Commit 5b437001 authored by Frank Bossen's avatar Frank Bossen

Merge branch 'master' into 'M0483-IBC'

# Conflicts:
#   source/Lib/CommonLib/MotionInfo.h
#   source/Lib/CommonLib/Slice.cpp
#   source/Lib/CommonLib/TypeDef.h
#   source/Lib/CommonLib/UnitTools.cpp
parents 1627a88b 50ab2508
......@@ -112,6 +112,8 @@ DepQuant : 1
IMV : 2
ALF : 1
IBC : 0 # turned off in CTC
AllowDisFracMMVD : 1
AffineAmvr : 0
# Fast tools
PBIntraFast : 1
......
......@@ -129,6 +129,8 @@ IMV : 2
ALF : 1
MHIntra : 1
IBC : 0 # turned off in CTC
AllowDisFracMMVD : 1
AffineAmvr : 0
# Fast tools
PBIntraFast : 1
......
......@@ -132,6 +132,8 @@ GBiFast : 1
MHIntra : 1
Triangle : 1
IBC : 0 # turned off in CTC
AllowDisFracMMVD : 1
AffineAmvr : 0
# Fast tools
PBIntraFast : 1
......
......@@ -147,6 +147,8 @@ BIO : 1
MHIntra : 1
Triangle : 1
IBC : 0 # turned off in CTC
AllowDisFracMMVD : 1
AffineAmvr : 1
# Fast tools
PBIntraFast : 1
......
IBC : 1
HashME : 1
......@@ -257,7 +257,12 @@ void EncApp::xInitLibCfg()
#endif
m_cEncLib.setUseMHIntra ( m_MHIntra );
m_cEncLib.setUseTriangle ( m_Triangle );
#if JVET_M0255_FRACMMVD_SWITCH
m_cEncLib.setAllowDisFracMMVD ( m_allowDisFracMMVD );
#endif
#if JVET_M0246_AFFINE_AMVR
m_cEncLib.setUseAffineAmvr ( m_AffineAmvr );
#endif
m_cEncLib.setIBCMode ( m_IBCMode );
m_cEncLib.setIBCLocalSearchRangeX ( m_IBCLocalSearchRangeX );
m_cEncLib.setIBCLocalSearchRangeY ( m_IBCLocalSearchRangeY );
......
......@@ -864,7 +864,12 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
#endif
("MHIntra", m_MHIntra, false, "Enable MHIntra mode")
("Triangle", m_Triangle, false, "Enable triangular shape motion vector prediction (0:off, 1:on)")
#if JVET_M0255_FRACMMVD_SWITCH
("AllowDisFracMMVD", m_allowDisFracMMVD, false, "Disable fractional MVD in MMVD mode adaptively")
#endif
#if JVET_M0246_AFFINE_AMVR
("AffineAmvr", m_AffineAmvr, false, "Eanble AMVR for affine inter mode")
#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")
......@@ -3145,6 +3150,12 @@ void EncAppCfg::xPrintParameter()
#endif
msg(VERBOSE, "MHIntra:%d ", m_MHIntra);
msg( VERBOSE, "Triangle:%d ", m_Triangle );
#if JVET_M0255_FRACMMVD_SWITCH
msg( VERBOSE, "AllowDisFracMMVD:%d ", m_allowDisFracMMVD );
#endif
#if JVET_M0246_AFFINE_AMVR
msg( VERBOSE, "AffineAmvr:%d ", m_AffineAmvr );
#endif
}
msg(VERBOSE, "IBC:%d ", m_IBCMode);
msg( VERBOSE, "WrapAround:%d ", m_wrapAround);
......
......@@ -237,7 +237,12 @@ protected:
bool m_MHIntra;
bool m_Triangle;
#if JVET_M0255_FRACMMVD_SWITCH
bool m_allowDisFracMMVD;
#endif
#if JVET_M0246_AFFINE_AMVR
bool m_AffineAmvr;
#endif
unsigned m_IBCMode;
unsigned m_IBCLocalSearchRangeX;
......@@ -246,7 +251,7 @@ protected:
unsigned m_IBCHashSearchMaxCand;
unsigned m_IBCHashSearchRange4SmallBlk;
unsigned m_IBCFastMethod;
bool m_wrapAround;
unsigned m_wrapAroundOffset;
......
......@@ -91,18 +91,30 @@ void addBIOAvgCore(const Pel* src0, int src0Stride, const Pel* src1, int src1Str
}
}
#if JVET_M0063_BDOF_FIX
void gradFilterCore(Pel* pSrc, int srcStride, int width, int height, int gradStride, Pel* gradX, Pel* gradY, const int bitDepth)
#else
void gradFilterCore(Pel* pSrc, int srcStride, int width, int height, int gradStride, Pel* gradX, Pel* gradY)
#endif
{
Pel* srcTmp = pSrc + srcStride + 1;
Pel* gradXTmp = gradX + gradStride + 1;
Pel* gradYTmp = gradY + gradStride + 1;
#if JVET_M0063_BDOF_FIX
int shift1 = std::max<int>(2, (IF_INTERNAL_PREC - bitDepth));
#endif
for (int y = 0; y < (height - 2 * BIO_EXTEND_SIZE); y++)
{
for (int x = 0; x < (width - 2 * BIO_EXTEND_SIZE); x++)
{
#if JVET_M0063_BDOF_FIX
gradYTmp[x] = (srcTmp[x + srcStride] - srcTmp[x - srcStride]) >> shift1;
gradXTmp[x] = (srcTmp[x + 1] - srcTmp[x - 1]) >> shift1;
#else
gradYTmp[x] = (srcTmp[x + srcStride] - srcTmp[x - srcStride]) >> 4;
gradXTmp[x] = (srcTmp[x + 1] - srcTmp[x - 1]) >> 4;
#endif
}
gradXTmp += gradStride;
gradYTmp += gradStride;
......@@ -130,15 +142,29 @@ void gradFilterCore(Pel* pSrc, int srcStride, int width, int height, int gradStr
::memcpy(gradYTmp + (height - 2 * BIO_EXTEND_SIZE)*gradStride, gradYTmp + (height - 2 * BIO_EXTEND_SIZE - 1)*gradStride, sizeof(Pel)*(width));
}
#if JVET_M0063_BDOF_FIX
void calcBIOParCore(const Pel* srcY0Temp, const Pel* srcY1Temp, const Pel* gradX0, const Pel* gradX1, const Pel* gradY0, const Pel* gradY1, int* dotProductTemp1, int* dotProductTemp2, int* dotProductTemp3, int* dotProductTemp5, int* dotProductTemp6, const int src0Stride, const int src1Stride, const int gradStride, const int widthG, const int heightG, const int bitDepth)
#else
void calcBIOParCore(const Pel* srcY0Temp, const Pel* srcY1Temp, const Pel* gradX0, const Pel* gradX1, const Pel* gradY0, const Pel* gradY1, int* dotProductTemp1, int* dotProductTemp2, int* dotProductTemp3, int* dotProductTemp5, int* dotProductTemp6, const int src0Stride, const int src1Stride, const int gradStride, const int widthG, const int heightG)
#endif
{
#if JVET_M0063_BDOF_FIX
int shift4 = std::min<int>(8, (bitDepth - 4));
int shift5 = std::min<int>(5, (bitDepth - 7));
#endif
for (int y = 0; y < heightG; y++)
{
for (int x = 0; x < widthG; x++)
{
#if JVET_M0063_BDOF_FIX
int temp = (srcY0Temp[x] >> shift4) - (srcY1Temp[x] >> shift4);
int tempX = (gradX0[x] + gradX1[x]) >> shift5;
int tempY = (gradY0[x] + gradY1[x]) >> shift5;
#else
int temp = (srcY0Temp[x] >> 6) - (srcY1Temp[x] >> 6);
int tempX = (gradX0[x] + gradX1[x]) >> 3;
int tempY = (gradY0[x] + gradY1[x]) >> 3;
#endif
dotProductTemp1[x] = tempX * tempX;
dotProductTemp2[x] = tempX * tempY;
dotProductTemp3[x] = -tempX * temp;
......
......@@ -69,8 +69,13 @@ struct PelBufferOps
void ( *linTf4 ) ( const Pel* src0, int src0Stride, Pel *dst, int dstStride, int width, int height, int scale, int shift, int offset, const ClpRng& clpRng, bool bClip );
void ( *linTf8 ) ( const Pel* src0, int src0Stride, Pel *dst, int dstStride, int width, int height, int scale, int shift, int offset, const ClpRng& clpRng, bool bClip );
void(*addBIOAvg4) (const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, Pel *dst, int dstStride, const Pel *gradX0, const Pel *gradX1, const Pel *gradY0, const Pel*gradY1, int gradStride, int width, int height, int tmpx, int tmpy, int shift, int offset, const ClpRng& clpRng);
#if JVET_M0063_BDOF_FIX
void(*bioGradFilter) (Pel* pSrc, int srcStride, int width, int height, int gradStride, Pel* gradX, Pel* gradY, const int bitDepth);
void(*calcBIOPar) (const Pel* srcY0Temp, const Pel* srcY1Temp, const Pel* gradX0, const Pel* gradX1, const Pel* gradY0, const Pel* gradY1, int* dotProductTemp1, int* dotProductTemp2, int* dotProductTemp3, int* dotProductTemp5, int* dotProductTemp6, const int src0Stride, const int src1Stride, const int gradStride, const int widthG, const int heightG, const int bitDepth);
#else
void(*bioGradFilter) (Pel* pSrc, int srcStride, int width, int height, int gradStride, Pel* gradX, Pel* gradY);
void(*calcBIOPar) (const Pel* srcY0Temp, const Pel* srcY1Temp, const Pel* gradX0, const Pel* gradX1, const Pel* gradY0, const Pel* gradY1, int* dotProductTemp1, int* dotProductTemp2, int* dotProductTemp3, int* dotProductTemp5, int* dotProductTemp6, const int src0Stride, const int src1Stride, const int gradStride, const int widthG, const int heightG);
#endif
void(*calcBlkGradient)(int sx, int sy, int *arraysGx2, int *arraysGxGy, int *arraysGxdI, int *arraysGy2, int *arraysGydI, int &sGx2, int &sGy2, int &sGxGy, int &sGxdI, int &sGydI, int width, int height, int unitSize);
#if ENABLE_SIMD_OPT_GBI
void ( *removeWeightHighFreq8) ( Pel* src0, int src0Stride, const Pel* src1, int src1Stride, int width, int height, int shift, int gbiWeight);
......
......@@ -62,6 +62,9 @@ CodingStructure::CodingStructure(CUCache& cuCache, PUCache& puCache, TUCache& tu
: area ()
, picture ( nullptr )
, parent ( nullptr )
#if JVET_M0246_AFFINE_AMVR
, bestCS ( nullptr )
#endif
, m_isTuEnc ( false )
, m_cuCache ( cuCache )
, m_puCache ( puCache )
......
......@@ -79,7 +79,9 @@ public:
Picture *picture;
CodingStructure *parent;
#if JVET_M0246_AFFINE_AMVR
CodingStructure *bestCS;
#endif
Slice *slice;
UnitScale unitScale[MAX_NUM_COMPONENT];
......
......@@ -162,9 +162,11 @@ static const int MAXIMUM_INTRA_FILTERED_HEIGHT = 16;
static const int MAX_CPB_CNT = 32; ///< Upper bound of (cpb_cnt_minus1 + 1)
static const int MAX_NUM_LAYER_IDS = 64;
#if JVET_M0470
static const int COEF_REMAIN_BIN_REDUCTION = 5; ///< indicates the level at which the VLC transitions from Golomb-Rice to TU+EG(k)
#else
static const int COEF_REMAIN_BIN_REDUCTION = 3; ///< indicates the level at which the VLC transitions from Golomb-Rice to TU+EG(k)
#endif
static const int CU_DQP_TU_CMAX = 5; ///< max number bins for truncated unary
static const int CU_DQP_EG_k = 0; ///< expgolomb order
......@@ -316,7 +318,7 @@ static const int BIO_TEMP_BUFFER_SIZE = (MAX_CU_SIZE
static const int GBI_NUM = 5; ///< the number of weight options
static const int GBI_DEFAULT = ((uint8_t)(GBI_NUM >> 1)); ///< Default weighting index representing for w=0.5
static const int GBI_SIZE_CONSTRAINT = 256; ///< disabling GBi if cu size is smaller than 256
static const int MAX_NUM_HMVP_CANDS = 6; ///< maximum number of HMVP candidates to be stored and used in merge list
static const int MAX_NUM_HMVP_CANDS = 5; ///< maximum number of HMVP candidates to be stored and used in merge list
static const int MAX_NUM_HMVP_AVMPCANDS = 4; ///< maximum number of HMVP candidates to be used in AMVP list
#if W0038_DB_OPT
......@@ -365,7 +367,7 @@ static const int FAST_SKIP_DEPTH = 2;
static const double PBINTRA_RATIO = 1.1;
static const int NUM_MRG_SATD_CAND = 4;
static const double MRG_FAST_RATIO = 1.25;
static const int NUM_AFF_MRG_SATD_CAND = 1;
static const int NUM_AFF_MRG_SATD_CAND = 2;
static const double AMAXBT_TH32 = 15.0;
static const double AMAXBT_TH64 = 30.0;
......@@ -403,6 +405,14 @@ static const int IBC_FAST_METHOD_NOINTRA_IBCCBF0 = 0x01;
static const int IBC_FAST_METHOD_BUFFERBV = 0X02;
static const int IBC_FAST_METHOD_ADAPTIVE_SEARCHRANGE = 0X04;
#if JVET_M0512_MOTION_BUFFER_COMPRESSION
static constexpr int MV_EXPONENT_BITCOUNT = 4;
static constexpr int MV_MANTISSA_BITCOUNT = 6;
static constexpr int MV_MANTISSA_UPPER_LIMIT = ((1 << (MV_MANTISSA_BITCOUNT - 1)) - 1);
static constexpr int MV_MANTISSA_LIMIT = (1 << (MV_MANTISSA_BITCOUNT - 1));
static constexpr int MV_EXPONENT_MASK = ((1 << MV_EXPONENT_BITCOUNT) - 1);
#endif
// ====================================================================================================================
// Macro functions
// ====================================================================================================================
......
......@@ -53,8 +53,13 @@ CoeffCodingContext::CoeffCodingContext(const TransformUnit& tu, ComponentID comp
, m_log2CGWidth ((m_width & 3) || (m_height & 3) ? 1 : 2)
, m_log2CGHeight ((m_width & 3) || (m_height & 3) ? 1 : 2)
, m_log2CGSize (m_log2CGWidth + m_log2CGHeight)
, m_widthInGroups (m_width >> m_log2CGWidth)
, m_heightInGroups (m_height >> m_log2CGHeight)
#if JVET_M0257
, m_widthInGroups(std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_width) >> m_log2CGWidth)
, m_heightInGroups(std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_height) >> m_log2CGHeight)
#else
, m_widthInGroups(m_width >> m_log2CGWidth)
, m_heightInGroups(m_height >> m_log2CGHeight)
#endif
, m_log2BlockWidth (g_aucLog2[m_width])
, m_log2BlockHeight (g_aucLog2[m_height])
, m_log2BlockSize ((m_log2BlockWidth + m_log2BlockHeight)>>1)
......@@ -75,8 +80,13 @@ CoeffCodingContext::CoeffCodingContext(const TransformUnit& tu, ComponentID comp
, m_scanCG (g_scanOrder[SCAN_UNGROUPED ][m_scanType][gp_sizeIdxInfo->idxFrom(m_widthInGroups)][gp_sizeIdxInfo->idxFrom(m_heightInGroups)])
, m_CtxSetLastX (Ctx::LastX[m_chType])
, m_CtxSetLastY (Ctx::LastY[m_chType])
, m_maxLastPosX (g_uiGroupIdx[m_width - 1])
, m_maxLastPosY (g_uiGroupIdx[m_height - 1])
#if JVET_M0257
, m_maxLastPosX(g_uiGroupIdx[std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_width) - 1])
, m_maxLastPosY(g_uiGroupIdx[std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_height) - 1])
#else
, m_maxLastPosX(g_uiGroupIdx[m_width - 1])
, m_maxLastPosY(g_uiGroupIdx[m_height - 1])
#endif
, m_lastOffsetX (0)
, m_lastOffsetY (0)
, m_lastShiftX (0)
......@@ -503,6 +513,9 @@ void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx )
#if JVET_M0068_M0171_MMVD_CLEANUP
PU::restrictBiPredMergeCandsOne(pu);
#endif
#if JVET_M0823_MMVD_ENCOPT
pu.mmvdEncOptMode = 0;
#endif
}
void MergeCtx::setMmvdMergeCandiInfo(PredictionUnit& pu, int candIdx)
{
......@@ -523,8 +536,15 @@ void MergeCtx::setMmvdMergeCandiInfo(PredictionUnit& pu, int candIdx)
tempIdx = tempIdx - fPosBaseIdx * (MMVD_MAX_REFINE_NUM);
fPosStep = tempIdx / 4;
fPosPosition = tempIdx - fPosStep * (4);
#if JVET_M0255_FRACMMVD_SWITCH
int offset = refMvdCands[fPosStep];
if ( pu.cu->slice->getDisFracMMVD() )
{
offset <<= 2;
}
#else
const int offset = refMvdCands[fPosStep];
#endif
const int refList0 = mmvdBaseMv[fPosBaseIdx][0].refIdx;
const int refList1 = mmvdBaseMv[fPosBaseIdx][1].refIdx;
......
......@@ -1241,15 +1241,28 @@ const CtxSet ContextSetCfg::ChromaQpAdjIdc = ContextSetCfg::addCtxSet
const CtxSet ContextSetCfg::ImvFlag = ContextSetCfg::addCtxSet
({
#if JVET_M0453_CABAC_ENGINE
#if JVET_M0246_AFFINE_AMVR
{ 227, 214, 230, 195, 227, 214, },
{ 213, 229, 230, 166, 213, 229, },
{ CNU, CNU, CNU, CNU, CNU, CNU, },
{ 1, 4, 4, 5, 1, 4, },
#else
{ 227, 214, 230, 195,},
{ 213, 229, 230, 166,},
{ CNU, CNU, CNU, CNU,},
{ 1, 4, 4, 5,},
#endif
#else
#if JVET_M0246_AFFINE_AMVR
{ 212, 214, 230, 182, 212, 214 },
{ 212, 214, 230, 182, 212, 214 },
{ CNU, CNU, CNU, CNU, CNU, CNU },
#else
{ 212, 214, 230, 182, },
{ 212, 214, 230, 182, },
{ CNU, CNU, CNU, CNU, },
#endif
#endif
});
const CtxSet ContextSetCfg::ctbAlfFlag =
......
......@@ -334,8 +334,13 @@ namespace DQIntern
m_log2SbbSize = m_log2SbbWidth + m_log2SbbHeight;
m_sbbSize = ( 1 << m_log2SbbSize );
m_sbbMask = m_sbbSize - 1;
#if JVET_M0257
m_widthInSbb = std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_width) >> m_log2SbbWidth;
m_heightInSbb = std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_height) >> m_log2SbbHeight;
#else
m_widthInSbb = m_width >> m_log2SbbWidth;
m_heightInSbb = m_height >> m_log2SbbHeight;
#endif
m_numSbb = m_widthInSbb * m_heightInSbb;
#if HEVC_USE_MDCS
#error "MDCS is not supported" // use different function...
......@@ -489,7 +494,11 @@ namespace DQIntern
const unsigned lastShift = ( compID == COMPONENT_Y ? (log2Size+1)>>2 : Clip3<unsigned>(0,2,size>>3) );
const unsigned lastOffset = ( compID == COMPONENT_Y ? ( prefixCtx[log2Size] ) : 0 );
uint32_t sumFBits = 0;
#if JVET_M0257
unsigned maxCtxId = g_uiGroupIdx[std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, size) - 1];
#else
unsigned maxCtxId = g_uiGroupIdx[ size - 1 ];
#endif
for( unsigned ctxId = 0; ctxId < maxCtxId; ctxId++ )
{
const BinFracBits bits = fracBitsAccess.getFracBitsArray( ctxSetLast( lastOffset + ( ctxId >> lastShift ) ) );
......@@ -497,7 +506,11 @@ namespace DQIntern
sumFBits += bits.intBits[1];
}
ctxBits [ maxCtxId ] = sumFBits + ( maxCtxId>3 ? ((maxCtxId-2)>>1)<<SCALE_BITS : 0 ) + bitOffset;
#if JVET_M0257
for (unsigned pos = 0; pos < std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, size); pos++)
#else
for( unsigned pos = 0; pos < size; pos++ )
#endif
{
lastBits[ pos ] = ctxBits[ g_uiGroupIdx[ pos ] ];
}
......@@ -840,6 +853,15 @@ namespace DQIntern
};
#define RICEMAX 32
#if JVET_M0470
const int32_t g_goRiceBits[4][RICEMAX] =
{
{ 32768, 65536, 98304, 131072, 163840, 196608, 262144, 262144, 327680, 327680, 327680, 327680, 393216, 393216, 393216, 393216, 393216, 393216, 393216, 393216, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752},
{ 65536, 65536, 98304, 98304, 131072, 131072, 163840, 163840, 196608, 196608, 229376, 229376, 294912, 294912, 294912, 294912, 360448, 360448, 360448, 360448, 360448, 360448, 360448, 360448, 425984, 425984, 425984, 425984, 425984, 425984, 425984, 425984},
{ 98304, 98304, 98304, 98304, 131072, 131072, 131072, 131072, 163840, 163840, 163840, 163840, 196608, 196608, 196608, 196608, 229376, 229376, 229376, 229376, 262144, 262144, 262144, 262144, 327680, 327680, 327680, 327680, 327680, 327680, 327680, 327680},
{ 131072, 131072, 131072, 131072, 131072, 131072, 131072, 131072, 163840, 163840, 163840, 163840, 163840, 163840, 163840, 163840, 196608, 196608, 196608, 196608, 196608, 196608, 196608, 196608, 229376, 229376, 229376, 229376, 229376, 229376, 229376, 229376}
};
#else
const int32_t g_goRiceBits[4][RICEMAX] =
{
{ 32768, 65536, 98304, 131072, 163840, 196608, 229376, 294912, 294912, 360448, 360448, 360448, 360448, 425984, 425984, 425984, 425984, 425984, 425984, 425984, 425984, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520 },
......@@ -847,6 +869,7 @@ namespace DQIntern
{ 98304, 98304, 98304, 98304, 131072, 131072, 131072, 131072, 163840, 163840, 163840, 163840, 196608, 196608, 196608, 196608, 229376, 229376, 229376, 229376, 262144, 262144, 262144, 262144, 294912, 294912, 294912, 294912, 360448, 360448, 360448, 360448 },
{ 131072, 131072, 131072, 131072, 131072, 131072, 131072, 131072, 163840, 163840, 163840, 163840, 163840, 163840, 163840, 163840, 196608, 196608, 196608, 196608, 196608, 196608, 196608, 196608, 229376, 229376, 229376, 229376, 229376, 229376, 229376, 229376 }
};
#endif
class State
{
......
......@@ -326,7 +326,9 @@ void InterPrediction::xSubPuMC( PredictionUnit& pu, PelUnitBuf& predBuf, const R
subPu.UnitArea::operator=(UnitArea(pu.chromaFormat, Area(x, y, dx, dy)));
subPu = curMi;
PelUnitBuf subPredBuf = predBuf.subBuf(UnitAreaRelative(pu, subPu));
#if JVET_M0823_MMVD_ENCOPT
subPu.mmvdEncOptMode = 0;
#endif
motionCompensation(subPu, subPredBuf, eRefPicList);
secDim = later - secStep;
}
......@@ -400,8 +402,12 @@ void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList&
pu.cu->lumaSize(),
sps);
#if JVET_M0823_MMVD_ENCOPT
int numOfPass = (pu.mmvdMergeFlag && pu.mmvdEncOptMode) ? 1 : (std::min((int)pcYuvPred.bufs.size(), m_maxCompIDToPred + 1));
for (uint32_t comp = COMPONENT_Y; comp < numOfPass; comp++)
#else
for( uint32_t comp = COMPONENT_Y; comp < pcYuvPred.bufs.size() && comp <= m_maxCompIDToPred; comp++ )
#endif
{
const ComponentID compID = ComponentID( comp );
if (compID == COMPONENT_Y && !luma)
......@@ -478,7 +484,11 @@ void InterPrediction::xPredInterBi(PredictionUnit& pu, PelUnitBuf &pcYuvPred)
bioApplied = false;
}
}
#if JVET_M0823_MMVD_ENCOPT
if (pu.mmvdEncOptMode == 2 && pu.mmvdMergeFlag) {
bioApplied = false;
}
#endif
for (uint32_t refList = 0; refList < NUM_REF_PIC_LIST_01; refList++)
{
if( pu.refIdx[refList] < 0)
......@@ -768,24 +778,55 @@ void InterPrediction::xPredAffineBlk( const ComponentID& compID, const Predictio
}
else
{
#if JVET_M0265_MV_ROUNDING_CLEANUP
m_storedMv[h / AFFINE_MIN_BLOCK_SIZE * MVBUFFER_SIZE + w / AFFINE_MIN_BLOCK_SIZE].set(iMvScaleTmpHor, iMvScaleTmpVer);
#endif
iMvScaleTmpHor = std::min<int>(iHorMax, std::max<int>(iHorMin, iMvScaleTmpHor));
iMvScaleTmpVer = std::min<int>(iVerMax, std::max<int>(iVerMin, iMvScaleTmpVer));
#if !JVET_M0265_MV_ROUNDING_CLEANUP
m_storedMv[h / AFFINE_MIN_BLOCK_SIZE * MVBUFFER_SIZE + w / AFFINE_MIN_BLOCK_SIZE].set(iMvScaleTmpHor, iMvScaleTmpVer);
#endif
}
}
else
{
#if JVET_M0265_MV_ROUNDING_CLEANUP
#if JVET_M0192_AFF_CHROMA_SIMPL
Mv curMv = m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE) * MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE)] +
m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE + 1)* MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE + 1)];
roundAffineMv(curMv.hor, curMv.ver, 1);
#else
Mv curMv = m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE) * MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE)] +
m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE + 1)* MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE)] +
m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE)* MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE + 1)] +
m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE + 1)* MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE + 1)];
roundAffineMv(curMv.hor, curMv.ver, 2);
#endif
#else
#if JVET_M0192_AFF_CHROMA_SIMPL
Mv curMv = m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE) * MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE)] +
m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE + 1)* MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE + 1)];
roundAffineMv(curMv.hor, curMv.ver, 1);
#else
Mv curMv = (m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE) * MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE)] +
m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE + 1)* MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE)] +
m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE)* MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE + 1)] +
m_storedMv[((h << iScaleY) / AFFINE_MIN_BLOCK_SIZE + 1)* MVBUFFER_SIZE + ((w << iScaleX) / AFFINE_MIN_BLOCK_SIZE + 1)] +
Mv(2, 2));
curMv.set(curMv.getHor() >> 2, curMv.getVer() >> 2);
curMv.set(curMv.getHor() >> 2, curMv.getVer() >> 2);
#endif
#endif
if (sps.getWrapAroundEnabledFlag())
{
clipMv(curMv, Position(pu.Y().x + (w << iScaleX), pu.Y().y + (h << iScaleY)), Size(blockWidth << iScaleX, blockHeight << iScaleY), sps);
}
#if JVET_M0265_MV_ROUNDING_CLEANUP
else
{
curMv.hor = std::min<int>(iHorMax, std::max<int>(iHorMin, curMv.hor));
curMv.ver = std::min<int>(iVerMax, std::max<int>(iVerMin, curMv.ver));
}
#endif
iMvScaleTmpHor = curMv.hor;
iMvScaleTmpVer = curMv.ver;
}
......@@ -882,7 +923,11 @@ void InterPrediction::applyBiOptFlow(const PredictionUnit &pu, const CPelUnitBuf
Pel* gradY = (refList == 0) ? m_gradY0 : m_gradY1;
Pel* gradX = (refList == 0) ? m_gradX0 : m_gradX1;
#if JVET_M0063_BDOF_FIX
xBioGradFilter(dstTempPtr, stridePredMC, widthG, heightG, widthG, gradX, gradY, clipBitDepths.recon[toChannelType(COMPONENT_Y)]);
#else
xBioGradFilter(dstTempPtr, stridePredMC, widthG, heightG, widthG, gradX, gradY);
#endif
Pel* padStr = m_filteredBlockTmp[2 + refList][COMPONENT_Y] + 2 * stridePredMC + 2;
for (int y = 0; y< height; y++)
{
......@@ -900,7 +945,11 @@ void InterPrediction::applyBiOptFlow(const PredictionUnit &pu, const CPelUnitBuf
const int bitDepth = clipBitDepths.recon[toChannelType(COMPONENT_Y)];
const int shiftNum = IF_INTERNAL_PREC + 1 - bitDepth;
const int offset = (1 << (shiftNum - 1)) + 2 * IF_INTERNAL_OFFS;
#if JVET_M0063_BDOF_FIX
const int limit = (bitDepth>12)? 2 : ((int)1 << (4 + IF_INTERNAL_PREC - bitDepth - 5));
#else
const int limit = ((int)1 << (4 + IF_INTERNAL_PREC - bitDepth - 5));
#endif
int* dotProductTemp1 = m_dotProduct1;
int* dotProductTemp2 = m_dotProduct2;
......@@ -908,7 +957,11 @@ void InterPrediction::applyBiOptFlow(const PredictionUnit &pu, const CPelUnitBuf
int* dotProductTemp5 = m_dotProduct5;
int* dotProductTemp6 = m_dotProduct6;
#if JVET_M0063_BDOF_FIX
xCalcBIOPar(srcY0Temp, srcY1Temp, gradX0, gradX1, gradY0, gradY1, dotProductTemp1, dotProductTemp2, dotProductTemp3, dotProductTemp5, dotProductTemp6, src0Stride, src1Stride, widthG, widthG, heightG, bitDepth);
#else
xCalcBIOPar(srcY0Temp, srcY1Temp, gradX0, gradX1, gradY0, gradY1, dotProductTemp1, dotProductTemp2, dotProductTemp3, dotProductTemp5, dotProductTemp6, src0Stride, src1Stride, widthG, widthG, heightG);
#endif
int xUnit = (width >> 2);
int yUnit = (height >> 2);
......@@ -1073,6 +1126,17 @@ void InterPrediction::xAddBIOAvg4(const Pel* src0, int src0Stride, const Pel* sr
g_pelBufOP.addBIOAvg4(src0, src0Stride, src1, src1Stride, dst, dstStride, gradX0, gradX1, gradY0, gradY1, gradStride, width, height, tmpx, tmpy, shift, offset, clpRng);
}
#if JVET_M0063_BDOF_FIX
void InterPrediction::xBioGradFilter(Pel* pSrc, int srcStride, int width, int height, int gradStride, Pel* gradX, Pel* gradY, int bitDepth)
{
g_pelBufOP.bioGradFilter(pSrc, srcStride, width, height, gradStride, gradX, gradY, bitDepth);
}
void InterPrediction::xCalcBIOPar(const Pel* srcY0Temp, const Pel* srcY1Temp, const Pel* gradX0, const Pel* gradX1, const Pel* gradY0, const Pel* gradY1, int* dotProductTemp1, int* dotProductTemp2, int* dotProductTemp3, int* dotProductTemp5, int* dotProductTemp6, const int src0Stride, const int src1Stride, const int gradStride, const int widthG, const int heightG, int bitDepth)
{
g_pelBufOP.calcBIOPar(srcY0Temp, srcY1Temp, gradX0, gradX1, gradY0, gradY1, dotProductTemp1, dotProductTemp2, dotProductTemp3, dotProductTemp5, dotProductTemp6, src0Stride, src1Stride, gradStride, widthG, heightG, bitDepth);
}
#else
void InterPrediction::xBioGradFilter(Pel* pSrc, int srcStride, int width, int height, int gradStride, Pel* gradX, Pel* gradY