[x265] [PATCH 1 of 2] Introduce refine-inter levels 2 and 3
Pradeep Ramachandran
pradeep at multicorewareinc.com
Thu Aug 10 08:50:34 CEST 2017
On Wed, Aug 9, 2017 at 6:11 PM, <bhavna at multicorewareinc.com> wrote:
> # HG changeset patch
> # User Bhavna Hariharan <bhavna at multicorewareinc.com>
> # Date 1500881283 -19800
> # Mon Jul 24 12:58:03 2017 +0530
> # Node ID 81f17d9c7c273e4b282be66bf8bcd193e25a1d2e
> # Parent d11482e5fedbcdaf62ee3c6872f43827d99ad181
> Introduce refine-inter levels 2 and 3
>
Pushed both patches to default branch
>
> refine-inter 2 limits the modes evaluated in the encode that uses
> --analysis-reuse-mode load.
> 2nx2n in save encode - disable re-evaluation of rect and amp
> skip in save encode - re-evaluates only skip, merge and 2nx2n modes
>
> refine-inter 3 will force only the depth from the encode that uses
> --analysis-reuse-mode=save and re-evaluates all the modes in the
> encode that uses --analysis-reuse-mode=load.
>
> diff -r d11482e5fedb -r 81f17d9c7c27 doc/reST/cli.rst
> --- a/doc/reST/cli.rst Mon Jul 24 11:15:38 2017 +0530
> +++ b/doc/reST/cli.rst Mon Jul 24 12:58:03 2017 +0530
> @@ -897,24 +897,38 @@
>
> Enables refinement of intra blocks in current encode.
>
> - Level 0 - Forces both mode and depth from the previous encode.
> + Level 0 - Forces both mode and depth from the save encode.
>
> - Level 1 - Evaluates all intra modes for blocks of size one smaller
> than
> - the min-cu-size of the incoming analysis data from the previous
> encode,
> - forces modes for blocks of larger size.
> + Level 1 - Evaluates all intra modes at current depth(n) and at
> depth
> + (n+1) when current block size is one greater than the min-cu-size.
> + Forces modes for larger blocks.
>
> - Level 2 - Evaluates all intra modes for blocks of size one smaller
> than
> - the min-cu-size of the incoming analysis data from the previous
> encode.
> - For larger blocks, force only depth when angular mode is chosen by
> the
> - previous encode, force depth and mode when other intra modes are
> chosen.
> + Level 2 - In addition to the functionality of level 1, at all
> depths, force
> + (a) only depth when angular mode is chosen by the save encode.
> + (b) depth and mode when other intra modes are chosen by the save
> encode.
>
> Default 0.
>
> -.. option:: --refine-inter-depth
> -
> - Enables refinement of inter blocks in current encode. Evaluates all
> - inter modes for blocks of size one smaller than the min-cu-size of
> the
> - incoming analysis data from the previous encode. Default disabled.
> +.. option:: --refine-inter <0..3>
> +
> + Enables refinement of inter blocks in current encode.
> +
> + Level 0 - Forces both mode and depth from the save encode.
> +
> + Level 1 - Evaluates all inter modes at current depth(n) and at
> depth
> + (n+1) when current block size is one greater than the min-cu-size.
> + Forces modes for larger blocks.
> +
> + Level 2 - In addition to the functionality of level 1, restricts
> the modes
> + evaluated when specific modes are decided as the best mode by the
> save encode.
> +
> + 2nx2n in save encode - disable re-evaluation of rect and amp.
> +
> + skip in save encode - re-evaluates only skip, merge and 2nx2n
> modes.
> +
> + Level 3 - Perform analysis of inter modes while reusing depths
> from the save encode.
> +
> + Default 0.
>
> .. option:: --refine-mv
>
> diff -r d11482e5fedb -r 81f17d9c7c27 source/CMakeLists.txt
> --- a/source/CMakeLists.txt Mon Jul 24 11:15:38 2017 +0530
> +++ b/source/CMakeLists.txt Mon Jul 24 12:58:03 2017 +0530
> @@ -29,7 +29,7 @@
> option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)
> mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
> # X265_BUILD must be incremented each time the public API is changed
> -set(X265_BUILD 131)
> +set(X265_BUILD 132)
> configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
> "${PROJECT_BINARY_DIR}/x265.def")
> configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r d11482e5fedb -r 81f17d9c7c27 source/common/param.cpp
> --- a/source/common/param.cpp Mon Jul 24 11:15:38 2017 +0530
> +++ b/source/common/param.cpp Mon Jul 24 12:58:03 2017 +0530
> @@ -972,7 +972,7 @@
> OPT("ctu-info") p->bCTUInfo = atoi(value);
> OPT("scale-factor") p->scaleFactor = atoi(value);
> OPT("refine-intra")p->intraRefine = atoi(value);
> - OPT("refine-inter")p->interRefine = atobool(value);
> + OPT("refine-inter")p->interRefine = atoi(value);
> OPT("refine-mv")p->mvRefine = atobool(value);
> OPT("force-flush")p->forceFlush = atoi(value);
> else
> @@ -1318,6 +1318,10 @@
> "Supported range for log2MaxPocLsb is 4 to 16");
> CHECK(param->bCTUInfo < 0 || (param->bCTUInfo != 0 && param->bCTUInfo
> != 1 && param->bCTUInfo != 2 && param->bCTUInfo != 4 && param->bCTUInfo !=
> 6) || param->bCTUInfo > 6,
> "Supported values for bCTUInfo are 0, 1, 2, 4, 6");
> + CHECK(param->interRefine > 3 || param->interRefine < 0,
> + "Invalid refine-inter value, refine-inter levels 0 to 3
> supported");
> + CHECK(param->intraRefine > 2 || param->intraRefine < 0,
> + "Invalid refine-intra value, refine-intra levels 0 to 2
> supported");
> #if !X86_64
> CHECK(param->searchMethod == X265_SEA && (param->sourceWidth > 840 ||
> param->sourceHeight > 480),
> "SEA motion search does not support resolutions greater than 480p
> in 32 bit build");
> diff -r d11482e5fedb -r 81f17d9c7c27 source/encoder/analysis.cpp
> --- a/source/encoder/analysis.cpp Mon Jul 24 11:15:38 2017 +0530
> +++ b/source/encoder/analysis.cpp Mon Jul 24 12:58:03 2017 +0530
> @@ -1131,10 +1131,18 @@
> bool chooseMerge = false;
> bool bCtuInfoCheck = false;
> int sameContentRef = 0;
> -
> - if (m_evaluateInter == 1)
> + bool checkRefineInter = false;
> +
> + if (m_evaluateInter)
> {
> - skipRectAmp = !!md.bestMode;
> + if (m_param->interRefine == 2)
> + {
> + checkRefineInter = true;
> + if (parentCTU.m_predMode[cuGeom.absPartIdx] == MODE_SKIP)
> + skipModes = true;
> + if (parentCTU.m_partSize[cuGeom.absPartIdx] == SIZE_2Nx2N)
> + skipRectAmp = true;
> + }
> mightSplit &= false;
> minDepth = depth;
> }
> @@ -1252,7 +1260,8 @@
> md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom, qp);
> checkMerge2Nx2N_rd0_4(md.pred[PRED_SKIP], md.pred[PRED_MERGE],
> cuGeom);
> if (m_param->rdLevel)
> - skipModes = m_param->bEnableEarlySkip && md.bestMode &&
> md.bestMode->cu.isSkipped(0); // TODO: sa8d threshold per depth
> + skipModes = (m_param->bEnableEarlySkip || checkRefineInter)
> + && md.bestMode && md.bestMode->cu.isSkipped(0);
> // TODO: sa8d threshold per depth
> }
>
> if (md.bestMode && m_param->bEnableRecursionSkip && !bCtuInfoCheck)
> @@ -1511,7 +1520,7 @@
> }
> }
> }
> - bool bTryIntra = (m_slice->m_sliceType != B_SLICE ||
> m_param->bIntraInBFrames) && cuGeom.log2CUSize != MAX_LOG2_CU_SIZE &&
> !((m_param->bCTUInfo & 4) && bCtuInfoCheck);
> + bool bTryIntra = (m_slice->m_sliceType != B_SLICE ||
> m_param->bIntraInBFrames) && cuGeom.log2CUSize != MAX_LOG2_CU_SIZE &&
> !((m_param->bCTUInfo & 4) && bCtuInfoCheck) && !checkRefineInter;
> if (m_param->rdLevel >= 3)
> {
> /* Calculate RD cost of best inter option */
> @@ -1756,10 +1765,18 @@
> bool skipRectAmp = false;
> bool bCtuInfoCheck = false;
> int sameContentRef = 0;
> -
> - if (m_evaluateInter == 1)
> + bool checkRefineInter = false;
> +
> + if (m_evaluateInter)
> {
> - skipRectAmp = !!md.bestMode;
> + if (m_param->interRefine == 2)
> + {
> + checkRefineInter = true;
> + if (parentCTU.m_predMode[cuGeom.absPartIdx] == MODE_SKIP)
> + skipModes = true;
> + if (parentCTU.m_partSize[cuGeom.absPartIdx] == SIZE_2Nx2N)
> + skipRectAmp = true;
> + }
> mightSplit &= false;
> }
>
> @@ -1883,7 +1900,8 @@
> md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom, qp);
> md.pred[PRED_MERGE].cu.initSubCU(parentCTU, cuGeom, qp);
> checkMerge2Nx2N_rd5_6(md.pred[PRED_SKIP], md.pred[PRED_MERGE],
> cuGeom);
> - skipModes = m_param->bEnableEarlySkip && md.bestMode &&
> !md.bestMode->cu.getQtRootCbf(0);
> + skipModes = (m_param->bEnableEarlySkip || checkRefineInter) &&
> + md.bestMode && !md.bestMode->cu.getQtRootCbf(0);
> refMasks[0] = allSplitRefs;
> md.pred[PRED_2Nx2N].cu.initSubCU(parentCTU, cuGeom, qp);
> checkInter_rd5_6(md.pred[PRED_2Nx2N], cuGeom, SIZE_2Nx2N,
> refMasks);
> @@ -2135,7 +2153,7 @@
> }
> }
>
> - if ((m_slice->m_sliceType != B_SLICE ||
> m_param->bIntraInBFrames) && (cuGeom.log2CUSize != MAX_LOG2_CU_SIZE) &&
> !((m_param->bCTUInfo & 4) && bCtuInfoCheck))
> + if ((m_slice->m_sliceType != B_SLICE ||
> m_param->bIntraInBFrames) && (cuGeom.log2CUSize != MAX_LOG2_CU_SIZE) &&
> !((m_param->bCTUInfo & 4) && bCtuInfoCheck) && !checkRefineInter)
> {
> if (!m_param->limitReferences || splitIntra)
> {
> @@ -2260,7 +2278,7 @@
> }
> checkIntra(mode, cuGeom, size);
> }
> - else
> + else if (m_param->interRefine < 2)
> {
> mode.cu.copyFromPic(parentCTU, cuGeom, m_csp, false);
> uint32_t numPU = parentCTU.getNumPartInter(
> cuGeom.absPartIdx);
> @@ -2328,16 +2346,19 @@
> checkDQP(mode, cuGeom);
> }
>
> - if (m_bTryLossless)
> - tryLossless(cuGeom);
> -
> - if (mightSplit)
> - addSplitFlagCost(*md.bestMode, cuGeom.depth);
> -
> - if (mightSplit && m_param->rdLevel < 5)
> - checkDQPForSplitPred(*md.bestMode, cuGeom);
> -
> - if (m_param->interRefine && parentCTU.m_predMode[cuGeom.absPartIdx]
> == MODE_SKIP && !mode.cu.isSkipped(0))
> + if (m_param->interRefine < 2 || parentCTU.isIntra(cuGeom.
> absPartIdx))
> + {
> + if (m_bTryLossless)
> + tryLossless(cuGeom);
> +
> + if (mightSplit)
> + addSplitFlagCost(*md.bestMode, cuGeom.depth);
> +
> + if (mightSplit && m_param->rdLevel < 5)
> + checkDQPForSplitPred(*md.bestMode, cuGeom);
> + }
> +
> + if (!parentCTU.isIntra(cuGeom.absPartIdx) && (
> m_param->interRefine > 1 || (m_param->interRefine &&
> parentCTU.m_predMode[cuGeom.absPartIdx] == MODE_SKIP &&
> !mode.cu.isSkipped(0))))
> {
> m_evaluateInter = 1;
> m_param->rdLevel > 4 ? compressInterCU_rd5_6(parentCTU,
> cuGeom, qp) : compressInterCU_rd0_4(parentCTU, cuGeom, qp);
> diff -r d11482e5fedb -r 81f17d9c7c27 source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp Mon Jul 24 11:15:38 2017 +0530
> +++ b/source/encoder/encoder.cpp Mon Jul 24 12:58:03 2017 +0530
> @@ -2349,6 +2349,11 @@
> x265_log(p, X265_LOG_WARNING, "MV refinement requires
> analysis load, analysis-reuse-level 10, scale factor. Disabling MV
> refine.\n");
> p->mvRefine = 0;
> }
> + else if (p->interRefine >= 2)
> + {
> + x265_log(p, X265_LOG_WARNING, "MVs are recomputed when
> refine-inter >= 2. MV refinement not applicable. Disabling MV refine\n");
> + p->mvRefine = 0;
> + }
> }
>
> if ((p->analysisMultiPassRefine || p->analysisMultiPassDistortion)
> && (p->bDistributeModeAnalysis || p->bDistributeMotionEstimation))
> diff -r d11482e5fedb -r 81f17d9c7c27 source/x265cli.h
> --- a/source/x265cli.h Mon Jul 24 11:15:38 2017 +0530
> +++ b/source/x265cli.h Mon Jul 24 12:58:03 2017 +0530
> @@ -255,8 +255,7 @@
> { "analysis-reuse-level", required_argument, NULL, 0 },
> { "scale-factor", required_argument, NULL, 0 },
> { "refine-intra", required_argument, NULL, 0 },
> - { "refine-inter", no_argument, NULL, 0 },
> - { "no-refine-inter",no_argument, NULL, 0 },
> + { "refine-inter", required_argument, NULL, 0 },
> { "strict-cbr", no_argument, NULL, 0 },
> { "temporal-layers", no_argument, NULL, 0 },
> { "no-temporal-layers", no_argument, NULL, 0 },
> @@ -454,8 +453,17 @@
> H0(" --analysis-reuse-file <filename> Specify file name used for
> either dumping or reading analysis data. Deault x265_analysis.dat\n");
> H0(" --analysis-reuse-level <1..10> Level of analysis reuse
> indicates amount of info stored/reused in save/load mode, 1:least..10:most.
> Default %d\n", param->analysisReuseLevel);
> H0(" --scale-factor <int> Specify factor by which input
> video is scaled down for analysis save mode. Default %d\n",
> param->scaleFactor);
> - H0(" --refine-intra <int> Enable intra refinement for load
> mode. Default %d\n", param->intraRefine);
> - H0(" --[no-]refine-inter Enable inter refinement for load
> mode. Default %s\n", OPT(param->interRefine));
> + H0(" --refine-intra <0..2> Enable intra refinement for
> encode that uses analysis-reuse-mode=load.\n"
> + " - 0 : Forces both mode and
> depth from the save encode.\n"
> + " - 1 : Evaluates all intra
> modes when current block size is one greater than the min-cu-size.\n"
> + " - 2 : In addition to level 1
> functionality, force only depth when angular mode is chosen by the save
> encode.\n"
> + " Default:%d\n",
> param->intraRefine);
> + H0(" --refine-inter <0..3> Enable inter refinement for
> encode that uses analysis-reuse-mode=load.\n"
> + " - 0 : Forces both mode and
> depth from the save encode.\n"
> + " - 1 : Evaluates all inter
> modes when current block is a skip and block size is one greater than the
> min-cu-size.\n"
> + " - 2 : In addition to level 1
> functionality, restricts the modes evaluated when specific modes are
> decided as the best mode by the save encode.\n"
> + " - 3 : Perform analysis of
> inter modes while reusing depths from the previous encode.\n"
> + " Default:%d\n",
> param->interRefine);
> H0(" --[no-]refine-mv Enable mv refinement for load
> mode. Default %s\n", OPT(param->mvRefine));
> H0(" --aq-mode <integer> Mode for Adaptive Quantization -
> 0:none 1:uniform AQ 2:auto variance 3:auto variance with bias to dark
> scenes. Default %d\n", param->rc.aqMode);
> H0(" --aq-strength <float> Reduces blocking and blurring in
> flat and textured areas (0 to 3.0). Default %.2f\n", param->rc.aqStrength);
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20170810/1ee95e39/attachment-0001.html>
More information about the x265-devel
mailing list