shithub: libvpx

Download patch

ref: 892c855313fa068067299001a3d0c9bbe2b68c4f
parent: 7e1c766158070c5abcce19d35467a65656836367
author: Marco Paniconi <marpan@google.com>
date: Sun Feb 24 14:02:14 EST 2019

vp9-rtc: Fix to Q clamp in adjust_q_cbr

For CBR mode: clamp the Q to worst/best quality in
adjust_q_cbr().

Under certain conditions, when the worst/best quality is
suddenly changed by a large amount mid-stream, the Q
adjustment from the final Q from adjust_q_cbr may not respect
the worst/best qualiy limits.

Change-Id: I3776129325d89882d422b22e6247d44660dd90ac

--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -668,7 +668,7 @@
   }
   if (cpi->oxcf.content == VP9E_CONTENT_SCREEN)
     vp9_cyclic_refresh_limit_q(cpi, &q);
-  return q;
+  return VPXMAX(VPXMIN(q, cpi->rc.worst_quality), cpi->rc.best_quality);
 }
 
 static double get_rate_correction_factor(const VP9_COMP *cpi) {
@@ -1076,6 +1076,7 @@
         q = *top_index;
     }
   }
+
   assert(*top_index <= rc->worst_quality && *top_index >= rc->best_quality);
   assert(*bottom_index <= rc->worst_quality &&
          *bottom_index >= rc->best_quality);