shithub: libvpx

Download patch

ref: 3338c878a7704ddd32877e0ed0e8ff9e10777dfd
parent: a46bb83e0c0d9592a20e000e843f36c117c96f13
parent: 93488acda641c74bdc0f606cd4086b021e733f84
author: Yaowu Xu <yaowu@google.com>
date: Fri Dec 7 17:53:43 EST 2018

Merge "Optimize RDMult"

--- a/vp9/encoder/vp9_rd.c
+++ b/vp9/encoder/vp9_rd.c
@@ -176,8 +176,27 @@
 int vp9_compute_rd_mult_based_on_qindex(const VP9_COMP *cpi, int qindex) {
   // largest dc_quant is 21387, therefore rdmult should always fit in int32_t
   const int q = vp9_dc_quant(qindex, 0, cpi->common.bit_depth);
-  int rdmult = q * q;
-  rdmult = rdmult * 3 + (rdmult * 2 / 3);
+  uint32_t rdmult = q * q;
+
+  if (cpi->common.frame_type != KEY_FRAME) {
+    if (qindex < 1)
+      rdmult = rdmult * 3 + (rdmult * 2 / 3);
+    else if (qindex < 128)
+      rdmult = rdmult * 4;
+    else if (qindex < 190)
+      rdmult = rdmult * 4 + rdmult / 2;
+    else
+      rdmult = rdmult * 3;
+  } else {
+    if (qindex < 64)
+      rdmult = rdmult * 4;
+    else if (qindex <= 128)
+      rdmult = rdmult * 3 + rdmult / 2;
+    else if (qindex < 190)
+      rdmult = rdmult * 4 + rdmult / 2;
+    else
+      rdmult = rdmult * 7 + rdmult / 2;
+  }
 #if CONFIG_VP9_HIGHBITDEPTH
   switch (cpi->common.bit_depth) {
     case VPX_BITS_10: rdmult = ROUND_POWER_OF_TWO(rdmult, 4); break;