[x265] [PATCH 2 of 2] move m_estBitsSbac from Quant to Entropy
Min Chen
chenm003 at 163.com
Thu Aug 14 02:29:29 CEST 2014
# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1407976158 25200
# Node ID 6487dee1c917e1600935673d71351f55125be198
# Parent 41de0838d88bf89b9156e44e31772273df24c070
move m_estBitsSbac from Quant to Entropy
diff -r 41de0838d88b -r 6487dee1c917 source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp Wed Aug 13 17:29:06 2014 -0700
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp Wed Aug 13 17:29:18 2014 -0700
@@ -427,7 +427,7 @@
//===== transform and quantization =====
//--- init rate estimation arrays for RDOQ ---
if (m_bEnableRDOQ)
- m_entropyCoder->estBit(m_quant.m_estBitsSbac, log2TrSize, TEXT_LUMA);
+ m_entropyCoder->estBit(m_entropyCoder->m_estBitsSbac, log2TrSize, TEXT_LUMA);
//--- transform and quantization ---
uint32_t numSig = m_quant.transformNxN(cu, fenc, stride, residual, stride, coeff, log2TrSize, TEXT_LUMA, absPartIdx, useTransformSkip);
@@ -496,7 +496,7 @@
//===== transform and quantization =====
//--- init rate estimation arrays for RDOQ ---
if (m_bEnableRDOQ)
- m_entropyCoder->estBit(m_quant.m_estBitsSbac, log2TrSizeC, TEXT_CHROMA);
+ m_entropyCoder->estBit(m_entropyCoder->m_estBitsSbac, log2TrSizeC, TEXT_CHROMA);
//--- transform and quantization ---
uint32_t numSig = m_quant.transformNxN(cu, fenc, stride, residual, stride, coeff, log2TrSizeC, ttype, absPartIdx, useTransformSkipC);
@@ -2720,7 +2720,7 @@
cu->setTransformSkipSubParts(0, TEXT_LUMA, absPartIdx, depth);
if (m_bEnableRDOQ)
- m_entropyCoder->estBit(m_quant.m_estBitsSbac, log2TrSize, TEXT_LUMA);
+ m_entropyCoder->estBit(m_entropyCoder->m_estBitsSbac, log2TrSize, TEXT_LUMA);
numSigY = m_quant.transformNxN(cu, fencYuv->getLumaAddr(absPartIdx), fencYuv->getStride(), resiYuv->getLumaAddr(absPartIdx), resiYuv->m_width, coeffCurY,
log2TrSize, TEXT_LUMA, absPartIdx, false);
@@ -2748,7 +2748,7 @@
cu->setTransformSkipPartRange(0, TEXT_CHROMA_V, absPartIdxC, tuIterator.absPartIdxStep);
if (m_bEnableRDOQ)
- m_entropyCoder->estBit(m_quant.m_estBitsSbac, log2TrSizeC, TEXT_CHROMA);
+ m_entropyCoder->estBit(m_entropyCoder->m_estBitsSbac, log2TrSizeC, TEXT_CHROMA);
numSigU[tuIterator.section] = m_quant.transformNxN(cu, fencYuv->getCbAddr(absPartIdxC), fencYuv->getCStride(), resiYuv->getCbAddr(absPartIdxC), resiYuv->m_cwidth, coeffCurU + subTUOffset,
log2TrSizeC, TEXT_CHROMA_U, absPartIdxC, false);
@@ -3079,7 +3079,7 @@
cu->setTransformSkipSubParts(1, TEXT_LUMA, absPartIdx, depth);
if (m_bEnableRDOQ)
- m_entropyCoder->estBit(m_quant.m_estBitsSbac, log2TrSize, TEXT_LUMA);
+ m_entropyCoder->estBit(m_entropyCoder->m_estBitsSbac, log2TrSize, TEXT_LUMA);
uint32_t numSigTSkipY = m_quant.transformNxN(cu, fencYuv->getLumaAddr(absPartIdx), fencYuv->getStride(), resiYuv->getLumaAddr(absPartIdx), resiYuv->m_width, tsCoeffY,
log2TrSize, TEXT_LUMA, absPartIdx, true);
@@ -3160,7 +3160,7 @@
cu->setTransformSkipPartRange(1, TEXT_CHROMA_V, absPartIdxC, tuIterator.absPartIdxStep);
if (m_bEnableRDOQ)
- m_entropyCoder->estBit(m_quant.m_estBitsSbac, log2TrSizeC, TEXT_CHROMA);
+ m_entropyCoder->estBit(m_entropyCoder->m_estBitsSbac, log2TrSizeC, TEXT_CHROMA);
uint32_t numSigTSkipU = m_quant.transformNxN(cu, fencYuv->getCbAddr(absPartIdxC), fencYuv->getCStride(), resiYuv->getCbAddr(absPartIdxC), resiYuv->m_cwidth, tsCoeffU,
log2TrSizeC, TEXT_CHROMA_U, absPartIdxC, true);
diff -r 41de0838d88b -r 6487dee1c917 source/common/quant.cpp
--- a/source/common/quant.cpp Wed Aug 13 17:29:06 2014 -0700
+++ b/source/common/quant.cpp Wed Aug 13 17:29:18 2014 -0700
@@ -25,6 +25,7 @@
#include "primitives.h"
#include "quant.h"
#include "frame.h"
+#include "entropy.h"
#include "TLibCommon/TComDataCU.h"
#include "TLibCommon/TComYuv.h"
#include "TLibCommon/ContextTables.h"
@@ -621,8 +622,8 @@
// coefficient level estimation
const uint32_t oneCtx = 4 * ctxSet + c1;
const uint32_t absCtx = ctxSet + c2;
- const int *greaterOneBits = m_estBitsSbac.greaterOneBits[oneCtx];
- const int *levelAbsBits = m_estBitsSbac.levelAbsBits[absCtx];
+ const int *greaterOneBits = m_entropyCoder->m_estBitsSbac.greaterOneBits[oneCtx];
+ const int *levelAbsBits = m_entropyCoder->m_estBitsSbac.levelAbsBits[absCtx];
uint32_t level = 0;
uint32_t sigCoefBits = 0;
@@ -636,11 +637,11 @@
if (maxAbsLevel < 3)
{
/* set default costs to uncoded costs */
- costSig[scanPos] = SIGCOST(m_estBitsSbac.significantBits[ctxSig][0]);
+ costSig[scanPos] = SIGCOST(m_entropyCoder->m_estBitsSbac.significantBits[ctxSig][0]);
costCoeff[scanPos] = costUncoded[scanPos] + costSig[scanPos];
}
- sigRateDelta[blkPos] = m_estBitsSbac.significantBits[ctxSig][1] - m_estBitsSbac.significantBits[ctxSig][0];
- sigCoefBits = m_estBitsSbac.significantBits[ctxSig][1];
+ sigRateDelta[blkPos] = m_entropyCoder->m_estBitsSbac.significantBits[ctxSig][1] - m_entropyCoder->m_estBitsSbac.significantBits[ctxSig][0];
+ sigCoefBits = m_entropyCoder->m_estBitsSbac.significantBits[ctxSig][1];
}
if (maxAbsLevel)
{
@@ -755,19 +756,19 @@
uint32_t sigCtx = getSigCoeffGroupCtxInc(sigCoeffGroupFlag64, cgPosX, cgPosY, codeParams.log2TrSizeCG);
- int64_t costZeroCG = totalRdCost + SIGCOST(m_estBitsSbac.significantCoeffGroupBits[sigCtx][0]);
+ int64_t costZeroCG = totalRdCost + SIGCOST(m_entropyCoder->m_estBitsSbac.significantCoeffGroupBits[sigCtx][0]);
costZeroCG += cgRdStats.uncodedDist; /* add distortion for resetting non-zero levels to zero levels */
costZeroCG -= cgRdStats.codedLevelAndDist; /* remove distortion and level cost of coded coefficients */
costZeroCG -= cgRdStats.sigCost; /* remove signaling cost of significant coeff bitmap */
- costCoeffGroupSig[cgScanPos] = SIGCOST(m_estBitsSbac.significantCoeffGroupBits[sigCtx][1]);
+ costCoeffGroupSig[cgScanPos] = SIGCOST(m_entropyCoder->m_estBitsSbac.significantCoeffGroupBits[sigCtx][1]);
totalRdCost += costCoeffGroupSig[cgScanPos]; /* add the cost of 1 bit in significant CG bitmap */
if (costZeroCG < totalRdCost)
{
sigCoeffGroupFlag64 &= ~cgBlkPosMask;
totalRdCost = costZeroCG;
- costCoeffGroupSig[cgScanPos] = SIGCOST(m_estBitsSbac.significantCoeffGroupBits[sigCtx][0]);
+ costCoeffGroupSig[cgScanPos] = SIGCOST(m_entropyCoder->m_estBitsSbac.significantCoeffGroupBits[sigCtx][0]);
/* reset all coeffs to 0. UNCODE THIS COEFF GROUP! */
for (int scanPosinCG = cgSize - 1; scanPosinCG >= 0; scanPosinCG--)
@@ -787,7 +788,7 @@
{
/* there were no coded coefficients in this coefficient group */
uint32_t ctxSig = getSigCoeffGroupCtxInc(sigCoeffGroupFlag64, cgPosX, cgPosY, codeParams.log2TrSizeCG);
- costCoeffGroupSig[cgScanPos] = SIGCOST(m_estBitsSbac.significantCoeffGroupBits[ctxSig][0]);
+ costCoeffGroupSig[cgScanPos] = SIGCOST(m_entropyCoder->m_estBitsSbac.significantCoeffGroupBits[ctxSig][0]);
totalRdCost += costCoeffGroupSig[cgScanPos]; /* add cost of 0 bit in significant CG bitmap */
totalRdCost -= cgRdStats.sigCost; /* remove cost of significant coefficient bitmap */
}
@@ -799,14 +800,14 @@
int64_t bestCost;
if (!cu->isIntra(absPartIdx) && bIsLuma && !cu->getTransformIdx(absPartIdx))
{
- bestCost = totalUncodedCost + SIGCOST(m_estBitsSbac.blockRootCbpBits[0][0]);
- totalRdCost += SIGCOST(m_estBitsSbac.blockRootCbpBits[0][1]);
+ bestCost = totalUncodedCost + SIGCOST(m_entropyCoder->m_estBitsSbac.blockRootCbpBits[0][0]);
+ totalRdCost += SIGCOST(m_entropyCoder->m_estBitsSbac.blockRootCbpBits[0][1]);
}
else
{
int ctx = cu->getCtxQtCbf(ttype, cu->getTransformIdx(absPartIdx));
- bestCost = totalUncodedCost + SIGCOST(m_estBitsSbac.blockCbpBits[ctx][0]);
- totalRdCost += SIGCOST(m_estBitsSbac.blockCbpBits[ctx][1]);
+ bestCost = totalUncodedCost + SIGCOST(m_entropyCoder->m_estBitsSbac.blockCbpBits[ctx][0]);
+ totalRdCost += SIGCOST(m_entropyCoder->m_estBitsSbac.blockCbpBits[ctx][1]);
}
/* This loop starts with the last non-zero found in the first loop and then refines this last
@@ -1105,7 +1106,7 @@
{
uint32_t ctxX = getGroupIdx(posx);
uint32_t ctxY = getGroupIdx(posy);
- uint32_t cost = m_estBitsSbac.lastXBits[ctxX] + m_estBitsSbac.lastYBits[ctxY];
+ uint32_t cost = m_entropyCoder->m_estBitsSbac.lastXBits[ctxX] + m_entropyCoder->m_estBitsSbac.lastYBits[ctxY];
int32_t maskX = (int32_t)(2 - posx) >> 31;
int32_t maskY = (int32_t)(2 - posy) >> 31;
diff -r 41de0838d88b -r 6487dee1c917 source/common/quant.h
--- a/source/common/quant.h Wed Aug 13 17:29:06 2014 -0700
+++ b/source/common/quant.h Wed Aug 13 17:29:18 2014 -0700
@@ -33,21 +33,9 @@
// private namespace
class TComDataCU;
+class Entropy;
struct TUEntropyCodingParameters;
-struct EstBitsSbac
-{
- int significantCoeffGroupBits[NUM_SIG_CG_FLAG_CTX][2];
- uint32_t significantBits[NUM_SIG_FLAG_CTX][2];
- int lastXBits[10];
- int lastYBits[10];
- int greaterOneBits[NUM_ONE_FLAG_CTX][2];
- int levelAbsBits[NUM_ABS_FLAG_CTX][2];
-
- int blockCbpBits[NUM_QT_CBF_CTX][2];
- int blockRootCbpBits[NUM_QT_ROOT_CBF_CTX][2];
-};
-
struct QpParam
{
int rem;
@@ -71,8 +59,8 @@
{
public:
- EstBitsSbac m_estBitsSbac;
NoiseReduction* m_nr;
+ Entropy* m_entropyCoder;
protected:
diff -r 41de0838d88b -r 6487dee1c917 source/encoder/cturow.cpp
--- a/source/encoder/cturow.cpp Wed Aug 13 17:29:06 2014 -0700
+++ b/source/encoder/cturow.cpp Wed Aug 13 17:29:18 2014 -0700
@@ -50,6 +50,7 @@
// setup thread local data structures to use this row's CABAC state
tld.m_cuCoder.m_entropyCoder = &m_entropyCoder;
tld.m_cuCoder.m_rdEntropyCoders = m_rdEntropyCoders;
+ tld.m_cuCoder.m_quant.m_entropyCoder = &m_entropyCoder;
tld.m_cuCoder.compressCU(cu); // Does all the CU analysis
diff -r 41de0838d88b -r 6487dee1c917 source/encoder/entropy.h
--- a/source/encoder/entropy.h Wed Aug 13 17:29:06 2014 -0700
+++ b/source/encoder/entropy.h Wed Aug 13 17:29:18 2014 -0700
@@ -85,6 +85,19 @@
}
};
+struct EstBitsSbac
+{
+ int significantCoeffGroupBits[NUM_SIG_CG_FLAG_CTX][2];
+ uint32_t significantBits[NUM_SIG_FLAG_CTX][2];
+ int lastXBits[10];
+ int lastYBits[10];
+ int greaterOneBits[NUM_ONE_FLAG_CTX][2];
+ int levelAbsBits[NUM_ABS_FLAG_CTX][2];
+
+ int blockCbpBits[NUM_QT_CBF_CTX][2];
+ int blockRootCbpBits[NUM_QT_ROOT_CBF_CTX][2];
+};
+
class Entropy : public SyntaxElementWriter
{
public:
@@ -99,6 +112,7 @@
int m_numBufferedBytes;
int m_bitsLeft;
uint64_t m_fracBits;
+ EstBitsSbac m_estBitsSbac;
Entropy();
More information about the x265-devel
mailing list