<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">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><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Kavitha Sampath <<a href="mailto:kavitha@multicorewareinc.com">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>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">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>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div>Deepthi Nandakumar<br></div>Engineering Manager, x265<br></div>Multicoreware, Inc<br></div></div>
</div>