[x265] [PATCH 6 of 7] faster sign(X) and N^2 on TComTrQuant::xRateDistOptQuant

Min Chen chenm003 at 163.com
Mon Mar 24 20:00:43 CET 2014


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1395687590 25200
# Node ID 5d22c7cd7cd603a3481720dd2467865012e39d37
# Parent  d39b436d01f293e20fd51a5a53028166e50cee58
faster sign(X) and N^2 on TComTrQuant::xRateDistOptQuant

diff -r d39b436d01f2 -r 5d22c7cd7cd6 source/Lib/TLibCommon/TComTrQuant.cpp
--- a/source/Lib/TLibCommon/TComTrQuant.cpp	Mon Mar 24 11:59:32 2014 -0700
+++ b/source/Lib/TLibCommon/TComTrQuant.cpp	Mon Mar 24 11:59:50 2014 -0700
@@ -876,7 +876,8 @@
         absSum += level;
         if (level)
             *lastPos = blkPos;
-        dstCoeff[blkPos] = (srcCoeff[blkPos] < 0) ? -level : level;
+        uint32_t mask = (int32_t)srcCoeff[blkPos] >> 31;
+        dstCoeff[blkPos] = (level ^ mask) - mask;
     }
 
     //===== clean uncoded coefficients =====
@@ -895,7 +896,7 @@
         int tmpSum = 0;
         int n;
 
-        for (int subSet = (trSize * trSize - 1) >> LOG2_SCAN_SET_SIZE; subSet >= 0; subSet--)
+        for (int subSet = ((1 << (log2TrSize * 2)) - 1) >> LOG2_SCAN_SET_SIZE; subSet >= 0; subSet--)
         {
             int subPos = subSet << LOG2_SCAN_SET_SIZE;
             int firstNZPosInCG = SCAN_SET_SIZE, lastNZPosInCG = -1;



More information about the x265-devel mailing list