[x265] [PATCH] [branches master, 3.4, 3.5] Fixes inconsistency in rskip 2 at slow presets
Srikanth Kurapati
srikanth.kurapati at multicorewareinc.com
Tue Oct 13 02:43:59 CEST 2020
Please skip this patch for testing. Review in progress.
On Tue, 6 Oct, 2020, 11:10 Srikanth Kurapati, <
srikanth.kurapati at multicorewareinc.com> wrote:
> From b5b5194847c924bafcae7293d9a56fcc5a98339b Mon Sep 17 00:00:00 2001
> From: Srikanth Kurapati <srikanth.kurapati at multicorewareinc.com>
> Date: Wed, 30 Sep 2020 12:39:25 +0530
> Subject: [PATCH] Fixes inconsistency in rskip 2 for slow presets
>
> Considers the following based on rd levels
> a) colocated CTU depth information.
> b) skip decisions based on neighbour costs/residual bits.
> ---
> doc/reST/cli.rst | 6 ++++--
> source/encoder/analysis.cpp | 23 ++++++++---------------
> source/test/regression-tests.txt | 2 +-
> source/x265cli.cpp | 5 ++---
> 4 files changed, 15 insertions(+), 21 deletions(-)
>
> diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst
> index 1a1de9f50..a9f77c290 100755
> --- a/doc/reST/cli.rst
> +++ b/doc/reST/cli.rst
> @@ -854,11 +854,13 @@ the prediction quad-tree.
>
> +----------+------------+----------------------------------------------------------------+
> | RD Level | Rskip Mode | Skip Recursion Heuristic
> |
>
> +==========+============+================================================================+
> - | 0 - 4 | 1 | Neighbour costs and CU homogenity.
> |
> + | 0 - 4 | 1 | Neighbour costs and CU homogeneity.
> |
>
> +----------+------------+----------------------------------------------------------------+
> | 5 - 6 | 1 | Comparison with inter2Nx2N.
> |
>
> +----------+------------+----------------------------------------------------------------+
> - | 0 - 6 | 2 | CU edge density.
> |
> + | 0 - 6 | 2 | Neighbour costs and CU edge density.
> |
> +
> +----------+------------+----------------------------------------------------------------+
> + | 5 - 6 | 2 | Comparison with inter2Nx2N and CU edge
> density. |
>
> +----------+------------+----------------------------------------------------------------+
>
> Provides minimal quality degradation at good performance gains for
> non-zero modes.
> diff --git a/source/encoder/analysis.cpp b/source/encoder/analysis.cpp
> index aabf386ca..18a7b2988 100644
> --- a/source/encoder/analysis.cpp
> +++ b/source/encoder/analysis.cpp
> @@ -1319,17 +1319,13 @@ SplitData Analysis::compressInterCU_rd0_4(const
> CUData& parentCTU, const CUGeom&
> skipRecursion = md.bestMode->cu.isSkipped(0);
> if (mightSplit && !skipRecursion)
> {
> - if (depth >= minDepth && m_param->recursionSkipMode ==
> RDCOST_BASED_RSKIP)
> + if (depth >= minDepth)
> {
> if (depth)
> skipRecursion = recursionDepthCheck(parentCTU,
> cuGeom, *md.bestMode);
> - if (m_bHD && !skipRecursion && m_param->rdLevel == 2
> && md.fencYuv.m_size != MAX_CU_SIZE)
> + if (!skipRecursion)
> skipRecursion = complexityCheckCU(*md.bestMode);
> }
> - else if (cuGeom.log2CUSize >= MAX_LOG2_CU_SIZE - 1 &&
> m_param->recursionSkipMode == EDGE_BASED_RSKIP)
> - {
> - skipRecursion = complexityCheckCU(*md.bestMode);
> - }
>
> }
> }
> @@ -2025,8 +2021,8 @@ SplitData Analysis::compressInterCU_rd5_6(const
> CUData& parentCTU, const CUGeom&
>
> if (m_param->recursionSkipMode == RDCOST_BASED_RSKIP && depth
> && m_modeDepth[depth - 1].bestMode)
> skipRecursion = md.bestMode &&
> !md.bestMode->cu.getQtRootCbf(0);
> - else if (cuGeom.log2CUSize >= MAX_LOG2_CU_SIZE - 1 &&
> m_param->recursionSkipMode == EDGE_BASED_RSKIP)
> - skipRecursion = md.bestMode &&
> complexityCheckCU(*md.bestMode);
> + else if (m_param->recursionSkipMode == EDGE_BASED_RSKIP &&
> (!depth || (depth && m_modeDepth[depth - 1].bestMode)))
> + skipRecursion = md.bestMode &&
> (complexityCheckCU(*md.bestMode) || !md.bestMode->cu.getQtRootCbf(0));
> }
> if (m_param->bAnalysisType == AVC_INFO && md.bestMode &&
> cuGeom.numPartitions <= 16 && m_param->analysisLoadReuseLevel == 7)
> skipRecursion = true;
> @@ -3535,7 +3531,7 @@ bool Analysis::recursionDepthCheck(const CUData&
> parentCTU, const CUGeom& cuGeom
>
> bool Analysis::complexityCheckCU(const Mode& bestMode)
> {
> - if (m_param->recursionSkipMode == RDCOST_BASED_RSKIP)
> + if (m_param->recursionSkipMode == RDCOST_BASED_RSKIP && m_bHD &&
> m_param->rdLevel == 2 && bestMode.fencYuv->m_size != MAX_CU_SIZE)
> {
> uint32_t mean = 0;
> uint32_t homo = 0;
> @@ -3555,10 +3551,8 @@ bool Analysis::complexityCheckCU(const Mode&
> bestMode)
>
> if (homo < (.1 * mean))
> return true;
> -
> - return false;
> }
> - else
> + else if (bestMode.fencYuv->m_size >= MAX_CU_SIZE - 1 &&
> m_param->recursionSkipMode == EDGE_BASED_RSKIP)
> {
> int blockType = bestMode.cu.m_log2CUSize[0] - LOG2_UNIT_SIZE;
> int shift = bestMode.cu.m_log2CUSize[0] * LOG2_UNIT_SIZE;
> @@ -3570,11 +3564,10 @@ bool Analysis::complexityCheckCU(const Mode&
> bestMode)
> uint32_t pixelCount = 1 << shift;
> double cuEdgeVariance = (ss - ((double)sum * sum / pixelCount)) /
> pixelCount;
>
> - if (cuEdgeVariance > (double)m_param->edgeVarThreshold)
> - return false;
> - else
> + if (cuEdgeVariance < (double)m_param->edgeVarThreshold)
> return true;
> }
> + return false;
> }
>
> uint32_t Analysis::calculateCUVariance(const CUData& ctu, const CUGeom&
> cuGeom)
> diff --git a/source/test/regression-tests.txt
> b/source/test/regression-tests.txt
> index 22673d469..23237a263 100644
> --- a/source/test/regression-tests.txt
> +++ b/source/test/regression-tests.txt
> @@ -162,7 +162,7 @@ sintel_trailer_2k_1920x1080_24.yuv, --preset medium
> --hist-scenecut --hist-thres
> sintel_trailer_2k_1920x1080_24.yuv, --preset medium --hist-scenecut
> --hist-threshold 0.02
> sintel_trailer_2k_1920x1080_24.yuv, --preset ultrafast --hist-scenecut
> --hist-threshold 0.02
> crowd_run_1920x1080_50.yuv, --preset faster --ctu 32 --rskip 2
> --rskip-edge-threshold 5
> -crowd_run_1920x1080_50.yuv, --preset fast --ctu 64 --rskip 2
> --rskip-edge-threshold 5 --aq-mode 4
> +crowd_run_1920x1080_50.yuv, --preset medium --ctu 32 --rskip 2
> --rskip-edge-threshold 5
> crowd_run_1920x1080_50.yuv, --preset slow --ctu 32 --rskip 2
> --rskip-edge-threshold 5 --hist-scenecut --hist-threshold 0.1
> crowd_run_1920x1080_50.yuv, --preset slower --ctu 16 --rskip 2
> --rskip-edge-threshold 5 --hist-scenecut --hist-threshold 0.1 --aq-mode 4
>
> diff --git a/source/x265cli.cpp b/source/x265cli.cpp
> index c28dd7f8c..0c74bf7b6 100755
> --- a/source/x265cli.cpp
> +++ b/source/x265cli.cpp
> @@ -127,9 +127,8 @@ namespace X265_NS {
> H0(" --[no-]ssim-rd Enable ssim rate distortion
> optimization, 0 to disable. Default %s\n", OPT(param->bSsimRd));
> H0(" --[no-]rd-refine Enable QP based RD
> refinement for rd levels 5 and 6. Default %s\n",
> OPT(param->bEnableRdRefine));
> H0(" --[no-]early-skip Enable early SKIP detection.
> Default %s\n", OPT(param->bEnableEarlySkip));
> - 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"
> - " Mode 0: disabled. Default
> %d\n", param->recursionSkipMode);
> - 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);
> + 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);
> + 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);
> H1(" --[no-]tskip-fast Enable fast intra transform
> skipping. Default %s\n", OPT(param->bEnableTSkipFast));
> 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));
> 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");
> --
> 2.20.1.windows.1
>
> --
> *With Regards,*
> *Srikanth Kurapati.*
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20201013/0201c299/attachment.html>
More information about the x265-devel
mailing list