[x265-commits] [x265] TEncSearch: use X265_MALLOC to allocate pixel buffers, an...
Steve Borho
steve at borho.org
Fri Feb 21 09:52:29 CET 2014
details: http://hg.videolan.org/x265/rev/fc3db1cfef2a
branches:
changeset: 6229:fc3db1cfef2a
user: Steve Borho <steve at borho.org>
date: Thu Feb 20 16:47:26 2014 -0600
description:
TEncSearch: use X265_MALLOC to allocate pixel buffers, and pixel type
Subject: [x265] TEncSearch: use X265_MALLOC for UChar buffers, and uint8_t type
details: http://hg.videolan.org/x265/rev/6b476469c212
branches:
changeset: 6230:6b476469c212
user: Steve Borho <steve at borho.org>
date: Thu Feb 20 16:56:33 2014 -0600
description:
TEncSearch: use X265_MALLOC for UChar buffers, and uint8_t type
Subject: [x265] TEncSearch: remove redundant m_hChromaShift, m_vChromaShift
details: http://hg.videolan.org/x265/rev/406abea93732
branches:
changeset: 6231:406abea93732
user: Steve Borho <steve at borho.org>
date: Thu Feb 20 18:20:56 2014 -0600
description:
TEncSearch: remove redundant m_hChromaShift, m_vChromaShift
TComPrediction has these members, and TEncSearch derives from TComPrediction
Subject: [x265] TComYuv: combine copyPartToPartLuma and copyPartToPartChroma
details: http://hg.videolan.org/x265/rev/13f73b241382
branches:
changeset: 6232:13f73b241382
user: Steve Borho <steve at borho.org>
date: Fri Feb 21 02:25:58 2014 -0600
description:
TComYuv: combine copyPartToPartLuma and copyPartToPartChroma
The new function tries to ensure the proper chroma block is copied, when
necessary.
diffstat:
source/Lib/TLibCommon/TComYuv.cpp | 42 ++++++++++---------
source/Lib/TLibCommon/TComYuv.h | 3 +-
source/Lib/TLibEncoder/TEncSearch.cpp | 72 ++++++++++++++--------------------
source/Lib/TLibEncoder/TEncSearch.h | 12 ++---
4 files changed, 58 insertions(+), 71 deletions(-)
diffs (257 lines):
diff -r 0c19c44af2d3 -r 13f73b241382 source/Lib/TLibCommon/TComYuv.cpp
--- a/source/Lib/TLibCommon/TComYuv.cpp Fri Feb 21 12:23:22 2014 +0900
+++ b/source/Lib/TLibCommon/TComYuv.cpp Fri Feb 21 02:25:58 2014 -0600
@@ -161,6 +161,7 @@ void TComYuv::copyPartToYuv(TComYuv* dst
void TComYuv::copyPartToPartYuv(TComYuv* dstPicYuv, uint32_t partIdx, uint32_t width, uint32_t height, bool bLuma, bool bChroma)
{
int part = partitionFromSizes(width, height);
+ assert(width != 4 || height != 4);
if (bLuma)
{
@@ -187,32 +188,33 @@ void TComYuv::copyPartToPartYuv(TComYuv*
}
}
-void TComYuv::copyPartToPartLuma(TShortYUV* dstPicYuv, uint32_t partIdx, uint32_t part)
+void TComYuv::copyPartToPartShort(TShortYUV* dstPicYuv, uint32_t partIdx, uint32_t lumaSize, bool bChroma, bool bChromaSame)
{
- Pel* src = getLumaAddr(partIdx);
+ int part = partitionFromSizes(lumaSize, lumaSize);
+
int16_t* dst = dstPicYuv->getLumaAddr(partIdx);
+ uint32_t dststride = dstPicYuv->m_width;
+ primitives.luma_copy_ps[part](dst, dststride, getLumaAddr(partIdx), getStride());
- uint32_t srcstride = getStride();
- uint32_t dststride = dstPicYuv->m_width;
+ if (bChroma)
+ {
+ int16_t* dstU = dstPicYuv->getCbAddr(partIdx);
+ int16_t* dstV = dstPicYuv->getCrAddr(partIdx);
+ dststride = dstPicYuv->m_cwidth;
- primitives.luma_copy_ps[part](dst, dststride, src, srcstride);
+ if (bChromaSame)
+ {
+ primitives.luma_copy_ps[part](dstU, dststride, getCbAddr(partIdx), getCStride());
+ primitives.luma_copy_ps[part](dstV, dststride, getCrAddr(partIdx), getCStride());
+ }
+ else
+ {
+ primitives.chroma[m_csp].copy_ps[part](dstU, dststride, getCbAddr(partIdx), getCStride());
+ primitives.chroma[m_csp].copy_ps[part](dstV, dststride, getCrAddr(partIdx), getCStride());
+ }
+ }
}
-void TComYuv::copyPartToPartChroma(TShortYUV* dstPicYuv, uint32_t partIdx, uint32_t part)
-{
- Pel* srcU = getCbAddr(partIdx);
- Pel* srcV = getCrAddr(partIdx);
- int16_t* dstU = dstPicYuv->getCbAddr(partIdx);
- int16_t* dstV = dstPicYuv->getCrAddr(partIdx);
-
- uint32_t srcstride = getCStride();
- uint32_t dststride = dstPicYuv->m_cwidth;
-
- primitives.chroma[m_csp].copy_ps[part](dstU, dststride, srcU, srcstride);
- primitives.chroma[m_csp].copy_ps[part](dstV, dststride, srcV, srcstride);
-}
-
-
void TComYuv::copyPartToPartChroma(TShortYUV* dstPicYuv, uint32_t partIdx, uint32_t lumaSize, uint32_t chromaId)
{
int part = partitionFromSizes(lumaSize, lumaSize);
diff -r 0c19c44af2d3 -r 13f73b241382 source/Lib/TLibCommon/TComYuv.h
--- a/source/Lib/TLibCommon/TComYuv.h Fri Feb 21 12:23:22 2014 +0900
+++ b/source/Lib/TLibCommon/TComYuv.h Fri Feb 21 02:25:58 2014 -0600
@@ -131,8 +131,7 @@ public:
// Copy YUV partition buffer to other YUV partition buffer
void copyPartToPartYuv(TComYuv* dstPicYuv, uint32_t partIdx, uint32_t width, uint32_t height, bool bLuma, bool bChroma);
- void copyPartToPartLuma(TShortYUV* dstPicYuv, uint32_t partIdx, uint32_t part);
- void copyPartToPartChroma(TShortYUV* dstPicYuv, uint32_t partIdx, uint32_t part);
+ void copyPartToPartShort(TShortYUV* dstPicYuv, uint32_t partIdx, uint32_t lumaSize, bool bChroma, bool bChromaSame);
void copyPartToPartChroma(TShortYUV* dstPicYuv, uint32_t partIdx, uint32_t lumaSize, uint32_t chromaId);
// ------------------------------------------------------------------------------------------------------------------
diff -r 0c19c44af2d3 -r 13f73b241382 source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp Fri Feb 21 12:23:22 2014 +0900
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp Fri Feb 21 02:25:58 2014 -0600
@@ -64,8 +64,8 @@ TEncSearch::TEncSearch()
for (int i = 0; i < 3; i++)
{
m_sharedPredTransformSkip[i] = NULL;
+ m_qtTempTransformSkipFlag[i] = NULL;
m_qtTempCbf[i] = NULL;
- m_qtTempTransformSkipFlag[i] = NULL;
}
m_cfg = NULL;
@@ -79,8 +79,6 @@ TEncSearch::TEncSearch()
TEncSearch::~TEncSearch()
{
- delete [] m_tempPel;
-
if (m_cfg)
{
const uint32_t numLayersToAllocate = m_cfg->getQuadtreeTULog2MaxSize() - m_cfg->getQuadtreeTULog2MinSize() + 1;
@@ -92,21 +90,22 @@ TEncSearch::~TEncSearch()
m_qtTempShortYuv[i].destroy();
}
}
+ X265_FREE(m_qtTempTUCoeffY);
+ X265_FREE(m_qtTempTUCoeffCb);
+ X265_FREE(m_qtTempTUCoeffCr);
+ X265_FREE(m_tempPel);
+ X265_FREE(m_qtTempTrIdx);
+ for (uint32_t i = 0; i < 3; ++i)
+ {
+ X265_FREE(m_qtTempCbf[i]);
+ X265_FREE(m_sharedPredTransformSkip[i]);
+ X265_FREE(m_qtTempTransformSkipFlag[i]);
+ }
+
delete[] m_qtTempCoeffY;
delete[] m_qtTempCoeffCb;
delete[] m_qtTempCoeffCr;
- delete[] m_qtTempTrIdx;
delete[] m_qtTempShortYuv;
- X265_FREE(m_qtTempTUCoeffY);
- X265_FREE(m_qtTempTUCoeffCb);
- X265_FREE(m_qtTempTUCoeffCr);
- for (uint32_t i = 0; i < 3; ++i)
- {
- delete[] m_qtTempCbf[i];
- delete[] m_sharedPredTransformSkip[i];
- delete[] m_qtTempTransformSkipFlag[i];
- }
-
m_qtTempTransformSkipYuv.destroy();
m_tmpYuvPred.destroy();
}
@@ -117,6 +116,7 @@ void TEncSearch::init(TEncCfg* cfg, TCom
m_trQuant = trQuant;
m_rdCost = rdCost;
+ initTempBuff(cfg->param.internalCsp);
m_me.setSearchMethod(cfg->param.searchMethod);
m_me.setSubpelRefine(cfg->param.subpelRefine);
@@ -133,25 +133,11 @@ void TEncSearch::init(TEncCfg* cfg, TCom
}
}
- initTempBuff(cfg->param.internalCsp);
-
- m_tempPel = new Pel[g_maxCUWidth * g_maxCUHeight];
-
const uint32_t numLayersToAllocate = cfg->getQuadtreeTULog2MaxSize() - cfg->getQuadtreeTULog2MinSize() + 1;
m_qtTempCoeffY = new TCoeff*[numLayersToAllocate];
m_qtTempCoeffCb = new TCoeff*[numLayersToAllocate];
m_qtTempCoeffCr = new TCoeff*[numLayersToAllocate];
-
- const uint32_t numPartitions = 1 << (g_maxCUDepth << 1);
- m_qtTempTrIdx = new UChar[numPartitions];
- m_qtTempCbf[0] = new UChar[numPartitions];
- m_qtTempCbf[1] = new UChar[numPartitions];
- m_qtTempCbf[2] = new UChar[numPartitions];
- m_qtTempShortYuv = new TShortYUV[numLayersToAllocate];
-
- m_hChromaShift = CHROMA_H_SHIFT(cfg->param.internalCsp);
- m_vChromaShift = CHROMA_V_SHIFT(cfg->param.internalCsp);
-
+ m_qtTempShortYuv = new TShortYUV[numLayersToAllocate];
for (uint32_t i = 0; i < numLayersToAllocate; ++i)
{
m_qtTempCoeffY[i] = X265_MALLOC(TCoeff, g_maxCUWidth * g_maxCUHeight);
@@ -160,18 +146,25 @@ void TEncSearch::init(TEncCfg* cfg, TCom
m_qtTempShortYuv[i].create(MAX_CU_SIZE, MAX_CU_SIZE, cfg->param.internalCsp);
}
- m_sharedPredTransformSkip[0] = new Pel[MAX_TS_WIDTH * MAX_TS_HEIGHT];
- m_sharedPredTransformSkip[1] = new Pel[MAX_TS_WIDTH * MAX_TS_HEIGHT];
- m_sharedPredTransformSkip[2] = new Pel[MAX_TS_WIDTH * MAX_TS_HEIGHT];
+ const uint32_t numPartitions = 1 << (g_maxCUDepth << 1);
+ m_qtTempTrIdx = X265_MALLOC(uint8_t, numPartitions);
+ m_qtTempCbf[0] = X265_MALLOC(uint8_t, numPartitions);
+ m_qtTempCbf[1] = X265_MALLOC(uint8_t, numPartitions);
+ m_qtTempCbf[2] = X265_MALLOC(uint8_t, numPartitions);
+ m_qtTempTransformSkipFlag[0] = X265_MALLOC(uint8_t, numPartitions);
+ m_qtTempTransformSkipFlag[1] = X265_MALLOC(uint8_t, numPartitions);
+ m_qtTempTransformSkipFlag[2] = X265_MALLOC(uint8_t, numPartitions);
+
+ m_sharedPredTransformSkip[0] = X265_MALLOC(pixel, MAX_TS_WIDTH * MAX_TS_HEIGHT);
+ m_sharedPredTransformSkip[1] = X265_MALLOC(pixel, MAX_TS_WIDTH * MAX_TS_HEIGHT);
+ m_sharedPredTransformSkip[2] = X265_MALLOC(pixel, MAX_TS_WIDTH * MAX_TS_HEIGHT);
m_qtTempTUCoeffY = X265_MALLOC(TCoeff, MAX_TS_WIDTH * MAX_TS_HEIGHT);
m_qtTempTUCoeffCb = X265_MALLOC(TCoeff, MAX_TS_WIDTH * MAX_TS_HEIGHT);
m_qtTempTUCoeffCr = X265_MALLOC(TCoeff, MAX_TS_WIDTH * MAX_TS_HEIGHT);
+ m_tempPel = X265_MALLOC(pixel, g_maxCUWidth * g_maxCUHeight);
m_qtTempTransformSkipYuv.create(g_maxCUWidth, g_maxCUHeight, cfg->param.internalCsp);
- m_qtTempTransformSkipFlag[0] = new UChar[numPartitions];
- m_qtTempTransformSkipFlag[1] = new UChar[numPartitions];
- m_qtTempTransformSkipFlag[2] = new UChar[numPartitions];
m_tmpYuvPred.create(MAX_CU_SIZE, MAX_CU_SIZE, cfg->param.internalCsp);
}
@@ -1238,14 +1231,9 @@ void TEncSearch::xLoadIntraResultQT(TCom
::memcpy(coeffDstV, coeffSrcV, sizeof(TCoeff) * numCoeffC);
}
- int part = partitionFromSizes(1 << trSizeLog2, 1 << trSizeLog2);
+
//===== copy reconstruction =====
- m_qtTempTransformSkipYuv.copyPartToPartLuma(&m_qtTempShortYuv[qtlayer], absPartIdx, part);
-
- if (!bLumaOnly && !bSkipChroma)
- {
- m_qtTempTransformSkipYuv.copyPartToPartChroma(&m_qtTempShortYuv[qtlayer], absPartIdx, part);
- }
+ m_qtTempTransformSkipYuv.copyPartToPartShort(&m_qtTempShortYuv[qtlayer], absPartIdx, 1 << trSizeLog2, !bLumaOnly && !bSkipChroma, bChromaSame);
uint32_t zOrder = cu->getZorderIdxInCU() + absPartIdx;
pixel* reconIPred = cu->getPic()->getPicYuvRec()->getLumaAddr(cu->getAddr(), zOrder);
diff -r 0c19c44af2d3 -r 13f73b241382 source/Lib/TLibEncoder/TEncSearch.h
--- a/source/Lib/TLibEncoder/TEncSearch.h Fri Feb 21 12:23:22 2014 +0900
+++ b/source/Lib/TLibEncoder/TEncSearch.h Fri Feb 21 02:25:58 2014 -0600
@@ -84,18 +84,18 @@ public:
protected:
TShortYUV* m_qtTempShortYuv;
- Pel* m_sharedPredTransformSkip[3];
+ pixel* m_sharedPredTransformSkip[3];
TCoeff** m_qtTempCoeffY;
TCoeff** m_qtTempCoeffCb;
TCoeff** m_qtTempCoeffCr;
- UChar* m_qtTempTrIdx;
- UChar* m_qtTempCbf[3];
+ uint8_t* m_qtTempTrIdx;
+ uint8_t* m_qtTempCbf[3];
TCoeff* m_qtTempTUCoeffY;
TCoeff* m_qtTempTUCoeffCb;
TCoeff* m_qtTempTUCoeffCr;
- UChar* m_qtTempTransformSkipFlag[3];
+ uint8_t* m_qtTempTransformSkipFlag[3];
TComYuv m_qtTempTransformSkipYuv;
// interface to option
@@ -112,11 +112,9 @@ protected:
MV m_mvPredictors[3];
TComYuv m_tmpYuvPred; // to avoid constant memory allocation/deallocation in xGetInterPredictionError()
- Pel* m_tempPel; // avoid mallocs in xEstimateResidualQT
+ pixel* m_tempPel; // avoid mallocs in xEstimateResidualQT
// Color space parameters
- int m_hChromaShift;
- int m_vChromaShift;
uint32_t m_section;
uint32_t m_splitMode;
uint32_t m_absPartIdxTURelCU;
More information about the x265-commits
mailing list