[x265] [PATCH] faster ctxSig by replace array table_cnt by 64-bits constant

Min Chen chenm003 at 163.com
Wed Aug 26 01:51:15 CEST 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1440545952 25200
# Node ID 6659e1ef92c2a4887a089b9a50a10a80d5e2b2a0
# Parent  7012026de2627f6b7f421c28930ba028684e9186
faster ctxSig by replace array table_cnt by 64-bits constant
---
 source/common/quant.cpp |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff -r 7012026de262 -r 6659e1ef92c2 source/common/quant.cpp
--- a/source/common/quant.cpp	Tue Aug 25 10:59:08 2015 -0700
+++ b/source/common/quant.cpp	Tue Aug 25 16:39:12 2015 -0700
@@ -854,7 +854,13 @@
 
             // coefficient level estimation
             const int* greaterOneBits = estBitsSbac.greaterOneBits[4 * ctxSet + c1];
-            const uint32_t ctxSig = (blkPos == 0) ? 0 : table_cnt[(trSize == 4) ? 4 : patternSigCtx][g_scan4x4[codeParams.scanType][scanPosinCG]] + ctxSigOffset;
+            //const uint32_t ctxSig = (blkPos == 0) ? 0 : table_cnt[(trSize == 4) ? 4 : patternSigCtx][g_scan4x4[codeParams.scanType][scanPosinCG]] + ctxSigOffset;
+            static const uint64_t table_cnt64[4] = {0x0000000100110112ULL, 0x0000000011112222ULL, 0x0012001200120012ULL, 0x2222222222222222ULL};
+            uint64_t ctxCnt = table_cnt64[patternSigCtx];
+            if (trSize == 4)
+                ctxCnt = 0x8877886654325410ULL;
+            const uint32_t ctxSig = (blkPos == 0) ? 0 : ((ctxCnt >> (4 * g_scan4x4[codeParams.scanType][scanPosinCG])) & 0xF) + ctxSigOffset;
+            // NOTE: above equal to 'table_cnt[(trSize == 4) ? 4 : patternSigCtx][g_scan4x4[codeParams.scanType][scanPosinCG]] + ctxSigOffset'
             X265_CHECK(ctxSig == getSigCtxInc(patternSigCtx, log2TrSize, trSize, blkPos, bIsLuma, codeParams.firstSignificanceMapContext), "sigCtx check failure\n");
 
             // before find lastest non-zero coeff



More information about the x265-devel mailing list