[x265] [PATCH 2 of 4] cabac: move static table to global space

Min Chen chenm003 at 163.com
Wed Oct 23 14:10:36 CEST 2013


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1382530117 -28800
# Node ID a4450449aed7c4fbfad373118bf3ed9465a8bec9
# Parent  43af41054e42de428294c663b8e487d030626c9f
cabac: move static table to global space

diff -r 43af41054e42 -r a4450449aed7 source/Lib/TLibCommon/ContextModel.cpp
--- a/source/Lib/TLibCommon/ContextModel.cpp	Wed Oct 23 20:08:17 2013 +0800
+++ b/source/Lib/TLibCommon/ContextModel.cpp	Wed Oct 23 20:08:37 2013 +0800
@@ -65,7 +65,7 @@
     m_state       = ((mpState ? (initState - 64) : (63 - initState)) << 1) + mpState;
 }
 
-const UChar ContextModel::s_nextStateMPS[128] =
+const UChar g_nextStateMPS[128] =
 {
     2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
     18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
@@ -77,7 +77,7 @@
     114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 124, 125, 126, 127
 };
 
-const UChar ContextModel::s_nextStateLPS[128] =
+const UChar g_nextStateLPS[128] =
 {
     1, 0, 0, 1, 2, 3, 4, 5, 4, 5, 8, 9, 8, 9, 10, 11,
     12, 13, 14, 15, 16, 17, 18, 19, 18, 19, 22, 23, 22, 23, 24, 25,
@@ -89,7 +89,7 @@
     72, 73, 72, 73, 74, 75, 74, 75, 74, 75, 76, 77, 76, 77, 126, 127
 };
 
-UChar ContextModel::m_nextState[128][2];
+UChar g_nextState[128][2];
 
 void ContextModel::buildNextStateTable()
 {
@@ -97,12 +97,12 @@
     {
         for (int j = 0; j < 2; j++)
         {
-            m_nextState[i][j] = ((i & 1) == j) ? s_nextStateMPS[i] : s_nextStateLPS[i];
+            g_nextState[i][j] = ((i & 1) == j) ? g_nextStateMPS[i] : g_nextStateLPS[i];
         }
     }
 }
 
-const int ContextModel::s_entropyBits[128] =
+const int g_entropyBits[128] =
 {
     // Corrected table, most notably for last state
     0x07b23, 0x085f9, 0x074a0, 0x08cbc, 0x06ee4, 0x09354, 0x067f4, 0x09c1b, 0x060b0, 0x0a62a, 0x05a9c, 0x0af5b, 0x0548d, 0x0b955, 0x04f56, 0x0c2a9,
diff -r 43af41054e42 -r a4450449aed7 source/Lib/TLibCommon/ContextModel.h
--- a/source/Lib/TLibCommon/ContextModel.h	Wed Oct 23 20:08:17 2013 +0800
+++ b/source/Lib/TLibCommon/ContextModel.h	Wed Oct 23 20:08:37 2013 +0800
@@ -43,6 +43,13 @@
 //! \ingroup TLibCommon
 //! \{
 
+using namespace x265;
+
+extern const UChar g_nextStateMPS[128];
+extern const UChar g_nextStateLPS[128];
+extern const int   g_entropyBits[128];
+extern       UChar g_nextState[128][2];
+
 namespace x265 {
 // private namespace
 
@@ -67,24 +74,24 @@
 
     void updateLPS()
     {
-        m_state = s_nextStateLPS[m_state];
+        m_state = g_nextStateLPS[m_state];
     }
 
     void updateMPS()
     {
-        m_state = s_nextStateMPS[m_state];
+        m_state = g_nextStateMPS[m_state];
     }
 
-    int getEntropyBits(UInt val) { return s_entropyBits[m_state ^ val]; }
-    int getEntropyBits(UInt state, UInt val) { return s_entropyBits[state ^ val]; }
+    int getEntropyBits(UInt val) { return g_entropyBits[m_state ^ val]; }
+    int getEntropyBits(UInt state, UInt val) { return g_entropyBits[state ^ val]; }
 
     void update(int binVal)
     {
-        m_state = m_nextState[m_state][binVal];
+        m_state = g_nextState[m_state][binVal];
     }
 
     static void buildNextStateTable();
-    static int getEntropyBitsTrm(int val) { return s_entropyBits[126 ^ val]; }
+    static int getEntropyBitsTrm(int val) { return g_entropyBits[126 ^ val]; }
 
     void setBinsCoded(UInt val)   { bBinsCoded = (UChar)val;  }
 
@@ -94,10 +101,6 @@
 
     UChar         m_state;  ///< internal state variable
     UChar         bBinsCoded;
-    static const UChar s_nextStateMPS[128];
-    static const UChar s_nextStateLPS[128];
-    static const int   s_entropyBits[128];
-    static UChar  m_nextState[128][2];
 };
 }
 //! \}



More information about the x265-devel mailing list