Commit d40ec529 authored by Xiaoyu Xiu's avatar Xiaoyu Xiu

Merge branch 'master' into JVET_N0334_MVClipping

parents 74a26608 d19f3cef
......@@ -134,8 +134,9 @@ AMaxBT : 1
# Encoder optimization tools
AffineAmvrEncOpt : 0
MmvdDisNum : 6
### DO NOT ADD ANYTHING BELOW THIS LINE ###
### DO NOT DELETE THE EMPTY LINE BELOW ###
......@@ -137,8 +137,9 @@ AMaxBT : 1
# Encoder optimization tools
AffineAmvrEncOpt : 0
MmvdDisNum : 6
### DO NOT ADD ANYTHING BELOW THIS LINE ###
### DO NOT DELETE THE EMPTY LINE BELOW ###
......@@ -153,8 +153,9 @@ AMaxBT : 1
# Encoder optimization tools
AffineAmvrEncOpt : 1
MmvdDisNum : 6
### DO NOT ADD ANYTHING BELOW THIS LINE ###
### DO NOT DELETE THE EMPTY LINE BELOW ###
......@@ -1228,6 +1228,11 @@ Specifies the maximum number of merge candidates to use.
Flag to disable intra PUs in inter slices.
\\
\Option{MmvdDisNum} &
%\ShortOption{\None} &
\Default{6} &
Specifies the number of MMVD distance entries used from the distance table at encoder.
\\
\end{OptionTableNoShorthand}
......
......@@ -279,6 +279,9 @@ void EncApp::xInitLibCfg()
m_cEncLib.setUseAffineAmvr ( m_AffineAmvr );
m_cEncLib.setUseAffineAmvrEncOpt ( m_AffineAmvrEncOpt );
m_cEncLib.setDMVR ( m_DMVR );
#if JVET_N0449_MMVD_SIMP
m_cEncLib.setMmvdDisNum (m_MmvdDisNum);
#endif
m_cEncLib.setIBCMode ( m_IBCMode );
m_cEncLib.setIBCLocalSearchRangeX ( m_IBCLocalSearchRangeX );
m_cEncLib.setIBCLocalSearchRangeY ( m_IBCLocalSearchRangeY );
......
......@@ -874,6 +874,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
("AffineAmvr", m_AffineAmvr, false, "Eanble AMVR for affine inter mode")
("AffineAmvrEncOpt", m_AffineAmvrEncOpt, false, "Enable encoder optimization of affine AMVR")
("DMVR", m_DMVR, false, "Decoder-side Motion Vector Refinement")
#if JVET_N0449_MMVD_SIMP
("MmvdDisNum", m_MmvdDisNum, 8, "Number of MMVD Distance Entries")
#endif
( "IBC", m_IBCMode, 0u, "IBCMode (0x1:enabled, 0x0:disabled) [default: disabled]")
( "IBCLocalSearchRangeX", m_IBCLocalSearchRangeX, 128u, "Search range of IBC local search in x direction")
( "IBCLocalSearchRangeY", m_IBCLocalSearchRangeY, 128u, "Search range of IBC local search in y direction")
......@@ -1973,6 +1976,9 @@ bool EncAppCfg::xCheckParameter()
xConfirmPara( m_GBiFast, "GBiFast is only allowed with NEXT profile" );
xConfirmPara( m_Triangle, "Triangle is only allowed with NEXT profile" );
xConfirmPara(m_DMVR, "DMVR only allowed with NEXT profile");
#if JVET_N0449_MMVD_SIMP
xConfirmPara(m_MmvdDisNum, "Number of distance MMVD entry setting only allowed with NEXT profile");
#endif
// ADD_NEW_TOOL : (parameter check) add a check for next tools here
}
else
......@@ -3159,6 +3165,9 @@ void EncAppCfg::xPrintParameter()
m_AffineAmvrEncOpt = m_AffineAmvr ? m_AffineAmvrEncOpt : false;
msg( VERBOSE, "AffineAmvrEncOpt:%d ", m_AffineAmvrEncOpt );
msg(VERBOSE, "DMVR:%d ", m_DMVR);
#if JVET_N0449_MMVD_SIMP
msg(VERBOSE, "MmvdDisNum:%d ", m_MmvdDisNum);
#endif
}
msg(VERBOSE, "IBC:%d ", m_IBCMode);
msg( VERBOSE, "HashME:%d ", m_HashME );
......
......@@ -260,7 +260,9 @@ protected:
bool m_AffineAmvr;
bool m_AffineAmvrEncOpt;
bool m_DMVR;
#if JVET_N0449_MMVD_SIMP
int m_MmvdDisNum;
#endif
unsigned m_IBCMode;
unsigned m_IBCLocalSearchRangeX;
unsigned m_IBCLocalSearchRangeY;
......
......@@ -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,
......
......@@ -125,6 +125,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;
......@@ -132,6 +140,7 @@ public:
#endif
hor >>= i;
ver >>= i;
#endif
}
const Mv& operator<<= (const int i)
......@@ -143,8 +152,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;
}
......@@ -170,8 +188,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 );
}
......@@ -186,8 +209,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,14 @@
#define JVET_N0334_MVCLIPPING 1 // prevention of MV stroage overflow and alignment with spec of MV/CPMV modular for AMVP mode
#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 )
......
......@@ -240,6 +240,9 @@ protected:
bool m_HashME;
bool m_AffineAmvrEncOpt;
bool m_DMVR;
#if JVET_N0449_MMVD_SIMP
int m_MmvdDisNum;
#endif
unsigned m_IBCMode;
unsigned m_IBCLocalSearchRangeX;
unsigned m_IBCLocalSearchRangeY;
......@@ -762,7 +765,10 @@ public:
bool getUseAffineAmvrEncOpt () const { return m_AffineAmvrEncOpt; }
void setDMVR ( bool b ) { m_DMVR = b; }
bool getDMVR () const { return m_DMVR; }
#if JVET_N0449_MMVD_SIMP
void setMmvdDisNum ( int b ) { m_MmvdDisNum = b; }
int getMmvdDisNum () const { return m_MmvdDisNum; }
#endif
void setIBCMode (unsigned n) { m_IBCMode = n; }
unsigned getIBCMode () const { return m_IBCMode; }
void setIBCLocalSearchRangeX (unsigned n) { m_IBCLocalSearchRangeX = n; }
......
......@@ -1999,6 +1999,10 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *&
int refineStep;
baseIdx = mmvdMergeCand / MMVD_MAX_REFINE_NUM;
refineStep = (mmvdMergeCand - (baseIdx * MMVD_MAX_REFINE_NUM)) / 4;
#if JVET_N0449_MMVD_SIMP
if (refineStep >= m_pcEncCfg->getMmvdDisNum())
continue;
#endif
bitsBaseIdx = baseIdx + 1;
if (baseIdx == MMVD_BASE_MV_NUM - 1)
{
......
......@@ -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