Commits

Anonymous committed 945e071

replace g_convertToBit[] to g_log2Size[] const table

Comments (0)

Files changed (5)

source/Lib/TLibCommon/TComDataCU.cpp

 
     uint32_t tmp = 4 * AMVP_DECIMATION_FACTOR / unitSize;
     tmp = tmp * tmp;
-    X265_CHECK(tmp == (1 << (g_convertToBit[tmp] + 2)), "unexpected pixel count\n");
-    tmp = g_convertToBit[tmp] + 2;
+    X265_CHECK(tmp == (1 << (g_log2Size[tmp])), "unexpected pixel count\n");
+    tmp = g_log2Size[tmp];
     m_unitMask = ~((1 << tmp) - 1);
 
     uint32_t sizeL = cuSize * cuSize;

source/Lib/TLibCommon/TComRom.cpp

 {
     if (ATOMIC_CAS32(&initialized, 0, 1) == 1)
         return;
-
-    int i, c;
-
-    memset(g_convertToBit, -1, sizeof(g_convertToBit));
-    c = 0;
-    for (i = 4; i <= MAX_CU_SIZE; i *= 2)
-    {
-        g_convertToBit[i] = c;
-        c++;
-    }
 }
 
 void destroyROM()
 const uint8_t g_chroma422IntraAngleMappingTable[36] =
 { 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20, 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31, DM_CHROMA_IDX };
 
-uint8_t g_convertToBit[MAX_CU_SIZE + 1];
+const uint8_t g_log2Size[MAX_CU_SIZE + 1] =
+{
+    0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
+    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+    6
+};
 
 // ====================================================================================================================
 // Scanning order & context model mapping

source/Lib/TLibCommon/TComRom.h

 extern const uint8_t g_minInGroup[10];
 extern const uint8_t g_goRiceRange[5]; // maximum value coded with Rice codes
 
-extern uint8_t g_convertToBit[MAX_CU_SIZE + 1]; // from width to log2(width)-2
+extern const uint8_t g_log2Size[MAX_CU_SIZE + 1]; // from size to log2(size)
 
 // Map Luma samples to chroma samples
 extern const int g_winUnitX[MAX_CHROMA_FORMAT_IDC + 1];

source/common/param.cpp

     if (check_failed == 1)
         return check_failed;
 
-    uint32_t maxCUDepth = (uint32_t)g_convertToBit[param->maxCUSize];
-    uint32_t maxLog2CUSize = maxCUDepth + 2;
+    uint32_t maxLog2CUSize = (uint32_t)g_log2Size[param->maxCUSize];
+    uint32_t maxCUDepth = maxLog2CUSize - 2;
     uint32_t tuQTMaxLog2Size = maxLog2CUSize - 1;
     uint32_t tuQTMinLog2Size = 2; //log2(4)
 
 
 int x265_set_globals(x265_param *param)
 {
-    uint32_t maxCUDepth = (uint32_t)g_convertToBit[param->maxCUSize];
+    uint32_t maxLog2CUSize = (uint32_t)g_log2Size[param->maxCUSize];
+    uint32_t maxCUDepth = maxLog2CUSize - 2;
     uint32_t tuQTMinLog2Size = 2; //log2(4)
 
     static int once /* = 0 */;
     {
         // set max CU width & height
         g_maxCUSize = param->maxCUSize;
-        g_maxLog2CUSize = maxCUDepth + 2;
+        g_maxLog2CUSize = maxLog2CUSize;
 
         // compute actual CU depth with respect to config depth and max transform size
         g_addCUDepth = g_maxLog2CUSize - maxCUDepth - tuQTMinLog2Size;

source/encoder/encoder.cpp

 
     setThreadPool(ThreadPool::allocThreadPool(p->poolNumThreads));
     int poolThreadCount = ThreadPool::getThreadPool()->getThreadCount();
-    uint32_t maxLog2CUSize = g_convertToBit[p->maxCUSize] + 2;
+    uint32_t maxLog2CUSize = g_log2Size[p->maxCUSize];
     int rows = (p->sourceHeight + p->maxCUSize - 1) >> maxLog2CUSize;
 
     if (p->frameNumThreads == 0)
     m_conformanceWindow.leftOffset = 0;
 
     //======== set pad size if width is not multiple of the minimum CU size =========
-    uint32_t maxCUDepth = (uint32_t)g_convertToBit[p->maxCUSize];
+    uint32_t maxCUDepth = maxLog2CUSize - 2;
     uint32_t minCUDepth = (p->maxCUSize >> (maxCUDepth - 1));
     if ((p->sourceWidth % minCUDepth) != 0)
     {