diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 5a7a23d7c3d40d6391fe563cd7edbf49b4072248..06c4f8ccf7e6966252afa1d720446fcb8dbd8cc1 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -50,6 +50,8 @@ #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 diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp index b4950ee80d1d552a7a9f07bd61ed0578144f5697..84381632a3c07841b7f90f4adcaee74563ac865e 100644 --- a/source/Lib/CommonLib/UnitTools.cpp +++ b/source/Lib/CommonLib/UnitTools.cpp @@ -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 ); } }