<div dir="ltr"><div># HG changeset patch</div><div># User Aarthi Thirumalai</div><div># Date 1419064540 -19800</div><div># Sat Dec 20 14:05:40 2014 +0530</div><div># Node ID 1e7de45ddd54a1af7feab49d807c3fde7d34e1f8</div><div># Parent d55fed4ebcd22823f8ffb878fa898b5d288cbb6a</div><div>rc: restrict low tolerance for bitrate fluctuations to strict-cbr option</div><div><br></div><div>diff -r d55fed4ebcd2 -r 1e7de45ddd54 source/encoder/ratecontrol.cpp</div><div>--- a/source/encoder/ratecontrol.cpp<span class="" style="white-space:pre"> </span>Tue Dec 23 16:32:30 2014 +0530</div><div>+++ b/source/encoder/ratecontrol.cpp<span class="" style="white-space:pre"> </span>Sat Dec 20 14:05:40 2014 +0530</div><div>@@ -1759,7 +1759,7 @@</div><div> for (int j = 0; bufferFillCur >= 0; j++)</div><div> {</div><div> int type = curFrame->m_lowres.plannedType[j];</div><div>- if (type == X265_TYPE_AUTO)</div><div>+ if (type == X265_TYPE_AUTO || totalDuration >= 1.0)</div><div> break;</div><div> totalDuration += m_frameDuration;</div><div> double wantedFrameSize = m_vbvMaxRate * m_frameDuration;</div><div>@@ -1773,17 +1773,21 @@</div><div> bufferFillCur -= curBits;</div><div> }</div><div> </div><div>- /* Try to get the buffer no more than 80% filled, but don't set an impossible goal. */</div><div>- double tol = isIFramePresent ? 1 / totalDuration : totalDuration < 0.5 ? 2 : 1;</div><div>- targetFill = X265_MIN(m_bufferFill + totalDuration * m_vbvMaxRate * 0.5 , m_bufferSize * (1 - 0.8 * totalDuration * tol));</div><div>+ /* Try to get the buffer at least 50% filled, but don't set an impossible goal. */</div><div>+ double finalDur = 1;</div><div>+ if (m_param->rc.bStrictCbr)</div><div>+ {</div><div>+ finalDur = x265_clip3(0.4, 1.0, totalDuration);</div><div>+ }</div><div>+ targetFill = X265_MIN(m_bufferFill + totalDuration * m_vbvMaxRate * 0.5 , m_bufferSize * (1 - 0.5 * finalDur));</div><div> if (bufferFillCur < targetFill)</div><div> {</div><div> q *= 1.01;</div><div> loopTerminate |= 1;</div><div> continue;</div><div> }</div><div>- /* Try to get the buffer atleast 50% filled, but don't set an impossible goal. */</div><div>- targetFill = x265_clip3(m_bufferSize - (m_bufferSize * totalDuration * 0.5), m_bufferSize, m_bufferFill - totalDuration * m_vbvMaxRate * 0.5);</div><div>+ /* Try to get the buffer not more than 80% filled, but don't set an impossible goal. */</div><div>+ targetFill = x265_clip3(m_bufferSize * (1 - 0.2 * finalDur), m_bufferSize, m_bufferFill - totalDuration * m_vbvMaxRate * 0.5);</div><div> if (m_isCbr && bufferFillCur > targetFill)</div><div> {</div><div> q /= 1.01;</div><div>@@ -1976,7 +1980,7 @@</div><div> if (row < sps.numCuInHeight - 1)</div><div> {</div><div> /* More threads means we have to be more cautious in letting ratecontrol use up extra bits. */</div><div>- double rcTol = (bufferLeftPlanned * 0.2) / m_param->frameNumThreads * m_param->rc.rateTolerance;</div><div>+ double rcTol = bufferLeftPlanned / m_param->frameNumThreads * m_param->rc.rateTolerance;</div><div> int32_t encodedBitsSoFar = 0;</div><div> double accFrameBits = predictRowsSizeSum(curFrame, rce, qpVbv, encodedBitsSoFar);</div><div> </div><div>@@ -1994,7 +1998,7 @@</div><div> </div><div> while (qpVbv < qpMax</div><div> && ((accFrameBits > rce->frameSizePlanned + rcTol) ||</div><div>- (rce->bufferFill - accFrameBits < bufferLeftPlanned * 0.2) ||</div><div>+ (rce->bufferFill - accFrameBits < bufferLeftPlanned * 0.5) ||</div><div> (accFrameBits > rce->frameSizePlanned && qpVbv < rce->qpNoVbv)))</div><div> {</div><div> qpVbv += stepSize;</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 11, 2015 at 3:57 PM, Aarthi Priya Thirumalai <span dir="ltr"><<a href="mailto:aarthi@multicorewareinc.com" target="_blank">aarthi@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">no, there were a few conflicts because my local tip wasn't updated. Sending again..</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 8, 2015 at 8:02 PM, Steve Borho <span dir="ltr"><<a href="mailto:steve@borho.org" target="_blank">steve@borho.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 01/07, <a href="mailto:aarthi@multicorewareinc.com" target="_blank">aarthi@multicorewareinc.com</a> wrote:<br>
> # HG changeset patch<br>
> # User Aarthi Thirumalai<br>
> # Date 1419064540 -19800<br>
> # Sat Dec 20 14:05:40 2014 +0530<br>
> # Node ID 5d658640bcf115f2add4da1619eeaec50177973f<br>
> # Parent 9b30c4b16dfc4c673b57ee4c567fa8956a41e2fc<br>
> rc: restrict low tolerance for bitrate fluctuations to strict-cbr option<br>
<br>
</span>this patch isn't applying; perhaps it depends on the RCstart/stop patch<br>
<div><div><br>
> diff -r 9b30c4b16dfc -r 5d658640bcf1 source/encoder/ratecontrol.cpp<br>
> --- a/source/encoder/ratecontrol.cpp Tue Dec 23 16:32:30 2014 +0530<br>
> +++ b/source/encoder/ratecontrol.cpp Sat Dec 20 14:05:40 2014 +0530<br>
> @@ -1759,7 +1759,7 @@<br>
> for (int j = 0; bufferFillCur >= 0; j++)<br>
> {<br>
> int type = curFrame->m_lowres.plannedType[j];<br>
> - if (type == X265_TYPE_AUTO)<br>
> + if (type == X265_TYPE_AUTO || totalDuration >= 1.0)<br>
> break;<br>
> totalDuration += m_frameDuration;<br>
> double wantedFrameSize = m_vbvMaxRate * m_frameDuration;<br>
> @@ -1773,17 +1773,21 @@<br>
> bufferFillCur -= curBits;<br>
> }<br>
><br>
> - /* Try to get the buffer no more than 80% filled, but don't set an impossible goal. */<br>
> - double tol = isIFramePresent ? 1 / totalDuration : totalDuration < 0.5 ? 2 : 1;<br>
> - targetFill = X265_MIN(m_bufferFill + totalDuration * m_vbvMaxRate * 0.5 , m_bufferSize * (1 - 0.8 * totalDuration * tol));<br>
> + /* Try to get the buffer at least 50% filled, but don't set an impossible goal. */<br>
> + double finalDur = 1;<br>
> + if (m_param->rc.bStrictCbr)<br>
> + {<br>
> + finalDur = Clip3(0.4, 1.0, totalDuration);<br>
> + }<br>
> + targetFill = X265_MIN(m_bufferFill + totalDuration * m_vbvMaxRate * 0.5 , m_bufferSize * (1 - 0.5 * finalDur));<br>
> if (bufferFillCur < targetFill)<br>
> {<br>
> q *= 1.01;<br>
> loopTerminate |= 1;<br>
> continue;<br>
> }<br>
> - /* Try to get the buffer atleast 50% filled, but don't set an impossible goal. */<br>
> - targetFill = Clip3(m_bufferSize - (m_bufferSize * totalDuration * 0.5), m_bufferSize, m_bufferFill - totalDuration * m_vbvMaxRate * 0.5);<br>
> + /* Try to get the buffer not more than 80% filled, but don't set an impossible goal. */<br>
> + targetFill = Clip3(m_bufferSize * (1 - 0.2 * finalDur) , m_bufferSize, m_bufferFill - totalDuration * m_vbvMaxRate * 0.5);<br>
> if (m_isCbr && bufferFillCur > targetFill)<br>
> {<br>
> q /= 1.01;<br>
> @@ -1976,7 +1980,7 @@<br>
> if (row < sps.numCuInHeight - 1)<br>
> {<br>
> /* More threads means we have to be more cautious in letting ratecontrol use up extra bits. */<br>
> - double rcTol = (bufferLeftPlanned * 0.2) / m_param->frameNumThreads * m_param->rc.rateTolerance;<br>
> + double rcTol = bufferLeftPlanned / m_param->frameNumThreads * m_param->rc.rateTolerance;<br>
> int32_t encodedBitsSoFar = 0;<br>
> double accFrameBits = predictRowsSizeSum(curFrame, rce, qpVbv, encodedBitsSoFar);<br>
><br>
> @@ -1994,7 +1998,7 @@<br>
><br>
> while (qpVbv < qpMax<br>
> && ((accFrameBits > rce->frameSizePlanned + rcTol) ||<br>
> - (rce->bufferFill - accFrameBits < bufferLeftPlanned * 0.2) ||<br>
> + (rce->bufferFill - accFrameBits < bufferLeftPlanned * 0.5) ||<br>
> (accFrameBits > rce->frameSizePlanned && qpVbv < rce->qpNoVbv)))<br>
> {<br>
> qpVbv += stepSize;<br>
</div></div>> _______________________________________________<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" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
<span><font color="#888888"><br>
--<br>
Steve Borho<br>
_______________________________________________<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" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>