[x265] [PATCH x265] dynamic-refine: remove refine-inter level 0 from dynamic refinement
bhavna at multicorewareinc.com
bhavna at multicorewareinc.com
Fri Mar 30 13:57:25 CEST 2018
# HG changeset patch
# User Bhavna Hariharan <bhavna at multicorewareinc.com>
# Date 1522408458 -19800
# Fri Mar 30 16:44:18 2018 +0530
# Node ID 77d9a3c77e624cf593093c0c2176d155a0ccce68
# Parent ae72210ad6e846062572ef8a02970b74052c2f1c
dynamic-refine: remove refine-inter level 0 from dynamic refinement.
refine-inter 0 is no longer supported when scale factor is enabled.
Hence, dynamic-refine is also modified such that the algorithm switches between
inter-refine levels 1 and 3.
diff -r ae72210ad6e8 -r 77d9a3c77e62 source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp Fri Mar 30 16:40:10 2018 +0530
+++ b/source/encoder/analysis.cpp Fri Mar 30 16:44:18 2018 +0530
@@ -2419,7 +2419,7 @@
if (!m_param->bDynamicRefine)
m_refineLevel = m_param->interRefine;
else
- m_refineLevel = m_frame->m_classifyFrame ? 0 : 3;
+ m_refineLevel = m_frame->m_classifyFrame ? 1 : 3;
int split = (m_refineLevel && cuGeom.log2CUSize == (uint32_t)(g_log2Size[m_param->minCUSize] + 1) && bDecidedDepth);
td.split = split;
@@ -2638,11 +2638,11 @@
uint64_t diffRefine[X265_REFINE_INTER_LEVELS];
uint64_t diffRefineRd[X265_REFINE_INTER_LEVELS];
float probRefine[X265_REFINE_INTER_LEVELS] = { 0 };
- uint8_t varRefineLevel = 0;
- uint8_t rdRefineLevel = 0;
+ uint8_t varRefineLevel = 1;
+ uint8_t rdRefineLevel = 1;
uint64_t cuCost = bestMode.rdCost;
- int offset = (depth * X265_REFINE_INTER_LEVELS) + 1;
+ int offset = (depth * X265_REFINE_INTER_LEVELS);
if (cuCost < m_frame->m_classifyRd[offset])
m_refineLevel = 1;
else
@@ -2669,10 +2669,11 @@
P(c) is the prior probability of class.
P(x|c) is the likelihood which is the probability of predictor given class.
P(x) is the prior probability of predictor.*/
- if ((diffRefine[i] * probRefine[m_refineLevel]) < (diffRefine[m_refineLevel] * probRefine[i]))
- varRefineLevel = i;
- if ((diffRefineRd[i] * probRefine[m_refineLevel]) < (diffRefineRd[m_refineLevel] * probRefine[i]))
- rdRefineLevel = i;
+ int curRefineLevel = m_refineLevel - 1;
+ if ((diffRefine[i] * probRefine[curRefineLevel]) < (diffRefine[curRefineLevel] * probRefine[i]))
+ varRefineLevel = i + 1;
+ if ((diffRefineRd[i] * probRefine[curRefineLevel]) < (diffRefineRd[curRefineLevel] * probRefine[i]))
+ rdRefineLevel = i + 1;
}
m_refineLevel = X265_MAX(varRefineLevel, rdRefineLevel);
}
@@ -2682,13 +2683,19 @@
void Analysis::trainCU(const CUData& ctu, const CUGeom& cuGeom, const Mode& bestMode, TrainingData& trainData)
{
uint32_t depth = cuGeom.depth;
- int classify = 0;
+ int classify = 1;
if (!m_frame->m_classifyFrame)
{
- if (trainData.predMode == ctu.m_predMode[cuGeom.absPartIdx] && trainData.partSize == ctu.m_partSize[cuGeom.absPartIdx]
- && trainData.mergeFlag == ctu.m_mergeFlag[cuGeom.absPartIdx])
- classify = 0;
- else if ((depth == m_param->maxCUDepth - 1) && trainData.split)
+ /* classify = 1 : CUs for which the save data matches with that after encoding with refine-inter 3
+ and CUs that has split.
+ classify = 2 : CUs which are encoded as simple modes (Skip/Merge/2Nx2N).
+ classify = 3 : CUs encoded as any other mode. */
+
+ bool refineInter0 = (trainData.predMode == ctu.m_predMode[cuGeom.absPartIdx] &&
+ trainData.partSize == ctu.m_partSize[cuGeom.absPartIdx] &&
+ trainData.mergeFlag == ctu.m_mergeFlag[cuGeom.absPartIdx]);
+ bool refineInter1 = (depth == m_param->maxCUDepth - 1) && trainData.split;
+ if (refineInter0 || refineInter1)
classify = 1;
else if (trainData.partSize == SIZE_2Nx2N && trainData.partSize == ctu.m_partSize[cuGeom.absPartIdx])
classify = 2;
@@ -2698,7 +2705,7 @@
else
classify = m_refineLevel;
uint64_t cuCost = bestMode.rdCost;
- int offset = (depth * X265_REFINE_INTER_LEVELS) + classify;
+ int offset = (depth * X265_REFINE_INTER_LEVELS) + classify - 1;
ctu.m_collectCURd[offset] += cuCost;
ctu.m_collectCUVariance[offset] += trainData.cuVariance;
ctu.m_collectCUCount[offset]++;
diff -r ae72210ad6e8 -r 77d9a3c77e62 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Fri Mar 30 16:40:10 2018 +0530
+++ b/source/encoder/encoder.cpp Fri Mar 30 16:44:18 2018 +0530
@@ -2722,7 +2722,7 @@
}
}
- if (p->scaleFactor && p->analysisLoad && !p->interRefine)
+ if (p->scaleFactor && p->analysisLoad && !p->interRefine && !p->bDynamicRefine)
{
x265_log(p, X265_LOG_WARNING, "Inter refinement 0 is not supported with scaling. Enabling refine-inter 1.\n");
p->interRefine = 1;
diff -r ae72210ad6e8 -r 77d9a3c77e62 source/x265.h
--- a/source/x265.h Fri Mar 30 16:40:10 2018 +0530
+++ b/source/x265.h Fri Mar 30 16:44:18 2018 +0530
@@ -466,7 +466,7 @@
#define x265_ADAPT_RD_STRENGTH 4
-#define X265_REFINE_INTER_LEVELS 4
+#define X265_REFINE_INTER_LEVELS 3
/* NOTE! For this release only X265_CSP_I420 and X265_CSP_I444 are supported */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265-clone.patch
Type: text/x-patch
Size: 5382 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20180330/a91b1e4b/attachment.bin>
More information about the x265-devel
mailing list