From ae9023a3c915a95e13e96721888b174d68c83553 Mon Sep 17 00:00:00 2001 From: Paul Wilkins <paulwilkins@google.com> Date: Mon, 12 Dec 2011 11:18:57 +0000 Subject: [PATCH] QINDEX_RANGE fixed tables. Removed a couple more fixed tables for the extended quantizer experiment that depend on QINDEX_RANGE. Change-Id: I2c15ffc7488c2a2b8d6504e2c4b6b2339799d117 --- vp8/encoder/firstpass.c | 33 ++++++++++++++++++++------------- vp8/encoder/ratectrl.c | 11 +++++++++++ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/vp8/encoder/firstpass.c b/vp8/encoder/firstpass.c index 3295cea228..b35b89450d 100644 --- a/vp8/encoder/firstpass.c +++ b/vp8/encoder/firstpass.c @@ -63,20 +63,27 @@ extern void vp8_alloc_compressor_data(VP8_COMP *cpi); static int vscale_lookup[7] = {0, 1, 1, 2, 2, 3, 3}; static int hscale_lookup[7] = {0, 0, 1, 1, 2, 2, 3}; -// TODO #if CONFIG_EXTEND_QRANGE -static const int cq_level[QINDEX_RANGE] = +static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame); + +static int select_cq_level( int qindex ) { - 0,0,1,1,2,3,3,4,4,5,6,6,7,8,8,9, - 9,10,11,11,12,13,13,14,15,15,16,17,17,18,19,20, - 20,21,22,22,23,24,24,25,26,27,27,28,29,30,30,31, - 32,33,33,34,35,36,36,37,38,39,39,40,41,42,42,43, - 44,45,46,46,47,48,49,50,50,51,52,53,54,55,55,56, - 57,58,59,60,60,61,62,63,64,65,66,67,67,68,69,70, - 71,72,73,74,75,75,76,77,78,79,80,81,82,83,84,85, - 86,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100 -}; + int ret_val = QINDEX_RANGE - 1; + int i; + + double target_q = ( vp8_convert_qindex_to_q( qindex ) * 0.5847 ) + 1.0; + + for ( i = 0; i < QINDEX_RANGE; i++ ) + { + if ( target_q <= vp8_convert_qindex_to_q( i ) ) + { + ret_val = i; + break; + } + } + + return ret_val; +} -static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame); // Resets the first pass file to the given position using a relative seek from the current position static void reset_fpf_position(VP8_COMP *cpi, FIRSTPASS_STATS *Position) @@ -1143,7 +1150,7 @@ static int estimate_cq( VP8_COMP *cpi, } // Clip value to range "best allowed to (worst allowed - 1)" - Q = cq_level[Q]; + Q = select_cq_level( Q ); if ( Q >= cpi->worst_quality ) Q = cpi->worst_quality - 1; if ( Q < cpi->best_quality ) diff --git a/vp8/encoder/ratectrl.c b/vp8/encoder/ratectrl.c index bc11457483..d2e680f89d 100644 --- a/vp8/encoder/ratectrl.c +++ b/vp8/encoder/ratectrl.c @@ -45,6 +45,7 @@ extern int inter_b_modes[B_MODE_COUNT]; // Bits Per MB at different Q (Multiplied by 512) #define BPER_MB_NORMBITS 9 +#if !CONFIG_EXTEND_QRANGE static const int kf_gf_boost_qlimits[QINDEX_RANGE] = { 150, 155, 160, 165, 170, 175, 180, 185, @@ -64,6 +65,7 @@ static const int kf_gf_boost_qlimits[QINDEX_RANGE] = 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, }; +#endif // % adjustment to target kf size based on seperation from previous frame static const int kf_boost_seperation_adjustment[16] = @@ -499,8 +501,17 @@ static void calc_gf_params(VP8_COMP *cpi) } // Apply an upper limit based on Q for 1 pass encodes +#if !CONFIG_EXTEND_QRANGE if (Boost > kf_gf_boost_qlimits[Q] && (cpi->pass == 0)) Boost = kf_gf_boost_qlimits[Q]; +#else + // TODO. + // This is a temporay measure oas one pass not really supported yet in + // the experimental branch + if (Boost > 600 && (cpi->pass == 0)) + Boost = 600; + +#endif // Apply lower limits to boost. else if (Boost < 110) -- GitLab