[x265] [PATCH 1 of 8] convert sigCtx table from [4][4] to [16]

Min Chen chenm003 at 163.com
Thu Apr 30 12:49:33 CEST 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1430390926 -28800
# Node ID ef32940066fd4da3d132fd7b23d714849647915c
# Parent  74d7fe7a81ad773c8ae66f076c4e319b253d94ab
convert sigCtx table from [4][4] to [16]
---
 source/encoder/entropy.cpp |   42 +++++++++++++++++++++---------------------
 1 files changed, 21 insertions(+), 21 deletions(-)

diff -r 74d7fe7a81ad -r ef32940066fd source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp	Wed Apr 29 11:08:44 2015 -0500
+++ b/source/encoder/entropy.cpp	Thu Apr 30 18:48:46 2015 +0800
@@ -1570,35 +1570,35 @@
                 7, 7, 8, 8
             };
             // NOTE: [patternSigCtx][posXinSubset][posYinSubset]
-            static const uint8_t table_cnt[4][4][4] =
+            static const uint8_t table_cnt[4][SCAN_SET_SIZE] =
             {
                 // patternSigCtx = 0
                 {
-                    { 2, 1, 1, 0 },
-                    { 1, 1, 0, 0 },
-                    { 1, 0, 0, 0 },
-                    { 0, 0, 0, 0 },
+                    2, 1, 1, 0,
+                    1, 1, 0, 0,
+                    1, 0, 0, 0,
+                    0, 0, 0, 0,
                 },
                 // patternSigCtx = 1
                 {
-                    { 2, 1, 0, 0 },
-                    { 2, 1, 0, 0 },
-                    { 2, 1, 0, 0 },
-                    { 2, 1, 0, 0 },
+                    2, 2, 2, 2,
+                    1, 1, 1, 1,
+                    0, 0, 0, 0,
+                    0, 0, 0, 0,
                 },
                 // patternSigCtx = 2
                 {
-                    { 2, 2, 2, 2 },
-                    { 1, 1, 1, 1 },
-                    { 0, 0, 0, 0 },
-                    { 0, 0, 0, 0 },
+                    2, 1, 0, 0,
+                    2, 1, 0, 0,
+                    2, 1, 0, 0,
+                    2, 1, 0, 0,
                 },
                 // patternSigCtx = 3
                 {
-                    { 2, 2, 2, 2 },
-                    { 2, 2, 2, 2 },
-                    { 2, 2, 2, 2 },
-                    { 2, 2, 2, 2 },
+                    2, 2, 2, 2,
+                    2, 2, 2, 2,
+                    2, 2, 2, 2,
+                    2, 2, 2, 2,
                 }
             };
             if (m_bitIf)
@@ -1625,7 +1625,7 @@
                 {
                     X265_CHECK((log2TrSize > 2), "log2TrSize must be more than 2 in this path!\n");
 
-                    const uint8_t (*tabSigCtx)[4] = table_cnt[(uint32_t)patternSigCtx];
+                    const uint8_t *tabSigCtx = table_cnt[(uint32_t)patternSigCtx];
                     const int offset = codingParameters.firstSignificanceMapContext;
 
                     uint32_t blkPos, sig, ctxSig;
@@ -1643,7 +1643,7 @@
 
                             const uint32_t posXinSubset = blkPos & 3;
                             const uint32_t posYinSubset = posY & 3;
-                            const uint32_t cnt = tabSigCtx[posXinSubset][posYinSubset] + offset;
+                            const uint32_t cnt = tabSigCtx[posYinSubset * 4 + posXinSubset] + offset;
                             ctxSig = (cnt + posOffset) & posZeroMask;
 
                             X265_CHECK(ctxSig == Quant::getSigCtxInc(patternSigCtx, log2TrSize, trSize, blkPos, bIsLuma, codingParameters.firstSignificanceMapContext), "sigCtx mistake!\n");;
@@ -1683,7 +1683,7 @@
                 {
                     X265_CHECK((log2TrSize > 2), "log2TrSize must be more than 2 in this path!\n");
 
-                    const uint8_t (*tabSigCtx)[4] = table_cnt[(uint32_t)patternSigCtx];
+                    const uint8_t *tabSigCtx = table_cnt[(uint32_t)patternSigCtx];
                     const int offset = codingParameters.firstSignificanceMapContext;
 
                     uint32_t blkPos, sig, ctxSig;
@@ -1701,7 +1701,7 @@
 
                             const uint32_t posXinSubset = blkPos & 3;
                             const uint32_t posYinSubset = posY & 3;
-                            const uint32_t cnt = tabSigCtx[posXinSubset][posYinSubset] + offset;
+                            const uint32_t cnt = tabSigCtx[posYinSubset * 4 + posXinSubset] + offset;
                             ctxSig = (cnt + posOffset) & posZeroMask;
 
                             X265_CHECK(ctxSig == Quant::getSigCtxInc(patternSigCtx, log2TrSize, trSize, blkPos, bIsLuma, codingParameters.firstSignificanceMapContext), "sigCtx mistake!\n");;



More information about the x265-devel mailing list