]> git.sesse.net Git - x264/commitdiff
Clip log2_max_frame_num
authorFiona Glaser <fiona@x264.com>
Wed, 30 Sep 2009 06:32:07 +0000 (23:32 -0700)
committerFiona Glaser <fiona@x264.com>
Wed, 7 Oct 2009 00:24:02 +0000 (17:24 -0700)
It's still much higher than it needs to be, but that will be fixed with the upcoming MMCO patch.
Also make sure we don't write too large a frame_num or poc in slice header.

encoder/encoder.c
encoder/set.c

index 6c66c80e8b9ed4fbf7b4a00b8c5d73d37a210ab5..080a259e28fe4ed052d8a83477b2ab6a93dff929 100644 (file)
@@ -175,7 +175,7 @@ static void x264_slice_header_write( bs_t *s, x264_slice_header_t *sh, int i_nal
 
     bs_write_ue( s, sh->i_type + 5 );   /* same type things */
     bs_write_ue( s, sh->i_pps_id );
-    bs_write( s, sh->sps->i_log2_max_frame_num, sh->i_frame_num );
+    bs_write( s, sh->sps->i_log2_max_frame_num, sh->i_frame_num & ((1<<sh->sps->i_log2_max_frame_num)-1) );
 
     if( !sh->sps->b_frame_mbs_only )
     {
@@ -191,7 +191,7 @@ static void x264_slice_header_write( bs_t *s, x264_slice_header_t *sh, int i_nal
 
     if( sh->sps->i_poc_type == 0 )
     {
-        bs_write( s, sh->sps->i_log2_max_poc_lsb, sh->i_poc_lsb );
+        bs_write( s, sh->sps->i_log2_max_poc_lsb, sh->i_poc_lsb & ((1<<sh->sps->i_log2_max_poc_lsb)-1) );
         if( sh->pps->b_pic_order && !sh->b_field_pic )
         {
             bs_write_se( s, sh->i_delta_poc_bottom );
index 5c00096d253c869848ae13f7b2335d72ee91c2f1..2f7e7855e57f03913e75380ee43c873e12aa3007 100644 (file)
@@ -97,11 +97,9 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )
     sps->b_constraint_set2  = 0;
 
     sps->i_log2_max_frame_num = 4;  /* at least 4 */
-    while( (1 << sps->i_log2_max_frame_num) <= param->i_keyint_max )
-    {
+    while( (1 << sps->i_log2_max_frame_num) <= param->i_keyint_max && sps->i_log2_max_frame_num < 10 )
         sps->i_log2_max_frame_num++;
-    }
-    sps->i_log2_max_frame_num++;    /* just in case */
+    sps->i_log2_max_frame_num++;
 
     sps->i_poc_type = 0;
     if( sps->i_poc_type == 0 )