Commit 56f2bee0 authored by Xiang Li's avatar Xiang Li

Merge branch 'clean19' into 'master'

Cleanup weighted predition related code

See merge request jvet/VVCSoftware_VTM!1803
parents e275b6f4 1a04b7dd
...@@ -517,12 +517,12 @@ void InterPrediction::xPredInterBi(PredictionUnit &pu, PelUnitBuf &pcYuvPred, co ...@@ -517,12 +517,12 @@ void InterPrediction::xPredInterBi(PredictionUnit &pu, PelUnitBuf &pcYuvPred, co
const PPS &pps = *pu.cs->pps; const PPS &pps = *pu.cs->pps;
const Slice &slice = *pu.cs->slice; const Slice &slice = *pu.cs->slice;
CHECK( !pu.cu->affine && pu.refIdx[0] >= 0 && pu.refIdx[1] >= 0 && ( pu.lwidth() + pu.lheight() == 12 ), "invalid 4x8/8x4 bi-predicted blocks" ); CHECK( !pu.cu->affine && pu.refIdx[0] >= 0 && pu.refIdx[1] >= 0 && ( pu.lwidth() + pu.lheight() == 12 ), "invalid 4x8/8x4 bi-predicted blocks" );
WPScalingParam *wp0;
WPScalingParam *wp1;
int refIdx0 = pu.refIdx[REF_PIC_LIST_0]; int refIdx0 = pu.refIdx[REF_PIC_LIST_0];
int refIdx1 = pu.refIdx[REF_PIC_LIST_1]; int refIdx1 = pu.refIdx[REF_PIC_LIST_1];
pu.cs->slice->getWpScaling(REF_PIC_LIST_0, refIdx0, wp0);
pu.cs->slice->getWpScaling(REF_PIC_LIST_1, refIdx1, wp1); const WPScalingParam *wp0 = pu.cs->slice->getWpScaling(REF_PIC_LIST_0, refIdx0);
const WPScalingParam *wp1 = pu.cs->slice->getWpScaling(REF_PIC_LIST_1, refIdx1);
bool bioApplied = false; bool bioApplied = false;
if (pu.cs->sps->getBDOFEnabledFlag() && (!pu.cs->picHeader->getDisBdofFlag())) if (pu.cs->sps->getBDOFEnabledFlag() && (!pu.cs->picHeader->getDisBdofFlag()))
...@@ -533,7 +533,8 @@ void InterPrediction::xPredInterBi(PredictionUnit &pu, PelUnitBuf &pcYuvPred, co ...@@ -533,7 +533,8 @@ void InterPrediction::xPredInterBi(PredictionUnit &pu, PelUnitBuf &pcYuvPred, co
} }
else else
{ {
const bool biocheck0 = !((wp0[COMPONENT_Y].bPresentFlag || wp0[COMPONENT_Cb].bPresentFlag || wp0[COMPONENT_Cr].bPresentFlag || wp1[COMPONENT_Y].bPresentFlag || wp1[COMPONENT_Cb].bPresentFlag || wp1[COMPONENT_Cr].bPresentFlag) && slice.getSliceType() == B_SLICE); const bool biocheck0 =
!((WPScalingParam::isWeighted(wp0) || WPScalingParam::isWeighted(wp1)) && slice.getSliceType() == B_SLICE);
const bool biocheck1 = !(pps.getUseWP() && slice.getSliceType() == P_SLICE); const bool biocheck1 = !(pps.getUseWP() && slice.getSliceType() == P_SLICE);
if (biocheck0 if (biocheck0
&& biocheck1 && biocheck1
...@@ -1496,12 +1497,12 @@ void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBu ...@@ -1496,12 +1497,12 @@ void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBu
{ {
CHECK( !pu.cu->affine && pu.refIdx[0] >= 0 && pu.refIdx[1] >= 0 && ( pu.lwidth() + pu.lheight() == 12 ), "invalid 4x8/8x4 bi-predicted blocks" ); CHECK( !pu.cu->affine && pu.refIdx[0] >= 0 && pu.refIdx[1] >= 0 && ( pu.lwidth() + pu.lheight() == 12 ), "invalid 4x8/8x4 bi-predicted blocks" );
WPScalingParam *wp0;
WPScalingParam *wp1;
int refIdx0 = pu.refIdx[REF_PIC_LIST_0]; int refIdx0 = pu.refIdx[REF_PIC_LIST_0];
int refIdx1 = pu.refIdx[REF_PIC_LIST_1]; int refIdx1 = pu.refIdx[REF_PIC_LIST_1];
pu.cs->slice->getWpScaling(REF_PIC_LIST_0, refIdx0, wp0);
pu.cs->slice->getWpScaling(REF_PIC_LIST_1, refIdx1, wp1); const WPScalingParam *wp0 = pu.cs->slice->getWpScaling(REF_PIC_LIST_0, refIdx0);
const WPScalingParam *wp1 = pu.cs->slice->getWpScaling(REF_PIC_LIST_1, refIdx1);
bool bioApplied = false; bool bioApplied = false;
const Slice &slice = *pu.cs->slice; const Slice &slice = *pu.cs->slice;
if (pu.cs->sps->getBDOFEnabledFlag() && (!pu.cs->picHeader->getDisBdofFlag())) if (pu.cs->sps->getBDOFEnabledFlag() && (!pu.cs->picHeader->getDisBdofFlag()))
...@@ -1513,7 +1514,8 @@ void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBu ...@@ -1513,7 +1514,8 @@ void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBu
} }
else else
{ {
const bool biocheck0 = !((wp0[COMPONENT_Y].bPresentFlag || wp0[COMPONENT_Cb].bPresentFlag || wp0[COMPONENT_Cr].bPresentFlag || wp1[COMPONENT_Y].bPresentFlag || wp1[COMPONENT_Cb].bPresentFlag || wp1[COMPONENT_Cr].bPresentFlag) && slice.getSliceType() == B_SLICE); const bool biocheck0 =
!((WPScalingParam::isWeighted(wp0) || WPScalingParam::isWeighted(wp1)) && slice.getSliceType() == B_SLICE);
const bool biocheck1 = !(pps.getUseWP() && slice.getSliceType() == P_SLICE); const bool biocheck1 = !(pps.getUseWP() && slice.getSliceType() == P_SLICE);
if (biocheck0 if (biocheck0
&& biocheck1 && biocheck1
......
...@@ -2227,10 +2227,30 @@ void Slice::initWpAcDcParam() ...@@ -2227,10 +2227,30 @@ void Slice::initWpAcDcParam()
} }
//! get tables for weighted prediction //! get tables for weighted prediction
void Slice::getWpScaling( RefPicList e, int iRefIdx, WPScalingParam *&wp ) const const WPScalingParam *Slice::getWpScaling(const RefPicList refPicList, const int refIdx) const
{ {
CHECK(e>=NUM_REF_PIC_LIST_01, "Invalid picture reference list"); CHECK(refPicList >= NUM_REF_PIC_LIST_01, "Invalid picture reference list");
wp = (WPScalingParam*) m_weightPredTable[e][iRefIdx]; if (refIdx < 0)
{
return nullptr;
}
else
{
return m_weightPredTable[refPicList][refIdx];
}
}
WPScalingParam *Slice::getWpScaling(const RefPicList refPicList, const int refIdx)
{
CHECK(refPicList >= NUM_REF_PIC_LIST_01, "Invalid picture reference list");
if (refIdx < 0)
{
return nullptr;
}
else
{
return m_weightPredTable[refPicList][refIdx];
}
} }
//! reset Default WP tables settings : no weight. //! reset Default WP tables settings : no weight.
...@@ -2243,11 +2263,11 @@ void Slice::resetWpScaling() ...@@ -2243,11 +2263,11 @@ void Slice::resetWpScaling()
for ( int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ ) for ( int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ )
{ {
WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]);
pwp->bPresentFlag = false; pwp->presentFlag = false;
pwp->uiLog2WeightDenom = 0; pwp->log2WeightDenom = 0;
pwp->uiLog2WeightDenom = 0; pwp->log2WeightDenom = 0;
pwp->iWeight = 1; pwp->codedWeight = 1;
pwp->iOffset = 0; pwp->codedOffset = 0;
} }
} }
} }
...@@ -2264,19 +2284,20 @@ void Slice::initWpScaling(const SPS *sps) ...@@ -2264,19 +2284,20 @@ void Slice::initWpScaling(const SPS *sps)
for ( int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ ) for ( int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ )
{ {
WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]);
if ( !pwp->bPresentFlag ) if (!pwp->presentFlag)
{ {
// Inferring values not present : // Inferring values not present :
pwp->iWeight = (1 << pwp->uiLog2WeightDenom); pwp->codedWeight = (1 << pwp->log2WeightDenom);
pwp->iOffset = 0; pwp->codedOffset = 0;
} }
const int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (sps->getBitDepth(toChannelType(ComponentID(yuv)))-8)); const int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (sps->getBitDepth(toChannelType(ComponentID(yuv)))-8));
pwp->w = pwp->iWeight; pwp->w = pwp->codedWeight;
pwp->o = pwp->iOffset * offsetScalingFactor; //NOTE: This value of the ".o" variable is never used - .o is set immediately before it gets used pwp->o = pwp->codedOffset * offsetScalingFactor; // NOTE: This value of the ".o" variable is never used - .o
pwp->shift = pwp->uiLog2WeightDenom; // is set immediately before it gets used
pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); pwp->shift = pwp->log2WeightDenom;
pwp->round = (pwp->log2WeightDenom >= 1) ? (1 << (pwp->log2WeightDenom - 1)) : (0);
} }
} }
} }
...@@ -2749,10 +2770,30 @@ void PicHeader::initPicHeader() ...@@ -2749,10 +2770,30 @@ void PicHeader::initPicHeader()
m_alfApsId.resize(0); m_alfApsId.resize(0);
} }
void PicHeader::getWpScaling(RefPicList e, int iRefIdx, WPScalingParam *&wp) const const WPScalingParam *PicHeader::getWpScaling(const RefPicList refPicList, const int refIdx) const
{ {
CHECK(e >= NUM_REF_PIC_LIST_01, "Invalid picture reference list"); CHECK(refPicList >= NUM_REF_PIC_LIST_01, "Invalid picture reference list");
wp = (WPScalingParam *) m_weightPredTable[e][iRefIdx]; if (refIdx < 0)
{
return nullptr;
}
else
{
return m_weightPredTable[refPicList][refIdx];
}
}
WPScalingParam *PicHeader::getWpScaling(const RefPicList refPicList, const int refIdx)
{
CHECK(refPicList >= NUM_REF_PIC_LIST_01, "Invalid picture reference list");
if (refIdx < 0)
{
return nullptr;
}
else
{
return m_weightPredTable[refPicList][refIdx];
}
} }
void PicHeader::resetWpScaling() void PicHeader::resetWpScaling()
...@@ -2764,10 +2805,10 @@ void PicHeader::resetWpScaling() ...@@ -2764,10 +2805,10 @@ void PicHeader::resetWpScaling()
for ( int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ ) for ( int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ )
{ {
WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]);
pwp->bPresentFlag = false; pwp->presentFlag = false;
pwp->uiLog2WeightDenom = 0; pwp->log2WeightDenom = 0;
pwp->iWeight = 1; pwp->codedWeight = 1;
pwp->iOffset = 0; pwp->codedOffset = 0;
} }
} }
} }
......
...@@ -2325,10 +2325,10 @@ struct WPScalingParam ...@@ -2325,10 +2325,10 @@ struct WPScalingParam
{ {
// Explicit weighted prediction parameters parsed in slice header, // Explicit weighted prediction parameters parsed in slice header,
// or Implicit weighted prediction parameters (8 bits depth values). // or Implicit weighted prediction parameters (8 bits depth values).
bool bPresentFlag; bool presentFlag;
uint32_t uiLog2WeightDenom; uint32_t log2WeightDenom;
int iWeight; int codedWeight;
int iOffset; int codedOffset;
// Weighted prediction scaling values built from above parameters (bitdepth scaled): // Weighted prediction scaling values built from above parameters (bitdepth scaled):
int w; int w;
...@@ -2337,7 +2337,14 @@ struct WPScalingParam ...@@ -2337,7 +2337,14 @@ struct WPScalingParam
int shift; int shift;
int round; int round;
static bool isWeighted(const WPScalingParam *wp);
}; };
inline bool WPScalingParam::isWeighted(const WPScalingParam *wp)
{
return wp != nullptr && (wp[COMPONENT_Y].presentFlag || wp[COMPONENT_Cb].presentFlag || wp[COMPONENT_Cr].presentFlag);
}
struct WPACDCParam struct WPACDCParam
{ {
int64_t iAC; int64_t iAC;
...@@ -2605,7 +2612,8 @@ public: ...@@ -2605,7 +2612,8 @@ public:
{ {
memcpy(m_weightPredTable, wp, sizeof(WPScalingParam) * NUM_REF_PIC_LIST_01 * MAX_NUM_REF * MAX_NUM_COMPONENT); memcpy(m_weightPredTable, wp, sizeof(WPScalingParam) * NUM_REF_PIC_LIST_01 * MAX_NUM_REF * MAX_NUM_COMPONENT);
} }
void getWpScaling(RefPicList e, int iRefIdx, WPScalingParam *&wp) const; const WPScalingParam * getWpScaling(const RefPicList refPicList, const int refIdx) const;
WPScalingParam * getWpScaling(const RefPicList refPicList, const int refIdx);
WPScalingParam* getWpScalingAll() { return (WPScalingParam *) m_weightPredTable; } WPScalingParam* getWpScalingAll() { return (WPScalingParam *) m_weightPredTable; }
void resetWpScaling(); void resetWpScaling();
void setNumL0Weights(int b) { m_numL0Weights = b; } void setNumL0Weights(int b) { m_numL0Weights = b; }
...@@ -2975,7 +2983,8 @@ public: ...@@ -2975,7 +2983,8 @@ public:
memcpy(m_weightPredTable, wp, sizeof(WPScalingParam) * NUM_REF_PIC_LIST_01 * MAX_NUM_REF * MAX_NUM_COMPONENT); memcpy(m_weightPredTable, wp, sizeof(WPScalingParam) * NUM_REF_PIC_LIST_01 * MAX_NUM_REF * MAX_NUM_COMPONENT);
} }
WPScalingParam * getWpScalingAll() { return (WPScalingParam *) m_weightPredTable; } WPScalingParam * getWpScalingAll() { return (WPScalingParam *) m_weightPredTable; }
void getWpScaling( RefPicList e, int iRefIdx, WPScalingParam *&wp) const; WPScalingParam * getWpScaling(const RefPicList refPicList, const int refIdx);
const WPScalingParam * getWpScaling(const RefPicList refPicList, const int refIdx) const;
void resetWpScaling(); void resetWpScaling();
void initWpScaling(const SPS *sps); void initWpScaling(const SPS *sps);
......
...@@ -1403,29 +1403,23 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, ...@@ -1403,29 +1403,23 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx,
bool PU::checkDMVRCondition(const PredictionUnit& pu) bool PU::checkDMVRCondition(const PredictionUnit& pu)
{ {
WPScalingParam *wp0; if (pu.cs->sps->getUseDMVR() && !pu.cs->picHeader->getDisDmvrFlag())
WPScalingParam *wp1; {
int refIdx0 = pu.refIdx[REF_PIC_LIST_0]; const int refIdx0 = pu.refIdx[REF_PIC_LIST_0];
int refIdx1 = pu.refIdx[REF_PIC_LIST_1]; const int refIdx1 = pu.refIdx[REF_PIC_LIST_1];
pu.cu->slice->getWpScaling(REF_PIC_LIST_0, refIdx0, wp0);
pu.cu->slice->getWpScaling(REF_PIC_LIST_1, refIdx1, wp1); const WPScalingParam *wp0 = pu.cu->slice->getWpScaling(REF_PIC_LIST_0, refIdx0);
if (pu.cs->sps->getUseDMVR() && (!pu.cs->picHeader->getDisDmvrFlag())) const WPScalingParam *wp1 = pu.cu->slice->getWpScaling(REF_PIC_LIST_1, refIdx1);
{
return pu.mergeFlag const bool ref0IsScaled =
&& pu.mergeType == MRG_TYPE_DEFAULT_N refIdx0 < 0 ? false : pu.cu->slice->getRefPic(REF_PIC_LIST_0, refIdx0)->isRefScaled(pu.cs->pps);
&& !pu.ciipFlag const bool ref1IsScaled =
&& !pu.cu->affine refIdx1 < 0 ? false : pu.cu->slice->getRefPic(REF_PIC_LIST_1, refIdx1)->isRefScaled(pu.cs->pps);
&& !pu.mmvdMergeFlag
&& !pu.cu->mmvdSkip return pu.mergeFlag && pu.mergeType == MRG_TYPE_DEFAULT_N && !pu.ciipFlag && !pu.cu->affine && !pu.mmvdMergeFlag
&& PU::isBiPredFromDifferentDirEqDistPoc(pu) && !pu.cu->mmvdSkip && PU::isBiPredFromDifferentDirEqDistPoc(pu) && (pu.lheight() >= 8) && (pu.lwidth() >= 8)
&& (pu.lheight() >= 8) && ((pu.lheight() * pu.lwidth()) >= 128) && (pu.cu->BcwIdx == BCW_DEFAULT)
&& (pu.lwidth() >= 8) && !WPScalingParam::isWeighted(wp0) && !WPScalingParam::isWeighted(wp1) && !ref0IsScaled && !ref1IsScaled;
&& ((pu.lheight() * pu.lwidth()) >= 128)
&& (pu.cu->BcwIdx == BCW_DEFAULT)
&& ((!wp0[COMPONENT_Y].bPresentFlag) && (!wp0[COMPONENT_Cb].bPresentFlag) && (!wp0[COMPONENT_Cr].bPresentFlag) && (!wp1[COMPONENT_Y].bPresentFlag) && (!wp1[COMPONENT_Cb].bPresentFlag) && (!wp1[COMPONENT_Cr].bPresentFlag))
&& ( refIdx0 < 0 ? true : (pu.cu->slice->getRefPic( REF_PIC_LIST_0, refIdx0 )->isRefScaled( pu.cs->pps ) == false) )
&& ( refIdx1 < 0 ? true : (pu.cu->slice->getRefPic( REF_PIC_LIST_1, refIdx1 )->isRefScaled( pu.cs->pps ) == false) )
;
} }
else else
{ {
...@@ -3733,19 +3727,13 @@ bool CU::isBcwIdxCoded( const CodingUnit &cu ) ...@@ -3733,19 +3727,13 @@ bool CU::isBcwIdxCoded( const CodingUnit &cu )
{ {
if( cu.firstPU->interDir == 3 ) if( cu.firstPU->interDir == 3 )
{ {
WPScalingParam *wp0; const int refIdx0 = cu.firstPU->refIdx[REF_PIC_LIST_0];
WPScalingParam *wp1; const int refIdx1 = cu.firstPU->refIdx[REF_PIC_LIST_1];
int refIdx0 = cu.firstPU->refIdx[REF_PIC_LIST_0];
int refIdx1 = cu.firstPU->refIdx[REF_PIC_LIST_1];
cu.cs->slice->getWpScaling(REF_PIC_LIST_0, refIdx0, wp0); const WPScalingParam *wp0 = cu.cs->slice->getWpScaling(REF_PIC_LIST_0, refIdx0);
cu.cs->slice->getWpScaling(REF_PIC_LIST_1, refIdx1, wp1); const WPScalingParam *wp1 = cu.cs->slice->getWpScaling(REF_PIC_LIST_1, refIdx1);
if ((wp0[COMPONENT_Y].bPresentFlag || wp0[COMPONENT_Cb].bPresentFlag || wp0[COMPONENT_Cr].bPresentFlag
|| wp1[COMPONENT_Y].bPresentFlag || wp1[COMPONENT_Cb].bPresentFlag || wp1[COMPONENT_Cr].bPresentFlag)) return !(WPScalingParam::isWeighted(wp0) || WPScalingParam::isWeighted(wp1));
{
return false;
}
return true;
} }
} }
......
...@@ -72,14 +72,8 @@ WeightPrediction::WeightPrediction() ...@@ -72,14 +72,8 @@ WeightPrediction::WeightPrediction()
{ {
} }
void WeightPrediction::getWpScaling(Slice *pcSlice, const int &iRefIdx0, const int &iRefIdx1, WPScalingParam *&wp0,
WPScalingParam *&wp1, const ComponentID maxNumComp)
void WeightPrediction::getWpScaling(const Slice *pcSlice,
const int &iRefIdx0,
const int &iRefIdx1,
WPScalingParam *&wp0,
WPScalingParam *&wp1,
const ComponentID maxNumComp)
{ {
CHECK(iRefIdx0 < 0 && iRefIdx1 < 0, "Both picture reference list indizes smaller than '0'"); CHECK(iRefIdx0 < 0 && iRefIdx1 < 0, "Both picture reference list indizes smaller than '0'");
...@@ -90,14 +84,8 @@ void WeightPrediction::getWpScaling(const Slice *pcSlice, ...@@ -90,14 +84,8 @@ void WeightPrediction::getWpScaling(const Slice *pcSlice,
if (bUniPred || wpBiPred) if (bUniPred || wpBiPred)
{ {
// explicit -------------------- // explicit --------------------
if (iRefIdx0 >= 0) wp0 = pcSlice->getWpScaling(REF_PIC_LIST_0, iRefIdx0);
{ wp1 = pcSlice->getWpScaling(REF_PIC_LIST_1, iRefIdx1);
pcSlice->getWpScaling(REF_PIC_LIST_0, iRefIdx0, wp0);
}
if (iRefIdx1 >= 0)
{
pcSlice->getWpScaling(REF_PIC_LIST_1, iRefIdx1, wp1);
}
} }
else else
{ {
...@@ -106,11 +94,11 @@ void WeightPrediction::getWpScaling(const Slice *pcSlice, ...@@ -106,11 +94,11 @@ void WeightPrediction::getWpScaling(const Slice *pcSlice,
if (iRefIdx0 < 0) if (iRefIdx0 < 0)
{ {
wp0 = NULL; wp0 = nullptr;
} }
if (iRefIdx1 < 0) if (iRefIdx1 < 0)
{ {
wp1 = NULL; wp1 = nullptr;
} }
const uint32_t numValidComponent = getNumberValidComponents(pcSlice->getSPS()->getChromaFormatIdc()); const uint32_t numValidComponent = getNumberValidComponents(pcSlice->getSPS()->getChromaFormatIdc());
...@@ -124,13 +112,13 @@ void WeightPrediction::getWpScaling(const Slice *pcSlice, ...@@ -124,13 +112,13 @@ void WeightPrediction::getWpScaling(const Slice *pcSlice,
const int bitDepth = pcSlice->getSPS()->getBitDepth(toChannelType(ComponentID(yuv))); const int bitDepth = pcSlice->getSPS()->getBitDepth(toChannelType(ComponentID(yuv)));
const int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (bitDepth - 8)); const int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (bitDepth - 8));
wp0[yuv].w = wp0[yuv].iWeight; wp0[yuv].w = wp0[yuv].codedWeight;
wp1[yuv].w = wp1[yuv].iWeight; wp1[yuv].w = wp1[yuv].codedWeight;
wp0[yuv].o = wp0[yuv].iOffset * offsetScalingFactor; wp0[yuv].o = wp0[yuv].codedOffset * offsetScalingFactor;
wp1[yuv].o = wp1[yuv].iOffset * offsetScalingFactor; wp1[yuv].o = wp1[yuv].codedOffset * offsetScalingFactor;
wp0[yuv].offset = wp0[yuv].o + wp1[yuv].o; wp0[yuv].offset = wp0[yuv].o + wp1[yuv].o;
wp0[yuv].shift = wp0[yuv].uiLog2WeightDenom + 1; wp0[yuv].shift = wp0[yuv].log2WeightDenom + 1;
wp0[yuv].round = (1 << wp0[yuv].uiLog2WeightDenom); wp0[yuv].round = (1 << wp0[yuv].log2WeightDenom);
wp1[yuv].offset = wp0[yuv].offset; wp1[yuv].offset = wp0[yuv].offset;
wp1[yuv].shift = wp0[yuv].shift; wp1[yuv].shift = wp0[yuv].shift;
wp1[yuv].round = wp0[yuv].round; wp1[yuv].round = wp0[yuv].round;
...@@ -146,10 +134,10 @@ void WeightPrediction::getWpScaling(const Slice *pcSlice, ...@@ -146,10 +134,10 @@ void WeightPrediction::getWpScaling(const Slice *pcSlice,
const int bitDepth = pcSlice->getSPS()->getBitDepth(toChannelType(ComponentID(yuv))); const int bitDepth = pcSlice->getSPS()->getBitDepth(toChannelType(ComponentID(yuv)));
const int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (bitDepth - 8)); const int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (bitDepth - 8));
pwp[yuv].w = pwp[yuv].iWeight; pwp[yuv].w = pwp[yuv].codedWeight;
pwp[yuv].offset = pwp[yuv].iOffset * offsetScalingFactor; pwp[yuv].offset = pwp[yuv].codedOffset * offsetScalingFactor;
pwp[yuv].shift = pwp[yuv].uiLog2WeightDenom; pwp[yuv].shift = pwp[yuv].log2WeightDenom;
pwp[yuv].round = (pwp[yuv].uiLog2WeightDenom >= 1) ? (1 << (pwp[yuv].uiLog2WeightDenom - 1)) : (0); pwp[yuv].round = (pwp[yuv].log2WeightDenom >= 1) ? (1 << (pwp[yuv].log2WeightDenom - 1)) : (0);
} }
} }
} }
......
...@@ -55,12 +55,8 @@ class WeightPrediction ...@@ -55,12 +55,8 @@ class WeightPrediction
public: public:
WeightPrediction(); WeightPrediction();
void getWpScaling( const Slice *slice, void getWpScaling(Slice *slice, const int &iRefIdx0, const int &iRefIdx1, WPScalingParam *&wp0, WPScalingParam *&wp1,
const int &iRefIdx0, const ComponentID maxNumComp = MAX_NUM_COMPONENT);
const int &iRefIdx1,
WPScalingParam *&wp0,
WPScalingParam *&wp1,
const ComponentID maxNumComp = MAX_NUM_COMPONENT );
void addWeightBi( const CPelUnitBuf &pcYuvSrc0, void addWeightBi( const CPelUnitBuf &pcYuvSrc0,
const CPelUnitBuf &pcYuvSrc1, const CPelUnitBuf &pcYuvSrc1,
......
This diff is collapsed.
...@@ -2832,10 +2832,9 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) ...@@ -2832,10 +2832,9 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner)
{ {
CHECK(iRefIdxBi[0]<0, "Invalid picture reference index"); CHECK(iRefIdxBi[0]<0, "Invalid picture reference index");
CHECK(iRefIdxBi[1]<0, "Invalid picture reference index"); CHECK(iRefIdxBi[1]<0, "Invalid picture reference index");
cu.cs->slice->getWpScaling(REF_PIC_LIST_0, iRefIdxBi[0], wp0); wp0 = cu.cs->slice->getWpScaling(REF_PIC_LIST_0, iRefIdxBi[0]);
cu.cs->slice->getWpScaling(REF_PIC_LIST_1, iRefIdxBi[1], wp1); wp1 = cu.cs->slice->getWpScaling(REF_PIC_LIST_1, iRefIdxBi[1]);
if ((wp0[COMPONENT_Y].bPresentFlag || wp0[COMPONENT_Cb].bPresentFlag || wp0[COMPONENT_Cr].bPresentFlag if (WPScalingParam::isWeighted(wp0) || WPScalingParam::isWeighted(wp1))
|| wp1[COMPONENT_Y].bPresentFlag || wp1[COMPONENT_Cb].bPresentFlag || wp1[COMPONENT_Cr].bPresentFlag))
{ {
uiCostBi = MAX_UINT; uiCostBi = MAX_UINT;
enforceBcwPred = false; enforceBcwPred = false;
...@@ -5125,10 +5124,10 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, ...@@ -5125,10 +5124,10 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu,
{ {
CHECK(iRefIdxBi[0]<0, "Invalid picture reference index"); CHECK(iRefIdxBi[0]<0, "Invalid picture reference index");
CHECK(iRefIdxBi[1]<0, "Invalid picture reference index"); CHECK(iRefIdxBi[1]<0, "Invalid picture reference index");
pu.cs->slice->getWpScaling(REF_PIC_LIST_0, iRefIdxBi[0], wp0); wp0 = pu.cs->slice->getWpScaling(REF_PIC_LIST_0, iRefIdxBi[0]);
pu.cs->slice->getWpScaling(REF_PIC_LIST_1, iRefIdxBi[1], wp1); wp1 = pu.cs->slice->getWpScaling(REF_PIC_LIST_1, iRefIdxBi[1]);
if ((wp0[COMPONENT_Y].bPresentFlag || wp0[COMPONENT_Cb].bPresentFlag || wp0[COMPONENT_Cr].bPresentFlag
|| wp1[COMPONENT_Y].bPresentFlag || wp1[COMPONENT_Cb].bPresentFlag || wp1[COMPONENT_Cr].bPresentFlag)) if (WPScalingParam::isWeighted(wp0) || WPScalingParam::isWeighted(wp1))
{ {
uiCostBi = MAX_UINT; uiCostBi = MAX_UINT;
enforceBcwPred = false; enforceBcwPred = false;
......
...@@ -2843,61 +2843,65 @@ void HLSWriter::xCodePredWeightTable( Slice* pcSlice ) ...@@ -2843,61 +2843,65 @@ void HLSWriter::xCodePredWeightTable( Slice* pcSlice )
{ {
RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
// NOTE: wp[].uiLog2WeightDenom and wp[].bPresentFlag are actually per-channel-type settings. // NOTE: wp[].log2WeightDenom and wp[].presentFlag are actually per-channel-type settings.
for ( int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) for ( int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
{ {
pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); wp = pcSlice->getWpScaling(eRefPicList, iRefIdx);
if ( !bDenomCoded ) if ( !bDenomCoded )
{ {
int iDeltaDenom; int iDeltaDenom;
WRITE_UVLC( wp[COMPONENT_Y].uiLog2WeightDenom, "luma_log2_weight_denom" ); WRITE_UVLC(wp[COMPONENT_Y].log2WeightDenom, "luma_log2_weight_denom");
if( bChroma ) if( bChroma )
{ {
CHECK( wp[COMPONENT_Cb].uiLog2WeightDenom != wp[COMPONENT_Cr].uiLog2WeightDenom, "Chroma blocks of different size not supported" ); CHECK(wp[COMPONENT_Cb].log2WeightDenom != wp[COMPONENT_Cr].log2WeightDenom,
iDeltaDenom = (wp[COMPONENT_Cb].uiLog2WeightDenom - wp[COMPONENT_Y].uiLog2WeightDenom); "Chroma blocks of different size not supported");
iDeltaDenom = (wp[COMPONENT_Cb].log2WeightDenom - wp[COMPONENT_Y].log2WeightDenom);
WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" );
} }
bDenomCoded = true; bDenomCoded = true;
} }
WRITE_FLAG( wp[COMPONENT_Y].bPresentFlag, iNumRef==0?"luma_weight_l0_flag[i]":"luma_weight_l1_flag[i]" ); WRITE_FLAG(wp[COMPONENT_Y].presentFlag, iNumRef == 0 ? "luma_weight_l0_flag[i]" : "luma_weight_l1_flag[i]");
uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag; uiTotalSignalledWeightFlags += wp[COMPONENT_Y].presentFlag;
} }
if (bChroma) if (bChroma)
{ {
for ( int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) for ( int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
{ {
pcSlice->getWpScaling( eRefPicList, iRefIdx, wp ); wp = pcSlice->getWpScaling(eRefPicList, iRefIdx);
CHECK( wp[COMPONENT_Cb].bPresentFlag != wp[COMPONENT_Cr].bPresentFlag, "Inconsistent settings for chroma channels" ); CHECK(wp[COMPONENT_Cb].presentFlag != wp[COMPONENT_Cr].presentFlag,
WRITE_FLAG( wp[COMPONENT_Cb].bPresentFlag, iNumRef==0?"chroma_weight_l0_flag[i]":"chroma_weight_l1_flag[i]" ); "Inconsistent settings for chroma channels");