Commit 43e22576 authored by Yin Zhao's avatar Yin Zhao

JVET-L0361: Context modeling of CU split modes

parent f0b08443
......@@ -198,7 +198,9 @@ unsigned DeriveCtx::CtxCUsplit( const CodingStructure& cs, Partitioner& partitio
#endif
ctxId += ( cuAbove && cuAbove->qtDepth > partitioner.currQtDepth ) ? 1 : 0;
#if JVET_L0361_SPLIT_CTX
ctxId += partitioner.currQtDepth < 2 ? 0 : 3;
#else
if( cs.sps->getSpsNext().getUseLargeCTU() )
{
unsigned minDepth = 0;
......@@ -213,6 +215,7 @@ unsigned DeriveCtx::CtxCUsplit( const CodingStructure& cs, Partitioner& partitio
ctxId = 4;
}
}
#endif
return ctxId;
}
......@@ -319,10 +322,39 @@ unsigned DeriveCtx::CtxBTsplit(const CodingStructure& cs, Partitioner& partition
#endif
{
#if JVET_L0361_SPLIT_CTX
unsigned widthCurr = partitioner.currArea().lwidth();
unsigned heightCurr = partitioner.currArea().lheight();
if( cuLeft )
{
unsigned heightLeft = cuLeft->Y().height;
ctx += ( heightLeft < heightCurr ? 1 : 0 );
}
if( cuAbove )
{
unsigned widthAbove = cuAbove->Y().width;
ctx += ( widthAbove < widthCurr ? 1 : 0 );
}
if( partitioner.chType == CHANNEL_TYPE_CHROMA )
{
ctx += 9;
}
else
{
int maxBTSize = cs.pcv->getMaxBtSize( *cs.slice, partitioner.chType );
int th1 = ( maxBTSize == 128 ) ? 128 : ( ( maxBTSize == 64 ) ? 64 : 64 );
int th2 = ( maxBTSize == 128 ) ? 1024 : ( ( maxBTSize == 64 ) ? 512 : 256 );
unsigned int sizeCurr = widthCurr * heightCurr;
ctx += sizeCurr > th2 ? 0 : ( sizeCurr > th1 ? 3 : 6 );
}
#else
const unsigned currDepth = partitioner.currQtDepth * 2 + partitioner.currBtDepth;
if( cuLeft ) ctx += ( ( 2 * cuLeft->qtDepth + cuLeft->btDepth ) > currDepth ? 1 : 0 );
if( cuAbove ) ctx += ( ( 2 * cuAbove->qtDepth + cuAbove->btDepth ) > currDepth ? 1 : 0 );
#endif
}
return ctx;
}
......
......@@ -262,16 +262,29 @@ std::vector<std::vector<uint8_t>> ContextSetCfg::sm_InitTables( NUMBER_OF_SLICE_
const CtxSet ContextSetCfg::SplitFlag = ContextSetCfg::addCtxSet
({
#if JVET_L0361_SPLIT_CTX
{ 107, 139, 126, 107, 139, 126, },
{ 107, 139, 126, 107, 139, 126, },
{ 139, 141, 157, 139, 141, 157, },
#else
{ 107, 139, 126, 255, 0,},
{ 107, 139, 126, 255, 0,},
{ 139, 141, 157, 255, 0,},
#endif
});
const CtxSet ContextSetCfg::BTSplitFlag = ContextSetCfg::addCtxSet
({
#if JVET_L0361_SPLIT_CTX
// |-------- 1st bin, 9 ctx for luma + 3 ctx for chroma------| |--2nd bin--| |3rd bin|
{ 107, 139, 126, 107, 139, 126, 107, 139, 126, 107, 139, 126, 154, 154, 154, 154,},
{ 107, 139, 126, 107, 139, 126, 107, 139, 126, 107, 139, 126, 154, 154, 154, 154,},
{ 139, 141, 157, 139, 141, 157, 139, 141, 157, 139, 141, 157, 154, 154, 154, 154,},
#else
{ 107, 139, 126, 154, 154, 154, 154, 154, 154, 154, 154, 154,},
{ 107, 139, 126, 154, 154, 154, 154, 154, 154, 154, 154, 154,},
{ 139, 141, 157, 154, 154, 154, 154, 154, 154, 154, 154, 154,},
#endif
});
const CtxSet ContextSetCfg::SkipFlag = ContextSetCfg::addCtxSet
......
......@@ -60,6 +60,8 @@
#define JVET_L0194_ONE_CTX_FOR_MRG_IDX 1 // one context for full-block Merge index
#define JVET_L0361_SPLIT_CTX 1 // context for cu-split-related flags
#define JVET_L0274 1
#define JVET_L0274_ENCODER_SPEED_UP ( 1 && JVET_L0274 ) // encoder speed-up by pre-calculating position dependent parameters
......
......@@ -622,10 +622,17 @@ PartSplit CABACReader::split_cu_mode_mt( CodingStructure& cs, Partitioner &parti
unsigned btSCtxId = width == height ? 0 : ( width > height ? 1 : 2 );
dt.setCtxId( DTT_SPLIT_DO_SPLIT_DECISION, Ctx::BTSplitFlag( ctxIdBT ) ); // 0- 2
#if JVET_L0361_SPLIT_CTX
dt.setCtxId( DTT_SPLIT_HV_DECISION, Ctx::BTSplitFlag( 12 + btSCtxId ) );//12-14
dt.setCtxId( DTT_SPLIT_H_IS_BT_12_DECISION, Ctx::BTSplitFlag( 15 ) );
dt.setCtxId( DTT_SPLIT_V_IS_BT_12_DECISION, Ctx::BTSplitFlag( 15 ) );
#else
dt.setCtxId( DTT_SPLIT_HV_DECISION, Ctx::BTSplitFlag( 3 + btSCtxId ) ); // 3- 5
dt.setCtxId( DTT_SPLIT_H_IS_BT_12_DECISION, Ctx::BTSplitFlag( 6 + btSCtxId ) ); // 6- 8
dt.setCtxId( DTT_SPLIT_V_IS_BT_12_DECISION, Ctx::BTSplitFlag( 9 + btSCtxId ) ); // 9-11
#endif
unsigned id = decode_sparse_dt( dt );
......
......@@ -565,10 +565,17 @@ void CABACWriter::split_cu_mode_mt(const PartSplit split, const CodingStructure&
unsigned btSCtxId = width == height ? 0 : ( width > height ? 1 : 2 );
dt.setCtxId( DTT_SPLIT_DO_SPLIT_DECISION, Ctx::BTSplitFlag( ctxIdBT ) );
#if JVET_L0361_SPLIT_CTX
dt.setCtxId( DTT_SPLIT_HV_DECISION, Ctx::BTSplitFlag( 12 + btSCtxId ) );
dt.setCtxId( DTT_SPLIT_H_IS_BT_12_DECISION, Ctx::BTSplitFlag( 15 ) );
dt.setCtxId( DTT_SPLIT_V_IS_BT_12_DECISION, Ctx::BTSplitFlag( 15 ) );
#else
dt.setCtxId( DTT_SPLIT_HV_DECISION, Ctx::BTSplitFlag( 3 + btSCtxId ) );
dt.setCtxId( DTT_SPLIT_H_IS_BT_12_DECISION, Ctx::BTSplitFlag( 6 + btSCtxId ) );
dt.setCtxId( DTT_SPLIT_V_IS_BT_12_DECISION, Ctx::BTSplitFlag( 9 + btSCtxId ) );
#endif
encode_sparse_dt( dt, split == CU_DONT_SPLIT ? ( unsigned ) DTT_SPLIT_NO_SPLIT : ( unsigned ) split );
......
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