shithub: libvpx

Download patch

ref: 360ac89885b9e21442f8e5e2f63206da4cc6f605
parent: a8eee97b43b532c9ee35280bfdf910ab468004a4
author: Marco <marpan@google.com>
date: Mon Dec 5 07:05:35 EST 2016

vp9: Adjust the weight factor for segment rate cost for aq-mode=3.

Use the segment weight factor based on the target (cr->percent_refresh)
if it less than the current estimate (avergae of past usage and target).
Small improvement at low bitrates.

Change-Id: Iba8fd909e203f94458901366d3a991f7ea854d49

--- a/vp9/encoder/vp9_aq_cyclicrefresh.c
+++ b/vp9/encoder/vp9_aq_cyclicrefresh.c
@@ -128,16 +128,20 @@
   CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
   int bits_per_mb;
   int num8x8bl = cm->MBs << 2;
+  // Compute delta-q corresponding to qindex i.
+  int deltaq = compute_deltaq(cpi, i, cr->rate_ratio_qdelta);
   // Weight for segment prior to encoding: take the average of the target
   // number for the frame to be encoded and the actual from the previous frame.
+  // Use the target if its less.
   int target_refresh = cr->percent_refresh * cm->mi_rows * cm->mi_cols / 100;
+  double weight_segment_target = (double)(target_refresh) / num8x8bl;
   double weight_segment =
       (double)((target_refresh + cr->actual_num_seg1_blocks +
                 cr->actual_num_seg2_blocks) >>
                1) /
       num8x8bl;
-  // Compute delta-q corresponding to qindex i.
-  int deltaq = compute_deltaq(cpi, i, cr->rate_ratio_qdelta);
+  if (weight_segment_target < 7 * weight_segment / 8)
+    weight_segment = weight_segment_target;
   // Take segment weighted average for bits per mb.
   bits_per_mb = (int)((1.0 - weight_segment) *
                           vp9_rc_bits_per_mb(cm->frame_type, i,