[x265] [PATCH 1 of 2] fixed bugs in ABR mode - implemeted log2() instead of log() as required

Steve Borho steve at borho.org
Thu Aug 22 21:41:30 CEST 2013


On Thu, Aug 22, 2013 at 2:30 PM, <aarthi at multicorewareinc.com> wrote:

> # HG changeset patch
> # User Aarthi<aarthi at multicorewareinc.com>
> # Date 1377199708 -19800
> #      Fri Aug 23 00:58:28 2013 +0530
> # Node ID 41f20253a3b8f7b8aae5d83cb563af919249c0fc
> # Parent  77418bf4a67b3679272f4b549a5c045d9a769230
> fixed bugs in ABR mode - implemeted log2() instead of log() as required.
>

I'll push these patches as-is, but we need to handle log2(n) in a cleaner
way.  Perhaps with a macro like:

static const double INV_LOG2 = ...;
#define X265_LOG2(n) log(n) * INV_LOG2;


>
> diff -r 77418bf4a67b -r 41f20253a3b8 source/encoder/ratecontrol.cpp
> --- a/source/encoder/ratecontrol.cpp    Thu Aug 22 12:22:20 2013 -0500
> +++ b/source/encoder/ratecontrol.cpp    Fri Aug 23 00:58:28 2013 +0530
> @@ -41,7 +41,7 @@
>  Approx qscale increases by 12%  with every qp increment */
>  static inline double qScale2qp(double qScale)
>  {
> -    return 12.0 + 6.0 * log(qScale / 0.85);
> +    return 12.0 + 6.0 * (double)(log(qScale / 0.85)/log (2));
>  }
>
>  static inline double qp2qScale(double qp)
> @@ -78,17 +78,17 @@
>          accumPNorm = .01;
>          accumPQp = (ABR_INIT_QP)*accumPNorm;
>          /* estimated ratio that produces a reasonable QP for the first
> I-frame  - needs to be tweaked for x265*/
> -        cplxrSum = .01 * pow(7.0e5, qCompress) * pow(ncu, 0.5);
> +        cplxrSum = .01 * pow(7.0e5, qCompress) * pow(ncu, 0.6);
>          wantedBitsWindow = 1.0 * bitrate / fps;
>          lastNonBPictType = I_SLICE;
>      }
> -    ipOffset = 6.0 * log(param->rc.ipFactor);
> -    pbOffset = 6.0 * log(param->rc.pbFactor);
> +    ipOffset = 6.0 * (float)(log(param->rc.ipFactor)/log(2));
> +    pbOffset = 6.0 * (float)(log(param->rc.pbFactor)/log(2));
>      for (int i = 0; i < 3; i++)
>      {
>          lastQScaleFor[i] = qp2qScale(ABR_INIT_QP);
>          lmin[i] = qp2qScale(MIN_QP);
> -        lmax[i] = qp2qScale(MAX_QP);  // maxQP val in x264 = 51+18
> +        lmax[i] = qp2qScale(MAX_QP+18);  // maxQP val in x264 = 51+18
>      }
>
>      //qstep - value set as encoder specific.
> @@ -117,7 +117,7 @@
>          break;
>      }
>
> -    q = Clip3(MIN_QP, MAX_QP, (int)q);
> +    q = Clip3((double)MIN_QP, (double)MAX_QP, q);
>      qp = Clip3(0, MAX_QP, (int)(q + 0.5f));
>      qpaRc = qpm = q;    // qpaRc is set in the rate_control_mb call in
> x264. we are updating here itself.
>      if (rce)
> @@ -258,7 +258,7 @@
>          lastQScaleFor[pictType] =
>              lastQScale = q;
>
> -        if (!curFrame->getPOC() == 0)
> +        if (curFrame->getPOC() == 0)
>              lastQScaleFor[P_SLICE] = q * fabs(ipFactor);
>
>          return q;
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>



-- 
Steve Borho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.videolan.org/private/x265-devel/attachments/20130822/8cf2348e/attachment.html>


More information about the x265-devel mailing list