[x265] replace g_convertToBit[] to g_log2Size[] const table

Satoshi Nakagawa nakagawa424 at oki.com
Tue Aug 12 05:30:21 CEST 2014


# HG changeset patch
# User Satoshi Nakagawa <nakagawa424 at oki.com>
# Date 1407814080 -32400
#      Tue Aug 12 12:28:00 2014 +0900
# Node ID c0f00c662c5a255d093f3355e1c8dff123125137
# Parent  23d58a1819c7ab394db69f19926b68bce9e85bb4
replace g_convertToBit[] to g_log2Size[] const table

diff -r 23d58a1819c7 -r c0f00c662c5a source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Mon Aug 11 16:54:09 2014 -0700
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Tue Aug 12 12:28:00 2014 +0900
@@ -141,8 +141,8 @@
 
     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;
diff -r 23d58a1819c7 -r c0f00c662c5a source/Lib/TLibCommon/TComRom.cpp
--- a/source/Lib/TLibCommon/TComRom.cpp	Mon Aug 11 16:54:09 2014 -0700
+++ b/source/Lib/TLibCommon/TComRom.cpp	Tue Aug 12 12:28:00 2014 +0900
@@ -99,16 +99,6 @@
 {
     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()
@@ -300,7 +290,14 @@
 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
diff -r 23d58a1819c7 -r c0f00c662c5a source/Lib/TLibCommon/TComRom.h
--- a/source/Lib/TLibCommon/TComRom.h	Mon Aug 11 16:54:09 2014 -0700
+++ b/source/Lib/TLibCommon/TComRom.h	Tue Aug 12 12:28:00 2014 +0900
@@ -134,7 +134,7 @@
 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];
diff -r 23d58a1819c7 -r c0f00c662c5a source/common/param.cpp
--- a/source/common/param.cpp	Mon Aug 11 16:54:09 2014 -0700
+++ b/source/common/param.cpp	Tue Aug 12 12:28:00 2014 +0900
@@ -861,8 +861,8 @@
     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)
 
@@ -1041,7 +1041,8 @@
 
 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 */;
@@ -1058,7 +1059,7 @@
     {
         // 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;
diff -r 23d58a1819c7 -r c0f00c662c5a source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Mon Aug 11 16:54:09 2014 -0700
+++ b/source/encoder/encoder.cpp	Tue Aug 12 12:28:00 2014 +0900
@@ -1209,7 +1209,7 @@
 
     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)
@@ -1391,7 +1391,7 @@
     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)
     {


More information about the x265-devel mailing list