Commit 577f9156 authored by Yan Zhang's avatar Yan Zhang

Integration of JVET-K0357 AMVR

parent 66a787c5
......@@ -111,6 +111,8 @@ SubPuMvp : 1
MaxNumMergeCand : 6
LMChroma : 1 # use CCLM only
DepQuant : 1
IMV : 2
# Fast tools
PBIntraFast : 1
......@@ -119,3 +121,4 @@ AMaxBT : 1
### DO NOT ADD ANYTHING BELOW THIS LINE ###
### DO NOT DELETE THE EMPTY LINE BELOW ###
......@@ -127,6 +127,8 @@ SubPuMvp : 1
MaxNumMergeCand : 6
LMChroma : 1 # use CCLM only
DepQuant : 1
IMV : 2
# Fast tools
PBIntraFast : 1
FastMrg : 1
......@@ -134,3 +136,4 @@ AMaxBT : 1
### DO NOT ADD ANYTHING BELOW THIS LINE ###
### DO NOT DELETE THE EMPTY LINE BELOW ###
......@@ -127,6 +127,8 @@ SubPuMvp : 1
MaxNumMergeCand : 6
LMChroma : 1 # use CCLM only
DepQuant : 1
IMV : 2
# Fast tools
PBIntraFast : 1
FastMrg : 1
......@@ -134,3 +136,4 @@ AMaxBT : 1
### DO NOT ADD ANYTHING BELOW THIS LINE ###
### DO NOT DELETE THE EMPTY LINE BELOW ###
......@@ -141,6 +141,8 @@ SubPuMvp : 1
MaxNumMergeCand : 6
LMChroma : 1 # use CCLM only
DepQuant : 1
IMV : 2
# Fast tools
PBIntraFast : 1
......@@ -150,3 +152,4 @@ AMaxBT : 1
### DO NOT ADD ANYTHING BELOW THIS LINE ###
### DO NOT DELETE THE EMPTY LINE BELOW ###
......@@ -557,7 +557,7 @@ Void EncApp::xInitLibCfg()
m_cEncLib.setSummaryOutFilename ( m_summaryOutFilename );
m_cEncLib.setSummaryPicFilenameBase ( m_summaryPicFilenameBase );
m_cEncLib.setSummaryVerboseness ( m_summaryVerboseness );
#if JEM_TOOLS
#if JVET_K0357_AMVR
m_cEncLib.setIMV ( m_ImvMode );
m_cEncLib.setIMV4PelFast ( m_Imv4PelFast );
m_cEncLib.setIMVMaxCand ( m_ImvMaxCand );
......
......@@ -847,7 +847,9 @@ Bool EncAppCfg::parseCfg( Int argc, TChar* argv[] )
#if JEM_TOOLS
("LICMode", m_LICMode, 0u, "Local illumination compensation [LIC] (0:disabled, 1:enabled, 2:enabled for certain modes) [default: 0]")
("FastPicLevelLIC", m_FastPicLevelLIC, false, "Fast picture level LIC decision (0:disabled, 1:enabled) [default: 0]")
("IMV", m_ImvMode, 0, "Adaptive MV precision Mode (IMV)\n"
#endif
#if JVET_K0357_AMVR
("IMV", m_ImvMode, 2, "Adaptive MV precision Mode (IMV)\n"
"\t0: disabled IMV\n"
"\t1: IMV default (Full-Pel)\n"
"\t2: IMV Full-Pel and 4-PEL\n")
......@@ -1982,7 +1984,7 @@ Bool EncAppCfg::xCheckParameter()
xConfirmPara( m_LICMode, "LICMode > 0 is only allowed with NEXT profile" );
#endif
xConfirmPara( m_MTT, "Multi type tree is only allowed with NEXT profile" );
#if JEM_TOOLS
#if JVET_K0357_AMVR
xConfirmPara( m_ImvMode, "IMV is only allowed with NEXT profile" );
#endif
#if JEM_TOOLS
......@@ -3013,7 +3015,7 @@ Bool EncAppCfg::xCheckParameter()
#if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI
xConfirmPara(m_preferredTransferCharacteristics > 255, "transfer_characteristics_idc should not be greater than 255.");
#endif
#if JEM_TOOLS
#if JVET_K0357_AMVR
xConfirmPara( unsigned(m_ImvMode) > 2, "ImvMode exceeds range (0 to 2)" );
#endif
xConfirmPara( m_decodeBitstreams[0] == m_bitstreamFileName, "Debug bitstream and the output bitstream cannot be equal.\n" );
......@@ -3297,7 +3299,7 @@ Void EncAppCfg::xPrintParameter()
msg( VERBOSE, "QTBT:%d ", m_QTBT );
if( m_QTBT ) msg( VERBOSE, "DualITree:%d ", m_dualTree );
msg( VERBOSE, "LargeCTU:%d ", m_LargeCTU );
#if JEM_TOOLS
#if JVET_K0357_AMVR
msg( VERBOSE, "IMV:%d ", m_ImvMode );
if( !m_QTBT ) msg( VERBOSE, "IMVMaxCand:%d ", m_ImvMaxCand );
#endif
......@@ -3373,6 +3375,8 @@ Void EncAppCfg::xPrintParameter()
msg( VERBOSE, "PBIntraFast:%d ", m_usePbIntraFast );
#if JEM_TOOLS
if( m_LICMode > 0 ) msg( VERBOSE, "FastPicLevelLIC:%d ", m_FastPicLevelLIC );
#endif
#if JVET_K0357_AMVR
if( m_ImvMode == 2 ) msg( VERBOSE, "IMV4PelFast:%d ", m_Imv4PelFast );
#endif
#if JEM_TOOLS || JVET_K1000_SIMPLIFIED_EMT
......
......@@ -545,7 +545,7 @@ protected:
Int m_maxBitsPerMinCuDenom; ///< Indicates an upper bound for the number of bits of coding_unit() data
Int m_log2MaxMvLengthHorizontal; ///< Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units
Int m_log2MaxMvLengthVertical; ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units
#if JEM_TOOLS
#if JVET_K0357_AMVR
Int m_ImvMode; ///< imv mode
Int m_Imv4PelFast; ///< imv 4-Pel fast mode
Int m_ImvMaxCand; ///< imv max num cand for test (QTBT off only)
......
......@@ -109,6 +109,8 @@ enum CodingStatisticsType
STATS__CABAC_BITS__ALIGNED_ESCAPE_BITS,
#if JEM_TOOLS
STATS__CABAC_BITS__OBMC_FLAG,
#endif
#if JVET_K0357_AMVR
STATS__CABAC_BITS__IMV_FLAG,
#endif
#if JEM_TOOLS || JVET_K1000_SIMPLIFIED_EMT
......@@ -187,6 +189,8 @@ static inline const TChar* getName(CodingStatisticsType name)
"CABAC_BITS__ALIGNED_ESCAPE_BITS",
#if JEM_TOOLS
"CABAC_BITS__OBMC_FLAG",
#endif
#if JVET_K0357_AMVR
"CABAC_BITS__IMV_FLAG",
#endif
#if JEM_TOOLS || JVET_K1000_SIMPLIFIED_EMT
......
......@@ -667,7 +667,7 @@ unsigned DeriveCtx::CtxSkipFlag( const CodingUnit& cu )
}
#if JEM_TOOLS
#if JVET_K0357_AMVR
unsigned DeriveCtx::CtxIMVFlag( const CodingUnit& cu )
{
const CodingStructure *cs = cu.cs;
......
......@@ -594,8 +594,10 @@ unsigned CtxQtCbf ( const ComponentID compID );
#endif
unsigned CtxInterDir ( const PredictionUnit& pu );
unsigned CtxSkipFlag ( const CodingUnit& cu );
#if JEM_TOOLS
#if JVET_K0357_AMVR
unsigned CtxIMVFlag ( const CodingUnit& cu );
#endif
#if JEM_TOOLS
unsigned CtxAffineFlag( const CodingUnit& cu );
unsigned CtxFrucFlag ( const PredictionUnit& pu );
unsigned CtxFrucMode ( const PredictionUnit& pu );
......
......@@ -1410,14 +1410,15 @@ const CtxSet ContextSetCfg::ChromaQpAdjIdc = ContextSetCfg::addCtxSet
{ 154,},
});
#if JEM_TOOLS
#if JVET_K0357_AMVR
const CtxSet ContextSetCfg::ImvFlag = ContextSetCfg::addCtxSet
({
{ 197, 185, 201, 185,},
{ 197, 185, 201, 185,},
{ CNU, CNU, CNU, CNU,},
});
#endif
#if JEM_TOOLS
const CtxSet ContextSetCfg::LICFlag = ContextSetCfg::addCtxSet
({
{ 154,},
......@@ -1706,7 +1707,7 @@ void CtxWSizeStore::xInitMappingTable( const SPS* sps )
unsigned numCtxTransSubdiv = ( spsNext.getUseLargeCTU() || spsNext.getUseQTBT() ? 4 : 3 ); // hard-wired in JEM
unsigned numCtxLastXY = ( spsNext.getUseLargeCTU() || spsNext.getUseQTBT() ? 25 : 15 ); // hard-wired in JEM
unsigned numCtxEmtCUFlag = ( spsNext.getUseLargeCTU() || spsNext.getUseQTBT() ? 6 : 4 ); // hard-wired in JEM
#if JEM_TOOLS
#if JVET_K0357_AMVR
unsigned numImvCtx = ( spsNext.getImvMode() > 1 ? 4 : 3 );
#endif
addCtxSetToMapping ( m_codeId2ctxId, Ctx::SplitFlag, 0, numCtxSplitFlag );
......@@ -1813,10 +1814,12 @@ void CtxWSizeStore::xInitMappingTable( const SPS* sps )
{
addCtxSetToMapping ( m_codeId2ctxId, Ctx::ObmcFlag, 0, 1 );
}
#if JVET_K0357_AMVR
if( true /* VCEG_AZ07_IMV */ )
{
addCtxSetToMapping ( m_codeId2ctxId, Ctx::ImvFlag, 0, numImvCtx );
}
#endif
if( spsNext.getLICEnabled() ) // hard-wired in JEM
{
addCtxSetToMapping ( m_codeId2ctxId, Ctx::LICFlag, 0, 1 );
......
......@@ -382,8 +382,10 @@ public:
static const CtxSet CrossCompPred;
static const CtxSet ChromaQpAdjFlag;
static const CtxSet ChromaQpAdjIdc;
#if JEM_TOOLS
#if JVET_K0357_AMVR
static const CtxSet ImvFlag;
#endif
#if JEM_TOOLS
static const CtxSet LICFlag;
static const CtxSet ObmcFlag;
static const CtxSet FrucFlag;
......
......@@ -40,7 +40,7 @@
#include "Common.h"
#include "Slice.h"
#if JEM_TOOLS
#if JVET_K0357_AMVR
void roundMV( Mv & rMV, unsigned imvShift )
{
CHECK( imvShift == 0, "roundMV called for imvShift=0" );
......
......@@ -266,7 +266,7 @@ public:
#endif
};// END CLASS DEFINITION MV
#if JEM_TOOLS
#if JVET_K0357_AMVR
void roundMV( Mv& rcMv, unsigned imvShift );
#endif
void clipMv ( Mv& rcMv, const struct Position& pos, const class SPS& sps );
......
......@@ -187,7 +187,7 @@ public:
return uiLength2 + ( g_aucPrevLog2[uiTemp2] << 1 );
}
#if JEM_TOOLS
#if JVET_K0357_AMVR
Distortion getCostOfVectorWithPredictor( const Int x, const Int y, const unsigned imvShift ) { return Distortion( m_motionLambda * getBitsOfVectorWithPredictor(x, y, imvShift )); }
UInt getBitsOfVectorWithPredictor( const Int x, const Int y, const unsigned imvShift ) { return xGetExpGolombNumberOfBits(((x << m_iCostScale) - m_mvPredictor.getHor())>>imvShift) + xGetExpGolombNumberOfBits(((y << m_iCostScale) - m_mvPredictor.getVer())>>imvShift); }
#else
......
......@@ -1739,7 +1739,7 @@ SPSNext::SPSNext( SPS& sps )
#if JEM_TOOLS
, m_ModifiedCABACEngine ( false )
#endif
#if JEM_TOOLS
#if JVET_K0357_AMVR
, m_IMV ( false )
#endif
#if JVET_K0072
......@@ -1808,7 +1808,7 @@ SPSNext::SPSNext( SPS& sps )
#if JEM_TOOLS
, m_CABACEngineMode ( 0 )
#endif
#if JEM_TOOLS
#if JVET_K0357_AMVR
, m_ImvMode ( IMV_OFF )
#endif
#if JVET_K0072
......
......@@ -819,7 +819,7 @@ private:
#if JEM_TOOLS
bool m_ModifiedCABACEngine; // 8
#endif
#if JEM_TOOLS
#if JVET_K0357_AMVR
bool m_IMV; // 9
#endif
#if JVET_K0072
......@@ -898,7 +898,7 @@ private:
// cabac engine
unsigned m_CABACEngineMode;
#endif
#if JEM_TOOLS
#if JVET_K0357_AMVR
//imv
ImvMode m_ImvMode;
#endif
......@@ -977,9 +977,11 @@ public:
#if JEM_TOOLS
bool getModifiedCABACEngine() const { return m_ModifiedCABACEngine; }
#endif
#if JEM_TOOLS
#if JVET_K0357_AMVR
void setUseIMV ( bool b ) { m_IMV = b; }
bool getUseIMV () const { return m_IMV; }
#endif
#if JEM_TOOLS
void setUseAffine ( bool b ) { m_Affine = b; }
bool getUseAffine () const { return m_Affine; }
#if JVET_K0337_AFFINE_6PARA
......@@ -1099,7 +1101,7 @@ public:
unsigned getCABACEngineMode () const { return m_CABACEngineMode; }
void setCABACEngineMode ( unsigned mode ) { m_CABACEngineMode = mode; m_ModifiedCABACEngine = ( m_CABACEngineMode != 0 ); }
#endif
#if JEM_TOOLS
#if JVET_K0357_AMVR
void setImvMode(ImvMode m) { m_ImvMode = m; m_IMV = m != 0; }
ImvMode getImvMode () const { return m_ImvMode; }
#endif
......
......@@ -100,8 +100,10 @@
#endif
#endif
#define JVET_K0357_AMVR 1 // Adaptive motion vector resolution separated from JEM_TOOLS macro
#ifndef JEM_TOOLS
#define JEM_TOOLS 1 // Defines the inclusion of JEM tools into compiled executable
#define JEM_TOOLS 0 // Defines the inclusion of JEM tools into compiled executable
#endif
#ifndef JVET_B0051_NON_MPM_MODE
......
......@@ -277,9 +277,11 @@ CodingUnit& CodingUnit::operator=( const CodingUnit& other )
#if HEVC_TILES_WPP
tileIdx = other.tileIdx;
#endif
#if JEM_TOOLS
#if JVET_K0357_AMVR
imv = other.imv;
imvNumCand = other.imvNumCand;
#endif
#if JEM_TOOLS
obmcFlag = other.obmcFlag;
#endif
......@@ -320,9 +322,11 @@ Void CodingUnit::initData()
#if HEVC_TILES_WPP
tileIdx = 0;
#endif
#if JEM_TOOLS
#if JVET_K0357_AMVR
imv = 0;
imvNumCand = 0;
#endif
#if JEM_TOOLS
obmcFlag = false;
#endif
}
......
......@@ -306,7 +306,7 @@ struct CodingUnit : public UnitArea
Bool pdpc;
#endif
Bool ipcm;
#if JEM_TOOLS
#if JVET_K0357_AMVR
UChar imv;
#endif
Bool rootCbf;
......
......@@ -1925,7 +1925,7 @@ void PU::fillMvpCand(PredictionUnit &pu, const RefPicList &eRefPicList, const in
}
}
#if JEM_TOOLS
#if JVET_K0357_AMVR
if( pu.cu->imv != 0)
{
unsigned imvShift = pu.cu->imv << 1;
......@@ -2038,7 +2038,8 @@ void PU::fillMvpCand(PredictionUnit &pu, const RefPicList &eRefPicList, const in
if( mv.highPrec ) mv.setLowPrec();
}
}
#endif
#if JVET_K0357_AMVR
if (pu.cu->imv != 0)
{
unsigned imvShift = pu.cu->imv << 1;
......@@ -4374,7 +4375,8 @@ void PU::spanLICFlags( PredictionUnit &pu, const bool LICFlag )
}
}
}
#endif
#if JVET_K0357_AMVR
Void PU::applyImv( PredictionUnit& pu, MergeCtx &mrgCtx, InterPrediction *interPred )
{
if( !pu.mergeFlag )
......@@ -4389,7 +4391,11 @@ Void PU::applyImv( PredictionUnit& pu, MergeCtx &mrgCtx, InterPrediction *interP
}
unsigned mvp_idx = pu.mvpIdx[0];
AMVPInfo amvpInfo;
PU::fillMvpCand( pu, REF_PIC_LIST_0, pu.refIdx[0], amvpInfo, interPred );
#if JEM_TOOLS
PU::fillMvpCand(pu, REF_PIC_LIST_0, pu.refIdx[0], amvpInfo, interPred);
#else
PU::fillMvpCand(pu, REF_PIC_LIST_0, pu.refIdx[0], amvpInfo);
#endif
pu.mvpNum[0] = amvpInfo.numCand;
pu.mvpIdx[0] = mvp_idx;
pu.mv [0] = amvpInfo.mvCand[mvp_idx] + pu.mvd[0];
......@@ -4404,7 +4410,11 @@ Void PU::applyImv( PredictionUnit& pu, MergeCtx &mrgCtx, InterPrediction *interP
}
unsigned mvp_idx = pu.mvpIdx[1];
AMVPInfo amvpInfo;
PU::fillMvpCand( pu, REF_PIC_LIST_1, pu.refIdx[1], amvpInfo, interPred );
#if JEM_TOOLS
PU::fillMvpCand(pu, REF_PIC_LIST_1, pu.refIdx[1], amvpInfo, interPred);
#else
PU::fillMvpCand(pu, REF_PIC_LIST_1, pu.refIdx[1], amvpInfo);
#endif
pu.mvpNum[1] = amvpInfo.numCand;
pu.mvpIdx[1] = mvp_idx;
pu.mv [1] = amvpInfo.mvCand[mvp_idx] + pu.mvd[1];
......@@ -4422,8 +4432,8 @@ Void PU::applyImv( PredictionUnit& pu, MergeCtx &mrgCtx, InterPrediction *interP
PU::spanMotionInfo( pu, mrgCtx );
}
#endif
#if JEM_TOOLS
bool PU::isBIOLDB( const PredictionUnit& pu )
{
const Slice& slice = *pu.cs->slice;
......@@ -4487,7 +4497,7 @@ void PU::restrictBiPredMergeCands( const PredictionUnit &pu, MergeCtx& mergeCtx
}
}
#if JEM_TOOLS
#if JVET_K0357_AMVR
void CU::resetMVDandMV2Int( CodingUnit& cu, InterPrediction *interPred )
{
for( auto &pu : CU::traversePUs( cu ) )
......@@ -4502,7 +4512,11 @@ void CU::resetMVDandMV2Int( CodingUnit& cu, InterPrediction *interPred )
Mv mv = pu.mv[0];
Mv mvPred;
AMVPInfo amvpInfo;
PU::fillMvpCand( pu, REF_PIC_LIST_0, pu.refIdx[0], amvpInfo, interPred );
#if JEM_TOOLS
PU::fillMvpCand(pu, REF_PIC_LIST_0, pu.refIdx[0], amvpInfo, interPred);
#else
PU::fillMvpCand(pu, REF_PIC_LIST_0, pu.refIdx[0], amvpInfo);
#endif
pu.mvpNum[0] = amvpInfo.numCand;
mvPred = amvpInfo.mvCand[pu.mvpIdx[0]];
......@@ -4516,7 +4530,11 @@ void CU::resetMVDandMV2Int( CodingUnit& cu, InterPrediction *interPred )
Mv mv = pu.mv[1];
Mv mvPred;
AMVPInfo amvpInfo;
PU::fillMvpCand( pu, REF_PIC_LIST_1, pu.refIdx[1], amvpInfo, interPred );
#if JEM_TOOLS
PU::fillMvpCand(pu, REF_PIC_LIST_1, pu.refIdx[1], amvpInfo, interPred);
#else
PU::fillMvpCand(pu, REF_PIC_LIST_1, pu.refIdx[1], amvpInfo);
#endif
pu.mvpNum[1] = amvpInfo.numCand;
mvPred = amvpInfo.mvCand[pu.mvpIdx[1]];
......@@ -4538,6 +4556,7 @@ void CU::resetMVDandMV2Int( CodingUnit& cu, InterPrediction *interPred )
}
else
{
#if JEM_TOOLS
if( pu.frucMrgMode )
{
Bool avail = interPred->deriveFRUCMV( pu );
......@@ -4554,12 +4573,14 @@ void CU::resetMVDandMV2Int( CodingUnit& cu, InterPrediction *interPred )
mrgCtx.subPuMvpMiBuf = MotionBuf( ( MotionInfo* ) alloca( bufSize.area() * sizeof( MotionInfo ) ), bufSize );
mrgCtx.subPuMvpExtMiBuf = MotionBuf( ( MotionInfo* ) alloca( bufSize.area() * sizeof( MotionInfo ) ), bufSize );
}
#endif
PU::getInterMergeCandidates ( pu, mrgCtx );
PU::restrictBiPredMergeCands( pu, mrgCtx );
mrgCtx.setMergeInfo( pu, pu.mergeIdx );
}
#if JEM_TOOLS
}
#endif
}
PU::spanMotionInfo( pu, mrgCtx );
......
......@@ -103,7 +103,7 @@ namespace CU
cPUTraverser traversePUs (const CodingUnit& cu);
cTUTraverser traverseTUs (const CodingUnit& cu);
#if JEM_TOOLS
#if JVET_K0357_AMVR
bool hasSubCUNonZeroMVd (const CodingUnit& cu);
int getMaxNeighboriMVCandNum (const CodingStructure& cs, const Position& pos);
void resetMVDandMV2Int ( CodingUnit& cu, InterPrediction *interPred );
......@@ -163,7 +163,11 @@ namespace PU
bool getInterMergeSubPuMvpCand (const PredictionUnit &pu, MergeCtx &mrgCtx, bool& LICFlag, const int count );
bool getInterMergeSubPuRecurCand (const PredictionUnit &pu, MergeCtx &mrgCtx, const int count );
#endif
#if JVET_K0357_AMVR
void applyImv ( PredictionUnit &pu, MergeCtx &mrgCtx, InterPrediction *interPred = NULL );
#endif
#if JEM_TOOLS
bool isAffineMrgFlagCoded (const PredictionUnit &pu );
void getAffineMergeCand (const PredictionUnit &pu, MvField (*mvFieldNeighbours)[3], unsigned char &interDirNeighbours, int &numValidMergeCand );
void setAllAffineMvField ( PredictionUnit &pu, MvField *mvField, RefPicList eRefList );
......
......@@ -123,7 +123,11 @@ inline void dtraceModeCost(CodingStructure &cs, double lambda)
cs.pus[0]->frucMrgMode,
cs.cus[0]->obmcFlag,
cs.cus[0]->LICFlag,
#if JVET_K0357_AMVR
cs.cus[0]->imv,
#else
0,
#endif
cs.cus[0]->affine,
intraModeL, intraModeC,
tempCost, tempBits, tempDist );
......@@ -139,7 +143,13 @@ inline void dtraceModeCost(CodingStructure &cs, double lambda)
cs.cus[0]->partSize,
cs.cus[0]->skip,
cs.pus[0]->mergeFlag,
0, 0, 0, 0, 0,
0, 0,
#if JVET_K0357_AMVR
cs.cus[0]->imv,
#else
0,
#endif
0, 0,
intraModeL, intraModeC,
tempCost, tempBits, tempDist );
#endif
......
......@@ -1282,7 +1282,7 @@ void CABACReader::cu_skip_flag( CodingUnit& cu )
}
}
#if JEM_TOOLS
#if JVET_K0357_AMVR
void CABACReader::imv_mode( CodingUnit& cu, MergeCtx& mrgCtx )
{
RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET( STATS__CABAC_BITS__OTHER );
......@@ -1375,8 +1375,10 @@ void CABACReader::cu_pred_data( CodingUnit &cu )
prediction_unit( pu, mrgCtx );
}
#if JEM_TOOLS
#if JVET_K0357_AMVR
imv_mode ( cu, mrgCtx );
#endif
#if JEM_TOOLS
obmc_flag ( cu );
cu_lic_flag( cu ); // local illumination compensation
......
......@@ -120,7 +120,7 @@ public:
void affine_flag ( CodingUnit& cu );
#endif
void merge_idx ( PredictionUnit& pu );
#if JEM_TOOLS
#if JVET_K0357_AMVR
void imv_mode ( CodingUnit& cu, MergeCtx& mrgCtx );
#endif
void inter_pred_idc ( PredictionUnit& pu );
......
......@@ -520,16 +520,16 @@ Void DecCu::xDeriveCUMV( CodingUnit &cu )
}
else
{
#if JEM_TOOLS
#if JVET_K0357_AMVR
#if REUSE_CU_RESULTS
if( cu.imv && !cu.cs->pcv->isEncoder )
if (cu.imv && !cu.cs->pcv->isEncoder)
#else
if( cu.imv )
if (cu.imv)
#endif
{
PU::applyImv( pu, mrgCtx, m_pcInterPred );
}
else
{
PU::applyImv(pu, mrgCtx, m_pcInterPred);
}
else
#endif
{
#if JEM_TOOLS || JVET_K_AFFINE
......@@ -658,19 +658,34 @@ Void DecCu::xDeriveCUMV( CodingUnit &cu )
}
else
{
for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
#if JVET_K0357_AMVR
#if REUSE_CU_RESULTS
if (cu.imv && !cu.cs->pcv->isEncoder)
#else
if (cu.imv)
#endif
{
RefPicList eRefList = RefPicList( uiRefListIdx );
if ( pu.cs->slice->getNumRefIdx( eRefList ) > 0 && ( pu.interDir & ( 1 << uiRefListIdx ) ) )
PU::applyImv(pu, mrgCtx, m_pcInterPred);
}
else
{
#endif
for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
{
AMVPInfo amvpInfo;
PU::fillMvpCand( pu, eRefList, pu.refIdx[eRefList], amvpInfo );
pu.mvpNum [eRefList] = amvpInfo.numCand;
pu.mv [eRefList] = amvpInfo.mvCand[pu.mvpIdx [eRefList]] + pu.mvd[eRefList];
RefPicList eRefList = RefPicList( uiRefListIdx );
if ( pu.cs->slice->getNumRefIdx( eRefList ) > 0 && ( pu.interDir & ( 1 << uiRefListIdx ) ) )
{
AMVPInfo amvpInfo;
PU::fillMvpCand( pu, eRefList, pu.refIdx[eRefList], amvpInfo );
pu.mvpNum [eRefList] = amvpInfo.numCand;
pu.mv [eRefList] = amvpInfo.mvCand[pu.mvpIdx [eRefList]] + pu.mvd[eRefList];
}
}
PU::spanMotionInfo( pu, mrgCtx );
}
PU::spanMotionInfo( pu, mrgCtx );
#if JVET_K0357_AMVR
}
#endif
}
}
#endif
......
......@@ -816,7 +816,7 @@ void HLSyntaxReader::parseSPSNext( SPSNext& spsNext, const bool usePCM )
#if JEM_TOOLS
READ_FLAG( symbol, "modified_cabac_engine_flag" ); spsNext.setCABACEngineMode ( symbol );
#endif
#if JEM_TOOLS
#if JVET_K0357_AMVR
READ_FLAG( symbol, "imv_enable_flag" ); spsNext.setUseIMV ( symbol != 0 );
#endif
#if JVET_K0072
......@@ -938,12 +938,13 @@ void HLSyntaxReader::parseSPSNext( SPSNext& spsNext, const bool usePCM )
}
#endif
#if JEM_TOOLS
#if JVET_K0357_AMVR
if( spsNext.getUseIMV() )
{
READ_UVLC( symbol, "imv_mode_minus1" ); spsNext.setImvMode( ImvMode( symbol + 1 ) );
}
#endif
#if JEM_TOOLS
if( spsNext.getLICEnabled() )
{
READ_UVLC( symbol, "lic_mode_minus1" ); spsNext.setLICMode( symbol + 1 );
......
......@@ -1388,8 +1388,10 @@ void CABACWriter::cu_pred_data( const CodingUnit& cu )
prediction_unit( pu );
}
#if JEM_TOOLS
#if JVET_K0357_AMVR
imv_mode ( cu );
#endif
#if JEM_TOOLS
obmc_flag ( cu );
cu_lic_flag( cu );
#endif
......@@ -2006,12 +2008,21 @@ void CABACWriter::prediction_unit( const PredictionUnit& pu )
#if JEM_TOOLS
if( pu.cu->affine )
{
mvd_coding( pu.mvdAffi[REF_PIC_LIST_0][0], 0 );
mvd_coding( pu.mvdAffi[REF_PIC_LIST_0][1], 0 );
#if JVET_K0357_AMVR
mvd_coding(pu.mvdAffi[REF_PIC_LIST_0][0], 0);
mvd_coding(pu.mvdAffi[REF_PIC_LIST_0][1], 0);
#else
mvd_coding(pu.mvdAffi[REF_PIC_LIST_0][0]);
mvd_coding(pu.mvdAffi[REF_PIC_LIST_0][1]);
#endif
#if JVET_K0337_AFFINE_6PARA
if ( pu.cu->affineType == AFFINEMODEL_6PARAM )
{
mvd_coding( pu.mvdAffi[REF_PIC_LIST_0][2], 0 );
#if JVET_K0357_AMVR
mvd_coding(pu.mvdAffi[REF_PIC_LIST_0][2], 0);
#else
mvd_coding(pu.mvdAffi[REF_PIC_LIST_0][2]);
#endif
}
#endif
}
......@@ -2019,19 +2030,28 @@ void CABACWriter::prediction_unit( const PredictionUnit& pu )
#elif JVET_K_AFFINE
if ( pu.cu->affine )
{
mvd_coding( pu.mvdAffi[REF_PIC_LIST_0][0] );
mvd_coding( pu.mvdAffi[REF_PIC_LIST_0][1] );
#if JVET_K0357_AMVR
mvd_coding(pu.mvdAffi[REF_PIC_LIST_0][0], 0);
mvd_coding(pu.mvdAffi[REF_PIC_LIST_0][1], 0);
#else
mvd_coding(pu.mvdAffi[REF_PIC_LIST_0][0]);
mvd_coding(pu.mvdAffi[REF_PIC_LIST_0][1]);
#endif
#if JVET_K0337_AFFINE_6PARA
if ( pu.cu->affineType == AFFINEMODEL_6PARAM )
{
mvd_coding( pu.mvdAffi[REF_PIC_LIST_0][2] );
#if JVET_K0357_AMVR
mvd_coding(pu.mvdAffi[REF_PIC_LIST_0][2], 0);
#else
mvd_coding(pu.mvdAffi[REF_PIC_LIST_0][2]);
#endif
}
#endif
}
else
#endif
{
#if JEM_TOOLS
#if JVET_K0357_AMVR
mvd_coding( pu.mvd[REF_PIC_LIST_0], pu.cu->imv );
#else
mvd_coding( pu.mvd[REF_PIC_LIST_0] );
......@@ -2047,12 +2067,21 @@ void CABACWriter::prediction_unit( const PredictionUnit& pu )
#if JEM_TOOLS
if( pu.cu->affine )