[x265] [PATCH] rc: improve loop in clipQscale

Aarthi Priya Thirumalai aarthi at multicorewareinc.com
Tue Nov 10 13:37:25 CET 2015


LGTM
On Nov 6, 2015 1:41 PM, "Ximing Cheng" <chengximing1989 at foxmail.com> wrote:

> # HG changeset patch
> # User Ximing Cheng <ximingcheng at tencent.com>
> # Date 1446797063 -28800
> #      Fri Nov 06 16:04:23 2015 +0800
> # Node ID f11b17b4656a85a15dc82fd04485fbf920848e4d
> # Parent  45ea73c63c12c66e5e5e777e80853c8b3cadf101
> rc: improve loop in clipQscale
>
> diff -r 45ea73c63c12 -r f11b17b4656a source/encoder/ratecontrol.cpp
> --- a/source/encoder/ratecontrol.cpp    Fri Nov 06 11:55:27 2015 +0530
> +++ b/source/encoder/ratecontrol.cpp    Fri Nov 06 16:04:23 2015 +0800
> @@ -1756,6 +1756,7 @@
>              * is in a reasonable state by the end of the lookahead. */
>              int loopTerminate = 0;
>              /* Avoid an infinite loop. */
> +            double pSliceFactor = m_sliceType == I_SLICE ?
> m_param->rc.ipFactor : (m_sliceType == B_SLICE ? 1 / m_param->rc.pbFactor :
> 1);
>              for (int iterations = 0; iterations < 1000 && loopTerminate
> != 3; iterations++)
>              {
>                  double frameQ[3];
> @@ -1764,7 +1765,7 @@
>                  double bufferFillCur = m_bufferFill - curBits;
>                  double targetFill;
>                  double totalDuration = m_frameDuration;
> -                frameQ[P_SLICE] = m_sliceType == I_SLICE ? q *
> m_param->rc.ipFactor : (m_sliceType == B_SLICE ? q / m_param->rc.pbFactor :
> q);
> +                frameQ[P_SLICE] = q * pSliceFactor;
>                  frameQ[B_SLICE] = frameQ[P_SLICE] * m_param->rc.pbFactor;
>                  frameQ[I_SLICE] = frameQ[P_SLICE] / m_param->rc.ipFactor;
>                  /* Loop over the planned future frames. */
> @@ -1798,12 +1799,15 @@
>                      continue;
>                  }
>                  /* Try to get the buffer not more than 80% filled, but
> don't set an impossible goal. */
> -                targetFill = x265_clip3(m_bufferSize * (1 - 0.2 *
> finalDur), m_bufferSize, m_bufferFill - totalDuration * m_vbvMaxRate * 0.5);
> -                if (m_isCbr && bufferFillCur > targetFill &&
> !m_isSceneTransition)
> +                if (m_isCbr && !m_isSceneTransition)
>                  {
> -                    q /= 1.01;
> -                    loopTerminate |= 2;
> -                    continue;
> +                    targetFill = x265_clip3(m_bufferSize * (1 - 0.2 *
> finalDur), m_bufferSize, m_bufferFill - totalDuration * m_vbvMaxRate * 0.5);
> +                    if (bufferFillCur > targetFill)
> +                    {
> +                        q /= 1.01;
> +                        loopTerminate |= 2;
> +                        continue;
> +                    }
>                  }
>                  break;
>              }
> @@ -1857,7 +1861,7 @@
>          if (m_rateFactorMaxIncrement)
>          {
>              double qpNoVbv = x265_qScale2qp(q0);
> -            double qmax = X265_MIN(MAX_MAX_QPSCALE,x265_qp2qScale(qpNoVbv
> + m_rateFactorMaxIncrement));
> +            double qmax = X265_MIN(MAX_MAX_QPSCALE,
> x265_qp2qScale(qpNoVbv + m_rateFactorMaxIncrement));
>              return x265_clip3(MIN_QPSCALE, qmax, q);
>          }
>      }
>
>
> _______________________________________________
> 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/20151110/03bce85d/attachment.html>


More information about the x265-devel mailing list