[x265] [PATCH 4 of 5] rdoQuant: fast zero-coeff path
Min Chen
chenm003 at 163.com
Fri Apr 17 15:32:20 CEST 2015
# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1429277486 -28800
# Node ID 70e81203b675b6b2be781f89a9aabe04def569e2
# Parent 5a141357fd592293d9b5b66b9d173543234df783
rdoQuant: fast zero-coeff path
---
source/common/quant.cpp | 41 +++++++++++++++++++++++++++++------------
1 files changed, 29 insertions(+), 12 deletions(-)
diff -r 5a141357fd59 -r 70e81203b675 source/common/quant.cpp
--- a/source/common/quant.cpp Fri Apr 17 21:31:23 2015 +0800
+++ b/source/common/quant.cpp Fri Apr 17 21:31:26 2015 +0800
@@ -710,6 +710,7 @@
coeffGroupRDStats cgRdStats;
memset(&cgRdStats, 0, sizeof(coeffGroupRDStats));
+ uint32_t subFlagMask = coeffFlag[cgScanPos];
int c2 = 0;
uint32_t goRiceParam = 0;
uint32_t c1Idx = 0;
@@ -736,6 +737,9 @@
totalUncodedCost += costUncoded[blkPos];
+ // coefficient level estimation
+ const int* greaterOneBits = estBitsSbac.greaterOneBits[4 * ctxSet + c1];
+
// before find lastest non-zero coeff
if (scanPos > (uint32_t)lastScanPos)
{
@@ -748,8 +752,24 @@
* quantization the coefficient may have been non-zero */
totalRdCost += costUncoded[blkPos];
}
+ else if (!(subFlagMask & 1))
+ {
+ // fast zero coeff path
+ const uint32_t ctxSig = getSigCtxInc(patternSigCtx, log2TrSize, trSize, blkPos, bIsLuma, codeParams.firstSignificanceMapContext);
+
+ /* set default costs to uncoded costs */
+ costSig[scanPos] = SIGCOST(estBitsSbac.significantBits[ctxSig][0]);
+ costCoeff[scanPos] = costUncoded[blkPos] + costSig[scanPos];
+ sigRateDelta[blkPos] = estBitsSbac.significantBits[ctxSig][1] - estBitsSbac.significantBits[ctxSig][0];
+ totalRdCost += costCoeff[scanPos];
+ rateIncUp[blkPos] = greaterOneBits[0];
+
+ subFlagMask >>= 1;
+ }
else
{
+ subFlagMask >>= 1;
+
const uint32_t c1c2Idx = ((c1Idx - 8) >> (sizeof(int) * CHAR_BIT - 1)) + (((-(int)c2Idx) >> (sizeof(int) * CHAR_BIT - 1)) + 1) * 2;
const uint32_t baseLevel = ((uint32_t)0xD9 >> (c1c2Idx * 2)) & 3; // {1, 2, 1, 3}
@@ -758,10 +778,7 @@
X265_CHECK((int)baseLevel == ((c1Idx < C1FLAG_NUMBER) ? (2 + (c2Idx == 0)) : 1), "scan validation 3\n");
// coefficient level estimation
- const uint32_t oneCtx = 4 * ctxSet + c1;
- const uint32_t absCtx = ctxSet + c2;
- const int* greaterOneBits = estBitsSbac.greaterOneBits[oneCtx];
- const int* levelAbsBits = estBitsSbac.levelAbsBits[absCtx];
+ const int* levelAbsBits = estBitsSbac.levelAbsBits[ctxSet + c2];
uint32_t level = 0;
uint32_t sigCoefBits = 0;
@@ -908,19 +925,19 @@
}
else if ((c1 < 3) && (c1 > 0) && level)
c1++;
+
+ if (dstCoeff[blkPos])
+ {
+ sigCoeffGroupFlag64 |= cgBlkPosMask;
+ cgRdStats.codedLevelAndDist += costCoeff[scanPos] - costSig[scanPos];
+ cgRdStats.uncodedDist += costUncoded[blkPos];
+ cgRdStats.nnzBeforePos0 += scanPosinCG;
+ }
}
cgRdStats.sigCost += costSig[scanPos];
if (!scanPosinCG)
cgRdStats.sigCost0 = costSig[scanPos];
-
- if (dstCoeff[blkPos])
- {
- sigCoeffGroupFlag64 |= cgBlkPosMask;
- cgRdStats.codedLevelAndDist += costCoeff[scanPos] - costSig[scanPos];
- cgRdStats.uncodedDist += costUncoded[blkPos];
- cgRdStats.nnzBeforePos0 += scanPosinCG;
- }
} /* end for (scanPosinCG) */
costCoeffGroupSig[cgScanPos] = 0;
More information about the x265-devel
mailing list