diff --git a/source/Lib/CommonLib/Contexts.cpp b/source/Lib/CommonLib/Contexts.cpp index 944154732650e667364559982a5936bb09fecccd..16f4d962bc9c667b96c9f0db7b457a535fe9e0d0 100644 --- a/source/Lib/CommonLib/Contexts.cpp +++ b/source/Lib/CommonLib/Contexts.cpp @@ -696,10 +696,17 @@ const CtxSet ContextSetCfg::TransquantBypassFlag = ContextSetCfg::addCtxSet #if JVET_N0193_LFNST const CtxSet ContextSetCfg::LFNSTIdx = ContextSetCfg::addCtxSet ( { +#if JVET_N0105_LFNST_CTX_MODELLING + { CNU, CNU, }, + { CNU, CNU, }, + { CNU, CNU, }, + { DWS, DWS, }, +#else { CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, }, { CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, }, { CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, }, { DWS, DWS, DWS, DWS, DWS, DWS, DWS, DWS, }, +#endif } ); #endif diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 59ab96c1a929595a818ceb3136e1f9bdf393e93d..b78762c11c6f13cbbb51ef9b6a2d9943627d08a4 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -50,6 +50,8 @@ #include <assert.h> #include <cassert> +#define JVET_N0105_LFNST_CTX_MODELLING 1 // LFNST index signalled without intra mode dependency and with on ctx-coded bin + #define JVET_N0193_LFNST 1 //Low Frequency Non-Separable Transform (LFNST), previously, Reduced Secondary Transform (RST) #define JVET_N0217_MATRIX_INTRAPRED 1 // matrix-based intra prediction (MIP) diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index b34a0521b772a80c5113231a94457232875a8456..c005156e92e071ecf3c383efeacb2bbe3917e554 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -2902,6 +2902,7 @@ void CABACReader::residual_lfnst_mode( CodingUnit& cu ) return; } +#if !JVET_N0105_LFNST_CTX_MODELLING uint32_t ctxOff = 0; int intraMode = cu.firstPU->intraDir[ cu.chType ]; @@ -2914,14 +2915,23 @@ void CABACReader::residual_lfnst_mode( CodingUnit& cu ) intraMode = g_chroma422IntraAngleMappingTable[ intraMode ]; } ctxOff = PU::isLMCMode( intraMode ) || intraMode <= DC_IDX; +#endif unsigned cctx = 0; if( cu.firstTU->mtsIdx < 2 && CS::isDualITree( *cu.cs ) ) cctx++; +#if JVET_N0105_LFNST_CTX_MODELLING + uint32_t idxLFNST = m_BinDecoder.decodeBin( Ctx::LFNSTIdx( cctx ) ); +#else uint32_t idxLFNST = m_BinDecoder.decodeBin( Ctx::LFNSTIdx( ctxOff + 4 * cctx ) ); +#endif if( idxLFNST ) { +#if JVET_N0105_LFNST_CTX_MODELLING + idxLFNST += m_BinDecoder.decodeBinEP(); +#else idxLFNST += m_BinDecoder.decodeBin( Ctx::LFNSTIdx( 2 + ctxOff + 4 * cctx ) ); +#endif } cu.lfnstIdx = idxLFNST; @@ -3558,4 +3568,4 @@ void CABACReader::mip_pred_mode( PredictionUnit &pu ) DTRACE( g_trace_ctx, D_SYNTAX, "mip_pred_mode() pos=(%d,%d) mode=%d\n", pu.lumaPos().x, pu.lumaPos().y, pu.intraDir[CHANNEL_TYPE_LUMA] ); } -#endif \ No newline at end of file +#endif diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index e92a739ba27d148ad2a5cd114d582a44fee265d4..0685777bcdbc0287ddaea5ade08e43ee3d53bc9a 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -2810,6 +2810,7 @@ void CABACWriter::residual_lfnst_mode( const CodingUnit& cu, CUCtx& cuCtx ) return; } +#if !JVET_N0105_LFNST_CTX_MODELLING uint32_t ctxOff = 0; int intraMode = cu.firstPU->intraDir[ cu.chType ]; @@ -2822,17 +2823,26 @@ void CABACWriter::residual_lfnst_mode( const CodingUnit& cu, CUCtx& cuCtx ) intraMode = g_chroma422IntraAngleMappingTable[ intraMode ]; } ctxOff = PU::isLMCMode( intraMode ) || intraMode <= DC_IDX; +#endif unsigned cctx = 0; if( cu.firstTU->mtsIdx < 2 && CS::isDualITree( *cu.cs ) ) cctx++; const uint32_t idxLFNST = cu.lfnstIdx; assert( idxLFNST < 3 ); +#if JVET_N0105_LFNST_CTX_MODELLING + m_BinEncoder.encodeBin( idxLFNST ? 1 : 0, Ctx::LFNSTIdx( cctx ) ); +#else m_BinEncoder.encodeBin( idxLFNST ? 1 : 0, Ctx::LFNSTIdx( ctxOff + 4 * cctx ) ); +#endif if( idxLFNST ) { +#if JVET_N0105_LFNST_CTX_MODELLING + m_BinEncoder.encodeBinEP( ( idxLFNST - 1 ) ? 1 : 0 ); +#else m_BinEncoder.encodeBin( ( idxLFNST - 1 ) ? 1 : 0, Ctx::LFNSTIdx( 2 + ctxOff + 4 * cctx ) ); +#endif } DTRACE( g_trace_ctx, D_SYNTAX, "residual_lfnst_mode() etype=%d pos=(%d,%d) mode=%d\n", COMPONENT_Y, cu.lx(), cu.ly(), ( int ) cu.lfnstIdx );