x264_macroblock_analyse模块分析-2
来源:互联网 发布:人工智能定理证明 编辑:程序博客网 时间:2024/05/16 09:46
2、static inline int x264_macroblock_probe_pskip( x264_t *h )
该函数直接调用了x264_macroblock_probe_skip(h, 0);看看里边有什么东东。
if( !b_bidir ) { x264_mb_predict_mv_pskip( h, mvp ); mvp[0] = x264_clip3( mvp[0], h->mb.mv_min[0], h->mb.mv_max[0] ); mvp[1] = x264_clip3( mvp[1], h->mb.mv_min[1], h->mb.mv_max[1] ); h->mc.mc_luma( h->mb.pic.p_fref[0][0], h->mb.pic.i_stride[0], h->mb.pic.p_fdec[0], FDEC_STRIDE, mvp[0], mvp[1], 16, 16 ); }先得到预测矢量MVp,然后对MVp进行饱和处理,再进行相应的运动补偿。h->dctf.sub16x16_dct( dct4x4, h->mb.pic.p_fenc[0], FENC_STRIDE, h->mb.pic.p_fdec[0], FDEC_STRIDE );for( i8x8 = 0, i_decimate_mb = 0; i8x8 < 4; i8x8++ ) { /* encode one 4x4 block */ for( i4x4 = 0; i4x4 < 4; i4x4++ ) { const int idx = i8x8 * 4 + i4x4; quant_4x4( h, dct4x4[idx], (int(*)[4][4])def_quant4_mf, i_qp, 0 ); scan_zigzag_4x4full( dctscan, dct4x4[idx] ); i_decimate_mb += x264_mb_decimate_score( dctscan, 16 ); if( i_decimate_mb >= 6 ) { /* not as P_SKIP */ return 0; } } }
进行dct变换(注意是4×4变换,不是8×8!!!),然后对每个8×8块中的4×4对进行量化,zigzag扫描,得到8×8块的i_decimate_mb值。如果量化后系数中只有零星的非零系数,且都是1或-1,i_decimate_mb就比较小。if(i_decimate_mb<6),可以将系数全变为0。注意,其他模式下的残差编码也用到了该处理过程。
程序后面是对色度进行处理,与亮度类似,不进行讨论。
3、static void x264_mb_analyse_inter_p16x16 ( x264_t *h, x264_mb_analysis_t *a )
直接看核心吧
for( i_ref = 0; i_ref < h->i_ref0; i_ref++ ) {//循环搜索搜索每个参考帧x264_mb_predict_mv_16x16( h, 0, i_ref, m.mvp );//得到MVp,x264_mb_predict_mv_ref16x16( h, 0, i_ref, mvc, &i_mvc );得到邻块的MV、前一帧对应位置的MV,可用来预测搜索起点,加速运动估计。x264_me_search_ref( h, &m, mvc, i_mvc, p_halfpel_thresh );///动估计函数。下面将详细讨论//再接着就是一个多参考帧的中止判断,略。
4、void x264_me_search_ref( x264_t *h, x264_me_t *m, int (*mvc)[2], int i_mvc, int *p_halfpel_thresh )
bmx = pmx = x264_clip3( ( m->mvp[0] + 2 ) >> 2, mv_x_min, mv_x_max ); bmy = pmy = x264_clip3( ( m->mvp[1] + 2 ) >> 2, mv_y_min, mv_y_max ); bcost = COST_MAX; COST_MV( pmx, pmy ); bcost -= p_cost_mvx[ bmx<<2 ] + p_cost_mvy[ bmy<<2 ]; for( i = 0; i < i_mvc; i++ ) { const int mx = x264_clip3( ( mvc[i][0] + 2 ) >> 2, mv_x_min, mv_x_max ); const int my = x264_clip3( ( mvc[i][1] + 2 ) >> 2, mv_y_min, mv_y_max ); if( mx != bmx || my != bmy ) COST_MV( mx, my ); } COST_MV( 0, 0 );
先检测MVp点,再检测其他预测矢量,最后检测原点(0,0)。注意mvp[0
]保留的是1/4精度,所以除以4就变成了整象素精度。
然后就是具体的搜索算法。代码不贴,直接解释吧。^_^
case 菱形搜索:用小菱形模板反复搜索。菱形算法还有大模板搜索,这里没用到。
case 六边形:先用六边形模板反复搜索,粗匹配。
case UMHexagonS:看我主页中的注释,呵呵,是基于JM9.5的。
case 连续消除法(SEA) 全搜索法的快速运算。这里不介绍了。
if( h->mb.i_subpel_refine >= 2 ) { int hpel = subpel_iterations[h->mb.i_subpel_refine][2]; int qpel = subpel_iterations[h->mb.i_subpel_refine][3]; refine_subpel( h, m, hpel, qpel, p_halfpel_thresh, 0 ); }//亚象素搜索,在x264_macroblock_analyse()函数我已经介绍过了
- x264_macroblock_analyse模块分析-2
- x264_macroblock_analyse模块分析
- [转贴]x264_macroblock_analyse模块分析
- x264_macroblock_analyse模块分析
- x264_macroblock_analyse模块分析-3
- X264中x264_macroblock_analyse模块分析
- x264代码追踪之x264_macroblock_analyse模块分析
- x264_macroblock_analyse(x264_t *h ) 分析
- x264_macroblock_analyse(x264_t *h ) 分析
- x264_macroblock_analyse(x264_t *h ) 分析
- x264代码剖析(十一):核心算法之宏块分析函数x264_macroblock_analyse()
- OVS vswitchd 模块分析(2)
- 请假模块工作流分析(2)
- 麻将网络模块分析2
- linux 模块Makefile 分析2
- Linux 时钟模块分析2
- Jforum中索引模块的分析(2)
- gloox代码分析2 - xml parser模块
- IN OUT NOCOPY 分析
- 程序的内存分配问题
- C++ 增强型方法
- Windows Server时间服务器配置方法
- 使用sitemesh建立复合视图 - 1.hello
- x264_macroblock_analyse模块分析-2
- 用NMAKE创建VS2012 C++工程二 创建目录结构
- BT 协议调用流程
- tips for using maven and testng/junit
- jquery dialog
- Debug和Release区别
- 如何快速接手一个项目(内部项目或开源项目)
- java发起http请求提交表单
- android屏幕适配2