diff --git a/source/Lib/CommonLib/Contexts.cpp b/source/Lib/CommonLib/Contexts.cpp index 2babdef1cb3d367303dd17297a3fff984266c502..ac966c7c4969771746abce830533c833dd9a21fe 100644 --- a/source/Lib/CommonLib/Contexts.cpp +++ b/source/Lib/CommonLib/Contexts.cpp @@ -557,10 +557,8 @@ const CtxSet ContextSetCfg::MultiRefLineIdx = ContextSetCfg::addCtxSet #endif }); -const CtxSet ContextSetCfg::IPredMode[] = -{ - ContextSetCfg::addCtxSet - ({ +const CtxSet ContextSetCfg::IntraLumaMpmFlag = ContextSetCfg::addCtxSet +({ #if JVET_M0453_CABAC_ENGINE { 169,}, { 169,}, @@ -571,29 +569,19 @@ const CtxSet ContextSetCfg::IPredMode[] = { 154, }, { 156, }, #endif - }), - ContextSetCfg::addCtxSet - ({ -#if JVET_M0453_CABAC_ENGINE - { CNU, 137, 139, 140, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU,}, - { CNU, 138, 139, 169, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU,}, - { CNU, 154, 139, 154, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU,}, - { DWS, 5, 8, 9, DWS, DWS, DWS, DWS, DWS, DWS, DWS, DWS, }, -#else - { CNU, 152, 139, 154, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, }, - { CNU, 138, 139, 169, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, }, - { CNU, 109, 139, 154, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, }, -#endif - }), -}; +}); -const CtxSet ContextSetCfg::PdpcFlag = ContextSetCfg::addCtxSet +const CtxSet ContextSetCfg::IntraChromaPredMode = ContextSetCfg::addCtxSet ({ - { 107,}, - { 107,}, - { 139,}, #if JVET_M0453_CABAC_ENGINE - { DWS, } + { 137, 139, 140,}, + { 138, 139, 169,}, + { 154, 139, 154,}, + { 5, 8, 9,}, +#else + { 152, 139, 154,}, + { 138, 139, 169,}, + { 109, 139, 154,}, #endif }); @@ -719,16 +707,6 @@ const CtxSet ContextSetCfg::Mvd = ContextSetCfg::addCtxSet #endif }); -const CtxSet ContextSetCfg::TransSubdivFlag = ContextSetCfg::addCtxSet -({ - { 224, 167, 122, 122, 122}, - { 124, 138, 94, 94, 94}, - { 153, 138, 138, 138, 138}, -#if JVET_M0453_CABAC_ENGINE - { DWS, DWS, DWS, DWS, DWS, } -#endif -}); - const CtxSet ContextSetCfg::QtRootCbf = ContextSetCfg::addCtxSet ({ #if JVET_M0453_CABAC_ENGINE diff --git a/source/Lib/CommonLib/Contexts.h b/source/Lib/CommonLib/Contexts.h index 00dc798cecfbb1ba1cf5fe2822837b8240b06fd2..79bfc51f179f0abd347614993a7c6d096a82e796 100644 --- a/source/Lib/CommonLib/Contexts.h +++ b/source/Lib/CommonLib/Contexts.h @@ -258,8 +258,8 @@ public: static const CtxSet PartSize; static const CtxSet PredMode; static const CtxSet MultiRefLineIdx; - static const CtxSet IPredMode [2]; // [ ChannelType ] - static const CtxSet PdpcFlag; + static const CtxSet IntraLumaMpmFlag; + static const CtxSet IntraChromaPredMode; static const CtxSet DeltaQP; static const CtxSet InterDir; static const CtxSet RefPic; @@ -270,7 +270,6 @@ public: static const CtxSet AffineType; static const CtxSet AffMergeIdx; static const CtxSet Mvd; - static const CtxSet TransSubdivFlag; static const CtxSet QtRootCbf; static const CtxSet QtCbf [3]; // [ channel ] static const CtxSet SigCoeffGroup [4]; // [ ChannelType ] diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 7219e398b8d527b25189bbc0d1559f45ad263ba2..cdcaf87292bbcb0c3577ef73460b797e02a781b3 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -1355,7 +1355,9 @@ void CABACReader::intra_luma_pred_modes( CodingUnit &cu ) mpmFlag[0] = true; } else - mpmFlag[k] = m_BinDecoder.decodeBin( Ctx::IPredMode[0]() ); + { + mpmFlag[k] = m_BinDecoder.decodeBin(Ctx::IntraLumaMpmFlag()); + } } PredictionUnit *pu = cu.firstPU; @@ -1430,7 +1432,7 @@ bool CABACReader::intra_chroma_lmc_mode( PredictionUnit& pu ) { int lmModeList[10]; int maxSymbol = PU::getLMSymbolList(pu, lmModeList); - int symbol = unary_max_symbol( Ctx::IPredMode[1]( 2 ), Ctx::IPredMode[1]( 3 ), maxSymbol - 1 ); + int symbol = unary_max_symbol(Ctx::IntraChromaPredMode(1), Ctx::IntraChromaPredMode(2), maxSymbol - 1); if ( lmModeList[ symbol ] != -1 ) { pu.intraDir[1] = lmModeList[ symbol ]; @@ -1444,7 +1446,7 @@ void CABACReader::intra_chroma_pred_mode( PredictionUnit& pu ) RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET_SIZE2( STATS__CABAC_BITS__INTRA_DIR_ANG, pu.cu->blocks[pu.chType].lumaSize(), CHANNEL_TYPE_CHROMA ); { - if( m_BinDecoder.decodeBin( Ctx::IPredMode[1]( 1 ) ) == 0 ) + if (m_BinDecoder.decodeBin(Ctx::IntraChromaPredMode(0)) == 0) { pu.intraDir[1] = DM_CHROMA_IDX; return; diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index 090994ca8d6702ab505bcfc9aeddfc4521959c35..99cc5c6e625b69bed1d0632c597c2fdfdb23f09d 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -1099,7 +1099,9 @@ void CABACWriter::intra_luma_pred_modes( const CodingUnit& cu ) CHECK(mpm_idx >= numMPMs, "use of non-MPM"); } else - m_BinEncoder.encodeBin( mpm_idx < numMPMs, Ctx::IPredMode[0]() ); + { + m_BinEncoder.encodeBin(mpm_idx < numMPMs, Ctx::IntraLumaMpmFlag()); + } pu = pu->next; } @@ -1188,7 +1190,9 @@ void CABACWriter::intra_luma_pred_mode( const PredictionUnit& pu ) CHECK(mpm_idx >= numMPMs, "use of non-MPM"); } else - m_BinEncoder.encodeBin( mpm_idx < numMPMs, Ctx::IPredMode[0]() ); + { + m_BinEncoder.encodeBin(mpm_idx < numMPMs, Ctx::IntraLumaMpmFlag()); + } // mpm_idx / rem_intra_luma_pred_mode if( mpm_idx < numMPMs ) @@ -1258,20 +1262,20 @@ void CABACWriter::intra_chroma_lmc_mode( const PredictionUnit& pu ) } CHECK( symbol < 0, "invalid symbol found" ); - unary_max_symbol( symbol, Ctx::IPredMode[1]( 2 ), Ctx::IPredMode[1]( 3 ), maxSymbol - 1 ); + unary_max_symbol(symbol, Ctx::IntraChromaPredMode(1), Ctx::IntraChromaPredMode(2), maxSymbol - 1); } void CABACWriter::intra_chroma_pred_mode( const PredictionUnit& pu ) { const unsigned intraDir = pu.intraDir[1]; + const bool isDerivedMode = intraDir == DM_CHROMA_IDX; + + m_BinEncoder.encodeBin(isDerivedMode ? 0 : 1, Ctx::IntraChromaPredMode(0)); + + if (isDerivedMode) { - if( intraDir == DM_CHROMA_IDX ) - { - m_BinEncoder.encodeBin( 0, Ctx::IPredMode[1]( 1 ) ); - return; - } - m_BinEncoder.encodeBin( 1, Ctx::IPredMode[1]( 1 ) ); + return; } // LM chroma mode diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp index 189e272c801a55f8b028a680542e27ec2c98af29..e91b75652dd091471920fde6c09e8fe7f6586d86 100644 --- a/source/Lib/EncoderLib/IntraSearch.cpp +++ b/source/Lib/EncoderLib/IntraSearch.cpp @@ -294,7 +294,7 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner ) //===== loop over partitions ===== const TempCtx ctxStart ( m_CtxCache, m_CABACEstimator->getCtx() ); - const TempCtx ctxStartIntraMode ( m_CtxCache, SubCtx( Ctx::IPredMode[CHANNEL_TYPE_LUMA], m_CABACEstimator->getCtx() ) ); + const TempCtx ctxStartIntraMode(m_CtxCache, SubCtx(Ctx::IntraLumaMpmFlag, m_CABACEstimator->getCtx())); const TempCtx ctxStartMHIntraMode ( m_CtxCache, SubCtx( Ctx::MHIntraPredMode, m_CABACEstimator->getCtx() ) ); const TempCtx ctxStartMrlIdx ( m_CtxCache, SubCtx( Ctx::MultiRefLineIdx, m_CABACEstimator->getCtx() ) ); @@ -485,7 +485,7 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner ) uiSad += distParam.distFunc(distParam); // NB xFracModeBitsIntra will not affect the mode for chroma that may have already been pre-estimated. - m_CABACEstimator->getCtx() = SubCtx( Ctx::IPredMode[CHANNEL_TYPE_LUMA], ctxStartIntraMode ); + m_CABACEstimator->getCtx() = SubCtx(Ctx::IntraLumaMpmFlag, ctxStartIntraMode); m_CABACEstimator->getCtx() = SubCtx( Ctx::MHIntraPredMode, ctxStartMHIntraMode ); m_CABACEstimator->getCtx() = SubCtx( Ctx::MultiRefLineIdx, ctxStartMrlIdx ); @@ -539,7 +539,7 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner ) Distortion sad = distParam.distFunc(distParam); // NB xFracModeBitsIntra will not affect the mode for chroma that may have already been pre-estimated. - m_CABACEstimator->getCtx() = SubCtx( Ctx::IPredMode[CHANNEL_TYPE_LUMA], ctxStartIntraMode ); + m_CABACEstimator->getCtx() = SubCtx(Ctx::IntraLumaMpmFlag, ctxStartIntraMode); m_CABACEstimator->getCtx() = SubCtx( Ctx::MHIntraPredMode, ctxStartMHIntraMode ); m_CABACEstimator->getCtx() = SubCtx( Ctx::MultiRefLineIdx, ctxStartMrlIdx ); @@ -598,7 +598,7 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner ) Distortion sad = distParam.distFunc(distParam); // NB xFracModeBitsIntra will not affect the mode for chroma that may have already been pre-estimated. - m_CABACEstimator->getCtx() = SubCtx( Ctx::IPredMode[CHANNEL_TYPE_LUMA], ctxStartIntraMode ); + m_CABACEstimator->getCtx() = SubCtx(Ctx::IntraLumaMpmFlag, ctxStartIntraMode); m_CABACEstimator->getCtx() = SubCtx( Ctx::MHIntraPredMode, ctxStartMHIntraMode ); m_CABACEstimator->getCtx() = SubCtx( Ctx::MultiRefLineIdx, ctxStartMrlIdx ); @@ -797,7 +797,7 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner ) cs.interHad = 0; //===== reset context models ===== - m_CABACEstimator->getCtx() = SubCtx( Ctx::IPredMode[CHANNEL_TYPE_LUMA], ctxStartIntraMode ); + m_CABACEstimator->getCtx() = SubCtx(Ctx::IntraLumaMpmFlag, ctxStartIntraMode); m_CABACEstimator->getCtx() = SubCtx( Ctx::MHIntraPredMode, ctxStartMHIntraMode ); m_CABACEstimator->getCtx() = SubCtx( Ctx::MultiRefLineIdx, ctxStartMrlIdx );