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

Add IBC from VTM3.0 to master

parent 818a0736
...@@ -746,7 +746,11 @@ void CodingStructure::useSubStructure( const CodingStructure& subStruct, const C ...@@ -746,7 +746,11 @@ void CodingStructure::useSubStructure( const CodingStructure& subStruct, const C
if( cpyResi ) picture->getResiBuf( clippedArea ).copyFrom( subResiBuf ); if( cpyResi ) picture->getResiBuf( clippedArea ).copyFrom( subResiBuf );
if( cpyReco ) picture->getRecoBuf( clippedArea ).copyFrom( subRecoBuf ); if( cpyReco ) picture->getRecoBuf( clippedArea ).copyFrom( subRecoBuf );
#if IBC_SEPERATE_MODE
if (!subStruct.m_isTuEnc && ((!slice->isIntra() || slice->getSPS()->getSpsNext().getIBCMode()) && subStruct.chType != CHANNEL_TYPE_CHROMA))
#else
if (!subStruct.m_isTuEnc && (!slice->isIntra() && subStruct.chType != CHANNEL_TYPE_CHROMA)) if (!subStruct.m_isTuEnc && (!slice->isIntra() && subStruct.chType != CHANNEL_TYPE_CHROMA))
#endif
{ {
// copy motion buffer // copy motion buffer
MotionBuf ownMB = getMotionBuf ( clippedArea ); MotionBuf ownMB = getMotionBuf ( clippedArea );
...@@ -926,7 +930,11 @@ void CodingStructure::copyStructure( const CodingStructure& other, const Channel ...@@ -926,7 +930,11 @@ void CodingStructure::copyStructure( const CodingStructure& other, const Channel
pu = *ppu; pu = *ppu;
} }
#if IBC_SEPERATE_MODE
if (!other.slice->isIntra() || other.slice->getSPS()->getSpsNext().getIBCMode())
#else
if( !other.slice->isIntra() ) if( !other.slice->isIntra() )
#endif
{ {
// copy motion buffer // copy motion buffer
MotionBuf ownMB = getMotionBuf(); MotionBuf ownMB = getMotionBuf();
...@@ -981,7 +989,11 @@ void CodingStructure::initStructData( const int &QP, const bool &_isLosses, cons ...@@ -981,7 +989,11 @@ void CodingStructure::initStructData( const int &QP, const bool &_isLosses, cons
isLossless = _isLosses; isLossless = _isLosses;
} }
#if IBC_SEPERATE_MODE
if (!skipMotBuf && (!parent || ((!slice->isIntra() || slice->getSPS()->getSpsNext().getIBCMode()) && !m_isTuEnc)))
#else
if( !skipMotBuf && ( !parent || ( ( slice->getSliceType() != I_SLICE ) && !m_isTuEnc ) ) ) if( !skipMotBuf && ( !parent || ( ( slice->getSliceType() != I_SLICE ) && !m_isTuEnc ) ) )
#endif
{ {
getMotionBuf() .memset( 0 ); getMotionBuf() .memset( 0 );
} }
......
...@@ -451,6 +451,20 @@ unsigned DeriveCtx::CtxPredModeFlag( const CodingUnit& cu ) ...@@ -451,6 +451,20 @@ unsigned DeriveCtx::CtxPredModeFlag( const CodingUnit& cu )
} }
#endif #endif
#if IBC_SEPERATE_MODE
unsigned DeriveCtx::CtxIBCFlag(const CodingUnit& cu)
{
const CodingStructure *cs = cu.cs;
unsigned ctxId = 0;
const CodingUnit *cuLeft = cs->getCURestricted(cu.lumaPos().offset(-1, 0), cu, CH_L);
ctxId = (cuLeft && CU::isIBC(*cuLeft)) ? 1 : 0;
const CodingUnit *cuAbove = cs->getCURestricted(cu.lumaPos().offset(0, -1), cu, CH_L);
ctxId = (cuAbove && CU::isIBC(*cuAbove)) ? 1 : 0;
return ctxId;
}
#endif
void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx ) void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx )
{ {
CHECK( candIdx >= numValidMergeCand, "Merge candidate does not exist" ); CHECK( candIdx >= numValidMergeCand, "Merge candidate does not exist" );
...@@ -470,12 +484,20 @@ void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx ) ...@@ -470,12 +484,20 @@ void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx )
pu.mvpIdx [REF_PIC_LIST_1] = NOT_VALID; pu.mvpIdx [REF_PIC_LIST_1] = NOT_VALID;
pu.mvpNum [REF_PIC_LIST_0] = NOT_VALID; pu.mvpNum [REF_PIC_LIST_0] = NOT_VALID;
pu.mvpNum [REF_PIC_LIST_1] = NOT_VALID; pu.mvpNum [REF_PIC_LIST_1] = NOT_VALID;
#if IBC_SEPERATE_MODE // remove macro VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE
if (CU::isIBC(*pu.cu))
{
pu.bv = pu.mv[REF_PIC_LIST_0];
pu.bv >>= (2 + MV_FRACTIONAL_BITS_DIFF); // used for only integer resolution
}
#else
if (interDirNeighbours[candIdx] == 1 && pu.cs->slice->getRefPic(REF_PIC_LIST_0, mvFieldNeighbours[candIdx << 1].refIdx)->getPOC() == pu.cs->slice->getPOC()) if (interDirNeighbours[candIdx] == 1 && pu.cs->slice->getRefPic(REF_PIC_LIST_0, mvFieldNeighbours[candIdx << 1].refIdx)->getPOC() == pu.cs->slice->getPOC())
{ {
pu.cu->ibc = true; pu.cu->ibc = true;
pu.bv = pu.mv[REF_PIC_LIST_0]; pu.bv = pu.mv[REF_PIC_LIST_0];
pu.bv.changePrecision(MV_PRECISION_INTERNAL, MV_PRECISION_INT); // used for only integer resolution pu.bv.changePrecision(MV_PRECISION_INTERNAL, MV_PRECISION_INT); // used for only integer resolution
} }
#endif
pu.cu->GBiIdx = ( interDirNeighbours[candIdx] == 3 ) ? GBiIdx[candIdx] : GBI_DEFAULT; pu.cu->GBiIdx = ( interDirNeighbours[candIdx] == 3 ) ? GBiIdx[candIdx] : GBI_DEFAULT;
#if JVET_M0068_M0171_MMVD_CLEANUP #if JVET_M0068_M0171_MMVD_CLEANUP
......
...@@ -317,6 +317,9 @@ unsigned CtxTriangleFlag( const CodingUnit& cu ); ...@@ -317,6 +317,9 @@ unsigned CtxTriangleFlag( const CodingUnit& cu );
#if JVET_M0502_PRED_MODE_CTX #if JVET_M0502_PRED_MODE_CTX
unsigned CtxPredModeFlag( const CodingUnit& cu ); unsigned CtxPredModeFlag( const CodingUnit& cu );
#endif #endif
#if IBC_SEPERATE_MODE
unsigned CtxIBCFlag(const CodingUnit& cu);
#endif
} }
#endif // __CONTEXTMODELLING__ #endif // __CONTEXTMODELLING__
...@@ -1326,6 +1326,21 @@ const CtxSet ContextSetCfg::TriangleIdx = ContextSetCfg::addCtxSet ...@@ -1326,6 +1326,21 @@ const CtxSet ContextSetCfg::TriangleIdx = ContextSetCfg::addCtxSet
}); });
// clang-format on // clang-format on
#if IBC_SEPERATE_MODE
const CtxSet ContextSetCfg::IBCFlag = ContextSetCfg::addCtxSet
({
#if TRAINED_CABAC_INIT_TABLES
{ 165, 137, 153, },
{ 106, 122, 138, },
{ CNU, CNU, CNU, },
#else
{ 151, 137, 154, },
{ 151, 137, 154, },
{ CNU, CNU, CNU, },
#endif
});
#endif
const unsigned ContextSetCfg::NumberOfContexts = (unsigned)ContextSetCfg::sm_InitTables[0].size(); const unsigned ContextSetCfg::NumberOfContexts = (unsigned)ContextSetCfg::sm_InitTables[0].size();
......
...@@ -306,6 +306,9 @@ public: ...@@ -306,6 +306,9 @@ public:
static const CtxSet TriangleIdx; static const CtxSet TriangleIdx;
#if JVET_M0444_SMVD #if JVET_M0444_SMVD
static const CtxSet SmvdFlag; static const CtxSet SmvdFlag;
#endif
#if IBC_SEPERATE_MODE
static const CtxSet IBCFlag;
#endif #endif
static const unsigned NumberOfContexts; static const unsigned NumberOfContexts;
......
...@@ -375,7 +375,11 @@ void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList& ...@@ -375,7 +375,11 @@ void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList&
int iRefIdx = pu.refIdx[eRefPicList]; int iRefIdx = pu.refIdx[eRefPicList];
Mv mv[3]; Mv mv[3];
bool isIBC = false; bool isIBC = false;
#if IBC_SEPERATE_MODE
if (CU::isIBC(*pu.cu))
#else
if (pu.cs->slice->getRefPic(eRefPicList, iRefIdx)->getPOC() == pu.cs->slice->getPOC()) if (pu.cs->slice->getRefPic(eRefPicList, iRefIdx)->getPOC() == pu.cs->slice->getPOC())
#endif
{ {
isIBC = true; isIBC = true;
} }
...@@ -411,11 +415,27 @@ void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList& ...@@ -411,11 +415,27 @@ void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList&
} }
else else
{ {
#if IBC_SEPERATE_MODE
if (isIBC)
{
xPredInterBlk(compID, pu, pu.cu->slice->getPic(), mv[0], pcYuvPred, bi, pu.cu->slice->clpRng(compID)
, bioApplied
, isIBC
);
}
else
{
xPredInterBlk(compID, pu, pu.cu->slice->getRefPic(eRefPicList, iRefIdx), mv[0], pcYuvPred, bi, pu.cu->slice->clpRng(compID)
, bioApplied
, isIBC
);
}
#else
xPredInterBlk( compID, pu, pu.cu->slice->getRefPic( eRefPicList, iRefIdx ), mv[0], pcYuvPred, bi, pu.cu->slice->clpRng( compID ) xPredInterBlk( compID, pu, pu.cu->slice->getRefPic( eRefPicList, iRefIdx ), mv[0], pcYuvPred, bi, pu.cu->slice->clpRng( compID )
, bioApplied , bioApplied
, isIBC , isIBC
); );
#endif
} }
} }
} }
...@@ -468,7 +488,12 @@ void InterPrediction::xPredInterBi(PredictionUnit& pu, PelUnitBuf &pcYuvPred) ...@@ -468,7 +488,12 @@ void InterPrediction::xPredInterBi(PredictionUnit& pu, PelUnitBuf &pcYuvPred)
RefPicList eRefPicList = (refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); RefPicList eRefPicList = (refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
#if IBC_SEPERATE_MODE
CHECK(pu.refIdx[refList] > slice.getNumRefIdx(eRefPicList), "Invalid reference index");
CHECK((CU::isInter(*pu.cu) && pu.refIdx[refList] >= slice.getNumRefIdx(eRefPicList)), "Invalid reference index");
#else
CHECK( pu.refIdx[refList] >= slice.getNumRefIdx( eRefPicList ), "Invalid reference index" ); CHECK( pu.refIdx[refList] >= slice.getNumRefIdx( eRefPicList ), "Invalid reference index" );
#endif
m_iRefListIdx = refList; m_iRefListIdx = refList;
PelUnitBuf pcMbBuf = ( pu.chromaFormat == CHROMA_400 ? PelUnitBuf pcMbBuf = ( pu.chromaFormat == CHROMA_400 ?
......
...@@ -101,19 +101,31 @@ struct MvField ...@@ -101,19 +101,31 @@ struct MvField
struct MotionInfo struct MotionInfo
{ {
bool isInter; bool isInter;
#if IBC_SEPERATE_MODE
bool isIBCmot;
#endif
char interDir; char interDir;
uint16_t sliceIdx; uint16_t sliceIdx;
Mv mv [ NUM_REF_PIC_LIST_01 ]; Mv mv [ NUM_REF_PIC_LIST_01 ];
int16_t refIdx [ NUM_REF_PIC_LIST_01 ]; int16_t refIdx [ NUM_REF_PIC_LIST_01 ];
Mv bv; Mv bv;
#if IBC_SEPERATE_MODE
MotionInfo() : isInter(false), isIBCmot(false), interDir(0), sliceIdx(0), refIdx{ NOT_VALID, NOT_VALID } { }
// ensure that MotionInfo(0) produces '\x000....' bit pattern - needed to work with AreaBuf - don't use this constructor for anything else
MotionInfo(int i) : isInter(i != 0), isIBCmot(false), interDir(0), sliceIdx(0), refIdx{ 0, 0 } { CHECKD(i != 0, "The argument for this constructor has to be '0'"); }
#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 } { }
// 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
MotionInfo( int i ) : isInter( i != 0 ), interDir( 0 ), sliceIdx( 0 ), refIdx{ 0, 0 } { CHECKD( i != 0, "The argument for this constructor has to be '0'" ); } MotionInfo( int i ) : isInter( i != 0 ), interDir( 0 ), sliceIdx( 0 ), refIdx{ 0, 0 } { CHECKD( i != 0, "The argument for this constructor has to be '0'" ); }
#endif
bool operator==( const MotionInfo& mi ) const bool operator==( const MotionInfo& mi ) const
{ {
if( isInter != mi.isInter ) return false; if( isInter != mi.isInter ) return false;
#if IBC_SEPERATE_MODE
if (isIBCmot != mi.isIBCmot) return false;
#endif
if( isInter ) if( isInter )
{ {
if( sliceIdx != mi.sliceIdx ) return false; if( sliceIdx != mi.sliceIdx ) return false;
...@@ -211,5 +223,8 @@ struct LutMotionCand ...@@ -211,5 +223,8 @@ struct LutMotionCand
{ {
MotionInfo* motionCand; MotionInfo* motionCand;
int currCnt; int currCnt;
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
int currCntIBC;
#endif
}; };
#endif // __MOTIONINFO__ #endif // __MOTIONINFO__
...@@ -435,6 +435,7 @@ void Slice::setRefPicList( PicList& rcListPic, bool checkNumPocTotalCurr, bool b ...@@ -435,6 +435,7 @@ void Slice::setRefPicList( PicList& rcListPic, bool checkNumPocTotalCurr, bool b
pcRefPic = xGetLongTermRefPic(rcListPic, m_pRPS->getPOC(i), m_pRPS->getCheckLTMSBPresent(i)); pcRefPic = xGetLongTermRefPic(rcListPic, m_pRPS->getPOC(i), m_pRPS->getCheckLTMSBPresent(i));
} }
} }
#if IBC_SEPERATE_MODE==0
if (getSPS()->getSpsNext().getIBCMode()) if (getSPS()->getSpsNext().getIBCMode())
{ {
RefPicSetLtCurr[NumPicLtCurr] = getPic(); RefPicSetLtCurr[NumPicLtCurr] = getPic();
...@@ -442,6 +443,7 @@ void Slice::setRefPicList( PicList& rcListPic, bool checkNumPocTotalCurr, bool b ...@@ -442,6 +443,7 @@ void Slice::setRefPicList( PicList& rcListPic, bool checkNumPocTotalCurr, bool b
getPic()->longTerm = true; getPic()->longTerm = true;
NumPicLtCurr++; NumPicLtCurr++;
} }
#endif
// ref_pic_list_init // ref_pic_list_init
Picture* rpsCurrList0[MAX_NUM_REF+1]; Picture* rpsCurrList0[MAX_NUM_REF+1];
Picture* rpsCurrList1[MAX_NUM_REF+1]; Picture* rpsCurrList1[MAX_NUM_REF+1];
...@@ -454,11 +456,13 @@ void Slice::setRefPicList( PicList& rcListPic, bool checkNumPocTotalCurr, bool b ...@@ -454,11 +456,13 @@ void Slice::setRefPicList( PicList& rcListPic, bool checkNumPocTotalCurr, bool b
// - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
if (getRapPicFlag()) if (getRapPicFlag())
{ {
#if IBC_SEPERATE_MODE==0
if (getSPS()->getSpsNext().getIBCMode()) if (getSPS()->getSpsNext().getIBCMode())
{ {
CHECK(numPicTotalCurr != 1, "Invalid state"); CHECK(numPicTotalCurr != 1, "Invalid state");
} }
else else
#endif
CHECK(numPicTotalCurr != 0, "Invalid state"); CHECK(numPicTotalCurr != 0, "Invalid state");
} }
...@@ -529,11 +533,13 @@ void Slice::setRefPicList( PicList& rcListPic, bool checkNumPocTotalCurr, bool b ...@@ -529,11 +533,13 @@ void Slice::setRefPicList( PicList& rcListPic, bool checkNumPocTotalCurr, bool b
m_bIsUsedAsLongTerm[REF_PIC_LIST_1][rIdx] = ( cIdx >= NumPicStCurr0 + NumPicStCurr1 ); m_bIsUsedAsLongTerm[REF_PIC_LIST_1][rIdx] = ( cIdx >= NumPicStCurr0 + NumPicStCurr1 );
} }
} }
#if IBC_SEPERATE_MODE==0
if (getSPS()->getSpsNext().getIBCMode()) if (getSPS()->getSpsNext().getIBCMode())
{ {
m_apcRefPicList[REF_PIC_LIST_0][m_aiNumRefIdx[REF_PIC_LIST_0] - 1] = getPic(); m_apcRefPicList[REF_PIC_LIST_0][m_aiNumRefIdx[REF_PIC_LIST_0] - 1] = getPic();
m_bIsUsedAsLongTerm[REF_PIC_LIST_0][m_aiNumRefIdx[REF_PIC_LIST_0] - 1] = true; m_bIsUsedAsLongTerm[REF_PIC_LIST_0][m_aiNumRefIdx[REF_PIC_LIST_0] - 1] = true;
} }
#endif
// For generalized B // For generalized B
// note: maybe not existed case (always L0 is copied to L1 if L1 is empty) // note: maybe not existed case (always L0 is copied to L1 if L1 is empty)
if( bCopyL0toL1ErrorCase && isInterB() && getNumRefIdx(REF_PIC_LIST_1) == 0) if( bCopyL0toL1ErrorCase && isInterB() && getNumRefIdx(REF_PIC_LIST_1) == 0)
...@@ -1612,14 +1618,28 @@ void Slice::initMotionLUTs() ...@@ -1612,14 +1618,28 @@ void Slice::initMotionLUTs()
{ {
m_MotionCandLut = new LutMotionCand; m_MotionCandLut = new LutMotionCand;
m_MotionCandLut->currCnt = 0; m_MotionCandLut->currCnt = 0;
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
m_MotionCandLut->currCntIBC = 0;
#endif
m_MotionCandLut->motionCand = nullptr; m_MotionCandLut->motionCand = nullptr;
#if IBC_SEPERATE_MODE
m_MotionCandLut->motionCand = new MotionInfo[MAX_NUM_HMVP_CANDS * 2];
#else
m_MotionCandLut->motionCand = new MotionInfo[MAX_NUM_HMVP_CANDS]; m_MotionCandLut->motionCand = new MotionInfo[MAX_NUM_HMVP_CANDS];
#endif
#if JVET_M0170_MRG_SHARELIST #if JVET_M0170_MRG_SHARELIST
m_MotionCandLuTsBkup = new LutMotionCand; m_MotionCandLuTsBkup = new LutMotionCand;
m_MotionCandLuTsBkup->currCnt = 0; m_MotionCandLuTsBkup->currCnt = 0;
#if IBC_SEPERATE_MODE_AND_MER && IBC_SEPERATE_MODE_REDUCTION==0
m_MotionCandLuTsBkup->currCntIBC = 0;
#endif
m_MotionCandLuTsBkup->motionCand = nullptr; m_MotionCandLuTsBkup->motionCand = nullptr;
#if IBC_SEPERATE_MODE_AND_MER
m_MotionCandLuTsBkup->motionCand = new MotionInfo[MAX_NUM_HMVP_CANDS * 2];
#else
m_MotionCandLuTsBkup->motionCand = new MotionInfo[MAX_NUM_HMVP_CANDS]; m_MotionCandLuTsBkup->motionCand = new MotionInfo[MAX_NUM_HMVP_CANDS];
#endif #endif
#endif
} }
void Slice::destroyMotionLUTs() void Slice::destroyMotionLUTs()
{ {
...@@ -1637,8 +1657,14 @@ void Slice::destroyMotionLUTs() ...@@ -1637,8 +1657,14 @@ void Slice::destroyMotionLUTs()
void Slice::resetMotionLUTs() void Slice::resetMotionLUTs()
{ {
m_MotionCandLut->currCnt = 0; m_MotionCandLut->currCnt = 0;
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
m_MotionCandLut->currCntIBC = 0;
#endif
#if JVET_M0170_MRG_SHARELIST #if JVET_M0170_MRG_SHARELIST
m_MotionCandLuTsBkup->currCnt = 0; m_MotionCandLuTsBkup->currCnt = 0;
#if IBC_SEPERATE_MODE_AND_MER && IBC_SEPERATE_MODE_REDUCTION==0
m_MotionCandLuTsBkup->currCntIBC = 0;
#endif
#endif #endif
} }
...@@ -1653,8 +1679,46 @@ MotionInfo Slice::getMotionInfoFromLUTBkup(int MotCandIdx) const ...@@ -1653,8 +1679,46 @@ MotionInfo Slice::getMotionInfoFromLUTBkup(int MotCandIdx) const
} }
#endif #endif
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
void Slice::addMotionInfoToLUTs(LutMotionCand* lutMC, MotionInfo newMi, bool ibcflag)
#else
void Slice::addMotionInfoToLUTs(LutMotionCand* lutMC, MotionInfo newMi) void Slice::addMotionInfoToLUTs(LutMotionCand* lutMC, MotionInfo newMi)
#endif
{ {
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
int currCntIBC = ibcflag ? lutMC->currCntIBC : lutMC->currCnt;
int offset = ibcflag ? MAX_NUM_HMVP_CANDS : 0;
bool pruned = false;
int sameCandIdx = 0;
for (int idx = 0; idx < currCntIBC; idx++)
{
if (lutMC->motionCand[idx + offset] == newMi)
{
sameCandIdx = idx;
pruned = true;
break;
}
}
if (pruned || currCntIBC == MAX_NUM_HMVP_CANDS)
{
memmove(&lutMC->motionCand[sameCandIdx + offset], &lutMC->motionCand[sameCandIdx + offset + 1],
sizeof(MotionInfo) * (currCntIBC - sameCandIdx - 1));
memcpy(&lutMC->motionCand[currCntIBC + offset - 1], &newMi, sizeof(MotionInfo));
}
else
{
if (ibcflag)
{
memcpy(&lutMC->motionCand[currCntIBC + offset], &newMi, sizeof(MotionInfo));
lutMC->currCntIBC++;
}
else
{
memcpy(&lutMC->motionCand[currCntIBC], &newMi, sizeof(MotionInfo));
lutMC->currCnt++;
}
}
#else
int currCnt = lutMC->currCnt ; int currCnt = lutMC->currCnt ;
bool pruned = false; bool pruned = false;
...@@ -1678,6 +1742,7 @@ void Slice::addMotionInfoToLUTs(LutMotionCand* lutMC, MotionInfo newMi) ...@@ -1678,6 +1742,7 @@ void Slice::addMotionInfoToLUTs(LutMotionCand* lutMC, MotionInfo newMi)
{ {
memcpy(&lutMC->motionCand[lutMC->currCnt++], &newMi, sizeof(MotionInfo)); memcpy(&lutMC->motionCand[lutMC->currCnt++], &newMi, sizeof(MotionInfo));
} }
#endif
} }
void Slice::updateMotionLUTs(LutMotionCand* lutMC, CodingUnit & cu) void Slice::updateMotionLUTs(LutMotionCand* lutMC, CodingUnit & cu)
...@@ -1686,19 +1751,34 @@ void Slice::updateMotionLUTs(LutMotionCand* lutMC, CodingUnit & cu) ...@@ -1686,19 +1751,34 @@ void Slice::updateMotionLUTs(LutMotionCand* lutMC, CodingUnit & cu)
if (cu.affine) { return; } if (cu.affine) { return; }
if (cu.triangle) { return; } if (cu.triangle) { return; }
MotionInfo newMi = selectedPU->getMotionInfo(); MotionInfo newMi = selectedPU->getMotionInfo();
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
addMotionInfoToLUTs(lutMC, newMi, CU::isIBC(cu));
#else
addMotionInfoToLUTs(lutMC, newMi); addMotionInfoToLUTs(lutMC, newMi);
#endif
} }
void Slice::copyMotionLUTs(LutMotionCand* Src, LutMotionCand* Dst) void Slice::copyMotionLUTs(LutMotionCand* Src, LutMotionCand* Dst)
{ {
memcpy(Dst->motionCand, Src->motionCand, sizeof(MotionInfo)*(std::min(Src->currCnt, MAX_NUM_HMVP_CANDS))); memcpy(Dst->motionCand, Src->motionCand, sizeof(MotionInfo)*(std::min(Src->currCnt, MAX_NUM_HMVP_CANDS)));
Dst->currCnt = Src->currCnt; Dst->currCnt = Src->currCnt;
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
memcpy(Dst->motionCand + MAX_NUM_HMVP_CANDS, Src->motionCand + MAX_NUM_HMVP_CANDS, sizeof(MotionInfo)*(std::min(Src->currCntIBC, MAX_NUM_HMVP_CANDS)));
Dst->currCntIBC = Src->currCntIBC;
#endif
} }
unsigned Slice::getMinPictureDistance() const unsigned Slice::getMinPictureDistance() const
{ {
int minPicDist = MAX_INT; int minPicDist = MAX_INT;
#if IBC_SEPERATE_MODE
if (getSPS()->getSpsNext().getIBCMode())
{
minPicDist = 0;
}
else
#endif
if( ! isIntra() ) if( ! isIntra() )
{ {
const int currPOC = getPOC(); const int currPOC = getPOC();
......
...@@ -1949,6 +1949,9 @@ public: ...@@ -1949,6 +1949,9 @@ public:
void initMotionLUTs (); void initMotionLUTs ();
void destroyMotionLUTs (); void destroyMotionLUTs ();
void resetMotionLUTs(); void resetMotionLUTs();
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
int getAvailableLUTIBCMrgNum() const { return m_MotionCandLut->currCntIBC; }
#endif
int getAvailableLUTMrgNum() const { return m_MotionCandLut->currCnt; } int getAvailableLUTMrgNum() const { return m_MotionCandLut->currCnt; }
#if JVET_M0170_MRG_SHARELIST #if JVET_M0170_MRG_SHARELIST
int getAvailableLUTBkupMrgNum() const { return m_MotionCandLuTsBkup->currCnt; } int getAvailableLUTBkupMrgNum() const { return m_MotionCandLuTsBkup->currCnt; }
...@@ -1957,8 +1960,11 @@ public: ...@@ -1957,8 +1960,11 @@ public:
MotionInfo getMotionInfoFromLUTs(int MotCandIdx) const; MotionInfo getMotionInfoFromLUTs(int MotCandIdx) const;
LutMotionCand* getMotionLUTs() { return m_MotionCandLut; } LutMotionCand* getMotionLUTs() { return m_MotionCandLut; }
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
void addMotionInfoToLUTs(LutMotionCand* lutMC, MotionInfo newMi, bool ibcflag);
#else
void addMotionInfoToLUTs(LutMotionCand* lutMC, MotionInfo newMi); void addMotionInfoToLUTs(LutMotionCand* lutMC, MotionInfo newMi);
#endif
void updateMotionLUTs(LutMotionCand* lutMC, CodingUnit & cu); void updateMotionLUTs(LutMotionCand* lutMC, CodingUnit & cu);
void copyMotionLUTs(LutMotionCand* Src, LutMotionCand* Dst); void copyMotionLUTs(LutMotionCand* Src, LutMotionCand* Dst);
......
...@@ -50,6 +50,21 @@ ...@@ -50,6 +50,21 @@
#include <assert.h> #include <assert.h>
#include <cassert> #include <cassert>
#define JVET_M0483_IBC 1 //
#if JVET_M0483_IBC
#define IBC_SEPERATE_MODE 1 //JVET-M0483_method3
#define IBC_SEPERATE_MODE_FIX 1 //JVET-M0483_method3 bug fix ticket 129 and 140
#define IBC_SEPERATE_MODE_REDUCTION 0