Commit 24b520d5 authored by Xiang Li's avatar Xiang Li
Browse files

Merge branch 'JVET-O0193/O0375' into 'master'

JVET-O0193/O0375: remove transform depth in cbf ctx

See merge request jvet/VVCSoftware_VTM!724
parents eab9a095 f7e87bce
......@@ -231,7 +231,11 @@ void DeriveCtx::CtxSplit( const CodingStructure& cs, Partitioner& partitioner, u
ctxVerBt = ( partitioner.currMtDepth <= 1 ? 3 : 2 );
}
#if JVET_O0193_REMOVE_TR_DEPTH_IN_CBF_CTX
unsigned DeriveCtx::CtxQtCbf( const ComponentID compID, const bool prevCbCbf, const int ispIdx )
#else
unsigned DeriveCtx::CtxQtCbf( const ComponentID compID, const unsigned trDepth, const bool prevCbCbf, const int ispIdx )
#endif
{
if( ispIdx && isLuma( compID ) )
{
......@@ -241,6 +245,9 @@ unsigned DeriveCtx::CtxQtCbf( const ComponentID compID, const unsigned trDepth,
{
return ( prevCbCbf ? 1 : 0 );
}
#if JVET_O0193_REMOVE_TR_DEPTH_IN_CBF_CTX
return 0;
#else
if( isChroma( compID ) )
{
return ( trDepth == 0 ? 0 : 1 );
......@@ -249,6 +256,7 @@ unsigned DeriveCtx::CtxQtCbf( const ComponentID compID, const unsigned trDepth,
{
return ( trDepth == 0 ? 1 : 0 );
}
#endif
}
unsigned DeriveCtx::CtxInterDir( const PredictionUnit& pu )
......
......@@ -366,7 +366,11 @@ public:
namespace DeriveCtx
{
void CtxSplit ( const CodingStructure& cs, Partitioner& partitioner, unsigned& ctxSpl, unsigned& ctxQt, unsigned& ctxHv, unsigned& ctxHorBt, unsigned& ctxVerBt, bool* canSplit = nullptr );
#if JVET_O0193_REMOVE_TR_DEPTH_IN_CBF_CTX
unsigned CtxQtCbf ( const ComponentID compID, const bool prevCbCbf = false, const int ispIdx = 0 );
#else
unsigned CtxQtCbf ( const ComponentID compID, const unsigned trDepth, const bool prevCbCbf = false, const int ispIdx = 0 );
#endif
unsigned CtxInterDir ( const PredictionUnit& pu );
unsigned CtxSkipFlag ( const CodingUnit& cu );
unsigned CtxAffineFlag( const CodingUnit& cu );
......
......@@ -446,17 +446,31 @@ const CtxSet ContextSetCfg::QtCbf[] =
{
ContextSetCfg::addCtxSet
({
#if JVET_O0193_REMOVE_TR_DEPTH_IN_CBF_CTX
{ 127, 111, 124, 140 },
{ 127, 79, 139, 126 },
{ 126, 138, 124, 111 },
{ 5, 1, 8, 8 },
#else
{ 142, 127, 124, 140, 111, },
{ 143, 127, 139, 126, 79, },
{ CNU, 126, 124, 111, 138, },
{ 1, 5, 8, 8, 1, },
#endif
}),
ContextSetCfg::addCtxSet
({
#if JVET_O0193_REMOVE_TR_DEPTH_IN_CBF_CTX
{ 163, },
{ 150, },
{ 124, },
{ 5, },
#else
{ 163, 135, },
{ 150, 121, },
{ 124, CNU, },
{ 5, 0, },
#endif
}),
ContextSetCfg::addCtxSet
({
......
......@@ -510,11 +510,19 @@ namespace DQIntern
{
prevLumaCbf = TU::getPrevTuCbfAtDepth(tu, compID, tu.depth);
}
#if JVET_O0193_REMOVE_TR_DEPTH_IN_CBF_CTX
bits = fracBitsAccess.getFracBitsArray(Ctx::QtCbf[compID](DeriveCtx::CtxQtCbf(compID, prevLumaCbf, true)));
#else
bits = fracBitsAccess.getFracBitsArray(Ctx::QtCbf[compID](DeriveCtx::CtxQtCbf(compID, tu.depth, prevLumaCbf, true)));
#endif
}
else
{
#if JVET_O0193_REMOVE_TR_DEPTH_IN_CBF_CTX
bits = fracBitsAccess.getFracBitsArray(Ctx::QtCbf[compID](DeriveCtx::CtxQtCbf(compID, tu.cbf[COMPONENT_Cb])));
#else
bits = fracBitsAccess.getFracBitsArray(Ctx::QtCbf[compID](DeriveCtx::CtxQtCbf(compID, tu.depth, tu.cbf[COMPONENT_Cb])));
#endif
}
cbfDeltaBits = lastCbfIsInferred ? 0 : int32_t(bits.intBits[1]) - int32_t(bits.intBits[0]);
}
......
......@@ -959,7 +959,11 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID,
previousCbf = TU::getPrevTuCbfAtDepth(tu, compID, tu.depth);
}
}
#if JVET_O0193_REMOVE_TR_DEPTH_IN_CBF_CTX
BinFracBits fracBitsQtCbf = fracBits.getFracBitsArray( Ctx::QtCbf[compID]( DeriveCtx::CtxQtCbf( rect.compID, previousCbf, useIntraSubPartitions ) ) );
#else
BinFracBits fracBitsQtCbf = fracBits.getFracBitsArray( Ctx::QtCbf[compID]( DeriveCtx::CtxQtCbf( rect.compID, tu.depth, previousCbf, useIntraSubPartitions ) ) );
#endif
if( !lastCbfIsInferred )
{
......
......@@ -141,6 +141,7 @@
#define JVET_O0596_CBF_SIG_ALIGN_TO_SPEC 1 // JVET-O0596 align cbf signaling with specification
#define JVET_O0193_REMOVE_TR_DEPTH_IN_CBF_CTX 1 // JVET-O0193/JVET-O0375: remove transform depth in cbf context modeling
#define FIX_DB_MAX_TRANSFORM_SIZE 1
......
......@@ -2305,7 +2305,11 @@ void CABACReader::transform_tree( CodingStructure &cs, Partitioner &partitioner,
bool CABACReader::cbf_comp( CodingStructure& cs, const CompArea& area, unsigned depth, const bool prevCbf, const bool useISP )
{
#if JVET_O0193_REMOVE_TR_DEPTH_IN_CBF_CTX
const unsigned ctxId = DeriveCtx::CtxQtCbf( area.compID, prevCbf, useISP && isLuma( area.compID ) );
#else
const unsigned ctxId = DeriveCtx::CtxQtCbf( area.compID, depth, prevCbf, useISP && isLuma( area.compID ) );
#endif
const CtxSet& ctxSet = Ctx::QtCbf[ area.compID ];
RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET_SIZE2(STATS__CABAC_BITS__QT_CBF, area.size(), area.compID);
......@@ -2313,7 +2317,11 @@ bool CABACReader::cbf_comp( CodingStructure& cs, const CompArea& area, unsigned
unsigned cbf = 0;
if( area.compID == COMPONENT_Y && cs.getCU( area.pos(), ChannelType( area.compID ) )->bdpcmMode )
{
#if JVET_O0193_REMOVE_TR_DEPTH_IN_CBF_CTX
cbf = m_BinDecoder.decodeBin( ctxSet( 1 ) );
#else
cbf = m_BinDecoder.decodeBin( ctxSet( 4 ) );
#endif
}
else
{
......
......@@ -2175,11 +2175,19 @@ void CABACWriter::transform_tree( const CodingStructure& cs, Partitioner& partit
void CABACWriter::cbf_comp( const CodingStructure& cs, bool cbf, const CompArea& area, unsigned depth, const bool prevCbCbf, const bool useISP )
{
#if JVET_O0193_REMOVE_TR_DEPTH_IN_CBF_CTX
const unsigned ctxId = DeriveCtx::CtxQtCbf( area.compID, prevCbCbf, useISP && isLuma(area.compID) );
#else
const unsigned ctxId = DeriveCtx::CtxQtCbf( area.compID, depth, prevCbCbf, useISP && isLuma(area.compID) );
#endif
const CtxSet& ctxSet = Ctx::QtCbf[ area.compID ];
if( area.compID == COMPONENT_Y && cs.getCU( area.pos(), ChannelType( area.compID ) )->bdpcmMode )
{
#if JVET_O0193_REMOVE_TR_DEPTH_IN_CBF_CTX
m_BinEncoder.encodeBin( cbf, ctxSet( 1 ) );
#else
m_BinEncoder.encodeBin( cbf, ctxSet( 4 ) );
#endif
}
else
{
......
Supports Markdown
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