[x265] [PATCH] Fix: QP modification bug in Scenecut Aware Frame Quantizer Selection
Niranjan Bala
niranjan at multicorewareinc.com
Wed Jul 1 18:30:08 CEST 2020
>From b782cbcc497dc002ce7aba1758a7fa82ed92f52a Mon Sep 17 00:00:00 2001
From: Niranjan <niranjan at multicorewareinc.com>
Date: Wed, 1 Jul 2020 20:53:57 +0530
Subject: [PATCH] Fix: QP modification bug in Scenecut Aware Frame Quantizer
Selection
---
source/encoder/ratecontrol.cpp | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/source/encoder/ratecontrol.cpp b/source/encoder/ratecontrol.cpp
index 0a3a5bfe7..33e5a35a1 100644
--- a/source/encoder/ratecontrol.cpp
+++ b/source/encoder/ratecontrol.cpp
@@ -3152,12 +3152,13 @@ void RateControl::splitbUsed(char bused[],
RateControlEntry *rce)
double RateControl::scenecutAwareQp(Frame* curFrame, double q)
{
+ double qp = x265_qScale2qp(q);
uint32_t maxWindowSize = uint32_t((m_param->scenecutWindow / 1000.0) *
(m_param->fpsNum / m_param->fpsDenom) + 0.5);
uint32_t windowSize = maxWindowSize / 3;
int lastScenecut = m_top->m_rateControl->m_lastScenecut;
int lastIFrame = m_top->m_rateControl->m_lastScenecutAwareIFrame;
- double maxQpDelta = x265_qp2qScale(double(m_param->maxQpDelta));
- double iSliceDelta = x265_qp2qScale(double(I_SLICE_DELTA));
+ double maxQpDelta = double(m_param->maxQpDelta);
+ double iSliceDelta = double(I_SLICE_DELTA);
double sliceTypeDelta = SLICE_TYPE_DELTA * maxQpDelta;
double window2Delta = WINDOW2_DELTA * maxQpDelta;
double window3Delta = WINDOW3_DELTA * maxQpDelta;
@@ -3173,11 +3174,11 @@ double RateControl::scenecutAwareQp(Frame*
curFrame, double q)
if (!(lastIFrame > lastScenecut && lastIFrame <= (lastScenecut +
int(maxWindowSize))
&& curFrame->m_poc > lastIFrame))
{
- q += maxQpDelta - sliceTypeDelta;
+ qp += maxQpDelta - sliceTypeDelta;
if (((curFrame->m_poc) > (lastScenecut + int(windowSize))) &&
((curFrame->m_poc) <= (lastScenecut + 2 * int(windowSize))))
- q -= window2Delta;
+ qp -= window2Delta;
else if (curFrame->m_poc > lastScenecut + 2 * int(windowSize))
- q -= window3Delta;
+ qp -= window3Delta;
}
}
else if (isFrameInsideWindow &&
IS_X265_TYPE_B(curFrame->m_lowres.sliceType))
@@ -3185,16 +3186,16 @@ double RateControl::scenecutAwareQp(Frame*
curFrame, double q)
if (!(lastIFrame > lastScenecut && lastIFrame <= (lastScenecut +
int(maxWindowSize))
&& curFrame->m_poc > lastIFrame))
{
- q += maxQpDelta;
+ qp += maxQpDelta;
if (curFrame->m_lowres.sliceType == X265_TYPE_B)
- q += sliceTypeDelta;
+ qp += sliceTypeDelta;
if (((curFrame->m_poc) > (lastScenecut + int(windowSize))) &&
((curFrame->m_poc) <= (lastScenecut + 2 * int(windowSize))))
- q -= window2Delta;
+ qp -= window2Delta;
else if (curFrame->m_poc > lastScenecut + 2 * int(windowSize))
- q -= window3Delta;
+ qp -= window3Delta;
}
}
if (IS_X265_TYPE_I(curFrame->m_lowres.sliceType) &&
curFrame->m_lowres.bScenecut)
- q = q - iSliceDelta;
- return q;
+ qp = qp - iSliceDelta;
+ return x265_qp2qScale(qp);
}
--
2.18.0.windows.1
Thanks & Regards
*Niranjan Kumar B*
Video Codec Engineer
Media & AI Analytics
+91 958 511 1449
<https://multicorewareinc.com/>
On Wed, Jul 1, 2020 at 9:58 PM Niranjan Bala <niranjan at multicorewareinc.com>
wrote:
> Please ignore the above patch and use the following one.
>
> Thanks & Regards
> *Niranjan Kumar B*
> Video Codec Engineer
> Media & AI Analytics
> +91 958 511 1449
> <https://multicorewareinc.com/>
>
>
> On Wed, Jul 1, 2020 at 1:10 PM Niranjan Bala <
> niranjan at multicorewareinc.com> wrote:
>
>> # HG changeset patch
>> # User Niranjan <niranjan at multicorewareinc.com>
>> # Date 1593151129 -19800
>> # Fri Jun 26 11:28:49 2020 +0530
>> # Node ID c8bab0857b4ac70e37c70fcde419cc7a2a77badf
>> # Parent ac951f9fef8a019822cac11ab42870b2443a017c
>> Fix: QP modification bug in Scenecut Aware Frame Quantizer Selection
>>
>> diff --git a/source/encoder/ratecontrol.cpp
>> b/source/encoder/ratecontrol.cpp
>> --- a/source/encoder/ratecontrol.cpp
>> +++ b/source/encoder/ratecontrol.cpp
>> @@ -3152,12 +3152,13 @@
>>
>> double RateControl::scenecutAwareQp(Frame* curFrame, double q)
>> {
>> + double qp = x265_qScale2qp(q);
>> uint32_t maxWindowSize = uint32_t((m_param->scenecutWindow / 1000.0)
>> * (m_param->fpsNum / m_param->fpsDenom) + 0.5);
>> uint32_t windowSize = maxWindowSize / 3;
>> int lastScenecut = m_top->m_rateControl->m_lastScenecut;
>> int lastIFrame = m_top->m_rateControl->m_lastScenecutAwareIFrame;
>> - double maxQpDelta = x265_qp2qScale(double(m_param->maxQpDelta));
>> - double iSliceDelta = x265_qp2qScale(double(I_SLICE_DELTA));
>> + double maxQpDelta = double(m_param->maxQpDelta);
>> + double iSliceDelta = double(I_SLICE_DELTA);
>> double sliceTypeDelta = SLICE_TYPE_DELTA * maxQpDelta;
>> double window2Delta = WINDOW2_DELTA * maxQpDelta;
>> double window3Delta = WINDOW3_DELTA * maxQpDelta;
>> @@ -3173,11 +3174,11 @@
>> if (!(lastIFrame > lastScenecut && lastIFrame <= (lastScenecut +
>> int(maxWindowSize))
>> && curFrame->m_poc > lastIFrame))
>> {
>> - q += maxQpDelta - sliceTypeDelta;
>> + qp += maxQpDelta - sliceTypeDelta;
>> if (((curFrame->m_poc) > (lastScenecut + int(windowSize)))
>> && ((curFrame->m_poc) <= (lastScenecut + 2 * int(windowSize))))
>> - q -= window2Delta;
>> + qp -= window2Delta;
>> else if (curFrame->m_poc > lastScenecut + 2 *
>> int(windowSize))
>> - q -= window3Delta;
>> + qp -= window3Delta;
>> }
>> }
>> else if (isFrameInsideWindow &&
>> IS_X265_TYPE_B(curFrame->m_lowres.sliceType))
>> @@ -3185,16 +3186,16 @@
>> if (!(lastIFrame > lastScenecut && lastIFrame <= (lastScenecut +
>> int(maxWindowSize))
>> && curFrame->m_poc > lastIFrame))
>> {
>> - q += maxQpDelta;
>> + qp += maxQpDelta;
>> if (curFrame->m_lowres.sliceType == X265_TYPE_B)
>> - q += sliceTypeDelta;
>> + qp += sliceTypeDelta;
>> if (((curFrame->m_poc) > (lastScenecut + int(windowSize)))
>> && ((curFrame->m_poc) <= (lastScenecut + 2 * int(windowSize))))
>> - q -= window2Delta;
>> + qp -= window2Delta;
>> else if (curFrame->m_poc > lastScenecut + 2 *
>> int(windowSize))
>> - q -= window3Delta;
>> + qp -= window3Delta;
>> }
>> }
>> if (IS_X265_TYPE_I(curFrame->m_lowres.sliceType) &&
>> curFrame->m_lowres.bScenecut)
>> - q = q - iSliceDelta;
>> - return q;
>> + qp = qp - iSliceDelta;
>> + return x265_qp2qScale(qp);
>> }
>>
>> Thanks & Regards
>> *Niranjan Kumar B*
>> Video Codec Engineer
>> Media & AI Analytics
>> +91 958 511 1449
>> <https://multicorewareinc.com/>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20200701/5bc1aaeb/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch1.diff
Type: application/octet-stream
Size: 3279 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20200701/5bc1aaeb/attachment-0001.obj>
More information about the x265-devel
mailing list