[x265] [PATCH 1 of 2] improve rdoQuant by split path on different probability

Steve Borho steve at borho.org
Wed Feb 4 20:58:04 CET 2015


On 02/04, Min Chen wrote:
> # HG changeset patch
> # User Min Chen <chenm003 at 163.com>
> # Date 1423042728 -28800
> # Node ID f6757591ed230847367957b95d07156e98a49714
> # Parent  e11dd720557a4680162c399b96c688e322be9934
> improve rdoQuant by split path on different probability

queued without the unused function

> ---
>  source/common/quant.cpp |   76 +++++++++++++++++++++++++++++++++++++++++++---
>  1 files changed, 71 insertions(+), 5 deletions(-)
> 
> diff -r e11dd720557a -r f6757591ed23 source/common/quant.cpp
> --- a/source/common/quant.cpp	Tue Feb 03 21:15:08 2015 -0600
> +++ b/source/common/quant.cpp	Wed Feb 04 17:38:48 2015 +0800
> @@ -50,7 +50,7 @@
>      return y + ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))); // min(x, y)
>  }
>  
> -inline int getICRate(uint32_t absLevel, int32_t diffLevel, const int* greaterOneBits, const int* levelAbsBits, uint32_t absGoRice, uint32_t c1c2Idx)
> +inline int getICRate(uint32_t absLevel, int32_t diffLevel, const int* greaterOneBits, const int* levelAbsBits, const uint32_t absGoRice, const uint32_t maxVlc, uint32_t c1c2Idx)
>  {
>      X265_CHECK(c1c2Idx <= 3, "c1c2Idx check failure\n");
>      X265_CHECK(absGoRice <= 4, "absGoRice check failure\n");
> @@ -72,7 +72,6 @@
>      else
>      {
>          uint32_t symbol = diffLevel;
> -        const uint32_t maxVlc = g_goRiceRange[absGoRice];
>          bool expGolomb = (symbol > maxVlc);
>  
>          if (expGolomb)
> @@ -105,6 +104,39 @@
>      return rate;
>  }
>  
> +inline int getICRateNegDiff(uint32_t absLevel, const int* greaterOneBits, const int* levelAbsBits)
> +{
> +    X265_CHECK(absLevel <= 2, "absLevel check failure\n");
> +
> +    int rate;
> +    if (absLevel == 0)
> +        rate = 0;
> +    else if (absLevel == 2)
> +        rate = greaterOneBits[1] + levelAbsBits[0];
> +    else
> +        rate = greaterOneBits[0];
> +    return rate;
> +}
> +
> +inline int getICRateLessVlc(uint32_t absLevel, int32_t diffLevel, const uint32_t absGoRice)
> +{
> +    X265_CHECK(absGoRice <= 4, "absGoRice check failure\n");
> +    if (!absLevel)
> +    {
> +        X265_CHECK(diffLevel < 0, "diffLevel check failure\n");
> +        return 0;
> +    }
> +    int rate;
> +
> +    uint32_t symbol = diffLevel;
> +    uint32_t prefLen = (symbol >> absGoRice) + 1;
> +    uint32_t numBins = fastMin(prefLen + absGoRice, 8 /* g_goRicePrefixLen[absGoRice] + absGoRice */);
> +
> +    rate = numBins << 15;
> +
> +    return rate;
> +}
> +
>  /* Calculates the cost for specific absolute transform level */
>  inline uint32_t getICRateCost(uint32_t absLevel, int32_t diffLevel, const int* greaterOneBits, const int* levelAbsBits, uint32_t absGoRice, uint32_t c1c2Idx)
>  {
> @@ -674,9 +706,43 @@
>                  /* record costs for sign-hiding performed at the end */
>                  if (level)
>                  {
> -                    int rateNow = getICRate(level, level - baseLevel, greaterOneBits, levelAbsBits, goRiceParam, c1c2Idx);
> -                    rateIncUp[blkPos] = getICRate(level + 1, level + 1 - baseLevel, greaterOneBits, levelAbsBits, goRiceParam, c1c2Idx) - rateNow;
> -                    rateIncDown[blkPos] = getICRate(level - 1, level - 1 - baseLevel, greaterOneBits, levelAbsBits, goRiceParam, c1c2Idx) - rateNow;
> +                    const int32_t diff0 = level - 1 - baseLevel;
> +                    const int32_t diff2 = level + 1 - baseLevel;
> +                    const int32_t maxVlc = g_goRiceRange[goRiceParam];
> +                    int rate0, rate1, rate2;
> +
> +                    if (diff0 < -2)  // prob (92.9, 86.5, 74.5)%
> +                    {
> +                        // NOTE: Min: L - 1 - {1,2,1,3} < -2 ==> L < {0,1,0,2}
> +                        //            additional L > 0, so I got (L > 0 && L < 2) ==> L = 1
> +                        X265_CHECK(level == 1, "absLevel check failure\n");
> +
> +                        const int rateEqual2 = greaterOneBits[1] + levelAbsBits[0];;
> +                        const int rateNotEqual2 = greaterOneBits[0];
> +
> +                        rate0 = 0;
> +                        rate2 = rateEqual2;
> +                        rate1 = rateNotEqual2;
> +
> +                        X265_CHECK(rate1 == getICRateNegDiff(level + 0, greaterOneBits, levelAbsBits), "rate1 check failure!\n");
> +                        X265_CHECK(rate2 == getICRateNegDiff(level + 1, greaterOneBits, levelAbsBits), "rate1 check failure!\n");
> +                        X265_CHECK(rate0 == getICRateNegDiff(level - 1, greaterOneBits, levelAbsBits), "rate1 check failure!\n");
> +                    }
> +                    else if (diff0 >= 0 && diff2 <= maxVlc)     // prob except from above path (98.6, 97.9, 96.9)%
> +                    {
> +                        // NOTE: no c1c2 correct rate since all of rate include this factor
> +                        rate1 = getICRateLessVlc(level + 0, diff0 + 1, goRiceParam);
> +                        rate2 = getICRateLessVlc(level + 1, diff0 + 2, goRiceParam);
> +                        rate0 = getICRateLessVlc(level - 1, diff0 + 0, goRiceParam);
> +                    }
> +                    else
> +                    {
> +                        rate1 = getICRate(level + 0, diff0 + 1, greaterOneBits, levelAbsBits, goRiceParam, maxVlc, c1c2Idx);
> +                        rate2 = getICRate(level + 1, diff0 + 2, greaterOneBits, levelAbsBits, goRiceParam, maxVlc, c1c2Idx);
> +                        rate0 = getICRate(level - 1, diff0 + 0, greaterOneBits, levelAbsBits, goRiceParam, maxVlc, c1c2Idx);
> +                    }
> +                    rateIncUp[blkPos] = rate2 - rate1;
> +                    rateIncDown[blkPos] = rate0 - rate1;
>                  }
>                  else
>                  {
> 
> _______________________________________________
> 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