shithub: libvpx

Download patch

ref: 997ac14c6ab3b7504407223913c39182145e829a
parent: 4a28da58434d364337d9a6724e9ae79e0e264bd7
author: Marco <[email protected]>
date: Tue Jun 9 10:58:32 EDT 2015

Adjust some parameters for cyclic refresh for low bitrates.

Reduce motion threshold and boost factor for second segment,
for low bitrates, at low resolutions for now.
This is to reduce the rate fluctuation/frame dropping that occurs
at these low bitrates.

Change-Id: Ia66c3be41831882fca8c1e4fe104f5ea8fbe7142

--- a/vp9/encoder/vp9_aq_cyclicrefresh.c
+++ b/vp9/encoder/vp9_aq_cyclicrefresh.c
@@ -48,6 +48,8 @@
   int16_t motion_thresh;
   // Rate target ratio to set q delta.
   double rate_ratio_qdelta;
+  // Boost factor for rate target ratio, for segment CR_SEGMENT_ID_BOOST2.
+  double rate_boost_fac;
   double low_content_avg;
   int qindex_delta_seg1;
   int qindex_delta_seg2;
@@ -93,6 +95,19 @@
     return 1;
 }
 
+static void adjust_cyclic_refresh_parameters(VP9_COMP *const cpi) {
+  const VP9_COMMON *const cm = &cpi->common;
+  const RATE_CONTROL *const rc = &cpi->rc;
+  CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
+  // Adjust some parameters, currently only for low resolutions at low bitrates.
+  if (cm->width <= 352 &&
+      cm->height <= 288 &&
+      rc->avg_frame_bandwidth < 3400) {
+      cr->motion_thresh = 4;
+      cr->rate_boost_fac = 1.25;
+  }
+}
+
 // Check if this coding block, of size bsize, should be considered for refresh
 // (lower-qp coding). Decision can be based on various factors, such as
 // size of the coding block (i.e., below min_block size rejected), coding
@@ -462,6 +477,7 @@
     vp9_clear_system_state();
     cr->max_qdelta_perc = 50;
     cr->time_for_refresh = 0;
+    cr->rate_boost_fac = 1.7;
     // Set rate threshold to some multiple (set to 2 for now) of the target
     // rate (target is given by sb64_target_rate and scaled by 256).
     cr->thresh_rate_sb = ((int64_t)(rc->sb64_target_rate) << 8) << 2;
@@ -470,6 +486,9 @@
     // vp9_convert_qindex_to_q(), vp9_ac_quant(), ac_qlookup*[].
     cr->thresh_dist_sb = ((int64_t)(q * q)) << 2;
     cr->motion_thresh = 32;
+
+    adjust_cyclic_refresh_parameters(cpi);
+
     // Set up segmentation.
     // Clear down the segment map.
     vp9_enable_segmentation(&cm->seg);
@@ -505,7 +524,7 @@
     // Set a more aggressive (higher) q delta for segment BOOST2.
     qindex_delta = compute_deltaq(cpi, cm->base_qindex,
                                   MIN(CR_MAX_RATE_TARGET_RATIO,
-                                      CR_BOOST2_FAC * cr->rate_ratio_qdelta));
+                                  cr->rate_boost_fac * cr->rate_ratio_qdelta));
     cr->qindex_delta_seg2 = qindex_delta;
     vp9_set_segdata(seg, CR_SEGMENT_ID_BOOST2, SEG_LVL_ALT_Q, qindex_delta);
 
--- a/vp9/encoder/vp9_aq_cyclicrefresh.h
+++ b/vp9/encoder/vp9_aq_cyclicrefresh.h
@@ -27,9 +27,6 @@
 // Maximum rate target ratio for setting segment delta-qp.
 #define CR_MAX_RATE_TARGET_RATIO 4.0
 
-// Boost factor for rate target ratio, for segment CR_SEGMENT_ID_BOOST2.
-#define CR_BOOST2_FAC 1.7
-
 struct VP9_COMP;
 
 struct CYCLIC_REFRESH;