]> granicus.if.org Git - libvpx/commitdiff
Refactor partition mode cost calculation
authorJingning Han <jingning@google.com>
Wed, 30 May 2018 20:31:08 +0000 (13:31 -0700)
committerJingning Han <jingning@google.com>
Mon, 18 Jun 2018 19:01:13 +0000 (12:01 -0700)
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

vp9/encoder/vp9_encodeframe.c

index ed15c177dbd105aa95d28c676bab9c738293472e..e9ff20742487895044e78db8cb05885e40a90ec8 100644 (file)
@@ -3486,9 +3486,11 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
                      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 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
     }
 
     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 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
     }
 
     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 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td,
     }
 
     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;