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

Min Chen chenm003 at 163.com
Wed Oct 7 00:55:14 CEST 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1444148057 18000
# Node ID 2ce4e12fa135e80b92845357567107fa58237d80
# Parent  0c7ff7c3e85053009cae137e3a46584af74fdbe4
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 0c7ff7c3e850 -r 2ce4e12fa135 source/common/quant.cpp
--- a/source/common/quant.cpp	Tue Oct 06 11:14:14 2015 -0500
+++ b/source/common/quant.cpp	Tue Oct 06 11:14:17 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 0c7ff7c3e850 -r 2ce4e12fa135 source/common/quant.h
--- a/source/common/quant.h	Tue Oct 06 11:14:14 2015 -0500
+++ b/source/common/quant.h	Tue Oct 06 11:14:17 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