[x265] [PATCH] TEncCU:fix for memory leak

ashok at multicorewareinc.com ashok at multicorewareinc.com
Mon Jun 23 16:12:22 CEST 2014


# HG changeset patch
# User Ashok Kumar Mishra<ashok at multicorewareinc.com>
# Date 1403520102 -19800
#      Mon Jun 23 16:11:42 2014 +0530
# Node ID 25a1b89a8efbacd0bcaf1eb6cfd16880ffd74ee5
# Parent  b5fbe9e2a10ab03b433de42edd8d77976d42df51
TEncCU:fix for memory leak

diff -r b5fbe9e2a10a -r 25a1b89a8efb source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Fri Jun 20 15:17:49 2014 +0530
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Mon Jun 23 16:11:42 2014 +0530
@@ -106,33 +106,31 @@
 {
     bool ok = true;
 
-    m_DataCUMemPool = new DataCUMemPool;
-
     ok &= m_cuMvFieldMemPool.initialize(numPartition, numBlocks);
 
-    CHECKED_MALLOC(m_DataCUMemPool->qpMemBlock, char,  numPartition * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.qpMemBlock, char,  numPartition * numBlocks);
 
-    CHECKED_MALLOC(m_DataCUMemPool->depthMemBlock, uint8_t, numPartition * numBlocks);
-    CHECKED_MALLOC(m_DataCUMemPool->cuSizeMemBlock, uint8_t, numPartition * numBlocks);
-    CHECKED_MALLOC(m_DataCUMemPool->skipFlagMemBlock, bool, numPartition * numBlocks);
-    CHECKED_MALLOC(m_DataCUMemPool->partSizeMemBlock, char, numPartition * numBlocks);
-    CHECKED_MALLOC(m_DataCUMemPool->predModeMemBlock, char, numPartition * numBlocks);
-    CHECKED_MALLOC(m_DataCUMemPool->cuTQBypassMemBlock, bool, numPartition * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.depthMemBlock, uint8_t, numPartition * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.cuSizeMemBlock, uint8_t, numPartition * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.skipFlagMemBlock, bool, numPartition * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.partSizeMemBlock, char, numPartition * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.predModeMemBlock, char, numPartition * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.cuTQBypassMemBlock, bool, numPartition * numBlocks);
 
-    CHECKED_MALLOC(m_DataCUMemPool->mergeFlagMemBlock, bool,  numPartition * numBlocks);
-    CHECKED_MALLOC(m_DataCUMemPool->lumaIntraDirMemBlock, uint8_t, numPartition * numBlocks);
-    CHECKED_MALLOC(m_DataCUMemPool->chromaIntraDirMemBlock, uint8_t, numPartition * numBlocks);
-    CHECKED_MALLOC(m_DataCUMemPool->interDirMemBlock, uint8_t, numPartition * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.mergeFlagMemBlock, bool,  numPartition * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.lumaIntraDirMemBlock, uint8_t, numPartition * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.chromaIntraDirMemBlock, uint8_t, numPartition * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.interDirMemBlock, uint8_t, numPartition * numBlocks);
 
-    CHECKED_MALLOC(m_DataCUMemPool->trIdxMemBlock, uint8_t, numPartition * numBlocks);
-    CHECKED_MALLOC(m_DataCUMemPool->transformSkipMemBlock, uint8_t, numPartition * 3 * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.trIdxMemBlock, uint8_t, numPartition * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.transformSkipMemBlock, uint8_t, numPartition * 3 * numBlocks);
 
-    CHECKED_MALLOC(m_DataCUMemPool->cbfMemBlock, uint8_t, numPartition * 3 * numBlocks);
-    CHECKED_MALLOC(m_DataCUMemPool->mvpIdxMemBlock, uint8_t, numPartition * 2 * numBlocks);
-    CHECKED_MALLOC(m_DataCUMemPool->trCoeffMemBlock, coeff_t, (sizeL + sizeC * 2) * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.cbfMemBlock, uint8_t, numPartition * 3 * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.mvpIdxMemBlock, uint8_t, numPartition * 2 * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.trCoeffMemBlock, coeff_t, (sizeL + sizeC * 2) * numBlocks);
 
-    CHECKED_MALLOC(m_DataCUMemPool->iPCMFlagMemBlock, bool, numPartition * numBlocks);
-    CHECKED_MALLOC(m_DataCUMemPool->iPCMSampleYMemBlock, pixel, (sizeL + sizeC * 2) * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.iPCMFlagMemBlock, bool, numPartition * numBlocks);
+    CHECKED_MALLOC(m_DataCUMemPool.iPCMSampleYMemBlock, pixel, (sizeL + sizeC * 2) * numBlocks);
 
     return ok;
 
@@ -160,40 +158,40 @@
     uint32_t sizeL = cuSize * cuSize;
     uint32_t sizeC = sizeL >> (m_hChromaShift + m_vChromaShift);
 
-    m_cuMvField[0].create(cu->m_cuMvFieldMemPool, numPartition, index, 0);
-    m_cuMvField[1].create(cu->m_cuMvFieldMemPool, numPartition, index, 1);
+    m_cuMvField[0].create(&cu->m_cuMvFieldMemPool, numPartition, index, 0);
+    m_cuMvField[1].create(&cu->m_cuMvFieldMemPool, numPartition, index, 1);
 
-    m_qp                 = cu->m_DataCUMemPool->qpMemBlock             + index * numPartition;
-    m_depth              = cu->m_DataCUMemPool->depthMemBlock          + index * numPartition;
-    m_cuSize             = cu->m_DataCUMemPool->cuSizeMemBlock         + index * numPartition;
-    m_skipFlag           = cu->m_DataCUMemPool->skipFlagMemBlock       + index * numPartition;
-    m_partSizes          = cu->m_DataCUMemPool->partSizeMemBlock       + index * numPartition;
-    m_predModes          = cu->m_DataCUMemPool->predModeMemBlock       + index * numPartition;
-    m_cuTransquantBypass = cu->m_DataCUMemPool->cuTQBypassMemBlock     + index * numPartition;
+    m_qp                 = cu->m_DataCUMemPool.qpMemBlock             + index * numPartition;
+    m_depth              = cu->m_DataCUMemPool.depthMemBlock          + index * numPartition;
+    m_cuSize             = cu->m_DataCUMemPool.cuSizeMemBlock         + index * numPartition;
+    m_skipFlag           = cu->m_DataCUMemPool.skipFlagMemBlock       + index * numPartition;
+    m_partSizes          = cu->m_DataCUMemPool.partSizeMemBlock       + index * numPartition;
+    m_predModes          = cu->m_DataCUMemPool.predModeMemBlock       + index * numPartition;
+    m_cuTransquantBypass = cu->m_DataCUMemPool.cuTQBypassMemBlock     + index * numPartition;
 
-    m_bMergeFlags        = cu->m_DataCUMemPool->mergeFlagMemBlock      + index * numPartition;
-    m_lumaIntraDir       = cu->m_DataCUMemPool->lumaIntraDirMemBlock   + index * numPartition;
-    m_chromaIntraDir     = cu->m_DataCUMemPool->chromaIntraDirMemBlock + index * numPartition;
-    m_interDir           = cu->m_DataCUMemPool->interDirMemBlock       + index * numPartition;
+    m_bMergeFlags        = cu->m_DataCUMemPool.mergeFlagMemBlock      + index * numPartition;
+    m_lumaIntraDir       = cu->m_DataCUMemPool.lumaIntraDirMemBlock   + index * numPartition;
+    m_chromaIntraDir     = cu->m_DataCUMemPool.chromaIntraDirMemBlock + index * numPartition;
+    m_interDir           = cu->m_DataCUMemPool.interDirMemBlock       + index * numPartition;
 
-    m_trIdx              = cu->m_DataCUMemPool->trIdxMemBlock          + index * numPartition;
-    m_transformSkip[0]   = cu->m_DataCUMemPool->transformSkipMemBlock  + index * numPartition * 3;
+    m_trIdx              = cu->m_DataCUMemPool.trIdxMemBlock          + index * numPartition;
+    m_transformSkip[0]   = cu->m_DataCUMemPool.transformSkipMemBlock  + index * numPartition * 3;
     m_transformSkip[1]   = m_transformSkip[0]                          + numPartition;
     m_transformSkip[2]   = m_transformSkip[0]                          + numPartition * 2;
 
-    m_cbf[0]             = cu->m_DataCUMemPool->cbfMemBlock            + index * numPartition * 3;
+    m_cbf[0]             = cu->m_DataCUMemPool.cbfMemBlock            + index * numPartition * 3;
     m_cbf[1]             = m_cbf[0]                                    + numPartition;
     m_cbf[2]             = m_cbf[0]                                    + numPartition * 2;
 
-    m_mvpIdx[0]          = cu->m_DataCUMemPool->mvpIdxMemBlock         + index * numPartition * 2;
+    m_mvpIdx[0]          = cu->m_DataCUMemPool.mvpIdxMemBlock         + index * numPartition * 2;
     m_mvpIdx[1]          = m_mvpIdx[0]                                 + numPartition;
 
-    m_trCoeff[0]         = cu->m_DataCUMemPool->trCoeffMemBlock        + index * (sizeL + sizeC * 2);
+    m_trCoeff[0]         = cu->m_DataCUMemPool.trCoeffMemBlock        + index * (sizeL + sizeC * 2);
     m_trCoeff[1]         = m_trCoeff[0]                                + sizeL;
     m_trCoeff[2]         = m_trCoeff[0]                                + sizeL + sizeC;
 
-    m_iPCMFlags          = cu->m_DataCUMemPool->iPCMFlagMemBlock       + index * numPartition;
-    m_iPCMSampleY        = cu->m_DataCUMemPool->iPCMSampleYMemBlock    + index * (sizeL + sizeC * 2);
+    m_iPCMFlags          = cu->m_DataCUMemPool.iPCMFlagMemBlock       + index * numPartition;
+    m_iPCMSampleY        = cu->m_DataCUMemPool.iPCMSampleYMemBlock    + index * (sizeL + sizeC * 2);
     m_iPCMSampleCb       = m_iPCMSampleY                               + sizeL;
     m_iPCMSampleCr       = m_iPCMSampleY                               + sizeL + sizeC;
 
@@ -202,26 +200,24 @@
 
 void TComDataCU::destroy()
 {
-    X265_FREE(m_DataCUMemPool->qpMemBlock);
-    X265_FREE(m_DataCUMemPool->depthMemBlock);
-    X265_FREE(m_DataCUMemPool->cuSizeMemBlock);
-    X265_FREE(m_DataCUMemPool->cbfMemBlock);
-    X265_FREE(m_DataCUMemPool->interDirMemBlock);
-    X265_FREE(m_DataCUMemPool->mergeFlagMemBlock);
-    X265_FREE(m_DataCUMemPool->lumaIntraDirMemBlock);
-    X265_FREE(m_DataCUMemPool->chromaIntraDirMemBlock);
-    X265_FREE(m_DataCUMemPool->trIdxMemBlock);
-    X265_FREE(m_DataCUMemPool->transformSkipMemBlock);
-    X265_FREE(m_DataCUMemPool->trCoeffMemBlock);
-    X265_FREE(m_DataCUMemPool->iPCMFlagMemBlock);
-    X265_FREE(m_DataCUMemPool->iPCMSampleYMemBlock);
-    X265_FREE(m_DataCUMemPool->mvpIdxMemBlock);
-    X265_FREE(m_DataCUMemPool->cuTQBypassMemBlock);
-    X265_FREE(m_DataCUMemPool->skipFlagMemBlock);
-    X265_FREE(m_DataCUMemPool->partSizeMemBlock);
-    X265_FREE(m_DataCUMemPool->predModeMemBlock);
-
-    delete m_DataCUMemPool;
+    X265_FREE(m_DataCUMemPool.qpMemBlock);
+    X265_FREE(m_DataCUMemPool.depthMemBlock);
+    X265_FREE(m_DataCUMemPool.cuSizeMemBlock);
+    X265_FREE(m_DataCUMemPool.cbfMemBlock);
+    X265_FREE(m_DataCUMemPool.interDirMemBlock);
+    X265_FREE(m_DataCUMemPool.mergeFlagMemBlock);
+    X265_FREE(m_DataCUMemPool.lumaIntraDirMemBlock);
+    X265_FREE(m_DataCUMemPool.chromaIntraDirMemBlock);
+    X265_FREE(m_DataCUMemPool.trIdxMemBlock);
+    X265_FREE(m_DataCUMemPool.transformSkipMemBlock);
+    X265_FREE(m_DataCUMemPool.trCoeffMemBlock);
+    X265_FREE(m_DataCUMemPool.iPCMFlagMemBlock);
+    X265_FREE(m_DataCUMemPool.iPCMSampleYMemBlock);
+    X265_FREE(m_DataCUMemPool.mvpIdxMemBlock);
+    X265_FREE(m_DataCUMemPool.cuTQBypassMemBlock);
+    X265_FREE(m_DataCUMemPool.skipFlagMemBlock);
+    X265_FREE(m_DataCUMemPool.partSizeMemBlock);
+    X265_FREE(m_DataCUMemPool.predModeMemBlock);
 
     m_cuMvFieldMemPool.destroy();
 }
diff -r b5fbe9e2a10a -r 25a1b89a8efb source/Lib/TLibCommon/TComDataCU.h
--- a/source/Lib/TLibCommon/TComDataCU.h	Fri Jun 20 15:17:49 2014 +0530
+++ b/source/Lib/TLibCommon/TComDataCU.h	Mon Jun 23 16:11:42 2014 +0530
@@ -169,7 +169,7 @@
     // misc. variables
     // -------------------------------------------------------------------------------------------------------------------
 
-    DataCUMemPool *m_DataCUMemPool;
+    DataCUMemPool m_DataCUMemPool;
     TComCUMvField m_cuMvFieldMemPool;
 
 protected:
diff -r b5fbe9e2a10a -r 25a1b89a8efb source/Lib/TLibCommon/TComMotionInfo.cpp
--- a/source/Lib/TLibCommon/TComMotionInfo.cpp	Fri Jun 20 15:17:49 2014 +0530
+++ b/source/Lib/TLibCommon/TComMotionInfo.cpp	Mon Jun 23 16:11:42 2014 +0530
@@ -53,11 +53,9 @@
 
 bool TComCUMvField::initialize(uint32_t numPartition, uint32_t numBlocks)
 {
-    m_MVFieldMemPool = new MVFieldMemPool;
-
-    CHECKED_MALLOC(m_MVFieldMemPool->m_mvMemBlock,     MV,   numPartition * 2 * numBlocks);
-    CHECKED_MALLOC(m_MVFieldMemPool->m_mvdMemBlock,    MV,   numPartition * 2 * numBlocks);
-    CHECKED_MALLOC(m_MVFieldMemPool->m_refIdxMemBlock, char, numPartition * 2 * numBlocks);
+    CHECKED_MALLOC(m_MVFieldMemPool.m_mvMemBlock,     MV,   numPartition * 2 * numBlocks);
+    CHECKED_MALLOC(m_MVFieldMemPool.m_mvdMemBlock,    MV,   numPartition * 2 * numBlocks);
+    CHECKED_MALLOC(m_MVFieldMemPool.m_refIdxMemBlock, char, numPartition * 2 * numBlocks);
 
     return true;
 
@@ -65,26 +63,24 @@
     return false;
 }
 
-void TComCUMvField::create(TComCUMvField p, uint32_t numPartition, int index, int idx)
+void TComCUMvField::create(TComCUMvField *p, uint32_t numPartition, int index, int idx)
 {
-    m_mv     = p.m_MVFieldMemPool->m_mvMemBlock     + (index * 2 + idx) * numPartition;
-    m_mvd    = p.m_MVFieldMemPool->m_mvdMemBlock    + (index * 2 + idx) * numPartition;
-    m_refIdx = p.m_MVFieldMemPool->m_refIdxMemBlock + (index * 2 + idx) * numPartition;
+    m_mv     = p->m_MVFieldMemPool.m_mvMemBlock     + (index * 2 + idx) * numPartition;
+    m_mvd    = p->m_MVFieldMemPool.m_mvdMemBlock    + (index * 2 + idx) * numPartition;
+    m_refIdx = p->m_MVFieldMemPool.m_refIdxMemBlock + (index * 2 + idx) * numPartition;
 
     m_numPartitions = numPartition;
 }
 
 void TComCUMvField::destroy()
 {
-    X265_FREE(m_MVFieldMemPool->m_mvMemBlock);
-    X265_FREE(m_MVFieldMemPool->m_mvdMemBlock);
-    X265_FREE(m_MVFieldMemPool->m_refIdxMemBlock);
+    X265_FREE(m_MVFieldMemPool.m_mvMemBlock);
+    X265_FREE(m_MVFieldMemPool.m_mvdMemBlock);
+    X265_FREE(m_MVFieldMemPool.m_refIdxMemBlock);
 
-    m_MVFieldMemPool->m_mvMemBlock     = NULL;
-    m_MVFieldMemPool->m_mvdMemBlock    = NULL;
-    m_MVFieldMemPool->m_refIdxMemBlock = NULL;
-
-    delete m_MVFieldMemPool;
+    m_MVFieldMemPool.m_mvMemBlock     = NULL;
+    m_MVFieldMemPool.m_mvdMemBlock    = NULL;
+    m_MVFieldMemPool.m_refIdxMemBlock = NULL;
 
     m_numPartitions = 0;
 }
diff -r b5fbe9e2a10a -r 25a1b89a8efb source/Lib/TLibCommon/TComMotionInfo.h
--- a/source/Lib/TLibCommon/TComMotionInfo.h	Fri Jun 20 15:17:49 2014 +0530
+++ b/source/Lib/TLibCommon/TComMotionInfo.h	Mon Jun 23 16:11:42 2014 +0530
@@ -108,10 +108,10 @@
     // initialize / create / destroy
     // ------------------------------------------------------------------------------------------------------------------
 
-    MVFieldMemPool *m_MVFieldMemPool;
+    MVFieldMemPool m_MVFieldMemPool;
 
     bool initialize(uint32_t numPartition, uint32_t numBlocks);
-    void create(TComCUMvField p, uint32_t numPartition, int index, int idx);
+    void create(TComCUMvField *p, uint32_t numPartition, int index, int idx);
     void destroy();
 
     // ------------------------------------------------------------------------------------------------------------------
diff -r b5fbe9e2a10a -r 25a1b89a8efb source/Lib/TLibCommon/TComPicSym.cpp
--- a/source/Lib/TLibCommon/TComPicSym.cpp	Fri Jun 20 15:17:49 2014 +0530
+++ b/source/Lib/TLibCommon/TComPicSym.cpp	Mon Jun 23 16:11:42 2014 +0530
@@ -99,6 +99,11 @@
     delete m_slice;
     m_slice = NULL;
 
+    for (int i = 0; i < m_numCUsInFrame; i++)
+    {
+        m_cuData[i].destroy();
+    }
+
     delete [] m_cuData;
     m_cuData = NULL;
 
diff -r b5fbe9e2a10a -r 25a1b89a8efb source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp	Fri Jun 20 15:17:49 2014 +0530
+++ b/source/Lib/TLibEncoder/TEncCu.cpp	Mon Jun 23 16:11:42 2014 +0530
@@ -111,43 +111,42 @@
     int unitSize = maxWidth >> totalDepth;
     int csp = m_param->internalCsp;
 
+    m_memPool = new TComDataCU[totalDepth];
+
     bool ok = true;
     for (int i = 0; i < totalDepth; i++)
     {
         uint32_t numPartitions = 1 << ((totalDepth - i) << 1);
         uint32_t cuSize = maxWidth >> i;
 
-        pDataCU = new TComDataCU[8];
-
         uint32_t sizeL = cuSize * cuSize;
         uint32_t sizeC = sizeL >> (CHROMA_H_SHIFT(csp) + CHROMA_V_SHIFT(csp));
 
-        m_memPool[i] = new TComDataCU;
-        ok &= m_memPool[i]->initialize(numPartitions, sizeL, sizeC, 8);
+        ok &= m_memPool[i].initialize(numPartitions, sizeL, sizeC, 8);
 
-        m_interCU_2Nx2N[i]  = &pDataCU[0];
-        m_interCU_2Nx2N[i]->create(m_memPool[i], numPartitions, cuSize, unitSize, csp, 0);
+        m_interCU_2Nx2N[i]  = new TComDataCU;
+        m_interCU_2Nx2N[i]->create(&m_memPool[i], numPartitions, cuSize, unitSize, csp, 0);
 
-        m_interCU_2NxN[i]   = &pDataCU[1];
-        m_interCU_2NxN[i]->create(m_memPool[i], numPartitions, cuSize, unitSize, csp, 1);
+        m_interCU_2NxN[i]   = new TComDataCU;
+        m_interCU_2NxN[i]->create(&m_memPool[i], numPartitions, cuSize, unitSize, csp, 1);
 
-        m_interCU_Nx2N[i]   = &pDataCU[2];
-        m_interCU_Nx2N[i]->create(m_memPool[i], numPartitions, cuSize, unitSize, csp, 2);
+        m_interCU_Nx2N[i]   = new TComDataCU;
+        m_interCU_Nx2N[i]->create(&m_memPool[i], numPartitions, cuSize, unitSize, csp, 2);
 
-        m_intraInInterCU[i] = &pDataCU[3];
-        m_intraInInterCU[i]->create(m_memPool[i], numPartitions, cuSize, unitSize, csp, 3);
+        m_intraInInterCU[i] = new TComDataCU;
+        m_intraInInterCU[i]->create(&m_memPool[i], numPartitions, cuSize, unitSize, csp, 3);
 
-        m_mergeCU[i]        = &pDataCU[4];
-        m_mergeCU[i]->create(m_memPool[i], numPartitions, cuSize, unitSize, csp, 4);
+        m_mergeCU[i]        = new TComDataCU;
+        m_mergeCU[i]->create(&m_memPool[i], numPartitions, cuSize, unitSize, csp, 4);
 
-        m_bestMergeCU[i]    = &pDataCU[5];
-        m_bestMergeCU[i]->create(m_memPool[i], numPartitions, cuSize, unitSize, csp, 5);
+        m_bestMergeCU[i]    = new TComDataCU;
+        m_bestMergeCU[i]->create(&m_memPool[i], numPartitions, cuSize, unitSize, csp, 5);
 
-        m_bestCU[i]         = &pDataCU[6];
-        m_bestCU[i]->create(m_memPool[i], numPartitions, cuSize, unitSize, csp, 6);
+        m_bestCU[i]         = new TComDataCU;
+        m_bestCU[i]->create(&m_memPool[i], numPartitions, cuSize, unitSize, csp, 6);
 
-        m_tempCU[i]         = &pDataCU[7];
-        m_tempCU[i]->create(m_memPool[i], numPartitions, cuSize, unitSize, csp, 7);
+        m_tempCU[i]         = new TComDataCU;
+        m_tempCU[i]->create(&m_memPool[i], numPartitions, cuSize, unitSize, csp, 7);
 
         m_bestPredYuv[i] = new TComYuv;
         ok &= m_bestPredYuv[i]->create(cuSize, cuSize, csp);
@@ -188,9 +187,31 @@
 {
     for (int i = 0; i < m_totalDepth; i++)
     {
-        m_memPool[i]->destroy();
-        delete m_memPool[i];
-        m_memPool[i] = NULL;
+        m_memPool[i].destroy();
+
+        delete m_interCU_2Nx2N[i];
+        m_interCU_2Nx2N[i] = NULL;
+
+        delete m_interCU_2NxN[i];
+        m_interCU_2NxN[i] = NULL;
+
+        delete m_interCU_Nx2N[i];
+        m_interCU_Nx2N[i] = NULL;
+
+        delete m_intraInInterCU[i];
+        m_intraInInterCU[i] = NULL;
+
+        delete m_mergeCU[i];
+        m_mergeCU[i] = NULL;
+
+        delete m_bestMergeCU[i];
+        m_bestMergeCU[i] = NULL;
+
+        delete m_bestCU[i] ;
+        m_bestCU[i] = NULL;
+
+        delete m_tempCU[i] ;
+        m_tempCU[i] = NULL;
 
         if (m_bestPredYuv && m_bestPredYuv[i])
         {
@@ -254,8 +275,8 @@
         }
     }
 
-    delete [] pDataCU;
-    pDataCU = NULL;
+    delete [] m_memPool;
+    m_memPool = NULL;
 
     delete [] m_bestPredYuv;
     m_bestPredYuv = NULL;
diff -r b5fbe9e2a10a -r 25a1b89a8efb source/Lib/TLibEncoder/TEncCu.h
--- a/source/Lib/TLibEncoder/TEncCu.h	Fri Jun 20 15:17:49 2014 +0530
+++ b/source/Lib/TLibEncoder/TEncCu.h	Mon Jun 23 16:11:42 2014 +0530
@@ -90,8 +90,7 @@
 
     static const int MAX_PRED_TYPES = 6;
 
-    TComDataCU* pDataCU;
-    TComDataCU* m_memPool[MAX_CU_DEPTH];
+    TComDataCU* m_memPool;
 
     TComDataCU* m_interCU_2Nx2N[MAX_CU_DEPTH];
     TComDataCU* m_interCU_2NxN[MAX_CU_DEPTH];


More information about the x265-devel mailing list