with B-pyramid, forget old refs in POC order instead of coded order.
authorLoren Merritt <pengvado@videolan.org>
Tue, 27 Sep 2005 19:59:09 +0000 (19:59 +0000)
committerLoren Merritt <pengvado@videolan.org>
Tue, 27 Sep 2005 19:59:09 +0000 (19:59 +0000)
(before, b_skip was unavailable with pyramid and ref=1)

git-svn-id: svn://svn.videolan.org/x264/trunk@305 df754926-b1dd-0310-bc7b-ec298dee348c

common/macroblock.c
encoder/encoder.c
encoder/set.c

index f0f81da..014b41b 100644 (file)
@@ -977,8 +977,8 @@ void x264_macroblock_cache_init( x264_t *h )
 
     for( i=0; i<2; i++ )
     {
-        int i_refs = i ? 1 + h->param.b_bframe_pyramid : h->param.i_frame_reference;
-        for( j=0; j < i_refs; j++ )
+        int i_refs = (i ? 1 : h->param.i_frame_reference) + h->param.b_bframe_pyramid;
+        for( j=0; j < i_refs && j < 16; j++ )
             h->mb.mvr[i][j] = x264_malloc( 2 * i_mb_count * sizeof( int16_t ) );
     }
 
index 97adeb9..caccf66 100644 (file)
@@ -315,7 +315,6 @@ static void x264_slice_header_write( bs_t *s, x264_slice_header_t *sh, int i_nal
         else
         {
             bs_write1( s, 0 );  /* adaptive_ref_pic_marking_mode_flag */
-            /* FIXME */
         }
     }
 
@@ -403,11 +402,6 @@ static int x264_validate_parameters( x264_t *h )
     h->param.i_bframe = x264_clip3( h->param.i_bframe, 0, X264_BFRAME_MAX );
     h->param.i_bframe_bias = x264_clip3( h->param.i_bframe_bias, -90, 100 );
     h->param.b_bframe_pyramid = h->param.b_bframe_pyramid && h->param.i_bframe > 1;
-    h->frames.i_delay = h->param.i_bframe;
-    h->frames.i_max_ref0 = h->param.i_frame_reference;
-    h->frames.i_max_ref1 = h->param.b_bframe_pyramid ? 2
-                            : h->param.i_bframe ? 1 : 0;
-    h->frames.i_max_dpb = X264_MIN( 16, h->frames.i_max_ref0 + h->frames.i_max_ref1 ) + 1;
 
     h->param.i_deblocking_filter_alphac0 = x264_clip3( h->param.i_deblocking_filter_alphac0, -6, 6 );
     h->param.i_deblocking_filter_beta    = x264_clip3( h->param.i_deblocking_filter_beta, -6, 6 );
@@ -544,6 +538,11 @@ x264_t *x264_encoder_open   ( x264_param_t *param )
     h->mb.i_mb_count = h->sps->i_mb_width * h->sps->i_mb_height;
 
     /* Init frames. */
+    h->frames.i_delay = h->param.i_bframe;
+    h->frames.i_max_ref0 = h->param.i_frame_reference;
+    h->frames.i_max_ref1 = h->sps->vui.i_num_reorder_frames;
+    h->frames.i_max_dpb  = h->sps->vui.i_max_dec_frame_buffering + 1;
+
     for( i = 0; i < X264_BFRAME_MAX + 3; i++ )
     {
         h->frames.current[i] = NULL;
@@ -851,7 +850,6 @@ static inline void x264_reference_update( x264_t *h )
         h->frames.last_nonb = h->fdec;
 
     /* move frame in the buffer */
-    /* FIXME: override to forget earliest pts, not earliest dts */
     h->fdec = h->frames.reference[h->frames.i_max_dpb-1];
     for( i = h->frames.i_max_dpb-1; i > 0; i-- )
     {
index 212bdb0..5afd733 100644 (file)
@@ -113,8 +113,10 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )
     }
 
     sps->vui.i_num_reorder_frames = param->b_bframe_pyramid ? 2 : param->i_bframe ? 1 : 0;
+    /* extra slot with pyramid so that we don't have to override the
+     * order of forgetting old pictures */
     sps->vui.i_max_dec_frame_buffering =
-    sps->i_num_ref_frames = X264_MIN(16, param->i_frame_reference + sps->vui.i_num_reorder_frames);
+    sps->i_num_ref_frames = X264_MIN(16, param->i_frame_reference + sps->vui.i_num_reorder_frames + param->b_bframe_pyramid);
 
     sps->b_gaps_in_frame_num_value_allowed = 0;
     sps->i_mb_width = ( param->i_width + 15 ) / 16;