[x265] analysis: use only skip costs for recursionDepthCheck

Deepthi Nandakumar deepthi at multicorewareinc.com
Thu May 12 16:37:30 CEST 2016


# HG changeset patch
# User Deepthi Nandakumar <deepthi at multicorewareinc.com>
# Date 1462536024 -19800
#      Fri May 06 17:30:24 2016 +0530
# Node ID d2de32f15de0713d2c0514e7bac95f827a33e87f
# Parent  a5362b9533f6a5b77740b4e8f97dba2555b6f929
analysis: use only skip costs for recursionDepthCheck

Also cleanup variable names

diff -r a5362b9533f6 -r d2de32f15de0 source/common/framedata.cpp
--- a/source/common/framedata.cpp    Wed May 04 21:08:09 2016 +0000
+++ b/source/common/framedata.cpp    Fri May 06 17:30:24 2016 +0530
@@ -41,7 +41,7 @@
     for (uint32_t ctuAddr = 0; ctuAddr < sps.numCUsInFrame; ctuAddr++)
         m_picCTU[ctuAddr].initialize(m_cuMemPool, 0, param.internalCsp,
ctuAddr);

-    CHECKED_MALLOC(m_cuStat, RCStatCU, sps.numCUsInFrame);
+    CHECKED_MALLOC_ZERO(m_cuStat, RCStatCU, sps.numCUsInFrame);
     CHECKED_MALLOC(m_rowStat, RCStatRow, sps.numCuInHeight);
     reinit(sps);
     return true;
diff -r a5362b9533f6 -r d2de32f15de0 source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp    Wed May 04 21:08:09 2016 +0000
+++ b/source/encoder/analysis.cpp    Fri May 06 17:30:24 2016 +0530
@@ -885,7 +885,8 @@
     bool mightSplit = !(cuGeom.flags & CUGeom::LEAF);
     bool mightNotSplit = !(cuGeom.flags & CUGeom::SPLIT_MANDATORY);
     uint32_t minDepth = topSkipMinDepth(parentCTU, cuGeom);
-    bool earlyskip = false;
+    bool skipModes = false; /* Skip any remaining mode analyses at current
depth */
+    bool skipRecursion = false; /* Skip recursion */
     bool splitIntra = true;
     bool skipRectAmp = false;
     bool chooseMerge = false;
@@ -904,7 +905,6 @@
         md.pred[PRED_2Nx2N].sa8dCost = 0;
     }

-    bool foundSkip = false;
     if (m_param->analysisMode == X265_ANALYSIS_LOAD)
     {
         if (mightNotSplit && depth == m_reuseDepth[cuGeom.absPartIdx])
@@ -915,9 +915,9 @@
                 md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom, qp);
                 checkMerge2Nx2N_rd0_4(md.pred[PRED_SKIP],
md.pred[PRED_MERGE], cuGeom);

-                foundSkip = true;
+                skipRecursion = true;
                 if (m_param->rdLevel)
-                    earlyskip = md.bestMode && m_param->bEnableEarlySkip;
+                    skipModes = m_param->bEnableEarlySkip && md.bestMode;
             }
             if (m_reusePartSize[cuGeom.absPartIdx] == SIZE_2Nx2N)
             {
@@ -930,26 +930,26 @@
         }
     }

-    /* Step 1. Evaluate Merge/Skip candidates for likely early-outs */
-    if (mightNotSplit && depth >= minDepth && !foundSkip)
+    /* Step 1. Evaluate Merge/Skip candidates for likely early-outs, if
skip mode was not set above */
+    if (mightNotSplit && depth >= minDepth && !skipRecursion)
     {
         /* Compute Merge Cost */
         md.pred[PRED_MERGE].cu.initSubCU(parentCTU, cuGeom, qp);
         md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom, qp);
         checkMerge2Nx2N_rd0_4(md.pred[PRED_SKIP], md.pred[PRED_MERGE],
cuGeom);
         if (m_param->rdLevel)
-            earlyskip = m_param->bEnableEarlySkip && md.bestMode &&
md.bestMode->cu.isSkipped(0); // TODO: sa8d threshold per depth
+            skipModes = m_param->bEnableEarlySkip && md.bestMode &&
md.bestMode->cu.isSkipped(0); // TODO: sa8d threshold per depth
     }

     if (md.bestMode)
     {
-        foundSkip = md.bestMode->cu.isSkipped(0);
-        if (mightSplit && depth && depth >= minDepth && !foundSkip)
-            foundSkip = recursionDepthCheck(parentCTU, cuGeom,
*md.bestMode);
+        skipRecursion = md.bestMode->cu.isSkipped(0);
+        if (mightSplit && depth && depth >= minDepth && !skipRecursion)
+            skipRecursion = recursionDepthCheck(parentCTU, cuGeom,
*md.bestMode);
     }

     /* Step 2. Evaluate each of the 4 split sub-blocks in series */
-    if (mightSplit && !foundSkip)
+    if (mightSplit && !skipRecursion)
     {
         Mode* splitPred = &md.pred[PRED_SPLIT];
         splitPred->initCosts();
@@ -1011,7 +1011,7 @@
         if (m_slice->m_pps->bUseDQP && depth <=
m_slice->m_pps->maxCuDQPDepth && m_slice->m_pps->maxCuDQPDepth != 0)
             setLambdaFromQP(parentCTU, qp);

-        if (!earlyskip)
+        if (!skipModes)
         {
             uint32_t refMasks[2];
             refMasks[0] = allSplitRefs;
@@ -1333,7 +1333,7 @@
             addSplitFlagCost(*md.bestMode, cuGeom.depth);
     }

-    if (mightSplit && !foundSkip)
+    if (mightSplit && !skipRecursion)
     {
         Mode* splitPred = &md.pred[PRED_SPLIT];
         if (!md.bestMode)
@@ -1371,9 +1371,8 @@
         splitCUData.sa8dCost    = md.pred[PRED_2Nx2N].sa8dCost;
     }

-    if (mightNotSplit)
+    if (mightNotSplit && md.bestMode->cu.isSkipped(0))
     {
-        /* early-out statistics */
         FrameData& curEncData = *m_frame->m_encData;
         FrameData::RCStatCU& cuStat =
curEncData.m_cuStat[parentCTU.m_cuAddr];
         uint64_t temp = cuStat.avgCost[depth] * cuStat.count[depth];
@@ -1397,8 +1396,8 @@

     bool mightSplit = !(cuGeom.flags & CUGeom::LEAF);
     bool mightNotSplit = !(cuGeom.flags & CUGeom::SPLIT_MANDATORY);
-    bool foundSkip = false;
-    bool earlyskip = false;
+    bool skipRecursion = false;
+    bool skipModes = false;
     bool splitIntra = true;
     bool skipRectAmp = false;

@@ -1420,8 +1419,8 @@
                 md.pred[PRED_MERGE].cu.initSubCU(parentCTU, cuGeom, qp);
                 checkMerge2Nx2N_rd5_6(md.pred[PRED_SKIP],
md.pred[PRED_MERGE], cuGeom);

-                foundSkip = true;
-                earlyskip = !!m_param->bEnableEarlySkip;
+                skipRecursion = true;
+                skipModes = !!m_param->bEnableEarlySkip;
             }
             if (m_reusePartSize[cuGeom.absPartIdx] == SIZE_2Nx2N)
                 skipRectAmp = true && !!md.bestMode;
@@ -1435,18 +1434,18 @@
     splitData[3].initSplitCUData();

     /* Step 1. Evaluate Merge/Skip candidates for likely early-outs */
-    if (mightNotSplit && !foundSkip)
+    if (mightNotSplit && !skipRecursion)
     {
         md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom, qp);
         md.pred[PRED_MERGE].cu.initSubCU(parentCTU, cuGeom, qp);
         checkMerge2Nx2N_rd5_6(md.pred[PRED_SKIP], md.pred[PRED_MERGE],
cuGeom);
-        foundSkip = md.bestMode && !md.bestMode->cu.getQtRootCbf(0);
-        earlyskip = m_param->bEnableEarlySkip && foundSkip;
+        skipRecursion = md.bestMode && !md.bestMode->cu.getQtRootCbf(0);
+        skipModes = m_param->bEnableEarlySkip && skipRecursion;
     }

     // estimate split cost
     /* Step 2. Evaluate each of the 4 split sub-blocks in series */
-    if (mightSplit && !foundSkip)
+    if (mightSplit && !skipRecursion)
     {
         Mode* splitPred = &md.pred[PRED_SPLIT];
         splitPred->initCosts();
@@ -1504,7 +1503,7 @@
         if (m_slice->m_pps->bUseDQP && depth <=
m_slice->m_pps->maxCuDQPDepth && m_slice->m_pps->maxCuDQPDepth != 0)
             setLambdaFromQP(parentCTU, qp);

-        if (!earlyskip)
+        if (!skipModes)
         {
             uint32_t refMasks[2];
             refMasks[0] = allSplitRefs;
@@ -1712,7 +1711,7 @@
     }

     /* compare split RD cost against best cost */
-    if (mightSplit && !foundSkip)
+    if (mightSplit && !skipRecursion)
         checkBestMode(md.pred[PRED_SPLIT], depth);

     if (m_param->bEnableRdRefine && depth <= m_slice->m_pps->maxCuDQPDepth)


-- 
Deepthi Nandakumar
Engineering Manager, x265
Multicoreware, Inc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20160512/3192b407/attachment-0001.html>


More information about the x265-devel mailing list