summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorPaul Wilkins <paulwilkins@google.com>2017-05-11 18:25:44 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-05-11 18:25:45 +0000
commit3caaf21c5be04d012426b3e6a1b58a5d2c9700a8 (patch)
treef8590ca0158a13f1ea241934ddbf953cda1bb9af /vp9
parentd35541fe292fd8778d7212234a0bce633cda43af (diff)
parent9a7625652c94ab2d699cb1066ba6de24ceea3cfa (diff)
downloadlibvpx-3caaf21c5be04d012426b3e6a1b58a5d2c9700a8.tar
libvpx-3caaf21c5be04d012426b3e6a1b58a5d2c9700a8.tar.gz
libvpx-3caaf21c5be04d012426b3e6a1b58a5d2c9700a8.tar.bz2
libvpx-3caaf21c5be04d012426b3e6a1b58a5d2c9700a8.zip
Merge "Tuning of factor used to calculate Q range in two pass."
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_firstpass.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index e398ff5e8..77c49c545 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,