Commit 1fc9b8ac authored by Chris Rosewarne's avatar Chris Rosewarne

JVET-N0105: LFNST context modelling

- Removed lfnst_mode context modelling dependency on intra-prediction mode.
- Second bin of lfnst_mode is bypass-coded rather than context-coded.
parent 942a475a
......@@ -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
......
......@@ -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)
......
......@@ -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
......@@ -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 );
......
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