<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 30, 2014 at 2:51 PM,  <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"># HG changeset patch<br>
# User Aarthi Thirumalai<br>
# Date 1419064540 -19800<br>
#      Sat Dec 20 14:05:40 2014 +0530<br>
# Node ID fa8ab4bd8851613983e152e682c031fd4b0e83e8<br>
# Parent  98dfd6e0c72122e8613208d5927a4c81da6a8e7a<br>
rc: restrict low tolerance for bitrate fluctuations to strict-cbr option<br>
<br>
diff -r 98dfd6e0c721 -r fa8ab4bd8851 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,17 @@<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 tol = (isIFramePresent ? 1 / totalDuration : totalDuration < 0.5 ? 2 : 1 );<br>
+                targetFill = X265_MIN(m_bufferFill + totalDuration * m_vbvMaxRate * 0.5 , m_bufferSize * (1 - 0.5 * totalDuration * tol));<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 - totalDuration * tol * 0.2), m_bufferSize, m_bufferFill - totalDuration * m_vbvMaxRate * 0.5);<br>
                 if (m_isCbr && bufferFillCur > targetFill)<br>
                 {<br>
                     q /= 1.01;<br>
@@ -1976,7 +1976,8 @@<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 tol = m_param->rc.bStrictCbr ? 0.2 : 1;<br>
+        double rcTol = (bufferLeftPlanned * tol) / m_param->frameNumThreads * m_param->rc.rateTolerance;<br>
         int32_t encodedBitsSoFar = 0;<br>
         double accFrameBits = predictRowsSizeSum(curFrame, rce, qpVbv, encodedBitsSoFar);<br>
<br></blockquote><div>How does bStrictCbr interact with rateTolerance? Is it better to wrap these up into a single param->cbrRateTolerance which accepts a float tolerance value, so users can choose which point on the slope (quality vs bitrate flatness) they prefer?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
@@ -1994,7 +1995,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>
_______________________________________________<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" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br></div></div>