]> granicus.if.org Git - libx264/commitdiff
compute missing nnz count in subme7 cavlc
authorFiona Glaser <fiona@x264.com>
Sat, 26 Apr 2008 02:43:57 +0000 (20:43 -0600)
committerLoren Merritt <pengvado@akuvian.org>
Sun, 27 Apr 2008 08:40:52 +0000 (02:40 -0600)
encoder/cavlc.c

index 6ccbfdbb2ca42bcc59c7f4374f42779ae273ea26..54bc567ece6ab7844fde278bdc12fea1c82f8a98 100644 (file)
@@ -282,18 +282,17 @@ static inline void x264_macroblock_luma_write_cavlc( x264_t *h, bs_t *s, int i8s
         for( i8 = i8start; i8 <= i8end; i8++ )
             if( h->mb.i_cbp_luma & (1 << i8) )
                 for( i4 = 0; i4 < 4; i4++ )
-                {
                     for( i = 0; i < 16; i++ )
                         h->dct.luma4x4[i4+i8*4][i] = h->dct.luma8x8[i8][i4+i*4];
-                    h->mb.cache.non_zero_count[x264_scan8[i4+i8*4]] =
-                        array_non_zero_count( h->dct.luma4x4[i4+i8*4], 16 );
-                }
     }
 
     for( i8 = i8start; i8 <= i8end; i8++ )
         if( h->mb.i_cbp_luma & (1 << i8) )
             for( i4 = 0; i4 < 4; i4++ )
+            {
+                h->mb.cache.non_zero_count[x264_scan8[i4+i8*4]] = array_non_zero_count( h->dct.luma4x4[i4+i8*4], 16 );
                 block_residual_write_cavlc( h, s, i4+i8*4, h->dct.luma4x4[i4+i8*4], 16 );
+            }
 }
 
 /*****************************************************************************
@@ -646,7 +645,10 @@ void x264_macroblock_write_cavlc( x264_t *h, bs_t *s )
         /* AC Luma */
         if( h->mb.i_cbp_luma != 0 )
             for( i = 0; i < 16; i++ )
+            {
+                h->mb.cache.non_zero_count[x264_scan8[i]] = array_non_zero_count( h->dct.luma4x4[i]+1, 15 );
                 block_residual_write_cavlc( h, s, i, h->dct.luma4x4[i]+1, 15 );
+            }
     }
     else if( h->mb.i_cbp_luma != 0 || h->mb.i_cbp_chroma != 0 )
     {
@@ -660,7 +662,10 @@ void x264_macroblock_write_cavlc( x264_t *h, bs_t *s )
         block_residual_write_cavlc( h, s, BLOCK_INDEX_CHROMA_DC, h->dct.chroma_dc[1], 4 );
         if( h->mb.i_cbp_chroma&0x02 ) /* Chroma AC residual present */
             for( i = 16; i < 24; i++ )
+            {
+                h->mb.cache.non_zero_count[x264_scan8[i]] = array_non_zero_count( h->dct.luma4x4[i]+1, 15 );
                 block_residual_write_cavlc( h, s, i, h->dct.luma4x4[i]+1, 15 );
+            }
     }
 
 #ifndef RDO_SKIP_BS
@@ -725,10 +730,10 @@ int x264_partition_size_cavlc( x264_t *h, int i8, int i_pixel )
     for( j = (i_pixel < PIXEL_8x8); j >= 0; j-- )
     {
         x264_macroblock_luma_write_cavlc( h, &s, i8, i8 );
-
+        h->mb.cache.non_zero_count[x264_scan8[16+i8]] = array_non_zero_count( h->dct.luma4x4[16+i8]+1, 15 );
         block_residual_write_cavlc( h, &s, 16+i8, h->dct.luma4x4[16+i8]+1, 15 );
+        h->mb.cache.non_zero_count[x264_scan8[20+i8]] = array_non_zero_count( h->dct.luma4x4[20+i8]+1, 15 );
         block_residual_write_cavlc( h, &s, 20+i8, h->dct.luma4x4[20+i8]+1, 15 );
-
         i8 += x264_pixel_size[i_pixel].h >> 3;
     }
 
@@ -777,7 +782,10 @@ static int x264_i8x8_chroma_size_cavlc( x264_t *h )
         {
             int i;
             for( i = 16; i < 24; i++ )
+            {
+                h->mb.cache.non_zero_count[x264_scan8[i]] = array_non_zero_count( h->dct.luma4x4[i]+1, 15 );
                 block_residual_write_cavlc( h, &h->out.bs, i, h->dct.luma4x4[i]+1, 15 );
+            }
         }
     }
     return h->out.bs.i_bits_encoded;