[x265] [PATCH] ratecontrol: prevent one layer of non-zero I-slice qp clipping [CHANGES OUTPUT]

Santhoshini Sekar santhoshini at multicorewareinc.com
Thu Apr 10 12:59:22 CEST 2014


On Thu, Apr 10, 2014 at 3:15 PM, Deepthi Nandakumar <
deepthi at multicorewareinc.com> wrote:

> Santhoshini,
>
> I-slice clipping has been removed only if it is not the first keyframe. I
> havent touched the newly introduced logic which clips all concurrent frames
> at the beginning.
>

On applying the patch and debugging we can see that the clipping has been
removed for the first I slice only but applied for the rest of the
concurrent frames following it .

>
> On Thu, Apr 10, 2014 at 1:54 PM, Santhoshini Sekar <
> santhoshini at multicorewareinc.com> wrote:
>
>>
>>
>>
>> On Thu, Apr 10, 2014 at 12:57 PM, <deepthi at multicorewareinc.com> wrote:
>>
>>> # HG changeset patch
>>> # User Deepthi Nandakumar <deepthi at multicorewareinc.com>
>>> # Date 1397114813 -19800
>>> # Node ID 1c0f1a4ce209badcca1272f87c3917ec69ee1cc7
>>> # Parent  83ccf2f1453ffd91c9fd8b84b72e3d3daacba6c6
>>> ratecontrol: prevent one layer of non-zero I-slice qp clipping [CHANGES
>>> OUTPUT].
>>>
>>> This seems to have been an error importing RC code from x264. It could
>>> be responsible
>>> for error reports on I-slices (after POC 0) having much higher QP/low
>>> visual quality.
>>> Needs review.
>>>
>>> diff -r 83ccf2f1453f -r 1c0f1a4ce209 source/encoder/ratecontrol.cpp
>>> --- a/source/encoder/ratecontrol.cpp    Thu Apr 10 11:17:46 2014 +0530
>>> +++ b/source/encoder/ratecontrol.cpp    Thu Apr 10 12:56:53 2014 +0530
>>> @@ -554,33 +554,34 @@
>>>              q = x265_qp2qScale(accumPQp / accumPNorm);
>>>              q /= fabs(param->rc.ipFactor);
>>>          }
>>> -
>>> -        if (param->rc.rateControlMode != X265_RC_CRF)
>>> +        else if(framesDone > 0)
>>>
>>
> The above else if part is the only real addition. The remaining stuff is
> as is. Diff makes it harder to review the exact change. Pls apply the patch
> and you can see the exact change.
>

This else if framesDone > 0 will prevent the first I frame's
qp(POC,framesdone = 0) from getting clipped but the concurrent frames' QPs
will pass the condition and get clipped .

>
>
>>          {
>>> -            double lqmin = 0, lqmax = 0;
>>> -            if (totalBits == 0 && !isVbv)
>>> +            if (param->rc.rateControlMode != X265_RC_CRF)
>>>              {
>>> -                lqmin = x265_qp2qScale(ABR_INIT_QP_MIN) / lstep;
>>> -                lqmax = x265_qp2qScale(ABR_INIT_QP_MAX) * lstep;
>>> -                q = Clip3(lqmin, lqmax, q);
>>> -            }
>>> -            else if (totalBits > 0 || (isVbv && framesDone > 0))
>>> -            {
>>>
>>

> -                lqmin = lastQScaleFor[sliceType] / lstep;
>>> -                lqmax = lastQScaleFor[sliceType] * lstep;
>>> -                if (overflow > 1.1 && framesDone > 3)
>>> -                    lqmax *= lstep;
>>> -                else if (overflow < 0.9)
>>> -                    lqmin /= lstep;
>>> -                q = Clip3(lqmin, lqmax, q);
>>> +                double lqmin = 0, lqmax = 0;
>>> +                if (totalBits == 0 && !isVbv)
>>> +                {
>>>
>> for the successive I frames the totalbits will be > 0   so they don't get
clipped here. totalbits will be accumulated only after N parallel or
concurrent frames

> +                    lqmin = x265_qp2qScale(ABR_INIT_QP_MIN) / lstep;
>>> +                    lqmax = x265_qp2qScale(ABR_INIT_QP_MAX) * lstep;
>>> +                    q = Clip3(lqmin, lqmax, q);
>>> +                }
>>>
>> 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.
>>
>>> +                else if (totalBits > 0 || (isVbv && framesDone > 0))
>>> +                {
>>> +                    lqmin = lastQScaleFor[sliceType] / lstep;
>>> +                    lqmax = lastQScaleFor[sliceType] * lstep;
>>> +                    if (overflow > 1.1 && framesDone > 3)
>>> +                        lqmax *= lstep;
>>> +                    else if (overflow < 0.9)
>>> +                        lqmin /= lstep;
>>> +                    q = Clip3(lqmin, lqmax, q);
>>> +                }
>>>              }
>>>          }
>>> -        else
>>> +        else if (qCompress != 1 && param->rc.rateControlMode ==
>>> X265_RC_CRF)
>>>          {
>>> -            if (qCompress != 1 && framesDone == 0)
>>> -                q = x265_qp2qScale(ABR_INIT_QP) /
>>> fabs(param->rc.ipFactor);
>>> +            q = x265_qp2qScale(ABR_INIT_QP) / fabs(param->rc.ipFactor);
>>>          }
>>> -
>>> +
>>>          q = Clip3(MIN_QPSCALE, MAX_MAX_QPSCALE, q);
>>>          qpNoVbv = x265_qScale2qp(q);
>>>
>>> _______________________________________________
>>> x265-devel mailing list
>>> x265-devel at videolan.org
>>> https://mailman.videolan.org/listinfo/x265-devel
>>>
>>
>>
>> _______________________________________________
>> x265-devel mailing list
>> x265-devel at videolan.org
>> https://mailman.videolan.org/listinfo/x265-devel
>>
>>
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20140410/12f46597/attachment.html>


More information about the x265-devel mailing list