]> granicus.if.org Git - libvpx/commitdiff
vp9: Rate control fix for CBR mode.
authorMarco Paniconi <marpan@google.com>
Thu, 19 Apr 2018 00:15:16 +0000 (17:15 -0700)
committerMarco Paniconi <marpan@google.com>
Thu, 19 Apr 2018 00:21:51 +0000 (17:21 -0700)
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

index 748a0ddd82d93f0399e2825c69a7fccde8e386c3..ed28ca9ca30d3d12706bb678b36e9d770f1ace17 100644 (file)
@@ -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;
 }