<div dir="ltr"># HG changeset patch<br># User Deepthi Nandakumar <<a href="mailto:deepthi@multicorewareinc.com">deepthi@multicorewareinc.com</a>><br># Date 1462536024 -19800<br>#      Fri May 06 17:30:24 2016 +0530<br># Node ID d2de32f15de0713d2c0514e7bac95f827a33e87f<br># Parent  a5362b9533f6a5b77740b4e8f97dba2555b6f929<br>analysis: use only skip costs for recursionDepthCheck<br><br>Also cleanup variable names<br><br>diff -r a5362b9533f6 -r d2de32f15de0 source/common/framedata.cpp<br>--- a/source/common/framedata.cpp    Wed May 04 21:08:09 2016 +0000<br>+++ b/source/common/framedata.cpp    Fri May 06 17:30:24 2016 +0530<br>@@ -41,7 +41,7 @@<br>     for (uint32_t ctuAddr = 0; ctuAddr < sps.numCUsInFrame; ctuAddr++)<br>         m_picCTU[ctuAddr].initialize(m_cuMemPool, 0, param.internalCsp, ctuAddr);<br> <br>-    CHECKED_MALLOC(m_cuStat, RCStatCU, sps.numCUsInFrame);<br>+    CHECKED_MALLOC_ZERO(m_cuStat, RCStatCU, sps.numCUsInFrame);<br>     CHECKED_MALLOC(m_rowStat, RCStatRow, sps.numCuInHeight);<br>     reinit(sps);<br>     return true;<br>diff -r a5362b9533f6 -r d2de32f15de0 source/encoder/analysis.cpp<br>--- a/source/encoder/analysis.cpp    Wed May 04 21:08:09 2016 +0000<br>+++ b/source/encoder/analysis.cpp    Fri May 06 17:30:24 2016 +0530<br>@@ -885,7 +885,8 @@<br>     bool mightSplit = !(cuGeom.flags & CUGeom::LEAF);<br>     bool mightNotSplit = !(cuGeom.flags & CUGeom::SPLIT_MANDATORY);<br>     uint32_t minDepth = topSkipMinDepth(parentCTU, cuGeom);<br>-    bool earlyskip = false;<br>+    bool skipModes = false; /* Skip any remaining mode analyses at current depth */<br>+    bool skipRecursion = false; /* Skip recursion */<br>     bool splitIntra = true;<br>     bool skipRectAmp = false;<br>     bool chooseMerge = false;<br>@@ -904,7 +905,6 @@<br>         md.pred[PRED_2Nx2N].sa8dCost = 0;<br>     }<br> <br>-    bool foundSkip = false;<br>     if (m_param->analysisMode == X265_ANALYSIS_LOAD)<br>     {<br>         if (mightNotSplit && depth == m_reuseDepth[cuGeom.absPartIdx])<br>@@ -915,9 +915,9 @@<br>                 md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom, qp);<br>                 checkMerge2Nx2N_rd0_4(md.pred[PRED_SKIP], md.pred[PRED_MERGE], cuGeom);<br> <br>-                foundSkip = true;<br>+                skipRecursion = true;<br>                 if (m_param->rdLevel)<br>-                    earlyskip = md.bestMode && m_param->bEnableEarlySkip;<br>+                    skipModes = m_param->bEnableEarlySkip && md.bestMode;<br>             }<br>             if (m_reusePartSize[cuGeom.absPartIdx] == SIZE_2Nx2N)<br>             {<br>@@ -930,26 +930,26 @@<br>         }<br>     }<br> <br>-    /* Step 1. Evaluate Merge/Skip candidates for likely early-outs */<br>-    if (mightNotSplit && depth >= minDepth && !foundSkip)<br>+    /* Step 1. Evaluate Merge/Skip candidates for likely early-outs, if skip mode was not set above */<br>+    if (mightNotSplit && depth >= minDepth && !skipRecursion)<br>     {<br>         /* Compute Merge Cost */<br>         md.pred[PRED_MERGE].cu.initSubCU(parentCTU, cuGeom, qp);<br>         md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom, qp);<br>         checkMerge2Nx2N_rd0_4(md.pred[PRED_SKIP], md.pred[PRED_MERGE], cuGeom);<br>         if (m_param->rdLevel)<br>-            earlyskip = m_param->bEnableEarlySkip && md.bestMode && md.bestMode->cu.isSkipped(0); // TODO: sa8d threshold per depth<br>+            skipModes = m_param->bEnableEarlySkip && md.bestMode && md.bestMode->cu.isSkipped(0); // TODO: sa8d threshold per depth<br>     }<br> <br>     if (md.bestMode)<br>     {<br>-        foundSkip = md.bestMode->cu.isSkipped(0);<br>-        if (mightSplit && depth && depth >= minDepth && !foundSkip)<br>-            foundSkip = recursionDepthCheck(parentCTU, cuGeom, *md.bestMode);<br>+        skipRecursion = md.bestMode->cu.isSkipped(0);<br>+        if (mightSplit && depth && depth >= minDepth && !skipRecursion)<br>+            skipRecursion = recursionDepthCheck(parentCTU, cuGeom, *md.bestMode);<br>     }<br> <br>     /* Step 2. Evaluate each of the 4 split sub-blocks in series */<br>-    if (mightSplit && !foundSkip)<br>+    if (mightSplit && !skipRecursion)<br>     {<br>         Mode* splitPred = &md.pred[PRED_SPLIT];<br>         splitPred->initCosts();<br>@@ -1011,7 +1011,7 @@<br>         if (m_slice->m_pps->bUseDQP && depth <= m_slice->m_pps->maxCuDQPDepth && m_slice->m_pps->maxCuDQPDepth != 0)<br>             setLambdaFromQP(parentCTU, qp);<br> <br>-        if (!earlyskip)<br>+        if (!skipModes)<br>         {<br>             uint32_t refMasks[2];<br>             refMasks[0] = allSplitRefs;<br>@@ -1333,7 +1333,7 @@<br>             addSplitFlagCost(*md.bestMode, cuGeom.depth);<br>     }<br> <br>-    if (mightSplit && !foundSkip)<br>+    if (mightSplit && !skipRecursion)<br>     {<br>         Mode* splitPred = &md.pred[PRED_SPLIT];<br>         if (!md.bestMode)<br>@@ -1371,9 +1371,8 @@<br>         splitCUData.sa8dCost    = md.pred[PRED_2Nx2N].sa8dCost;<br>     }<br>     <br>-    if (mightNotSplit)<br>+    if (mightNotSplit && md.bestMode->cu.isSkipped(0))<br>     {<br>-        /* early-out statistics */<br>         FrameData& curEncData = *m_frame->m_encData;<br>         FrameData::RCStatCU& cuStat = curEncData.m_cuStat[parentCTU.m_cuAddr];<br>         uint64_t temp = cuStat.avgCost[depth] * cuStat.count[depth];<br>@@ -1397,8 +1396,8 @@<br> <br>     bool mightSplit = !(cuGeom.flags & CUGeom::LEAF);<br>     bool mightNotSplit = !(cuGeom.flags & CUGeom::SPLIT_MANDATORY);<br>-    bool foundSkip = false;<br>-    bool earlyskip = false;<br>+    bool skipRecursion = false;<br>+    bool skipModes = false;<br>     bool splitIntra = true;<br>     bool skipRectAmp = false;<br> <br>@@ -1420,8 +1419,8 @@<br>                 md.pred[PRED_MERGE].cu.initSubCU(parentCTU, cuGeom, qp);<br>                 checkMerge2Nx2N_rd5_6(md.pred[PRED_SKIP], md.pred[PRED_MERGE], cuGeom);<br> <br>-                foundSkip = true;<br>-                earlyskip = !!m_param->bEnableEarlySkip;<br>+                skipRecursion = true;<br>+                skipModes = !!m_param->bEnableEarlySkip;<br>             }<br>             if (m_reusePartSize[cuGeom.absPartIdx] == SIZE_2Nx2N)<br>                 skipRectAmp = true && !!md.bestMode;<br>@@ -1435,18 +1434,18 @@<br>     splitData[3].initSplitCUData();<br> <br>     /* Step 1. Evaluate Merge/Skip candidates for likely early-outs */<br>-    if (mightNotSplit && !foundSkip)<br>+    if (mightNotSplit && !skipRecursion)<br>     {<br>         md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom, qp);<br>         md.pred[PRED_MERGE].cu.initSubCU(parentCTU, cuGeom, qp);<br>         checkMerge2Nx2N_rd5_6(md.pred[PRED_SKIP], md.pred[PRED_MERGE], cuGeom);<br>-        foundSkip = md.bestMode && !md.bestMode->cu.getQtRootCbf(0);<br>-        earlyskip = m_param->bEnableEarlySkip && foundSkip;<br>+        skipRecursion = md.bestMode && !md.bestMode->cu.getQtRootCbf(0);<br>+        skipModes = m_param->bEnableEarlySkip && skipRecursion;<br>     }<br> <br>     // estimate split cost<br>     /* Step 2. Evaluate each of the 4 split sub-blocks in series */<br>-    if (mightSplit && !foundSkip)<br>+    if (mightSplit && !skipRecursion)<br>     {<br>         Mode* splitPred = &md.pred[PRED_SPLIT];<br>         splitPred->initCosts();<br>@@ -1504,7 +1503,7 @@<br>         if (m_slice->m_pps->bUseDQP && depth <= m_slice->m_pps->maxCuDQPDepth && m_slice->m_pps->maxCuDQPDepth != 0)<br>             setLambdaFromQP(parentCTU, qp);<br> <br>-        if (!earlyskip)<br>+        if (!skipModes)<br>         {<br>             uint32_t refMasks[2];<br>             refMasks[0] = allSplitRefs;<br>@@ -1712,7 +1711,7 @@<br>     }<br> <br>     /* compare split RD cost against best cost */<br>-    if (mightSplit && !foundSkip)<br>+    if (mightSplit && !skipRecursion)<br>         checkBestMode(md.pred[PRED_SPLIT], depth);<br> <br>     if (m_param->bEnableRdRefine && depth <= m_slice->m_pps->maxCuDQPDepth)<br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div>Deepthi Nandakumar<br></div>Engineering Manager, x265<br></div>Multicoreware, Inc<br></div></div>
</div>