X264源程序分析(x264_slice_write)——学习笔记(2)

来源:互联网 发布:广电网络集团前景 编辑:程序博客网 时间:2024/04/29 07:50

//   http://auraleo.blog.sohu.com/10119199.html

 

  TIMER_START( i_mtime_analyse );  x264_macroblock_analyse( h );//通过一系列的SAD算出最优方案。  TIMER_STOP( i_mtime_analyse );  —————————————————————————————————————————  void x264_macroblock_analyse( x264_t *h )  {   /*--------------------------- Do the analysis ---------------------------*/  if( h->sh。i_type == SLICE_TYPE_I )  {  /*帧内预测分析(亮度)。Try all mode and calculate their score。  Include: 16x16 prediction selection &  4x4 prediction selection */  x264_mb_analyse_intra( h, &analysis, COST_MAX );  ——————————————————————————  static void x264_mb_analyse_intra( x264_t *h, x264_mb_analysis_t *res, int i_cost_inter )  {     ……  predict_16x16_mode_available( h->mb。i_neighbour, predict_mode, &i_max );  //根据是否存在top或left值,确定使用什么预测模式(16*16亮度预测模式)  predict_4x4_mode_available( h->mb。i_neighbour, idx, predict_mode, &i_max );  //根据是否存在top或left值,确定使用什么预测模式(4*4亮度预测模式)  }  ——————————————————————————  if( analysis。i_sad_i4x4 < analysis。i_sad_i16x16 )h->mb。i_type = I_4x4;  else h->mb。i_type = I_16x16;  }  else if( h->sh。i_type == SLICE_TYPE_P )  {   ……  /* Fast P_SKIP detection *///判断是不是SKIP块  if( ( (i_neighbour&MB_LEFT) && h->mb。type[h->mb。i_mb_xy - 1] == P_SKIP ) ||  ( (i_neighbour&MB_TOP) && h->mb。type[h->mb。i_mb_xy - h->mb。i_mb_stride] == P_SKIP ) ||  ( ((i_neighbour&(MB_TOP|MB_LEFT)) == (MB_TOP|MB_LEFT) ) && h->mb。type[h->mb。i_mb_xy - h-                              >mb。i_mb_stride-1 ] == P_SKIP ) ||  ( (i_neighbour&MB_TOPRIGHT) && h->mb。type[h->mb。i_mb_xy - h->mb。i_mb_stride+1 ] == P_SKIP ) )  {b_skip = x264_macroblock_probe_pskip( h ); }  if( b_skip )  {  h->mb。i_type = P_SKIP;  h->mb。i_partition = D_16x16;  }  else//Direct块  {    ……  x264_mb_analyse_load_costs( h, &analysis );  //帧间预测 /* Select best inter mode */ /*16*16、16*8、8*16、8*8、8*4、4*8、4*4*/……  /* refine qpel *//*帧间模式选择后,对该模式进行亚象素精细搜索。以进一步减少误差。注意,在前面每个模式的检测时,也要进行亚象素搜索(包括半象素和1/4象素)。我怎么觉得好像只有16*16的帧间模式检测中用到了亚像素的搜索呢(主要是这两个函数:x264_mb_predict_mv_ref16x16( h, 0, i_ref, mvc, &i_mvc ); x264_me_search_ref( h, &m, mvc, i_mvc, p_fullpel_thresh );)?*/  //帧内预测(亮度)  x264_mb_analyse_intra( h, &analysis, i_cost );  if( h->mb。b_chroma_me && ( analysis。i_sad_i16x16 < i_cost|| ( analysis。i_sad_i4x4 < i_cost )))  {    //满足条件后进行色度的帧内预测  x264_mb_analyse_intra_chroma( h, &analysis );  analysis。i_sad_i16x16 += analysis。i_sad_i8x8;  analysis。i_sad_i4x4 += analysis。i_sad_i8x8;  }/*亮度代价分别存在analysis。i_sad_i16x16/i8x8/i4x4中,色度代价存在analysis。i_sad_i8x8chroma中。*/  else if( h->sh。i_type == SLICE_TYPE_B )     ……  /*-------------------- Update MB from the analysis ----------------------*/  /*根据上述所判断的结果,进行详细的帧内或帧间预测*/ }  —————————————————————————————————————————  /* encode this macrobock -> be carefull it can change the mb type to P_SKIP if needed */  TIMER_START( i_mtime_encode );  x264_macroblock_encode( h );  TIMER_STOP( i_mtime_encode );


 

原创粉丝点击