Commit 3fdc7d65 authored by rlliao's avatar rlliao

L0124 & L0208 Triangular shape prediction unit with the bug fix

parent ccaa3ca0
......@@ -130,6 +130,7 @@ ALF : 1
GBi : 1
GBiFast : 1
MHIntra : 1
Triangle : 1
# Fast tools
PBIntraFast : 1
......
......@@ -145,6 +145,7 @@ GBi : 1
GBiFast : 1
BIO : 1
MHIntra : 1
Triangle : 1
# Fast tools
PBIntraFast : 1
......
......@@ -263,6 +263,9 @@ void EncApp::xInitLibCfg()
#endif
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
m_cEncLib.setUseMHIntra ( m_MHIntra );
#endif
#if JVET_L0124_L0208_TRIANGLE
m_cEncLib.setUseTriangle ( m_Triangle );
#endif
// ADD_NEW_TOOL : (encoder app) add setting of tool enabling flags and associated parameters here
......
......@@ -868,6 +868,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
#endif
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
("MHIntra", m_MHIntra, false, "Enable MHIntra mode")
#endif
#if JVET_L0124_L0208_TRIANGLE
("Triangle", m_Triangle, false, "Enable triangular shape motion vector prediction (0:off, 1:on) [default: on]")
#endif
// ADD_NEW_TOOL : (encoder app) add parsing parameters here
......@@ -1966,6 +1969,9 @@ bool EncAppCfg::xCheckParameter()
#if JVET_L0646_GBI
xConfirmPara( m_GBi, "GBi is only allowed with NEXT profile" );
xConfirmPara( m_GBiFast, "GBiFast is only allowed with NEXT profile" );
#endif
#if JVET_L0124_L0208_TRIANGLE
xConfirmPara( m_Triangle, "Triangle is only allowed with NEXT profile" );
#endif
// ADD_NEW_TOOL : (parameter check) add a check for next tools here
}
......@@ -3191,6 +3197,9 @@ void EncAppCfg::xPrintParameter()
#endif
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
msg(VERBOSE, "MHIntra:%d ", m_MHIntra);
#endif
#if JVET_L0124_L0208_TRIANGLE
msg( VERBOSE, "Triangle:%d ", m_Triangle );
#endif
}
// ADD_NEW_TOOL (add some output indicating the usage of tools)
......
......@@ -240,6 +240,9 @@ protected:
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
bool m_MHIntra;
#endif
#if JVET_L0124_L0208_TRIANGLE
bool m_Triangle;
#endif
// ADD_NEW_TOOL : (encoder app) add tool enabling flags and associated parameters here
......
......@@ -108,6 +108,10 @@ enum CodingStatisticsType
STATS__TOOL_EMT,
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
STATS__CABAC_BITS__MH_INTRA_FLAG,
#endif
#if JVET_L0124_L0208_TRIANGLE
STATS__CABAC_BITS__TRIANGLE_FLAG,
STATS__CABAC_BITS__TRIANGLE_INDEX,
#endif
STATS__TOOL_TOTAL,
STATS__NUM_STATS
......@@ -183,6 +187,10 @@ static inline const char* getName(CodingStatisticsType name)
"CABAC_BITS__EMT_TU_INDX",
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
"CABAC_BITS__MH_INTRA_FLAG",
#endif
#if JVET_L0124_L0208_TRIANGLE
"CABAC_BITS__TRIANGLE_FLAG",
"CABAC_BITS__TRIANGLE_INDEX",
#endif
"CABAC_BITS__OTHER",
"CABAC_BITS__INVALID",
......
......@@ -415,6 +415,14 @@ static const int MAX_LADF_INTERVALS = 5; /// max n
static const int NTAPS_BILINEAR = 2; ///< Number of taps for bilinear filter
#endif
#if JVET_L0124_L0208_TRIANGLE
static const int TRIANGLE_MAX_NUM_UNI_CANDS = 5;
static const int TRIANGLE_MAX_NUM_CANDS_MEM = 7;
static const int TRIANGLE_MAX_NUM_CANDS = 40;
static const int TRIANGLE_MAX_NUM_SATD_CANDS = 3;
static const int TRIANGLE_MIN_SIZE = 8 * 8;
#endif
// ====================================================================================================================
// Macro functions
// ====================================================================================================================
......
......@@ -359,6 +359,22 @@ unsigned DeriveCtx::CtxBTsplit(const CodingStructure& cs, Partitioner& partition
return ctx;
}
#if JVET_L0124_L0208_TRIANGLE
unsigned DeriveCtx::CtxTriangleFlag( const CodingUnit& cu )
{
const CodingStructure *cs = cu.cs;
unsigned ctxId = 0;
const CodingUnit *cuLeft = cs->getCURestricted( cu.lumaPos().offset( -1, 0 ), cu, CH_L );
ctxId = ( cuLeft && cuLeft->triangle ) ? 1 : 0;
const CodingUnit *cuAbove = cs->getCURestricted( cu.lumaPos().offset( 0, -1 ), cu, CH_L );
ctxId += ( cuAbove && cuAbove->triangle ) ? 1 : 0;
return ctxId;
}
#endif
void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx )
{
......
......@@ -353,6 +353,9 @@ unsigned CtxInterDir ( const PredictionUnit& pu );
unsigned CtxSkipFlag ( const CodingUnit& cu );
unsigned CtxIMVFlag ( const CodingUnit& cu );
unsigned CtxAffineFlag( const CodingUnit& cu );
#if JVET_L0124_L0208_TRIANGLE
unsigned CtxTriangleFlag( const CodingUnit& cu );
#endif
}
#endif // __CONTEXTMODELLING__
......@@ -823,6 +823,22 @@ const CtxSet ContextSetCfg::MHIntraPredMode = ContextSetCfg::addCtxSet
});
#endif
#if JVET_L0124_L0208_TRIANGLE
const CtxSet ContextSetCfg::TriangleFlag = ContextSetCfg::addCtxSet
({
{ 151, 137, 154, },
{ 151, 137, 154, },
{ CNU, CNU, CNU, },
});
const CtxSet ContextSetCfg::TriangleIdx = ContextSetCfg::addCtxSet
({
{ 140, },
{ 140, },
{ CNU, },
});
#endif
const unsigned ContextSetCfg::NumberOfContexts = (unsigned)ContextSetCfg::sm_InitTables[0].size();
......
......@@ -206,6 +206,10 @@ public:
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
static const CtxSet MHIntraFlag;
static const CtxSet MHIntraPredMode;
#endif
#if JVET_L0124_L0208_TRIANGLE
static const CtxSet TriangleFlag;
static const CtxSet TriangleIdx;
#endif
static const unsigned NumberOfContexts;
......
This diff is collapsed.
......@@ -91,6 +91,9 @@ protected:
RdCost* m_pcRdCost;
int m_iRefListIdx;
#if JVET_L0124_L0208_TRIANGLE
PelStorage m_tmpTriangleBuf;
#endif
#if JVET_L0265_AFF_MINIMUM4X4
Mv* m_storedMv;
#endif
......@@ -149,6 +152,11 @@ public:
void motionCompensation (CodingUnit &cu, const RefPicList &eRefPicList = REF_PIC_LIST_X
);
#if JVET_L0124_L0208_TRIANGLE
void motionCompensation4Triangle( CodingUnit &cu, MergeCtx &TriangleMrgCtx, const bool SplitDir, const uint8_t CandIdx0, const uint8_t CandIdx1 );
void TriangleWeighting ( PredictionUnit &pu, bool ehanced, const bool SplitDir, int32_t channel, PelUnitBuf& PredDst, PelUnitBuf& PredSrc0, PelUnitBuf& PredSrc1 );
#endif
#if JVET_J0090_MEMORY_BANDWITH_MEASURE
void cacheAssign( CacheModel *cache );
#endif
......
......@@ -528,6 +528,30 @@ void initROM()
//--------------------------------------------------------------------------------------------------
}
}
#if JVET_L0124_L0208_TRIANGLE
for( int IdxH = MAX_CU_DEPTH - MIN_CU_LOG2; IdxH >= 0; --IdxH )
{
for( int IdxW = MAX_CU_DEPTH - MIN_CU_LOG2; IdxW >= 0; --IdxW )
{
int numW = 1 << IdxW;
int numH = 1 << IdxH;
int ratioW = std::max( 0, IdxW - IdxH );
int ratioH = std::max( 0, IdxH - IdxW );
int sum = std::max( (numW >> ratioW), (numH >> ratioH) ) - 1;
for( int y = 0; y < numH; y++ )
{
int IdxY = y >> ratioH;
for( int x = 0; x < numW; x++ )
{
int IdxX = x >> ratioW;
g_TriangleMvStorage[TRIANGLE_DIR_135][IdxH][IdxW][y][x] = (IdxX == IdxY) ? 2 : (IdxX > IdxY ? 0 : 1);
g_TriangleMvStorage[TRIANGLE_DIR_45][IdxH][IdxW][y][x] = (IdxX + IdxY == sum) ? 2 : (IdxX + IdxY > sum ? 1 : 0);
}
}
}
}
#endif
}
void destroyROM()
......@@ -883,5 +907,65 @@ const uint8_t g_NonMPM[257] = { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8 };
#if JVET_L0124_L0208_TRIANGLE
const Pel g_TrianglePelWeightedLuma[TRIANGLE_DIR_NUM][2][7] =
{
{ // TRIANGLE_DIR_135
{ 1, 2, 4, 6, 7, 0, 0 },
{ 1, 2, 3, 4, 5, 6, 7 }
},
{ // TRIANGLE_DIR_45
{ 7, 6, 4, 2, 1, 0, 0 },
{ 7, 6, 5, 4, 3, 2, 1 }
}
};
const Pel g_TrianglePelWeightedChroma[2][TRIANGLE_DIR_NUM][2][7] =
{
{ // 444 format
{ // TRIANGLE_DIR_135
{ 1, 2, 4, 6, 7, 0, 0 },
{ 1, 2, 3, 4, 5, 6, 7 }
},
{ // TRIANGLE_DIR_45
{ 7, 6, 4, 2, 1, 0, 0 },
{ 7, 6, 5, 4, 3, 2, 1 }
}
},
{ // 420 format
{ // TRIANGLE_DIR_135
{ 1, 4, 7, 0, 0, 0, 0 },
{ 2, 4, 6, 0, 0, 0, 0 }
},
{ // TRIANGLE_DIR_45
{ 7, 4, 1, 0, 0, 0, 0 },
{ 6, 4, 2, 0, 0, 0, 0 }
}
}
};
const uint8_t g_TriangleWeightLengthLuma[2] = { 5, 7 };
const uint8_t g_TriangleWeightLengthChroma[2][2] = { { 5, 7 }, { 3, 3 } };
uint8_t g_TriangleMvStorage[TRIANGLE_DIR_NUM][MAX_CU_DEPTH - MIN_CU_LOG2 + 1][MAX_CU_DEPTH - MIN_CU_LOG2 + 1][MAX_CU_SIZE >> MIN_CU_LOG2][MAX_CU_SIZE >> MIN_CU_LOG2];
const uint8_t g_TriangleCombination[TRIANGLE_MAX_NUM_CANDS][3] =
{
{ 0, 1, 0 }, { 1, 0, 1 }, { 1, 0, 2 }, { 0, 0, 1 }, { 0, 2, 0 },
{ 1, 0, 3 }, { 1, 0, 4 }, { 1, 1, 0 }, { 0, 3, 0 }, { 0, 4, 0 },
{ 0, 0, 2 }, { 0, 1, 2 }, { 1, 1, 2 }, { 0, 0, 4 }, { 0, 0, 3 },
{ 0, 1, 3 }, { 0, 1, 4 }, { 1, 1, 4 }, { 1, 1, 3 }, { 1, 2, 1 },
{ 1, 2, 0 }, { 0, 2, 1 }, { 0, 4, 3 }, { 1, 3, 0 }, { 1, 3, 2 },
{ 1, 3, 4 }, { 1, 4, 0 }, { 1, 3, 1 }, { 1, 2, 3 }, { 1, 4, 1 },
{ 0, 4, 1 }, { 0, 2, 3 }, { 1, 4, 2 }, { 0, 3, 2 }, { 1, 4, 3 },
{ 0, 3, 1 }, { 0, 2, 4 }, { 1, 2, 4 }, { 0, 4, 2 }, { 0, 3, 4 },
};
const uint8_t g_TriangleIdxBins[TRIANGLE_MAX_NUM_CANDS] =
{
2, 2, 4, 4, 4, 4, 6, 6, 6, 6,
6, 6, 6, 6, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10
};
#endif
//! \}
......@@ -270,5 +270,15 @@ constexpr uint8_t g_tbMax[257] = { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3,
//! \}
#if JVET_L0124_L0208_TRIANGLE
extern const Pel g_TrianglePelWeightedLuma[TRIANGLE_DIR_NUM][2][7];
extern const Pel g_TrianglePelWeightedChroma[2][TRIANGLE_DIR_NUM][2][7];
extern const uint8_t g_TriangleWeightLengthLuma[2];
extern const uint8_t g_TriangleWeightLengthChroma[2][2];
extern uint8_t g_TriangleMvStorage[TRIANGLE_DIR_NUM][MAX_CU_DEPTH - MIN_CU_LOG2 + 1][MAX_CU_DEPTH - MIN_CU_LOG2 + 1][MAX_CU_SIZE >> MIN_CU_LOG2][MAX_CU_SIZE >> MIN_CU_LOG2];
extern const uint8_t g_TriangleCombination[TRIANGLE_MAX_NUM_CANDS][3];
extern const uint8_t g_TriangleIdxBins[TRIANGLE_MAX_NUM_CANDS];
#endif
#endif //__TCOMROM__
......@@ -1651,6 +1651,9 @@ void Slice::updateMotionLUTs(LutMotionCand* lutMC, CodingUnit & cu)
{
PredictionUnit *selectedPU = cu.firstPU;
if (cu.affine) { return; }
#if JVET_L0124_L0208_TRIANGLE
if (cu.triangle) { return; }
#endif
MotionInfo newMi = selectedPU->getMotionInfo();
addMotionInfoToLUTs(lutMC, newMi);
......@@ -1757,6 +1760,9 @@ SPSNext::SPSNext( SPS& sps )
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
, m_MHIntra ( false )
#endif
#if JVET_L0124_L0208_TRIANGLE
, m_Triangle ( false )
#endif
#if ENABLE_WPP_PARALLELISM
, m_NextDQP ( false )
#endif
......
......@@ -823,6 +823,9 @@ private:
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
bool m_MHIntra;
#endif
#if JVET_L0124_L0208_TRIANGLE
bool m_Triangle;
#endif
#if ENABLE_WPP_PARALLELISM
bool m_NextDQP;
#endif
......@@ -972,6 +975,10 @@ public:
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
void setUseMHIntra ( bool b ) { m_MHIntra = b; }
bool getUseMHIntra () const { return m_MHIntra; }
#endif
#if JVET_L0124_L0208_TRIANGLE
void setUseTriangle ( bool b ) { m_Triangle = b; }
bool getUseTriangle () const { return m_Triangle; }
#endif
// ADD_NEW_TOOL : (sps extension) add access functions for tool enabling flags and associated parameters here
......
......@@ -50,6 +50,8 @@
#include <assert.h>
#include <cassert>
#define JVET_L0124_L0208_TRIANGLE 1 // triangular shape prediction unit
#define JVET_L0059_MTS_SIMP 1 // Simpification on MTS signaling
#define JVET_L0100_MULTI_HYPOTHESIS_INTRA 1 // Combine intra mode with an extra merge indexed prediction
......@@ -942,6 +944,14 @@ enum MergeType
NUM_MRG_TYPE // 5
};
#if JVET_L0124_L0208_TRIANGLE
enum TriangleSplit
{
TRIANGLE_DIR_135 = 0,
TRIANGLE_DIR_45,
TRIANGLE_DIR_NUM
};
#endif
//////////////////////////////////////////////////////////////////////////
// Encoder modes to try out
......
......@@ -258,6 +258,9 @@ CodingUnit& CodingUnit::operator=( const CodingUnit& other )
#endif
affine = other.affine;
affineType = other.affineType;
#if JVET_L0124_L0208_TRIANGLE
triangle = other.triangle;
#endif
transQuantBypass = other.transQuantBypass;
ipcm = other.ipcm;
qp = other.qp;
......@@ -292,6 +295,9 @@ void CodingUnit::initData()
#endif
affine = false;
affineType = 0;
#if JVET_L0124_L0208_TRIANGLE
triangle = false;
#endif
transQuantBypass = false;
ipcm = false;
qp = 0;
......
......@@ -300,6 +300,9 @@ struct CodingUnit : public UnitArea
#endif
bool affine;
int affineType;
#if JVET_L0124_L0208_TRIANGLE
bool triangle;
#endif
bool transQuantBypass;
bool ipcm;
uint8_t imv;
......
This diff is collapsed.
......@@ -173,6 +173,13 @@ namespace PU
int getMHIntraMPMs (const PredictionUnit &pu, unsigned *mpm, const ChannelType &channelType = CHANNEL_TYPE_LUMA, const bool isChromaMDMS = false, const unsigned startIdx = 0);
int getNarrowShape (const int width, const int height);
#endif
#if JVET_L0124_L0208_TRIANGLE
void getTriangleMergeCandidates (const PredictionUnit &pu, MergeCtx& TriangleMrgCtx);
bool isUniqueTriangleCandidates (const PredictionUnit &pu, MergeCtx& TriangleMrgCtx);
bool isTriangleEhancedWeight (const PredictionUnit &pu, MergeCtx &TriangleMrgCtx, const uint8_t CandIdx0, const uint8_t CandIdx1);
void spanTriangleMotionInfo ( PredictionUnit &pu, MergeCtx &TriangleMrgCtx, const uint8_t MergeIdx, const bool SplitDir, const uint8_t CandIdx0, const uint8_t CandIdx1);
int32_t mappingRefPic (const PredictionUnit &pu, int32_t refPicPoc, bool targetRefPicList);
#endif
}
// TU tools
......
......@@ -1172,6 +1172,9 @@ void CABACReader::prediction_unit( PredictionUnit& pu, MergeCtx& mrgCtx )
pu.intraDir[1] = DM_CHROMA_IDX;
}
#endif
#if JVET_L0124_L0208_TRIANGLE
triangle_mode( *pu.cu );
#endif
#if JVET_L0054_MMVD
if (pu.mmvdMergeFlag)
{
......@@ -1413,6 +1416,25 @@ void CABACReader::merge_idx( PredictionUnit& pu )
#endif
int numCandminus1 = int( pu.cs->slice->getMaxNumMergeCand() ) - 1;
pu.mergeIdx = 0;
#if JVET_L0124_L0208_TRIANGLE
if( pu.cu->triangle )
{
RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET( STATS__CABAC_BITS__TRIANGLE_INDEX );
if( m_BinDecoder.decodeBin( Ctx::TriangleIdx() ) == 0 )
{
pu.mergeIdx += m_BinDecoder.decodeBinEP();
}
else
{
pu.mergeIdx += exp_golomb_eqprob( 2 ) + 2;
}
DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() triangle_idx=%d\n", pu.mergeIdx );
return;
}
#endif
if( numCandminus1 > 0 )
{
if( m_BinDecoder.decodeBin( Ctx::MergeIdx() ) )
......@@ -1728,6 +1750,23 @@ void CABACReader::MHIntra_luma_pred_modes(CodingUnit &cu)
}
#endif
#if JVET_L0124_L0208_TRIANGLE
void CABACReader::triangle_mode( CodingUnit& cu )
{
RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET( STATS__CABAC_BITS__TRIANGLE_FLAG );
if( !cu.cs->slice->getSPS()->getSpsNext().getUseTriangle() || !cu.cs->slice->isInterB() || cu.lwidth() * cu.lheight() < TRIANGLE_MIN_SIZE || cu.affine )
{
return;
}
unsigned flag_idx = DeriveCtx::CtxTriangleFlag( cu );
cu.triangle = m_BinDecoder.decodeBin( Ctx::TriangleFlag(flag_idx) );
DTRACE( g_trace_ctx, D_SYNTAX, "triangle_mode() triangle_mode=%d pos=(%d,%d) size: %dx%d\n", cu.triangle, cu.Y().x, cu.Y().y, cu.lumaSize().width, cu.lumaSize().height );
}
#endif
//================================================================================
// clause 7.3.8.7
......
......@@ -111,6 +111,9 @@ public:
void MHIntra_flag ( PredictionUnit& pu );
void MHIntra_luma_pred_modes ( CodingUnit& cu );
#endif
#if JVET_L0124_L0208_TRIANGLE
void triangle_mode ( CodingUnit& cu );
#endif
// pcm samples (clause 7.3.8.7)
void pcm_samples ( TransformUnit& tu );
......
......@@ -314,12 +314,28 @@ void DecCu::xFillPCMBuffer(CodingUnit &cu)
void DecCu::xReconInter(CodingUnit &cu)
{
#if JVET_L0124_L0208_TRIANGLE
if( cu.triangle )
{
const uint8_t mergeIdx = cu.firstPU->mergeIdx;
const bool SplitDir = g_TriangleCombination[mergeIdx][0];
const uint8_t CandIdx0 = g_TriangleCombination[mergeIdx][1];
const uint8_t CandIdx1 = g_TriangleCombination[mergeIdx][2];
m_pcInterPred->motionCompensation4Triangle( cu, m_TriangleMrgCtx, SplitDir, CandIdx0, CandIdx1 );
PU::spanTriangleMotionInfo( *cu.firstPU, m_TriangleMrgCtx, mergeIdx, SplitDir, CandIdx0, CandIdx1 );
}
else
{
#endif
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
m_pcIntraPred->geneIntrainterPred(cu);
#endif
// inter prediction
m_pcInterPred->motionCompensation( cu );
#if JVET_L0124_L0208_TRIANGLE
}
#endif
#if JVET_L0266_HMVP
cu.slice->updateMotionLUTs(cu.slice->getMotionLUTs(), cu);
#endif
......@@ -486,6 +502,14 @@ void DecCu::xDeriveCUMV( CodingUnit &cu )
{
#endif
{
#if JVET_L0124_L0208_TRIANGLE
if( pu.cu->triangle )
{
PU::getTriangleMergeCandidates( pu, m_TriangleMrgCtx );
}
else
{
#endif
if( pu.cu->affine )
{
#if JVET_L0632_AFFINE_MERGE
......@@ -593,6 +617,9 @@ void DecCu::xDeriveCUMV( CodingUnit &cu )
PU::spanMotionInfo( pu, mrgCtx );
}
#if JVET_L0124_L0208_TRIANGLE
}
#endif
}
#if JVET_L0054_MMVD
}
......
......@@ -92,6 +92,10 @@ private:
MotionInfo m_SubPuMiBuf[(MAX_CU_SIZE * MAX_CU_SIZE) >> (MIN_CU_LOG2 << 1)];
#if JVET_L0124_L0208_TRIANGLE
MergeCtx m_TriangleMrgCtx;
#endif
};
//! \}
......
......@@ -818,6 +818,9 @@ void HLSyntaxReader::parseSPSNext( SPSNext& spsNext, const bool usePCM )
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
READ_FLAG( symbol, "mhintra_flag" ); spsNext.setUseMHIntra ( symbol != 0 );
#endif
#if JVET_L0124_L0208_TRIANGLE
READ_FLAG( symbol, "triangle_flag" ); spsNext.setUseTriangle ( symbol != 0 );
#endif
#if ENABLE_WPP_PARALLELISM
READ_FLAG( symbol, "next_dqp_enabled_flag" ); spsNext.setUseNextDQP ( symbol != 0 );
#else
......
......@@ -1132,6 +1132,9 @@ void CABACWriter::prediction_unit( const PredictionUnit& pu )
MHIntra_luma_pred_modes( *pu.cu );
}
#endif
#if JVET_L0124_L0208_TRIANGLE
triangle_mode( *pu.cu );
#endif
#if JVET_L0054_MMVD
if (pu.mmvdMergeFlag)
{
......@@ -1354,6 +1357,24 @@ void CABACWriter::merge_idx( const PredictionUnit& pu )
}
else
{
#endif
#if JVET_L0124_L0208_TRIANGLE
if( pu.cu->triangle )
{
if( pu.mergeIdx < 2 )
{
m_BinEncoder.encodeBin( 0, Ctx::TriangleIdx() );
m_BinEncoder.encodeBinEP( pu.mergeIdx );
}
else
{
m_BinEncoder.encodeBin( 1, Ctx::TriangleIdx() );
exp_golomb_eqprob( pu.mergeIdx - 2, 2 );
}
DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() triangle_idx=%d\n", pu.mergeIdx );
return;
}
#endif
int numCandminus1 = int( pu.cs->slice->getMaxNumMergeCand() ) - 1;
if( numCandminus1 > 0 )
......@@ -1618,6 +1639,22 @@ void CABACWriter::MHIntra_luma_pred_modes(const CodingUnit& cu)
}
#endif
#if JVET_L0124_L0208_TRIANGLE
void CABACWriter::triangle_mode( const CodingUnit& cu )
{
if( !cu.cs->slice->getSPS()->getSpsNext().getUseTriangle() || !cu.cs->slice->isInterB() || cu.lwidth() * cu.lheight() < TRIANGLE_MIN_SIZE || cu.affine )
{
return;
}
unsigned flag_idx = DeriveCtx::CtxTriangleFlag( cu );
m_BinEncoder.encodeBin( cu.triangle, Ctx::TriangleFlag(flag_idx) );
DTRACE( g_trace_ctx, D_SYNTAX, "triangle_mode() triangle_mode=%d pos=(%d,%d) size: %dx%d\n", cu.triangle, cu.Y().x, cu.Y().y, cu.lumaSize().width, cu.lumaSize().height );
}
#endif
//================================================================================
// clause 7.3.8.7
//--------------------------------------------------------------------------------
......
......@@ -125,6 +125,9 @@ public:
void MHIntra_flag ( const PredictionUnit& pu );
void MHIntra_luma_pred_modes ( const CodingUnit& cu );
#endif
#if JVET_L0124_L0208_TRIANGLE
void triangle_mode ( const CodingUnit& cu );
#endif
// pcm samples (clause 7.3.8.7)
void pcm_samples ( const TransformUnit& tu );
......
......@@ -223,6 +223,9 @@ protected:
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
bool m_MHIntra;
#endif
#if JVET_L0124_L0208_TRIANGLE
bool m_Triangle;
#endif
// ADD_NEW_TOOL : (encoder lib) add tool enabling flags and associated parameters here
......@@ -695,6 +698,10 @@ public:
void setUseMHIntra ( bool b ) { m_MHIntra = b; }
bool getUseMHIntra () const { return m_MHIntra; }
#endif
#if JVET_L0124_L0208_TRIANGLE
void setUseTriangle ( bool b ) { m_Triangle = b; }
bool getUseTriangle () const { return m_Triangle; }
#endif
// ADD_NEW_TOOL : (encoder lib) add access functions here
......
This diff is collapsed.
......@@ -119,6 +119,10 @@ private:
#endif
#else
PelStorage m_acMergeBuffer[MRG_MAX_NUM_CANDS];
#endif
#if JVET_L0124_L0208_TRIANGLE
PelStorage m_acTriangleWeightBuffer[TRIANGLE_MAX_NUM_CANDS]; // to store weighted prediction pixles
double m_mergeBestSATDCost;
#endif
MotionInfo m_SubPuMiBuf [( MAX_CU_SIZE * MAX_CU_SIZE ) >> ( MIN_CU_LOG2 << 1 )];
unsigned int m_subMergeBlkSize[10];
......@@ -173,6 +177,11 @@ public:
void setClearSubMergeStatic(bool b) { m_clearSubMergeStatic = b; }
bool getClearSubMergeStatic() { return m_clearSubMergeStatic; }
#if JVET_L0124_L0208_TRIANGLE
void setMergeBestSATDCost(double cost) { m_mergeBestSATDCost = cost; }
double getMergeBestSATDCost() { return m_mergeBestSATDCost; }
#endif
~EncCu();
protected:
......@@ -217,6 +226,10 @@ protected:
void xCheckRDCostMerge2Nx2N ( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &pm, const EncTestMode& encTestMode );
#if JVET_L0124_L0208_TRIANGLE
void xCheckRDCostMergeTriangle2Nx2N( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &pm, const EncTestMode& encTestMode );
#endif
void xEncodeInterResidual ( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &partitioner, const EncTestMode& encTestMode, int residualPass = 0
, CodingStructure* imvCS = NULL
, int emtMode = 1
......
......@@ -878,6 +878,9 @@ void EncLib::xInitSPS(SPS &sps)
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
sps.getSpsNext().setUseMHIntra ( m_MHIntra );
#endif
#if JVET_L0124_L0208_TRIANGLE
sps.getSpsNext().setUseTriangle ( m_Triangle );
#endif
// ADD_NEW_TOOL : (encoder lib) set tool enabling flags and associated parameters here
......
......@@ -1077,6 +1077,12 @@ void EncModeCtrlMTnoRQT::initCULevel( Partitioner &partit