From 740782f8cd899bb35782a0527c688de8127eee76 Mon Sep 17 00:00:00 2001 From: Marco Paniconi Date: Wed, 18 Apr 2018 17:15:16 -0700 Subject: [PATCH] vp9: Rate control fix for CBR mode. For CBR mode: modify the qp clamping to allow q to respond faster to overshoot. Can reduce some suprious overshoot events observed in screen content coding. Change-Id: I0b3f54b0d1b4086182f834e557a4121950b176d4 --- vp9/encoder/vp9_ratectrl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 748a0ddd8..ed28ca9ca 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -620,8 +620,14 @@ int vp9_rc_regulate_q(const VP9_COMP *cpi, int target_bits_per_frame, !(cpi->refresh_alt_ref_frame || cpi->refresh_golden_frame)) && (cpi->rc.rc_1_frame * cpi->rc.rc_2_frame == -1) && cpi->rc.q_1_frame != cpi->rc.q_2_frame) { - q = clamp(q, VPXMIN(cpi->rc.q_1_frame, cpi->rc.q_2_frame), - VPXMAX(cpi->rc.q_1_frame, cpi->rc.q_2_frame)); + int qclamp = clamp(q, VPXMIN(cpi->rc.q_1_frame, cpi->rc.q_2_frame), + VPXMAX(cpi->rc.q_1_frame, cpi->rc.q_2_frame)); + // If the previous had overshoot and the current q needs to increase above + // the clamped value, reduce the clamp for faster reaction to overshoot. + if (cpi->rc.rc_1_frame == -1 && q > qclamp) + q = (q + qclamp) >> 1; + else + q = qclamp; } return q; } -- 2.40.0