[x265] [PATCH 2 of 3] improve codeCoeffNxN by merge loop of encodeBin
Min Chen
chenm003 at 163.com
Wed Mar 25 02:39:14 CET 2015
# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1427247535 25200
# Node ID f1b266a1cba40f08e2306766fd6dc2c7292a0504
# Parent 51f63f5968617c7854b30d4e339418802e383795
improve codeCoeffNxN by merge loop of encodeBin
---
source/encoder/entropy.cpp | 31 ++++++++++++++++++++++++++++++-
1 files changed, 30 insertions(+), 1 deletions(-)
diff -r 51f63f596861 -r f1b266a1cba4 source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp Tue Mar 24 18:38:51 2015 -0700
+++ b/source/encoder/entropy.cpp Tue Mar 24 18:38:55 2015 -0700
@@ -1625,6 +1625,8 @@
static const uint32_t posXY4Mask[] = {0x024, 0x0CC, 0x39C};
const uint32_t posGT4Mask = posXY4Mask[log2TrSize - 3] & lumaMask;
+ uint8_t _sigList[16][2];
+ uint8_t (*pSigListEnd)[2] = _sigList;
uint32_t blkPos, sig, ctxSig;
for (; scanPosSigOff >= 0; scanPosSigOff--)
{
@@ -1645,11 +1647,38 @@
ctxSig = (cnt + posOffset) & posZeroMask;
X265_CHECK(ctxSig == Quant::getSigCtxInc(patternSigCtx, log2TrSize, trSize, blkPos, bIsLuma, codingParameters.firstSignificanceMapContext), "sigCtx mistake!\n");;
- encodeBin(sig, baseCtx[ctxSig]);
+ //encodeBin(sig, baseCtx[ctxSig]);
+ (*pSigListEnd)[0] = (uint8_t)sig;
+ (*pSigListEnd)[1] = (uint8_t)ctxSig;
+ pSigListEnd++;
}
absCoeff[numNonZero] = int(abs(coeff[blkPos]));
numNonZero += sig;
}
+ X265_CHECK(pSigListEnd <= &_sigList[16], "numSigList must be less or equal to 16\n");
+
+ uint8_t (*pSigScan)[2] = _sigList;
+ if (!m_bitIf)
+ {
+ while(pSigScan != pSigListEnd)
+ {
+ const uint32_t binValue = (*pSigScan)[0];
+ uint8_t &ctxModel = baseCtx[(*pSigScan)[1]];
+ pSigScan++;
+ uint32_t mstate = ctxModel;
+
+ ctxModel = sbacNext(mstate, binValue);
+ m_fracBits += sbacGetEntropyBits(mstate, binValue);
+ }
+ }
+ else
+ {
+ while(pSigScan != pSigListEnd)
+ {
+ encodeBin((*pSigScan)[0], baseCtx[(*pSigScan)[1]]);
+ pSigScan++;
+ }
+ }
}
}
X265_CHECK(coeffNum[subSet] == numNonZero, "coefNum mistake\n");
More information about the x265-devel
mailing list