diff --git a/source/Lib/CommonLib/ContextModelling.cpp b/source/Lib/CommonLib/ContextModelling.cpp index 178cd6ffd736e1bc52179557384207acf1268005..b6fab097fcf728bb1b0914b93d087b7f5ae677f9 100644 --- a/source/Lib/CommonLib/ContextModelling.cpp +++ b/source/Lib/CommonLib/ContextModelling.cpp @@ -439,6 +439,17 @@ unsigned DeriveCtx::CtxTriangleFlag( const CodingUnit& cu ) return ctxId; } +#if JVET_M0502_PRED_MODE_CTX +unsigned DeriveCtx::CtxPredModeFlag( const CodingUnit& cu ) +{ + const CodingUnit *cuLeft = cu.cs->getCURestricted(cu.lumaPos().offset(-1, 0), cu, CH_L); + const CodingUnit *cuAbove = cu.cs->getCURestricted(cu.lumaPos().offset(0, -1), cu, CH_L); + + unsigned ctxId = ((cuAbove && cuAbove->predMode == MODE_INTRA) || (cuLeft && cuLeft->predMode == MODE_INTRA)) ? 1 : 0; + + return ctxId; +} +#endif void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx ) { diff --git a/source/Lib/CommonLib/ContextModelling.h b/source/Lib/CommonLib/ContextModelling.h index c2e6d7899d721684782f1306adb4e4e2c8439a38..959b45b7c2cc709a0f69af4f75fc827df7bb3867 100644 --- a/source/Lib/CommonLib/ContextModelling.h +++ b/source/Lib/CommonLib/ContextModelling.h @@ -310,6 +310,9 @@ unsigned CtxSkipFlag ( const CodingUnit& cu ); unsigned CtxIMVFlag ( const CodingUnit& cu ); unsigned CtxAffineFlag( const CodingUnit& cu ); unsigned CtxTriangleFlag( const CodingUnit& cu ); +#if JVET_M0502_PRED_MODE_CTX +unsigned CtxPredModeFlag( const CodingUnit& cu ); +#endif } #endif // __CONTEXTMODELLING__ diff --git a/source/Lib/CommonLib/Contexts.cpp b/source/Lib/CommonLib/Contexts.cpp index 6555d5d76529d296f17adb4312ef14160d97cd68..3a29c4a4086b2bb5b3f8f0fe47b457a19fe38f30 100644 --- a/source/Lib/CommonLib/Contexts.cpp +++ b/source/Lib/CommonLib/Contexts.cpp @@ -519,15 +519,28 @@ const CtxSet ContextSetCfg::PartSize = ContextSetCfg::addCtxSet const CtxSet ContextSetCfg::PredMode = ContextSetCfg::addCtxSet ({ #if JVET_M0453_CABAC_ENGINE +#if JVET_M0502_PRED_MODE_CTX + { 193, 193, }, + { 151, 151, }, + { CNU, CNU, }, + { 1, 1, }, +#else { 193,}, { 151,}, { CNU,}, { 1,}, +#endif +#else +#if JVET_M0502_PRED_MODE_CTX + { 178, 178, }, + { 194, 194, }, + { CNU, CNU, }, #else { 178, }, { 194, }, { CNU, }, #endif +#endif }); const CtxSet ContextSetCfg::MultiRefLineIdx = ContextSetCfg::addCtxSet diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index d4a16eb0e1d8bf66ab1e8ec728a4e0a451045243..dad438451e17211e16114a69970bb577082642cf 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -52,6 +52,8 @@ #define JVET_M0479_18BITS_MV_CLIP 1 +#define JVET_M0502_PRED_MODE_CTX 1 + #define JVET_M0464_UNI_MTS 1 #if JVET_M0464_UNI_MTS diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 1d201b375c97ce5b5c41fa1d8442756dd98bda52..757202d9640bbf98b7bc32264ca4faeb1608a772 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -927,7 +927,11 @@ void CABACReader::pred_mode( CodingUnit& cu ) { RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET( STATS__CABAC_BITS__PRED_MODE ); +#if JVET_M0502_PRED_MODE_CTX + if( cu.cs->slice->isIntra() || m_BinDecoder.decodeBin( Ctx::PredMode(DeriveCtx::CtxPredModeFlag(cu)) ) ) +#else if( cu.cs->slice->isIntra() || m_BinDecoder.decodeBin( Ctx::PredMode() ) ) +#endif { cu.predMode = MODE_INTRA; } diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index eb391f4dcb261abf64549ffec038f63413269d9d..d883588edd785b18c692c7114accac21deafd738 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -783,7 +783,11 @@ void CABACWriter::pred_mode( const CodingUnit& cu ) { return; } +#if JVET_M0502_PRED_MODE_CTX + m_BinEncoder.encodeBin( ( CU::isIntra( cu ) ), Ctx::PredMode( DeriveCtx::CtxPredModeFlag( cu ) ) ); +#else m_BinEncoder.encodeBin( ( CU::isIntra( cu ) ), Ctx::PredMode() ); +#endif } void CABACWriter::pcm_data( const CodingUnit& cu, Partitioner& partitioner )