Merge two new VBR adjustment schemes.
authorPaul Wilkins <paulwilkins@google.com>
Wed, 16 Apr 2014 23:53:55 +0000 (16:53 -0700)
committerPaul Wilkins <paulwilkins@google.com>
Thu, 17 Apr 2014 19:05:31 +0000 (12:05 -0700)
To make direct side by side testing this patch combines two
VBR corrections schemes to allow more direct side by side testing.
(The other patch was by Debargha chg id I0cd1f7...)

Change-Id: I271c45e5c4ccf8de8305589000218b80d9dc3a25

vp9/encoder/vp9_firstpass.c
vp9/encoder/vp9_ratectrl.c

index 210f438961b14635ed1fed8a472dcf98df9be666..b80a651ce1cc078b2e90744544c76e984e0a5e6a 100644 (file)
@@ -2198,7 +2198,7 @@ void vp9_rc_get_first_pass_params(VP9_COMP *cpi) {
 // For VBR...adjustment to the frame target based on error from previous frames
 void vbr_rate_correction(int * this_frame_target,
                          const int64_t vbr_bits_off_target) {
-  int max_delta = *this_frame_target / 10;
+  int max_delta = (*this_frame_target * 15) / 100;
 
   // vbr_bits_off_target > 0 means we have extra bits to spend
   if (vbr_bits_off_target > 0) {
@@ -2370,10 +2370,17 @@ void vp9_twopass_postencode_update(VP9_COMP *cpi) {
   // kf_group_bits & gf_group_bits to reflect any deviation from the target
   // rate in this frame. This alters the allocation of bits to the
   // remaning frames in the group / clip.
+  //
   // This method can give rise to unstable behaviour near the end of a clip
   // or kf/gf group of frames where any accumulated error is corrected over an
-  // ever decreasing number of frames.
-  const int bits_used = rc->projected_frame_size;
+  // ever decreasing number of frames. Hence we change the balance of target
+  // vs. actual bitrate gradually as we progress towards the end of the
+  // sequence in order to mitigate this effect.
+  const double progress =
+      (double)(cpi->twopass.stats_in - cpi->twopass.stats_in_start) /
+              (cpi->twopass.stats_in_end - cpi->twopass.stats_in_start);
+  const int bits_used = progress * cpi->rc.this_frame_target +
+                        (1.0 - progress) * cpi->rc.projected_frame_size;
 #endif
 
   cpi->twopass.bits_left -= bits_used;
index 040655e14453af9de1f9795299862a04ad7aa81d..b0cbfa72b306550bec579e0e21cf0911dd736cb3 100644 (file)
@@ -85,7 +85,7 @@ void vp9_rc_init_minq_luts() {
     gf_high_motion_minq[i] = get_minq_index(maxq, 0.0000021, -0.00125, 0.50);
     afq_low_motion_minq[i] = get_minq_index(maxq, 0.0000015, -0.0009, 0.33);
     afq_high_motion_minq[i] = get_minq_index(maxq, 0.0000021, -0.00125, 0.55);
-    inter_minq[i] = get_minq_index(maxq, 0.00000271, -0.00113, 0.55);
+    inter_minq[i] = get_minq_index(maxq, 0.00000271, -0.00113, 0.75);
   }
 }