<div dir="auto">Please skip this patch for testing. Review in progress.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 6 Oct, 2020, 11:10 Srikanth Kurapati, <<a href="mailto:srikanth.kurapati@multicorewareinc.com">srikanth.kurapati@multicorewareinc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">From b5b5194847c924bafcae7293d9a56fcc5a98339b Mon Sep 17 00:00:00 2001<br>From: Srikanth Kurapati <<a href="mailto:srikanth.kurapati@multicorewareinc.com" target="_blank" rel="noreferrer">srikanth.kurapati@multicorewareinc.com</a>><br>Date: Wed, 30 Sep 2020 12:39:25 +0530<br>Subject: [PATCH] Fixes inconsistency in rskip 2 for slow presets<br><br>Considers the following based on rd levels<br>a) colocated CTU depth information.<br>b) skip decisions based on neighbour costs/residual bits.<br>---<br> doc/reST/cli.rst | 6 ++++--<br> source/encoder/analysis.cpp | 23 ++++++++---------------<br> source/test/regression-tests.txt | 2 +-<br> source/x265cli.cpp | 5 ++---<br> 4 files changed, 15 insertions(+), 21 deletions(-)<br><br>diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst<br>index 1a1de9f50..a9f77c290 100755<br>--- a/doc/reST/cli.rst<br>+++ b/doc/reST/cli.rst<br>@@ -854,11 +854,13 @@ the prediction quad-tree.<br> +----------+------------+----------------------------------------------------------------+<br> | RD Level | Rskip Mode | Skip Recursion Heuristic |<br> +==========+============+================================================================+<br>- | 0 - 4 | 1 | Neighbour costs and CU homogenity. |<br>+ | 0 - 4 | 1 | Neighbour costs and CU homogeneity. |<br> +----------+------------+----------------------------------------------------------------+<br> | 5 - 6 | 1 | Comparison with inter2Nx2N. |<br> +----------+------------+----------------------------------------------------------------+<br>- | 0 - 6 | 2 | CU edge density. |<br>+ | 0 - 6 | 2 | Neighbour costs and CU edge density. |<br>+ +----------+------------+----------------------------------------------------------------+<br>+ | 5 - 6 | 2 | Comparison with inter2Nx2N and CU edge density. |<br> +----------+------------+----------------------------------------------------------------+<br> <br> Provides minimal quality degradation at good performance gains for non-zero modes.<br>diff --git a/source/encoder/analysis.cpp b/source/encoder/analysis.cpp<br>index aabf386ca..18a7b2988 100644<br>--- a/source/encoder/analysis.cpp<br>+++ b/source/encoder/analysis.cpp<br>@@ -1319,17 +1319,13 @@ SplitData Analysis::compressInterCU_rd0_4(const CUData& parentCTU, const CUGeom&<br> skipRecursion = md.bestMode->cu.isSkipped(0);<br> if (mightSplit && !skipRecursion)<br> {<br>- if (depth >= minDepth && m_param->recursionSkipMode == RDCOST_BASED_RSKIP)<br>+ if (depth >= minDepth)<br> {<br> if (depth)<br> skipRecursion = recursionDepthCheck(parentCTU, cuGeom, *md.bestMode);<br>- if (m_bHD && !skipRecursion && m_param->rdLevel == 2 && md.fencYuv.m_size != MAX_CU_SIZE)<br>+ if (!skipRecursion)<br> skipRecursion = complexityCheckCU(*md.bestMode);<br> }<br>- else if (cuGeom.log2CUSize >= MAX_LOG2_CU_SIZE - 1 && m_param->recursionSkipMode == EDGE_BASED_RSKIP)<br>- {<br>- skipRecursion = complexityCheckCU(*md.bestMode);<br>- }<br> <br> }<br> }<br>@@ -2025,8 +2021,8 @@ SplitData Analysis::compressInterCU_rd5_6(const CUData& parentCTU, const CUGeom&<br> <br> if (m_param->recursionSkipMode == RDCOST_BASED_RSKIP && depth && m_modeDepth[depth - 1].bestMode)<br> skipRecursion = md.bestMode && !md.bestMode->cu.getQtRootCbf(0);<br>- else if (cuGeom.log2CUSize >= MAX_LOG2_CU_SIZE - 1 && m_param->recursionSkipMode == EDGE_BASED_RSKIP)<br>- skipRecursion = md.bestMode && complexityCheckCU(*md.bestMode);<br>+ else if (m_param->recursionSkipMode == EDGE_BASED_RSKIP && (!depth || (depth && m_modeDepth[depth - 1].bestMode)))<br>+ skipRecursion = md.bestMode && (complexityCheckCU(*md.bestMode) || !md.bestMode->cu.getQtRootCbf(0));<br> }<br> if (m_param->bAnalysisType == AVC_INFO && md.bestMode && cuGeom.numPartitions <= 16 && m_param->analysisLoadReuseLevel == 7)<br> skipRecursion = true;<br>@@ -3535,7 +3531,7 @@ bool Analysis::recursionDepthCheck(const CUData& parentCTU, const CUGeom& cuGeom<br> <br> bool Analysis::complexityCheckCU(const Mode& bestMode)<br> {<br>- if (m_param->recursionSkipMode == RDCOST_BASED_RSKIP)<br>+ if (m_param->recursionSkipMode == RDCOST_BASED_RSKIP && m_bHD && m_param->rdLevel == 2 && bestMode.fencYuv->m_size != MAX_CU_SIZE)<br> {<br> uint32_t mean = 0;<br> uint32_t homo = 0;<br>@@ -3555,10 +3551,8 @@ bool Analysis::complexityCheckCU(const Mode& bestMode)<br> <br> if (homo < (.1 * mean))<br> return true;<br>-<br>- return false;<br> }<br>- else<br>+ else if (bestMode.fencYuv->m_size >= MAX_CU_SIZE - 1 && m_param->recursionSkipMode == EDGE_BASED_RSKIP)<br> {<br> int blockType = bestMode.cu.m_log2CUSize[0] - LOG2_UNIT_SIZE;<br> int shift = bestMode.cu.m_log2CUSize[0] * LOG2_UNIT_SIZE;<br>@@ -3570,11 +3564,10 @@ bool Analysis::complexityCheckCU(const Mode& bestMode)<br> uint32_t pixelCount = 1 << shift;<br> double cuEdgeVariance = (ss - ((double)sum * sum / pixelCount)) / pixelCount;<br> <br>- if (cuEdgeVariance > (double)m_param->edgeVarThreshold)<br>- return false;<br>- else<br>+ if (cuEdgeVariance < (double)m_param->edgeVarThreshold)<br> return true;<br> }<br>+ return false;<br> }<br> <br> uint32_t Analysis::calculateCUVariance(const CUData& ctu, const CUGeom& cuGeom)<br>diff --git a/source/test/regression-tests.txt b/source/test/regression-tests.txt<br>index 22673d469..23237a263 100644<br>--- a/source/test/regression-tests.txt<br>+++ b/source/test/regression-tests.txt<br>@@ -162,7 +162,7 @@ sintel_trailer_2k_1920x1080_24.yuv, --preset medium --hist-scenecut --hist-thres<br> sintel_trailer_2k_1920x1080_24.yuv, --preset medium --hist-scenecut --hist-threshold 0.02<br> sintel_trailer_2k_1920x1080_24.yuv, --preset ultrafast --hist-scenecut --hist-threshold 0.02<br> crowd_run_1920x1080_50.yuv, --preset faster --ctu 32 --rskip 2 --rskip-edge-threshold 5<br>-crowd_run_1920x1080_50.yuv, --preset fast --ctu 64 --rskip 2 --rskip-edge-threshold 5 --aq-mode 4<br>+crowd_run_1920x1080_50.yuv, --preset medium --ctu 32 --rskip 2 --rskip-edge-threshold 5<br> crowd_run_1920x1080_50.yuv, --preset slow --ctu 32 --rskip 2 --rskip-edge-threshold 5 --hist-scenecut --hist-threshold 0.1<br> crowd_run_1920x1080_50.yuv, --preset slower --ctu 16 --rskip 2 --rskip-edge-threshold 5 --hist-scenecut --hist-threshold 0.1 --aq-mode 4<br> <br>diff --git a/source/x265cli.cpp b/source/x265cli.cpp<br>index c28dd7f8c..0c74bf7b6 100755<br>--- a/source/x265cli.cpp<br>+++ b/source/x265cli.cpp<br>@@ -127,9 +127,8 @@ namespace X265_NS {<br> H0(" --[no-]ssim-rd Enable ssim rate distortion optimization, 0 to disable. Default %s\n", OPT(param->bSsimRd));<br> H0(" --[no-]rd-refine Enable QP based RD refinement for rd levels 5 and 6. Default %s\n", OPT(param->bEnableRdRefine));<br> H0(" --[no-]early-skip Enable early SKIP detection. Default %s\n", OPT(param->bEnableEarlySkip));<br>- H0(" --rskip <mode> Set mode for early exit from recursion. Mode 1: exit using rdcost & CU homogenity. Mode 2: exit using CU edge density.\n"<br>- " Mode 0: disabled. Default %d\n", param->recursionSkipMode);<br>- H1(" --rskip-edge-threshold Threshold in terms of percentage (integer of range [0,100]) for minimum edge density in CUs used to prun the recursion depth. Applicable only for rskip mode 2. Value is preset dependent. Default: %.f\n", param->edgeVarThreshold*100.0f);<br>+ H0(" --rskip <Integer> Enable recursion skip for early exit from CTU analysis during inter prediction. 1: exit using RD cost & CU homogeneity. 2: exit using RD cost and CU edge density. 0: disabled. Default %d\n", param->recursionSkipMode);<br>+ H1(" --rskip-edge-threshold Threshold in terms of percentage (an integer of range [0,100]) for minimum edge density in CU's used to prune the recursion depth. Applicable only to rskip mode 2. Value is preset dependent. Default: %.f\n", param->edgeVarThreshold*100.0f);<br> H1(" --[no-]tskip-fast Enable fast intra transform skipping. Default %s\n", OPT(param->bEnableTSkipFast));<br> H1(" --[no-]splitrd-skip Enable skipping split RD analysis when sum of split CU rdCost larger than one split CU rdCost for Intra CU. Default %s\n", OPT(param->bEnableSplitRdSkip));<br> H1(" --nr-intra <integer> An integer value in range of 0 to 2000, which denotes strength of noise reduction in intra CUs. Default 0\n");<font color="#888888"><br>--<br>2.20.1.windows.1</font> <br clear="all"><div><br></div>-- <br><div dir="ltr" data-smartmail="gmail_signature"><div dir="ltr"><b style="background-color:rgb(255,255,255)"><font color="#0b5394">With Regards,</font></b><div><b style="background-color:rgb(255,255,255)"><font color="#0b5394">Srikanth Kurapati.</font></b></div></div></div></div>
</blockquote></div>