[x265] [PATCH] remove unneeded intermedia variant in coeff scan loop

Min Chen chenm003 at 163.com
Mon Feb 2 13:56:21 CET 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1422881775 -28800
# Node ID 40bf79cde6c6e5ea9dc84233fea210dc8ea2fa17
# Parent  6c5156500d6d4fa655acaf7a8b77f2ba3a0f794b
remove unneeded intermedia variant in coeff scan loop
---
 source/encoder/entropy.cpp |   15 +++------------
 1 files changed, 3 insertions(+), 12 deletions(-)

diff -r 6c5156500d6d -r 40bf79cde6c6 source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp	Fri Jan 30 11:54:22 2015 -0600
+++ b/source/encoder/entropy.cpp	Mon Feb 02 20:56:15 2015 +0800
@@ -1444,11 +1444,9 @@
     //const uint32_t maskPosXY = ((uint32_t)~0 >> (31 - log2TrSize + MLS_CG_LOG2_SIZE)) >> 1;
     X265_CHECK((uint32_t)((1 << (log2TrSize - MLS_CG_LOG2_SIZE)) - 1) == (((uint32_t)~0 >> (31 - log2TrSize + MLS_CG_LOG2_SIZE)) >> 1), "maskPosXY fault\n");
 
-    uint32_t cgBlkNum = 0;
     do
     {
-        const uint32_t cgBlkIdx = scanPosLast & (MLS_CG_BLK_SIZE - 1);
-        const uint32_t cgIdx = scanPosLast >> MLS_CG_SIZE;
+        const uint32_t cgIdx = (uint32_t)scanPosLast >> MLS_CG_SIZE;
 
         posLast = codingParameters.scan[scanPosLast++];
 
@@ -1464,16 +1462,9 @@
         numSig -= isNZCoeff;
 
         // TODO: optimize by instruction BTS
-        coeffSign[cgIdx] += (uint16_t)(((uint32_t)curCoeff >> 31) << cgBlkNum);
+        coeffSign[cgIdx] += (uint16_t)(((uint32_t)curCoeff >> 31) << coeffNum[cgIdx]);
         coeffFlag[cgIdx] = (coeffFlag[cgIdx] << 1) + (uint16_t)isNZCoeff;
-        cgBlkNum += isNZCoeff;
-        // TODO: reduce memory store operator, but avoid conditional branch
-        coeffNum[cgIdx] = (uint8_t)cgBlkNum;
-
-        if (cgBlkIdx == (MLS_CG_BLK_SIZE - 1))
-        {
-            cgBlkNum = 0;
-        }
+        coeffNum[cgIdx] += (uint8_t)isNZCoeff;
     }
     while (numSig > 0);
     scanPosLast--;



More information about the x265-devel mailing list