[x265] [PATCH] slicetype : estimateCUCost enhancement for selecting best cost

gopu at multicorewareinc.com gopu at multicorewareinc.com
Wed Aug 14 12:38:36 CEST 2013


# HG changeset patch
# User ggopu
# Date 1376476708 -19800
# Node ID 8f5074c0a750f0c7d77d17e09662f72a820233a5
# Parent  52a709ce88a85e9f87e16b3df6a0c6bfbc97f212
slicetype : estimateCUCost enhancement for selecting best cost

diff -r 52a709ce88a8 -r 8f5074c0a750 source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Wed Aug 14 03:32:51 2013 -0500
+++ b/source/encoder/slicetype.cpp	Wed Aug 14 16:08:28 2013 +0530
@@ -192,7 +192,7 @@
     return score;
 }
 
-int Lookahead::estimateCUCost(int cux, int cuy, int p0, int p1, int b, int do_search[2])
+void Lookahead::estimateCUCost(int cux, int cuy, int p0, int p1, int b, int do_search[2])
 {
     LookaheadFrame *fref0 = frames[p0];
     LookaheadFrame *fref1 = frames[p1];
@@ -251,10 +251,10 @@
         // TODO: add bidir
     }
 
+    int bcost = me.COST_MAX, cost;
     if (!fenc->bIntraCalculated)
     {
         Int nLog2SizeMinus2 = g_convertToBit[cu_size]; // partition size
-        int bcost = me.COST_MAX, cost;
 
         fenc->bIntraCalculated = true;
 
@@ -294,8 +294,28 @@
         }
         fenc->lowresMvCosts[0][0][cu_xy] = bcost;
     }
-
-    return 0;
+    
+    /* bcost is the BestIntraCost now */
+    int bestInterCost = X265_MIN(*fenc_costs[0], *fenc_costs[1]);
+    if (!b_bidir)
+    {
+        int intra = bcost < bestInterCost;
+        if (!intra)
+        {
+            bcost = bestInterCost;
+        }
+        fenc->intraMbs[b - p0] += intra;
+    }
+    else
+        bcost = bestInterCost; // if not bidir then bestInterCost is the best cost 
+    
+    if (p0 != p1)
+    {
+        fenc->rowSatds[b - p0][p1 - b][cuy] += bcost;
+        fenc->costEst[b - p0][p1 - b] += bcost;      
+    }
+    fenc->lowresCosts[b - p0][p1 -b][cu_xy] = (uint16_t) bcost;
+    
 }
 
 #if 0
diff -r 52a709ce88a8 -r 8f5074c0a750 source/encoder/slicetype.h
--- a/source/encoder/slicetype.h	Wed Aug 14 03:32:51 2013 -0500
+++ b/source/encoder/slicetype.h	Wed Aug 14 16:08:28 2013 +0530
@@ -59,7 +59,7 @@
     void slicetypeDecide();
 
     int estimateFrameCost(int p0, int p1, int b, int bIntraPenalty);
-    int estimateCUCost(int cux, int cuy, int p0, int p1, int b, int do_search[2]);
+    void estimateCUCost(int cux, int cuy, int p0, int p1, int b, int do_search[2]);
 };
 
 }


More information about the x265-devel mailing list