Commit 85fe66c8 authored by Xiang Li's avatar Xiang Li

Merge branch 'tamse.anish/VVCSoftware_VTM-M0193-Pairwise-Average-Candidate-Reduction'

parents ced582bb 2f26d1f2
Pipeline #635 passed with stage
......@@ -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
......
......@@ -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 );
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment