shithub: libvpx

Download patch

ref: a2127236ae4742f329e5571d76b84de08cd3b8ea
parent: 08a668af32d05de2b29d29372b1749dd29ee8a61
author: Marco <marpan@google.com>
date: Thu Dec 7 12:24:41 EST 2017

vp9: Reset buffer level on large bitrate changes.

For a large change in the target avg_frame_bandwidth,
via the update in change_config()), reset the buffer_level
to optimal_level.

This fix prevents possible frame drops, where for example,
encoder suddenly goes from lower to higher bitrate.

Change-Id: I2f844c41d04c01240e85f574e59d2b9075c7eb6d

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -1868,6 +1868,7 @@
   // Check for resetting the rc flags (rc_1_frame, rc_2_frame) if the
   // configuration change has a large change in avg_frame_bandwidth.
   // For SVC check for resetting based on spatial layer average bandwidth.
+  // Also reset buffer level to optimal level.
   if (cm->current_video_frame > 0) {
     if (cpi->use_svc) {
       vp9_svc_check_reset_layer_rc_flag(cpi);
@@ -1876,6 +1877,8 @@
           rc->avg_frame_bandwidth < (rc->last_avg_frame_bandwidth >> 1)) {
         rc->rc_1_frame = 0;
         rc->rc_2_frame = 0;
+        rc->bits_off_target = rc->optimal_buffer_level;
+        rc->buffer_level = rc->optimal_buffer_level;
       }
     }
   }
--- a/vp9/encoder/vp9_svc_layercontext.c
+++ b/vp9/encoder/vp9_svc_layercontext.c
@@ -881,6 +881,8 @@
         RATE_CONTROL *lrc = &lc->rc;
         lrc->rc_1_frame = 0;
         lrc->rc_2_frame = 0;
+        lrc->bits_off_target = lrc->optimal_buffer_level;
+        lrc->buffer_level = lrc->optimal_buffer_level;
       }
     }
   }