Commit a73dc51f authored by LI JINGYA's avatar LI JINGYA
parents 11168f39 fd57fec5
......@@ -765,11 +765,22 @@ void InterPrediction::xPredAffineBlk( const ComponentID& compID, const Predictio
else
{
#if JVET_M0265_MV_ROUNDING_CLEANUP
#if JVET_M0192_AFF_CHROMA_SIMPL
Mv curMv = m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE) * MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE)] +
m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE + 1)* MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE + 1)];
roundAffineMv(curMv.hor, curMv.ver, 1);
#else
Mv curMv = m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE) * MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE)] +
m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE + 1)* MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE)] +
m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE)* MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE + 1)] +
m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE + 1)* MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE + 1)];
roundAffineMv(curMv.hor, curMv.ver, 2);
#endif
#else
#if JVET_M0192_AFF_CHROMA_SIMPL
Mv curMv = m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE) * MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE)] +
m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE + 1)* MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE + 1)];
roundAffineMv(curMv.hor, curMv.ver, 1);
#else
Mv curMv = (m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE) * MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE)] +
m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE + 1)* MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE)] +
......@@ -777,6 +788,7 @@ void InterPrediction::xPredAffineBlk( const ComponentID& compID, const Predictio
m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE + 1)* MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE + 1)] +
Mv(2, 2));
curMv.set(curMv.getHor() >> 2, curMv.getVer() >> 2);
#endif
#endif
if (sps.getWrapAroundEnabledFlag())
{
......@@ -1288,12 +1300,37 @@ void InterPrediction::motionCompensation4Triangle( CodingUnit &cu, MergeCtx &tri
PU::spanMotionInfo( pu );
motionCompensation( pu, predBuf );
#if JVET_M0328_KEEP_ONE_WEIGHT_GROUP
weightedTriangleBlk( pu, splitDir, MAX_NUM_CHANNEL_TYPE, predBuf, tmpTriangleBuf, predBuf );
#else
weightedTriangleBlk( pu, PU::getTriangleWeights(pu, triangleMrgCtx, candIdx0, candIdx1), splitDir, MAX_NUM_CHANNEL_TYPE, predBuf, tmpTriangleBuf, predBuf );
#endif
}
}
#if JVET_M0328_KEEP_ONE_WEIGHT_GROUP
void InterPrediction::weightedTriangleBlk( PredictionUnit &pu, const bool splitDir, int32_t channel, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1 )
#else
void InterPrediction::weightedTriangleBlk( PredictionUnit &pu, bool weights, const bool splitDir, int32_t channel, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1 )
#endif
{
#if JVET_M0328_KEEP_ONE_WEIGHT_GROUP
if( channel == CHANNEL_TYPE_LUMA )
{
xWeightedTriangleBlk( pu, pu.lumaSize().width, pu.lumaSize().height, COMPONENT_Y, splitDir, predDst, predSrc0, predSrc1 );
}
else if( channel == CHANNEL_TYPE_CHROMA )
{
xWeightedTriangleBlk( pu, pu.chromaSize().width, pu.chromaSize().height, COMPONENT_Cb, splitDir, predDst, predSrc0, predSrc1 );
xWeightedTriangleBlk( pu, pu.chromaSize().width, pu.chromaSize().height, COMPONENT_Cr, splitDir, predDst, predSrc0, predSrc1 );
}
else
{
xWeightedTriangleBlk( pu, pu.lumaSize().width, pu.lumaSize().height, COMPONENT_Y, splitDir, predDst, predSrc0, predSrc1 );
xWeightedTriangleBlk( pu, pu.chromaSize().width, pu.chromaSize().height, COMPONENT_Cb, splitDir, predDst, predSrc0, predSrc1 );
xWeightedTriangleBlk( pu, pu.chromaSize().width, pu.chromaSize().height, COMPONENT_Cr, splitDir, predDst, predSrc0, predSrc1 );
}
#else
if( channel == CHANNEL_TYPE_LUMA )
{
xWeightedTriangleBlk( pu, pu.lumaSize().width, pu.lumaSize().height, COMPONENT_Y, splitDir, weights, predDst, predSrc0, predSrc1 );
......@@ -1309,9 +1346,14 @@ void InterPrediction::weightedTriangleBlk( PredictionUnit &pu, bool weights, con
xWeightedTriangleBlk( pu, pu.chromaSize().width, pu.chromaSize().height, COMPONENT_Cb, splitDir, weights, predDst, predSrc0, predSrc1 );
xWeightedTriangleBlk( pu, pu.chromaSize().width, pu.chromaSize().height, COMPONENT_Cr, splitDir, weights, predDst, predSrc0, predSrc1 );
}
#endif
}
#if JVET_M0328_KEEP_ONE_WEIGHT_GROUP
void InterPrediction::xWeightedTriangleBlk( const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const bool splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1 )
#else
void InterPrediction::xWeightedTriangleBlk( const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const bool splitDir, const bool weights, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1 )
#endif
{
Pel* dst = predDst .get(compIdx).buf;
Pel* src0 = predSrc0.get(compIdx).buf;
......@@ -1330,13 +1372,23 @@ void InterPrediction::xWeightedTriangleBlk( const PredictionUnit &pu, const uint
const int32_t ratioWH = (width > height) ? (width / height) : 1;
const int32_t ratioHW = (width > height) ? 1 : (height / width);
#if JVET_M0328_KEEP_ONE_WEIGHT_GROUP
const bool longWeight = (compIdx == COMPONENT_Y) || ( predDst.chromaFormat == CHROMA_444 );
const int32_t weightedLength = longWeight ? 7 : 3;
#else
const Pel* pelWeighted = (compIdx == COMPONENT_Y) ? g_trianglePelWeightedLuma[splitDir][weights] : g_trianglePelWeightedChroma[predDst.chromaFormat == CHROMA_444 ? 0 : 1][splitDir][weights];
const int32_t weightedLength = (compIdx == COMPONENT_Y) ? g_triangleWeightLengthLuma[weights] : g_triangleWeightLengthChroma[predDst.chromaFormat == CHROMA_444 ? 0 : 1][weights];
#endif
int32_t weightedStartPos = ( splitDir == 0 ) ? ( 0 - (weightedLength >> 1) * ratioWH ) : ( width - ((weightedLength + 1) >> 1) * ratioWH );
int32_t weightedEndPos = weightedStartPos + weightedLength * ratioWH - 1;
int32_t weightedPosoffset =( splitDir == 0 ) ? ratioWH : -ratioWH;
#if JVET_M0328_KEEP_ONE_WEIGHT_GROUP
Pel tmpPelWeighted;
int32_t weightIdx;
#else
const Pel* tmpPelWeighted;
#endif
int32_t x, y, tmpX, tmpY, tmpWeightedStart, tmpWeightedEnd;
for( y = 0; y < height; y+= ratioHW )
......@@ -1352,18 +1404,36 @@ void InterPrediction::xWeightedTriangleBlk( const PredictionUnit &pu, const uint
tmpWeightedStart = std::max((int32_t)0, weightedStartPos);
tmpWeightedEnd = std::min(weightedEndPos, (int32_t)(width - 1));
#if JVET_M0328_KEEP_ONE_WEIGHT_GROUP
weightIdx = 1;
#else
tmpPelWeighted = pelWeighted;
#endif
if( weightedStartPos < 0 )
{
#if JVET_M0328_KEEP_ONE_WEIGHT_GROUP
weightIdx += abs(weightedStartPos) / ratioWH;
#else
tmpPelWeighted += abs(weightedStartPos) / ratioWH;
#endif
}
for( x = tmpWeightedStart; x <= tmpWeightedEnd; x+= ratioWH )
{
for( tmpX = ratioWH; tmpX > 0; tmpX-- )
{
#if JVET_M0328_KEEP_ONE_WEIGHT_GROUP
tmpPelWeighted = Clip3( 1, 7, longWeight ? weightIdx : (weightIdx * 2));
tmpPelWeighted = splitDir ? ( 8 - tmpPelWeighted ) : tmpPelWeighted;
*dst++ = ClipPel( rightShift( (tmpPelWeighted*(*src0++) + ((8 - tmpPelWeighted) * (*src1++)) + offsetWeighted), shiftWeighted ), clipRng );
#else
*dst++ = ClipPel( rightShift( ((*tmpPelWeighted)*(*src0++) + ((8 - (*tmpPelWeighted)) * (*src1++)) + offsetWeighted), shiftWeighted ), clipRng );
#endif
}
#if JVET_M0328_KEEP_ONE_WEIGHT_GROUP
weightIdx ++;
#else
tmpPelWeighted++;
#endif
}
for( x = weightedEndPos + 1; x < width; x++ )
......
......@@ -129,7 +129,11 @@ protected:
void xWeightedAverage ( const PredictionUnit& pu, const CPelUnitBuf& pcYuvSrc0, const CPelUnitBuf& pcYuvSrc1, PelUnitBuf& pcYuvDst, const BitDepths& clipBitDepths, const ClpRngs& clpRngs, const bool& bioApplied );
void xPredAffineBlk( const ComponentID& compID, const PredictionUnit& pu, const Picture* refPic, const Mv* _mv, PelUnitBuf& dstPic, const bool& bi, const ClpRng& clpRng );
#if JVET_M0328_KEEP_ONE_WEIGHT_GROUP
void xWeightedTriangleBlk ( const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const bool splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1 );
#else
void xWeightedTriangleBlk ( const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const bool splitDir, const bool weights, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1 );
#endif
static bool xCheckIdenticalMotion( const PredictionUnit& pu );
......@@ -160,7 +164,11 @@ public:
);
void motionCompensation4Triangle( CodingUnit &cu, MergeCtx &triangleMrgCtx, const bool splitDir, const uint8_t candIdx0, const uint8_t candIdx1 );
#if JVET_M0328_KEEP_ONE_WEIGHT_GROUP
void weightedTriangleBlk ( PredictionUnit &pu, const bool splitDir, int32_t channel, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1 );
#else
void weightedTriangleBlk ( PredictionUnit &pu, bool weights, const bool splitDir, int32_t channel, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1 );
#endif
#if JVET_J0090_MEMORY_BANDWITH_MEASURE
void cacheAssign( CacheModel *cache );
......
......@@ -806,6 +806,7 @@ const uint8_t g_NonMPM[257] = { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8 };
#if !JVET_M0328_KEEP_ONE_WEIGHT_GROUP
const Pel g_trianglePelWeightedLuma[TRIANGLE_DIR_NUM][2][7] =
{
{ // TRIANGLE_DIR_135
......@@ -843,9 +844,11 @@ const Pel g_trianglePelWeightedChroma[2][TRIANGLE_DIR_NUM][2][7] =
const uint8_t g_triangleWeightLengthLuma[2] = { 5, 7 };
const uint8_t g_triangleWeightLengthChroma[2][2] = { { 5, 7 }, { 3, 3 } };
#endif
uint8_t g_triangleMvStorage[TRIANGLE_DIR_NUM][MAX_CU_DEPTH - MIN_CU_LOG2 + 1][MAX_CU_DEPTH - MIN_CU_LOG2 + 1][MAX_CU_SIZE >> MIN_CU_LOG2][MAX_CU_SIZE >> MIN_CU_LOG2];
#if !JVET_M0883_TRIANGLE_SIGNALING
const uint8_t g_triangleCombination[TRIANGLE_MAX_NUM_CANDS][3] =
{
{ 0, 1, 0 }, { 1, 0, 1 }, { 1, 0, 2 }, { 0, 0, 1 }, { 0, 2, 0 },
......@@ -865,4 +868,5 @@ const uint8_t g_triangleIdxBins[TRIANGLE_MAX_NUM_CANDS] =
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10
};
#endif
//! \}
......@@ -246,13 +246,17 @@ constexpr uint8_t g_tbMax[257] = { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3,
//! \}
#if !JVET_M0328_KEEP_ONE_WEIGHT_GROUP
extern const Pel g_trianglePelWeightedLuma[TRIANGLE_DIR_NUM][2][7];
extern const Pel g_trianglePelWeightedChroma[2][TRIANGLE_DIR_NUM][2][7];
extern const uint8_t g_triangleWeightLengthLuma[2];
extern const uint8_t g_triangleWeightLengthChroma[2][2];
#endif
extern uint8_t g_triangleMvStorage[TRIANGLE_DIR_NUM][MAX_CU_DEPTH - MIN_CU_LOG2 + 1][MAX_CU_DEPTH - MIN_CU_LOG2 + 1][MAX_CU_SIZE >> MIN_CU_LOG2][MAX_CU_SIZE >> MIN_CU_LOG2];
#if !JVET_M0883_TRIANGLE_SIGNALING
extern const uint8_t g_triangleCombination[TRIANGLE_MAX_NUM_CANDS][3];
extern const uint8_t g_triangleIdxBins[TRIANGLE_MAX_NUM_CANDS];
#endif
#endif //__TCOMROM__
......@@ -1801,9 +1801,6 @@ SPSNext::SPSNext( SPS& sps )
, m_MTTEnabled ( false )
, m_MHIntra ( false )
, m_Triangle ( false )
#if JVET_M0255_FRACMMVD_SWITCH
, allowDisFracMMVD ( false )
#endif
#if ENABLE_WPP_PARALLELISM
, m_NextDQP ( false )
#endif
......@@ -1873,6 +1870,9 @@ SPS::SPS()
, m_bPCMFilterDisableFlag (false)
, m_sbtmvpEnabledFlag (false)
, m_bdofEnabledFlag (false)
#if JVET_M0255_FRACMMVD_SWITCH
, m_disFracMmvdEnabledFlag ( false )
#endif
, m_uiBitsForPOC ( 8)
, m_numLongTermRefPicSPS ( 0)
, m_uiMaxTrSize ( 32)
......
......@@ -820,9 +820,6 @@ private:
bool m_MTTEnabled; //
bool m_MHIntra;
bool m_Triangle;
#if JVET_M0255_FRACMMVD_SWITCH
bool allowDisFracMMVD;
#endif
#if ENABLE_WPP_PARALLELISM
bool m_NextDQP;
#endif
......@@ -919,10 +916,6 @@ public:
bool getUseTriangle () const { return m_Triangle; }
void setIBCMode (unsigned IBCMode) { m_IBCMode = IBCMode; }
unsigned getIBCMode () const { return m_IBCMode; }
#if JVET_M0255_FRACMMVD_SWITCH
void setAllowDisFracMMVD ( bool b ) { allowDisFracMMVD = b; }
bool getAllowDisFracMMVD () const { return allowDisFracMMVD; }
#endif
};
......@@ -997,7 +990,9 @@ private:
bool m_sbtmvpEnabledFlag;
bool m_bdofEnabledFlag;
#if JVET_M0255_FRACMMVD_SWITCH
bool m_disFracMmvdEnabledFlag;
#endif
uint32_t m_uiBitsForPOC;
uint32_t m_numLongTermRefPicSPS;
uint32_t m_ltRefPicPocLsbSps[MAX_NUM_LONG_TERM_REF_PICS];
......@@ -1200,6 +1195,11 @@ public:
void setBDOFEnabledFlag(bool b) { m_bdofEnabledFlag = b; }
bool getBDOFEnabledFlag() const { return m_bdofEnabledFlag; }
#if JVET_M0255_FRACMMVD_SWITCH
bool getDisFracMmvdEnabledFlag() const { return m_disFracMmvdEnabledFlag; }
void setDisFracMmvdEnabledFlag( bool b ) { m_disFracMmvdEnabledFlag = b; }
#endif
uint32_t getMaxTLayers() const { return m_uiMaxTLayers; }
void setMaxTLayers( uint32_t uiMaxTLayers ) { CHECK( uiMaxTLayers > MAX_TLAYER, "Invalid number T-layers" ); m_uiMaxTLayers = uiMaxTLayers; }
......
......@@ -50,11 +50,16 @@
#include <assert.h>
#include <cassert>
#define JVET_M0193_PAIR_AVG_REDUCTION 1 //Use only one pairwise average candidate
#define JVET_M0192_AFF_CHROMA_SIMPL 1 // Affine chroma MV derivation simplification and rounding unification
#define JVET_M0116_ATMVP_LEFT_NB_FOR_OFFSET 1 // Only use left neighbor for ATMVP offset derivation, from M0273, M0240, M0116, M0338, M0204
#define JVET_M0063_BDOF_FIX 1 // BDOF bitdepth bugfix
#define JVET_M0265_MV_ROUNDING_CLEANUP 1 // Unify MV roundings and make SW/WD allignment
#define JVET_M0883_TRIANGLE_SIGNALING 1 // Using regular merge index signaling for triangle mode
#define JVET_M0228_REMOVE_CPMV_COMPARE 1 // Remove CPMV comparisons for construnted affine merge candidates from JVET-M0228, M0166, M0477
......@@ -79,6 +84,7 @@
#define JVET_M0142_CCLM_COLLOCATED_CHROMA 1 // Adding support for chroma sample location type 2 in CCLM
#define JVET_M0328_KEEP_ONE_WEIGHT_GROUP 1
#define JVET_M0479_18BITS_MV_CLIP 1
......
......@@ -343,6 +343,11 @@ void PredictionUnit::initData()
// inter data
mergeFlag = false;
mergeIdx = MAX_UCHAR;
#if JVET_M0883_TRIANGLE_SIGNALING
triangleSplitDir = MAX_UCHAR;
triangleMergeIdx0 = MAX_UCHAR;
triangleMergeIdx1 = MAX_UCHAR;
#endif
mmvdMergeFlag = false;
mmvdMergeIdx = MAX_UINT;
interDir = MAX_UCHAR;
......@@ -391,6 +396,11 @@ PredictionUnit& PredictionUnit::operator=(const InterPredictionData& predData)
{
mergeFlag = predData.mergeFlag;
mergeIdx = predData.mergeIdx;
#if JVET_M0883_TRIANGLE_SIGNALING
triangleSplitDir = predData.triangleSplitDir ;
triangleMergeIdx0 = predData.triangleMergeIdx0 ;
triangleMergeIdx1 = predData.triangleMergeIdx1 ;
#endif
mmvdMergeFlag = predData.mmvdMergeFlag;
mmvdMergeIdx = predData.mmvdMergeIdx;
interDir = predData.interDir;
......@@ -431,6 +441,11 @@ PredictionUnit& PredictionUnit::operator=( const PredictionUnit& other )
mergeFlag = other.mergeFlag;
mergeIdx = other.mergeIdx;
#if JVET_M0883_TRIANGLE_SIGNALING
triangleSplitDir = other.triangleSplitDir ;
triangleMergeIdx0 = other.triangleMergeIdx0 ;
triangleMergeIdx1 = other.triangleMergeIdx1 ;
#endif
mmvdMergeFlag = other.mmvdMergeFlag;
mmvdMergeIdx = other.mmvdMergeIdx;
interDir = other.interDir;
......
......@@ -358,6 +358,11 @@ struct InterPredictionData
{
bool mergeFlag;
uint8_t mergeIdx;
#if JVET_M0883_TRIANGLE_SIGNALING
uint8_t triangleSplitDir;
uint8_t triangleMergeIdx0;
uint8_t triangleMergeIdx1;
#endif
bool mmvdMergeFlag;
uint32_t mmvdMergeIdx;
uint8_t interDir;
......
......@@ -1222,15 +1222,24 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx,
#if JVET_L0090_PAIR_AVG
// pairwise-average candidates
{
#if !JVET_M0193_PAIR_AVG_REDUCTION
const int cutoff = std::min( cnt, 4 );
const int end = cutoff * (cutoff - 1) / 2;
constexpr int PRIORITY_LIST0[] = { 0, 0, 1, 0, 1, 2 };
constexpr int PRIORITY_LIST1[] = { 1, 2, 2, 3, 3, 3 };
#endif
#if JVET_M0193_PAIR_AVG_REDUCTION
// skip when only 1 candidate is added so far or one is BV and one is MV
if( cnt > 1 && cnt < maxNumMergeCand && !(mrgCtx.mrgTypeNeighbours[0] != mrgCtx.mrgTypeNeighbours[1] && pu.cs->sps->getSpsNext().getIBCMode()))
#else
for( int idx = 0; idx < end && cnt != maxNumMergeCand; idx++ )
#endif
{
#if !JVET_M0193_PAIR_AVG_REDUCTION
const int i = PRIORITY_LIST0[idx];
const int j = PRIORITY_LIST1[idx];
#endif
mrgCtx.mvFieldNeighbours[cnt * 2].setMvField( Mv( 0, 0 ), NOT_VALID );
mrgCtx.mvFieldNeighbours[cnt * 2 + 1].setMvField( Mv( 0, 0 ), NOT_VALID );
......@@ -1238,15 +1247,22 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx,
unsigned char interDir = 0;
#if !JVET_M0193_PAIR_AVG_REDUCTION
// skip when one is BV and one is MV
if (mrgCtx.mrgTypeNeighbours[i] != mrgCtx.mrgTypeNeighbours[j] && pu.cs->sps->getSpsNext().getIBCMode())
{
continue;
}
#endif
for( int refListId = 0; refListId < (slice.isInterB() ? 2 : 1); refListId++ )
{
#if JVET_M0193_PAIR_AVG_REDUCTION
const short refIdxI = mrgCtx.mvFieldNeighbours[0 * 2 + refListId].refIdx;
const short refIdxJ = mrgCtx.mvFieldNeighbours[1 * 2 + refListId].refIdx;
#else
const short refIdxI = mrgCtx.mvFieldNeighbours[i * 2 + refListId].refIdx;
const short refIdxJ = mrgCtx.mvFieldNeighbours[j * 2 + refListId].refIdx;
#endif
// both MVs are invalid, skip
if( (refIdxI == NOT_VALID) && (refIdxJ == NOT_VALID) )
......@@ -1258,8 +1274,13 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx,
// both MVs are valid, average these two MVs
if( (refIdxI != NOT_VALID) && (refIdxJ != NOT_VALID) )
{
#if JVET_M0193_PAIR_AVG_REDUCTION
const Mv& MvI = mrgCtx.mvFieldNeighbours[0 * 2 + refListId].mv;
const Mv& MvJ = mrgCtx.mvFieldNeighbours[1 * 2 + refListId].mv;
#else
const Mv& MvI = mrgCtx.mvFieldNeighbours[i * 2 + refListId].mv;
const Mv& MvJ = mrgCtx.mvFieldNeighbours[j * 2 + refListId].mv;
#endif
// average two MVs
Mv avgMv = MvI;
......@@ -1272,7 +1293,11 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx,
#endif
#if JVET_M0193_PAIR_AVG_REDUCTION
if (mrgCtx.mrgTypeNeighbours[0] == MRG_TYPE_IBC && mrgCtx.mrgTypeNeighbours[1] == MRG_TYPE_IBC && pu.cs->sps->getSpsNext().getIBCMode())
#else
if (mrgCtx.mrgTypeNeighbours[i] == MRG_TYPE_IBC && mrgCtx.mrgTypeNeighbours[j] == MRG_TYPE_IBC && pu.cs->sps->getSpsNext().getIBCMode())
#endif
{
mrgCtx.mrgTypeNeighbours[cnt] = MRG_TYPE_IBC;
avgMv.setHor((avgMv.getHor() / 16) << 4);
......@@ -1284,12 +1309,20 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx,
// only one MV is valid, take the only one MV
else if( refIdxI != NOT_VALID )
{
#if JVET_M0193_PAIR_AVG_REDUCTION
Mv singleMv = mrgCtx.mvFieldNeighbours[0 * 2 + refListId].mv;
#else
Mv singleMv = mrgCtx.mvFieldNeighbours[i * 2 + refListId].mv;
#endif
mrgCtx.mvFieldNeighbours[cnt * 2 + refListId].setMvField( singleMv, refIdxI );
}
else if( refIdxJ != NOT_VALID )
{
#if JVET_M0193_PAIR_AVG_REDUCTION
Mv singleMv = mrgCtx.mvFieldNeighbours[1 * 2 + refListId].mv;
#else
Mv singleMv = mrgCtx.mvFieldNeighbours[j * 2 + refListId].mv;
#endif
mrgCtx.mvFieldNeighbours[cnt * 2 + refListId].setMvField( singleMv, refIdxJ );
}
}
......@@ -3955,7 +3988,6 @@ void PU::getTriangleMergeCandidates( const PredictionUnit &pu, MergeCtx& triangl
candCount++;
}
}
// put uni-prediction candidate to the triangle candidate list
for( int32_t i = 0; i < candCount; i++ )
{
......@@ -4090,6 +4122,7 @@ bool PU::isUniqueTriangleCandidates( const PredictionUnit &pu, MergeCtx& triangl
return true;
}
#if !JVET_M0328_KEEP_ONE_WEIGHT_GROUP
bool PU::getTriangleWeights( const PredictionUnit& pu, MergeCtx &triangleMrgCtx, const uint8_t candIdx0, const uint8_t candIdx1 )
{
RefPicList refPicListCand0 = triangleMrgCtx.interDirNeighbours[candIdx0] == 1 ? REF_PIC_LIST_0 : REF_PIC_LIST_1;
......@@ -4114,10 +4147,21 @@ bool PU::getTriangleWeights( const PredictionUnit& pu, MergeCtx &triangleMrgCtx,
return false;
}
#endif
#if JVET_M0883_TRIANGLE_SIGNALING
void PU::spanTriangleMotionInfo( PredictionUnit &pu, MergeCtx &triangleMrgCtx, const bool splitDir, const uint8_t candIdx0, const uint8_t candIdx1 )
#else
void PU::spanTriangleMotionInfo( PredictionUnit &pu, MergeCtx &triangleMrgCtx, const uint8_t mergeIdx, const bool splitDir, const uint8_t candIdx0, const uint8_t candIdx1 )
#endif
{
#if JVET_M0883_TRIANGLE_SIGNALING
pu.triangleSplitDir = splitDir;
pu.triangleMergeIdx0 = candIdx0;
pu.triangleMergeIdx1 = candIdx1;
#else
pu.mergeIdx = mergeIdx;
#endif
MotionBuf mb = pu.getMotionBuf();
MotionInfo biMv;
......
......@@ -160,8 +160,14 @@ namespace PU
int getNarrowShape (const int width, const int height);
void getTriangleMergeCandidates (const PredictionUnit &pu, MergeCtx &triangleMrgCtx);
bool isUniqueTriangleCandidates (const PredictionUnit &pu, MergeCtx &triangleMrgCtx);
#if !JVET_M0328_KEEP_ONE_WEIGHT_GROUP
bool getTriangleWeights (const PredictionUnit &pu, MergeCtx &triangleMrgCtx, const uint8_t candIdx0, const uint8_t candIdx1);
#endif
#if JVET_M0883_TRIANGLE_SIGNALING
void spanTriangleMotionInfo ( PredictionUnit &pu, MergeCtx &triangleMrgCtx, const bool splitDir, const uint8_t candIdx0, const uint8_t candIdx1);
#else
void spanTriangleMotionInfo ( PredictionUnit &pu, MergeCtx &triangleMrgCtx, const uint8_t mergeIdx, const bool splitDir, const uint8_t candIdx0, const uint8_t candIdx1);
#endif
int32_t mappingRefPic (const PredictionUnit &pu, int32_t refPicPoc, bool targetRefPicList);
void getIbcMVPsEncOnly(PredictionUnit &pu, Mv* MvPred, int& nbPred);
bool getDerivedBV(PredictionUnit &pu, const Mv& currentMv, Mv& derivedMv);
......
......@@ -1637,6 +1637,38 @@ void CABACReader::merge_idx( PredictionUnit& pu )
if( pu.cu->triangle )
{
RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET( STATS__CABAC_BITS__TRIANGLE_INDEX );
#if JVET_M0883_TRIANGLE_SIGNALING
bool splitDir;
uint8_t candIdx0;
uint8_t candIdx1;
splitDir = m_BinDecoder.decodeBinEP();
auto decodeOneIdx = [this](int numCandminus1) -> uint8_t
{
uint8_t decIdx = 0;
if( numCandminus1 > 0 )
{
if( this->m_BinDecoder.decodeBin( Ctx::MergeIdx() ) )
{
decIdx++;
for( ; decIdx < numCandminus1; decIdx++ )
{
if( !this->m_BinDecoder.decodeBinEP() )
break;
}
}
}
return decIdx;
};
candIdx0 = decodeOneIdx(TRIANGLE_MAX_NUM_UNI_CANDS - 1);
candIdx1 = decodeOneIdx(TRIANGLE_MAX_NUM_UNI_CANDS - 2);
candIdx1 += candIdx1 >= candIdx0 ? 1 : 0;
DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() triangle_split_dir=%d\n", splitDir );
DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() triangle_idx0=%d\n", candIdx0 );
DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() triangle_idx1=%d\n", candIdx1 );
pu.triangleSplitDir = splitDir;
pu.triangleMergeIdx0 = candIdx0;
pu.triangleMergeIdx1 = candIdx1;
#else
if( m_BinDecoder.decodeBin( Ctx::TriangleIdx() ) == 0 )
{
pu.mergeIdx += m_BinDecoder.decodeBinEP();
......@@ -1647,6 +1679,7 @@ void CABACReader::merge_idx( PredictionUnit& pu )
}
DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() triangle_idx=%d\n", pu.mergeIdx );
#endif
return;
}
......
......@@ -352,12 +352,22 @@ void DecCu::xReconInter(CodingUnit &cu)
{
if( cu.triangle )
{
#if JVET_M0883_TRIANGLE_SIGNALING
const bool splitDir = cu.firstPU->triangleSplitDir;
const uint8_t candIdx0 = cu.firstPU->triangleMergeIdx0;
const uint8_t candIdx1 = cu.firstPU->triangleMergeIdx1;
#else
const uint8_t mergeIdx = cu.firstPU->mergeIdx;
const bool splitDir = g_triangleCombination[mergeIdx][0];
const uint8_t candIdx0 = g_triangleCombination[mergeIdx][1];
const uint8_t candIdx1 = g_triangleCombination[mergeIdx][2];
#endif
m_pcInterPred->motionCompensation4Triangle( cu, m_triangleMrgCtx, splitDir, candIdx0, candIdx1 );
#if JVET_M0883_TRIANGLE_SIGNALING
PU::spanTriangleMotionInfo( *cu.firstPU, m_triangleMrgCtx, splitDir, candIdx0, candIdx1 );
#else
PU::spanTriangleMotionInfo( *cu.firstPU, m_triangleMrgCtx, mergeIdx, splitDir, candIdx0, candIdx1 );
#endif
}
else
{
......
......@@ -818,9 +818,6 @@ void HLSyntaxReader::parseSPSNext( SPSNext& spsNext, const bool usePCM )
}
READ_FLAG( symbol, "mtt_enabled_flag" ); spsNext.setMTTMode ( symbol );
READ_FLAG( symbol, "mhintra_flag" ); spsNext.setUseMHIntra ( symbol != 0 );
#if JVET_M0255_FRACMMVD_SWITCH
READ_FLAG( symbol, "sps_fracmmvd_disabled_flag" ); spsNext.setAllowDisFracMMVD ( symbol != 0 );
#endif
READ_FLAG( symbol, "triangle_flag" ); spsNext.setUseTriangle ( symbol != 0 );
#if ENABLE_WPP_PARALLELISM