[x265] [PATCH] Modify TComPrediction structure to remove redundant code
ashok at multicorewareinc.com
ashok at multicorewareinc.com
Fri Jan 10 15:35:31 CET 2014
# HG changeset patch
# User ashok at multicorewareinc.com
# Date 1389346038 -19800
# Fri Jan 10 14:57:18 2014 +0530
# Node ID c95b1f7269df342ea0d8172af0df1d54b981281a
# Parent 182e873f46a13b6f9cfd4ff72cc1a17d3ffe067e
Modify TComPrediction structure to remove redundant code
diff -r 182e873f46a1 -r c95b1f7269df source/Lib/TLibCommon/TComPrediction.cpp
--- a/source/Lib/TLibCommon/TComPrediction.cpp Fri Jan 10 14:39:12 2014 +0530
+++ b/source/Lib/TLibCommon/TComPrediction.cpp Fri Jan 10 14:57:18 2014 +0530
@@ -86,6 +86,7 @@
if (m_immedVals)
X265_FREE(m_immedVals);
}
+
void TComPrediction::initTempBuff(int csp)
{
m_hChromaShift = CHROMA_H_SHIFT(csp);
@@ -125,64 +126,58 @@
// ====================================================================================================================
// Public member functions
// ====================================================================================================================
+
bool TComPrediction::filteringIntraReferenceSamples(uint32_t dirMode, uint32_t width)
{
bool bFilter;
+
+ if (dirMode == DC_IDX)
{
+ bFilter = false; //no smoothing for DC or LM chroma
+ }
+ else
+ {
+ int diff = std::min<int>(abs((int) dirMode - HOR_IDX), abs((int)dirMode - VER_IDX));
+ uint32_t sizeIndex = g_convertToBit[width];
+ bFilter = diff > intraFilterThreshold[sizeIndex];
+ }
- if (dirMode == DC_IDX)
- {
- bFilter=false; //no smoothing for DC or LM chroma
- }
- else
- {
- int diff = std::min<int>(abs((int) dirMode - HOR_IDX), abs((int)dirMode - VER_IDX));
- uint32_t sizeIndex = g_convertToBit[width];
- bFilter = diff > intraFilterThreshold[sizeIndex];
- }
- }
return bFilter;
}
-void TComPrediction::predIntraLumaAng(uint32_t dirMode, Pel* dst, intptr_t stride, int size)
+void TComPrediction::predIntraLumaAng(uint32_t dirMode, Pel* dst, intptr_t stride, int width)
{
- assert(g_convertToBit[size] >= 0); // 4x 4
- assert(g_convertToBit[size] <= 5); // 128x128
-
- int log2BlkSize = g_convertToBit[size] + 2;
+ int log2BlkSize = g_convertToBit[width];
Pel *src = m_predBuf;
- assert(log2BlkSize >= 2 && log2BlkSize < 7);
- int diff = std::min<int>(abs((int)dirMode - HOR_IDX), abs((int)dirMode - VER_IDX));
- UChar filterIdx = diff > intraFilterThreshold[log2BlkSize - 2] ? 1 : 0;
- if (dirMode == DC_IDX)
+
+ assert(width >= 4 && width < 128);
+ bool bUseFilteredPredictions = TComPrediction::filteringIntraReferenceSamples(dirMode, width);
+
+ Pel *refLft, *refAbv;
+ refLft = refLeft + width - 1;
+ refAbv = refAbove + width - 1;
+
+ if (bUseFilteredPredictions)
{
- filterIdx = 0; //no smoothing for DC or LM chroma
+ src += ADI_BUF_STRIDE * (2 * width + 1);
+ refLft = refLeftFlt + width - 1;
+ refAbv = refAboveFlt + width - 1;
}
- assert(filterIdx <= 1);
+ bool bFilter = width <= 16 && dirMode != PLANAR_IDX;
+ primitives.intra_pred[log2BlkSize][dirMode](dst, stride, refLft, refAbv, dirMode, bFilter);
+}
- Pel *refLft, *refAbv;
- refLft = refLeft + size - 1;
- refAbv = refAbove + size - 1;
-
- if (filterIdx)
- {
- src += ADI_BUF_STRIDE * (2 * size + 1);
- refLft = refLeftFlt + size - 1;
- refAbv = refAboveFlt + size - 1;
- }
-
- bool bFilter = size <= 16 && dirMode != PLANAR_IDX;
- primitives.intra_pred[log2BlkSize - 2][dirMode](dst, stride, refLft, refAbv, dirMode, bFilter);
-}
// Angular chroma
void TComPrediction::predIntraChromaAng(Pel* src, uint32_t dirMode, Pel* dst, intptr_t stride, int width, int height, int chFmt)
{
int log2BlkSize = g_convertToBit[width];
+
// Create the prediction
Pel refAbv[3 * MAX_CU_SIZE];
Pel refLft[3 * MAX_CU_SIZE];
+
bool bUseFilteredPredictions = true;
if(chFmt != CHROMA_444)
@@ -197,7 +192,7 @@
if (bUseFilteredPredictions)
{
- uint32_t cuWidth2 = width << 1;
+ uint32_t cuWidth2 = width << 1;
uint32_t cuHeight2 = height << 1;
// generate filtered intra prediction samples
// left and left above border + above and above right border + top left corner = length of 3. filter buffer
@@ -257,6 +252,7 @@
refLft[k + width - 1] = src[k * ADI_BUF_STRIDE];
}
}
+
primitives.intra_pred[log2BlkSize][dirMode](dst, stride, refLft + width - 1, refAbv + width - 1, dirMode, 0);
}
@@ -575,20 +571,24 @@
{
int refStride = refPic->getCStride();
int dstStride = dstPic->getCStride();
+
int shiftHor = (2 + cu->getHorzChromaShift());
int shiftVer = (2 + cu->getVertChromaShift());
int refOffset = (mv->x >> shiftHor) + (mv->y >> shiftVer) * refStride;
+
Pel* refCb = refPic->getCbAddr(cu->getAddr(), cu->getZorderIdxInCU() + partAddr) + refOffset;
Pel* refCr = refPic->getCrAddr(cu->getAddr(), cu->getZorderIdxInCU() + partAddr) + refOffset;
Pel* dstCb = dstPic->getCbAddr(partAddr);
Pel* dstCr = dstPic->getCrAddr(partAddr);
+
int xFrac = mv->x & ((1 << shiftHor)-1);
int yFrac = mv->y & ((1 << shiftVer)-1);
int partEnum = partitionFromSizes(width, height);
int csp = cu->getChromaFormat();
+
if ((yFrac | xFrac) == 0)
{
primitives.chroma[csp].copy_pp[partEnum](dstCb, dstStride, refCb, refStride);
@@ -611,33 +611,43 @@
int extStride = cxWidth;
int filterSize = NTAPS_CHROMA;
int halfFilterSize = (filterSize >> 1);
+
primitives.chroma[csp].filter_hps[partEnum](refCb, refStride, m_immedVals, extStride, xFrac << (1 - cu->getHorzChromaShift()), 1);
primitives.chroma_vsp(m_immedVals + (halfFilterSize - 1) * extStride, extStride, dstCb, dstStride, cxWidth, cxHeight, yFrac << (1 - cu->getVertChromaShift()));
+
primitives.chroma[csp].filter_hps[partEnum](refCr, refStride, m_immedVals, extStride, xFrac << (1 - cu->getHorzChromaShift()), 1);
primitives.chroma_vsp(m_immedVals + (halfFilterSize - 1) * extStride, extStride, dstCr, dstStride, cxWidth, cxHeight, yFrac << (1 - cu->getVertChromaShift()));
}
}
+
// Generate motion compensated block when biprediction
void TComPrediction::xPredInterChromaBlk(TComDataCU *cu, TComPicYuv *refPic, uint32_t partAddr, MV *mv, int width, int height, TShortYUV *dstPic)
{
int refStride = refPic->getCStride();
int dstStride = dstPic->m_cwidth;
+
int shiftHor = (2 + cu->getHorzChromaShift());
int shiftVer = (2 + cu->getVertChromaShift());
int refOffset = (mv->x >> shiftHor) + (mv->y >> shiftVer) * refStride;
+
Pel* refCb = refPic->getCbAddr(cu->getAddr(), cu->getZorderIdxInCU() + partAddr) + refOffset;
Pel* refCr = refPic->getCrAddr(cu->getAddr(), cu->getZorderIdxInCU() + partAddr) + refOffset;
int16_t* dstCb = dstPic->getCbAddr(partAddr);
int16_t* dstCr = dstPic->getCrAddr(partAddr);
+
int xFrac = mv->x & ((1 << shiftHor)-1);
int yFrac = mv->y & ((1 << shiftVer)-1);
+
int partEnum = partitionFromSizes(width, height);
int csp = cu->getChromaFormat();
+
uint32_t cxWidth = width >> m_hChromaShift;
uint32_t cxHeight = height >> m_vChromaShift;
+
assert(((cxWidth | cxHeight) % 2) == 0);
+
if ((yFrac | xFrac) == 0)
{
primitives.chroma_p2s[csp](refCb, refStride, dstCb, cxWidth, cxHeight);
@@ -664,6 +674,7 @@
primitives.ipfilter_ss[FILTER_V_S_S_4](m_immedVals + (halfFilterSize - 1) * extStride, extStride, dstCr, dstStride, cxWidth, cxHeight, yFrac << (1 - cu->getVertChromaShift()));
}
}
+
void TComPrediction::xWeightedAverage(TComYuv* srcYuv0, TComYuv* srcYuv1, int refIdx0, int refIdx1, uint32_t partIdx, int width, int height, TComYuv*& outDstYuv, bool bLuma, bool bChroma)
{
if (refIdx0 >= 0 && refIdx1 >= 0)
More information about the x265-devel
mailing list