From: Jason Garrett-Glaser Date: Tue, 16 Aug 2011 20:02:24 +0000 (-0700) Subject: Avoid some unnecessary allocations with B-frames/CABAC off X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=6881f2475a98dca0de8b33e18223d9341f90fb12;p=x264.git Avoid some unnecessary allocations with B-frames/CABAC off --- diff --git a/common/macroblock.c b/common/macroblock.c index 2a65dc23..6b5779e2 100644 --- a/common/macroblock.c +++ b/common/macroblock.c @@ -247,7 +247,6 @@ int x264_macroblock_cache_allocate( x264_t *h ) CHECKED_MALLOC( h->mb.qp, i_mb_count * sizeof(int8_t) ); CHECKED_MALLOC( h->mb.cbp, i_mb_count * sizeof(int16_t) ); - CHECKED_MALLOC( h->mb.skipbp, i_mb_count * sizeof(int8_t) ); CHECKED_MALLOC( h->mb.mb_transform_size, i_mb_count * sizeof(int8_t) ); CHECKED_MALLOC( h->mb.slice_table, i_mb_count * sizeof(uint16_t) ); memset( h->mb.slice_table, -1, i_mb_count * sizeof(uint16_t) ); @@ -260,9 +259,11 @@ int x264_macroblock_cache_allocate( x264_t *h ) if( h->param.b_cabac ) { + CHECKED_MALLOC( h->mb.skipbp, i_mb_count * sizeof(int8_t) ); CHECKED_MALLOC( h->mb.chroma_pred_mode, i_mb_count * sizeof(int8_t) ); CHECKED_MALLOC( h->mb.mvd[0], i_mb_count * sizeof( **h->mb.mvd ) ); - CHECKED_MALLOC( h->mb.mvd[1], i_mb_count * sizeof( **h->mb.mvd ) ); + if( h->param.i_bframe ) + CHECKED_MALLOC( h->mb.mvd[1], i_mb_count * sizeof( **h->mb.mvd ) ); } for( int i = 0; i < 2; i++ ) @@ -329,6 +330,7 @@ void x264_macroblock_cache_free( x264_t *h ) if( h->param.b_cabac ) { + x264_free( h->mb.skipbp ); x264_free( h->mb.chroma_pred_mode ); x264_free( h->mb.mvd[0] ); x264_free( h->mb.mvd[1] ); @@ -337,7 +339,6 @@ void x264_macroblock_cache_free( x264_t *h ) x264_free( h->mb.intra4x4_pred_mode ); x264_free( h->mb.non_zero_count ); x264_free( h->mb.mb_transform_size ); - x264_free( h->mb.skipbp ); x264_free( h->mb.cbp ); x264_free( h->mb.qp ); }