From: Jason Garrett-Glaser Date: Wed, 30 Sep 2009 06:32:07 +0000 (-0700) Subject: Clip log2_max_frame_num X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=8be3935a8cef95fe94e0b054f3b6cb904a1f363a;p=x264.git Clip log2_max_frame_num 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. --- diff --git a/encoder/encoder.c b/encoder/encoder.c index c0b3b765..f2dbf703 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -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<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<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 ); diff --git a/encoder/set.c b/encoder/set.c index 5c00096d..2f7e7855 100644 --- a/encoder/set.c +++ b/encoder/set.c @@ -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 )