[x265] [PATCH 1 of 4] cabac: imprvement by merge context status update path

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


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1382530097 -28800
# Node ID 43af41054e42de428294c663b8e487d030626c9f
# Parent  6d96d64c4e9a2c526b57274760a7147241328cb3
cabac: imprvement by merge context status update path

diff -r 6d96d64c4e9a -r 43af41054e42 source/Lib/TLibCommon/ContextModel.h
--- a/source/Lib/TLibCommon/ContextModel.h	Tue Oct 22 23:36:36 2013 +0530
+++ b/source/Lib/TLibCommon/ContextModel.h	Wed Oct 23 20:08:17 2013 +0800
@@ -76,6 +76,7 @@
     }
 
     int getEntropyBits(UInt val) { return s_entropyBits[m_state ^ val]; }
+    int getEntropyBits(UInt state, UInt val) { return s_entropyBits[state ^ val]; }
 
     void update(int binVal)
     {
@@ -89,7 +90,7 @@
 
     UInt getBinsCoded()           { return bBinsCoded;   }
 
-private:
+public:
 
     UChar         m_state;  ///< internal state variable
     UChar         bBinsCoded;
diff -r 6d96d64c4e9a -r 43af41054e42 source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp
--- a/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp	Tue Oct 22 23:36:36 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp	Wed Oct 23 20:08:17 2013 +0800
@@ -182,38 +182,40 @@
         DTRACE_CABAC_V(binValue)
         DTRACE_CABAC_T("\n")
     }
+
+    UInt mstate = ctxModel.m_state;
+    ctxModel.update(binValue);
+
     if (bIsCounter)
     {
-        m_fracBits += ctxModel.getEntropyBits(binValue);
-        ctxModel.update(binValue);
+        m_fracBits += ctxModel.getEntropyBits(mstate, binValue);
         return;
     }
     ctxModel.setBinsCoded(1);
 
-    UInt lps = g_lpsTable[ctxModel.getState()][(m_range >> 6) & 3];
+    // TODO: Sync encode proto of cabac status
+    UInt mps = mstate & 1;
+    UInt state = mstate >> 1;
+    UInt lps = g_lpsTable[state][(m_range >> 6) & 3];
     m_range -= lps;
 
-    if (binValue != ctxModel.getMps())
+    int numBits = g_renormTable[lps >> 3];
+    if (binValue != mps)
     {
-        int numBits = g_renormTable[lps >> 3];
         m_low     = (m_low + m_range) << numBits;
         m_range   = lps << numBits;
-        ctxModel.updateLPS();
-
-        m_bitsLeft += numBits;
     }
     else
     {
-        ctxModel.updateMPS();
         if (m_range >= 256)
         {
             return;
         }
-
+        numBits = 1;
         m_low <<= 1;
         m_range <<= 1;
-        m_bitsLeft++;
     }
+    m_bitsLeft += numBits;
 
     testAndWriteOut();
 }



More information about the x265-devel mailing list