combined L0 & L1 reference lists are limited to a total of 16 pics.
authorLoren Merritt <pengvado@videolan.org>
Tue, 19 Apr 2005 23:09:29 +0000 (23:09 +0000)
committerLoren Merritt <pengvado@videolan.org>
Tue, 19 Apr 2005 23:09:29 +0000 (23:09 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@214 df754926-b1dd-0310-bc7b-ec298dee348c

encoder/encoder.c
encoder/set.c

index 39c5f1c..0075f04 100644 (file)
@@ -383,7 +383,7 @@ x264_t *x264_encoder_open   ( x264_param_t *param )
     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 = h->frames.i_max_ref0 + h->frames.i_max_ref1 + 1;
+    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 );
@@ -723,8 +723,9 @@ static inline void x264_reference_build_list( x264_t *h, int i_poc, int i_slice_
             }
     }
 
-    h->i_ref0 = X264_MIN( h->i_ref0, h->frames.i_max_ref0 );
     h->i_ref1 = X264_MIN( h->i_ref1, h->frames.i_max_ref1 );
+    h->i_ref0 = X264_MIN( h->i_ref0, h->frames.i_max_ref0 );
+    h->i_ref0 = X264_MIN( h->i_ref0, 16 - h->i_ref1 );
 }
 
 static inline void x264_reference_update( x264_t *h )
index e9a5e3c..d8a8027 100644 (file)
@@ -33,9 +33,8 @@
 #include <math.h>
 
 #include "x264.h"
-#include "common/bs.h"
-#include "common/set.h"
 #include "config.h"
+#include "common/common.h"
 
 void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )
 {
@@ -79,11 +78,10 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )
         }
     }
 
-    sps->i_num_ref_frames = param->i_frame_reference;
-    if( param->i_bframe )
-        sps->i_num_ref_frames++; /* for backwards ref in B */
-    if( param->b_bframe_pyramid )
-        sps->i_num_ref_frames++; /* for 2nd backwards ref */
+    sps->vui.i_num_reorder_frames = param->b_bframe_pyramid ? 2 : param->i_bframe ? 1 : 0;
+    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 + 1);
+
     sps->b_gaps_in_frame_num_value_allowed = 0;
     sps->i_mb_width = ( param->i_width + 15 ) / 16;
     sps->i_mb_height= ( param->i_height + 15 )/ 16;
@@ -143,8 +141,6 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )
         sps->vui.i_max_bits_per_mb_denom = 0;
         sps->vui.i_log2_max_mv_length_horizontal =
         sps->vui.i_log2_max_mv_length_vertical = (int)(log(param->analyse.i_mv_range*4-1)/log(2)) + 1;
-        sps->vui.i_num_reorder_frames = param->b_bframe_pyramid ? 2 : param->i_bframe ? 1 : 0;
-        sps->vui.i_max_dec_frame_buffering = param->i_frame_reference + sps->vui.i_num_reorder_frames + 1;
     }
     sps->b_vui |= sps->vui.b_bitstream_restriction;
 }