[x265] [PATCH 4 of 4] slicetype: calculate weighted frame costs for Aq

aarthi at multicorewareinc.com aarthi at multicorewareinc.com
Mon Oct 21 19:35:55 CEST 2013


# HG changeset patch
# User Aarthi Thirumalai<aarthi at multicorewareinc.com>
# Date 1382376878 -19800
#      Mon Oct 21 23:04:38 2013 +0530
# Node ID 8bee2e580fd438b3fbf631c71cbdbbf8e3eef2ff
# Parent  40c3771b3b15a68cda4f59f7f9a36f41d0733520
slicetype: calculate weighted frame costs for Aq

diff -r 40c3771b3b15 -r 8bee2e580fd4 source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Mon Oct 21 22:48:35 2013 +0530
+++ b/source/encoder/slicetype.cpp	Mon Oct 21 23:04:38 2013 +0530
@@ -197,7 +197,7 @@
         if (bDoSearch[1]) fenc->lowresMvs[1][p1 - b - 1][0].x = 0;
 
         fenc->costEst[b - p0][p1 - b] = 0;
-
+        fenc->costEstAq[b - p0][p1 - b] = 0;
         // TODO: use lowres MVs as motion candidates in full-res search
 
         for (int i = 0; i < heightInCU; i++)
@@ -233,6 +233,11 @@
         {
             score += lhrows[row].costEst;
             fenc->costEst[0][0] += lhrows[row].costIntra;
+            if (cfg->param.rc.aqMode)
+            {
+                fenc->costEstAq[0][0] += lhrows[row].costIntraAq;
+                fenc->costEst[b - p0][p1 - b] += lhrows[row].costEstAq;
+            }
             fenc->intraMbs[b - p0] += lhrows[row].intraMbs;
         }
 
@@ -250,6 +255,11 @@
         int ncu = NUM_CUS;
         score += (uint64_t)score * fenc->intraMbs[b - p0] / (ncu * 8);
     }
+
+    if (cfg->param.rc.aqMode)
+        fenc->satdCost = fenc->costEstAq[b - p0][p1 - b];
+    else
+        fenc->satdCost = score;
     x265_emms();
     return score;
 }
@@ -459,7 +469,12 @@
         // TOOD: i_icost += intra_penalty + lowres_penalty;
         fenc->intraCost[cuXY] = icost;
         fenc->rowSatds[0][0][cuy] += icost;
-        if (bFrameScoreCU) costIntra += icost;
+        if (bFrameScoreCU) 
+        {
+            costIntra += icost;
+            if (fenc->m_qpAqOffset[cuXY])
+                costIntraAq += (icost * x265_exp2fix8(fenc->m_qpAqOffset[cuXY]) + 128) >> 8;
+        }
     }
 
     if (!bBidir)
@@ -476,7 +491,12 @@
     if (p0 != p1)
     {
         fenc->rowSatds[b - p0][p1 - b][cuy] += bcost;
-        if (bFrameScoreCU) costEst += bcost;
+        if (bFrameScoreCU) 
+        {
+            costEst += bcost;
+            if (fenc->m_qpAqOffset[cuXY])
+                costEstAq += (bcost * x265_exp2fix8(fenc->m_qpAqOffset[cuXY]) + 128) >> 8;
+        }
     }
     fenc->lowresCosts[b - p0][p1 - b][cuXY] = (uint16_t)(X265_MIN(bcost, LOWRES_COST_MASK) | (listused << LOWRES_COST_SHIFT));
 }


More information about the x265-devel mailing list