现在的位置: 首页 > 综合 > 正文

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

2013年02月22日 ⁄ 综合 ⁄ 共 1813字 ⁄ 字号 评论关闭

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

 

/* 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 );
—————————————————————————————————————————
void x264_macroblock_encode( x264_t *h )
{
    ……
    /*SKIP片的处理*/
   if( h->mb.i_type == P_SKIP )
   {……}
   if( h->mb.i_type == B_SKIP )
   {……}
    /* quantification scale */
    if( h->mb.i_type == I_16x16 )
   {……
          /* do the right prediction */
         h->predict_16x16[i_mode]( h->mb.pic.p_fdec[0], h->mb.pic.i_stride[0] );
        /*我们看到h->predict_16x16[i_mode]( h->mb.pic.p_fdec[0], h->mb.pic.i_fdec[0] )只调用了一次,这是因为在x264_macroblock_analyse(  )中我们已经确定了采用4种方式中的哪种最合适。*/
         /* encode the 16x16 macroblock */
         x264_mb_encode_i16x16( h, i_qscale );
         /*在这个函数中可以看到量化、zig-扫描、反量化等函数了。包含:
sub16x16_dct、quant_4x4、scan_zigzag_4x4、x264_mb_dequant_4x4、dct4x4dc        scan_zigzag_4x4full、idct4x4dc、x264_mb_dequant_4x4_dc、add16x16_idct等函数*/
        /* fix the pred mode value */
   ……}
   else if( h->mb.i_type == I_4x4 )
  {
        for( i = 0; i < 16; i++ )
       {……
              x264_mb_encode_i4x4( h, i, i_qscale );
   ……}
   }
   else /* Inter MB */
  {……
       /* Motion compensation */
       x264_mb_mc( h );
       for( i8x8 = 0; i8x8 < 4; i8x8++ )
      {……
          /* encode one 4x4 block */
         ……
         /* decimate this 8x8 block */
    ……
         if( i_decimate_8x8 < 4 ){……}
         if( i_decimate_mb < 6 ){……}
         else
        {
              h->dctf.add16x16_idct( h->mb.pic.p_fdec[0], h->mb.pic.i_stride[0], dct4x4 );
         }//这部分的dedcimate,小徐老师提过。我对它没什么概念,以后再看看。(这一部分是这样的:残差X进行变换和量化后,检查宏块能量,如果太低的话(i_decimate_8x8 < 4及后面的i_decimate_mb < 6 ),可以将其值置为0。它们直接进行熵编码,不需要反量化和反变换了。而其他宏块除了要进行熵编码外,还需要反量化和反变换。)
    }
    /*以上都是亮度分析,下面开始色度分析了*/
    /* encode chroma */
  ……
    /* encode the 8x8 blocks */
    x264_mb_encode_8x8( h, !IS_INTRA( h->mb.i_type ), i_qscale );//对色度块进行编码了.
   /* 这个函数的for循环里面有个2,即对2个色度系数进行编码。*/
    /*下面的代码是计算cbp系数看需要对残差(包括ac,dc)中的哪个系数进行传输。*/
    /* Calculate the Luma/Chroma patern and non_zero_count */
  ……
    /* Calculate the chroma patern *///色度的cbp有3种方式.
  ……
    /* store cbp */
  ……
}
—————————————————————————————————————————
       TIMER_START( i_mtime_write );
        /*熵编码部分*/
        TIMER_STOP( i_mtime_write );

 

抱歉!评论已关闭.