<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 14, 2017 at 2:11 PM, <span dir="ltr"><<a href="mailto:aruna@multicorewareinc.com" target="_blank">aruna@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 Aruna Matheswaran <<a href="mailto:aruna@multicorewareinc.com">aruna@multicorewareinc.com</a>><br>
# Date 1498626859 -19800<br>
# Wed Jun 28 10:44:19 2017 +0530<br>
# Node ID 52ef1f37afc21c8fdf908ed5c9f48d<wbr>e48efe15c3<br>
# Parent 18fa144d453ebd1f47905e2656c34e<wbr>45794a8966<br>
Allow rc and non-rc reconfigure to occur simultaneously<br></blockquote><div><br></div><div>Pushed to default</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
diff -r 18fa144d453e -r 52ef1f37afc2 source/encoder/api.cpp<br>
--- a/source/encoder/api.cpp Thu Jul 13 16:50:35 2017 +0530<br>
+++ b/source/encoder/api.cpp Wed Jun 28 10:44:19 2017 +0530<br>
@@ -188,7 +188,8 @@<br>
<br>
x265_param save;<br>
Encoder* encoder = static_cast<Encoder*>(enc);<br>
- if (encoder->m_reconfigure || encoder->m_reconfigureRc) /* Reconfigure in progress */<br>
+ bool isReconfigureRc = encoder->isReconfigureRc(<wbr>encoder->m_latestParam, param_in);<br>
+ if (encoder->m_reconfigure && !isReconfigureRc || encoder->m_reconfigureRc && isReconfigureRc) /* Reconfigure in progress */<br>
return 1;<br>
memcpy(&save, encoder->m_latestParam, sizeof(x265_param));<br>
int ret = encoder->reconfigureParam(<wbr>encoder->m_latestParam, param_in);<br>
@@ -205,16 +206,22 @@<br>
if (encoder->m_param-><wbr>bRepeatHeaders)<br>
{<br>
if (encoder->m_scalingList.<wbr>parseScalingList(encoder->m_<wbr>latestParam->scalingLists))<br>
+ {<br>
+ memcpy(encoder->m_latestParam, &save, sizeof(x265_param));<br>
return -1;<br>
+ }<br>
encoder->m_scalingList.<wbr>setupQuantMatrices(encoder->m_<wbr>param->internalCsp);<br>
}<br>
else<br>
{<br>
x265_log(encoder->m_param, X265_LOG_ERROR, "Repeat headers is turned OFF, cannot reconfigure scalinglists\n");<br>
+ memcpy(encoder->m_latestParam, &save, sizeof(x265_param));<br>
return -1;<br>
}<br>
}<br>
- if (encoder->m_reconfigureRc)<br>
+ if (!isReconfigureRc)<br>
+ encoder->m_reconfigure = true;<br>
+ else if (encoder->m_reconfigureRc)<br>
{<br>
VPS saveVPS;<br>
memcpy(&saveVPS.ptl, &encoder->m_vps.ptl, sizeof(saveVPS.ptl));<br>
@@ -225,11 +232,11 @@<br>
x265_log(encoder->m_param, X265_LOG_WARNING, "Profile/Level/Tier has changed from %d/%d/%s to %d/%d/%s.Cannot reconfigure rate-control.\n",<br>
saveVPS.ptl.profileIdc, saveVPS.ptl.levelIdc, saveVPS.ptl.tierFlag ? "High" : "Main", encoder->m_vps.ptl.profileIdc,<br>
encoder->m_vps.ptl.levelIdc, encoder->m_vps.ptl.tierFlag ? "High" : "Main");<br>
+ memcpy(encoder->m_latestParam, &save, sizeof(x265_param));<br>
+ memcpy(&encoder->m_vps.ptl, &saveVPS.ptl, sizeof(saveVPS.ptl));<br>
encoder->m_reconfigureRc = false;<br>
}<br>
}<br>
- else<br>
- encoder->m_reconfigure = true;<br>
encoder-><wbr>printReconfigureParams();<br>
}<br>
return ret;<br>
diff -r 18fa144d453e -r 52ef1f37afc2 source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Thu Jul 13 16:50:35 2017 +0530<br>
+++ b/source/encoder/encoder.cpp Wed Jun 28 10:44:19 2017 +0530<br>
@@ -1130,48 +1130,61 @@<br>
<br>
int Encoder::reconfigureParam(<wbr>x265_param* encParam, x265_param* param)<br>
{<br>
- encParam->maxNumReferences = param->maxNumReferences; // never uses more refs than specified in stream headers<br>
- encParam->bEnableFastIntra = param->bEnableFastIntra;<br>
- encParam->bEnableEarlySkip = param->bEnableEarlySkip;<br>
- encParam->bEnableRecursionSkip = param->bEnableRecursionSkip;<br>
- encParam->searchMethod = param->searchMethod;<br>
- /* Scratch buffer prevents me_range from being increased for esa/tesa */<br>
- if (param->searchRange < encParam->searchRange)<br>
- encParam->searchRange = param->searchRange;<br>
- /* We can't switch out of subme=0 during encoding. */<br>
- if (encParam->subpelRefine)<br>
- encParam->subpelRefine = param->subpelRefine;<br>
- encParam->rdoqLevel = param->rdoqLevel;<br>
- encParam->rdLevel = param->rdLevel;<br>
- encParam->bEnableRectInter = param->bEnableRectInter;<br>
- encParam->maxNumMergeCand = param->maxNumMergeCand;<br>
- encParam->bIntraInBFrames = param->bIntraInBFrames;<br>
- if (param->scalingLists && !encParam->scalingLists)<br>
- encParam->scalingLists = strdup(param->scalingLists);<br>
- /* VBV can't be turned ON if it wasn't ON to begin with and can't be turned OFF if it was ON to begin with*/<br>
- if (param->rc.vbvMaxBitrate > 0 && param->rc.vbvBufferSize > 0 &&<br>
- encParam->rc.vbvMaxBitrate > 0 && encParam->rc.vbvBufferSize > 0)<br>
+ if (isReconfigureRc(encParam, param))<br>
{<br>
- m_reconfigureRc |= encParam->rc.vbvMaxBitrate != param->rc.vbvMaxBitrate;<br>
- m_reconfigureRc |= encParam->rc.vbvBufferSize != param->rc.vbvBufferSize;<br>
- if (m_reconfigureRc && m_param->bEmitHRDSEI)<br>
- x265_log(m_param, X265_LOG_WARNING, "VBV parameters cannot be changed when HRD is in use.\n");<br>
- else<br>
+ /* VBV can't be turned ON if it wasn't ON to begin with and can't be turned OFF if it was ON to begin with*/<br>
+ if (param->rc.vbvMaxBitrate > 0 && param->rc.vbvBufferSize > 0 &&<br>
+ encParam->rc.vbvMaxBitrate > 0 && encParam->rc.vbvBufferSize > 0)<br>
{<br>
- encParam->rc.vbvMaxBitrate = param->rc.vbvMaxBitrate;<br>
- encParam->rc.vbvBufferSize = param->rc.vbvBufferSize;<br>
+ m_reconfigureRc |= encParam->rc.vbvMaxBitrate != param->rc.vbvMaxBitrate;<br>
+ m_reconfigureRc |= encParam->rc.vbvBufferSize != param->rc.vbvBufferSize;<br>
+ if (m_reconfigureRc && m_param->bEmitHRDSEI)<br>
+ x265_log(m_param, X265_LOG_WARNING, "VBV parameters cannot be changed when HRD is in use.\n");<br>
+ else<br>
+ {<br>
+ encParam->rc.vbvMaxBitrate = param->rc.vbvMaxBitrate;<br>
+ encParam->rc.vbvBufferSize = param->rc.vbvBufferSize;<br>
+ }<br>
}<br>
+ m_reconfigureRc |= encParam->rc.bitrate != param->rc.bitrate;<br>
+ encParam->rc.bitrate = param->rc.bitrate;<br>
+ m_reconfigureRc |= encParam->rc.rfConstant != param->rc.rfConstant;<br>
+ encParam->rc.rfConstant = param->rc.rfConstant;<br>
}<br>
- m_reconfigureRc |= encParam->rc.bitrate != param->rc.bitrate;<br>
- encParam->rc.bitrate = param->rc.bitrate;<br>
- m_reconfigureRc |= encParam->rc.rfConstant != param->rc.rfConstant;<br>
- encParam->rc.rfConstant = param->rc.rfConstant;<br>
-<br>
+ else<br>
+ {<br>
+ encParam->maxNumReferences = param->maxNumReferences; // never uses more refs than specified in stream headers<br>
+ encParam->bEnableFastIntra = param->bEnableFastIntra;<br>
+ encParam->bEnableEarlySkip = param->bEnableEarlySkip;<br>
+ encParam->bEnableRecursionSkip = param->bEnableRecursionSkip;<br>
+ encParam->searchMethod = param->searchMethod;<br>
+ /* Scratch buffer prevents me_range from being increased for esa/tesa */<br>
+ if (param->searchRange < encParam->searchRange)<br>
+ encParam->searchRange = param->searchRange;<br>
+ /* We can't switch out of subme=0 during encoding. */<br>
+ if (encParam->subpelRefine)<br>
+ encParam->subpelRefine = param->subpelRefine;<br>
+ encParam->rdoqLevel = param->rdoqLevel;<br>
+ encParam->rdLevel = param->rdLevel;<br>
+ encParam->bEnableRectInter = param->bEnableRectInter;<br>
+ encParam->maxNumMergeCand = param->maxNumMergeCand;<br>
+ encParam->bIntraInBFrames = param->bIntraInBFrames;<br>
+ if (param->scalingLists && !encParam->scalingLists)<br>
+ encParam->scalingLists = strdup(param->scalingLists);<br>
+ }<br>
/* To add: Loop Filter/deblocking controls, transform skip, signhide require PPS to be resent */<br>
/* To add: SAO, temporal MVP, AMP, TU depths require SPS to be resent, at every CVS boundary */<br>
return x265_check_params(encParam);<br>
}<br>
<br>
+bool Encoder::isReconfigureRc(x265_<wbr>param* latestParam, x265_param* param_in)<br>
+{<br>
+ return (latestParam->rc.vbvMaxBitrate != param_in->rc.vbvMaxBitrate<br>
+ || latestParam->rc.vbvBufferSize != param_in->rc.vbvBufferSize<br>
+ || latestParam->rc.bitrate != param_in->rc.bitrate<br>
+ || latestParam->rc.rfConstant != param_in->rc.rfConstant);<br>
+}<br>
+<br>
void Encoder::copyCtuInfo(x265_ctu_<wbr>info_t** frameCtuInfo, int poc)<br>
{<br>
uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;<br>
diff -r 18fa144d453e -r 52ef1f37afc2 source/encoder/encoder.h<br>
--- a/source/encoder/encoder.h Thu Jul 13 16:50:35 2017 +0530<br>
+++ b/source/encoder/encoder.h Wed Jun 28 10:44:19 2017 +0530<br>
@@ -201,6 +201,8 @@<br>
<br>
int reconfigureParam(x265_param* encParam, x265_param* param);<br>
<br>
+ bool isReconfigureRc(x265_param* latestParam, x265_param* param_in);<br>
+<br>
void copyCtuInfo(x265_ctu_info_t** frameCtuInfo, int poc);<br>
<br>
void getStreamHeaders(NALList& list, Entropy& sbacCoder, Bitstream& bs);<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>