[x265] const tables

Satoshi Nakagawa nakagawa424 at oki.com
Thu Feb 13 08:44:45 CET 2014


# HG changeset patch
# User Satoshi Nakagawa <nakagawa424 at oki.com>
# Date 1392277193 -32400
#      Thu Feb 13 16:39:53 2014 +0900
# Node ID 3466fd21eb9e49722b8e6597e4a98884948a5571
# Parent  21832083908f96fa7c7f51f13457837fb0e8c2f9
const tables

diff -r 21832083908f -r 3466fd21eb9e source/Lib/TLibCommon/TComRom.cpp
--- a/source/Lib/TLibCommon/TComRom.cpp	Wed Feb 12 17:39:50 2014 -0600
+++ b/source/Lib/TLibCommon/TComRom.cpp	Thu Feb 13 16:39:53 2014 +0900
@@ -104,7 +104,7 @@
 uint32_t g_rasterToPelX[MAX_NUM_SPU_W * MAX_NUM_SPU_W] = { 0, };
 uint32_t g_rasterToPelY[MAX_NUM_SPU_W * MAX_NUM_SPU_W] = { 0, };
 
-uint32_t g_puOffset[8] = { 0, 8, 4, 4, 2, 10, 1, 5 };
+const uint32_t g_puOffset[8] = { 0, 8, 4, 4, 2, 10, 1, 5 };
 
 void initZscanToRaster(int maxDepth, int depth, uint32_t startVal, uint32_t*& curIdx)
 {
@@ -192,12 +192,12 @@
     { -2, 10, 58, -2 }
 };
 
-int g_quantScales[6] =
+const int g_quantScales[6] =
 {
     26214, 23302, 20560, 18396, 16384, 14564
 };
 
-int g_invQuantScales[6] =
+const int g_invQuantScales[6] =
 {
     40, 45, 51, 57, 64, 72
 };
@@ -330,7 +330,17 @@
     { 0, 1, 2, 3 },
     { 0, 2, 1, 3 }
 };
-uint32_t g_sigLastScanCG32x32[64];
+const uint32_t g_sigLastScanCG32x32[64] =
+{
+     0,  8,  1, 16,  9,  2, 24, 17,
+    10,  3, 32, 25, 18, 11,  4, 40,
+    33, 26, 19, 12,  5, 48, 41, 34,
+    27, 20, 13,  6, 56, 49, 42, 35,
+    28, 21, 14,  7, 57, 50, 43, 36,
+    29, 22, 15, 58, 51, 44, 37, 30,
+    23, 59, 52, 45, 38, 31, 60, 53,
+    46, 39, 61, 54, 47, 62, 55, 63
+};
 
 const uint32_t g_minInGroup[10] = { 0, 1, 2, 3, 4, 6, 8, 12, 16, 24 };
 const uint32_t g_groupIdx[32]   = { 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9 };
@@ -345,13 +355,8 @@
     const uint32_t  numScanPos  = uint32_t(width * width);
     uint32_t        nextScanPos = 0;
 
-    if (width < 16)
+    if (width <= 4)
     {
-        uint32_t* buffTemp = buffD;
-        if (width == 8)
-        {
-            buffTemp = g_sigLastScanCG32x32;
-        }
         for (uint32_t scanLine = 0; nextScanPos < numScanPos; scanLine++)
         {
             int primDim = int(scanLine);
@@ -364,7 +369,7 @@
 
             while (primDim >= 0 && scndDim < width)
             {
-                buffTemp[nextScanPos] = primDim * width + scndDim;
+                buffD[nextScanPos] = primDim * width + scndDim;
                 nextScanPos++;
                 scndDim++;
                 primDim--;
@@ -501,9 +506,9 @@
     20, 24, 25, 28, 33, 41, 54, 71,
     24, 25, 28, 33, 41, 54, 71, 91
 };
-uint32_t g_scalingListSize[4] = { 16, 64, 256, 1024 };
-uint32_t g_scalingListSizeX[4] = { 4, 8, 16,  32 };
-uint32_t g_scalingListNum[SCALING_LIST_SIZE_NUM] = { 6, 6, 6, 2 };
+const uint32_t g_scalingListSize[4] = { 16, 64, 256, 1024 };
+const uint32_t g_scalingListSizeX[4] = { 4, 8, 16,  32 };
+const uint32_t g_scalingListNum[SCALING_LIST_SIZE_NUM] = { 6, 6, 6, 2 };
 
 const int g_winUnitX[] = { 1, 2, 2, 1 };
 const int g_winUnitY[] = { 1, 2, 1, 1 };
diff -r 21832083908f -r 3466fd21eb9e source/Lib/TLibCommon/TComRom.h
--- a/source/Lib/TLibCommon/TComRom.h	Wed Feb 12 17:39:50 2014 -0600
+++ b/source/Lib/TLibCommon/TComRom.h	Thu Feb 13 16:39:53 2014 +0900
@@ -94,7 +94,7 @@
 #define MAX_TS_WIDTH  4
 #define MAX_TS_HEIGHT 4
 
-extern uint32_t g_puOffset[8];
+extern const uint32_t g_puOffset[8];
 
 #define QUANT_IQUANT_SHIFT    20 // Q(QP%6) * IQ(QP%6) = 2^20
 #define QUANT_SHIFT           14 // Q(4) = 2^14
@@ -104,8 +104,8 @@
 #define SHIFT_INV_1ST          7 // Shift after first inverse transform stage
 #define SHIFT_INV_2ND         12 // Shift after second inverse transform stage
 
-extern int g_quantScales[6];     // Q(QP%6)
-extern int g_invQuantScales[6];  // IQ(QP%6)
+extern const int g_quantScales[6];     // Q(QP%6)
+extern const int g_invQuantScales[6];  // IQ(QP%6)
 extern const int16_t g_t4[4][4];
 extern const int16_t g_t8[8][8];
 extern const int16_t g_t16[16][16];
@@ -143,7 +143,7 @@
 extern const uint32_t g_goRicePrefixLen[5];  //!< prefix length for each maximum value
 
 extern const uint32_t g_sigLastScan8x8[3][4];   //!< coefficient group scan order for 8x8 TUs
-extern       uint32_t g_sigLastScanCG32x32[64];
+extern const uint32_t g_sigLastScanCG32x32[64];
 
 // ====================================================================================================================
 // ADI table
@@ -279,9 +279,9 @@
 extern int g_quantInterDefault16x16[256];
 extern int g_quantInterDefault32x32[1024];
 extern int g_quantTSDefault4x4[16];
-extern uint32_t g_scalingListSize[SCALING_LIST_SIZE_NUM];
-extern uint32_t g_scalingListSizeX[SCALING_LIST_SIZE_NUM];
-extern uint32_t g_scalingListNum[SCALING_LIST_SIZE_NUM];
+extern const uint32_t g_scalingListSize[SCALING_LIST_SIZE_NUM];
+extern const uint32_t g_scalingListSizeX[SCALING_LIST_SIZE_NUM];
+extern const uint32_t g_scalingListNum[SCALING_LIST_SIZE_NUM];
 //! \}
 
 // Map Luma samples to chroma samples
diff -r 21832083908f -r 3466fd21eb9e source/Lib/TLibCommon/TComTrQuant.cpp
--- a/source/Lib/TLibCommon/TComTrQuant.cpp	Wed Feb 12 17:39:50 2014 -0600
+++ b/source/Lib/TLibCommon/TComTrQuant.cpp	Thu Feb 13 16:39:53 2014 +0900
@@ -1066,7 +1066,7 @@
     int posYinSubset = posY & 3;
 
     // NOTE: [patternSigCtx][posXinSubset][posYinSubset]
-    static uint8_t table_cnt[4][4][4] =
+    static const uint8_t table_cnt[4][4][4] =
     {
         // patternSigCtx = 0
         {
diff -r 21832083908f -r 3466fd21eb9e source/Lib/TLibEncoder/TEncSbac.cpp
--- a/source/Lib/TLibEncoder/TEncSbac.cpp	Wed Feb 12 17:39:50 2014 -0600
+++ b/source/Lib/TLibEncoder/TEncSbac.cpp	Thu Feb 13 16:39:53 2014 +0900
@@ -152,7 +152,7 @@
         tmpContextModel.m_state = sbacInit(qp, ctxModel[n]);
 
         // Map the 64 CABAC states to their corresponding probability values
-        static double aStateToProbLPS[] = { 0.50000000, 0.47460857, 0.45050660, 0.42762859, 0.40591239, 0.38529900, 0.36573242, 0.34715948, 0.32952974, 0.31279528, 0.29691064, 0.28183267, 0.26752040, 0.25393496, 0.24103941, 0.22879875, 0.21717969, 0.20615069, 0.19568177, 0.18574449, 0.17631186, 0.16735824, 0.15885931, 0.15079198, 0.14313433, 0.13586556, 0.12896592, 0.12241667, 0.11620000, 0.11029903, 0.10469773, 0.09938088, 0.09433404, 0.08954349, 0.08499621, 0.08067986, 0.07658271, 0.07269362, 0.06900203, 0.06549791, 0.06217174, 0.05901448, 0.05601756, 0.05317283, 0.05047256, 0.04790942, 0.04547644, 0.04316702, 0.04097487, 0.03889405, 0.03691890, 0.03504406, 0.03326442, 0.03157516, 0.02997168, 0.02844963, 0.02700488, 0.02563349, 0.02433175, 0.02309612, 0.02192323, 0.02080991, 0.01975312, 0.01875000 };
+        static const double aStateToProbLPS[] = { 0.50000000, 0.47460857, 0.45050660, 0.42762859, 0.40591239, 0.38529900, 0.36573242, 0.34715948, 0.32952974, 0.31279528, 0.29691064, 0.28183267, 0.26752040, 0.25393496, 0.24103941, 0.22879875, 0.21717969, 0.20615069, 0.19568177, 0.18574449, 0.17631186, 0.16735824, 0.15885931, 0.15079198, 0.14313433, 0.13586556, 0.12896592, 0.12241667, 0.11620000, 0.11029903, 0.10469773, 0.09938088, 0.09433404, 0.08954349, 0.08499621, 0.08067986, 0.07658271, 0.07269362, 0.06900203, 0.06549791, 0.06217174, 0.05901448, 0.05601756, 0.05317283, 0.05047256, 0.04790942, 0.04547644, 0.04316702, 0.04097487, 0.03889405, 0.03691890, 0.03504406, 0.03326442, 0.03157516, 0.02997168, 0.02844963, 0.02700488, 0.02563349, 0.02433175, 0.02309612, 0.02192323, 0.02080991, 0.01975312, 0.01875000 };
 
         double probLPS          = aStateToProbLPS[sbacGetState(contextModel[n].m_state)];
         double prob0, prob1;
@@ -942,7 +942,7 @@
 void TEncSbac::xCodeScalingList(TComScalingList* scalingList, uint32_t sizeId, uint32_t listId)
 {
     int coefNum = X265_MIN(MAX_MATRIX_COEF_NUM, (int)g_scalingListSize[sizeId]);
-    uint32_t* scan  = (sizeId == 0) ? g_sigLastScan[SCAN_DIAG][1] :  g_sigLastScanCG32x32;
+    const uint32_t* scan  = (sizeId == 0) ? g_sigLastScan[SCAN_DIAG][1] :  g_sigLastScanCG32x32;
     int nextCoef = SCALING_LIST_START_VALUE;
     int data;
     int32_t *src = scalingList->getScalingListAddress(sizeId, listId);
diff -r 21832083908f -r 3466fd21eb9e source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp	Wed Feb 12 17:39:50 2014 -0600
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Thu Feb 13 16:39:53 2014 +0900
@@ -2882,7 +2882,7 @@
     }
     else if ((cuMode == SIZE_2NxN || cuMode == SIZE_2NxnU) || cuMode == SIZE_2NxnD)
     {
-        uint32_t aauiMbBits[2][3][3] = { { { 0, 0, 3 }, { 0, 0, 0 }, { 0, 0, 0 } }, { { 5, 7, 7 }, { 7, 5, 7 }, { 9 - 3, 9 - 3, 9 - 3 } } };
+        static const uint32_t aauiMbBits[2][3][3] = { { { 0, 0, 3 }, { 0, 0, 0 }, { 0, 0, 0 } }, { { 5, 7, 7 }, { 7, 5, 7 }, { 9 - 3, 9 - 3, 9 - 3 } } };
         if (bPSlice)
         {
             blockBit[0] = 3;
@@ -2896,7 +2896,7 @@
     }
     else if ((cuMode == SIZE_Nx2N || cuMode == SIZE_nLx2N) || cuMode == SIZE_nRx2N)
     {
-        uint32_t aauiMbBits[2][3][3] = { { { 0, 2, 3 }, { 0, 0, 0 }, { 0, 0, 0 } }, { { 5, 7, 7 }, { 7 - 2, 7 - 2, 9 - 2 }, { 9 - 3, 9 - 3, 9 - 3 } } };
+        static const uint32_t aauiMbBits[2][3][3] = { { { 0, 2, 3 }, { 0, 0, 0 }, { 0, 0, 0 } }, { { 5, 7, 7 }, { 7 - 2, 7 - 2, 9 - 2 }, { 9 - 3, 9 - 3, 9 - 3 } } };
         if (bPSlice)
         {
             blockBit[0] = 3;
diff -r 21832083908f -r 3466fd21eb9e source/common/intrapred.cpp
--- a/source/common/intrapred.cpp	Wed Feb 12 17:39:50 2014 -0600
+++ b/source/common/intrapred.cpp	Thu Feb 13 16:39:53 2014 +0900
@@ -160,8 +160,8 @@
     int signAng        = intraPredAngle < 0 ? -1 : 1;
 
     // Set bitshifts and scale the angle parameter to block size
-    int angTable[9]    = { 0,    2,    5,   9,  13,  17,  21,  26,  32 };
-    int invAngTable[9] = { 0, 4096, 1638, 910, 630, 482, 390, 315, 256 }; // (256 * 32) / Angle
+    static const int angTable[9]    = { 0,    2,    5,   9,  13,  17,  21,  26,  32 };
+    static const int invAngTable[9] = { 0, 4096, 1638, 910, 630, 482, 390, 315, 256 }; // (256 * 32) / Angle
     int invAngle       = invAngTable[absAng];
 
     absAng             = angTable[absAng];
diff -r 21832083908f -r 3466fd21eb9e source/encoder/compress.cpp
--- a/source/encoder/compress.cpp	Wed Feb 12 17:39:50 2014 -0600
+++ b/source/encoder/compress.cpp	Thu Feb 13 16:39:53 2014 +0900
@@ -389,6 +389,8 @@
     {
         if (!bSliceEnd && bInsidePicture)
         {
+            static const uint32_t threshold[4] = { 20000, 6000, 1600, 500 };
+
             /* Initialise all Mode-CUs based on parentCU */
             if (depth == 0)
             {
@@ -418,7 +420,6 @@
                 earlyskip = (m_cfg->param.bEnableEarlySkip && m_bestMergeCU[depth]->isSkipped(0));
             else if (m_cfg->param.rdLevel == 1)
             {
-                uint32_t threshold[4] = { 20000, 6000, 1600, 500 };
                 int index = 4 - g_convertToBit[m_bestMergeCU[depth]->getWidth(0)];
                 if (m_bestMergeCU[depth]->m_totalDistortion < threshold[index])
                 {
@@ -435,7 +436,6 @@
             }
             else if (m_cfg->param.rdLevel == 0)
             {
-                uint32_t threshold[4] = { 20000, 6000, 1600, 500 };
                 int index = 4 - g_convertToBit[m_bestMergeCU[depth]->getWidth(0)];
                 if (m_bestMergeCU[depth]->m_totalDistortion < threshold[index])
                 {
@@ -521,7 +521,6 @@
                     }
                     else
                     {
-                        uint32_t threshold[4] = { 20000, 6000, 1600, 500 };
                         int index = 4 - g_convertToBit[outBestCU->getWidth(0)];
                         bdoIntra = (outBestCU->m_totalDistortion > threshold[index]);
                     }


More information about the x265-devel mailing list