[x264-devel] commit: Add decimation in i16x16 blocks (Jason Garrett-Glaser )

git version control git at videolan.org
Mon Feb 9 11:32:49 CET 2009


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Sun Feb  8 23:36:40 2009 -0800| [0ee50db35db3e5af0d40936dbc5ff7e2478b1a2c] | committer: Jason Garrett-Glaser 

Add decimation in i16x16 blocks
Up to +0.04db with CAVLC, generally a lot less with CABAC.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=0ee50db35db3e5af0d40936dbc5ff7e2478b1a2c
---

 encoder/macroblock.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/encoder/macroblock.c b/encoder/macroblock.c
index f1cb0ab..73cc597 100644
--- a/encoder/macroblock.c
+++ b/encoder/macroblock.c
@@ -190,6 +190,8 @@ static void x264_mb_encode_i16x16( x264_t *h, int i_qp )
     DECLARE_ALIGNED_16( int16_t dct_dc4x4[4][4] );
 
     int i, nz;
+    int b_decimate = h->sh.i_type == SLICE_TYPE_B || (h->param.analyse.b_dct_decimate && h->sh.i_type == SLICE_TYPE_P);
+    int decimate_score = b_decimate ? 0 : 9;
 
     if( h->mb.b_lossless )
     {
@@ -225,10 +227,22 @@ static void x264_mb_encode_i16x16( x264_t *h, int i_qp )
         {
             h->zigzagf.scan_4x4( h->dct.luma4x4[i], dct4x4[i] );
             h->quantf.dequant_4x4( dct4x4[i], h->dequant4_mf[CQM_4IY], i_qp );
+            if( decimate_score < 6 ) decimate_score += h->quantf.decimate_score15( h->dct.luma4x4[i] );
             h->mb.i_cbp_luma = 0xf;
         }
     }
 
+    /* Writing the 16 CBFs in an i16x16 block is quite costly, so decimation can save many bits. */
+    /* More useful with CAVLC, but still useful with CABAC. */
+    if( decimate_score < 6 )
+    {
+        h->mb.i_cbp_luma = 0;
+        *(uint32_t*)&h->mb.cache.non_zero_count[x264_scan8[ 0]] = 0;
+        *(uint32_t*)&h->mb.cache.non_zero_count[x264_scan8[ 2]] = 0;
+        *(uint32_t*)&h->mb.cache.non_zero_count[x264_scan8[ 8]] = 0;
+        *(uint32_t*)&h->mb.cache.non_zero_count[x264_scan8[10]] = 0;
+    }
+
     h->dctf.dct4x4dc( dct_dc4x4 );
     if( h->mb.b_trellis )
         nz = x264_quant_dc_trellis( h, (int16_t*)dct_dc4x4, CQM_4IY, i_qp, DCT_LUMA_DC, 1);



More information about the x264-devel mailing list