[x265] [PATCH 3 of 8] reduce shift operators in rdoQuant() since trSizeCG is constant

Min Chen chenm003 at 163.com
Thu Oct 1 02:48:43 CEST 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1443652339 18000
# Node ID 3a346ffd4f2c21d3385e3e722c513ae42c454a57
# Parent  fd5d57606bb724c7ece1073ee2d31b46b5bffba5
reduce shift operators in rdoQuant() since trSizeCG is constant
---
 source/common/quant.cpp |    2 +-
 source/common/quant.h   |    8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff -r fd5d57606bb7 -r 3a346ffd4f2c source/common/quant.cpp
--- a/source/common/quant.cpp	Wed Sep 30 17:32:16 2015 -0500
+++ b/source/common/quant.cpp	Wed Sep 30 17:32:19 2015 -0500
@@ -739,7 +739,7 @@
         uint32_t ctxSet = (cgScanPos && bIsLuma) ? 2 : 0;
         const uint32_t cgBlkPos = codeParams.scanCG[cgScanPos];
         const uint32_t cgPosY   = cgBlkPos >> log2TrSizeCG;
-        const uint32_t cgPosX   = cgBlkPos - (cgPosY << log2TrSizeCG);
+        const uint32_t cgPosX   = cgBlkPos & ((1 << log2TrSizeCG) - 1);
         const uint64_t cgBlkPosMask = ((uint64_t)1 << cgBlkPos);
         const int patternSigCtx = calcPatternSigCtx(sigCoeffGroupFlag64, cgPosX, cgPosY, cgBlkPos, cgStride);
         const int ctxSigOffset = codeParams.firstSignificanceMapContext + (cgScanPos && bIsLuma ? 3 : 0);
diff -r fd5d57606bb7 -r 3a346ffd4f2c source/common/quant.h
--- a/source/common/quant.h	Wed Sep 30 17:32:16 2015 -0500
+++ b/source/common/quant.h	Wed Sep 30 17:32:19 2015 -0500
@@ -126,8 +126,8 @@
         const uint32_t sigPos = (uint32_t)(sigCoeffGroupFlag64 >> (cgBlkPos + 1)); // just need lowest 7-bits valid
 
         // TODO: instruction BT is faster, but _bittest64 still generate instruction 'BT m, r' in VS2012
-        const uint32_t sigRight = ((uint32_t)(cgPosX - (trSizeCG - 1)) >> 31) & sigPos;
-        const uint32_t sigLower = ((uint32_t)(cgPosY - (trSizeCG - 1)) >> 31) & (sigPos >> (trSizeCG - 1));
+        const uint32_t sigRight = (cgPosX != (trSizeCG - 1)) & sigPos;
+        const uint32_t sigLower = (cgPosY != (trSizeCG - 1)) & (sigPos >> (trSizeCG - 1));
         return sigRight + sigLower * 2;
     }
 
@@ -137,8 +137,8 @@
         X265_CHECK(cgBlkPos < 64, "cgBlkPos is too large\n");
         // NOTE: unsafe shift operator, see NOTE in calcPatternSigCtx
         const uint32_t sigPos = (uint32_t)(cgGroupMask >> (cgBlkPos + 1)); // just need lowest 8-bits valid
-        const uint32_t sigRight = ((uint32_t)(cgPosX - (trSizeCG - 1)) >> 31) & sigPos;
-        const uint32_t sigLower = ((uint32_t)(cgPosY - (trSizeCG - 1)) >> 31) & (sigPos >> (trSizeCG - 1));
+        const uint32_t sigRight = (cgPosX != (trSizeCG - 1)) & sigPos;
+        const uint32_t sigLower = (cgPosY != (trSizeCG - 1)) & (sigPos >> (trSizeCG - 1));
 
         return (sigRight | sigLower);
     }



More information about the x265-devel mailing list