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