diff --git a/source/Lib/CommonLib/ContextModelling.h b/source/Lib/CommonLib/ContextModelling.h index ba1335b4bac1eb3d09ad3ff929f6bff71dfcb79b..af67152c7a99756347c8692c9679de86f34f3946 100644 --- a/source/Lib/CommonLib/ContextModelling.h +++ b/source/Lib/CommonLib/ContextModelling.h @@ -129,11 +129,23 @@ public: } } #undef UPDATE + + +#if JVET_O0617_SIG_FLAG_CONTEXT_REDUCTION + int ctxOfs = std::min((sumAbs+1)>>1, 3) + ( diag < 2 ? 4 : 0 ); +#else int ctxOfs = std::min( sumAbs, 5 ) + ( diag < 2 ? 6 : 0 ); +#endif + if( m_chType == CHANNEL_TYPE_LUMA ) { +#if JVET_O0617_SIG_FLAG_CONTEXT_REDUCTION + ctxOfs += diag < 5 ? 4 : 0; +#else ctxOfs += diag < 5 ? 6 : 0; +#endif } + m_tmplCpDiag = diag; m_tmplCpSum1 = sumAbs - numPos; return m_sigFlagCtxSet[std::max( 0, state-1 )]( ctxOfs ); diff --git a/source/Lib/CommonLib/Contexts.cpp b/source/Lib/CommonLib/Contexts.cpp index d1d3c9cff6db554e56b8cd59c9f550aac8c7dea5..8903da8fae4c4653fdab9fbff1ff9bb953a7b9ad 100755 --- a/source/Lib/CommonLib/Contexts.cpp +++ b/source/Lib/CommonLib/Contexts.cpp @@ -538,6 +538,50 @@ const CtxSet ContextSetCfg::SigCoeffGroup[] = const CtxSet ContextSetCfg::SigFlag[] = { +#if JVET_O0617_SIG_FLAG_CONTEXT_REDUCTION + ContextSetCfg::addCtxSet + ({ + { 88, 166, 182, 169, 101, 167, 168, 155, 194, 213, 183, 156, }, + { 132, 152, 168, 140, 177, 182, 154, 155, 151, 213, 169, 156, }, + { 89, 138, 139, 140, 150, 139, 140, 141, 138, 185, 141, 157, }, + { 12, 9, 9, 10, 9, 9, 9, 9, 8, 8, 8, 10, }, + }), + ContextSetCfg::addCtxSet + ({ + { 27, 167, 168, 140, 180, 199, 214, 186, }, + { 133, 138, 139, 140, 181, 214, 200, 157, }, + { 134, 153, 154, 155, 167, 186, 186, 143, }, + { 9, 9, 9, 13, 5, 5, 8, 9, }, + }), + ContextSetCfg::addCtxSet + ({ + { 152, 156, 186, 202, 182, 249, 247, 207, 182, 223, 223, 223, }, + { 123, 142, 172, 218, 138, 250, 248, 223, 125, 223, 223, 223, }, + { 93, 142, 143, 175, 153, 223, 223, 238, 154, 223, 223, 223, }, + { 9, 12, 8, 8, 8, 8, 8, 5, 8, 0, 0, 0, }, + }), + ContextSetCfg::addCtxSet + ({ + { 182, 171, 143, 190, 183, 223, 223, 223, }, + { 168, 156, 216, 249, 169, 223, 223, 223, }, + { 138, 173, 157, 223, 170, 223, 223, 223, }, + { 8, 12, 8, 8, 4, 0, 0, 0, }, + }), + ContextSetCfg::addCtxSet + ({ + { 123, 175, 223, 223, 212, 223, 223, 223, 0, 223, 223, 223, }, + { 123, 223, 205, 223, 138, 223, 223, 223, 196, 223, 223, 223, }, + { 107, 206, 223, 223, 93, 223, 223, 238, 55, 223, 223, 223, }, + { 8, 8, 8, 8, 8, 0, 4, 4, 0, 0, 0, 0, }, + }), + ContextSetCfg::addCtxSet + ({ + { 167, 187, 249, 207, 181, 223, 223, 223, }, + { 167, 157, 191, 223, 152, 223, 223, 223, }, + { 152, 236, 223, 223, 123, 223, 223, 223, }, + { 8, 8, 8, 8, 4, 0, 0, 0, }, + }), +#else ContextSetCfg::addCtxSet ({ { 88, 166, 152, 182, 168, 154, 116, 167, 182, 168, 183, 155, 208, 213, 183, 183, 169, 185, }, @@ -580,6 +624,7 @@ const CtxSet ContextSetCfg::SigFlag[] = { 137, 250, 223, 237, 234, 223, 123, 223, 223, 223, 223, 223, }, { 8, 8, 1, 8, 8, 8, 4, 0, 0, 0, 0, 0, }, }) +#endif }; const CtxSet ContextSetCfg::ParFlag[] = diff --git a/source/Lib/CommonLib/DepQuant.cpp b/source/Lib/CommonLib/DepQuant.cpp index 152fe036d39b71d6d30e1c68b7ba0a52d2e9cd90..4cfa8c3ab779b97bfc2b5281e11d83087cb854a8 100644 --- a/source/Lib/CommonLib/DepQuant.cpp +++ b/source/Lib/CommonLib/DepQuant.cpp @@ -401,12 +401,20 @@ namespace DQIntern const int diag = m_scanId2BlkPos[nextScanIdx].x + m_scanId2BlkPos[nextScanIdx].y; if( m_chType == CHANNEL_TYPE_LUMA ) { +#if JVET_O0617_SIG_FLAG_CONTEXT_REDUCTION + scanInfo.sigCtxOffsetNext = ( diag < 2 ? 8 : diag < 5 ? 4 : 0 ); +#else scanInfo.sigCtxOffsetNext = ( diag < 2 ? 12 : diag < 5 ? 6 : 0 ); +#endif scanInfo.gtxCtxOffsetNext = ( diag < 1 ? 16 : diag < 3 ? 11 : diag < 10 ? 6 : 1 ); } else { +#if JVET_O0617_SIG_FLAG_CONTEXT_REDUCTION + scanInfo.sigCtxOffsetNext = ( diag < 2 ? 4 : 0 ); +#else scanInfo.sigCtxOffsetNext = ( diag < 2 ? 6 : 0 ); +#endif scanInfo.gtxCtxOffsetNext = ( diag < 1 ? 6 : 1 ); } scanInfo.nextInsidePos = nextScanIdx & m_sbbMask; @@ -452,7 +460,11 @@ namespace DQIntern static const unsigned sm_numCtxSetsSig = 3; static const unsigned sm_numCtxSetsGtx = 2; static const unsigned sm_maxNumSigSbbCtx = 2; +#if JVET_O0617_SIG_FLAG_CONTEXT_REDUCTION + static const unsigned sm_maxNumSigCtx = 12; +#else static const unsigned sm_maxNumSigCtx = 18; +#endif static const unsigned sm_maxNumGtxCtx = 21; private: @@ -570,7 +582,11 @@ namespace DQIntern { BinFracBits* bits = m_sigFracBits [ ctxSetId ]; const CtxSet& ctxSet = Ctx::SigFlag [ chType + 2*ctxSetId ]; +#if JVET_O0617_SIG_FLAG_CONTEXT_REDUCTION + const unsigned numCtx = ( chType == CHANNEL_TYPE_LUMA ? 12 : 8 ); +#else const unsigned numCtx = ( chType == CHANNEL_TYPE_LUMA ? 18 : 12 ); +#endif for( unsigned ctxId = 0; ctxId < numCtx; ctxId++ ) { bits[ ctxId ] = fracBitsAccess.getFracBitsArray( ctxSet( ctxId ) ); @@ -1163,7 +1179,11 @@ namespace DQIntern } #undef UPDATE TCoeff sumGt1 = sumAbs1 - sumNum; +#if JVET_O0617_SIG_FLAG_CONTEXT_REDUCTION + m_sigFracBits = m_sigFracBitsArray[scanInfo.sigCtxOffsetNext + std::min( (sumAbs1+1)>>1, 3 )]; +#else m_sigFracBits = m_sigFracBitsArray[scanInfo.sigCtxOffsetNext + (sumAbs1 < 5 ? sumAbs1 : 5)]; +#endif m_coeffFracBits = m_gtxFracBitsArray[scanInfo.gtxCtxOffsetNext + (sumGt1 < 4 ? sumGt1 : 4)]; TCoeff sumAbs = m_absLevelsAndCtxInit[8 + scanInfo.nextInsidePos] >> 8; @@ -1277,7 +1297,11 @@ namespace DQIntern TCoeff sumNum = tinit & 7; TCoeff sumAbs1 = ( tinit >> 3 ) & 31; TCoeff sumGt1 = sumAbs1 - sumNum; +#if JVET_O0617_SIG_FLAG_CONTEXT_REDUCTION + m_sigFracBits = m_sigFracBitsArray[ scanInfo.sigCtxOffsetNext + std::min( (sumAbs1+1)>>1, 3 ) ]; +#else m_sigFracBits = m_sigFracBitsArray[ scanInfo.sigCtxOffsetNext + ( sumAbs1 < 5 ? sumAbs1 : 5 ) ]; +#endif m_coeffFracBits = m_gtxFracBitsArray[ scanInfo.gtxCtxOffsetNext + ( sumGt1 < 4 ? sumGt1 : 4 ) ]; } } diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 5fe6b457a42dfa530651fe8bc8130ff5d0cebc51..4cc261e7b2de5c4d4e15e50a5ef40db0646e8ca5 100755 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -52,6 +52,8 @@ #define JVET_O0213_RESTRICT_LFNST_TO_MAX_TB_SIZE 1 // JVET-O0213: Block size restriction of LFNST to maximum transform size +#define JVET_O0617_SIG_FLAG_CONTEXT_REDUCTION 1 // JVET-O0617: Significant flag context reduction + #define JVET_O0244_DELTA_POC 1 // JVET-O0244: weighted prediction in SPS and delta POC #define JVET_O1153_INTRA_CHROMAMODE_CODING 1 //JVET-O1153: simplified intra chromamode coding