<div dir="ltr"><div># HG changeset patch</div><div># User Deepthi Nandakumar <<a href="mailto:deepthi@multicorewareinc.com">deepthi@multicorewareinc.com</a>></div><div># Date 1457090985 -19800</div><div># Fri Mar 04 16:59:45 2016 +0530</div><div># Node ID 88aebc166fa8e16f91d5f0acce77690003be9d91</div><div># Parent 5cded27462444bee633d687151cf32299353b28b</div><div>encoder: handle m_latestParam and m_param correctly</div><div><br></div><div>During a reconfigure, m_latestParam and m_param will be different. Once all FEs</div><div>have been reconfigured, the Encoder considers its reconfigure complete.</div><div><br></div><div>diff -r 5cded2746244 -r 88aebc166fa8 source/encoder/api.cpp</div><div>--- a/source/encoder/api.cpp<span class="" style="white-space:pre"> </span>Fri Mar 04 16:33:57 2016 +0530</div><div>+++ b/source/encoder/api.cpp<span class="" style="white-space:pre"> </span>Fri Mar 04 16:59:45 2016 +0530</div><div>@@ -166,6 +166,8 @@</div><div> </div><div> x265_param save;</div><div> Encoder* encoder = static_cast<Encoder*>(enc);</div><div>+ if (encoder->m_reconfigure) /* Reconfigure in progress */</div><div>+ return -1;</div><div> memcpy(&save, encoder->m_latestParam, sizeof(x265_param));</div><div> int ret = encoder->reconfigureParam(encoder->m_latestParam, param_in);</div><div> if (ret)</div><div>@@ -173,7 +175,7 @@</div><div> memcpy(encoder->m_latestParam, &save, sizeof(x265_param));</div><div> else</div><div> {</div><div>- encoder->m_reconfigured = true;</div><div>+ encoder->m_reconfigure = true;</div><div> x265_print_reconfigured_params(&save, encoder->m_latestParam);</div><div> }</div><div> return ret;</div><div>diff -r 5cded2746244 -r 88aebc166fa8 source/encoder/encoder.cpp</div><div>--- a/source/encoder/encoder.cpp<span class="" style="white-space:pre"> </span>Fri Mar 04 16:33:57 2016 +0530</div><div>+++ b/source/encoder/encoder.cpp<span class="" style="white-space:pre"> </span>Fri Mar 04 16:59:45 2016 +0530</div><div>@@ -55,7 +55,7 @@</div><div> Encoder::Encoder()</div><div> {</div><div> m_aborted = false;</div><div>- m_reconfigured = false;</div><div>+ m_reconfigure = false;</div><div> m_encodedFrameNum = 0;</div><div> m_pocLast = -1;</div><div> m_curEncoder = 0;</div><div>@@ -528,7 +528,7 @@</div><div> if (m_dpb->m_freeList.empty())</div><div> {</div><div> inFrame = new Frame;</div><div>- x265_param* p = m_reconfigured? m_latestParam : m_param;</div><div>+ x265_param* p = m_reconfigure ? m_latestParam : m_param;</div><div> if (inFrame->create(p, pic_in->quantOffsets))</div><div> {</div><div> /* the first PicYuv created is asked to generate the CU and block unit offset</div><div>@@ -594,7 +594,7 @@</div><div> inFrame->m_userData = pic_in->userData;</div><div> inFrame->m_pts = pic_in->pts;</div><div> inFrame->m_forceqp = pic_in->forceqp;</div><div>- inFrame->m_param = m_reconfigured ? m_latestParam : m_param;</div><div>+ inFrame->m_param = m_reconfigure ? m_latestParam : m_param;</div><div> </div><div> if (pic_in->quantOffsets != NULL)</div><div> {</div><div>@@ -818,16 +818,36 @@</div><div> frameEnc = m_lookahead->getDecidedPicture();</div><div> if (frameEnc && !pass)</div><div> {</div><div>+ if (curEncoder->m_reconfigure)</div><div>+ {</div><div>+ /* One round robin cycle of FE reconfigure is complete */</div><div>+ if (m_reconfigure)</div><div>+ {</div><div>+ /* Safe to copy m_latestParam to Encoder::m_param, encoder reconfigure complete */</div><div>+ memcpy (m_param, m_latestParam, sizeof(x265_param));</div><div>+ m_reconfigure = false;</div><div>+ }</div><div>+ /* Reset current FEs to default */</div><div>+ curEncoder->m_param = m_param;</div><div>+ curEncoder->m_reconfigure = false;</div><div>+ }</div><div>+ else</div><div>+ {</div><div>+ /* Initiate reconfigure for this FE if necessary */</div><div>+ curEncoder->m_param = m_reconfigure ? m_latestParam : m_param;</div><div>+ curEncoder->m_reconfigure = m_reconfigure;</div><div>+ }</div><div> /* give this frame a FrameData instance before encoding */</div><div> if (m_dpb->m_frameDataFreeList)</div><div> {</div><div> frameEnc->m_encData = m_dpb->m_frameDataFreeList;</div><div> m_dpb->m_frameDataFreeList = m_dpb->m_frameDataFreeList->m_freeListNext;</div><div> frameEnc->reinit(m_sps);</div><div>+ frameEnc->m_param = m_reconfigure ? m_latestParam : m_param;</div><div> }</div><div> else</div><div> {</div><div>- frameEnc->allocEncodeData(m_param, m_sps);</div><div>+ frameEnc->allocEncodeData(m_reconfigure ? m_latestParam : m_param, m_sps);</div><div> Slice* slice = frameEnc->m_encData->m_slice;</div><div> slice->m_sps = &m_sps;</div><div> slice->m_pps = &m_pps;</div><div>diff -r 5cded2746244 -r 88aebc166fa8 source/encoder/encoder.h</div><div>--- a/source/encoder/encoder.h<span class="" style="white-space:pre"> </span>Fri Mar 04 16:33:57 2016 +0530</div><div>+++ b/source/encoder/encoder.h<span class="" style="white-space:pre"> </span>Fri Mar 04 16:59:45 2016 +0530</div><div>@@ -111,7 +111,7 @@</div><div> Frame* m_exportedPic;</div><div> FILE* m_analysisFile;</div><div> x265_param* m_param;</div><div>- x265_param* m_latestParam;</div><div>+ x265_param* m_latestParam; // Holds latest param during a reconfigure</div><div> RateControl* m_rateControl;</div><div> Lookahead* m_lookahead;</div><div> </div><div>@@ -130,7 +130,7 @@</div><div> bool m_emitCLLSEI;</div><div> bool m_bZeroLatency; // x265_encoder_encode() returns NALs for the input picture, zero lag</div><div> bool m_aborted; // fatal error detected</div><div>- bool m_reconfigured; // reconfigure of encoder detected</div><div>+ bool m_reconfigure; // Encoder reconfigure in progress</div><div> </div><div> /* Begin intra refresh when one not in progress or else begin one as soon as the current </div><div> * one is done. Requires bIntraRefresh to be set.*/</div><div>diff -r 5cded2746244 -r 88aebc166fa8 source/encoder/frameencoder.cpp</div><div>--- a/source/encoder/frameencoder.cpp<span class="" style="white-space:pre"> </span>Fri Mar 04 16:33:57 2016 +0530</div><div>+++ b/source/encoder/frameencoder.cpp<span class="" style="white-space:pre"> </span>Fri Mar 04 16:59:45 2016 +0530</div><div>@@ -41,6 +41,7 @@</div><div> FrameEncoder::FrameEncoder()</div><div> {</div><div> m_prevOutputTime = x265_mdate();</div><div>+ m_reconfigure = false;</div><div> m_isFrameEncoder = true;</div><div> m_threadActive = true;</div><div> m_slicetypeWaitTime = 0;</div><div>@@ -104,6 +105,7 @@</div><div> m_param = top->m_param;</div><div> m_numRows = numRows;</div><div> m_numCols = numCols;</div><div>+ m_reconfigure = false;</div><div> m_filterRowDelay = ((m_param->bEnableSAO && m_param->bSaoNonDeblocked)</div><div> || (!m_param->bEnableLoopFilter && m_param->bEnableSAO)) ?</div><div> 2 : (m_param->bEnableSAO || m_param->bEnableLoopFilter ? 1 : 0);</div><div>diff -r 5cded2746244 -r 88aebc166fa8 source/encoder/frameencoder.h</div><div>--- a/source/encoder/frameencoder.h<span class="" style="white-space:pre"> </span>Fri Mar 04 16:33:57 2016 +0530</div><div>+++ b/source/encoder/frameencoder.h<span class="" style="white-space:pre"> </span>Fri Mar 04 16:59:45 2016 +0530</div><div>@@ -129,7 +129,7 @@</div><div> Event m_done;</div><div> Event m_completionEvent;</div><div> int m_localTldIdx;</div><div>-</div><div>+ bool m_reconfigure; /* reconfigure in progress */</div><div> volatile bool m_threadActive;</div><div> volatile bool m_bAllRowsStop;</div><div> volatile int m_completionCount;</div><div><br></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div>Deepthi Nandakumar<br></div>Engineering Manager, x265<br></div>Multicoreware, Inc<br></div></div>
</div>