Commit 40f8efa5 authored by Xiang Li's avatar Xiang Li

Merge branch 'master' into 'JVET_N0449_MMVD_SIMP'

parents f4ce9217 476b4d7c
......@@ -359,7 +359,10 @@ static const int MIN_BT_SIZE_C = 4; ///<
static const int MAX_TT_SIZE_INTER = 64; ///< for initialization, [1<<MIN_CU_LOG2, 64]
static const int MIN_TT_SIZE_INTER = 4; ///<
#if JVET_N0137_DUALTREE_CHROMA_SIZE
static const int MIN_DUALTREE_CHROMA_WIDTH = 4;
static const int MIN_DUALTREE_CHROMA_SIZE = 16;
#endif
static const SplitSeries SPLIT_BITS = 5;
static const SplitSeries SPLIT_DMULT = 5;
static const SplitSeries SPLIT_MASK = 31; ///< = (1 << SPLIT_BITS) - 1
......
......@@ -447,11 +447,43 @@ void MergeCtx::setMmvdMergeCandiInfo(PredictionUnit& pu, int candIdx)
{
const int scale = PU::getDistScaleFactor(currPoc, poc0, currPoc, poc1);
tempMv[1] = tempMv[0];
#if JVET_N0332_LTRP_MMVD_FIX
const bool isL0RefLongTerm = slice.getRefPic(REF_PIC_LIST_0, refList0)->longTerm;
const bool isL1RefLongTerm = slice.getRefPic(REF_PIC_LIST_1, refList1)->longTerm;
if (isL0RefLongTerm || isL1RefLongTerm)
{
if ((poc1 - currPoc)*(poc0 - currPoc) > 0)
{
tempMv[0] = tempMv[1];
}
else
{
tempMv[0].set(-1 * tempMv[1].getHor(), -1 * tempMv[1].getVer());
}
}
else
#endif
tempMv[0] = tempMv[1].scaleMv(scale);
}
else
{
const int scale = PU::getDistScaleFactor(currPoc, poc1, currPoc, poc0);
#if JVET_N0332_LTRP_MMVD_FIX
const bool isL0RefLongTerm = slice.getRefPic(REF_PIC_LIST_0, refList0)->longTerm;
const bool isL1RefLongTerm = slice.getRefPic(REF_PIC_LIST_1, refList1)->longTerm;
if (isL0RefLongTerm || isL1RefLongTerm)
{
if ((poc1 - currPoc)*(poc0 - currPoc) > 0)
{
tempMv[1] = tempMv[0];
}
else
{
tempMv[1].set(-1 * tempMv[0].getHor(), -1 * tempMv[0].getVer());
}
}
else
#endif
tempMv[1] = tempMv[0].scaleMv(scale);
}
......
......@@ -45,8 +45,13 @@ const MvPrecision Mv::m_amvrPrecision[3] = { MV_PRECISION_QUARTER, MV_PRECISION_
void roundAffineMv( int& mvx, int& mvy, int nShift )
{
const int nOffset = 1 << (nShift - 1);
#if JVET_N0335_N0085_MV_ROUNDING
mvx = (mvx + nOffset - (mvx >= 0)) >> nShift;
mvy = (mvy + nOffset - (mvy >= 0)) >> nShift;
#else
mvx = mvx >= 0 ? (mvx + nOffset) >> nShift : -((-mvx + nOffset) >> nShift);
mvy = mvy >= 0 ? (mvy + nOffset) >> nShift : -((-mvy + nOffset) >> nShift);
#endif
}
void clipMv( Mv& rcMv, const Position& pos,
......
......@@ -121,6 +121,14 @@ public:
//! shift right with rounding
void divideByPowerOf2 (const int i)
{
#if JVET_N0335_N0085_MV_ROUNDING
if (i != 0)
{
const int offset = (1 << (i - 1));
hor = (hor + offset - (hor >= 0)) >> i;
ver = (ver + offset - (ver >= 0)) >> i;
}
#else
#if ME_ENABLE_ROUNDING_OF_MVS
const int offset = (i == 0) ? 0 : 1 << (i - 1);
hor += offset;
......@@ -128,6 +136,7 @@ public:
#endif
hor >>= i;
ver >>= i;
#endif
}
const Mv& operator<<= (const int i)
......@@ -139,8 +148,17 @@ public:
const Mv& operator>>= ( const int i )
{
#if JVET_N0335_N0085_MV_ROUNDING
if (i != 0)
{
const int offset = (1 << (i - 1));
hor = (hor + offset - (hor >= 0)) >> i;
ver = (ver + offset - (ver >= 0)) >> i;
}
#else
hor >>= i;
ver >>= i;
#endif
return *this;
}
......@@ -166,8 +184,13 @@ public:
const Mv scaleMv( int iScale ) const
{
#if JVET_N0335_N0085_MV_ROUNDING
const int mvx = Clip3(-131072, 131071, (iScale * getHor() + 128 - (iScale * getHor() >= 0)) >> 8);
const int mvy = Clip3(-131072, 131071, (iScale * getVer() + 128 - (iScale * getVer() >= 0)) >> 8);
#else
const int mvx = Clip3( -131072, 131071, (iScale * getHor() + 127 + (iScale * getHor() < 0)) >> 8 );
const int mvy = Clip3( -131072, 131071, (iScale * getVer() + 127 + (iScale * getVer() < 0)) >> 8 );
#endif
return Mv( mvx, mvy );
}
......@@ -182,8 +205,13 @@ public:
{
const int rightShift = -shift;
const int nOffset = 1 << (rightShift - 1);
#if JVET_N0335_N0085_MV_ROUNDING
hor = hor >= 0 ? (hor + nOffset - 1) >> rightShift : (hor + nOffset) >> rightShift;
ver = ver >= 0 ? (ver + nOffset - 1) >> rightShift : (ver + nOffset) >> rightShift;
#else
hor = hor >= 0 ? (hor + nOffset) >> rightShift : -((-hor + nOffset) >> rightShift);
ver = ver >= 0 ? (ver + nOffset) >> rightShift : -((-ver + nOffset) >> rightShift);
#endif
}
}
......
......@@ -52,6 +52,12 @@
#define JVET_N0449_MMVD_SIMP 1 // Configurable number of mmvd distance entries used
#define JVET_N0137_DUALTREE_CHROMA_SIZE 1
#define JVET_N0335_N0085_MV_ROUNDING 1 // MV rounding unification
#define JVET_N0332_LTRP_MMVD_FIX 1 // MMVD scaling considering LTRPs from N0332
#define JVET_N0477_LMCS_CLEANUP 1
#define JVET_N0220_LMCS_SIMPLIFICATION 1
......
......@@ -351,6 +351,9 @@ void QTBTPartitioner::canSplit( const CodingStructure &cs, bool& canNo, bool& ca
// the minimal and maximal sizes are given in luma samples
const CompArea& area = currArea().Y();
#if JVET_N0137_DUALTREE_CHROMA_SIZE
const CompArea& areaC = currArea().Cb();
#endif
PartLevel& level = m_partStack.back();
const PartSplit lastSplit = level.split;
......@@ -359,7 +362,9 @@ void QTBTPartitioner::canSplit( const CodingStructure &cs, bool& canNo, bool& ca
// don't allow QT-splitting below a BT split
if( lastSplit != CTU_LEVEL && lastSplit != CU_QUAD_SPLIT ) canQt = false;
if( area.width <= minQtSize ) canQt = false;
#if JVET_N0137_DUALTREE_CHROMA_SIZE
if( chType == CHANNEL_TYPE_CHROMA && areaC.width <= MIN_DUALTREE_CHROMA_WIDTH ) canQt = false;
#endif
if( implicitSplit != CU_DONT_SPLIT )
{
canNo = canTh = canTv = false;
......@@ -397,17 +402,26 @@ void QTBTPartitioner::canSplit( const CodingStructure &cs, bool& canNo, bool& ca
// specific check for BT splits
if( area.height <= minBtSize || area.height > maxBtSize ) canBh = false;
if( area.width > MAX_TB_SIZEY && area.height <= MAX_TB_SIZEY ) canBh = false;
#if JVET_N0137_DUALTREE_CHROMA_SIZE
if( chType == CHANNEL_TYPE_CHROMA && areaC.width * areaC.height <= MIN_DUALTREE_CHROMA_SIZE ) canBh = false;
#endif
if( area.width <= minBtSize || area.width > maxBtSize ) canBv = false;
if( area.width <= MAX_TB_SIZEY && area.height > MAX_TB_SIZEY ) canBv = false;
#if JVET_N0137_DUALTREE_CHROMA_SIZE
if( chType == CHANNEL_TYPE_CHROMA && areaC.width * areaC.height <= MIN_DUALTREE_CHROMA_SIZE ) canBv = false;
#endif
if( area.height <= 2 * minTtSize || area.height > maxTtSize || area.width > maxTtSize )
canTh = false;
if( area.width > MAX_TB_SIZEY || area.height > MAX_TB_SIZEY ) canTh = false;
#if JVET_N0137_DUALTREE_CHROMA_SIZE
if( chType == CHANNEL_TYPE_CHROMA && areaC.width * areaC.height <= MIN_DUALTREE_CHROMA_SIZE*2 ) canTh = false;
#endif
if( area.width <= 2 * minTtSize || area.width > maxTtSize || area.height > maxTtSize )
canTv = false;
if( area.width > MAX_TB_SIZEY || area.height > MAX_TB_SIZEY ) canTv = false;
#if JVET_N0137_DUALTREE_CHROMA_SIZE
if( chType == CHANNEL_TYPE_CHROMA && areaC.width * areaC.height <= MIN_DUALTREE_CHROMA_SIZE*2 ) canTv = false;
#endif
}
bool QTBTPartitioner::canSplit( const PartSplit split, const CodingStructure &cs )
......
......@@ -1527,7 +1527,13 @@ void InterSearch::xxIBCHashSearch(PredictionUnit& pu, Mv* mvPred, int numMvPred,
int imvShift = 2;
int offset = 1 << (imvShift - 1);
#if JVET_N0335_N0085_MV_ROUNDING
int x = (mvPred[n].hor + offset - (mvPred[n].hor >= 0)) >> 2;
int y = (mvPred[n].ver + offset - (mvPred[n].ver >= 0)) >> 2;
mvPredQuadPel.set(x, y);
#else
mvPredQuadPel.set(((mvPred[n].hor + offset) >> 2), ((mvPred[n].ver + offset) >> 2));
#endif
m_pcRdCost->setPredictor(mvPredQuadPel);
......@@ -4264,8 +4270,14 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu,
int shift = MAX_CU_DEPTH;
int vx2 = (mvFour[0].getHor() << shift) - ((mvFour[1].getVer() - mvFour[0].getVer()) << (shift + g_aucLog2[pu.lheight()] - g_aucLog2[pu.lwidth()]));
int vy2 = (mvFour[0].getVer() << shift) + ((mvFour[1].getHor() - mvFour[0].getHor()) << (shift + g_aucLog2[pu.lheight()] - g_aucLog2[pu.lwidth()]));
#if JVET_N0335_N0085_MV_ROUNDING
int offset = (1 << (shift - 1));
vx2 = (vx2 + offset - (vx2 >= 0)) >> shift;
vy2 = (vy2 + offset - (vy2 >= 0)) >> shift;
#else
vx2 >>= shift;
vy2 >>= shift;
#endif
mvFour[2].hor = vx2;
mvFour[2].ver = vy2;
mvFour[2].clipToStorageBitDepth();
......
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