<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 10, 2014 at 12:57 PM,  <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"># HG changeset patch<br>
# User Deepthi Nandakumar <<a href="mailto:deepthi@multicorewareinc.com">deepthi@multicorewareinc.com</a>><br>
# Date 1397114813 -19800<br>
# Node ID 1c0f1a4ce209badcca1272f87c3917ec69ee1cc7<br>
# Parent  83ccf2f1453ffd91c9fd8b84b72e3d3daacba6c6<br>
ratecontrol: prevent one layer of non-zero I-slice qp clipping [CHANGES OUTPUT].<br>
<br>
This seems to have been an error importing RC code from x264. It could be responsible<br>
for error reports on I-slices (after POC 0) having much higher QP/low visual quality.<br>
Needs review.<br>
<br>
diff -r 83ccf2f1453f -r 1c0f1a4ce209 source/encoder/ratecontrol.cpp<br>
--- a/source/encoder/ratecontrol.cpp    Thu Apr 10 11:17:46 2014 +0530<br>
+++ b/source/encoder/ratecontrol.cpp    Thu Apr 10 12:56:53 2014 +0530<br>
@@ -554,33 +554,34 @@<br>
             q = x265_qp2qScale(accumPQp / accumPNorm);<br>
             q /= fabs(param->rc.ipFactor);<br>
         }<br>
-<br>
-        if (param->rc.rateControlMode != X265_RC_CRF)<br>
+        else if(framesDone > 0)<br>
         {<br>
-            double lqmin = 0, lqmax = 0;<br>
-            if (totalBits == 0 && !isVbv)<br>
+            if (param->rc.rateControlMode != X265_RC_CRF)<br>
             {<br>
-                lqmin = x265_qp2qScale(ABR_INIT_QP_MIN) / lstep;<br>
-                lqmax = x265_qp2qScale(ABR_INIT_QP_MAX) * lstep;<br>
-                q = Clip3(lqmin, lqmax, q);<br>
-            }<br>
-            else if (totalBits > 0 || (isVbv && framesDone > 0))<br>
-            {<br>
-                lqmin = lastQScaleFor[sliceType] / lstep;<br>
-                lqmax = lastQScaleFor[sliceType] * lstep;<br>
-                if (overflow > 1.1 && framesDone > 3)<br>
-                    lqmax *= lstep;<br>
-                else if (overflow < 0.9)<br>
-                    lqmin /= lstep;<br>
-                q = Clip3(lqmin, lqmax, q);<br>
+                double lqmin = 0, lqmax = 0;<br>
+                if (totalBits == 0 && !isVbv)<br>
+                {<br>
+                    lqmin = x265_qp2qScale(ABR_INIT_QP_MIN) / lstep;<br>
+                    lqmax = x265_qp2qScale(ABR_INIT_QP_MAX) * lstep;<br>
+                    q = Clip3(lqmin, lqmax, q);<br>
+                }<br></blockquote><div>The above clipping logic is not present in x264. This was consciously introduced only in x265 to clip I slice's qp along with N concurrent frames' qp when frame parallelism is enabled. If I slice's clipping is removed then we need to remove the above piece of code as well.  Otherwise the frames following the I frame might have qp that gets clipped - lower than the I frame's qp.</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+                else if (totalBits > 0 || (isVbv && framesDone > 0))<br>
+                {<br>
+                    lqmin = lastQScaleFor[sliceType] / lstep;<br>
+                    lqmax = lastQScaleFor[sliceType] * lstep;<br>
+                    if (overflow > 1.1 && framesDone > 3)<br>
+                        lqmax *= lstep;<br>
+                    else if (overflow < 0.9)<br>
+                        lqmin /= lstep;<br>
+                    q = Clip3(lqmin, lqmax, q);<br>
+                }<br>
             }<br>
         }<br>
-        else<br>
+        else if (qCompress != 1 && param->rc.rateControlMode == X265_RC_CRF)<br>
         {<br>
-            if (qCompress != 1 && framesDone == 0)<br>
-                q = x265_qp2qScale(ABR_INIT_QP) / fabs(param->rc.ipFactor);<br>
+            q = x265_qp2qScale(ABR_INIT_QP) / fabs(param->rc.ipFactor);<br>
         }<br>
-<br>
+<br>
         q = Clip3(MIN_QPSCALE, MAX_MAX_QPSCALE, q);<br>
         qpNoVbv = x265_qScale2qp(q);<br>
<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>