[x264-devel] commit: Merge nnz_backup with scratch buffer (Jason Garrett-Glaser )

git version control git at videolan.org
Sat Jan 30 13:58:00 CET 2010


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Thu Jan 21 10:00:07 2010 -0800| [90a249aa40deec9234f9ea7554deb8a418183094] | committer: Jason Garrett-Glaser 

Merge nnz_backup with scratch buffer
Slightly less memory usage.

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

 common/common.h     |    1 -
 common/frame.c      |    5 +++--
 common/macroblock.c |    2 --
 encoder/encoder.c   |    4 +++-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/common/common.h b/common/common.h
index 02d1748..df39f26 100644
--- a/common/common.h
+++ b/common/common.h
@@ -532,7 +532,6 @@ struct x264_t
         int8_t  *skipbp;                    /* block pattern for SKIP or DIRECT (sub)mbs. B-frames + cabac only */
         int8_t  *mb_transform_size;         /* transform_size_8x8_flag of each mb */
         uint8_t *intra_border_backup[2][3]; /* bottom pixels of the previous mb row, used for intra prediction after the framebuffer has been deblocked */
-        uint8_t (*nnz_backup)[16];          /* when using cavlc + 8x8dct, the deblocker uses a modified nnz */
 
          /* buffer for weighted versions of the reference frames */
         uint8_t *p_weight_buf[16];
diff --git a/common/frame.c b/common/frame.c
index 08ef87f..3ef303a 100644
--- a/common/frame.c
+++ b/common/frame.c
@@ -661,9 +661,10 @@ void x264_frame_deblock_row( x264_t *h, int mb_y )
     int stride2y  = stridey << b_interlaced;
     int strideuv  = h->fdec->i_stride[1];
     int stride2uv = strideuv << b_interlaced;
+    uint8_t (*nnz_backup)[16] = h->scratch_buffer;
 
     if( !h->pps->b_cabac && h->pps->b_transform_8x8_mode )
-        munge_cavlc_nnz( h, mb_y, h->mb.nnz_backup, munge_cavlc_nnz_row );
+        munge_cavlc_nnz( h, mb_y, nnz_backup, munge_cavlc_nnz_row );
 
     for( mb_x = 0; mb_x < h->sps->i_mb_width; mb_x += (~b_interlaced | mb_y)&1, mb_y ^= b_interlaced )
     {
@@ -823,7 +824,7 @@ void x264_frame_deblock_row( x264_t *h, int mb_y )
     }
 
     if( !h->pps->b_cabac && h->pps->b_transform_8x8_mode )
-        munge_cavlc_nnz( h, mb_y, h->mb.nnz_backup, restore_cavlc_nnz_row );
+        munge_cavlc_nnz( h, mb_y, nnz_backup, restore_cavlc_nnz_row );
 }
 
 void x264_frame_deblock( x264_t *h )
diff --git a/common/macroblock.c b/common/macroblock.c
index 921d2b9..10f09ac 100644
--- a/common/macroblock.c
+++ b/common/macroblock.c
@@ -701,7 +701,6 @@ int x264_macroblock_cache_init( x264_t *h )
 
     /* all coeffs */
     CHECKED_MALLOC( h->mb.non_zero_count, i_mb_count * 24 * sizeof(uint8_t) );
-    CHECKED_MALLOC( h->mb.nnz_backup, h->sps->i_mb_width * 4 * 16 * sizeof(uint8_t) );
 
     if( h->param.b_cabac )
     {
@@ -797,7 +796,6 @@ void x264_macroblock_cache_end( x264_t *h )
     }
     x264_free( h->mb.intra4x4_pred_mode );
     x264_free( h->mb.non_zero_count );
-    x264_free( h->mb.nnz_backup );
     x264_free( h->mb.mb_transform_size );
     x264_free( h->mb.skipbp );
     x264_free( h->mb.cbp );
diff --git a/encoder/encoder.c b/encoder/encoder.c
index f97df1b..db2c861 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -1018,7 +1018,9 @@ x264_t *x264_encoder_open( x264_param_t *param )
         int buf_tesa = (h->param.analyse.i_me_method >= X264_ME_ESA) *
             ((me_range*2+18) * sizeof(int16_t) + (me_range+4) * (me_range+1) * 4 * sizeof(mvsad_t));
         int buf_mbtree = h->param.rc.b_mb_tree * ((h->sps->i_mb_width+3)&~3) * sizeof(int);
-        CHECKED_MALLOC( h->thread[i]->scratch_buffer, X264_MAX4( buf_hpel, buf_ssim, buf_tesa, buf_mbtree ) );
+        int buf_nnz = !h->param.b_cabac * h->pps->b_transform_8x8_mode * (h->sps->i_mb_width * 4 * 16 * sizeof(uint8_t));
+        int scratch_size = X264_MAX4( buf_hpel, buf_ssim, buf_tesa, X264_MAX( buf_mbtree, buf_nnz ) );
+        CHECKED_MALLOC( h->thread[i]->scratch_buffer, scratch_size );
     }
 
     if( x264_ratecontrol_new( h ) < 0 )



More information about the x264-devel mailing list