[x265] [PATCH] rate control changes: add x265_lambda2_tab[] , modify rateTolarace , initial cplxrSum etc

Steve Borho steve at borho.org
Thu Aug 29 03:55:40 CEST 2013


On Wed, Aug 28, 2013 at 5:49 PM, <aarthi at multicorewareinc.com> wrote:

> # HG changeset patch
> # User Aarthi Thirumalai<aarthi at multicorewareinc.com>
> # Date 1377730168 -19800
> #      Thu Aug 29 04:19:28 2013 +0530
> # Node ID abf5562a09435c243e4e50ff00dda11ebe98de06
> # Parent  a60d5991e6aacec0e158688f7aa81452c02cba5a
> rate control changes: add x265_lambda2_tab[] , modify rateTolarace ,
> initial cplxrSum etc
>


Looks good, but I have a few requests


>
> diff -r a60d5991e6aa -r abf5562a0943 source/Lib/TLibCommon/TComRom.cpp
> --- a/source/Lib/TLibCommon/TComRom.cpp Wed Aug 28 13:41:33 2013 -0700
> +++ b/source/Lib/TLibCommon/TComRom.cpp Thu Aug 29 04:19:28 2013 +0530
> @@ -516,13 +516,13 @@
>
>  const int x265_HM_lambda2_tab[MAX_QP+1] =
>

let's drop HM from this variable name


>  {
> -   1,   1,   1,   2,   2,  3,   4,   6, /*  0- 7 */
> -   6,   7,   9,   15,   15,   19,   23,   37, /*  8-15 */
> -   37,   47,   59,   93,   94,   118,   149,   235, /* 16-23 */
> -   237,   323,   438,   740,   795,   1064,   1420,   2361, /* 24-31 */
> -  2505,  3314,  4375,  7203,  7576,  9545,  12026,  18939, /* 32-39 */
> -  19090,  24052,  30303,  47726,  48104,  60608,  76361,  120261, /*
> 40-47 */
> -  121215,  152721,  192417,  303038
> -};
> +1,     1,      1,      1,      1,      1,      1,      1,
> +1,     1,      1,      1,      1,      1,      2,      2,
> +3,     4,      5,      6,      8,      11,     14,     18,
> +23,    30,     38,     49,     63,     81,     104, 133,
> +171, 220, 282, 363, 467, 600, 771, 991,
> +1273, 1636, 2102, 2701, 3471,4460,5731, 7363,
> +9462, 12157, 15621, 20072 };
>

and let's keep an 8 bit fractional component (multiply these by 256 before
truncating), so..


>
>  //! \}
> diff -r a60d5991e6aa -r abf5562a0943 source/Lib/TLibEncoder/TEncTop.cpp
> --- a/source/Lib/TLibEncoder/TEncTop.cpp        Wed Aug 28 13:41:33 2013
> -0700
> +++ b/source/Lib/TLibEncoder/TEncTop.cpp        Thu Aug 29 04:19:28 2013
> +0530
> @@ -843,79 +843,8 @@
>  Void TEncTop::computeLambdaForQp(TComSlice* slice)
>  {
>      FrameEncoder *curEncoder = &m_frameEncoder[m_curEncoder];
> -    Int lambda;
>      Int qp = slice->getSliceQp();
> -
> -    // compute lambda value
> -    Int    NumberBFrames = (getGOPSize() - 1);
> -    Int    SHIFT_QP = 12;
> -    Double lambda_scale = 1.0 - Clip3(0.0, 0.5, 0.05 *
> (Double)NumberBFrames);
> -    Double qpFactor;
> -
> -#if FULL_NBIT
> -    Int    bitdepth_luma_qp_scale = 6 * (X265_DEPTH - 8);
> -    Double qp_temp_orig = (Double)dQP - SHIFT_QP;
> -#else
> -    Int    bitdepth_luma_qp_scale = 0;
> -#endif
> -    Double qp_temp = (Double)qp + bitdepth_luma_qp_scale - SHIFT_QP;
> -
> -    // Case #1: I or P-slices (key-frame)
> -    if (slice->getPOC() % 4 == 3)
> -    {
> -        qpFactor = 0.578;
> -    }
> -    else
> -    {
> -        qpFactor = 0.4624;
> -    }
> -    if (slice->getSliceType() == I_SLICE)
> -    {
> -        qpFactor = 0.57 * lambda_scale;
> -    }
> -    lambda = qpFactor * pow(2.0, qp_temp / 3.0);
> -
> -    // depth computation based on GOP size
> -    Int depth = 0;
> -    Int poc = slice->getPOC() % getGOPSize();
> -    if (poc)
> -    {
> -        Int step = getGOPSize();
> -        for (Int i = step >> 1; i >= 1; i >>= 1)
> -        {
> -            for (Int j = i; j < getGOPSize(); j += step)
> -            {
> -                if (j == poc)
> -                {
> -                    i = 0;
> -                    break;
> -                }
> -            }
> -
> -            step >>= 1;
> -            depth++;
> -        }
> -    }
> -
> -    if (depth > 0)
> -    {
> -#if FULL_NBIT
> -        lambda *= Clip3(2.00, 4.00, (qp_temp_orig / 6.0));
> -#else
> -        lambda *= Clip3(2.00, 4.00, (qp_temp / 6.0));
> -#endif
> -    }
> -
> -    //qp = max(-m_sps.getQpBDOffsetY(), min(MAX_QP, (Int)floor(qpdouble +
> 0.5)));
> -
> -    if (slice->getSliceType() != I_SLICE)
> -    {
> -        lambda *= getLambdaModifier(0); // temporal layer 0
> -    }
> -
> -    // for RDO
> -    // in RdCost there is only one lambda because the luma and chroma
> bits are not separated,
> -    // instead we weight the distortion of chroma.
> +       Int lambda = x265_HM_lambda2_tab[qp];
>

here you would use:  double lambda = x265_lambda2_tab[qp] / 256.0;

Then in follow on commits you can remove all the lambdas being passed as
function arguments and simply have all those functions look up the value
themselves.


>      Double weight = 1.0;
>      Int qpc;
>      Int chromaQPOffset;
> diff -r a60d5991e6aa -r abf5562a0943 source/common/common.cpp
> --- a/source/common/common.cpp  Wed Aug 28 13:41:33 2013 -0700
> +++ b/source/common/common.cpp  Thu Aug 29 04:19:28 2013 +0530
> @@ -140,7 +140,7 @@
>      param->bFrameAdaptive = X265_B_ADAPT_FAST;
>      param->lookaheadDepth = 10;
>      param->rc.bitrate = 1000;
> -    param->rc.rateTolerance = 1;
> +    param->rc.rateTolerance = .1;
>      param->rc.qCompress = 0.6;
>      param->rc.ipFactor = 1.4f;
>      param->rc.pbFactor = 1.3f;
> diff -r a60d5991e6aa -r abf5562a0943 source/encoder/ratecontrol.cpp
> --- a/source/encoder/ratecontrol.cpp    Wed Aug 28 13:41:33 2013 -0700
> +++ b/source/encoder/ratecontrol.cpp    Thu Aug 29 04:19:28 2013 +0530
> @@ -80,7 +80,7 @@
>          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.6);
> +        cplxrSum = .01 * pow(7.0e5, qCompress) * pow(4*ncu, 0.5);
>          wantedBitsWindow = bitrate * frameDuration;
>          lastNonBPictType = I_SLICE;
>      }
> _______________________________________________
> 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/20130828/830e6d97/attachment-0001.html>


More information about the x265-devel mailing list