shithub: libvpx

Download patch

ref: aa327a1ed4280bfa30953b2cb4c05c8a64b595a1
parent: dbc5090b5e9cb262aa575fb5d41314ecfefff6eb
author: Jerome Jiang <jianj@google.com>
date: Thu Feb 2 12:51:01 EST 2017

vp9: speed 8: Tune threshold of ac skip and partitioning.

Threshold for partitioning only affects VGA and lower res.
0.07% quality regression is observed in borg tests on rtc_derf
and 0.2% regression on rtc.
5.6% speed up for low res and 6.8% for VGA on Nexus 6.

Change-Id: If85a2919b48c991de66059c90f32ed06980452be

--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -488,6 +488,8 @@
       else if (noise_level < kLow)
         threshold_base = (7 * threshold_base) >> 3;
     }
+    if (cpi->oxcf.speed >= 8 && cm->width <= 640 && cm->height <= 480)
+      threshold_base = (5 * threshold_base) >> 2;
     thresholds[0] = threshold_base;
     thresholds[2] = threshold_base << cpi->oxcf.speed;
     if (cm->width <= 352 && cm->height <= 288) {
--- a/vp9/encoder/vp9_pickmode.c
+++ b/vp9/encoder/vp9_pickmode.c
@@ -296,6 +296,18 @@
   }
 }
 
+// Adjust the ac_thr according to speed, width, height and normalized sum
+static int ac_thr_factor(const int speed, const int width, const int height,
+                         const int norm_sum) {
+  if (speed >= 8 && norm_sum < 5) {
+    if (width <= 640 && height <= 480)
+      return 4;
+    else
+      return 2;
+  }
+  return 1;
+}
+
 static void model_rd_for_sb_y_large(VP9_COMP *cpi, BLOCK_SIZE bsize,
                                     MACROBLOCK *x, MACROBLOCKD *xd,
                                     int *out_rate_sum, int64_t *out_dist_sum,
@@ -312,7 +324,7 @@
   const uint32_t dc_quant = pd->dequant[0];
   const uint32_t ac_quant = pd->dequant[1];
   const int64_t dc_thr = dc_quant * dc_quant >> 6;
-  const int64_t ac_thr = ac_quant * ac_quant >> 6;
+  int64_t ac_thr = ac_quant * ac_quant >> 6;
   unsigned int var;
   int sum;
   int skip_dc = 0;
@@ -340,6 +352,9 @@
 
   *var_y = var;
   *sse_y = sse;
+
+  ac_thr *= ac_thr_factor(cpi->oxcf.speed, cpi->common.width,
+                          cpi->common.height, abs(sum) >> (bw + bh));
 
   if (cpi->common.tx_mode == TX_MODE_SELECT) {
     if (sse > (var << 2))