[x265] [PATCH 2 of 4] rc: clamp qp for first I frame only in rateEstimateQscale (changes output)

Steve Borho steve at borho.org
Thu May 8 21:02:04 CEST 2014


On Thu, May 8, 2014 at 1:28 PM,  <aarthi at multicorewareinc.com> wrote:
> # HG changeset patch
> # User Aarthi Thirumalai
> # Date 1399573309 -19800
> #      Thu May 08 23:51:49 2014 +0530
> # Node ID 7ae5c6b44e111240f8b0727254db0c2ca91c0506
> # Parent  06c641032ed727f7160c3c6e412576b2f8935a19
> rc: clamp qp for first I frame only in rateEstimateQscale (changes output)
>
> diff -r 06c641032ed7 -r 7ae5c6b44e11 source/encoder/ratecontrol.cpp
> --- a/source/encoder/ratecontrol.cpp    Thu May 08 23:43:59 2014 +0530
> +++ b/source/encoder/ratecontrol.cpp    Thu May 08 23:51:49 2014 +0530
> @@ -443,6 +443,7 @@
>      if (pic->m_forceqp)
>      {
>          qp = int32_t(pic->m_forceqp + 0.5) - 1;
> +        qp = Clip3(MIN_QP, MAX_MAX_QP, qp);
>          rce->qpaRc = pic->m_avgQpRc = pic->m_avgQpAq = qp;
>      }
>      framesDone++;
> @@ -571,34 +572,35 @@
>              q = x265_qp2qScale(accumPQp / accumPNorm);
>              q /= fabs(param->rc.ipFactor);
>          }
> +
>          else if (framesDone > 0)
>          {
>              if (param->rc.rateControlMode != X265_RC_CRF)
>              {
>                  double lqmin = 0, lqmax = 0;
> -                if (totalBits == 0 && !isVbv)
> -                {
> -                    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);
> -                }
> +                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);
>              }
>          }
> +

we don't generally put blank lines before else() clauses, unless the
logic is so complicated we need to add a comment here.  queued without
the blank lines

>          else if (qCompress != 1 && param->rc.rateControlMode == X265_RC_CRF)
>          {
>              q = x265_qp2qScale(CRF_INIT_QP) / fabs(param->rc.ipFactor);
>          }
>
> +        else if (framesDone == 0 && !isVbv)
> +        {
> +            /* for ABR alone, clipe the first I frame qp within the range (ABR_INIT_QP_MIN, ABR_INIT_QP_MAX) to ensure quality. */
> +            double lqmin = x265_qp2qScale(ABR_INIT_QP_MIN) / lstep;
> +            double lqmax = x265_qp2qScale(ABR_INIT_QP_MAX) * lstep;
> +            q = Clip3(lqmin, lqmax, q);
> +        }
> +
>          q = Clip3(MIN_QPSCALE, MAX_MAX_QPSCALE, q);
>          rce->qpNoVbv = x265_qScale2qp(q);
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel



-- 
Steve Borho


More information about the x265-devel mailing list