[x265] [PATCH 2 of 5] convert for_loop to do_while in codeCoeffNxN(), because all of scanPosSigOff positive now

Min Chen chenm003 at 163.com
Tue May 12 01:42:24 CEST 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1431386742 25200
# Node ID dae597424faeb2955f85d6af8f10cfde1df781c9
# Parent  278b3fbc397fc02049145156997a5217bb902083
convert for_loop to do_while in codeCoeffNxN(), because all of scanPosSigOff positive now
---
 source/encoder/entropy.cpp |   32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)

diff -r 278b3fbc397f -r dae597424fae source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp	Mon May 11 16:25:39 2015 -0700
+++ b/source/encoder/entropy.cpp	Mon May 11 16:25:42 2015 -0700
@@ -1520,7 +1520,7 @@
     uint32_t c1 = 1;
     int scanPosSigOff = scanPosLast - (lastScanSet << MLS_CG_SIZE) - 1;
     int absCoeff[1 << MLS_CG_SIZE];
-    int numNonZero = 1;
+    uint32_t numNonZero = 1;
     unsigned long lastNZPosInCG;
     unsigned long firstNZPosInCG;
 
@@ -1617,9 +1617,9 @@
             {
                 if (log2TrSize == 2)
                 {
-                    uint32_t blkPos, sig, ctxSig;
-                    for (; scanPosSigOff >= 0; scanPosSigOff--)
+                    do
                     {
+                        uint32_t blkPos, sig, ctxSig;
                         blkPos = g_scan4x4[codingParameters.scanType][scanPosSigOff];
                         sig     = scanFlagMask & 1;
                         scanFlagMask >>= 1;
@@ -1631,17 +1631,18 @@
                         }
                         absCoeff[numNonZero] = tmpCoeff[blkPos];
                         numNonZero += sig;
+                        scanPosSigOff--;
                     }
+                    while(scanPosSigOff >= 0);
                 }
                 else
                 {
                     X265_CHECK((log2TrSize > 2), "log2TrSize must be more than 2 in this path!\n");
 
                     const uint8_t *tabSigCtx = table_cnt[(uint32_t)patternSigCtx];
-
-                    uint32_t blkPos, sig, ctxSig;
-                    for (; scanPosSigOff >= 0; scanPosSigOff--)
+                    do
                     {
+                        uint32_t blkPos, sig, ctxSig;
                         blkPos = g_scan4x4[codingParameters.scanType][scanPosSigOff];
                         const uint32_t posZeroMask = (subPosBase + scanPosSigOff) ? ~0 : 0;
                         sig     = scanFlagMask & 1;
@@ -1657,7 +1658,9 @@
                         }
                         absCoeff[numNonZero] = tmpCoeff[blkPos];
                         numNonZero += sig;
+                        scanPosSigOff--;
                     }
+                    while(scanPosSigOff >= 0);
                 }
             }
             else // fast RD path
@@ -1666,9 +1669,9 @@
                 uint32_t sum = 0;
                 if (log2TrSize == 2)
                 {
-                    uint32_t blkPos, sig, ctxSig;
-                    for (; scanPosSigOff >= 0; scanPosSigOff--)
+                    do
                     {
+                        uint32_t blkPos, sig, ctxSig;
                         blkPos = g_scan4x4[codingParameters.scanType][scanPosSigOff];
                         sig     = scanFlagMask & 1;
                         scanFlagMask >>= 1;
@@ -1690,17 +1693,18 @@
                         }
                         absCoeff[numNonZero] = tmpCoeff[blkPos];
                         numNonZero += sig;
+                        scanPosSigOff--;
                     }
+                    while(scanPosSigOff >= 0);
                 } // end of 4x4
                 else
                 {
                     X265_CHECK((log2TrSize > 2), "log2TrSize must be more than 2 in this path!\n");
 
                     const uint8_t *tabSigCtx = table_cnt[(uint32_t)patternSigCtx];
-
-                    uint32_t blkPos, sig, ctxSig;
-                    for (; scanPosSigOff >= 0; scanPosSigOff--)
+                    do
                     {
+                        uint32_t blkPos, sig, ctxSig;
                         blkPos = g_scan4x4[codingParameters.scanType][scanPosSigOff];
                         const uint32_t posZeroMask = (subPosBase + scanPosSigOff) ? ~0 : 0;
                         sig     = scanFlagMask & 1;
@@ -1726,7 +1730,9 @@
                         }
                         absCoeff[numNonZero] = tmpCoeff[blkPos];
                         numNonZero += sig;
+                        scanPosSigOff--;
                     }
+                    while(scanPosSigOff >= 0);
                 } // end of non 4x4 path
                 sum &= 0xFFFFFF;
 
@@ -1791,7 +1797,7 @@
                 if (!m_bitIf)
                 {
                     // FastRd path
-                    for (int idx = 0; idx < numNonZero; idx++)
+                    for (int idx = 0; idx < (int)numNonZero; idx++)
                     {
                         int baseLevel = (baseLevelN & 3) | firstCoeff2;
                         X265_CHECK(baseLevel == ((idx < C1FLAG_NUMBER) ? (2 + firstCoeff2) : 1), "baseLevel check failurr\n");
@@ -1828,7 +1834,7 @@
                 else
                 {
                     // Standard path
-                    for (int idx = 0; idx < numNonZero; idx++)
+                    for (int idx = 0; idx < (int)numNonZero; idx++)
                     {
                         int baseLevel = (baseLevelN & 3) | firstCoeff2;
                         X265_CHECK(baseLevel == ((idx < C1FLAG_NUMBER) ? (2 + firstCoeff2) : 1), "baseLevel check failurr\n");



More information about the x265-devel mailing list