[x265] [PATCH 2 of 8] reduce operators on goRiceParam and c1 update logic in rdoQuant()

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


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1443652336 18000
# Node ID fd5d57606bb724c7ece1073ee2d31b46b5bffba5
# Parent  e6e7afbd3b23b3692d8e83ec691d1bf124dc8ad1
reduce operators on goRiceParam and c1 update logic in rdoQuant()
---
 source/common/quant.cpp |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff -r e6e7afbd3b23 -r fd5d57606bb7 source/common/quant.cpp
--- a/source/common/quant.cpp	Wed Sep 30 17:32:14 2015 -0500
+++ b/source/common/quant.cpp	Wed Sep 30 17:32:16 2015 -0500
@@ -825,6 +825,7 @@
         uint32_t subFlagMask = coeffFlag[cgScanPos];
         int    c2            = 0;
         uint32_t goRiceParam = 0;
+        uint32_t levelThreshold = 3;
         uint32_t c1Idx       = 0;
         uint32_t c2Idx       = 0;
         /* iterate over coefficients in each group in reverse scan order */
@@ -1034,10 +1035,14 @@
                 }
 
                 /* Update CABAC estimation state */
-                if (level >= baseLevel && goRiceParam < 4 && level > (3U << goRiceParam))
+                if ((level >= baseLevel) && (goRiceParam < 4) && (level > levelThreshold))
+                {
                     goRiceParam++;
+                    levelThreshold <<= 1;
+                }
 
-                c1Idx -= (-(int32_t)level) >> 31;
+                const uint32_t isNonZero = (uint32_t)(-(int32_t)level) >> 31;
+                c1Idx += isNonZero;
 
                 /* update bin model */
                 if (level > 1)
@@ -1046,7 +1051,7 @@
                     c2 += (uint32_t)(c2 - 2) >> 31;
                     c2Idx++;
                 }
-                else if (((c1 == 1) | (c1 == 2)) && level)
+                else if (((c1 == 1) | (c1 == 2)) & isNonZero)
                     c1++;
 
                 if (dstCoeff[blkPos])



More information about the x265-devel mailing list