shithub: libvpx

Download patch

ref: 9d8ead125d10f46ff91941b0c7eb097e3ae9622a
parent: ee35f4dede9bfe50f5461c8c5df6e6a041f98326
author: Paul Wilkins <paulwilkins@google.com>
date: Tue Mar 15 08:54:52 EDT 2016

Force recode for bad rate misses.

Adds a second threshold for recodes even on frames where
recode is normally disabled if there is a big rate miss.

Change-Id: Ifd4a34707da55ec15eb7cfb87de4644b8d76deb2

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -2722,6 +2722,13 @@
   return scale;
 }
 
+static int big_rate_miss(VP9_COMP *cpi, int high_limit, int low_limit) {
+  const RATE_CONTROL *const rc = &cpi->rc;
+
+  return (rc->projected_frame_size > ((high_limit * 3) / 2)) ||
+         (rc->projected_frame_size < (low_limit / 2));
+}
+
 // Function to test for conditions that indicate we should loop
 // back and recode a frame.
 static int recode_loop_test(VP9_COMP *cpi,
@@ -2733,6 +2740,7 @@
   int force_recode = 0;
 
   if ((rc->projected_frame_size >= rc->max_frame_bandwidth) ||
+      big_rate_miss(cpi, high_limit, low_limit) ||
       (cpi->sf.recode_loop == ALLOW_RECODE) ||
       (frame_is_kfgfarf &&
        (cpi->sf.recode_loop == ALLOW_RECODE_KFARFGF))) {