<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 30, 2018 at 5:27 PM, <span dir="ltr"><<a href="mailto:bhavna@multicorewareinc.com" target="_blank">bhavna@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 Bhavna Hariharan <<a href="mailto:bhavna@multicorewareinc.com">bhavna@multicorewareinc.com</a>><br>
# Date 1522408458 -19800<br>
# Fri Mar 30 16:44:18 2018 +0530<br>
# Node ID 77d9a3c77e624cf593093c0c2176d1<wbr>55a0ccce68<br>
# Parent ae72210ad6e846062572ef8a02970b<wbr>74052c2f1c<br>
dynamic-refine: remove refine-inter level 0 from dynamic refinement.<br>
<br>
refine-inter 0 is no longer supported when scale factor is enabled.<br>
Hence, dynamic-refine is also modified such that the algorithm switches between<br>
inter-refine levels 1 and 3.<br>
<br>
diff -r ae72210ad6e8 -r 77d9a3c77e62 source/encoder/analysis.cpp<br>
--- a/source/encoder/analysis.cpp Fri Mar 30 16:40:10 2018 +0530<br>
+++ b/source/encoder/analysis.cpp Fri Mar 30 16:44:18 2018 +0530<br>
@@ -2419,7 +2419,7 @@<br>
if (!m_param->bDynamicRefine)<br>
m_refineLevel = m_param->interRefine;<br>
else<br>
- m_refineLevel = m_frame->m_classifyFrame ? 0 : 3;<br>
+ m_refineLevel = m_frame->m_classifyFrame ? 1 : 3;<br>
<br>
int split = (m_refineLevel && cuGeom.log2CUSize == (uint32_t)(g_log2Size[m_param-<wbr>>minCUSize] + 1) && bDecidedDepth);<br>
td.split = split;<br>
@@ -2638,11 +2638,11 @@<br>
uint64_t diffRefine[X265_REFINE_INTER_<wbr>LEVELS];<br>
uint64_t diffRefineRd[X265_REFINE_<wbr>INTER_LEVELS];<br>
float probRefine[X265_REFINE_INTER_<wbr>LEVELS] = { 0 };<br>
- uint8_t varRefineLevel = 0;<br>
- uint8_t rdRefineLevel = 0;<br>
+ uint8_t varRefineLevel = 1;<br>
+ uint8_t rdRefineLevel = 1;<br>
uint64_t cuCost = bestMode.rdCost;<br>
<br>
- int offset = (depth * X265_REFINE_INTER_LEVELS) + 1;<br>
+ int offset = (depth * X265_REFINE_INTER_LEVELS);<br>
if (cuCost < m_frame->m_classifyRd[offset])<br>
m_refineLevel = 1;<br>
else<br>
@@ -2669,10 +2669,11 @@<br>
P(c) is the prior probability of class.<br>
P(x|c) is the likelihood which is the probability of predictor given class.<br>
P(x) is the prior probability of predictor.*/<br>
- if ((diffRefine[i] * probRefine[m_refineLevel]) < (diffRefine[m_refineLevel] * probRefine[i]))<br>
- varRefineLevel = i;<br>
- if ((diffRefineRd[i] * probRefine[m_refineLevel]) < (diffRefineRd[m_refineLevel] * probRefine[i]))<br>
- rdRefineLevel = i;<br>
+ int curRefineLevel = m_refineLevel - 1;<br>
+ if ((diffRefine[i] * probRefine[curRefineLevel]) < (diffRefine[curRefineLevel] * probRefine[i]))<br>
+ varRefineLevel = i + 1;<br>
+ if ((diffRefineRd[i] * probRefine[curRefineLevel]) < (diffRefineRd[curRefineLevel] * probRefine[i]))<br>
+ rdRefineLevel = i + 1;<br>
}<br>
m_refineLevel = X265_MAX(varRefineLevel, rdRefineLevel);<br>
}<br>
@@ -2682,13 +2683,19 @@<br>
void Analysis::trainCU(const CUData& ctu, const CUGeom& cuGeom, const Mode& bestMode, TrainingData& trainData)<br>
{<br>
uint32_t depth = cuGeom.depth;<br>
- int classify = 0;<br>
+ int classify = 1;<br>
if (!m_frame->m_classifyFrame)<br>
{<br>
- if (trainData.predMode == ctu.m_predMode[cuGeom.<wbr>absPartIdx] && trainData.partSize == ctu.m_partSize[cuGeom.<wbr>absPartIdx]<br>
- && trainData.mergeFlag == ctu.m_mergeFlag[cuGeom.<wbr>absPartIdx])<br>
- classify = 0;<br>
- else if ((depth == m_param->maxCUDepth - 1) && trainData.split)<br>
+ /* classify = 1 : CUs for which the save data matches with that after encoding with refine-inter 3<br>
+ and CUs that has split.<br>
+ classify = 2 : CUs which are encoded as simple modes (Skip/Merge/2Nx2N).<br>
+ classify = 3 : CUs encoded as any other mode. */<br>
+<br>
+ bool refineInter0 = (trainData.predMode == ctu.m_predMode[cuGeom.<wbr>absPartIdx] &&<br>
+ trainData.partSize == ctu.m_partSize[cuGeom.<wbr>absPartIdx] &&<br>
+ trainData.mergeFlag == ctu.m_mergeFlag[cuGeom.<wbr>absPartIdx]);<br>
+ bool refineInter1 = (depth == m_param->maxCUDepth - 1) && trainData.split;<br>
+ if (refineInter0 || refineInter1)<br>
classify = 1;<br>
else if (trainData.partSize == SIZE_2Nx2N && trainData.partSize == ctu.m_partSize[cuGeom.<wbr>absPartIdx])<br>
classify = 2;<br>
@@ -2698,7 +2705,7 @@<br>
else<br>
classify = m_refineLevel;<br>
uint64_t cuCost = bestMode.rdCost;<br>
- int offset = (depth * X265_REFINE_INTER_LEVELS) + classify;<br>
+ int offset = (depth * X265_REFINE_INTER_LEVELS) + classify - 1;<br>
ctu.m_collectCURd[offset] += cuCost;<br>
ctu.m_collectCUVariance[<wbr>offset] += trainData.cuVariance;<br>
ctu.m_collectCUCount[offset]++<wbr>;<br>
diff -r ae72210ad6e8 -r 77d9a3c77e62 source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Fri Mar 30 16:40:10 2018 +0530<br>
+++ b/source/encoder/encoder.cpp Fri Mar 30 16:44:18 2018 +0530<br>
@@ -2722,7 +2722,7 @@<br>
}<br>
}<br>
<br>
- if (p->scaleFactor && p->analysisLoad && !p->interRefine)<br>
+ if (p->scaleFactor && p->analysisLoad && !p->interRefine && !p->bDynamicRefine)<br>
{<br>
x265_log(p, X265_LOG_WARNING, "Inter refinement 0 is not supported with scaling. Enabling refine-inter 1.\n");<br>
p->interRefine = 1;<br>
diff -r ae72210ad6e8 -r 77d9a3c77e62 source/x265.h<br>
--- a/source/x265.h Fri Mar 30 16:40:10 2018 +0530<br>
+++ b/source/x265.h Fri Mar 30 16:44:18 2018 +0530<br>
@@ -466,7 +466,7 @@<br>
<br>
#define x265_ADAPT_RD_STRENGTH 4<br>
<br>
-#define X265_REFINE_INTER_LEVELS 4<br>
+#define X265_REFINE_INTER_LEVELS 3<br>
<br>
/* NOTE! For this release only X265_CSP_I420 and X265_CSP_I444 are supported */<br>
<br>
<br>______________________________<wbr>_________________<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/<wbr>listinfo/x265-devel</a><br>
<br></blockquote></div><br></div><div class="gmail_extra">Pushed.</div></div>