<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 11, 2015 at 12:01 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 1425994215 -19800<br>
#      Tue Mar 10 19:00:15 2015 +0530<br>
# Node ID 9b7b93384e39e90cf2d4c0c0a53213abff362f70<br>
# Parent  8f148ac8dbe4b68e88ceff84f40e33b29e888dc9<br>
rc: recompute planned frame size when using vbv with --qpfile<br>
<br>
diff -r 8f148ac8dbe4 -r 9b7b93384e39 source/encoder/ratecontrol.cpp<br>
--- a/source/encoder/ratecontrol.cpp    Tue Mar 10 15:46:36 2015 +0530<br>
+++ b/source/encoder/ratecontrol.cpp    Tue Mar 10 19:00:15 2015 +0530<br>
@@ -1067,7 +1067,15 @@<br>
     {<br>
         m_qp = (int32_t)(curFrame->m_forceqp + 0.5) - 1;<br>
         m_qp = x265_clip3(QP_MIN, QP_MAX_MAX, m_qp);<br>
-        rce->qpaRc = curEncData.m_avgQpRc = curEncData.m_avgQpAq = m_qp;<br>
+        rce->qpaRc =curEncData.m_avgQpRc = curEncData.m_avgQpAq = m_qp;<br></blockquote><div><br>w/s<br>  <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+        if (m_isAbr)<br>
+        {<br>
+            rce->qpNoVbv = rce->qpaRc;<br>
+            m_lastQScaleFor[m_sliceType] = x265_qp2qScale(rce->qpaRc);<br>
+            if (rce->poc == 0)<br>
+                 m_lastQScaleFor[P_SLICE] = m_lastQScaleFor[m_sliceType] * fabs(m_param->rc.ipFactor);<br>
+            rce->frameSizePlanned = predictSize(&m_pred[m_sliceType], rce->qpaRc, (double)m_currentSatd);<br>
+        }<br>
     }<br>
     // Do not increment m_startEndOrder here. Make rateControlEnd of previous thread<br>
     // to wait until rateControlUpdateStats of this frame is called<br>
@@ -1360,13 +1368,14 @@<br>
             q += m_pbOffset;<br>
<br>
         double qScale = x265_qp2qScale(q);<br>
+        double lmin = 0, lmax = 0;<br>
         if (m_isCbr)<br>
         {<br>
             qScale = tuneAbrQScaleFromFeedback(qScale);<br>
             if (!m_isAbrReset)<br>
             {<br>
-                double lmin = m_lastQScaleFor[P_SLICE] / m_lstep;<br>
-                double lmax = m_lastQScaleFor[P_SLICE] * m_lstep;<br>
+                 lmin = m_lastQScaleFor[P_SLICE] / m_lstep;<br>
+                 lmax = m_lastQScaleFor[P_SLICE] * m_lstep;<br>
                 qScale = x265_clip3(lmin, lmax, qScale);<br>
             }<br>
             q = x265_qScale2qp(qScale);<br>
@@ -1375,6 +1384,8 @@<br>
         if (!m_2pass && m_isVbv)<br>
         {<br>
             qScale = clipQscale(curFrame, rce, qScale);<br>
+            if (m_pred[m_sliceType].count == 1)<br>
+                qScale = x265_clip3(lmin, lmax, qScale);<br>
             m_lastQScaleFor[m_sliceType] = qScale;<br>
             rce->frameSizePlanned = predictSize(&m_pred[m_sliceType], qScale, (double)m_currentSatd);<br>
         }<br>
@@ -1460,7 +1471,7 @@<br>
              * tolerances, the bit distribution approaches that of 2pass. */<br>
<br>
             double overflow = 1;<br>
-<br>
+            double lqmin = 0, lqmax = 0;<br>
             m_shortTermCplxSum *= 0.5;<br>
             m_shortTermCplxCount *= 0.5;<br>
             m_shortTermCplxSum += m_currentSatd / (CLIP_DURATION(m_frameDuration) / BASE_FRAME_DURATION);<br>
@@ -1494,7 +1505,6 @@<br>
             {<br>
                 if (m_param->rc.rateControlMode != X265_RC_CRF)<br>
                 {<br>
-                    double lqmin = 0, lqmax = 0;<br>
                     lqmin = m_lastQScaleFor[m_sliceType] / m_lstep;<br>
                     lqmax = m_lastQScaleFor[m_sliceType] * m_lstep;<br>
                     if (!m_partialResidualFrames)<br>
@@ -1520,6 +1530,8 @@<br>
             q = x265_clip3(MIN_QPSCALE, MAX_MAX_QPSCALE, q);<br>
             rce->qpNoVbv = x265_qScale2qp(q);<br>
             q = clipQscale(curFrame, rce, q);<br>
+            if (m_pred[m_sliceType].count == 1 && m_framesDone > 0)<br>
+                q = x265_clip3(lqmin, lqmax, q);<br>
         }<br></blockquote><div><br></div><div>Can we include some explanation for these lmin/lmax changes? <br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
         m_lastQScaleFor[m_sliceType] = q;<br>
         if ((m_curSlice->m_poc == 0 || m_lastQScaleFor[P_SLICE] < q) && !(m_2pass && !m_isVbv))<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>