shithub: libvpx

Download patch

ref: d99ba0399e0ef3f78a701e01df41707d66dafb4e
parent: 54dfdf28c70bff8dee6052e6152859298425e201
author: Jingning Han <jingning@google.com>
date: Wed May 30 09:31:08 EDT 2018

Refactor partition mode cost calculation

Compute the coding block partition mode cost as additional rdcost
to the cumulative rate-distortion cost from each coding block. This
changes the coding performance slightly due to the rounding error.
The compression performance change is neutral.

Change-Id: Ibdccae0e79263a0e70af7592a8cb11458d795f8d

--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -3486,9 +3486,11 @@
                      best_rdc.rdcost);
     if (this_rdc.rate != INT_MAX) {
       if (bsize >= BLOCK_8X8) {
-        this_rdc.rate += cpi->partition_cost[pl][PARTITION_NONE];
         this_rdc.rdcost =
             RDCOST(x->rdmult, x->rddiv, this_rdc.rate, this_rdc.dist);
+        this_rdc.rdcost += RDCOST(x->rdmult, x->rddiv,
+                                  cpi->partition_cost[pl][PARTITION_NONE], 0);
+        this_rdc.rate += cpi->partition_cost[pl][PARTITION_NONE];
       }
 
       if (this_rdc.rdcost < best_rdc.rdcost) {
@@ -3624,8 +3626,10 @@
     }
 
     if (sum_rdc.rdcost < best_rdc.rdcost && i == 4) {
-      sum_rdc.rate += cpi->partition_cost[pl][PARTITION_SPLIT];
       sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
+      sum_rdc.rdcost += RDCOST(x->rdmult, x->rddiv,
+                               cpi->partition_cost[pl][PARTITION_SPLIT], 0);
+      sum_rdc.rate += cpi->partition_cost[pl][PARTITION_SPLIT];
 
       if (sum_rdc.rdcost < best_rdc.rdcost) {
         best_rdc = sum_rdc;
@@ -3685,8 +3689,10 @@
     }
 
     if (sum_rdc.rdcost < best_rdc.rdcost) {
-      sum_rdc.rate += cpi->partition_cost[pl][PARTITION_HORZ];
       sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
+      sum_rdc.rdcost += RDCOST(x->rdmult, x->rddiv,
+                               cpi->partition_cost[pl][PARTITION_HORZ], 0);
+      sum_rdc.rate += cpi->partition_cost[pl][PARTITION_HORZ];
       if (sum_rdc.rdcost < best_rdc.rdcost) {
         best_rdc = sum_rdc;
         pc_tree->partitioning = PARTITION_HORZ;
@@ -3733,8 +3739,10 @@
     }
 
     if (sum_rdc.rdcost < best_rdc.rdcost) {
-      sum_rdc.rate += cpi->partition_cost[pl][PARTITION_VERT];
       sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
+      sum_rdc.rdcost += RDCOST(x->rdmult, x->rddiv,
+                               cpi->partition_cost[pl][PARTITION_VERT], 0);
+      sum_rdc.rate += cpi->partition_cost[pl][PARTITION_VERT];
       if (sum_rdc.rdcost < best_rdc.rdcost) {
         best_rdc = sum_rdc;
         pc_tree->partitioning = PARTITION_VERT;