[x265] [PATCH] pass bLuma and bChroma parameters for functions
sumalatha at multicorewareinc.com
sumalatha at multicorewareinc.com
Wed Oct 16 13:48:29 CEST 2013
# HG changeset patch
# User Sumalatha Polureddy
# Date 1381924099 -19800
# Node ID ac7aa89eae11d264992fd8495f6dcad8da85f243
# Parent 3cdbc62783e197cd5cf6dcf5b1cc76e2cd6d93c2
pass bLuma and bChroma parameters for functions
Based on the values of two parameters, luma and chroma operations are done.
Default value for both is set as true todo both operations
diff -r 3cdbc62783e1 -r ac7aa89eae11 source/Lib/TLibCommon/TComPrediction.cpp
--- a/source/Lib/TLibCommon/TComPrediction.cpp Wed Oct 16 12:17:21 2013 +0530
+++ b/source/Lib/TLibCommon/TComPrediction.cpp Wed Oct 16 17:18:19 2013 +0530
@@ -245,7 +245,7 @@
return false;
}
-void TComPrediction::motionCompensation(TComDataCU* cu, TComYuv* predYuv, RefPicList picList, int partIdx)
+void TComPrediction::motionCompensation(TComDataCU* cu, TComYuv* predYuv, RefPicList picList, int partIdx, bool bLuma, bool bChroma)
{
int width;
int height;
@@ -264,26 +264,27 @@
MV mv = cu->getCUMvField(picList)->getMv(partAddr);
cu->clipMv(mv);
+ if (bLuma)
+ xPredInterLumaBlk(cu, cu->getSlice()->getRefPic(picList, refId)->getPicYuvRec(), partAddr, &mv, width, height, pcMbYuv);
+ if (bChroma)
+ xPredInterChromaBlk(cu, cu->getSlice()->getRefPic(picList, refId)->getPicYuvRec(), partAddr, &mv, width, height, pcMbYuv);
- xPredInterLumaBlk(cu, cu->getSlice()->getRefPic(picList, refId)->getPicYuvRec(), partAddr, &mv, width, height, pcMbYuv);
- xPredInterChromaBlk(cu, cu->getSlice()->getRefPic(picList, refId)->getPicYuvRec(), partAddr, &mv, width, height, pcMbYuv);
-
- xWeightedPredictionUni(cu, pcMbYuv, partAddr, width, height, picList, predYuv);
+ xWeightedPredictionUni(cu, pcMbYuv, partAddr, width, height, picList, predYuv, bLuma, bChroma);
}
else
{
- xPredInterUni(cu, partAddr, width, height, picList, predYuv);
+ xPredInterUni(cu, partAddr, width, height, picList, predYuv, bLuma, bChroma);
}
}
else
{
if (xCheckIdenticalMotion(cu, partAddr))
{
- xPredInterUni(cu, partAddr, width, height, REF_PIC_LIST_0, predYuv);
+ xPredInterUni(cu, partAddr, width, height, REF_PIC_LIST_0, predYuv, bLuma, bChroma);
}
else
{
- xPredInterBi(cu, partAddr, width, height, predYuv);
+ xPredInterBi(cu, partAddr, width, height, predYuv, bLuma, bChroma);
}
}
return;
@@ -305,31 +306,33 @@
MV mv = cu->getCUMvField(picList)->getMv(partAddr);
cu->clipMv(mv);
- xPredInterLumaBlk(cu, cu->getSlice()->getRefPic(picList, refId)->getPicYuvRec(), partAddr, &mv, width, height, pcMbYuv);
- xPredInterChromaBlk(cu, cu->getSlice()->getRefPic(picList, refId)->getPicYuvRec(), partAddr, &mv, width, height, pcMbYuv);
+ if (bLuma)
+ xPredInterLumaBlk(cu, cu->getSlice()->getRefPic(picList, refId)->getPicYuvRec(), partAddr, &mv, width, height, pcMbYuv);
+ if (bChroma)
+ xPredInterChromaBlk(cu, cu->getSlice()->getRefPic(picList, refId)->getPicYuvRec(), partAddr, &mv, width, height, pcMbYuv);
- xWeightedPredictionUni(cu, pcMbYuv, partAddr, width, height, picList, predYuv);
+ xWeightedPredictionUni(cu, pcMbYuv, partAddr, width, height, picList, predYuv, bLuma, bChroma);
}
else
{
- xPredInterUni(cu, partAddr, width, height, picList, predYuv);
+ xPredInterUni(cu, partAddr, width, height, picList, predYuv, bLuma, bChroma);
}
}
else
{
if (xCheckIdenticalMotion(cu, partAddr))
{
- xPredInterUni(cu, partAddr, width, height, REF_PIC_LIST_0, predYuv);
+ xPredInterUni(cu, partAddr, width, height, REF_PIC_LIST_0, predYuv, bLuma, bChroma);
}
else
{
- xPredInterBi(cu, partAddr, width, height, predYuv);
+ xPredInterBi(cu, partAddr, width, height, predYuv, bLuma, bChroma);
}
}
}
}
-void TComPrediction::xPredInterUni(TComDataCU* cu, UInt partAddr, int width, int height, RefPicList picList, TComYuv* outPredYuv)
+void TComPrediction::xPredInterUni(TComDataCU* cu, UInt partAddr, int width, int height, RefPicList picList, TComYuv* outPredYuv, bool bLuma, bool bChroma)
{
int refIdx = cu->getCUMvField(picList)->getRefIdx(partAddr);
@@ -338,12 +341,14 @@
MV mv = cu->getCUMvField(picList)->getMv(partAddr);
cu->clipMv(mv);
- xPredInterLumaBlk(cu, cu->getSlice()->m_mref[picList][refIdx], partAddr, &mv, width, height, outPredYuv);
+ if (bLuma)
+ xPredInterLumaBlk(cu, cu->getSlice()->m_mref[picList][refIdx], partAddr, &mv, width, height, outPredYuv);
- xPredInterChromaBlk(cu, cu->getSlice()->getRefPic(picList, refIdx)->getPicYuvRec(), partAddr, &mv, width, height, outPredYuv);
+ if (bChroma)
+ xPredInterChromaBlk(cu, cu->getSlice()->getRefPic(picList, refIdx)->getPicYuvRec(), partAddr, &mv, width, height, outPredYuv);
}
-void TComPrediction::xPredInterUni(TComDataCU* cu, UInt partAddr, int width, int height, RefPicList picList, TShortYUV* outPredYuv)
+void TComPrediction::xPredInterUni(TComDataCU* cu, UInt partAddr, int width, int height, RefPicList picList, TShortYUV* outPredYuv, bool bLuma, bool bChroma)
{
int refIdx = cu->getCUMvField(picList)->getRefIdx(partAddr);
@@ -352,11 +357,13 @@
MV mv = cu->getCUMvField(picList)->getMv(partAddr);
cu->clipMv(mv);
- xPredInterLumaBlk(cu, cu->getSlice()->getRefPic(picList, refIdx)->getPicYuvRec(), partAddr, &mv, width, height, outPredYuv);
- xPredInterChromaBlk(cu, cu->getSlice()->getRefPic(picList, refIdx)->getPicYuvRec(), partAddr, &mv, width, height, outPredYuv);
+ if (bLuma)
+ xPredInterLumaBlk(cu, cu->getSlice()->getRefPic(picList, refIdx)->getPicYuvRec(), partAddr, &mv, width, height, outPredYuv);
+ if (bChroma)
+ xPredInterChromaBlk(cu, cu->getSlice()->getRefPic(picList, refIdx)->getPicYuvRec(), partAddr, &mv, width, height, outPredYuv);
}
-void TComPrediction::xPredInterBi(TComDataCU* cu, UInt partAddr, int width, int height, TComYuv*& outPredYuv)
+void TComPrediction::xPredInterBi(TComDataCU* cu, UInt partAddr, int width, int height, TComYuv*& outPredYuv, bool bLuma, bool bChroma)
{
int refIdx[2] = { -1, -1 };
@@ -371,16 +378,16 @@
assert(refIdx[refList] < cu->getSlice()->getNumRefIdx(picList));
pcMbYuv = &m_predShortYuv[refList];
- xPredInterUni(cu, partAddr, width, height, picList, pcMbYuv);
+ xPredInterUni(cu, partAddr, width, height, picList, pcMbYuv, bLuma, bChroma);
}
if (cu->getSlice()->getPPS()->getWPBiPred() && cu->getSlice()->getSliceType() == B_SLICE)
{
- xWeightedPredictionBi(cu, &m_predShortYuv[0], &m_predShortYuv[1], refIdx[0], refIdx[1], partAddr, width, height, outPredYuv);
+ xWeightedPredictionBi(cu, &m_predShortYuv[0], &m_predShortYuv[1], refIdx[0], refIdx[1], partAddr, width, height, outPredYuv, bLuma, bChroma);
}
else
{
- outPredYuv->addAvg(&m_predShortYuv[0], &m_predShortYuv[1], partAddr, width, height);
+ outPredYuv->addAvg(&m_predShortYuv[0], &m_predShortYuv[1], partAddr, width, height, bLuma, bChroma);
}
}
else if (cu->getSlice()->getPPS()->getWPBiPred() && cu->getSlice()->getSliceType() == B_SLICE)
@@ -399,10 +406,10 @@
assert(refIdx[refList] < cu->getSlice()->getNumRefIdx(picList));
pcMbYuv = &m_predShortYuv[refList];
- xPredInterUni(cu, partAddr, width, height, picList, pcMbYuv);
+ xPredInterUni(cu, partAddr, width, height, picList, pcMbYuv, bLuma, bChroma);
}
- xWeightedPredictionBi(cu, &m_predShortYuv[0], &m_predShortYuv[1], refIdx[0], refIdx[1], partAddr, width, height, outPredYuv);
+ xWeightedPredictionBi(cu, &m_predShortYuv[0], &m_predShortYuv[1], refIdx[0], refIdx[1], partAddr, width, height, outPredYuv, bLuma, bChroma);
}
else if (cu->getSlice()->getPPS()->getUseWP() && cu->getSlice()->getSliceType() == P_SLICE)
{
@@ -421,11 +428,12 @@
MV mv = cu->getCUMvField(picList)->getMv(partAddr);
cu->clipMv(mv);
+ if (bLuma)
+ xPredInterLumaBlk(cu, cu->getSlice()->getRefPic(picList, refId)->getPicYuvRec(), partAddr, &mv, width, height, pcMbYuv);
+ if (bChroma)
+ xPredInterChromaBlk(cu, cu->getSlice()->getRefPic(picList, refId)->getPicYuvRec(), partAddr, &mv, width, height, pcMbYuv);
- xPredInterLumaBlk(cu, cu->getSlice()->getRefPic(picList, refId)->getPicYuvRec(), partAddr, &mv, width, height, pcMbYuv);
- xPredInterChromaBlk(cu, cu->getSlice()->getRefPic(picList, refId)->getPicYuvRec(), partAddr, &mv, width, height, pcMbYuv);
-
- xWeightedPredictionUni(cu, &m_predShortYuv[0], partAddr, width, height, REF_PIC_LIST_0, outPredYuv);
+ xWeightedPredictionUni(cu, &m_predShortYuv[0], partAddr, width, height, REF_PIC_LIST_0, outPredYuv, bLuma, bChroma);
}
}
else
@@ -443,10 +451,10 @@
assert(refIdx[refList] < cu->getSlice()->getNumRefIdx(picList));
TComYuv* yuv = &m_predYuv[refList];
- xPredInterUni(cu, partAddr, width, height, picList, yuv);
+ xPredInterUni(cu, partAddr, width, height, picList, yuv, bLuma, bChroma);
}
- xWeightedAverage(&m_predYuv[0], &m_predYuv[1], refIdx[0], refIdx[1], partAddr, width, height, outPredYuv);
+ xWeightedAverage(&m_predYuv[0], &m_predYuv[1], refIdx[0], refIdx[1], partAddr, width, height, outPredYuv, bLuma, bChroma);
}
}
@@ -635,19 +643,19 @@
}
}
-void TComPrediction::xWeightedAverage(TComYuv* srcYuv0, TComYuv* srcYuv1, int refIdx0, int refIdx1, UInt partIdx, int width, int height, TComYuv*& outDstYuv)
+void TComPrediction::xWeightedAverage(TComYuv* srcYuv0, TComYuv* srcYuv1, int refIdx0, int refIdx1, UInt partIdx, int width, int height, TComYuv*& outDstYuv, bool bLuma, bool bChroma)
{
if (refIdx0 >= 0 && refIdx1 >= 0)
{
- outDstYuv->addAvg(srcYuv0, srcYuv1, partIdx, width, height);
+ outDstYuv->addAvg(srcYuv0, srcYuv1, partIdx, width, height, bLuma, bChroma);
}
else if (refIdx0 >= 0 && refIdx1 < 0)
{
- srcYuv0->copyPartToPartYuv(outDstYuv, partIdx, width, height);
+ srcYuv0->copyPartToPartYuv(outDstYuv, partIdx, width, height, bLuma, bChroma);
}
else if (refIdx0 < 0 && refIdx1 >= 0)
{
- srcYuv1->copyPartToPartYuv(outDstYuv, partIdx, width, height);
+ srcYuv1->copyPartToPartYuv(outDstYuv, partIdx, width, height, bLuma, bChroma);
}
}
diff -r 3cdbc62783e1 -r ac7aa89eae11 source/Lib/TLibCommon/TComPrediction.h
--- a/source/Lib/TLibCommon/TComPrediction.h Wed Oct 16 12:17:21 2013 +0530
+++ b/source/Lib/TLibCommon/TComPrediction.h Wed Oct 16 17:18:19 2013 +0530
@@ -83,15 +83,15 @@
int m_lumaRecStride; ///< stride of m_lumaRecBuffer
// motion compensation functions
- void xPredInterUni(TComDataCU* cu, UInt partAddr, int width, int height, RefPicList picList, TComYuv* outPredYuv);
- void xPredInterUni(TComDataCU* cu, UInt partAddr, int width, int height, RefPicList picList, TShortYUV* outPredYuv);
+ void xPredInterUni(TComDataCU* cu, UInt partAddr, int width, int height, RefPicList picList, TComYuv* outPredYuv, bool bLuma = true, bool bChroma = true);
+ void xPredInterUni(TComDataCU* cu, UInt partAddr, int width, int height, RefPicList picList, TShortYUV* outPredYuv, bool bLuma = true, bool bChroma = true);
void xPredInterLumaBlk(TComDataCU *cu, MotionReference *refPic, UInt partAddr, MV *mv, int width, int height, TComYuv *dstPic);
void xPredInterLumaBlk(TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, MV *mv, int width, int height, TShortYUV *dstPic);
void xPredInterChromaBlk(TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, MV *mv, int width, int height, TComYuv *dstPic);
void xPredInterChromaBlk(TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, MV *mv, int width, int height, TShortYUV *dstPic);
- void xPredInterBi(TComDataCU* cu, UInt partAddr, int width, int height, TComYuv*& outPredYuv);
- void xWeightedAverage(TComYuv* srcYuv0, TComYuv* srcYuv1, int refIdx0, int refIdx1, UInt partAddr, int width, int height, TComYuv*& outDstYuv);
+ void xPredInterBi(TComDataCU* cu, UInt partAddr, int width, int height, TComYuv*& outPredYuv, bool bLuma = true, bool bChroma = true);
+ void xWeightedAverage(TComYuv* srcYuv0, TComYuv* srcYuv1, int refIdx0, int refIdx1, UInt partAddr, int width, int height, TComYuv*& outDstYuv, bool bLuma = true, bool bChroma = true);
void xGetLLSPrediction(TComPattern* pcPattern, int* src0, int srcstride, Pel* dst0, int dststride, UInt width, UInt height, UInt ext0);
@@ -107,7 +107,7 @@
void initTempBuff();
// inter
- void motionCompensation(TComDataCU* cu, TComYuv* predYuv, RefPicList picList = REF_PIC_LIST_X, int partIdx = -1);
+ void motionCompensation(TComDataCU* cu, TComYuv* predYuv, RefPicList picList = REF_PIC_LIST_X, int partIdx = -1, bool bLuma = true, bool bChroma = true);
// motion vector prediction
void getMvPredAMVP(TComDataCU* cu, UInt partIdx, UInt partAddr, RefPicList picList, MV& mvPred);
diff -r 3cdbc62783e1 -r ac7aa89eae11 source/Lib/TLibCommon/TComWeightPrediction.cpp
--- a/source/Lib/TLibCommon/TComWeightPrediction.cpp Wed Oct 16 12:17:21 2013 +0530
+++ b/source/Lib/TLibCommon/TComWeightPrediction.cpp Wed Oct 16 17:18:19 2013 +0530
@@ -80,7 +80,7 @@
* \param TComYuv* outDstYuv
* \returns void
*/
-void TComWeightPrediction::addWeightBi(TComYuv* srcYuv0, TComYuv* srcYuv1, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* outDstYuv, bool bRound)
+void TComWeightPrediction::addWeightBi(TComYuv* srcYuv0, TComYuv* srcYuv1, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* outDstYuv, bool bRound, bool bLuma, bool bChroma)
{
int x, y;
@@ -96,90 +96,96 @@
Pel* dstU = outDstYuv->getCbAddr(partUnitIdx);
Pel* dstV = outDstYuv->getCrAddr(partUnitIdx);
- // Luma : --------------------------------------------
- int w0 = wp0[0].w;
- int offset = wp0[0].offset;
- int shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
- int shift = wp0[0].shift + shiftNum;
- int round = shift ? (1 << (shift - 1)) * bRound : 0;
- int w1 = wp1[0].w;
+ if (bLuma)
+ {
+ // Luma : --------------------------------------------
+ int w0 = wp0[0].w;
+ int offset = wp0[0].offset;
+ int shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
+ int shift = wp0[0].shift + shiftNum;
+ int round = shift ? (1 << (shift - 1)) * bRound : 0;
+ int w1 = wp1[0].w;
- UInt src0Stride = srcYuv0->getStride();
- UInt src1Stride = srcYuv1->getStride();
- UInt dststride = outDstYuv->getStride();
+ UInt src0Stride = srcYuv0->getStride();
+ UInt src1Stride = srcYuv1->getStride();
+ UInt dststride = outDstYuv->getStride();
- for (y = height - 1; y >= 0; y--)
+ for (y = height - 1; y >= 0; y--)
+ {
+ for (x = width - 1; x >= 0; )
+ {
+ // note: luma min width is 4
+ pDstY[x] = weightBidirY(w0, srcY0[x], w1, srcY1[x], round, shift, offset);
+ x--;
+ pDstY[x] = weightBidirY(w0, srcY0[x], w1, srcY1[x], round, shift, offset);
+ x--;
+ pDstY[x] = weightBidirY(w0, srcY0[x], w1, srcY1[x], round, shift, offset);
+ x--;
+ pDstY[x] = weightBidirY(w0, srcY0[x], w1, srcY1[x], round, shift, offset);
+ x--;
+ }
+
+ srcY0 += src0Stride;
+ srcY1 += src1Stride;
+ pDstY += dststride;
+ }
+ }
+
+ if (bChroma)
{
- for (x = width - 1; x >= 0; )
+ // Chroma U : --------------------------------------------
+ int w0 = wp0[1].w;
+ int offset = wp0[1].offset;
+ int shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
+ int shift = wp0[1].shift + shiftNum;
+ int round = shift ? (1 << (shift - 1)) : 0;
+ int w1 = wp1[1].w;
+
+ UInt src0Stride = srcYuv0->getCStride();
+ UInt src1Stride = srcYuv1->getCStride();
+ UInt dststride = outDstYuv->getCStride();
+
+ width >>= 1;
+ height >>= 1;
+
+ for (y = height - 1; y >= 0; y--)
{
- // note: luma min width is 4
- pDstY[x] = weightBidirY(w0, srcY0[x], w1, srcY1[x], round, shift, offset);
- x--;
- pDstY[x] = weightBidirY(w0, srcY0[x], w1, srcY1[x], round, shift, offset);
- x--;
- pDstY[x] = weightBidirY(w0, srcY0[x], w1, srcY1[x], round, shift, offset);
- x--;
- pDstY[x] = weightBidirY(w0, srcY0[x], w1, srcY1[x], round, shift, offset);
- x--;
+ for (x = width - 1; x >= 0; )
+ {
+ // note: chroma min width is 2
+ dstU[x] = weightBidirC(w0, srcU0[x], w1, srcU1[x], round, shift, offset);
+ x--;
+ dstU[x] = weightBidirC(w0, srcU0[x], w1, srcU1[x], round, shift, offset);
+ x--;
+ }
+
+ srcU0 += src0Stride;
+ srcU1 += src1Stride;
+ dstU += dststride;
}
- srcY0 += src0Stride;
- srcY1 += src1Stride;
- pDstY += dststride;
- }
+ // Chroma V : --------------------------------------------
+ w0 = wp0[2].w;
+ offset = wp0[2].offset;
+ shift = wp0[2].shift + shiftNum;
+ round = shift ? (1 << (shift - 1)) : 0;
+ w1 = wp1[2].w;
- // Chroma U : --------------------------------------------
- w0 = wp0[1].w;
- offset = wp0[1].offset;
- shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
- shift = wp0[1].shift + shiftNum;
- round = shift ? (1 << (shift - 1)) : 0;
- w1 = wp1[1].w;
+ for (y = height - 1; y >= 0; y--)
+ {
+ for (x = width - 1; x >= 0; )
+ {
+ // note: chroma min width is 2
+ dstV[x] = weightBidirC(w0, srcV0[x], w1, srcV1[x], round, shift, offset);
+ x--;
+ dstV[x] = weightBidirC(w0, srcV0[x], w1, srcV1[x], round, shift, offset);
+ x--;
+ }
- src0Stride = srcYuv0->getCStride();
- src1Stride = srcYuv1->getCStride();
- dststride = outDstYuv->getCStride();
-
- width >>= 1;
- height >>= 1;
-
- for (y = height - 1; y >= 0; y--)
- {
- for (x = width - 1; x >= 0; )
- {
- // note: chroma min width is 2
- dstU[x] = weightBidirC(w0, srcU0[x], w1, srcU1[x], round, shift, offset);
- x--;
- dstU[x] = weightBidirC(w0, srcU0[x], w1, srcU1[x], round, shift, offset);
- x--;
+ srcV0 += src0Stride;
+ srcV1 += src1Stride;
+ dstV += dststride;
}
-
- srcU0 += src0Stride;
- srcU1 += src1Stride;
- dstU += dststride;
- }
-
- // Chroma V : --------------------------------------------
- w0 = wp0[2].w;
- offset = wp0[2].offset;
- shift = wp0[2].shift + shiftNum;
- round = shift ? (1 << (shift - 1)) : 0;
- w1 = wp1[2].w;
-
- for (y = height - 1; y >= 0; y--)
- {
- for (x = width - 1; x >= 0; )
- {
- // note: chroma min width is 2
- dstV[x] = weightBidirC(w0, srcV0[x], w1, srcV1[x], round, shift, offset);
- x--;
- dstV[x] = weightBidirC(w0, srcV0[x], w1, srcV1[x], round, shift, offset);
- x--;
- }
-
- srcV0 += src0Stride;
- srcV1 += src1Stride;
- dstV += dststride;
}
}
@@ -194,10 +200,13 @@
* \param TComYuv* outDstYuv
* \returns void
*/
-void TComWeightPrediction::addWeightBi(TShortYUV* srcYuv0, TShortYUV* srcYuv1, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* outDstYuv, bool bRound)
+void TComWeightPrediction::addWeightBi(TShortYUV* srcYuv0, TShortYUV* srcYuv1, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* outDstYuv, bool bRound, bool bLuma, bool bChroma)
{
int x, y;
+ int w0,w1, offset, shiftNum, shift, round;
+ UInt src0Stride, src1Stride, dststride;
+
short* srcY0 = srcYuv0->getLumaAddr(partUnitIdx);
short* srcU0 = srcYuv0->getCbAddr(partUnitIdx);
short* srcV0 = srcYuv0->getCrAddr(partUnitIdx);
@@ -210,90 +219,96 @@
Pel* dstU = outDstYuv->getCbAddr(partUnitIdx);
Pel* dstV = outDstYuv->getCrAddr(partUnitIdx);
- // Luma : --------------------------------------------
- int w0 = wp0[0].w;
- int offset = wp0[0].offset;
- int shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
- int shift = wp0[0].shift + shiftNum;
- int round = shift ? (1 << (shift - 1)) * bRound : 0;
- int w1 = wp1[0].w;
+ if (bLuma)
+ {
+ // Luma : --------------------------------------------
+ w0 = wp0[0].w;
+ offset = wp0[0].offset;
+ shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
+ shift = wp0[0].shift + shiftNum;
+ round = shift ? (1 << (shift - 1)) * bRound : 0;
+ w1 = wp1[0].w;
- UInt src0Stride = srcYuv0->m_width;
- UInt src1Stride = srcYuv1->m_width;
- UInt dststride = outDstYuv->getStride();
+ src0Stride = srcYuv0->m_width;
+ src1Stride = srcYuv1->m_width;
+ dststride = outDstYuv->getStride();
- for (y = height - 1; y >= 0; y--)
+ for (y = height - 1; y >= 0; y--)
+ {
+ for (x = width - 1; x >= 0; )
+ {
+ // note: luma min width is 4
+ dstY[x] = weightBidirY(w0, srcY0[x], w1, srcY1[x], round, shift, offset);
+ x--;
+ dstY[x] = weightBidirY(w0, srcY0[x], w1, srcY1[x], round, shift, offset);
+ x--;
+ dstY[x] = weightBidirY(w0, srcY0[x], w1, srcY1[x], round, shift, offset);
+ x--;
+ dstY[x] = weightBidirY(w0, srcY0[x], w1, srcY1[x], round, shift, offset);
+ x--;
+ }
+
+ srcY0 += src0Stride;
+ srcY1 += src1Stride;
+ dstY += dststride;
+ }
+ }
+
+ if (bChroma)
{
- for (x = width - 1; x >= 0; )
+ // Chroma U : --------------------------------------------
+ w0 = wp0[1].w;
+ offset = wp0[1].offset;
+ shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
+ shift = wp0[1].shift + shiftNum;
+ round = shift ? (1 << (shift - 1)) : 0;
+ w1 = wp1[1].w;
+
+ src0Stride = srcYuv0->m_cwidth;
+ src1Stride = srcYuv1->m_cwidth;
+ dststride = outDstYuv->getCStride();
+
+ width >>= 1;
+ height >>= 1;
+
+ for (y = height - 1; y >= 0; y--)
{
- // note: luma min width is 4
- dstY[x] = weightBidirY(w0, srcY0[x], w1, srcY1[x], round, shift, offset);
- x--;
- dstY[x] = weightBidirY(w0, srcY0[x], w1, srcY1[x], round, shift, offset);
- x--;
- dstY[x] = weightBidirY(w0, srcY0[x], w1, srcY1[x], round, shift, offset);
- x--;
- dstY[x] = weightBidirY(w0, srcY0[x], w1, srcY1[x], round, shift, offset);
- x--;
+ for (x = width - 1; x >= 0; )
+ {
+ // note: chroma min width is 2
+ dstU[x] = weightBidirC(w0, srcU0[x], w1, srcU1[x], round, shift, offset);
+ x--;
+ dstU[x] = weightBidirC(w0, srcU0[x], w1, srcU1[x], round, shift, offset);
+ x--;
+ }
+
+ srcU0 += src0Stride;
+ srcU1 += src1Stride;
+ dstU += dststride;
}
- srcY0 += src0Stride;
- srcY1 += src1Stride;
- dstY += dststride;
- }
+ // Chroma V : --------------------------------------------
+ w0 = wp0[2].w;
+ offset = wp0[2].offset;
+ shift = wp0[2].shift + shiftNum;
+ round = shift ? (1 << (shift - 1)) : 0;
+ w1 = wp1[2].w;
- // Chroma U : --------------------------------------------
- w0 = wp0[1].w;
- offset = wp0[1].offset;
- shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
- shift = wp0[1].shift + shiftNum;
- round = shift ? (1 << (shift - 1)) : 0;
- w1 = wp1[1].w;
+ for (y = height - 1; y >= 0; y--)
+ {
+ for (x = width - 1; x >= 0; )
+ {
+ // note: chroma min width is 2
+ dstV[x] = weightBidirC(w0, srcV0[x], w1, srcV1[x], round, shift, offset);
+ x--;
+ dstV[x] = weightBidirC(w0, srcV0[x], w1, srcV1[x], round, shift, offset);
+ x--;
+ }
- src0Stride = srcYuv0->m_cwidth;
- src1Stride = srcYuv1->m_cwidth;
- dststride = outDstYuv->getCStride();
-
- width >>= 1;
- height >>= 1;
-
- for (y = height - 1; y >= 0; y--)
- {
- for (x = width - 1; x >= 0; )
- {
- // note: chroma min width is 2
- dstU[x] = weightBidirC(w0, srcU0[x], w1, srcU1[x], round, shift, offset);
- x--;
- dstU[x] = weightBidirC(w0, srcU0[x], w1, srcU1[x], round, shift, offset);
- x--;
+ srcV0 += src0Stride;
+ srcV1 += src1Stride;
+ dstV += dststride;
}
-
- srcU0 += src0Stride;
- srcU1 += src1Stride;
- dstU += dststride;
- }
-
- // Chroma V : --------------------------------------------
- w0 = wp0[2].w;
- offset = wp0[2].offset;
- shift = wp0[2].shift + shiftNum;
- round = shift ? (1 << (shift - 1)) : 0;
- w1 = wp1[2].w;
-
- for (y = height - 1; y >= 0; y--)
- {
- for (x = width - 1; x >= 0; )
- {
- // note: chroma min width is 2
- dstV[x] = weightBidirC(w0, srcV0[x], w1, srcV1[x], round, shift, offset);
- x--;
- dstV[x] = weightBidirC(w0, srcV0[x], w1, srcV1[x], round, shift, offset);
- x--;
- }
-
- srcV0 += src0Stride;
- srcV1 += src1Stride;
- dstV += dststride;
}
}
@@ -306,10 +321,13 @@
* \param TComYuv* outDstYuv
* \returns void
*/
-void TComWeightPrediction::addWeightUni(TComYuv* srcYuv0, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, TComYuv* outDstYuv)
+void TComWeightPrediction::addWeightUni(TComYuv* srcYuv0, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, TComYuv* outDstYuv, bool bLuma, bool bChroma)
{
int x, y;
+ int w0, offset, shiftNum, shift, round;
+ UInt src0Stride, dststride;
+
Pel* srcY0 = srcYuv0->getLumaAddr(partUnitIdx);
Pel* srcU0 = srcYuv0->getCbAddr(partUnitIdx);
Pel* srcV0 = srcYuv0->getCrAddr(partUnitIdx);
@@ -318,81 +336,87 @@
Pel* dstU = outDstYuv->getCbAddr(partUnitIdx);
Pel* dstV = outDstYuv->getCrAddr(partUnitIdx);
- // Luma : --------------------------------------------
- int w0 = wp0[0].w;
- int offset = wp0[0].offset;
- int shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
- int shift = wp0[0].shift + shiftNum;
- int round = shift ? (1 << (shift - 1)) : 0;
- UInt src0Stride = srcYuv0->getStride();
- UInt dststride = outDstYuv->getStride();
+ if (bLuma)
+ {
+ // Luma : --------------------------------------------
+ w0 = wp0[0].w;
+ offset = wp0[0].offset;
+ shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
+ shift = wp0[0].shift + shiftNum;
+ round = shift ? (1 << (shift - 1)) : 0;
+ src0Stride = srcYuv0->getStride();
+ dststride = outDstYuv->getStride();
- for (y = height - 1; y >= 0; y--)
+ for (y = height - 1; y >= 0; y--)
+ {
+ for (x = width - 1; x >= 0; )
+ {
+ // note: luma min width is 4
+ dstY[x] = weightUnidirY(w0, srcY0[x], round, shift, offset);
+ x--;
+ dstY[x] = weightUnidirY(w0, srcY0[x], round, shift, offset);
+ x--;
+ dstY[x] = weightUnidirY(w0, srcY0[x], round, shift, offset);
+ x--;
+ dstY[x] = weightUnidirY(w0, srcY0[x], round, shift, offset);
+ x--;
+ }
+
+ srcY0 += src0Stride;
+ dstY += dststride;
+ }
+ }
+
+ if (bChroma)
{
- for (x = width - 1; x >= 0; )
+ // Chroma U : --------------------------------------------
+ w0 = wp0[1].w;
+ offset = wp0[1].offset;
+ shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
+ shift = wp0[1].shift + shiftNum;
+ round = shift ? (1 << (shift - 1)) : 0;
+
+ src0Stride = srcYuv0->getCStride();
+ dststride = outDstYuv->getCStride();
+
+ width >>= 1;
+ height >>= 1;
+
+ for (y = height - 1; y >= 0; y--)
{
- // note: luma min width is 4
- dstY[x] = weightUnidirY(w0, srcY0[x], round, shift, offset);
- x--;
- dstY[x] = weightUnidirY(w0, srcY0[x], round, shift, offset);
- x--;
- dstY[x] = weightUnidirY(w0, srcY0[x], round, shift, offset);
- x--;
- dstY[x] = weightUnidirY(w0, srcY0[x], round, shift, offset);
- x--;
+ for (x = width - 1; x >= 0; )
+ {
+ // note: chroma min width is 2
+ dstU[x] = weightUnidirC(w0, srcU0[x], round, shift, offset);
+ x--;
+ dstU[x] = weightUnidirC(w0, srcU0[x], round, shift, offset);
+ x--;
+ }
+
+ srcU0 += src0Stride;
+ dstU += dststride;
}
- srcY0 += src0Stride;
- dstY += dststride;
- }
+ // Chroma V : --------------------------------------------
+ w0 = wp0[2].w;
+ offset = wp0[2].offset;
+ shift = wp0[2].shift + shiftNum;
+ round = shift ? (1 << (shift - 1)) : 0;
- // Chroma U : --------------------------------------------
- w0 = wp0[1].w;
- offset = wp0[1].offset;
- shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
- shift = wp0[1].shift + shiftNum;
- round = shift ? (1 << (shift - 1)) : 0;
+ for (y = height - 1; y >= 0; y--)
+ {
+ for (x = width - 1; x >= 0; )
+ {
+ // note: chroma min width is 2
+ dstV[x] = weightUnidirC(w0, srcV0[x], round, shift, offset);
+ x--;
+ dstV[x] = weightUnidirC(w0, srcV0[x], round, shift, offset);
+ x--;
+ }
- src0Stride = srcYuv0->getCStride();
- dststride = outDstYuv->getCStride();
-
- width >>= 1;
- height >>= 1;
-
- for (y = height - 1; y >= 0; y--)
- {
- for (x = width - 1; x >= 0; )
- {
- // note: chroma min width is 2
- dstU[x] = weightUnidirC(w0, srcU0[x], round, shift, offset);
- x--;
- dstU[x] = weightUnidirC(w0, srcU0[x], round, shift, offset);
- x--;
+ srcV0 += src0Stride;
+ dstV += dststride;
}
-
- srcU0 += src0Stride;
- dstU += dststride;
- }
-
- // Chroma V : --------------------------------------------
- w0 = wp0[2].w;
- offset = wp0[2].offset;
- shift = wp0[2].shift + shiftNum;
- round = shift ? (1 << (shift - 1)) : 0;
-
- for (y = height - 1; y >= 0; y--)
- {
- for (x = width - 1; x >= 0; )
- {
- // note: chroma min width is 2
- dstV[x] = weightUnidirC(w0, srcV0[x], round, shift, offset);
- x--;
- dstV[x] = weightUnidirC(w0, srcV0[x], round, shift, offset);
- x--;
- }
-
- srcV0 += src0Stride;
- dstV += dststride;
}
}
@@ -406,7 +430,7 @@
* \returns void
*/
-void TComWeightPrediction::addWeightUni(TShortYUV* srcYuv0, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, TComYuv* outDstYuv, bool justChroma)
+void TComWeightPrediction::addWeightUni(TShortYUV* srcYuv0, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, TComYuv* outDstYuv, bool bLuma, bool bChroma)
{
short* srcY0 = srcYuv0->getLumaAddr(partUnitIdx);
short* srcU0 = srcYuv0->getCbAddr(partUnitIdx);
@@ -420,7 +444,7 @@
int w0, offset, shiftNum, shift, round;
UInt srcStride, dstStride;
- if(!justChroma)
+ if (bLuma)
{
// Luma : --------------------------------------------
w0 = wp0[0].w;
@@ -434,28 +458,31 @@
primitives.weightpUni((int16_t *)srcY0, dstY, srcStride, dstStride, width, height, w0, round, shift, offset);
}
- // Chroma U : --------------------------------------------
- w0 = wp0[1].w;
- offset = wp0[1].offset;
- shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
- shift = wp0[1].shift + shiftNum;
- round = shift ? (1 << (shift - 1)) : 0;
+ if (bChroma)
+ {
+ // Chroma U : --------------------------------------------
+ w0 = wp0[1].w;
+ offset = wp0[1].offset;
+ shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
+ shift = wp0[1].shift + shiftNum;
+ round = shift ? (1 << (shift - 1)) : 0;
- srcStride = srcYuv0->m_cwidth;
- dstStride = outDstYuv->getCStride();
+ srcStride = srcYuv0->m_cwidth;
+ dstStride = outDstYuv->getCStride();
- width >>= 1;
- height >>= 1;
+ width >>= 1;
+ height >>= 1;
- primitives.weightpUni((int16_t *)srcU0, dstU, srcStride, dstStride, width, height, w0, round, shift, offset);
+ primitives.weightpUni((int16_t *)srcU0, dstU, srcStride, dstStride, width, height, w0, round, shift, offset);
- // Chroma V : --------------------------------------------
- w0 = wp0[2].w;
- offset = wp0[2].offset;
- shift = wp0[2].shift + shiftNum;
- round = shift ? (1 << (shift - 1)) : 0;
+ // Chroma V : --------------------------------------------
+ w0 = wp0[2].w;
+ offset = wp0[2].offset;
+ shift = wp0[2].shift + shiftNum;
+ round = shift ? (1 << (shift - 1)) : 0;
- primitives.weightpUni((int16_t *)srcV0, dstV, srcStride, dstStride, width, height, w0, round, shift, offset);
+ primitives.weightpUni((int16_t *)srcV0, dstV, srcStride, dstStride, width, height, w0, round, shift, offset);
+ }
}
//=======================================================
@@ -546,7 +573,7 @@
* \param TComYuv* outDstYuv
* \returns void
*/
-void TComWeightPrediction::xWeightedPredictionBi(TComDataCU* cu, TComYuv* srcYuv0, TComYuv* srcYuv1, int refIdx0, int refIdx1, UInt partIdx, int width, int height, TComYuv* outDstYuv)
+void TComWeightPrediction::xWeightedPredictionBi(TComDataCU* cu, TComYuv* srcYuv0, TComYuv* srcYuv1, int refIdx0, int refIdx1, UInt partIdx, int width, int height, TComYuv* outDstYuv, bool bLuma, bool bChroma)
{
wpScalingParam *pwp0, *pwp1;
@@ -554,15 +581,15 @@
if (refIdx0 >= 0 && refIdx1 >= 0)
{
- addWeightBi(srcYuv0, srcYuv1, partIdx, width, height, pwp0, pwp1, outDstYuv);
+ addWeightBi(srcYuv0, srcYuv1, partIdx, width, height, pwp0, pwp1, outDstYuv, bLuma, bChroma);
}
else if (refIdx0 >= 0 && refIdx1 < 0)
{
- addWeightUni(srcYuv0, partIdx, width, height, pwp0, outDstYuv);
+ addWeightUni(srcYuv0, partIdx, width, height, pwp0, outDstYuv, bLuma, bChroma);
}
else if (refIdx0 < 0 && refIdx1 >= 0)
{
- addWeightUni(srcYuv1, partIdx, width, height, pwp1, outDstYuv);
+ addWeightUni(srcYuv1, partIdx, width, height, pwp1, outDstYuv, bLuma, bChroma);
}
else
{
@@ -582,7 +609,7 @@
* \param TComYuv* outDstYuv
* \returns void
*/
-void TComWeightPrediction::xWeightedPredictionBi(TComDataCU* cu, TShortYUV* srcYuv0, TShortYUV* srcYuv1, int refIdx0, int refIdx1, UInt partIdx, int width, int height, TComYuv* outDstYuv)
+void TComWeightPrediction::xWeightedPredictionBi(TComDataCU* cu, TShortYUV* srcYuv0, TShortYUV* srcYuv1, int refIdx0, int refIdx1, UInt partIdx, int width, int height, TComYuv* outDstYuv, bool bLuma, bool bChroma)
{
wpScalingParam *pwp0, *pwp1;
@@ -590,15 +617,15 @@
if (refIdx0 >= 0 && refIdx1 >= 0)
{
- addWeightBi(srcYuv0, srcYuv1, partIdx, width, height, pwp0, pwp1, outDstYuv);
+ addWeightBi(srcYuv0, srcYuv1, partIdx, width, height, pwp0, pwp1, outDstYuv, bLuma, bChroma);
}
else if (refIdx0 >= 0 && refIdx1 < 0)
{
- addWeightUni(srcYuv0, partIdx, width, height, pwp0, outDstYuv);
+ addWeightUni(srcYuv0, partIdx, width, height, pwp0, outDstYuv, bLuma, bChroma);
}
else if (refIdx0 < 0 && refIdx1 >= 0)
{
- addWeightUni(srcYuv1, partIdx, width, height, pwp1, outDstYuv);
+ addWeightUni(srcYuv1, partIdx, width, height, pwp1, outDstYuv, bLuma, bChroma);
}
else
{
@@ -618,7 +645,7 @@
* \param refIdx
* \returns void
*/
-void TComWeightPrediction::xWeightedPredictionUni(TComDataCU* cu, TComYuv* srcYuv, UInt partAddr, int width, int height, RefPicList picList, TComYuv*& outPredYuv, int refIdx)
+void TComWeightPrediction::xWeightedPredictionUni(TComDataCU* cu, TComYuv* srcYuv, UInt partAddr, int width, int height, RefPicList picList, TComYuv*& outPredYuv, int refIdx, bool bLuma, bool bChroma)
{
wpScalingParam *pwp, *pwpTmp;
@@ -636,7 +663,7 @@
{
getWpScaling(cu, -1, refIdx, pwpTmp, pwp);
}
- addWeightUni(srcYuv, partAddr, width, height, pwp, outPredYuv);
+ addWeightUni(srcYuv, partAddr, width, height, pwp, outPredYuv, bLuma, bChroma);
}
/** weighted prediction for uni-pred
@@ -651,7 +678,7 @@
* \param refIdx
* \returns void
*/
-void TComWeightPrediction::xWeightedPredictionUni(TComDataCU* cu, TShortYUV* srcYuv, UInt partAddr, int width, int height, RefPicList picList, TComYuv*& outPredYuv, int refIdx)
+void TComWeightPrediction::xWeightedPredictionUni(TComDataCU* cu, TShortYUV* srcYuv, UInt partAddr, int width, int height, RefPicList picList, TComYuv*& outPredYuv, int refIdx, bool bLuma, bool bChroma)
{
wpScalingParam *pwp, *pwpTmp;
@@ -669,5 +696,5 @@
{
getWpScaling(cu, -1, refIdx, pwpTmp, pwp);
}
- addWeightUni(srcYuv, partAddr, width, height, pwp, outPredYuv);
+ addWeightUni(srcYuv, partAddr, width, height, pwp, outPredYuv, bLuma, bChroma);
}
diff -r 3cdbc62783e1 -r ac7aa89eae11 source/Lib/TLibCommon/TComWeightPrediction.h
--- a/source/Lib/TLibCommon/TComWeightPrediction.h Wed Oct 16 12:17:21 2013 +0530
+++ b/source/Lib/TLibCommon/TComWeightPrediction.h Wed Oct 16 17:18:19 2013 +0530
@@ -60,15 +60,15 @@
void getWpScaling(TComDataCU* cu, int refIdx0, int refIdx1, wpScalingParam *&wp0, wpScalingParam *&wp1);
- void addWeightBi(TComYuv* srcYuv0, TComYuv* srcYuv1, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* outDstYuv, bool bRound = true);
- void addWeightBi(TShortYUV* srcYuv0, TShortYUV* srcYuv1, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* outDstYuv, bool bRound = true);
- void addWeightUni(TComYuv* srcYuv0, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, TComYuv* outDstYuv);
- void addWeightUni(TShortYUV* srcYuv0, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, TComYuv* outDstYuv, bool justChroma = false);
+ void addWeightBi(TComYuv* srcYuv0, TComYuv* srcYuv1, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* outDstYuv, bool bRound = true, bool bLuma = true, bool bChroma = true);
+ void addWeightBi(TShortYUV* srcYuv0, TShortYUV* srcYuv1, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* outDstYuv, bool bRound = true, bool bLuma = true, bool bChroma = true);
+ void addWeightUni(TComYuv* srcYuv0, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, TComYuv* outDstYuv, bool bLuma = true, bool bChroma = true);
+ void addWeightUni(TShortYUV* srcYuv0, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, TComYuv* outDstYuv, bool bLuma = true, bool bChroma = true);
- void xWeightedPredictionUni(TComDataCU* cu, TComYuv* srcYuv, UInt partAddr, int width, int height, RefPicList picList, TComYuv*& outPredYuv, int refIdx = -1);
- void xWeightedPredictionUni(TComDataCU* cu, TShortYUV* srcYuv, UInt partAddr, int width, int height, RefPicList picList, TComYuv*& outPredYuv, int refIdx = -1);
- void xWeightedPredictionBi(TComDataCU* cu, TComYuv* srcYuv0, TComYuv* srcYuv1, int refIdx0, int refIdx1, UInt partIdx, int width, int height, TComYuv* outDstYuv);
- void xWeightedPredictionBi(TComDataCU* cu, TShortYUV* srcYuv0, TShortYUV* srcYuv1, int refIdx0, int refIdx1, UInt partIdx, int width, int height, TComYuv* outDstYuv);
+ void xWeightedPredictionUni(TComDataCU* cu, TComYuv* srcYuv, UInt partAddr, int width, int height, RefPicList picList, TComYuv*& outPredYuv, int refIdx = -1, bool bLuma = true, bool bChroma = true);
+ void xWeightedPredictionUni(TComDataCU* cu, TShortYUV* srcYuv, UInt partAddr, int width, int height, RefPicList picList, TComYuv*& outPredYuv, int refIdx = -1, bool bLuma = true, bool bChroma = true);
+ void xWeightedPredictionBi(TComDataCU* cu, TComYuv* srcYuv0, TComYuv* srcYuv1, int refIdx0, int refIdx1, UInt partIdx, int width, int height, TComYuv* outDstYuv, bool bLuma = true, bool bChroma = true);
+ void xWeightedPredictionBi(TComDataCU* cu, TShortYUV* srcYuv0, TShortYUV* srcYuv1, int refIdx0, int refIdx1, UInt partIdx, int width, int height, TComYuv* outDstYuv, bool bLuma = true, bool bChroma = true);
};
}
diff -r 3cdbc62783e1 -r ac7aa89eae11 source/Lib/TLibCommon/TComYuv.cpp
--- a/source/Lib/TLibCommon/TComYuv.cpp Wed Oct 16 12:17:21 2013 +0530
+++ b/source/Lib/TLibCommon/TComYuv.cpp Wed Oct 16 17:18:19 2013 +0530
@@ -234,16 +234,20 @@
primitives.blockcpy_pp(uiCWidth, uiCHeight, dstV, dststride, srcV, srcstride);
}
-void TComYuv::copyPartToPartYuv(TComYuv* dstPicYuv, UInt partIdx, UInt width, UInt height)
+void TComYuv::copyPartToPartYuv(TComYuv* dstPicYuv, UInt partIdx, UInt width, UInt height, bool bLuma, bool bChroma)
{
- copyPartToPartLuma(dstPicYuv, partIdx, width, height);
- copyPartToPartChroma(dstPicYuv, partIdx, width >> 1, height >> 1);
+ if(bLuma)
+ copyPartToPartLuma(dstPicYuv, partIdx, width, height);
+ if(bChroma)
+ copyPartToPartChroma(dstPicYuv, partIdx, width >> 1, height >> 1);
}
-void TComYuv::copyPartToPartYuv(TShortYUV* dstPicYuv, UInt partIdx, UInt width, UInt height)
+void TComYuv::copyPartToPartYuv(TShortYUV* dstPicYuv, UInt partIdx, UInt width, UInt height, bool bLuma, bool bChroma)
{
- copyPartToPartLuma(dstPicYuv, partIdx, width, height);
- copyPartToPartChroma(dstPicYuv, partIdx, width >> 1, height >> 1);
+ if(bLuma)
+ copyPartToPartLuma(dstPicYuv, partIdx, width, height);
+ if(bChroma)
+ copyPartToPartChroma(dstPicYuv, partIdx, width >> 1, height >> 1);
}
void TComYuv::copyPartToPartLuma(TComYuv* dstPicYuv, UInt partIdx, UInt width, UInt height)
@@ -529,9 +533,11 @@
}
}
-void TComYuv::addAvg(TComYuv* srcYuv0, TComYuv* srcYuv1, UInt partUnitIdx, UInt width, UInt height)
+void TComYuv::addAvg(TComYuv* srcYuv0, TComYuv* srcYuv1, UInt partUnitIdx, UInt width, UInt height, bool bLuma, bool bChroma)
{
int x, y;
+ UInt src0Stride, src1Stride, dststride;
+ int shiftNum, offset;
Pel* srcY0 = srcYuv0->getLumaAddr(partUnitIdx);
Pel* srcU0 = srcYuv0->getCbAddr(partUnitIdx);
@@ -545,62 +551,69 @@
Pel* dstU = getCbAddr(partUnitIdx);
Pel* dstV = getCrAddr(partUnitIdx);
- UInt src0Stride = srcYuv0->getStride();
- UInt src1Stride = srcYuv1->getStride();
- UInt dststride = getStride();
- int shiftNum = IF_INTERNAL_PREC + 1 - X265_DEPTH;
- int offset = (1 << (shiftNum - 1)) + 2 * IF_INTERNAL_OFFS;
+ if(bLuma)
+ {
+ src0Stride = srcYuv0->getStride();
+ src1Stride = srcYuv1->getStride();
+ dststride = getStride();
+ shiftNum = IF_INTERNAL_PREC + 1 - X265_DEPTH;
+ offset = (1 << (shiftNum - 1)) + 2 * IF_INTERNAL_OFFS;
- for (y = 0; y < height; y++)
+ for (y = 0; y < height; y++)
+ {
+ for (x = 0; x < width; x += 4)
+ {
+ dstY[x + 0] = ClipY((srcY0[x + 0] + srcY1[x + 0] + offset) >> shiftNum);
+ dstY[x + 1] = ClipY((srcY0[x + 1] + srcY1[x + 1] + offset) >> shiftNum);
+ dstY[x + 2] = ClipY((srcY0[x + 2] + srcY1[x + 2] + offset) >> shiftNum);
+ dstY[x + 3] = ClipY((srcY0[x + 3] + srcY1[x + 3] + offset) >> shiftNum);
+ }
+
+ srcY0 += src0Stride;
+ srcY1 += src1Stride;
+ dstY += dststride;
+ }
+ }
+ if(bChroma)
{
- for (x = 0; x < width; x += 4)
+ shiftNum = IF_INTERNAL_PREC + 1 - X265_DEPTH;
+ offset = (1 << (shiftNum - 1)) + 2 * IF_INTERNAL_OFFS;
+
+ src0Stride = srcYuv0->getCStride();
+ src1Stride = srcYuv1->getCStride();
+ dststride = getCStride();
+
+ width >>= 1;
+ height >>= 1;
+
+ for (y = height - 1; y >= 0; y--)
{
- dstY[x + 0] = ClipY((srcY0[x + 0] + srcY1[x + 0] + offset) >> shiftNum);
- dstY[x + 1] = ClipY((srcY0[x + 1] + srcY1[x + 1] + offset) >> shiftNum);
- dstY[x + 2] = ClipY((srcY0[x + 2] + srcY1[x + 2] + offset) >> shiftNum);
- dstY[x + 3] = ClipY((srcY0[x + 3] + srcY1[x + 3] + offset) >> shiftNum);
+ for (x = width - 1; x >= 0; )
+ {
+ // note: chroma min width is 2
+ dstU[x] = ClipC((srcU0[x] + srcU1[x] + offset) >> shiftNum);
+ dstV[x] = ClipC((srcV0[x] + srcV1[x] + offset) >> shiftNum);
+ x--;
+ dstU[x] = ClipC((srcU0[x] + srcU1[x] + offset) >> shiftNum);
+ dstV[x] = ClipC((srcV0[x] + srcV1[x] + offset) >> shiftNum);
+ x--;
+ }
+
+ srcU0 += src0Stride;
+ srcU1 += src1Stride;
+ srcV0 += src0Stride;
+ srcV1 += src1Stride;
+ dstU += dststride;
+ dstV += dststride;
}
-
- srcY0 += src0Stride;
- srcY1 += src1Stride;
- dstY += dststride;
- }
-
- shiftNum = IF_INTERNAL_PREC + 1 - X265_DEPTH;
- offset = (1 << (shiftNum - 1)) + 2 * IF_INTERNAL_OFFS;
-
- src0Stride = srcYuv0->getCStride();
- src1Stride = srcYuv1->getCStride();
- dststride = getCStride();
-
- width >>= 1;
- height >>= 1;
-
- for (y = height - 1; y >= 0; y--)
- {
- for (x = width - 1; x >= 0; )
- {
- // note: chroma min width is 2
- dstU[x] = ClipC((srcU0[x] + srcU1[x] + offset) >> shiftNum);
- dstV[x] = ClipC((srcV0[x] + srcV1[x] + offset) >> shiftNum);
- x--;
- dstU[x] = ClipC((srcU0[x] + srcU1[x] + offset) >> shiftNum);
- dstV[x] = ClipC((srcV0[x] + srcV1[x] + offset) >> shiftNum);
- x--;
- }
-
- srcU0 += src0Stride;
- srcU1 += src1Stride;
- srcV0 += src0Stride;
- srcV1 += src1Stride;
- dstU += dststride;
- dstV += dststride;
}
}
-void TComYuv::addAvg(TShortYUV* srcYuv0, TShortYUV* srcYuv1, UInt partUnitIdx, UInt width, UInt height)
+void TComYuv::addAvg(TShortYUV* srcYuv0, TShortYUV* srcYuv1, UInt partUnitIdx, UInt width, UInt height, bool bLuma, bool bChroma)
{
int x, y;
+ UInt src0Stride, src1Stride, dststride;
+ int shiftNum, offset;
short* srcY0 = srcYuv0->getLumaAddr(partUnitIdx);
short* srcU0 = srcYuv0->getCbAddr(partUnitIdx);
@@ -614,56 +627,61 @@
Pel* dstU = getCbAddr(partUnitIdx);
Pel* dstV = getCrAddr(partUnitIdx);
- UInt src0Stride = srcYuv0->m_width;
- UInt src1Stride = srcYuv1->m_width;
- UInt dststride = getStride();
- int shiftNum = IF_INTERNAL_PREC + 1 - X265_DEPTH;
- int offset = (1 << (shiftNum - 1)) + 2 * IF_INTERNAL_OFFS;
+ if(bLuma)
+ {
+ src0Stride = srcYuv0->m_width;
+ src1Stride = srcYuv1->m_width;
+ dststride = getStride();
+ shiftNum = IF_INTERNAL_PREC + 1 - X265_DEPTH;
+ offset = (1 << (shiftNum - 1)) + 2 * IF_INTERNAL_OFFS;
- for (y = 0; y < height; y++)
+ for (y = 0; y < height; y++)
+ {
+ for (x = 0; x < width; x += 4)
+ {
+ dstY[x + 0] = ClipY((srcY0[x + 0] + srcY1[x + 0] + offset) >> shiftNum);
+ dstY[x + 1] = ClipY((srcY0[x + 1] + srcY1[x + 1] + offset) >> shiftNum);
+ dstY[x + 2] = ClipY((srcY0[x + 2] + srcY1[x + 2] + offset) >> shiftNum);
+ dstY[x + 3] = ClipY((srcY0[x + 3] + srcY1[x + 3] + offset) >> shiftNum);
+ }
+
+ srcY0 += src0Stride;
+ srcY1 += src1Stride;
+ dstY += dststride;
+ }
+ }
+ if(bChroma)
{
- for (x = 0; x < width; x += 4)
+ shiftNum = IF_INTERNAL_PREC + 1 - X265_DEPTH;
+ offset = (1 << (shiftNum - 1)) + 2 * IF_INTERNAL_OFFS;
+
+ src0Stride = srcYuv0->m_cwidth;
+ src1Stride = srcYuv1->m_cwidth;
+ dststride = getCStride();
+
+ width >>= 1;
+ height >>= 1;
+
+ for (y = height - 1; y >= 0; y--)
{
- dstY[x + 0] = ClipY((srcY0[x + 0] + srcY1[x + 0] + offset) >> shiftNum);
- dstY[x + 1] = ClipY((srcY0[x + 1] + srcY1[x + 1] + offset) >> shiftNum);
- dstY[x + 2] = ClipY((srcY0[x + 2] + srcY1[x + 2] + offset) >> shiftNum);
- dstY[x + 3] = ClipY((srcY0[x + 3] + srcY1[x + 3] + offset) >> shiftNum);
+ for (x = width - 1; x >= 0; )
+ {
+ // note: chroma min width is 2
+ dstU[x] = ClipC((srcU0[x] + srcU1[x] + offset) >> shiftNum);
+ dstV[x] = ClipC((srcV0[x] + srcV1[x] + offset) >> shiftNum);
+ x--;
+ dstU[x] = ClipC((srcU0[x] + srcU1[x] + offset) >> shiftNum);
+ dstV[x] = ClipC((srcV0[x] + srcV1[x] + offset) >> shiftNum);
+ x--;
+ }
+
+ srcU0 += src0Stride;
+ srcU1 += src1Stride;
+ srcV0 += src0Stride;
+ srcV1 += src1Stride;
+ dstU += dststride;
+ dstV += dststride;
}
-
- srcY0 += src0Stride;
- srcY1 += src1Stride;
- dstY += dststride;
- }
-
- shiftNum = IF_INTERNAL_PREC + 1 - X265_DEPTH;
- offset = (1 << (shiftNum - 1)) + 2 * IF_INTERNAL_OFFS;
-
- src0Stride = srcYuv0->m_cwidth;
- src1Stride = srcYuv1->m_cwidth;
- dststride = getCStride();
-
- width >>= 1;
- height >>= 1;
-
- for (y = height - 1; y >= 0; y--)
- {
- for (x = width - 1; x >= 0; )
- {
- // note: chroma min width is 2
- dstU[x] = ClipC((srcU0[x] + srcU1[x] + offset) >> shiftNum);
- dstV[x] = ClipC((srcV0[x] + srcV1[x] + offset) >> shiftNum);
- x--;
- dstU[x] = ClipC((srcU0[x] + srcU1[x] + offset) >> shiftNum);
- dstV[x] = ClipC((srcV0[x] + srcV1[x] + offset) >> shiftNum);
- x--;
- }
-
- srcU0 += src0Stride;
- srcU1 += src1Stride;
- srcV0 += src0Stride;
- srcV1 += src1Stride;
- dstU += dststride;
- dstV += dststride;
}
}
diff -r 3cdbc62783e1 -r ac7aa89eae11 source/Lib/TLibCommon/TComYuv.h
--- a/source/Lib/TLibCommon/TComYuv.h Wed Oct 16 12:17:21 2013 +0530
+++ b/source/Lib/TLibCommon/TComYuv.h Wed Oct 16 17:18:19 2013 +0530
@@ -132,8 +132,8 @@
void copyPartToChroma(TComYuv* dstPicYuv, UInt uiSrcPartIdx);
// Copy YUV partition buffer to other YUV partition buffer
- void copyPartToPartYuv(TComYuv* dstPicYuv, UInt partIdx, UInt width, UInt height);
- void copyPartToPartYuv(TShortYUV* dstPicYuv, UInt partIdx, UInt width, UInt height);
+ void copyPartToPartYuv(TComYuv* dstPicYuv, UInt partIdx, UInt width, UInt height, bool bLuma = true, bool bChroma = true);
+ void copyPartToPartYuv(TShortYUV* dstPicYuv, UInt partIdx, UInt width, UInt height, bool bLuma = true, bool bChroma = true);
void copyPartToPartLuma(TComYuv* dstPicYuv, UInt partIdx, UInt width, UInt height);
void copyPartToPartLuma(TShortYUV* dstPicYuv, UInt partIdx, UInt width, UInt height);
void copyPartToPartChroma(TComYuv* dstPicYuv, UInt partIdx, UInt width, UInt height);
@@ -160,8 +160,8 @@
void subtractChroma(TComYuv* srcYuv0, TComYuv* srcYuv1, UInt trUnitIdx, UInt partSize);
// (srcYuv0 + srcYuv1)/2 for YUV partition
- void addAvg(TComYuv* srcYuv0, TComYuv* srcYuv1, UInt partUnitIdx, UInt width, UInt height);
- void addAvg(TShortYUV* srcYuv0, TShortYUV* srcYuv1, UInt partUnitIdx, UInt width, UInt height);
+ void addAvg(TComYuv* srcYuv0, TComYuv* srcYuv1, UInt partUnitIdx, UInt width, UInt height, bool bLuma = true, bool bChroma = true);
+ void addAvg(TShortYUV* srcYuv0, TShortYUV* srcYuv1, UInt partUnitIdx, UInt width, UInt height, bool bLuma = true, bool bChroma = true);
// Remove High frequency
void removeHighFreq(TComYuv* srcYuv, UInt partIdx, UInt width, UInt height);
diff -r 3cdbc62783e1 -r ac7aa89eae11 source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp Wed Oct 16 12:17:21 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp Wed Oct 16 17:18:19 2013 +0530
@@ -2196,7 +2196,7 @@
* \param bUseMRG
* \returns void
*/
-void TEncSearch::predInterSearch(TComDataCU* cu, TComYuv* predYuv, bool bUseMRG)
+void TEncSearch::predInterSearch(TComDataCU* cu, TComYuv* predYuv, bool bUseMRG, bool bLuma, bool bChroma)
{
MV mvzero(0, 0);
MV mv[2];
@@ -2521,7 +2521,7 @@
#endif
}
}
- motionCompensation(cu, predYuv, REF_PIC_LIST_X, partIdx);
+ motionCompensation(cu, predYuv, REF_PIC_LIST_X, partIdx, bLuma, bChroma);
}
setWpScalingDistParam(cu, -1, REF_PIC_LIST_X);
diff -r 3cdbc62783e1 -r ac7aa89eae11 source/Lib/TLibEncoder/TEncSearch.h
--- a/source/Lib/TLibEncoder/TEncSearch.h Wed Oct 16 12:17:21 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncSearch.h Wed Oct 16 17:18:19 2013 +0530
@@ -142,7 +142,7 @@
TComYuv* reconYuv, UInt precalcDistC);
/// encoder estimation - inter prediction (non-skip)
- void predInterSearch(TComDataCU* cu, TComYuv* predYuv, bool bUseMRG = false);
+ void predInterSearch(TComDataCU* cu, TComYuv* predYuv, bool bUseMRG = false, bool bLuma = true, bool bChroma = true);
/// encode residual and compute rd-cost for inter mode
void encodeResAndCalcRdInterCU(TComDataCU* cu, TComYuv* fencYuv, TComYuv* predYuv, TShortYUV* resiYuv, TShortYUV* bestResiYuv,
More information about the x265-devel
mailing list