From 5394872fcdde4c29a66d3e7902dca03c3b941947 Mon Sep 17 00:00:00 2001 From: James Darnley Date: Thu, 9 Jul 2009 11:25:55 -0700 Subject: [PATCH] Fix bug in reference frame autoadjustment For some types of input file, x264 did the adjustment before width/height were known. --- x264.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/x264.c b/x264.c index e79f9acc..91d2ca15 100644 --- a/x264.c +++ b/x264.c @@ -822,24 +822,6 @@ generic_option: param->analyse.i_trellis = 0; } - /* Automatically reduce reference frame count to match the user's target level - * if the user didn't explicitly set a reference frame count. */ - if( !b_user_ref ) - { - int mbs = (((param->i_width)+15)>>4) * (((param->i_height)+15)>>4); - int i; - for( i = 0; x264_levels[i].level_idc != 0; i++ ) - if( param->i_level_idc == x264_levels[i].level_idc ) - { - while( mbs * 384 * param->i_frame_reference > x264_levels[i].dpb - && param->i_frame_reference > 1 ) - { - param->i_frame_reference--; - } - break; - } - } - /* Apply profile restrictions. */ if( profile ) { @@ -972,6 +954,26 @@ generic_option: } #endif + + /* Automatically reduce reference frame count to match the user's target level + * if the user didn't explicitly set a reference frame count. */ + if( !b_user_ref ) + { + int mbs = (((param->i_width)+15)>>4) * (((param->i_height)+15)>>4); + int i; + for( i = 0; x264_levels[i].level_idc != 0; i++ ) + if( param->i_level_idc == x264_levels[i].level_idc ) + { + while( mbs * 384 * param->i_frame_reference > x264_levels[i].dpb + && param->i_frame_reference > 1 ) + { + param->i_frame_reference--; + } + break; + } + } + + return 0; } -- 2.40.0