Commit 8ac77cab authored by Xiang Li's avatar Xiang Li

Merge branch 'master' into 'master'

JVET-N0185: A Unified MPM List for Intra Mode Coding

See merge request !415
parents 6b4725cb 140792e1
Pipeline #1213 passed with stage
......@@ -310,6 +310,17 @@ const CtxSet ContextSetCfg::IntraLumaMpmFlag = ContextSetCfg::addCtxSet
{ 6, },
});
#if JVET_N0185_UNIFIED_MPM
const CtxSet ContextSetCfg::IntraLumaPlanarFlag = ContextSetCfg::addCtxSet
({
{ 154, 154, },
{ 154, 154, },
{ 154, 154, },
{ 6, 6, },
});
#endif
const CtxSet ContextSetCfg::IntraChromaPredMode = ContextSetCfg::addCtxSet
({
{ 137, 139, 140,},
......
......@@ -206,6 +206,9 @@ public:
static const CtxSet PredMode;
static const CtxSet MultiRefLineIdx;
static const CtxSet IntraLumaMpmFlag;
#if JVET_N0185_UNIFIED_MPM
static const CtxSet IntraLumaPlanarFlag;
#endif
static const CtxSet IntraChromaPredMode;
static const CtxSet DeltaQP;
static const CtxSet InterDir;
......
......@@ -70,6 +70,7 @@
#define JVET_N0477_LMCS_CLEANUP 1
#define JVET_N0220_LMCS_SIMPLIFICATION 1
#define JVET_N0185_UNIFIED_MPM 1
#define JVET_N0271_SIMPLFIED_CCLM 1 // Simplified CCLM parameter derivation in JVET-N0271
......
......@@ -461,9 +461,11 @@ cTUTraverser CU::traverseTUs( const CodingUnit& cu )
int PU::getIntraMPMs( const PredictionUnit &pu, unsigned* mpm, const ChannelType &channelType /*= CHANNEL_TYPE_LUMA*/ )
{
const int numMPMs = NUM_MOST_PROBABLE_MODES;
#if !JVET_N0185_UNIFIED_MPM
const int extendRefLine = (channelType == CHANNEL_TYPE_LUMA) ? pu.multiRefIdx : 0;
const ISPType ispType = isLuma( channelType ) ? ISPType( pu.cu->ispMode ) : NOT_INTRA_SUBPARTITIONS;
const bool isHorSplit = ispType == HOR_INTRA_SUBPARTITIONS;
#endif
{
int numCand = -1;
int leftIntraDir = PLANAR_IDX, aboveIntraDir = PLANAR_IDX;
......@@ -491,6 +493,7 @@ int PU::getIntraMPMs( const PredictionUnit &pu, unsigned* mpm, const ChannelType
const int offset = (int)NUM_LUMA_MODE - 6;
const int mod = offset + 3;
#if !JVET_N0185_UNIFIED_MPM
if (extendRefLine)
{
int modeIdx = 0;
......@@ -667,9 +670,15 @@ int PU::getIntraMPMs( const PredictionUnit &pu, unsigned* mpm, const ChannelType
}
}
else
#endif
{
#if JVET_N0185_UNIFIED_MPM
mpm[0] = PLANAR_IDX;
mpm[1] = DC_IDX;
#else
mpm[0] = leftIntraDir;
mpm[1] = (mpm[0] == PLANAR_IDX) ? DC_IDX : PLANAR_IDX;
#endif
mpm[2] = VER_IDX;
mpm[3] = HOR_IDX;
mpm[4] = VER_IDX - 4;
......@@ -680,26 +689,53 @@ int PU::getIntraMPMs( const PredictionUnit &pu, unsigned* mpm, const ChannelType
numCand = 1;
if (leftIntraDir > DC_IDX)
{
#if JVET_N0185_UNIFIED_MPM
mpm[0] = PLANAR_IDX;
mpm[1] = leftIntraDir;
mpm[2] = ((leftIntraDir + offset) % mod) + 2;
mpm[3] = ((leftIntraDir - 1) % mod) + 2;
mpm[4] = DC_IDX;
mpm[5] = ((leftIntraDir + offset - 1) % mod) + 2;
#else
mpm[0] = leftIntraDir;
mpm[1] = PLANAR_IDX;
mpm[2] = DC_IDX;
mpm[3] = ((leftIntraDir + offset) % mod) + 2;
mpm[4] = ((leftIntraDir - 1) % mod) + 2;
mpm[5] = ((leftIntraDir + offset - 1) % mod) + 2;
#endif
}
}
else //L!=A
{
numCand = 2;
#if !JVET_N0185_UNIFIED_MPM
mpm[0] = leftIntraDir;
mpm[1] = aboveIntraDir;
#endif
#if JVET_N0185_UNIFIED_MPM
int maxCandModeIdx = mpm[0] > mpm[1] ? 0 : 1;
#else
bool maxCandModeIdx = mpm[0] > mpm[1] ? 0 : 1;
#endif
if ((leftIntraDir > DC_IDX) && (aboveIntraDir > DC_IDX))
{
#if JVET_N0185_UNIFIED_MPM
mpm[0] = PLANAR_IDX;
mpm[1] = leftIntraDir;
mpm[2] = aboveIntraDir;
maxCandModeIdx = mpm[1] > mpm[2] ? 1 : 2;
int minCandModeIdx = mpm[1] > mpm[2] ? 2 : 1;
#else
mpm[2] = PLANAR_IDX;
#endif
mpm[3] = DC_IDX;
#if JVET_N0185_UNIFIED_MPM
if ((mpm[maxCandModeIdx] - mpm[minCandModeIdx] < 63) && (mpm[maxCandModeIdx] - mpm[minCandModeIdx] > 1))
#else
if ((mpm[maxCandModeIdx] - mpm[!maxCandModeIdx] < 63) && (mpm[maxCandModeIdx] - mpm[!maxCandModeIdx] > 1))
#endif
{
mpm[4] = ((mpm[maxCandModeIdx] + offset) % mod) + 2;
mpm[5] = ((mpm[maxCandModeIdx] - 1) % mod) + 2;
......@@ -712,7 +748,14 @@ int PU::getIntraMPMs( const PredictionUnit &pu, unsigned* mpm, const ChannelType
}
else if (leftIntraDir + aboveIntraDir >= 2)
{
#if JVET_N0185_UNIFIED_MPM
mpm[0] = PLANAR_IDX;
mpm[1] = (leftIntraDir < aboveIntraDir) ? aboveIntraDir : leftIntraDir;
maxCandModeIdx = 1;
mpm[2] = DC_IDX;
#else
mpm[2] = (mpm[!maxCandModeIdx] == PLANAR_IDX) ? DC_IDX : PLANAR_IDX;
#endif
mpm[3] = ((mpm[maxCandModeIdx] + offset) % mod) + 2;
mpm[4] = ((mpm[maxCandModeIdx] - 1) % mod) + 2;
mpm[5] = ((mpm[maxCandModeIdx] + offset - 1) % mod) + 2;
......
......@@ -1092,7 +1092,15 @@ void CABACReader::intra_luma_pred_modes( CodingUnit &cu )
{
uint32_t ipred_idx = 0;
{
#if JVET_N0185_UNIFIED_MPM
unsigned ctx = (pu->cu->ispMode == NOT_INTRA_SUBPARTITIONS ? 1 : 0);
if (pu->multiRefIdx == 0)
ipred_idx = m_BinDecoder.decodeBin(Ctx::IntraLumaPlanarFlag(ctx));
else
ipred_idx = 1;
#else
ipred_idx = m_BinDecoder.decodeBinEP();
#endif
if( ipred_idx )
{
ipred_idx += m_BinDecoder.decodeBinEP();
......
......@@ -945,7 +945,13 @@ void CABACWriter::intra_luma_pred_modes( const CodingUnit& cu )
if( mpm_idx < numMPMs )
{
{
#if JVET_N0185_UNIFIED_MPM
unsigned ctx = (pu->cu->ispMode == NOT_INTRA_SUBPARTITIONS ? 1 : 0);
if (pu->multiRefIdx == 0)
m_BinEncoder.encodeBin(mpm_idx > 0, Ctx::IntraLumaPlanarFlag(ctx));
#else
m_BinEncoder.encodeBinEP( mpm_idx > 0 );
#endif
if( mpm_idx )
{
m_BinEncoder.encodeBinEP( mpm_idx > 1 );
......@@ -1024,7 +1030,13 @@ void CABACWriter::intra_luma_pred_mode( const PredictionUnit& pu )
if( mpm_idx < numMPMs )
{
{
#if JVET_N0185_UNIFIED_MPM
unsigned ctx = (pu.cu->ispMode == NOT_INTRA_SUBPARTITIONS ? 1 : 0);
if (pu.multiRefIdx == 0)
m_BinEncoder.encodeBin( mpm_idx > 0, Ctx::IntraLumaPlanarFlag(ctx) );
#else
m_BinEncoder.encodeBinEP( mpm_idx > 0 );
#endif
if( mpm_idx )
{
m_BinEncoder.encodeBinEP( mpm_idx > 1 );
......
......@@ -534,7 +534,11 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner,
{
initIntraPatternChType(cu, pu.Y(), IntraPrediction::useFilteredIntraRefSamples(COMPONENT_Y, pu, false, pu));
}
#if JVET_N0185_UNIFIED_MPM
for (int x = 1; x < numMPMs; x++)
#else
for (int x = 0; x < numMPMs; x++)
#endif
{
uint32_t mode = multiRefMPM[x];
{
......@@ -798,7 +802,11 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner,
{
multiRefIdx = extendRefList[uiMode];
pu.multiRefIdx = multiRefIdx;
#if !JVET_N0185_UNIFIED_MPM
CHECK( pu.multiRefIdx && ( pu.intraDir[0] == DC_IDX || pu.intraDir[0] == PLANAR_IDX ), "ERL" );
#else
CHECK( pu.multiRefIdx && (pu.intraDir[0] == PLANAR_IDX), "ERL" );
#endif
}
......
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