💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## 音频同步 初步印象:播放的速度终于均匀了,不过感觉好快 话说,是按照视频同步的方案增加的函数 增加的大函数都是audio做文件名的。期望在下一轮阅读中再次分析 synchronize_audio ## 比较tutorial5 vs tutorial 6 结构有点乱 代码增加的大致有: ###选择同步的时钟接口函数 新添加了 double get_video_clock(VideoState *is) ~~~ double get_video_clock(VideoState *is) { double delta; delta = (av_gettime() - is->video_current_pts_time) / 1000000.0; return is->video_current_pts + delta; } double get_external_clock(VideoState *is) { return av_gettime() / 1000000.0; } double get_master_clock(VideoState *is) { if(is->av_sync_type == AV_SYNC_VIDEO_MASTER) { return get_video_clock(is); } else if(is->av_sync_type == AV_SYNC_AUDIO_MASTER) { return get_audio_clock(is); } else { return get_external_clock(is); } } ~~~ ### 重点移植 synchronize_audio 第二是,添加了类似于尚一章同步视频的函数:同步音频,这个函数期望反复阅读 鉴于重要性,分代码展示和代码分析两端 ~~~ int synchronize_audio(VideoState *is, short *samples, int samples_size, double pts) { int n; double ref_clock; n = 2 * is->audio_st->codec->channels; if(is->av_sync_type != AV_SYNC_AUDIO_MASTER) { double diff, avg_diff; int wanted_size, min_size, max_size, nb_samples; ref_clock = get_master_clock(is); diff = get_audio_clock(is) - ref_clock; if(diff < AV_NOSYNC_THRESHOLD) { // accumulate the diffs is->audio_diff_cum = diff + is->audio_diff_avg_coef * is->audio_diff_cum; if(is->audio_diff_avg_count < AUDIO_DIFF_AVG_NB) {//涉及到一个公式 is->audio_diff_avg_count++; } else { avg_diff = is->audio_diff_cum * (1.0 - is->audio_diff_avg_coef); if(fabs(avg_diff) >= is->audio_diff_threshold) { wanted_size = samples_size + ((int)(diff * is->audio_st->codec->sample_rate) * n); min_size = samples_size * ((100 - SAMPLE_CORRECTION_PERCENT_MAX) / 100); max_size = samples_size * ((100 + SAMPLE_CORRECTION_PERCENT_MAX) / 100); if(wanted_size < min_size) { wanted_size = min_size; } else if (wanted_size > max_size) { wanted_size = max_size; } if(wanted_size < samples_size) { /* remove samples */ samples_size = wanted_size; } else if(wanted_size > samples_size) { uint8_t *samples_end, *q; int nb; /* add samples by copying final sample*/ nb = (samples_size - wanted_size); samples_end = (uint8_t *)samples + samples_size - n; q = samples_end + n; while(nb > 0) { memcpy(q, samples_end, n); q += n; nb -= n; } samples_size = wanted_size; } } } } else { /* difference is TOO big; reset diff stuff */ is->audio_diff_avg_count = 0; is->audio_diff_cum = 0; } } return samples_size; } ~~~ 下面用突出 显示  展示我认为代码中的难点。 /* Add or subtract samples to get a better sync, return new audio buffer size */ int synchronize_audio(VideoState *is, short *samples, int samples_size, double pts) { int n; double ref_clock; n = 2 * is->audio_st->codec->channels; if(is->av_sync_type != AV_SYNC_AUDIO_MASTER) { double diff, avg_diff; int wanted_size, min_size, max_size, nb_samples; ref_clock = get_master_clock(is); diff = get_audio_clock(is) - ref_clock; if(diff < AV_NOSYNC_THRESHOLD) { // accumulate the diffs is->audio_diff_cum = diff + is->audio_diff_avg_coef * is->audio_diff_cum; if(is->audio_diff_avg_count < AUDIO_DIFF_AVG_NB) {//涉及到一个公式 is->audio_diff_avg_count++; } else { avg_diff = is->audio_diff_cum * (1.0 - is->audio_diff_avg_coef); //这一个函数都是理解的难点 if(fabs(avg_diff) >= is->audio_diff_threshold) { wanted_size = samples_size + ((int)(diff * is->audio_st->codec->sample_rate) * n); min_size = samples_size * ((100 - SAMPLE_CORRECTION_PERCENT_MAX) / 100); max_size = samples_size * ((100 + SAMPLE_CORRECTION_PERCENT_MAX) / 100); if(wanted_size < min_size) { wanted_size = min_size; } else if (wanted_size > max_size) { wanted_size = max_size; } if(wanted_size < samples_size) { /* remove samples */ samples_size = wanted_size; } else if(wanted_size > samples_size) { uint8_t *samples_end, *q; int nb; /* add samples by copying final sample*/ nb = (samples_size - wanted_size); samples_end = (uint8_t *)samples + samples_size - n; q = samples_end + n; while(nb > 0) { memcpy(q, samples_end, n); q += n; nb -= n; } samples_size = wanted_size; } } } } else { /* difference is TOO big; reset diff stuff */ is->audio_diff_avg_count = 0; is->audio_diff_cum = 0; } } return samples_size; } ### 变化最大的函数之audio_callback ~~~ void audio_callback(void *userdata, Uint8 *stream, int len) { VideoState *is = (VideoState *)userdata; int len1, audio_size; double pts; while(len > 0) { if(is->audio_buf_index >= is->audio_buf_size) { /* We have already sent all our data; get more */ audio_size = audio_decode_frame(is, is->audio_buf, sizeof(is->audio_buf), &pts); if(audio_size < 0) { /* If error, output silence */ is->audio_buf_size = 1024; memset(is->audio_buf, 0, is->audio_buf_size); } else { audio_size = synchronize_audio(is, (int16_t *)is->audio_buf, audio_size, pts); is->audio_buf_size = audio_size; } is->audio_buf_index = 0; } len1 = is->audio_buf_size - is->audio_buf_index; if(len1 > len) len1 = len; memcpy(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1); len -= len1; stream += len1; is->audio_buf_index += len1; } } ~~~ 以上是代码,这里附带两个版本的callback函数的对比图: ![](https://box.kancloud.cn/2016-02-22_56cae4b84da80.jpg) 可以看到终点修改的位置在解码后的处理。尤其注意红色的标示部分 对比视频同步的代码,主要在vedio_thread中。 ### 小结看代码思路 音频的入口,就是从回调函数看起,然后看到同步的函数 对比,视频,视频就是从线程看起,并且结合主函数的刷新定时器来看。 ## 代码实践 以下直接拿log分析:给出一次代码运行过程产生的输出,以后直接对应代码 ~~~ Function: synchronize_audio(VideoState *, short *, int, double), diff=0.027000000000000000 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= 0.027000000000000000 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=0 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 //这是一轮音频get 解码播放 的过程,round 0,相同的过程将会持续到round 18,变化请看下面的注释 //省略其中重复的18个 //这是第20次音频取样播放,20是认为设定的阈值(详细见宏定义);此时计算avg_diff,【】【】其实就是执行的另外一条代码覆盖; //并且第一次【注意,这是第一次】进入休整样本值的过程中,后续的代码执行结果:表示我们想让样本变小?? Function: synchronize_audio(VideoState *, short *, int, double), diff=-13.566370441424555 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -13.573071923920748 Function: synchronize_audio(VideoState *, short *, int, double), avg_diff=-9.2559631349317831e+061, 【when】is->audio_diff_avg_count:20 >10 // Function: synchronize_audio(VideoState *, short *, int, double), wanted_size < min_size :-216580 < 0 Function: synchronize_audio(VideoState *, short *, int, double), /* remove samples */ Function: audio_callback(void *, unsigned char *, int),auido_size= 0 ~~~ 初步印象:视频放完了,音频还没有放完。 **表格一:**audio_size**(**synchronize_audio**返回的值)** 比较一下老代码,这个值是多还是少? Todo:分析一下老版本的值多少? 可否从音频的波特率上分析下,一共20个,20*480 <table border="1" cellspacing="0" cellpadding="7" width="569"><colgroup><col width="553"/></colgroup><tbody><tr><td valign="top" width="553"><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 4: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 8: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 12: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 16: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 20: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 24: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 28: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 32: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 36: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 40: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 44: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 48: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 52: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 56: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 60: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 64: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 68: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 72: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 76: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 80: Function: audio_callback(void *, unsigned char *, int),auido_size= 480</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 86: Function: audio_callback(void *, unsigned char *, int),auido_size= 0</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 92: Function: audio_callback(void *, unsigned char *, int),auido_size= 0</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 98: Function: audio_callback(void *, unsigned char *, int),auido_size= 0</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 104: Function: audio_callback(void *, unsigned char *, int),auido_size= 0</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 110: Function: audio_callback(void *, unsigned char *, int),auido_size= 0</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 116: Function: audio_callback(void *, unsigned char *, int),auido_size= 0</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 122: Function: audio_callback(void *, unsigned char *, int),auido_size= 0</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 128: Function: audio_callback(void *, unsigned char *, int),auido_size= 0</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 134: Function: audio_callback(void *, unsigned char *, int),auido_size= 0</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 140: Function: audio_callback(void *, unsigned char *, int),auido_size= 0</span></span></span></p><p lang="zh-CN" align="left" style="margin-bottom:0cm"><span style="font-family:Times New Roman,serif"><span style="font-size:12px"><span lang="en-US">Line 146: Function: audio_callback(void *, unsigned char *, int),auido_size= 0</span></span></span></p><p lang="zh-CN" align="left"><br/></p></td></tr></tbody></table> ### 附件:完整的log分析记录: Function: synchronize_audio(VideoState *, short *, int, double), diff=0.027000000000000000 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= 0.027000000000000000 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=0 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 //这是一轮音频get解码 播放 的过程,round 0,相同的过程将会持续到round 18,变化请看下面的注释 Function: synchronize_audio(VideoState *, short *, int, double), diff=-0.14302037207122775 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -0.14300687207122775 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=1 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-0.33604274414245550 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -0.33611424757849112 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=2 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-0.50606311621368327 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -0.50623117333747247 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=3 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-0.67608448828491097 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -0.67633760387157971 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=4 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-10.821046860356137 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -10.821385029158073 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=5 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-10.991067232427365 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -10.996477924941944 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=6 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-11.173088604498595 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -11.178586843461066 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=7 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-11.343109976569822 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -11.348699269991553 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=8 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-11.565133348641048 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -11.570807698276043 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=9 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-11.735154720712277 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -11.740940124561416 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=10 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-11.905175092783505 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -11.911045562845786 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=11 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-12.076196464854734 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -12.082151987636157 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=12 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-12.277218836925961 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -12.283259912919778 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=13 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-12.447239208997187 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -12.453380838953647 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=14 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-12.639261581068416 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -12.645488271487892 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=15 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-12.856284953139644 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -12.862607697275388 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=16 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-13.028306325210870 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -13.034737629059508 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=17 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-13.225328697282098 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -13.231846066096628 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=18 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 Function: synchronize_audio(VideoState *, short *, int, double), diff=-13.396349069353327 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -13.402964992386377 Function: synchronize_audio(VideoState *, short *, int, double), audio_diff_avg_count=19 Function: audio_callback(void *, unsigned char *, int),auido_size= 480 //这是第20次音频取样播放,20是认为设定的阈值;此时计算avg_diff; //并且第一次【注意,这是第一次】进入休整样本值的过程中,后续的代码执行结果:表示我们想让样本变小?? Function: synchronize_audio(VideoState *, short *, int, double), diff=-13.566370441424555 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -13.573071923920748 Function: synchronize_audio(VideoState *, short *, int, double), avg_diff=-9.2559631349317831e+061,【when】is->audio_diff_avg_count:20 >10 // Function: synchronize_audio(VideoState *, short *, int, double), wanted_size < min_size:-216580 < 0 Function: synchronize_audio(VideoState *, short *, int, double), /* remove samples */ Function: audio_callback(void *, unsigned char *, int),auido_size= 0 Function: synchronize_audio(VideoState *, short *, int, double), diff=-13.836396813495783 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -13.843183349457744 Function: synchronize_audio(VideoState *, short *, int, double), avg_diff=-9.2559631349317831e+061,【when】is->audio_diff_avg_count:20 >10 Function: synchronize_audio(VideoState *, short *, int, double), wanted_size < min_size:-220902 < 0 Function: synchronize_audio(VideoState *, short *, int, double), /* remove samples */ Function: audio_callback(void *, unsigned char *, int),auido_size= 0 Function: synchronize_audio(VideoState *, short *, int, double), diff=-14.106423185567010 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -14.113344777241739 Function: synchronize_audio(VideoState *, short *, int, double), avg_diff=-9.2559631349317831e+061,【when】is->audio_diff_avg_count:20 >10 Function: synchronize_audio(VideoState *, short *, int, double), wanted_size < min_size:-225222 < 0 Function: synchronize_audio(VideoState *, short *, int, double), /* remove samples */ Function: audio_callback(void *, unsigned char *, int),auido_size= 0 Function: synchronize_audio(VideoState *, short *, int, double), diff=-14.376449557638237 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -14.383506230026859 Function: synchronize_audio(VideoState *, short *, int, double), avg_diff=-9.2559631349317831e+061,【when】is->audio_diff_avg_count:20 >10 Function: synchronize_audio(VideoState *, short *, int, double), wanted_size < min_size:-229542 < 0 Function: synchronize_audio(VideoState *, short *, int, double), /* remove samples */ Function: audio_callback(void *, unsigned char *, int),auido_size= 0 Function: synchronize_audio(VideoState *, short *, int, double), diff=-14.646475929709466 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -14.653667682824478 Function: synchronize_audio(VideoState *, short *, int, double), avg_diff=-9.2559631349317831e+061,【when】is->audio_diff_avg_count:20 >10 Function: synchronize_audio(VideoState *, short *, int, double), wanted_size < min_size:-233862 < 0 Function: synchronize_audio(VideoState *, short *, int, double), /* remove samples */ Function: audio_callback(void *, unsigned char *, int),auido_size= 0 Function: synchronize_audio(VideoState *, short *, int, double), diff=-14.926503301780693 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -14.933830135622106 Function: synchronize_audio(VideoState *, short *, int, double), avg_diff=-9.2559631349317831e+061,【when】is->audio_diff_avg_count:20 >10 Function: synchronize_audio(VideoState *, short *, int, double), wanted_size < min_size:-238344 < 0 Function: synchronize_audio(VideoState *, short *, int, double), /* remove samples */ Function: audio_callback(void *, unsigned char *, int),auido_size= 0 Function: synchronize_audio(VideoState *, short *, int, double), diff=-15.196529673851920 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -15.203996588919731 Function: synchronize_audio(VideoState *, short *, int, double), avg_diff=-9.2559631349317831e+061,【when】is->audio_diff_avg_count:20 >10 Function: synchronize_audio(VideoState *, short *, int, double), wanted_size < min_size:-242664 < 0 Function: synchronize_audio(VideoState *, short *, int, double), /* remove samples */ Function: audio_callback(void *, unsigned char *, int),auido_size= 0 Function: synchronize_audio(VideoState *, short *, int, double), diff=-15.466556045923149 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -15.474158044217608 Function: synchronize_audio(VideoState *, short *, int, double), avg_diff=-9.2559631349317831e+061,【when】is->audio_diff_avg_count:20 >10 Function: synchronize_audio(VideoState *, short *, int, double), wanted_size < min_size:-246984 < 0 Function: synchronize_audio(VideoState *, short *, int, double), /* remove samples */ Function: audio_callback(void *, unsigned char *, int),auido_size= 0 Function: synchronize_audio(VideoState *, short *, int, double), diff=-15.736582417994377 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -15.744319497016486 Function: synchronize_audio(VideoState *, short *, int, double), avg_diff=-9.2559631349317831e+061,【when】is->audio_diff_avg_count:20 >10 Function: synchronize_audio(VideoState *, short *, int, double), wanted_size < min_size:-251304 < 0 Function: synchronize_audio(VideoState *, short *, int, double), /* remove samples */ Function: audio_callback(void *, unsigned char *, int),auido_size= 0 Function: synchronize_audio(VideoState *, short *, int, double), diff=-16.040610790065607 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -16.048482949814115 Function: synchronize_audio(VideoState *, short *, int, double), avg_diff=-9.2559631349317831e+061,【when】is->audio_diff_avg_count:20 >10 Function: synchronize_audio(VideoState *, short *, int, double), wanted_size < min_size:-256168 < 0 Function: synchronize_audio(VideoState *, short *, int, double), /* remove samples */ Function: audio_callback(void *, unsigned char *, int),auido_size= 0 Function: synchronize_audio(VideoState *, short *, int, double), diff=-16.310638162136833 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -16.318662403611739 Function: synchronize_audio(VideoState *, short *, int, double), avg_diff=-9.2559631349317831e+061,【when】is->audio_diff_avg_count:20 >10 Function: synchronize_audio(VideoState *, short *, int, double), wanted_size < min_size:-260490 < 0 Function: synchronize_audio(VideoState *, short *, int, double), /* remove samples */ Function: audio_callback(void *, unsigned char *, int),auido_size= 0 Function: synchronize_audio(VideoState *, short *, int, double), diff=-16.582664534208060 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -16.590823865409867 Function: synchronize_audio(VideoState *, short *, int, double), avg_diff=-9.2559631349317831e+061,【when】is->audio_diff_avg_count:20 >10 Function: synchronize_audio(VideoState *, short *, int, double), wanted_size < min_size:-264842 < 0 Function: synchronize_audio(VideoState *, short *, int, double), /* remove samples */ Function: audio_callback(void *, unsigned char *, int),auido_size= 0 Function: synchronize_audio(VideoState *, short *, int, double), diff=-16.868691906279288 Function: synchronize_audio(VideoState *, short *, int, double), // accumulate the diffs= -16.876987318211992 Function: synchronize_audio(VideoState *, short *, int, double), avg_diff=-9.2559631349317831e+061,【when】is->audio_diff_avg_count:20 >10 Function: synchronize_audio(VideoState *, short *, int, double), wanted_size < min_size:-269418 < 0 Function: synchronize_audio(VideoState *, short *, int, double), /* remove samples */ Function: audio_callback(void *, unsigned char *, int),auido_size= 0 ## 小结 算法很重要 实践很重要 结合代码覆盖学习