<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 2, 2018 at 4:04 PM, Ashok Kumar Mishra <span dir="ltr"><<a href="mailto:ashok@multicorewareinc.com" target="_blank">ashok@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Fri, Mar 30, 2018 at 5:26 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" target="_blank">bhavna@multicorewareinc.com</a>><br>
# Date 1522408210 -19800<br>
# Fri Mar 30 16:40:10 2018 +0530<br>
# Node ID ae72210ad6e846062572ef8a02970b<wbr>74052c2f1c<br>
# Parent 3440a56acc7865dcdea725b8ce7755<wbr>450209a8ee<br>
dynamic-refine: restart training at the beginning of each GOP<br>
<br>
Earlier, the training restarted at scenecuts. Now, the algorithm restarts at<br>
the beginning of each GOP in addition to the scenecuts.<br>
<br>
diff -r 3440a56acc78 -r ae72210ad6e8 source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Thu Mar 29 14:35:50 2018 +0530<br>
+++ b/source/encoder/encoder.cpp Fri Mar 30 16:40:10 2018 +0530<br>
@@ -416,7 +416,8 @@<br>
<br>
if (m_param->bDynamicRefine)<br>
{<br>
- int size = m_param->totalFrames * m_param->maxCUDepth * X265_REFINE_INTER_LEVELS;<br>
+ /* Allocate memory for 1 GOP and reuse it for the subsequent GOPs */<br>
+ int size = (m_param->keyframeMax + m_param->lookaheadDepth) * m_param->maxCUDepth * X265_REFINE_INTER_LEVELS;<br>
CHECKED_MALLOC_ZERO(m_varianc<wbr>e, uint64_t, size);<br>
CHECKED_MALLOC_ZERO(m_rdCost, uint64_t, size);<br>
CHECKED_MALLOC_ZERO(m_trainin<wbr>gCount, uint32_t, size);<br>
diff -r 3440a56acc78 -r ae72210ad6e8 source/encoder/frameencoder.cp<wbr>p<br>
--- a/source/encoder/frameencoder.<wbr>cpp Thu Mar 29 14:35:50 2018 +0530<br>
+++ b/source/encoder/frameencoder.<wbr>cpp Fri Mar 30 16:40:10 2018 +0530<br>
@@ -1463,6 +1463,7 @@<br>
<br>
if (m_param->bDynamicRefine)<br>
{<br>
+ if (m_top->m_startPoint <= m_frame->m_encodeOrder) // Avoid collecting data that will not be used by future frames.<br>
{<br>
ScopedLock dynLock(m_top->m_dynamicRefine<wbr>Lock);<br>
for (uint32_t i = 0; i < X265_REFINE_INTER_LEVELS; i++)<br>
@@ -1470,7 +1471,8 @@<br>
for (uint32_t depth = 0; depth < m_param->maxCUDepth; depth++)<br>
{<br>
int offset = (depth * X265_REFINE_INTER_LEVELS) + i;<br>
- int index = (m_frame->m_encodeOrder * X265_REFINE_INTER_LEVELS * m_param->maxCUDepth) + offset;<br>
+ int curFrameIndex = m_frame->m_encodeOrder - m_top->m_startPoint;<br>
+ int index = (curFrameIndex * X265_REFINE_INTER_LEVELS * m_param->maxCUDepth) + offset;<br>
if (ctu->m_collectCUCount[offset]<wbr>)<br>
{<br>
m_top->m_variance[index] += ctu->m_collectCUVariance[offse<wbr>t];<br>
@@ -1869,8 +1871,14 @@<br>
<br>
void FrameEncoder::computeAvgTraini<wbr>ngData()<br>
{<br>
- if (m_frame->m_lowres.bScenecut)<br>
+ if (m_frame->m_lowres.bScenecut || m_frame->m_lowres.bKeyframe)<br>
+ {<br>
m_top->m_startPoint = m_frame->m_encodeOrder;<br>
+ int size = (m_param->keyframeMax + m_param->lookaheadDepth) * m_param->maxCUDepth * X265_REFINE_INTER_LEVELS;<br>
+ memset(m_top->m_variance, 0, size * sizeof(uint64_t));<br>
+ memset(m_top->m_rdCost, 0, size * sizeof(uint64_t));<br>
+ memset(m_top->m_trainingCount, 0, size * sizeof(uint32_t));<br></blockquote><div><br></div></div></div><div>Is it required to reset the buffer every time? I believe you might be over writing those buffers periodically. Correct me if i am wrong. </div></div></div></div></blockquote><div><br></div><div>We will be incrementally adding to the buffer so the reset is required when we want to restart the training. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
+ }<br>
<br>
if (m_frame->m_encodeOrder - m_top->m_startPoint < 2 * m_param->frameNumThreads)<br>
m_frame->m_classifyFrame = false;<br>
@@ -1884,8 +1892,8 @@<br>
<br>
if (m_frame->m_classifyFrame)<br>
{<br>
- uint32_t limit = m_frame->m_encodeOrder - m_param->frameNumThreads - 1;<br>
- for (uint32_t i = m_top->m_startPoint + 1; i < limit; i++)<br>
+ uint32_t limit = m_frame->m_encodeOrder - m_top->m_startPoint - m_param->frameNumThreads;<br>
+ for (uint32_t i = 1; i < limit; i++)<br>
{<br>
for (uint32_t j = 0; j < X265_REFINE_INTER_LEVELS; j++)<br>
{<br>
<br></span>______________________________<wbr>_________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/l<wbr>istinfo/x265-devel</a><br>
<br></blockquote></div><br></div></div>
<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>