[x265] [PATCH 3 of 4] optimize: simplify operators on loop sigCoeffGroupFlag

Min Chen chenm003 at 163.com
Wed Mar 12 19:03:23 CET 2014


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1394647344 25200
# Node ID ad1470a0e17e48d3d198da09fb8b251b84c59614
# Parent  265ddf73f344ba41fdb885a8b40795b4fb453f48
optimize: simplify operators on loop sigCoeffGroupFlag

diff -r 265ddf73f344 -r ad1470a0e17e source/Lib/TLibEncoder/TEncSbac.cpp
--- a/source/Lib/TLibEncoder/TEncSbac.cpp	Wed Mar 12 11:01:32 2014 -0700
+++ b/source/Lib/TLibEncoder/TEncSbac.cpp	Wed Mar 12 11:02:24 2014 -0700
@@ -2092,15 +2092,18 @@
     uint32_t sigCoeffGroupFlag[MLS_GRP_NUM];
     uint32_t cgNum = 1 << codingParameters.log2TrSizeCG * 2;
     memset(sigCoeffGroupFlag, 0, sizeof(uint32_t) * cgNum);
+    const uint32_t maskPosXY = (1 << (log2TrSize - MLS_CG_LOG2_SIZE)) - 1;
     do
     {
         posLast = codingParameters.scan[++scanPosLast];
         if (coeff[posLast] != 0)
         {
             // get L1 sig map
-            uint32_t posy   = posLast >> log2TrSize;
-            uint32_t posx   = posLast - (posy << log2TrSize);
-            uint32_t blkIdx = ((posy >> MLS_CG_LOG2_SIZE) << codingParameters.log2TrSizeCG) + (posx >> MLS_CG_LOG2_SIZE);
+            // NOTE: the new algorithm is complicated, so I keep reference code here
+            //uint32_t posy   = posLast >> log2TrSize;
+            //uint32_t posx   = posLast - (posy << log2TrSize);
+            //uint32_t blkIdx0 = ((posy >> MLS_CG_LOG2_SIZE) << codingParameters.log2TrSizeCG) + (posx >> MLS_CG_LOG2_SIZE);
+            uint32_t blkIdx = ((posLast >> (2 * MLS_CG_LOG2_SIZE)) & ~maskPosXY) + ((posLast >> MLS_CG_LOG2_SIZE) & maskPosXY);
             sigCoeffGroupFlag[blkIdx] = 1;
 
             numSig--;



More information about the x265-devel mailing list