]> granicus.if.org Git - libx264/commitdiff
Avoid some unnecessary allocations with B-frames/CABAC off
authorFiona Glaser <fiona@x264.com>
Tue, 16 Aug 2011 20:02:24 +0000 (13:02 -0700)
committerFiona Glaser <fiona@x264.com>
Wed, 24 Aug 2011 17:23:14 +0000 (10:23 -0700)
common/macroblock.c

index 9f97aa0c047e1171e74b193942eb4162475c1718..9eb3b59562abdb86e98b5959551481095a552615 100644 (file)
@@ -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 );
 }