Commit c3941585 authored by Yu Han's avatar Yu Han
Browse files

Bug fix on GBiIdx order

parent d585bf2a
...@@ -106,11 +106,11 @@ struct MotionInfo ...@@ -106,11 +106,11 @@ struct MotionInfo
#endif #endif
char interDir; char interDir;
uint16_t sliceIdx; uint16_t sliceIdx;
Mv mv [ NUM_REF_PIC_LIST_01 ];
int16_t refIdx [ NUM_REF_PIC_LIST_01 ];
#if JVET_M0264_HMVP_WITH_GBIIDX #if JVET_M0264_HMVP_WITH_GBIIDX
uint8_t GBiIdx; uint8_t GBiIdx;
#endif #endif
Mv mv [ NUM_REF_PIC_LIST_01 ];
int16_t refIdx [ NUM_REF_PIC_LIST_01 ];
Mv bv; Mv bv;
#if JVET_M0483_IBC #if JVET_M0483_IBC
#if JVET_M0264_HMVP_WITH_GBIIDX #if JVET_M0264_HMVP_WITH_GBIIDX
...@@ -128,7 +128,7 @@ struct MotionInfo ...@@ -128,7 +128,7 @@ struct MotionInfo
#if JVET_M0264_HMVP_WITH_GBIIDX #if JVET_M0264_HMVP_WITH_GBIIDX
MotionInfo() : isInter(false), interDir(0), sliceIdx(0), refIdx{ NOT_VALID, NOT_VALID }, GBiIdx(0) { } MotionInfo() : isInter(false), interDir(0), sliceIdx(0), refIdx{ NOT_VALID, NOT_VALID }, GBiIdx(0) { }
#else #else
MotionInfo() : isInter( false ), interDir( 0 ), sliceIdx( 0 ), refIdx{ NOT_VALID, NOT_VALID } { } MotionInfo() : isInter(false), interDir( 0 ), sliceIdx( 0 ), refIdx{ NOT_VALID, NOT_VALID } { }
#endif #endif
// ensure that MotionInfo(0) produces '\x000....' bit pattern - needed to work with AreaBuf - don't use this constructor for anything else // ensure that MotionInfo(0) produces '\x000....' bit pattern - needed to work with AreaBuf - don't use this constructor for anything else
#if JVET_M0264_HMVP_WITH_GBIIDX #if JVET_M0264_HMVP_WITH_GBIIDX
......
...@@ -1022,7 +1022,7 @@ void PU::getIBCMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const ...@@ -1022,7 +1022,7 @@ void PU::getIBCMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const
#if JVET_L0090_PAIR_AVG #if JVET_L0090_PAIR_AVG
// pairwise-average candidates // pairwise-average candidates
{ #if JVET_M0193_PAIR_AVG_REDUCTION==0
const int cutoff = std::min(cnt, 4); const int cutoff = std::min(cnt, 4);
const int end = cutoff * (cutoff - 1) / 2; const int end = cutoff * (cutoff - 1) / 2;
constexpr int PRIORITY_LIST0[] = { 0, 0, 1, 0, 1, 2 }; constexpr int PRIORITY_LIST0[] = { 0, 0, 1, 0, 1, 2 };
...@@ -1032,49 +1032,34 @@ void PU::getIBCMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const ...@@ -1032,49 +1032,34 @@ void PU::getIBCMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const
{ {
const int i = PRIORITY_LIST0[idx]; const int i = PRIORITY_LIST0[idx];
const int j = PRIORITY_LIST1[idx]; const int j = PRIORITY_LIST1[idx];
#else
if (cnt>1 && cnt <maxNumMergeCand)
{
#endif
mrgCtx.mvFieldNeighbours[cnt * 2 ].setMvField(Mv(0, 0), NOT_VALID);
mrgCtx.mvFieldNeighbours[cnt * 2 + 1].setMvField(Mv(0, 0), NOT_VALID);
#if JVET_M0193_PAIR_AVG_REDUCTION
const Mv& MvI = mrgCtx.mvFieldNeighbours[0 * 2].mv;
const Mv& MvJ = mrgCtx.mvFieldNeighbours[1 * 2].mv;
#else
const Mv& MvI = mrgCtx.mvFieldNeighbours[i * 2 ].mv;
const Mv& MvJ = mrgCtx.mvFieldNeighbours[j * 2 ].mv;
#endif
// average two MVs
Mv avgMv = MvI;
mrgCtx.mvFieldNeighbours[cnt * 2].setMvField(Mv(0, 0), NOT_VALID); avgMv += MvJ;
mrgCtx.mvFieldNeighbours[cnt * 2 + 1].setMvField(Mv(0, 0), NOT_VALID); mrgCtx.mrgTypeNeighbours[cnt] = MRG_TYPE_IBC;
// calculate average MV for L0 and L1 seperately
unsigned char interDir = 0;
for (int refListId = 0; refListId < 1; refListId++)
{
const short refIdxI = mrgCtx.mvFieldNeighbours[i * 2 + refListId].refIdx;
const short refIdxJ = mrgCtx.mvFieldNeighbours[j * 2 + refListId].refIdx;
// both MVs are invalid, skip
if ((refIdxI == NOT_VALID) && (refIdxJ == NOT_VALID))
{
continue;
}
interDir += 1 << refListId;
// both MVs are valid, average these two MVs
if ((refIdxI != NOT_VALID) && (refIdxJ != NOT_VALID))
{
const Mv& MvI = mrgCtx.mvFieldNeighbours[i * 2 + refListId].mv;
const Mv& MvJ = mrgCtx.mvFieldNeighbours[j * 2 + refListId].mv;
// average two MVs
Mv avgMv = MvI;
avgMv += MvJ;
mrgCtx.mrgTypeNeighbours[cnt] = MRG_TYPE_IBC;
#if JVET_M0265_MV_ROUNDING_CLEANUP #if JVET_M0265_MV_ROUNDING_CLEANUP
roundAffineMv(avgMv.hor, avgMv.ver, 1); roundAffineMv(avgMv.hor, avgMv.ver, 1);
#else #else
avgMv.setHor(avgMv.getHor() / 2); avgMv.setHor(avgMv.getHor() / 2);
avgMv.setVer(avgMv.getVer() / 2); avgMv.setVer(avgMv.getVer() / 2);
#endif #endif
mrgCtx.mvFieldNeighbours[cnt * 2 + refListId].setMvField(avgMv, refIdxI); mrgCtx.mvFieldNeighbours[cnt * 2 ].setMvField(avgMv, MAX_NUM_REF);
} mrgCtx.interDirNeighbours[cnt] = 1;
} cnt++;
mrgCtx.interDirNeighbours[cnt] = interDir;
if (interDir > 0)
{
cnt++;
}
} }
// early termination // early termination
...@@ -1082,7 +1067,6 @@ void PU::getIBCMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const ...@@ -1082,7 +1067,6 @@ void PU::getIBCMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const
{ {
return; return;
} }
}
#endif #endif
mrgCtx.numValidMergeCand = cnt; mrgCtx.numValidMergeCand = cnt;
...@@ -1652,6 +1636,7 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, ...@@ -1652,6 +1636,7 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx,
avgMv.setVer( avgMv.getVer() / 2 ); avgMv.setVer( avgMv.getVer() / 2 );
#endif #endif
#if JVET_M0483_IBC==0
#if JVET_M0193_PAIR_AVG_REDUCTION #if JVET_M0193_PAIR_AVG_REDUCTION
if (mrgCtx.mrgTypeNeighbours[0] == MRG_TYPE_IBC && mrgCtx.mrgTypeNeighbours[1] == MRG_TYPE_IBC && pu.cs->sps->getSpsNext().getIBCMode()) if (mrgCtx.mrgTypeNeighbours[0] == MRG_TYPE_IBC && mrgCtx.mrgTypeNeighbours[1] == MRG_TYPE_IBC && pu.cs->sps->getSpsNext().getIBCMode())
#else #else
...@@ -1662,7 +1647,7 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, ...@@ -1662,7 +1647,7 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx,
avgMv.setHor((avgMv.getHor() / 16) << 4); avgMv.setHor((avgMv.getHor() / 16) << 4);
avgMv.setVer((avgMv.getVer() / 16) << 4); avgMv.setVer((avgMv.getVer() / 16) << 4);
} }
#endif
mrgCtx.mvFieldNeighbours[cnt * 2 + refListId].setMvField( avgMv, refIdxI ); mrgCtx.mvFieldNeighbours[cnt * 2 + refListId].setMvField( avgMv, refIdxI );
} }
// only one MV is valid, take the only one MV // only one MV is valid, take the only one MV
......
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