<div dir="ltr">Pushed to master.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 1, 2020 at 10:00 PM Niranjan Bala <<a href="mailto:niranjan@multicorewareinc.com">niranjan@multicorewareinc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">From b782cbcc497dc002ce7aba1758a7fa82ed92f52a Mon Sep 17 00:00:00 2001<br>From: Niranjan <<a href="mailto:niranjan@multicorewareinc.com" target="_blank">niranjan@multicorewareinc.com</a>><br>Date: Wed, 1 Jul 2020 20:53:57 +0530<br>Subject: [PATCH] Fix: QP modification bug in Scenecut Aware Frame Quantizer<br> Selection<br><br>---<br> source/encoder/ratecontrol.cpp | 23 ++++++++++++-----------<br> 1 file changed, 12 insertions(+), 11 deletions(-)<br><br>diff --git a/source/encoder/ratecontrol.cpp b/source/encoder/ratecontrol.cpp<br>index 0a3a5bfe7..33e5a35a1 100644<br>--- a/source/encoder/ratecontrol.cpp<br>+++ b/source/encoder/ratecontrol.cpp<br>@@ -3152,12 +3152,13 @@ void RateControl::splitbUsed(char bused[], RateControlEntry *rce)<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 @@ double RateControl::scenecutAwareQp(Frame* curFrame, double q)<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 @@ double RateControl::scenecutAwareQp(Frame* curFrame, double q)<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>-- <br>2.18.0.windows.1<br><br><div><div dir="ltr"><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><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 1, 2020 at 9:58 PM Niranjan Bala <<a href="mailto:niranjan@multicorewareinc.com" target="_blank">niranjan@multicorewareinc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Please ignore the above patch and use the following one.<div><div><div dir="ltr"><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><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 1, 2020 at 1:10 PM Niranjan Bala <<a href="mailto:niranjan@multicorewareinc.com" target="_blank">niranjan@multicorewareinc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"># HG changeset patch<br># User Niranjan <<a href="mailto:niranjan@multicorewareinc.com" target="_blank">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"><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>
</blockquote></div>
</blockquote></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><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font face="georgia, serif">Regards,</font><div><b><font face="georgia, serif">Aruna Matheswaran,</font></b></div><div><font face="georgia, serif">Video Codec Engineer,</font></div><div><font face="georgia, serif">Media & AI analytics BU,</font></div><div><span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:153px;height:58px"><img src="https://lh5.googleusercontent.com/gjX5cPNIZgwUrhfqkTwQUZWztIKmmo0qs3kbwvkS5H-bDVE2ftte9pMTVnFLSjOcjYWLtfc6_OGpxW4vraLg2r5QAIf1Q3MpldFDgWtzK_gXi8ptw5B3joIbsGL6mxj-JRdjHzT5" width="96" height="36" style="margin-left: 0px; margin-top: 0px;"></span></span></span><font face="georgia, serif"><br></font></div><div><span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:153px;height:58px"><img src="https://lh5.googleusercontent.com/gjX5cPNIZgwUrhfqkTwQUZWztIKmmo0qs3kbwvkS5H-bDVE2ftte9pMTVnFLSjOcjYWLtfc6_OGpxW4vraLg2r5QAIf1Q3MpldFDgWtzK_gXi8ptw5B3joIbsGL6mxj-JRdjHzT5" style="margin-left: 0px; margin-top: 0px;"></span></span></span><font face="georgia, serif"><br></font></div><div><font face="georgia, serif"><br></font></div></div></div></div></div></div></div></div></div>