shithub: libvpx

Download patch

ref: 5464395948a84f358f41568304e0c45b248acdf1
parent: 2b369bf63ccb709ce0607ffa4eedcfea1c235b31
parent: 740782f8cd899bb35782a0527c688de8127eee76
author: Marco Paniconi <marpan@google.com>
date: Wed Apr 18 22:56:26 EDT 2018

Merge "vp9: Rate control fix for CBR mode."

--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -620,8 +620,14 @@
        !(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;
 }