From: Marco Paniconi Date: Thu, 19 Apr 2018 00:15:16 +0000 (-0700) Subject: vp9: Rate control fix for CBR mode. X-Git-Tag: v1.8.0~731^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=740782f8cd899bb35782a0527c688de8127eee76;p=libvpx 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 --- 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; }