diff options
author | paulwilkins <paulwilkins@google.com> | 2017-05-10 16:07:13 +0100 |
---|---|---|
committer | paulwilkins <paulwilkins@google.com> | 2017-05-11 16:19:59 +0100 |
commit | 9a7625652c94ab2d699cb1066ba6de24ceea3cfa (patch) | |
tree | 70834a428e52a9e7e2e349ea6ca688aa3ddae889 /vp9 | |
parent | 8053dba5a1470a9ced7236f5b692b16f0d7b8a98 (diff) | |
download | libvpx-9a7625652c94ab2d699cb1066ba6de24ceea3cfa.tar libvpx-9a7625652c94ab2d699cb1066ba6de24ceea3cfa.tar.gz libvpx-9a7625652c94ab2d699cb1066ba6de24ceea3cfa.tar.bz2 libvpx-9a7625652c94ab2d699cb1066ba6de24ceea3cfa.zip |
Tuning of factor used to calculate Q range in two pass.
A more detailed explanation of the experimentation
leading to this change can be found in:-
https://docs.google.com/a/google.com/document/d/13lsYhxgPyxUHvEess6wg9nikaonIZKY9Ak_Lpafv5Mo/edit?usp=sharing
This change gives gains across all our standard test sets for
overall psnr, ssim, fast ssim and psnr-HVS.
Values expressed as % reduction in bitrate.
Low res set -0.257, -0.192, -0.173, -0.101
Mid res set -0.233, -0.336, -0.367, -0.139
High res set -0.999, -1.039, -1.111, -0.567
NetFlix 2K set -0.734, -0.174, -0.389, -0.820
Netflix 4K set -0.814, -0.485, -0.796, -0.839
Change-Id: Ie981fb3c895c9dfcfc8682640d201a86375db5c8
Diffstat (limited to 'vp9')
-rw-r--r-- | vp9/encoder/vp9_firstpass.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 55f425b6c..0eabb3e3b 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -42,15 +42,12 @@ #define OUTPUT_FPF 0 #define ARF_STATS_OUTPUT 0 -#define FACTOR_PT_LOW 0.70 -#define FACTOR_PT_HIGH 0.90 #define FIRST_PASS_Q 10.0 #define GF_MAX_BOOST 96.0 #define INTRA_MODE_PENALTY 1024 #define MIN_ARF_GF_BOOST 240 #define MIN_DECAY_FACTOR 0.01 #define NEW_MV_MODE_PENALTY 32 -#define SVC_FACTOR_PT_LOW 0.45 #define DARK_THRESH 64 #define DEFAULT_GRP_WEIGHT 1.0 #define RC_FACTOR_MIN 0.75 @@ -1522,14 +1519,22 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) { if (cpi->use_svc) vp9_inc_frame_in_layer(cpi); } +static const double q_pow_term[(QINDEX_RANGE >> 5) + 1] = { + 0.65, 0.70, 0.75, 0.85, 0.90, 0.90, 0.90, 1.00, 1.25 +}; + static double calc_correction_factor(double err_per_mb, double err_divisor, - double pt_low, double pt_high, int q, - vpx_bit_depth_t bit_depth) { - const double error_term = err_per_mb / err_divisor; + int q) { + const double error_term = err_per_mb / DOUBLE_DIVIDE_CHECK(err_divisor); + const int index = q >> 5; + double power_term; + + assert((index >= 0) && (index < (QINDEX_RANGE >> 5))); - // Adjustment based on actual quantizer to power term. - const double power_term = - VPXMIN(vp9_convert_qindex_to_q(q, bit_depth) * 0.01 + pt_low, pt_high); + // Adjustment based on quantizer to the power term. + power_term = + q_pow_term[index] + + (((q_pow_term[index + 1] - q_pow_term[index]) * (q % 32)) / 32.0); // Calculate correction factor. if (power_term < 1.0) assert(error_term >= 0.0); @@ -1567,10 +1572,6 @@ static int get_twopass_worst_quality(VP9_COMP *cpi, const double section_err, const int target_norm_bits_per_mb = (int)(((uint64_t)target_rate << BPER_MB_NORMBITS) / active_mbs); int q; - int is_svc_upper_layer = 0; - - if (is_two_pass_svc(cpi) && cpi->svc.spatial_layer_id > 0) - is_svc_upper_layer = 1; // based on recent history adjust expectations of bits per macroblock. last_group_rate_err = @@ -1583,10 +1584,8 @@ static int get_twopass_worst_quality(VP9_COMP *cpi, const double section_err, // Try and pick a max Q that will be high enough to encode the // content at the given rate. for (q = rc->best_quality; q < rc->worst_quality; ++q) { - const double factor = calc_correction_factor( - av_err_per_mb, ERR_DIVISOR, - is_svc_upper_layer ? SVC_FACTOR_PT_LOW : FACTOR_PT_LOW, - FACTOR_PT_HIGH, q, cpi->common.bit_depth); + const double factor = + calc_correction_factor(av_err_per_mb, ERR_DIVISOR, q); const int bits_per_mb = vp9_rc_bits_per_mb( INTER_FRAME, q, factor * speed_term * cpi->twopass.bpm_factor * noise_factor, |