<div dir="ltr"># HG changeset patch<br># User Niranjan <<a href="mailto:niranjan@multicorewareinc.com">niranjan@multicorewareinc.com</a>><br># Date 1593151129 -19800<br>#      Fri Jun 26 11:28:49 2020 +0530<br># Node ID c8bab0857b4ac70e37c70fcde419cc7a2a77badf<br># Parent  ac951f9fef8a019822cac11ab42870b2443a017c<br>Fix: QP modification bug in Scenecut Aware Frame Quantizer Selection<br><br>diff --git a/source/encoder/ratecontrol.cpp b/source/encoder/ratecontrol.cpp<br>--- a/source/encoder/ratecontrol.cpp<br>+++ b/source/encoder/ratecontrol.cpp<br>@@ -3152,12 +3152,13 @@<br> <br> double RateControl::scenecutAwareQp(Frame* curFrame, double q)<br> {<br>+    double qp = x265_qScale2qp(q);<br>     uint32_t maxWindowSize = uint32_t((m_param->scenecutWindow / 1000.0) * (m_param->fpsNum / m_param->fpsDenom) + 0.5);<br>     uint32_t windowSize = maxWindowSize / 3;<br>     int lastScenecut = m_top->m_rateControl->m_lastScenecut;<br>     int lastIFrame = m_top->m_rateControl->m_lastScenecutAwareIFrame;<br>-    double maxQpDelta = x265_qp2qScale(double(m_param->maxQpDelta));<br>-    double iSliceDelta = x265_qp2qScale(double(I_SLICE_DELTA));<br>+    double maxQpDelta = double(m_param->maxQpDelta);<br>+    double iSliceDelta = double(I_SLICE_DELTA);<br>     double sliceTypeDelta = SLICE_TYPE_DELTA * maxQpDelta;<br>     double window2Delta = WINDOW2_DELTA * maxQpDelta;<br>     double window3Delta = WINDOW3_DELTA * maxQpDelta;<br>@@ -3173,11 +3174,11 @@<br>         if (!(lastIFrame > lastScenecut && lastIFrame <= (lastScenecut + int(maxWindowSize))<br>             && curFrame->m_poc > lastIFrame))<br>         {<br>-            q += maxQpDelta - sliceTypeDelta;<br>+            qp += maxQpDelta - sliceTypeDelta;<br>             if (((curFrame->m_poc) > (lastScenecut + int(windowSize))) && ((curFrame->m_poc) <= (lastScenecut + 2 * int(windowSize))))<br>-                q -= window2Delta;<br>+                qp -= window2Delta;<br>             else if (curFrame->m_poc > lastScenecut + 2 * int(windowSize))<br>-                q -= window3Delta;<br>+                qp -= window3Delta;<br>         }<br>     }<br>     else if (isFrameInsideWindow && IS_X265_TYPE_B(curFrame->m_lowres.sliceType))<br>@@ -3185,16 +3186,16 @@<br>         if (!(lastIFrame > lastScenecut && lastIFrame <= (lastScenecut + int(maxWindowSize))<br>             && curFrame->m_poc > lastIFrame))<br>         {<br>-            q += maxQpDelta;<br>+            qp += maxQpDelta;<br>             if (curFrame->m_lowres.sliceType == X265_TYPE_B)<br>-                q += sliceTypeDelta;<br>+                qp += sliceTypeDelta;<br>             if (((curFrame->m_poc) > (lastScenecut + int(windowSize))) && ((curFrame->m_poc) <= (lastScenecut + 2 * int(windowSize))))<br>-                q -= window2Delta;<br>+                qp -= window2Delta;<br>             else if (curFrame->m_poc > lastScenecut + 2 * int(windowSize))<br>-                q -= window3Delta;<br>+                qp -= window3Delta;<br>         }<br>     }<br>     if (IS_X265_TYPE_I(curFrame->m_lowres.sliceType) && curFrame->m_lowres.bScenecut)<br>-        q = q - iSliceDelta;<br>-    return q;<br>+        qp = qp - iSliceDelta;<br>+    return  x265_qp2qScale(qp);<br> }<br><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><font color="#0c343d" face="verdana, sans-serif"><br></font></div><div dir="ltr"><font color="#0c343d" face="verdana, sans-serif">Thanks & Regards</font><div><font color="#0c343d" face="verdana, sans-serif"><b>Niranjan Kumar B</b></font></div><div><font size="1" color="#0c343d" face="verdana, sans-serif">Video Codec Engineer </font></div><div><font size="1" color="#0c343d" face="verdana, sans-serif">Media & AI Analytics</font></div><div><font face="trebuchet ms, sans-serif" color="#0c343d">+91 958 511 1449</font></div><div><a href="https://multicorewareinc.com/" style="color:rgb(17,85,204)" target="_blank"><img src="https://docs.google.com/uc?export=download&id=1kc3RJu9M8bnIf6Xa5rUw2d-eEVUsPBE5&revid=0B7tw9XJBmynaemR1VUpQUi9DVytRVW5SVkRwVTFjb1hBMUcwPQ"></a></div></div></div></div></div></div></div></div></div>