summaryrefslogtreecommitdiff
path: root/vp9/encoder
diff options
context:
space:
mode:
Diffstat (limited to 'vp9/encoder')
-rw-r--r--vp9/encoder/vp9_firstpass.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index f4fda0965..89348e666 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -105,7 +105,7 @@ static void output_stats(FIRSTPASS_STATS *stats,
fprintf(fpfile,
"%12.0lf %12.4lf %12.2lf %12.2lf %12.2lf %12.0lf %12.4lf %12.4lf"
"%12.4lf %12.4lf %12.4lf %12.4lf %12.4lf %12.4lf %12.4lf %12.4lf"
- "%12.4lf %12.4lf %12.4lf %12.4lf %12.4lf %12.0lf %12.0lf %12.0lf"
+ "%12.4lf %12.4lf %12.4lf %12.4lf %12.4lf %12.0lf %12.4lf %12.0lf"
"%12.4lf"
"\n",
stats->frame, stats->weight, stats->intra_error, stats->coded_error,
@@ -1970,7 +1970,20 @@ static double calc_frame_boost(VP9_COMP *cpi, const FIRSTPASS_STATS *this_frame,
return VPXMIN(frame_boost, GF_MAX_BOOST * boost_q_correction);
}
-#define KF_BASELINE_ERR_PER_MB 12500.0
+static double kf_err_per_mb(VP9_COMP *cpi) {
+ const VP9_COMMON *const cm = &cpi->common;
+ unsigned int screen_area = (cm->width * cm->height);
+
+ // Use a different error per mb factor for calculating boost for
+ // different formats.
+ if (screen_area < 1280 * 720) {
+ return 2000.0;
+ } else if (screen_area < 1920 * 1080) {
+ return 500.0;
+ }
+ return 250.0;
+}
+
static double calc_kf_frame_boost(VP9_COMP *cpi,
const FIRSTPASS_STATS *this_frame,
double *sr_accumulator,
@@ -1983,7 +1996,7 @@ static double calc_kf_frame_boost(VP9_COMP *cpi,
const double active_area = calculate_active_area(cpi, this_frame);
// Underlying boost factor is based on inter error ratio.
- frame_boost = (KF_BASELINE_ERR_PER_MB * active_area) /
+ frame_boost = (kf_err_per_mb(cpi) * active_area) /
DOUBLE_DIVIDE_CHECK(this_frame->coded_error + *sr_accumulator);
// Update the accumulator for second ref error difference.
@@ -1996,8 +2009,11 @@ static double calc_kf_frame_boost(VP9_COMP *cpi,
if (this_frame_mv_in_out > 0.0)
frame_boost += frame_boost * (this_frame_mv_in_out * 2.0);
- // Q correction and scalling
- frame_boost = frame_boost * boost_q_correction;
+ // Q correction and scaling
+ // The 40.0 value here is an experimentally derived baseline minimum.
+ // This value is in line with the minimum per frame boost in the alt_ref
+ // boost calculation.
+ frame_boost = ((frame_boost + 40.0) * boost_q_correction);
return VPXMIN(frame_boost, max_boost * boost_q_correction);
}