<div dir="ltr"><div><div># HG changeset patch</div><div># User Aarthi Thirumalai <<a href="mailto:aarthi@multicorewareinc.com">aarthi@multicorewareinc.com</a>></div><div># Date 1448384595 -19800</div><div>#      Tue Nov 24 22:33:15 2015 +0530</div><div># Node ID 7b84524dc44236071ba33f5858a6c38a909162d2</div><div># Parent  e90c2d74de88459dd18837765a310a462d9679ec</div><div>rc: record RF details in csv for 2 pass CRF</div><div><br></div><div>diff -r e90c2d74de88 -r 7b84524dc442 source/encoder/ratecontrol.cpp</div><div>--- a/source/encoder/ratecontrol.cpp<span class="" style="white-space:pre">   </span>Mon Nov 23 12:26:45 2015 +0530</div><div>+++ b/source/encoder/ratecontrol.cpp<span class="" style="white-space:pre"> </span>Tue Nov 24 22:33:15 2015 +0530</div><div>@@ -2239,10 +2239,11 @@</div><div>     {</div><div>         if (m_param->rc.rateControlMode == X265_RC_ABR && !m_param->rc.bStatRead)</div><div>             checkAndResetABR(rce, true);</div><div>+    }</div><div> </div><div>-        if (m_param->rc.rateControlMode == X265_RC_CRF)</div><div>+     if (m_param->rc.rateControlMode == X265_RC_CRF)</div><div>         {</div><div>-            if (int(curEncData.m_avgQpRc + 0.5) == slice->m_sliceQp)</div><div>+            if (curEncData.m_avgQpRc - rce->qpNoVbv < 1)</div><div>                 curEncData.m_rateFactor = m_rateFactorConstant;</div><div>             else</div><div>             {</div><div>@@ -2253,7 +2254,6 @@</div><div>                     x265_qp2qScale(int(curEncData.m_avgQpRc + 0.5) + mbtree_offset);</div><div>             }</div><div>         }</div><div>-    }</div><div> </div><div>     if (m_isAbr && !m_isAbrReset)</div><div>     {</div></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 25, 2015 at 12:33 PM, Deepthi Nandakumar <span dir="ltr"><<a href="mailto:deepthi@multicorewareinc.com" target="_blank">deepthi@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">can you resend this patch, conflicts with your earlier one.<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Tue, Nov 24, 2015 at 11:47 PM,  <span dir="ltr"><<a href="mailto:aarthi@multicorewareinc.com" target="_blank">aarthi@multicorewareinc.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"># HG changeset patch<br>
# User Aarthi Thirumalai <<a href="mailto:aarthi@multicorewareinc.com" target="_blank">aarthi@multicorewareinc.com</a>><br>
<span># Date 1448384595 -19800<br>
#      Tue Nov 24 22:33:15 2015 +0530<br>
# Branch stable<br>
</span># Node ID d17f491e06152f4627152a36169c272651bd5e3d<br>
<span># Parent  0c49c9cc75e4c1ef9534a28b49b97b9107636f5d<br>
rc: record RF details in csv for 2 pass CRF<br>
<br>
</span>diff -r 0c49c9cc75e4 -r d17f491e0615 source/encoder/ratecontrol.cpp<br>
<span>--- a/source/encoder/ratecontrol.cpp    Mon Nov 23 14:06:10 2015 +0530<br>
+++ b/source/encoder/ratecontrol.cpp    Tue Nov 24 22:33:15 2015 +0530<br>
@@ -1141,6 +1141,7 @@<br>
     }<br>
     if (!m_isAbr && m_2pass && m_param->rc.rateControlMode == X265_RC_CRF)<br>
     {<br>
+        rce->oldQScale = rce->qScale;<br>
         rce->qScale = rce->newQScale;<br>
         rce->qpaRc = curEncData.m_avgQpRc = curEncData.m_avgQpAq = x265_qScale2qp(rce->newQScale);<br>
         m_qp = int(rce->qpaRc + 0.5);<br>
</span>@@ -1704,6 +1705,7 @@<br>
             bool isFrameAfterScenecut = m_sliceType!= I_SLICE && m_curSlice->m_refPicList[0][0]->m_lowres.bScenecut;<br>
             if (!m_2pass && m_isVbv && isFrameAfterScenecut)<br>
                 q = x265_clip3(lqmin, lqmax, q);<br>
+            rce->qScale = q;<br>
         }<br>
         m_lastQScaleFor[m_sliceType] = q;<br>
         if ((m_curSlice->m_poc == 0 || m_lastQScaleFor[P_SLICE] < q) && !(m_2pass && !m_isVbv))<br>
@@ -2337,10 +2339,12 @@<br>
<span>     {<br>
         if (m_param->rc.rateControlMode == X265_RC_ABR && !m_param->rc.bStatRead)<br>
             checkAndResetABR(rce, true);<br>
+    }<br>
<br>
-        if (m_param->rc.rateControlMode == X265_RC_CRF)<br>
+     if (m_param->rc.rateControlMode == X265_RC_CRF)<br>
         {<br>
-            if (int(curEncData.m_avgQpRc + 0.5) == slice->m_sliceQp)<br>
+            if ((int(curEncData.m_avgQpRc + 0.5) == slice->m_sliceQp && !m_2pass) ||<br>
+                (rce->oldQScale == rce->qScale))<br>
                 curEncData.m_rateFactor = m_rateFactorConstant;<br>
             else<br>
             {<br>
</span>@@ -2351,7 +2355,6 @@<br>
<span>                     x265_qp2qScale(int(curEncData.m_avgQpRc + 0.5) + mbtree_offset);<br>
             }<br>
         }<br>
-    }<br>
<br>
     if (m_isAbr && !m_isAbrReset)<br>
     {<br>
</span>diff -r 0c49c9cc75e4 -r d17f491e0615 source/encoder/ratecontrol.h<br>
</div></div><div><div><div><div class="h5">--- a/source/encoder/ratecontrol.h      Mon Nov 23 14:06:10 2015 +0530<br>
+++ b/source/encoder/ratecontrol.h      Tue Nov 24 22:33:15 2015 +0530<br>
@@ -101,6 +101,7 @@<br>
     double   qScale;<br>
     double   newQScale;<br>
     double   newQp;<br>
+    double   oldQScale;<br>
     int      mvBits;<br>
     int      miscBits;<br>
     int      coeffBits;<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" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><span class="HOEnZb"><font color="#888888"><br>
</font></span></div></div></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><br>-- <br><div><div dir="ltr"><div><div>Deepthi Nandakumar<br></div>Engineering Manager, x265<br></div>Multicoreware, Inc<br></div></div>
</font></span></div>
<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" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
<br></blockquote></div><br></div>