[x265-commits] [x265] quant: hoist IEP_RATE out of getICRateCost
Steve Borho
steve at borho.org
Sun Aug 3 20:43:07 CEST 2014
details: http://hg.videolan.org/x265/rev/01116c890510
branches:
changeset: 7697:01116c890510
user: Steve Borho <steve at borho.org>
date: Sun Aug 03 12:56:29 2014 -0500
description:
quant: hoist IEP_RATE out of getICRateCost
diffstat:
source/common/quant.cpp | 26 ++++++++++++--------------
source/common/quant.h | 4 ++--
2 files changed, 14 insertions(+), 16 deletions(-)
diffs (101 lines):
diff -r 49bab9bdf2a3 -r 01116c890510 source/common/quant.cpp
--- a/source/common/quant.cpp Fri Aug 01 17:56:37 2014 -0700
+++ b/source/common/quant.cpp Sun Aug 03 12:56:29 2014 -0500
@@ -44,12 +44,12 @@ struct coeffGroupRDStats
double sigCost0;
};
-inline static int fastMin(int x, int y)
+inline int fastMin(int x, int y)
{
return y + ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))); // min(x, y)
}
-inline static void denoiseDct(coeff_t* dctCoef, uint32_t* resSum, uint16_t* offset, int size)
+inline void denoiseDct(coeff_t* dctCoef, uint32_t* resSum, uint16_t* offset, int size)
{
for (int i = 0; i < size; i++)
{
@@ -121,46 +121,44 @@ inline int getICRate(uint32_t absLevel,
inline uint32_t getICRateCost(uint32_t absLevel, int32_t diffLevel, const int *greaterOneBits, const int *levelAbsBits, uint32_t absGoRice, uint32_t c1c2Idx)
{
X265_CHECK(absLevel, "absLevel should not be zero\n");
- uint32_t rate = Quant::IEP_RATE;
if (diffLevel < 0)
{
X265_CHECK((absLevel == 1) || (absLevel == 2), "absLevel range check failure\n");
- rate += greaterOneBits[(absLevel == 2)];
+ uint32_t rate = greaterOneBits[(absLevel == 2)];
if (absLevel == 2)
rate += levelAbsBits[0];
+ return rate;
}
else
{
+ uint32_t rate;
uint32_t symbol = diffLevel;
- uint32_t length;
if ((symbol >> absGoRice) < COEF_REMAIN_BIN_REDUCTION)
{
- length = symbol >> absGoRice;
- rate += (length + 1 + absGoRice) << 15;
+ uint32_t length = symbol >> absGoRice;
+ rate = (length + 1 + absGoRice) << 15;
}
else
{
- length = 0;
+ uint32_t length = 0;
symbol = (symbol >> absGoRice) - COEF_REMAIN_BIN_REDUCTION;
- if (symbol != 0)
+ if (symbol)
{
unsigned long idx;
CLZ32(idx, symbol + 1);
length = idx;
}
- rate += (COEF_REMAIN_BIN_REDUCTION + length + absGoRice + 1 + length) << 15;
+ rate = (COEF_REMAIN_BIN_REDUCTION + length + absGoRice + 1 + length) << 15;
}
if (c1c2Idx & 1)
rate += greaterOneBits[1];
-
if (c1c2Idx == 3)
rate += levelAbsBits[1];
+ return rate;
}
-
- return rate;
}
}
@@ -641,7 +639,7 @@ uint32_t Quant::rdoQuant(TComDataCU* cu,
for (uint32_t lvl = maxAbsLevel; lvl >= minAbsLevel; lvl--)
{
uint32_t rateCost = getICRateCost(lvl, lvl - baseLevel, greaterOneBits, levelAbsBits, goRiceParam, c1c2Idx);
- double curCost = err2 * scaleFactor + lambda2 * (codedSigBits + rateCost);
+ double curCost = err2 * scaleFactor + lambda2 * (codedSigBits + rateCost + IEP_RATE);
// Psy RDOQ: bias in favor of higher AC coefficients in the reconstructed frame
int psyValue = 0;
diff -r 49bab9bdf2a3 -r 01116c890510 source/common/quant.h
--- a/source/common/quant.h Fri Aug 01 17:56:37 2014 -0700
+++ b/source/common/quant.h Sun Aug 03 12:56:29 2014 -0500
@@ -105,12 +105,12 @@ public:
coeff_t* m_fencDctCoeff;
int16_t* m_fencShortBuf;
- enum { IEP_RATE = 32768 }; // cost of an equal probable bit
-
void setQPforQuant(int qpy, TextType ttype, int chromaQPOffset, int chFmt);
protected:
+ enum { IEP_RATE = 32768 }; // cost of an equal probable bit
+
uint32_t signBitHidingHDQ(coeff_t* qcoeff, coeff_t* coeff, int32_t* deltaU, uint32_t numSig, const TUEntropyCodingParameters &codingParameters);
uint32_t quant(TComDataCU* cu, coeff_t* dst, uint32_t log2TrSize, TextType ttype, uint32_t absPartIdx);
More information about the x265-commits
mailing list