[x265-commits] [x265] TComDataCU: refactor structure for better data locality
Ashok Kumar Mishra
ashok at multicorewareinc.com
Fri Jun 20 03:16:13 CEST 2014
details: http://hg.videolan.org/x265/rev/62d1d9dd760c
branches:
changeset: 7133:62d1d9dd760c
user: Ashok Kumar Mishra<ashok at multicorewareinc.com>
date: Mon Jun 16 13:51:53 2014 +0530
description:
TComDataCU: refactor structure for better data locality
Subject: [x265] rc: disable MSVC warnings about using POSIX function names like unlink()
details: http://hg.videolan.org/x265/rev/dfaf67c21c32
branches:
changeset: 7134:dfaf67c21c32
user: Steve Borho <steve at borho.org>
date: Thu Jun 19 20:11:24 2014 -0500
description:
rc: disable MSVC warnings about using POSIX function names like unlink()
diffstat:
source/Lib/TLibCommon/TComDataCU.cpp | 163 +++++++++++++++++-----------
source/Lib/TLibCommon/TComDataCU.h | 32 +++++-
source/Lib/TLibCommon/TComMotionInfo.cpp | 34 ++++-
source/Lib/TLibCommon/TComMotionInfo.h | 16 ++-
source/Lib/TLibCommon/TComPicSym.cpp | 7 +-
source/Lib/TLibEncoder/TEncCu.cpp | 172 ++++++++++--------------------
source/Lib/TLibEncoder/TEncCu.h | 19 +-
source/encoder/ratecontrol.cpp | 4 +
8 files changed, 243 insertions(+), 204 deletions(-)
diffs (truncated from 628 to 300 lines):
diff -r c72093672ad1 -r dfaf67c21c32 source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp Thu Jun 19 18:38:15 2014 -0500
+++ b/source/Lib/TLibCommon/TComDataCU.cpp Thu Jun 19 20:11:24 2014 -0500
@@ -100,7 +100,47 @@ TComDataCU::TComDataCU()
TComDataCU::~TComDataCU()
{}
-bool TComDataCU::create(uint32_t numPartition, uint32_t cuSize, int unitSize, int csp)
+
+bool TComDataCU::initialize(uint32_t numPartition, uint32_t sizeL, uint32_t sizeC, uint32_t numBlocks)
+{
+ 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->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->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->iPCMFlagMemBlock, bool, numPartition * 8);
+ CHECKED_MALLOC(m_DataCUMemPool->iPCMSampleYMemBlock, pixel, (sizeL + sizeC * 2) * numBlocks);
+
+ return ok;
+
+fail:
+ ok = false;
+ return ok;
+}
+
+void TComDataCU::create(TComDataCU *cu, uint32_t numPartition, uint32_t cuSize, int unitSize, int csp, int index)
{
m_hChromaShift = CHROMA_H_SHIFT(csp);
m_vChromaShift = CHROMA_V_SHIFT(csp);
@@ -119,75 +159,70 @@ bool TComDataCU::create(uint32_t numPart
uint32_t sizeL = cuSize * cuSize;
uint32_t sizeC = sizeL >> (m_hChromaShift + m_vChromaShift);
- bool ok = true;
- ok &= m_cuMvField[0].create(numPartition);
- ok &= m_cuMvField[1].create(numPartition);
-
- CHECKED_MALLOC(m_qp, char, numPartition);
- CHECKED_MALLOC(m_depth, uint8_t, numPartition);
- CHECKED_MALLOC(m_cuSize, uint8_t, numPartition);
- CHECKED_MALLOC(m_skipFlag, bool, numPartition);
- CHECKED_MALLOC(m_partSizes, char, numPartition);
- CHECKED_MALLOC(m_predModes, char, numPartition);
- CHECKED_MALLOC(m_cuTransquantBypass, bool, numPartition);
-
- CHECKED_MALLOC(m_bMergeFlags, bool, numPartition);
- CHECKED_MALLOC(m_lumaIntraDir, uint8_t, numPartition);
- CHECKED_MALLOC(m_chromaIntraDir, uint8_t, numPartition);
- CHECKED_MALLOC(m_interDir, uint8_t, numPartition);
-
- CHECKED_MALLOC(m_trIdx, uint8_t, numPartition);
- CHECKED_MALLOC(m_transformSkip[0], uint8_t, numPartition * 3);
- m_transformSkip[1] = m_transformSkip[0] + numPartition;
- m_transformSkip[2] = m_transformSkip[0] + numPartition * 2;
-
- CHECKED_MALLOC(m_cbf[0], uint8_t, numPartition * 3);
- m_cbf[1] = m_cbf[0] + numPartition;
- m_cbf[2] = m_cbf[0] + numPartition * 2;
-
- CHECKED_MALLOC(m_mvpIdx[0], uint8_t, numPartition * 2);
- m_mvpIdx[1] = m_mvpIdx[0] + numPartition;
-
- CHECKED_MALLOC(m_trCoeff[0], coeff_t, sizeL + sizeC * 2);
- m_trCoeff[1] = m_trCoeff[0] + sizeL;
- m_trCoeff[2] = m_trCoeff[0] + sizeL + sizeC;
-
- CHECKED_MALLOC(m_iPCMFlags, bool, numPartition);
- CHECKED_MALLOC(m_iPCMSampleY, pixel, sizeL + sizeC * 2);
- m_iPCMSampleCb = m_iPCMSampleY + sizeL;
- m_iPCMSampleCr = m_iPCMSampleY + sizeL + sizeC;
+ 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_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_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[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[1] = m_mvpIdx[0] + numPartition;
+
+ 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_iPCMSampleCb = m_iPCMSampleY + sizeL;
+ m_iPCMSampleCr = m_iPCMSampleY + sizeL + sizeC;
memset(m_partSizes, SIZE_NONE, numPartition * sizeof(*m_partSizes));
- return ok;
-
-fail:
- ok = false;
- return ok;
}
void TComDataCU::destroy()
{
- X265_FREE(m_qp);
- X265_FREE(m_depth);
- X265_FREE(m_cuSize);
- X265_FREE(m_cbf[0]);
- X265_FREE(m_interDir);
- X265_FREE(m_bMergeFlags);
- X265_FREE(m_lumaIntraDir);
- X265_FREE(m_chromaIntraDir);
- X265_FREE(m_trIdx);
- X265_FREE(m_transformSkip[0]);
- X265_FREE(m_trCoeff[0]);
- X265_FREE(m_iPCMFlags);
- X265_FREE(m_iPCMSampleY);
- X265_FREE(m_mvpIdx[0]);
- X265_FREE(m_cuTransquantBypass);
- X265_FREE(m_skipFlag);
- X265_FREE(m_partSizes);
- X265_FREE(m_predModes);
-
- m_cuMvField[0].destroy();
- m_cuMvField[1].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;
+
+ m_cuMvFieldMemPool.destroy();
}
// ====================================================================================================================
diff -r c72093672ad1 -r dfaf67c21c32 source/Lib/TLibCommon/TComDataCU.h
--- a/source/Lib/TLibCommon/TComDataCU.h Thu Jun 19 18:38:15 2014 -0500
+++ b/source/Lib/TLibCommon/TComDataCU.h Thu Jun 19 20:11:24 2014 -0500
@@ -68,6 +68,30 @@ enum NDBFBlockBorderTag
NUM_SGU_BORDER
};
+
+typedef struct
+{
+ char* qpMemBlock;
+ uint8_t* depthMemBlock;
+ uint8_t* cuSizeMemBlock;
+ bool* skipFlagMemBlock;
+ char* partSizeMemBlock;
+ char* predModeMemBlock;
+ bool* cuTQBypassMemBlock;
+ bool* mergeFlagMemBlock;
+ uint8_t* lumaIntraDirMemBlock;
+ uint8_t* chromaIntraDirMemBlock;
+ uint8_t* interDirMemBlock;
+ uint8_t* trIdxMemBlock;
+ uint8_t* transformSkipMemBlock;
+ uint8_t* cbfMemBlock;
+ uint8_t* mvpIdxMemBlock;
+ coeff_t* trCoeffMemBlock;
+ bool* iPCMFlagMemBlock;
+ pixel* iPCMSampleYMemBlock;
+} DataCUMemPool;
+
+
// ====================================================================================================================
// Class definition
// ====================================================================================================================
@@ -142,6 +166,9 @@ private:
// misc. variables
// -------------------------------------------------------------------------------------------------------------------
+ DataCUMemPool *m_DataCUMemPool;
+ TComCUMvField m_cuMvFieldMemPool;
+
protected:
/// add possible motion vector predictor candidates
@@ -172,11 +199,14 @@ public:
uint32_t m_count[4];
uint64_t m_sa8dCost;
double m_baseQp; //Qp of Cu set from RateControl/Vbv.
+
// -------------------------------------------------------------------------------------------------------------------
// create / destroy / initialize / copy
// -------------------------------------------------------------------------------------------------------------------
+ void create(TComDataCU *p, uint32_t numPartition, uint32_t cuSize, int unitSize, int csp, int index);
- bool create(uint32_t numPartition, uint32_t cuSize, int unitSize, int csp);
+ bool initialize(uint32_t numPartition, uint32_t sizeL, uint32_t sizeC, uint32_t numBlocks);
+
void destroy();
void initCU(TComPic* pic, uint32_t cuAddr);
diff -r c72093672ad1 -r dfaf67c21c32 source/Lib/TLibCommon/TComMotionInfo.cpp
--- a/source/Lib/TLibCommon/TComMotionInfo.cpp Thu Jun 19 18:38:15 2014 -0500
+++ b/source/Lib/TLibCommon/TComMotionInfo.cpp Thu Jun 19 20:11:24 2014 -0500
@@ -51,28 +51,40 @@ using namespace x265;
// Create / destroy
// --------------------------------------------------------------------------------------------------------------------
-bool TComCUMvField::create(uint32_t numPartition)
+bool TComCUMvField::initialize(uint32_t numPartition, uint32_t numBlocks)
{
- CHECKED_MALLOC(m_mv, MV, numPartition);
- CHECKED_MALLOC(m_mvd, MV, numPartition);
- CHECKED_MALLOC(m_refIdx, char, numPartition);
+ m_MVFieldMemPool = new MVFieldMemPool;
- m_numPartitions = numPartition;
+ 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);
return true;
+
fail:
return false;
}
+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_numPartitions = numPartition;
+}
+
void TComCUMvField::destroy()
{
- X265_FREE(m_mv);
- X265_FREE(m_mvd);
- X265_FREE(m_refIdx);
+ X265_FREE(m_MVFieldMemPool->m_mvBase);
+ X265_FREE(m_MVFieldMemPool->m_mvdBase);
+ X265_FREE(m_MVFieldMemPool->m_refIdxBase);
- m_mv = NULL;
- m_mvd = NULL;
- m_refIdx = NULL;
+ m_MVFieldMemPool->m_mvBase = NULL;
+ m_MVFieldMemPool->m_mvdBase = NULL;
+ m_MVFieldMemPool->m_refIdxBase = NULL;
+
+ delete m_MVFieldMemPool;
m_numPartitions = 0;
More information about the x265-commits
mailing list