Commit 422d7bc9 authored by Paul Wilkins's avatar Paul Wilkins
Browse files

Relax maximum Q for extreme overshoot.

Added code to relax the active maximum Q in response
to extreme local overshoot to reduce bandwidth peaks.

The impact is small in metrics terms, but it this helps reduce
bandwidth spikes and overall overshoot in a number of
clips in our tests sets (especially the YT test set).

In particular this should help prevent very big spikes where a clip
is mainly easy but has a short hard section. In such a case a choice
of maximum Q for the clip as a whole may allow us to hit the overall
target rate but give some extreme spikes. The chunked encoding in YT
mitigates this problem but it can show up where a longer clip is
coded as a single chunk.

Change-Id: I213d09950ccb8489d10adf00fda1e53235b39203
parent d56b3eb0
......@@ -2478,7 +2478,6 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) {
#define MINQ_ADJ_LIMIT 32
#define Q_LIMIT_STEP 1
void vp9_twopass_postencode_update(VP9_COMP *cpi) {
TWO_PASS *const twopass = &cpi->twopass;
RATE_CONTROL *const rc = &cpi->rc;
......@@ -2523,16 +2522,22 @@ void vp9_twopass_postencode_update(VP9_COMP *cpi) {
if (rc->rate_error_estimate > cpi->oxcf.under_shoot_pct) {
if (rc->rolling_target_bits >= rc->rolling_actual_bits)
twopass->extend_minq += Q_LIMIT_STEP;
// Overshoot.
} else if (rc->rate_error_estimate < -cpi->oxcf.over_shoot_pct) {
if (rc->rolling_target_bits < rc->rolling_actual_bits)
twopass->extend_maxq += Q_LIMIT_STEP;
} else {
// Adjustment for extreme local overshoot.
if (rc->projected_frame_size > (2 * rc->base_frame_target) &&
rc->projected_frame_size > (2 * rc->avg_frame_bandwidth))
// Unwind undershoot or overshoot adjustment.
if (rc->rolling_target_bits < rc->rolling_actual_bits)
if (rc->rolling_target_bits > rc->rolling_actual_bits)
else if (rc->rolling_target_bits > rc->rolling_actual_bits)
twopass->extend_minq = clamp(twopass->extend_minq, 0, MINQ_ADJ_LIMIT);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment