<div dir="ltr"><div># HG changeset patch</div><div># User Kavitha Sampath <<a href="mailto:kavitha@multicorewareinc.com">kavitha@multicorewareinc.com</a>></div><div># Date 1465814710 -19800</div><div>#      Mon Jun 13 16:15:10 2016 +0530</div><div># Node ID d9a7d21cb17918f869f0ff3407dec764880827d4</div><div># Parent  106a5a7dc4b337121c11484bc3bc4900b8a0d9a4</div><div>rd: determine CU complexity to skip analysis of higher depths</div><div><br></div><div>Complexity check is performed for RD level 2 of 4K videos</div><div><br></div><div>diff -r 106a5a7dc4b3 -r d9a7d21cb179 source/encoder/analysis.cpp</div><div>--- a/source/encoder/analysis.cpp<span class="" style="white-space:pre"> </span>Thu Jun 09 13:34:55 2016 -0500</div><div>+++ b/source/encoder/analysis.cpp<span class="" style="white-space:pre">    </span>Mon Jun 13 16:15:10 2016 +0530</div><div>@@ -74,6 +74,7 @@</div><div> {</div><div>     m_reuseInterDataCTU = NULL;</div><div>     m_reuseRef = NULL;</div><div>+    m_is4k = false;</div><div> }</div><div> bool Analysis::create(ThreadLocalData *tld)</div><div> {</div><div>@@ -105,6 +106,8 @@</div><div>             md.pred[j].fencYuv = &md.fencYuv;</div><div>         }</div><div>     }</div><div>+    if (m_param->sourceWidth >= 3840)</div><div>+        m_is4k = true;</div><div> </div><div>     return ok;</div><div> }</div><div>@@ -944,8 +947,13 @@</div><div>     if (md.bestMode && m_param->bEnableRecursionSkip)</div><div>     {</div><div>         skipRecursion = md.bestMode->cu.isSkipped(0);</div><div>-        if (mightSplit && depth && depth >= minDepth && !skipRecursion)</div><div>-            skipRecursion = recursionDepthCheck(parentCTU, cuGeom, *md.bestMode);</div><div>+        if (mightSplit && depth >= minDepth && !skipRecursion)</div><div>+        {</div><div>+            if (depth)</div><div>+                skipRecursion = recursionDepthCheck(parentCTU, cuGeom, *md.bestMode);</div><div>+            if (m_is4k && !skipRecursion && m_param->rdLevel == 2 && md.fencYuv.m_size != MAX_CU_SIZE)</div><div>+                skipRecursion = complexityCheckCU(*md.bestMode);</div><div>+        }</div><div>     }</div><div> </div><div>     /* Step 2. Evaluate each of the 4 split sub-blocks in series */</div><div>@@ -2593,6 +2601,30 @@</div><div>     return false;</div><div> }</div><div> </div><div>+bool Analysis::complexityCheckCU(const Mode& bestMode)</div><div>+{</div><div>+    uint32_t mean = 0;</div><div>+    uint32_t homo = 0;</div><div>+    uint32_t cuSize = bestMode.fencYuv->m_size;</div><div>+    for (uint32_t y = 0; y < cuSize; y++) {</div><div>+        for (uint32_t x = 0; x < cuSize; x++) {</div><div>+            mean += (bestMode.fencYuv->m_buf[0][y * cuSize + x]);</div><div>+        }</div><div>+    }</div><div>+    mean = mean / (cuSize * cuSize);</div><div>+    for (uint32_t y = 0 ; y < cuSize; y++){</div><div>+        for (uint32_t x = 0 ; x < cuSize; x++){</div><div>+            homo += abs(int(bestMode.fencYuv->m_buf[0][y * cuSize + x] - mean));</div><div>+        }</div><div>+    }</div><div>+    homo = homo / (cuSize * cuSize);</div><div>+</div><div>+    if (homo < (.1 * mean))</div><div>+        return true;</div><div>+</div><div>+    return false;</div><div>+}</div><div>+</div><div> int Analysis::calculateQpforCuSize(const CUData& ctu, const CUGeom& cuGeom, double baseQp)</div><div> {</div><div>     FrameData& curEncData = *m_frame->m_encData;</div><div>diff -r 106a5a7dc4b3 -r d9a7d21cb179 source/encoder/analysis.h</div><div>--- a/source/encoder/analysis.h<span class="" style="white-space:pre">     </span>Thu Jun 09 13:34:55 2016 -0500</div><div>+++ b/source/encoder/analysis.h<span class="" style="white-space:pre">      </span>Mon Jun 13 16:15:10 2016 +0530</div><div>@@ -108,6 +108,7 @@</div><div>     ModeDepth m_modeDepth[NUM_CU_DEPTH];</div><div>     bool      m_bTryLossless;</div><div>     bool      m_bChromaSa8d;</div><div>+    bool      m_is4k;</div><div> </div><div>     Analysis();</div><div> </div><div>@@ -160,6 +161,7 @@</div><div>     /* work-avoidance heuristics for RD levels < 5 */</div><div>     uint32_t topSkipMinDepth(const CUData& parentCTU, const CUGeom& cuGeom);</div><div>     bool recursionDepthCheck(const CUData& parentCTU, const CUGeom& cuGeom, const Mode& bestMode);</div><div>+    bool complexityCheckCU(const Mode& bestMode);</div><div> </div><div>     /* generate residual and recon pixels for an entire CTU recursively (RD0) */</div><div>     void encodeResidue(const CUData& parentCTU, const CUGeom& cuGeom);</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 13, 2016 at 3:50 PM, Kavitha Sampath <span dir="ltr"><<a href="mailto:kavitha@multicorewareinc.com" target="_blank">kavitha@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">yes I can make that a member of Analysis<br>I will make the change and send the updated patch</div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Mon, Jun 13, 2016 at 12:28 PM, Deepthi Nandakumar <span dir="ltr"><<a href="mailto:deepthi@multicorewareinc.com" target="_blank">deepthi@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Kavitha,<div><br></div><div>Is there a need to introduce another global variable - can't we just keep a local one here, or one in Analysis? <br></div><div><br></div><div>Deepthi</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Thu, Jun 9, 2016 at 12:07 PM,  <span dir="ltr"><<a href="mailto:kavitha@multicorewareinc.com" target="_blank">kavitha@multicorewareinc.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div># HG changeset patch<br>
# User Kavitha Sampath <<a href="mailto:kavitha@multicorewareinc.com" target="_blank">kavitha@multicorewareinc.com</a>><br>
# Date 1463588688 25200<br>
#      Wed May 18 09:24:48 2016 -0700<br>
# Node ID 4baa78c17dca00c3d2f8a1c4d5e0ae87d7463f05<br>
# Parent  0af296185f7ae3e05493ecf164046ddfec085bb3<br>
rd: determine CU complexity to skip analysis of higher depths<br>
<br>
Complexity check is performed for RD level 2 of 4K videos<br>
<br>
diff -r 0af296185f7a -r 4baa78c17dca source/common/constants.cpp<br>
--- a/source/common/constants.cpp       Tue Jun 07 09:20:11 2016 +0530<br>
+++ b/source/common/constants.cpp       Wed May 18 09:24:48 2016 -0700<br>
@@ -161,6 +161,7 @@<br>
     65535<br>
 };<br>
<br>
+bool     g_is4k = false;<br>
 int      g_ctuSizeConfigured = 0;<br>
 uint32_t g_maxLog2CUSize = MAX_LOG2_CU_SIZE;<br>
 uint32_t g_maxCUSize     = MAX_CU_SIZE;<br>
diff -r 0af296185f7a -r 4baa78c17dca source/common/constants.h<br>
--- a/source/common/constants.h Tue Jun 07 09:20:11 2016 +0530<br>
+++ b/source/common/constants.h Wed May 18 09:24:48 2016 -0700<br>
@@ -31,6 +31,7 @@<br>
 // private namespace<br>
<br>
 extern int g_ctuSizeConfigured;<br>
+extern bool g_is4k;<br>
<br>
 void initZscanToRaster(uint32_t maxFullDepth, uint32_t depth, uint32_t startVal, uint32_t*& curIdx);<br>
 void initRasterToZscan(uint32_t maxFullDepth);<br>
diff -r 0af296185f7a -r 4baa78c17dca source/common/param.cpp<br>
--- a/source/common/param.cpp   Tue Jun 07 09:20:11 2016 +0530<br>
+++ b/source/common/param.cpp   Wed May 18 09:24:48 2016 -0700<br>
@@ -1265,6 +1265,9 @@<br>
         initZscanToRaster(g_unitSizeDepth, 1, 0, tmp);<br>
         initRasterToZscan(g_unitSizeDepth);<br>
     }<br>
+    if (param->sourceWidth >= 3840)<br>
+        g_is4k = true;<br>
+<br>
     return 0;<br>
 }<br>
<br>
diff -r 0af296185f7a -r 4baa78c17dca source/encoder/analysis.cpp<br>
--- a/source/encoder/analysis.cpp       Tue Jun 07 09:20:11 2016 +0530<br>
+++ b/source/encoder/analysis.cpp       Wed May 18 09:24:48 2016 -0700<br>
@@ -944,8 +944,13 @@<br>
     if (md.bestMode && m_param->bEnableRecursionSkip)<br>
     {<br>
         skipRecursion = md.bestMode->cu.isSkipped(0);<br>
-        if (mightSplit && depth && depth >= minDepth && !skipRecursion)<br>
-            skipRecursion = recursionDepthCheck(parentCTU, cuGeom, *md.bestMode);<br>
+        if (mightSplit && depth >= minDepth && !skipRecursion)<br>
+        {<br>
+            if (depth)<br>
+                skipRecursion = recursionDepthCheck(parentCTU, cuGeom, *md.bestMode);<br>
+            if (g_is4k && !skipRecursion && m_param->rdLevel == 2 && md.fencYuv.m_size != MAX_CU_SIZE)<br>
+                skipRecursion = complexityCheckCU(*md.bestMode);<br>
+        }<br>
     }<br>
<br>
     /* Step 2. Evaluate each of the 4 split sub-blocks in series */<br>
@@ -2593,6 +2598,30 @@<br>
     return false;<br>
 }<br>
<br>
+bool Analysis::complexityCheckCU(const Mode& bestMode)<br>
+{<br>
+    uint32_t mean = 0;<br>
+    uint32_t homo = 0;<br>
+    uint32_t cuSize = bestMode.fencYuv->m_size;<br>
+    for (uint32_t y = 0; y < cuSize; y++) {<br>
+        for (uint32_t x = 0; x < cuSize; x++) {<br>
+            mean += (bestMode.fencYuv->m_buf[0][y * cuSize + x]);<br>
+        }<br>
+    }<br>
+    mean = mean / (cuSize * cuSize);<br>
+    for (uint32_t y = 0 ; y < cuSize; y++){<br>
+        for (uint32_t x = 0 ; x < cuSize; x++){<br>
+            homo += abs(int(bestMode.fencYuv->m_buf[0][y * cuSize + x] - mean));<br>
+        }<br>
+    }<br>
+    homo = homo / (cuSize * cuSize);<br>
+<br>
+    if (homo < (.1 * mean))<br>
+        return true;<br>
+<br>
+    return false;<br>
+}<br>
+<br>
 int Analysis::calculateQpforCuSize(const CUData& ctu, const CUGeom& cuGeom, double baseQp)<br>
 {<br>
     FrameData& curEncData = *m_frame->m_encData;<br>
diff -r 0af296185f7a -r 4baa78c17dca source/encoder/analysis.h<br>
--- a/source/encoder/analysis.h Tue Jun 07 09:20:11 2016 +0530<br>
+++ b/source/encoder/analysis.h Wed May 18 09:24:48 2016 -0700<br>
@@ -160,6 +160,7 @@<br>
     /* work-avoidance heuristics for RD levels < 5 */<br>
     uint32_t topSkipMinDepth(const CUData& parentCTU, const CUGeom& cuGeom);<br>
     bool recursionDepthCheck(const CUData& parentCTU, const CUGeom& cuGeom, const Mode& bestMode);<br>
+    bool complexityCheckCU(const Mode& bestMode);<br>
<br>
     /* generate residual and recon pixels for an entire CTU recursively (RD0) */<br>
     void encodeResidue(const CUData& parentCTU, const CUGeom& cuGeom);<br></div></div>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><span><font color="#888888"><br>
</font></span></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div data-smartmail="gmail_signature"><div dir="ltr"><div><div>Deepthi Nandakumar<br></div>Engineering Manager, x265<br></div>Multicoreware, Inc<br></div></div>
</font></span></div>
<br>_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br></div></div><div data-smartmail="gmail_signature"><div dir="ltr"><font color="#0000ff">Regards,<br>Kavitha</font></div></div>
</div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><font color="#0000ff">Regards,<br>Kavitha</font></div></div>
</div>