[x265] [PATCH] TEncCU:fix for large memory consumption
ashok at multicorewareinc.com
ashok at multicorewareinc.com
Sat Jun 21 16:09:43 CEST 2014
# HG changeset patch
# User Ashok Kumar Mishra<ashok at multicorewareinc.com>
# Date 1403352131 -19800
# Sat Jun 21 17:32:11 2014 +0530
# Node ID da4aa721bf2f0bb7e8f31b4e9a04c6fbc32fa439
# Parent fe370292c232ec9a629d191791271b71c1c6f354
TEncCU:fix for large memory consumption
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 @@
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 @@
{
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 @@
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 @@
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 @@
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 @@
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 @@
}
}
- 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 @@
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-devel
mailing list