[x265] [PATCH] sao: remove duplicate calculation on BO cost

Ximing Cheng chengximing1989 at foxmail.com
Wed Jun 28 18:44:18 CEST 2017


# HG changeset patch
# User Ximing Cheng <ximingcheng at tencent.com>
# Date 1498668227 -28800
#      Thu Jun 29 00:43:47 2017 +0800
# Node ID 0bb8e464147ac932c74321663216214969a079ac
# Parent  fa076d29d6191699e314484a94dcae472e9c102a
sao: remove duplicate calculation on BO cost

diff -r fa076d29d619 -r 0bb8e464147a source/encoder/sao.cpp
--- a/source/encoder/sao.cpp	Tue Jun 27 16:41:11 2017 +0530
+++ b/source/encoder/sao.cpp	Thu Jun 29 00:43:47 2017 +0800
@@ -1553,14 +1553,17 @@
     }
 
     // Estimate Best Position
-    int64_t bestRDCostBO = MAX_INT64;
     int32_t bestClassBO  = 0;
+    int64_t currentRDCost = costClasses[0];
+    currentRDCost += costClasses[1];
+    currentRDCost += costClasses[2];
+    currentRDCost += costClasses[3];
+    int64_t bestRDCostBO = currentRDCost;
 
-    for (int i = 0; i < MAX_NUM_SAO_CLASS - SAO_NUM_OFFSET + 1; i++)
+    for (int i = 1; i < MAX_NUM_SAO_CLASS - SAO_NUM_OFFSET + 1; i++)
     {
-        int64_t currentRDCost = 0;
-        for (int j = i; j < i + SAO_NUM_OFFSET; j++)
-            currentRDCost += costClasses[j];
+        currentRDCost -= costClasses[i - 1];
+        currentRDCost += costClasses[i + 3];
 
         if (currentRDCost < bestRDCostBO)
         {




More information about the x265-devel mailing list