ref: 5e5da2e963c08f8b0e4a5af42b7401ebbc135ae0
parent: 5db4b77789d7882502a7abede76e0ae073bc56af
author: Paul Wilkins <paulwilkins@google.com>
date: Thu Nov 20 07:22:53 EST 2014
Fix bug in calculating number of mbs with scaling. Correct calculation of number of mbs in two pass code when frame resizing is enabled. Always use initial number of mbs if scaling is enabled, as this is what was used in the first pass. Change-Id: I49a4280ab5a8b1000efcc157a449a081cbb6d410
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -949,9 +949,8 @@
// where the typical "real" energy per MB also falls.
// Initial estimate here uses sqrt(mbs) to define the min_err, where the
// number of mbs is proportional to the image area.
- const int num_mbs =
- cpi->oxcf.resize_mode == RESIZE_FIXED ?
- cpi->initial_mbs : cpi->common.MBs;
+ const int num_mbs = (cpi->oxcf.resize_mode != RESIZE_NONE)
+ ? cpi->initial_mbs : cpi->common.MBs;
const double min_err = 200 * sqrt(num_mbs);
intra_factor = intra_factor / (double)num_mbs;
@@ -1091,9 +1090,8 @@
if (section_target_bandwidth <= 0) {
return rc->worst_quality; // Highest value allowed
} else {
- const int num_mbs =
- cpi->oxcf.resize_mode == RESIZE_FIXED ?
- cpi->initial_mbs : cpi->common.MBs;
+ const int num_mbs = (cpi->oxcf.resize_mode != RESIZE_NONE)
+ ? cpi->initial_mbs : cpi->common.MBs;
const double section_err = stats->coded_error / stats->count;
const double err_per_mb = section_err / num_mbs;
const double speed_term = 1.0 + 0.04 * oxcf->speed;
@@ -1210,9 +1208,8 @@
static double get_sr_decay_rate(const VP9_COMP *cpi,
const FIRSTPASS_STATS *frame) {
- const int num_mbs =
- cpi->oxcf.resize_mode == RESIZE_FIXED ?
- cpi->initial_mbs : cpi->common.MBs;
+ const int num_mbs = (cpi->oxcf.resize_mode != RESIZE_NONE)
+ ? cpi->initial_mbs : cpi->common.MBs;
double sr_diff =
(frame->sr_coded_error - frame->coded_error) / num_mbs;
double sr_decay = 1.0;
@@ -1338,9 +1335,8 @@
vp9_convert_qindex_to_q(cpi->rc.avg_frame_qindex[INTER_FRAME],
cpi->common.bit_depth);
const double boost_q_correction = MIN((0.5 + (lq * 0.015)), 1.5);
- const int num_mbs =
- cpi->oxcf.resize_mode == RESIZE_FIXED ?
- cpi->initial_mbs : cpi->common.MBs;
+ const int num_mbs = (cpi->oxcf.resize_mode != RESIZE_NONE)
+ ? cpi->initial_mbs : cpi->common.MBs;
// Underlying boost factor is based on inter error ratio.
frame_boost = (BASELINE_ERR_PER_MB * num_mbs) /
--
⑨