Commit c4131230 authored by Xiang Li's avatar Xiang Li

Merge branch 'JVET_L0257_ATMVP' into 'master'

JVET-L0257: ATMVP MV clipping

See merge request jvet/VVCSoftware_VTM!25
parents 21a6002a 0e442c01
Pipeline #174 passed with stage
......@@ -94,6 +94,8 @@
#define JVET_L0093_SIMP_PRUNE 1
#define JVET_L0257_ATMVP_COLBLK_CLIP 1
#ifndef JVET_B0051_NON_MPM_MODE
#define JVET_B0051_NON_MPM_MODE ( 1 && JEM_TOOLS )
#endif
......
......@@ -2239,6 +2239,23 @@ static bool deriveScaledMotionTemporal( const Slice& slice,
return false;
}
#if JVET_L0257_ATMVP_COLBLK_CLIP
void clipColPos(int& posX, int& posY, const PredictionUnit& pu)
{
Position puPos = pu.lumaPos();
int log2CtuSize = g_aucLog2[pu.cs->sps->getSpsNext().getCTUSize()];
int ctuX = ((puPos.x >> log2CtuSize) << log2CtuSize);
int ctuY = ((puPos.y >> log2CtuSize) << log2CtuSize);
int horMax = std::min((int)pu.cs->sps->getPicWidthInLumaSamples() - 1, ctuX + (int)pu.cs->sps->getSpsNext().getCTUSize() + 3);
int horMin = std::max((int)0, ctuX);
int verMax = std::min((int)pu.cs->sps->getPicHeightInLumaSamples() - 1, ctuY + (int)pu.cs->sps->getSpsNext().getCTUSize() - 1);
int verMin = std::max((int)0, ctuY);
posX = std::min(horMax, std::max(horMin, posX));
posY = std::min(verMax, std::max(verMin, posY));
}
#else
void clipColBlkMv(int& mvX, int& mvY, const PredictionUnit& pu)
{
Position puPos = pu.lumaPos();
......@@ -2261,6 +2278,7 @@ void clipColBlkMv(int& mvX, int& mvY, const PredictionUnit& pu)
mvX = std::min(horMax, std::max(horMin, mvX));
mvY = std::min(verMax, std::max(verMin, mvY));
}
#endif
bool PU::getInterMergeSubPuMvpCand(const PredictionUnit &pu, MergeCtx& mrgCtx, bool& LICFlag, const int count
)
......@@ -2303,7 +2321,9 @@ bool PU::getInterMergeSubPuMvpCand(const PredictionUnit &pu, MergeCtx& mrgCtx, b
#if !REMOVE_MV_ADAPT_PREC
}
#endif
#if !JVET_L0257_ATMVP_COLBLK_CLIP
int mvRndOffs = (1 << mvPrec) >> 1;
#endif
Mv cTempVector = cTMv;
bool tempLICFlag = false;
......@@ -2324,6 +2344,15 @@ bool PU::getInterMergeSubPuMvpCand(const PredictionUnit &pu, MergeCtx& mrgCtx, b
bool found = false;
cTempVector = cTMv;
#if JVET_L0257_ATMVP_COLBLK_CLIP
int tempX = cTempVector.getHor() >> mvPrec;
int tempY = cTempVector.getVer() >> mvPrec;
centerPos.x = puPos.x + (puSize.width >> 1) + tempX;
centerPos.y = puPos.y + (puSize.height >> 1) + tempY;
clipColPos(centerPos.x, centerPos.y, pu);
#else
int tempX = ((cTempVector.getHor() + mvRndOffs) >> mvPrec);
int tempY = ((cTempVector.getVer() + mvRndOffs) >> mvPrec);
clipColBlkMv(tempX, tempY, pu);
......@@ -2341,6 +2370,7 @@ bool PU::getInterMergeSubPuMvpCand(const PredictionUnit &pu, MergeCtx& mrgCtx, b
centerPos.x = Clip3(0, (int)pColPic->lwidth() - 1, centerPos.x);
centerPos.y = Clip3(0, (int)pColPic->lheight() - 1, centerPos.y);
#endif
centerPos = Position{ PosType(centerPos.x & mask), PosType(centerPos.y & mask) };
......@@ -2377,6 +2407,10 @@ bool PU::getInterMergeSubPuMvpCand(const PredictionUnit &pu, MergeCtx& mrgCtx, b
return false;
}
#if JVET_L0257_ATMVP_COLBLK_CLIP
int xOff = (puWidth >> 1) + tempX;
int yOff = (puHeight >> 1) + tempY;
#else
int xOff = puWidth / 2;
int yOff = puHeight / 2;
......@@ -2386,6 +2420,7 @@ bool PU::getInterMergeSubPuMvpCand(const PredictionUnit &pu, MergeCtx& mrgCtx, b
int iPicWidth = pColPic->lwidth() - 1;
int iPicHeight = pColPic->lheight() - 1;
#endif
MotionBuf& mb = mrgCtx.subPuMvpMiBuf;
......@@ -2397,8 +2432,12 @@ bool PU::getInterMergeSubPuMvpCand(const PredictionUnit &pu, MergeCtx& mrgCtx, b
{
Position colPos{ x + xOff, y + yOff };
#if JVET_L0257_ATMVP_COLBLK_CLIP
clipColPos(colPos.x, colPos.y, pu);
#else
colPos.x = Clip3(0, iPicWidth, colPos.x);
colPos.y = Clip3(0, iPicHeight, colPos.y);
#endif
colPos = Position{ PosType(colPos.x & mask), PosType(colPos.y & mask) };
......
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