[x265] [PATCH] cleanup initCU()

Min Chen chenm003 at 163.com
Wed Jan 15 10:51:18 CET 2014


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1389779471 -28800
# Node ID cd3e896af13531bd27608bca2f90a4f720e13247
# Parent  7af141be0e7aa06f28802a3d75efbda760518126
cleanup initCU()

diff -r 7af141be0e7a -r cd3e896af135 source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Tue Jan 14 23:13:35 2014 -0600
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Wed Jan 15 17:51:11 2014 +0800
@@ -246,47 +246,45 @@
     }
 
     // CHECK_ME: why partStartIdx always negative
-    int partStartIdx = 0 - (cuAddr) * pic->getNumPartInCU();
-    int firstElement = std::max<int>(partStartIdx, 0);
-    int numElements = m_numPartitions - firstElement;
-
-    if (numElements > 0)
+    int numElements = m_numPartitions;
+    assert(numElements > 0);
+
     {
-        memset(m_skipFlag         + firstElement, false,                    numElements * sizeof(*m_skipFlag));
-        memset(m_predModes        + firstElement, MODE_NONE,                numElements * sizeof(*m_predModes));
-        memset(m_cuTransquantBypass + firstElement, false,                  numElements * sizeof(*m_cuTransquantBypass));
-        memset(m_depth            + firstElement, 0,                        numElements * sizeof(*m_depth));
-        memset(m_trIdx            + firstElement, 0,                        numElements * sizeof(*m_trIdx));
-        memset(m_transformSkip[0] + firstElement, 0,                        numElements * sizeof(*m_transformSkip[0]));
-        memset(m_transformSkip[1] + firstElement, 0,                        numElements * sizeof(*m_transformSkip[1]));
-        memset(m_transformSkip[2] + firstElement, 0,                        numElements * sizeof(*m_transformSkip[2]));
-        memset(m_width            + firstElement, g_maxCUWidth,             numElements * sizeof(*m_width));
-        memset(m_height           + firstElement, g_maxCUHeight,            numElements * sizeof(*m_height));
-        memset(m_qp               + firstElement, qp,                       numElements * sizeof(*m_qp));
-        memset(m_bMergeFlags      + firstElement, false,                    numElements * sizeof(*m_bMergeFlags));
-        memset(m_mergeIndex       + firstElement, 0,                        numElements * sizeof(*m_mergeIndex));
-        memset(m_lumaIntraDir     + firstElement, DC_IDX,                   numElements * sizeof(*m_lumaIntraDir));
-        memset(m_chromaIntraDir   + firstElement, 0,                        numElements * sizeof(*m_chromaIntraDir));
-        memset(m_interDir         + firstElement, 0,                        numElements * sizeof(*m_interDir));
-        memset(m_cbf[0]           + firstElement, 0,                        numElements * sizeof(*m_cbf[0]));
-        memset(m_cbf[1]           + firstElement, 0,                        numElements * sizeof(*m_cbf[1]));
-        memset(m_cbf[2]           + firstElement, 0,                        numElements * sizeof(*m_cbf[2]));
-        memset(m_iPCMFlags        + firstElement, false,                    numElements * sizeof(*m_iPCMFlags));
+        memset(m_skipFlag         , false,                    numElements * sizeof(*m_skipFlag));
+        memset(m_predModes        , MODE_NONE,                numElements * sizeof(*m_predModes));
+        memset(m_cuTransquantBypass, false,                   numElements * sizeof(*m_cuTransquantBypass));
+        memset(m_depth            , 0,                        numElements * sizeof(*m_depth));
+        memset(m_trIdx            , 0,                        numElements * sizeof(*m_trIdx));
+        memset(m_transformSkip[0] , 0,                        numElements * sizeof(*m_transformSkip[0]));
+        memset(m_transformSkip[1] , 0,                        numElements * sizeof(*m_transformSkip[1]));
+        memset(m_transformSkip[2] , 0,                        numElements * sizeof(*m_transformSkip[2]));
+        memset(m_width            , g_maxCUWidth,             numElements * sizeof(*m_width));
+        memset(m_height           , g_maxCUHeight,            numElements * sizeof(*m_height));
+        memset(m_qp               , qp,                       numElements * sizeof(*m_qp));
+        memset(m_bMergeFlags      , false,                    numElements * sizeof(*m_bMergeFlags));
+        memset(m_mergeIndex       , 0,                        numElements * sizeof(*m_mergeIndex));
+        memset(m_lumaIntraDir     , DC_IDX,                   numElements * sizeof(*m_lumaIntraDir));
+        memset(m_chromaIntraDir   , 0,                        numElements * sizeof(*m_chromaIntraDir));
+        memset(m_interDir         , 0,                        numElements * sizeof(*m_interDir));
+        memset(m_cbf[0]           , 0,                        numElements * sizeof(*m_cbf[0]));
+        memset(m_cbf[1]           , 0,                        numElements * sizeof(*m_cbf[1]));
+        memset(m_cbf[2]           , 0,                        numElements * sizeof(*m_cbf[2]));
+        memset(m_iPCMFlags        , false,                    numElements * sizeof(*m_iPCMFlags));
     }
 
     uint32_t y_tmp = g_maxCUWidth * g_maxCUHeight;
     uint32_t c_tmp = (g_maxCUWidth >> m_hChromaShift) * (g_maxCUHeight >> m_vChromaShift);
-    if (0 >= partStartIdx)
     {
         m_cuMvField[0].clearMvField();
         m_cuMvField[1].clearMvField();
-        memset(m_trCoeffY, 0, sizeof(TCoeff) * y_tmp);
-        memset(m_iPCMSampleY, 0, sizeof(Pel) * y_tmp);
-
-        memset(m_trCoeffCb, 0, sizeof(TCoeff) * c_tmp);
-        memset(m_trCoeffCr, 0, sizeof(TCoeff) * c_tmp);
-        memset(m_iPCMSampleCb, 0, sizeof(Pel) * c_tmp);
-        memset(m_iPCMSampleCr, 0, sizeof(Pel) * c_tmp);
+
+        // TODO: can be remove, but I haven't data to verify it, remove later
+        if (getSlice()->getSPS()->getUsePCM())
+        {
+            memset(m_iPCMSampleY, 0, sizeof(Pel) * y_tmp);
+            memset(m_iPCMSampleCb, 0, sizeof(Pel) * c_tmp);
+            memset(m_iPCMSampleCr, 0, sizeof(Pel) * c_tmp);
+        }
     }
 
     // Setting neighbor CU



More information about the x265-devel mailing list