[x265] [PATCH 4 of 6] reduce memory access to absCoeff[firstC2FlagIdx]

Min Chen chenm003 at 163.com
Tue Jun 9 20:06:04 CEST 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1433872873 25200
# Node ID 04c9567aa2bb7b549cd6a3514a1ef29d64724638
# Parent  d82b6f9e08e39b784ba8240e1843b9d6371dcee4
reduce memory access to absCoeff[firstC2FlagIdx]
---
 source/encoder/entropy.cpp |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff -r d82b6f9e08e3 -r 04c9567aa2bb source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp	Tue Jun 09 11:01:08 2015 -0700
+++ b/source/encoder/entropy.cpp	Tue Jun 09 11:01:13 2015 -0700
@@ -1699,28 +1699,29 @@
             uint8_t *baseCtxMod = bIsLuma ? &m_contextState[OFF_ONE_FLAG_CTX + 4 * ctxSet] : &m_contextState[OFF_ONE_FLAG_CTX + NUM_ONE_FLAG_CTX_LUMA + 4 * ctxSet];
 
             uint32_t numC1Flag = X265_MIN(numNonZero, C1FLAG_NUMBER);
-            int firstC2FlagIdx = -1;
+            int firstC2Flag = -1;
 
             X265_CHECK(numC1Flag > 0, "numC1Flag check failure\n");
             idx = 0;
             do
             {
-                uint32_t symbol = absCoeff[idx] > 1;
-                encodeBin(symbol, baseCtxMod[c1]);
+                uint32_t symbol1 = absCoeff[idx] > 1;
+                uint32_t symbol2 = absCoeff[idx] > 2;
+                encodeBin(symbol1, baseCtxMod[c1]);
 
                 // TODO: VC can't work fine on below style, but ICL can generate branch free code
 #ifdef __INTEL_COMPILER
                 if (symbol)
                     c1 = 0;
 
-                if ((firstC2FlagIdx < 0) & symbol)
-                    firstC2FlagIdx = (int)idx;
+                if ((firstC2Flag < 0) & symbol)
+                    firstC2Flag = (int)symbol2;
 #else
-                if (symbol)
+                if (symbol1)
                 {
                     c1 = 0;
-                    if (firstC2FlagIdx < 0)
-                        firstC2FlagIdx = (int)idx;
+                    if (firstC2Flag < 0)
+                        firstC2Flag = (int)symbol2;
                 }
 #endif
                 c1 += ((c1 >> 1) ^ c1) & 1;
@@ -1733,9 +1734,8 @@
             {
                 baseCtxMod = bIsLuma ? &m_contextState[OFF_ABS_FLAG_CTX + ctxSet] : &m_contextState[OFF_ABS_FLAG_CTX + NUM_ABS_FLAG_CTX_LUMA + ctxSet];
 
-                X265_CHECK((firstC2FlagIdx != -1), "firstC2FlagIdx check failure\n");
-                uint32_t symbol = absCoeff[firstC2FlagIdx] > 2;
-                encodeBin(symbol, baseCtxMod[0]);
+                X265_CHECK((firstC2Flag != -1), "firstC2FlagIdx check failure\n");
+                encodeBin(firstC2Flag, baseCtxMod[0]);
             }
 
             const int hiddenShift = (bHideFirstSign && signHidden) ? 1 : 0;



More information about the x265-devel mailing list