diff --git a/source/Lib/CommonLib/CodingStructure.cpp b/source/Lib/CommonLib/CodingStructure.cpp index a20ca1ca3224ce4d192c0e5b1091a4e84fdda73d..2be9ebd393e269de4037f91da42a831afff4b868 100644 --- a/source/Lib/CommonLib/CodingStructure.cpp +++ b/source/Lib/CommonLib/CodingStructure.cpp @@ -190,31 +190,28 @@ void CodingStructure::setDecomp(const UnitArea &_area, const bool _isCoded /*= t const int CodingStructure::signalModeCons( const PartSplit split, Partitioner &partitioner, const ModeType modeTypeParent ) const { if( CS::isDualITree( *this ) || modeTypeParent != MODE_TYPE_ALL ) - return 0; + return LDT_MODE_TYPE_INHERIT; int width = partitioner.currArea().lwidth(); int height = partitioner.currArea().lheight(); - //0: not constrain - //1: constrain with intra, no need signaling the flag - //2: constrain with intra or inter, need signaling the flag if( width * height == 64 ) { if( split == CU_QUAD_SPLIT || split == CU_TRIH_SPLIT || split == CU_TRIV_SPLIT ) // qt or tt - return slice->isIntra() ? 1 : 1; //only intra mode allowed for child nodes (have 4x4) + return LDT_MODE_TYPE_INFER; //only intra mode allowed for child nodes (have 4x4) else // bt - return slice->isIntra() ? 1 : 2; + return slice->isIntra() ? LDT_MODE_TYPE_INFER : LDT_MODE_TYPE_SIGNAL; } else if( width * height == 128 ) { - if( split == CU_TRIH_SPLIT || split == CU_TRIV_SPLIT ) - return slice->isIntra() ? 1 : 2; - else - return 0; + if( split == CU_TRIH_SPLIT || split == CU_TRIV_SPLIT ) // tt + return slice->isIntra() ? LDT_MODE_TYPE_INFER : LDT_MODE_TYPE_SIGNAL; + else // bt + return LDT_MODE_TYPE_INHERIT; } else { - return 0; + return LDT_MODE_TYPE_INHERIT; } } diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h index af6f13e9c12f58c2f6d383aa0c6a8fcf03f458b3..78cde6f86184442c1c6a8bebfcde967a90fdc735 100644 --- a/source/Lib/CommonLib/CommonDef.h +++ b/source/Lib/CommonLib/CommonDef.h @@ -454,6 +454,9 @@ static const int SBT_NUM_RDO = 2; ///< maxi #if JVET_O0050_LOCAL_DUAL_TREE static const int NUM_INTER_CU_INFO_SAVE = 8; ///< maximum number of inter cu information saved for fast algorithm +static const int LDT_MODE_TYPE_INHERIT = 0; ///< No need to signal mode_constraint_flag, and the modeType of the region is inherited from its parent node +static const int LDT_MODE_TYPE_INFER = 1; ///< No need to signal mode_constraint_flag, and the modeType of the region is inferred as MODE_TYPE_INTRA +static const int LDT_MODE_TYPE_SIGNAL = 2; ///< Need to signal mode_constraint_flag, and the modeType of the region is determined by the flag #endif static const int IBC_MAX_CAND_SIZE = 16; // max block size for ibc search diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 6362f55b0d398ab07c3bdabd0e11d1eedafdce1a..606f494e699e2e988ef23c45641757d3cd0264ca 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -676,14 +676,14 @@ bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU ModeType CABACReader::mode_constraint( CodingStructure& cs, Partitioner &partitioner, PartSplit splitMode ) { int val = cs.signalModeCons( splitMode, partitioner, partitioner.modeType ); - if( val == 2 ) + if( val == LDT_MODE_TYPE_SIGNAL ) { int ctxIdx = DeriveCtx::CtxModeConsFlag( cs, partitioner ); bool flag = m_BinDecoder.decodeBin( Ctx::ModeConsFlag( ctxIdx ) ); DTRACE( g_trace_ctx, D_SYNTAX, "mode_cons_flag() flag=%d\n", flag ); return flag ? MODE_TYPE_INTRA : MODE_TYPE_INTER; } - else if( val == 1 ) + else if( val == LDT_MODE_TYPE_INFER ) { return MODE_TYPE_INTRA; } diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index 102871b1b10212f9a121060687f201a528130bb3..b7129374547762af632499fee0317c2420191366 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -534,7 +534,7 @@ void CABACWriter::mode_constraint( const PartSplit split, const CodingStructure& { CHECK( split == CU_DONT_SPLIT, "splitMode shall not be no split" ); int val = cs.signalModeCons( split, partitioner, partitioner.modeType ); - if( val == 2 ) + if( val == LDT_MODE_TYPE_SIGNAL ) { CHECK( modeType == MODE_TYPE_ALL, "shall not be no constraint case" ); bool flag = modeType == MODE_TYPE_INTRA; @@ -542,7 +542,7 @@ void CABACWriter::mode_constraint( const PartSplit split, const CodingStructure& m_BinEncoder.encodeBin( flag, Ctx::ModeConsFlag( ctxIdx ) ); DTRACE( g_trace_ctx, D_SYNTAX, "mode_cons_flag() flag=%d\n", flag ); } - else if( val == 1 ) + else if( val == LDT_MODE_TYPE_INFER ) { assert( modeType == MODE_TYPE_INTRA ); } diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index a923fa31c8eb99d1bc468ccb95ffcd01bed8715b..e141527aaabecaee5a7941334c9dcd5d55903a5b 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -818,22 +818,22 @@ void EncCu::xCompressCU( CodingStructure *&tempCS, CodingStructure *&bestCS, Par #if JVET_O0050_LOCAL_DUAL_TREE assert( partitioner.modeType == tempCS->modeType ); int signalModeConsVal = tempCS->signalModeCons( getPartSplit( currTestMode ), partitioner, modeTypeParent ); - int num_round_rdo = signalModeConsVal == 2 ? 2 : 1; + int num_round_rdo = signalModeConsVal == LDT_MODE_TYPE_SIGNAL ? 2 : 1; bool skipInterPass = false; for( int i = 0; i < num_round_rdo; i++ ) { //change cons modes - if( signalModeConsVal == 2 ) + if( signalModeConsVal == LDT_MODE_TYPE_SIGNAL ) { CHECK( num_round_rdo != 2, "num_round_rdo shall be 2 - [2]" ); tempCS->modeType = partitioner.modeType = (i == 0) ? MODE_TYPE_INTER : MODE_TYPE_INTRA; } - else if( signalModeConsVal == 1 ) + else if( signalModeConsVal == LDT_MODE_TYPE_INFER ) { CHECK( num_round_rdo != 1, "num_round_rdo shall be 1 - [1]" ); tempCS->modeType = partitioner.modeType = MODE_TYPE_INTRA; } - else if( signalModeConsVal == 0 ) + else if( signalModeConsVal == LDT_MODE_TYPE_INHERIT ) { CHECK( num_round_rdo != 1, "num_round_rdo shall be 1 - [0]" ); tempCS->modeType = partitioner.modeType = modeTypeParent;