[x265-commits] [x265] TEncCU:fix for large memory consumption

Ashok Kumar Mishra ashok at multicorewareinc.com
Sat Jun 21 19:14:29 CEST 2014


details:   http://hg.videolan.org/x265/rev/da4aa721bf2f
branches:  
changeset: 7175:da4aa721bf2f
user:      Ashok Kumar Mishra<ashok at multicorewareinc.com>
date:      Sat Jun 21 17:32:11 2014 +0530
description:
TEncCU:fix for large memory consumption

diffstat:

 source/Lib/TLibCommon/TComDataCU.cpp     |   2 +-
 source/Lib/TLibCommon/TComMotionInfo.cpp |  24 ++++++++++++------------
 source/Lib/TLibCommon/TComMotionInfo.h   |   6 +++---
 source/Lib/TLibEncoder/TEncCu.cpp        |  26 +++++++++-----------------
 source/Lib/TLibEncoder/TEncCu.h          |   2 +-
 5 files changed, 26 insertions(+), 34 deletions(-)

diffs (152 lines):

diff -r fe370292c232 -r da4aa721bf2f source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Fri Jun 20 16:41:11 2014 -0700
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Sat Jun 21 17:32:11 2014 +0530
@@ -131,7 +131,7 @@ bool TComDataCU::initialize(uint32_t num
     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 * 8);
+    CHECKED_MALLOC(m_DataCUMemPool->iPCMFlagMemBlock, bool, numPartition * numBlocks);
     CHECKED_MALLOC(m_DataCUMemPool->iPCMSampleYMemBlock, pixel, (sizeL + sizeC * 2) * numBlocks);
 
     return ok;
diff -r fe370292c232 -r da4aa721bf2f source/Lib/TLibCommon/TComMotionInfo.cpp
--- a/source/Lib/TLibCommon/TComMotionInfo.cpp	Fri Jun 20 16:41:11 2014 -0700
+++ b/source/Lib/TLibCommon/TComMotionInfo.cpp	Sat Jun 21 17:32:11 2014 +0530
@@ -55,9 +55,9 @@ bool TComCUMvField::initialize(uint32_t 
 {
     m_MVFieldMemPool = new MVFieldMemPool;
 
-    CHECKED_MALLOC(m_MVFieldMemPool->m_mvBase, MV, numPartition * 2 * numBlocks);
-    CHECKED_MALLOC(m_MVFieldMemPool->m_mvdBase, MV, numPartition * 2 * numBlocks);
-    CHECKED_MALLOC(m_MVFieldMemPool->m_refIdxBase, 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;
 
@@ -67,22 +67,22 @@ fail:
 
 void TComCUMvField::create(TComCUMvField p, uint32_t numPartition, int index, int idx)
 {
-    m_mv     = p.m_MVFieldMemPool->m_mvBase     + (index * 2 + idx) * numPartition;
-    m_mvd    = p.m_MVFieldMemPool->m_mvdBase    + (index * 2 + idx) * numPartition;
-    m_refIdx = p.m_MVFieldMemPool->m_refIdxBase + (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_mvBase);
-    X265_FREE(m_MVFieldMemPool->m_mvdBase);
-    X265_FREE(m_MVFieldMemPool->m_refIdxBase);
+    X265_FREE(m_MVFieldMemPool->m_mvMemBlock);
+    X265_FREE(m_MVFieldMemPool->m_mvdMemBlock);
+    X265_FREE(m_MVFieldMemPool->m_refIdxMemBlock);
 
-    m_MVFieldMemPool->m_mvBase     = NULL;
-    m_MVFieldMemPool->m_mvdBase    = NULL;
-    m_MVFieldMemPool->m_refIdxBase = NULL;
+    m_MVFieldMemPool->m_mvMemBlock     = NULL;
+    m_MVFieldMemPool->m_mvdMemBlock    = NULL;
+    m_MVFieldMemPool->m_refIdxMemBlock = NULL;
 
     delete m_MVFieldMemPool;
 
diff -r fe370292c232 -r da4aa721bf2f source/Lib/TLibCommon/TComMotionInfo.h
--- a/source/Lib/TLibCommon/TComMotionInfo.h	Fri Jun 20 16:41:11 2014 -0700
+++ b/source/Lib/TLibCommon/TComMotionInfo.h	Sat Jun 21 17:32:11 2014 +0530
@@ -61,9 +61,9 @@ struct AMVPInfo
 
 typedef struct
 {
-    MV*   m_mvBase    ;
-    MV*   m_mvdBase   ;
-    char* m_refIdxBase;
+    MV*   m_mvMemBlock    ;
+    MV*   m_mvdMemBlock   ;
+    char* m_refIdxMemBlock;
 } MVFieldMemPool;
 
 // ====================================================================================================================
diff -r fe370292c232 -r da4aa721bf2f source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp	Fri Jun 20 16:41:11 2014 -0700
+++ b/source/Lib/TLibEncoder/TEncCu.cpp	Sat Jun 21 17:32:11 2014 +0530
@@ -117,13 +117,7 @@ bool TEncCu::create(uint8_t totalDepth, 
         uint32_t numPartitions = 1 << ((totalDepth - i) << 1);
         uint32_t cuSize = maxWidth >> i;
 
-        pDataCU = new TComDataCU*[8];
-        pDataCU[0] = new TComDataCU[8 * sizeof(TComDataCU)];
-
-        for (int j = 0; j < 8; j++)
-        {
-            pDataCU[j] = pDataCU[0] + j * sizeof(TComDataCU);
-        }
+        pDataCU = new TComDataCU[8];
 
         uint32_t sizeL = cuSize * cuSize;
         uint32_t sizeC = sizeL >> (CHROMA_H_SHIFT(csp) + CHROMA_V_SHIFT(csp));
@@ -131,28 +125,28 @@ bool TEncCu::create(uint8_t totalDepth, 
         m_memPool[i] = new TComDataCU;
         ok &= m_memPool[i]->initialize(numPartitions, sizeL, sizeC, 8);
 
-        m_interCU_2Nx2N[i]  = pDataCU[0];
+        m_interCU_2Nx2N[i]  = &pDataCU[0];
         m_interCU_2Nx2N[i]->create(m_memPool[i], numPartitions, cuSize, unitSize, csp, 0);
 
-        m_interCU_2NxN[i]   = pDataCU[1];
+        m_interCU_2NxN[i]   = &pDataCU[1];
         m_interCU_2NxN[i]->create(m_memPool[i], numPartitions, cuSize, unitSize, csp, 1);
 
-        m_interCU_Nx2N[i]   = pDataCU[2];
+        m_interCU_Nx2N[i]   = &pDataCU[2];
         m_interCU_Nx2N[i]->create(m_memPool[i], numPartitions, cuSize, unitSize, csp, 2);
 
-        m_intraInInterCU[i] = pDataCU[3];
+        m_intraInInterCU[i] = &pDataCU[3];
         m_intraInInterCU[i]->create(m_memPool[i], numPartitions, cuSize, unitSize, csp, 3);
 
-        m_mergeCU[i]        = pDataCU[4];
+        m_mergeCU[i]        = &pDataCU[4];
         m_mergeCU[i]->create(m_memPool[i], numPartitions, cuSize, unitSize, csp, 4);
 
-        m_bestMergeCU[i]    = pDataCU[5];
+        m_bestMergeCU[i]    = &pDataCU[5];
         m_bestMergeCU[i]->create(m_memPool[i], numPartitions, cuSize, unitSize, csp, 5);
 
-        m_bestCU[i]         = pDataCU[6];
+        m_bestCU[i]         = &pDataCU[6];
         m_bestCU[i]->create(m_memPool[i], numPartitions, cuSize, unitSize, csp, 6);
 
-        m_tempCU[i]         = pDataCU[7];
+        m_tempCU[i]         = &pDataCU[7];
         m_tempCU[i]->create(m_memPool[i], numPartitions, cuSize, unitSize, csp, 7);
 
         m_bestPredYuv[i] = new TComYuv;
@@ -260,8 +254,6 @@ void TEncCu::destroy()
         }
     }
 
-    delete [] pDataCU[0];
-    pDataCU[0] = NULL;
     delete [] pDataCU;
     pDataCU = NULL;
 
diff -r fe370292c232 -r da4aa721bf2f source/Lib/TLibEncoder/TEncCu.h
--- a/source/Lib/TLibEncoder/TEncCu.h	Fri Jun 20 16:41:11 2014 -0700
+++ b/source/Lib/TLibEncoder/TEncCu.h	Sat Jun 21 17:32:11 2014 +0530
@@ -90,7 +90,7 @@ private:
 
     static const int MAX_PRED_TYPES = 6;
 
-    TComDataCU** pDataCU;
+    TComDataCU* pDataCU;
     TComDataCU* m_memPool[MAX_CU_DEPTH];
 
     TComDataCU* m_interCU_2Nx2N[MAX_CU_DEPTH];


More information about the x265-commits mailing list