[x265] [PATCH algorithm modify] simplify coeff group clear when CG decide to not encode
Steve Borho
steve at borho.org
Tue Apr 7 17:13:46 CEST 2015
On 04/07, Min Chen wrote:
> # HG changeset patch
> # User Min Chen <chenm003 at 163.com>
> # Date 1428408208 -28800
> # Node ID d69e0b8066d7b146e1a4f1a17a9c6678e2740b30
> # Parent 095ed87526e5964ad45949ec81903704451d79f8
> simplify coeff group clear when CG decide to not encode
queued
> ---
> source/common/quant.cpp | 23 +++++++++--------------
> 1 files changed, 9 insertions(+), 14 deletions(-)
>
> diff -r 095ed87526e5 -r d69e0b8066d7 source/common/quant.cpp
> --- a/source/common/quant.cpp Tue Apr 07 09:42:31 2015 +0530
> +++ b/source/common/quant.cpp Tue Apr 07 20:03:28 2015 +0800
> @@ -585,6 +585,7 @@
> TUEntropyCodingParameters codeParams;
> cu.getTUEntropyCodingParameters(codeParams, absPartIdx, log2TrSize, bIsLuma);
> const uint32_t cgNum = 1 << (codeParams.log2TrSizeCG * 2);
> + const uint32_t cgStride = (trSize >> MLS_CG_LOG2_SIZE);
>
> /* TODO: update bit estimates if dirty */
> EstBitsSbac& estBitsSbac = m_entropyCoder->m_estBitsSbac;
> @@ -601,7 +602,7 @@
> const uint64_t cgBlkPosMask = ((uint64_t)1 << cgBlkPos);
> memset(&cgRdStats, 0, sizeof(coeffGroupRDStats));
>
> - const int patternSigCtx = calcPatternSigCtx(sigCoeffGroupFlag64, cgPosX, cgPosY, cgBlkPos, (trSize >> MLS_CG_LOG2_SIZE));
> + const int patternSigCtx = calcPatternSigCtx(sigCoeffGroupFlag64, cgPosX, cgPosY, cgBlkPos, cgStride);
>
> /* iterate over coefficients in each group in reverse scan order */
> for (int scanPosinCG = cgSize - 1; scanPosinCG >= 0; scanPosinCG--)
> @@ -824,7 +825,7 @@
> * of the significant coefficient group flag and evaluate whether the RD cost of the
> * coded group is more than the RD cost of the uncoded group */
>
> - uint32_t sigCtx = getSigCoeffGroupCtxInc(sigCoeffGroupFlag64, cgPosX, cgPosY, cgBlkPos, (trSize >> MLS_CG_LOG2_SIZE));
> + uint32_t sigCtx = getSigCoeffGroupCtxInc(sigCoeffGroupFlag64, cgPosX, cgPosY, cgBlkPos, cgStride);
>
> int64_t costZeroCG = totalRdCost + SIGCOST(estBitsSbac.significantCoeffGroupBits[sigCtx][0]);
> costZeroCG += cgRdStats.uncodedDist; /* add distortion for resetting non-zero levels to zero levels */
> @@ -841,23 +842,17 @@
> costCoeffGroupSig[cgScanPos] = SIGCOST(estBitsSbac.significantCoeffGroupBits[sigCtx][0]);
>
> /* reset all coeffs to 0. UNCODE THIS COEFF GROUP! */
> - for (int scanPosinCG = cgSize - 1; scanPosinCG >= 0; scanPosinCG--)
> - {
> - scanPos = cgScanPos * cgSize + scanPosinCG;
> - uint32_t blkPos = codeParams.scan[scanPos];
> - if (dstCoeff[blkPos])
> - {
> - costCoeff[scanPos] = costUncoded[scanPos];
> - costSig[scanPos] = 0;
> - }
> - dstCoeff[blkPos] = 0;
> - }
> + const uint32_t blkPos = codeParams.scan[cgScanPos * cgSize];
> + memset(&dstCoeff[blkPos + 0 * trSize], 0, 4 * sizeof(*dstCoeff));
> + memset(&dstCoeff[blkPos + 1 * trSize], 0, 4 * sizeof(*dstCoeff));
> + memset(&dstCoeff[blkPos + 2 * trSize], 0, 4 * sizeof(*dstCoeff));
> + memset(&dstCoeff[blkPos + 3 * trSize], 0, 4 * sizeof(*dstCoeff));
> }
> }
> else
> {
> /* there were no coded coefficients in this coefficient group */
> - uint32_t ctxSig = getSigCoeffGroupCtxInc(sigCoeffGroupFlag64, cgPosX, cgPosY, cgBlkPos, (trSize >> MLS_CG_LOG2_SIZE));
> + uint32_t ctxSig = getSigCoeffGroupCtxInc(sigCoeffGroupFlag64, cgPosX, cgPosY, cgBlkPos, cgStride);
> costCoeffGroupSig[cgScanPos] = SIGCOST(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 */
>
> _______________________________________________
> 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