diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index 4993b03c4565a92fd2bd013b60e7085d307483d8..5d3662eb0aac419447b84e4900f88d5189f48c88 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -2528,6 +2528,9 @@ bool EncAppCfg::xCheckParameter() #if MAX_TB_SIZE_SIGNALLING xConfirmPara( m_log2MaxTbSize > 6, "Log2MaxTbSize must be 6 or smaller." ); +#endif +#if JVET_O0545_MAX_TB_SIGNALLING + xConfirmPara( m_log2MaxTbSize < 5, "Log2MaxTbSize must be 5 or greater." ); #endif xConfirmPara( m_maxNumMergeCand < 1, "MaxNumMergeCand must be 1 or greater."); xConfirmPara( m_maxNumMergeCand > MRG_MAX_NUM_CANDS, "MaxNumMergeCand must be no more than MRG_MAX_NUM_CANDS." ); diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h index b56ee0e5c1b6261b9589e27e34e0c7eec282fa3b..0cca7e23e981365b391e04af83d6cfa09bf63079 100644 --- a/source/Lib/CommonLib/CommonDef.h +++ b/source/Lib/CommonLib/CommonDef.h @@ -314,7 +314,12 @@ static const int MAX_CU_SIZE = 1<<MAX_CU_DEPTH; static const int MIN_CU_LOG2 = 2; static const int MIN_PU_SIZE = 4; static const int MAX_NUM_PARTS_IN_CTU = ( ( MAX_CU_SIZE * MAX_CU_SIZE ) >> ( MIN_CU_LOG2 << 1 ) ); +#if JVET_O0545_MAX_TB_SIGNALLING +static const int MAX_NUM_TUS = 16; +static const int MAX_LOG2_DIFF_CU_TR_SIZE = 3; +#else static const int MAX_LOG2_DIFF_CU_TR_SIZE = 2; +#endif static const int MAX_CU_TILING_PARTITIONS = 1 << ( MAX_LOG2_DIFF_CU_TR_SIZE << 1 ); static const int JVET_C0024_ZERO_OUT_TH = 32; diff --git a/source/Lib/CommonLib/IntraPrediction.cpp b/source/Lib/CommonLib/IntraPrediction.cpp index ca75f5db4a375107719f85c29c5502a62c16d6f7..f9a5914b31de0bad7d500b62c113deda9bfc7b10 100644 --- a/source/Lib/CommonLib/IntraPrediction.cpp +++ b/source/Lib/CommonLib/IntraPrediction.cpp @@ -1997,7 +1997,11 @@ void IntraPrediction::xGetLMParameters(const PredictionUnit &pu, const Component void IntraPrediction::initIntraMip( const PredictionUnit &pu ) { +#if JVET_O0545_MAX_TB_SIGNALLING + CHECK( pu.lwidth() > pu.cs->sps->getMaxTbSize() || pu.lheight() > pu.cs->sps->getMaxTbSize(), "Error: block size not supported for MIP" ); +#else CHECK( pu.lwidth() > MIP_MAX_WIDTH || pu.lheight() > MIP_MAX_HEIGHT, "Error: block size not supported for MIP" ); +#endif // derive above and left availability AvailableInfo availInfo = PU::getAvailableInfoLuma(pu); @@ -2009,7 +2013,11 @@ void IntraPrediction::initIntraMip( const PredictionUnit &pu ) void IntraPrediction::predIntraMip( const ComponentID compId, PelBuf &piPred, const PredictionUnit &pu ) { CHECK( compId != COMPONENT_Y, "Error: chroma not supported" ); +#if JVET_O0545_MAX_TB_SIGNALLING + CHECK( pu.lwidth() > pu.cs->sps->getMaxTbSize() || pu.lheight() > pu.cs->sps->getMaxTbSize(), "Error: block size not supported for MIP" ); +#else CHECK( pu.lwidth() > MIP_MAX_WIDTH || pu.lheight() > MIP_MAX_HEIGHT, "Error: block size not supported for MIP" ); +#endif CHECK( pu.lwidth() != (1 << g_aucLog2[pu.lwidth()]) || pu.lheight() != (1 << g_aucLog2[pu.lheight()]), "Error: expecting blocks of size 2^M x 2^N" ); // generate mode-specific prediction diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 961e55e129d6620b74032150f1db2aeddc7e94fc..5fe6b457a42dfa530651fe8bc8130ff5d0cebc51 100755 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -138,6 +138,8 @@ #define JVET_O0669_REMOVE_ALF_COEFF_PRED 1 // JVET-O0425/O0427/O0669: remove prediction in ALF coefficients coding +#define JVET_O0545_MAX_TB_SIGNALLING 1 // JVET-O0545: Configurable maximum transform size + #define JVET_O0541_IMPLICIT_MTS_CONDITION 1 // JVET_O0541: Decouple the intra implicit transform selection from an inter MTS related SPS flag #define JVET_O0163_REMOVE_SWITCHING_TMV 1 // JVET-O0163/JVET-O0588: Remove switching between L0 and L1 for temporal MV #define JVET_O0655_422_CHROMA_DM_MAPPING_FIX 1 // JVET-O0655: modify chroma DM derivation table for 4:2:2 chroma format @@ -205,7 +207,11 @@ #define APPLY_SBT_SL_ON_MTS 1 // apply save & load fast algorithm on inter MTS when SBT is on #define FIX_PCM 1 // Fix PCM bugs in VTM3 +#if JVET_O0545_MAX_TB_SIGNALLING +#define MAX_TB_SIZE_SIGNALLING 1 +#else #define MAX_TB_SIZE_SIGNALLING 0 +#endif #define EMULATION_PREVENTION_FIX 1 // fix for start code emulation reported in #270. Diverges from specification text @@ -218,8 +224,10 @@ typedef std::pair<int, int> TrCost; #define REUSE_CU_RESULTS 1 #if REUSE_CU_RESULTS #define REUSE_CU_RESULTS_WITH_MULTIPLE_TUS 1 +#if !JVET_O0545_MAX_TB_SIGNALLING #define MAX_NUM_TUS 4 #endif +#endif // clang-format on diff --git a/source/Lib/CommonLib/UnitPartitioner.cpp b/source/Lib/CommonLib/UnitPartitioner.cpp index 3309c07d9b8ee8e166174432d89262ff08488271..9a9f6b05f2825682a6c6605fe974a932030d58ec 100644 --- a/source/Lib/CommonLib/UnitPartitioner.cpp +++ b/source/Lib/CommonLib/UnitPartitioner.cpp @@ -1005,9 +1005,15 @@ static const int g_zScanToY[1 << ( g_maxRtGridSize << 1 )] = 0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 5, 5, +#if JVET_O0545_MAX_TB_SIGNALLING + 6, 6, 7, 7, 6, 6, 7, 7, + 4, 4, 5, 5, 4, 4, 5, 5, + 6, 6, 7, 7, 6, 6, 7, 7, +#else 6, 6, 7, 7, 6, 5, 7, 7, 4, 4, 5, 5, 4, 4, 5, 5, 6, 6, 7, 7, 6, 5, 7, 7, +#endif }; static const int g_rsScanToZ[1 << ( g_maxRtGridSize << 1 )] = { @@ -1025,11 +1031,16 @@ Partitioning PartitionerImpl::getMaxTuTiling( const UnitArea &cuArea, const Codi { static_assert( MAX_LOG2_DIFF_CU_TR_SIZE <= g_maxRtGridSize, "Z-scan tables are only provided for MAX_LOG2_DIFF_CU_TR_SIZE for up to 3 (8x8 tiling)!" ); +#if JVET_O0545_MAX_TB_SIGNALLING + const Size area = cuArea.lumaSize(); + const int maxTrSize = (area.width>64 || area.height>64) ? 64 : cs.sps->getMaxTbSize(); +#else const CompArea area = cuArea.Y().valid() ? cuArea.Y() : cuArea.Cb(); #if MAX_TB_SIZE_SIGNALLING const int maxTrSize = cs.sps->getMaxTbSize() >> ( isLuma( area.compID ) ? 0 : 1 ); #else const int maxTrSize = MAX_TB_SIZEY >> ( isLuma( area.compID ) ? 0 : 1 ); +#endif #endif const int numTilesH = std::max<int>( 1, area.width / maxTrSize ); const int numTilesV = std::max<int>( 1, area.height / maxTrSize ); diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 21d394f56d117e620bf2d4aef00447d771ec5e2c..21ae8d05f91b801f5a0b15450696102be7ba2d3e 100755 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -3720,7 +3720,11 @@ void CABACReader::mip_flag( CodingUnit& cu ) cu.mipFlag = false; return; } +#if JVET_O0545_MAX_TB_SIGNALLING + if( cu.lwidth() > cu.cs->sps->getMaxTbSize() || cu.lheight() > cu.cs->sps->getMaxTbSize()) +#else if( cu.lwidth() > MIP_MAX_WIDTH || cu.lheight() > MIP_MAX_HEIGHT ) +#endif { cu.mipFlag = false; return; @@ -3752,7 +3756,11 @@ void CABACReader::mip_pred_modes( CodingUnit &cu ) void CABACReader::mip_pred_mode( PredictionUnit &pu ) { +#if JVET_O0545_MAX_TB_SIGNALLING + CHECK( pu.lwidth() > pu.cs->sps->getMaxTbSize() || pu.lheight() > pu.cs->sps->getMaxTbSize(), "Error: block size not supported" ); +#else CHECK( pu.lwidth() > MIP_MAX_WIDTH || pu.lheight() > MIP_MAX_HEIGHT, "Error: block size not supported" ); +#endif const int numModes = getNumModesMip( pu.Y() ); CHECKD( numModes > MAX_NUM_MIP_MODE, "Error: too many MIP modes" ); diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index af3efae387dbae3613bb87f9e405a6e16b4d6092..9005531365ab3411206071283619a4ade8f00151 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -1221,9 +1221,13 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) #if MAX_TB_SIZE_SIGNALLING +#if JVET_O0545_MAX_TB_SIGNALLING + READ_UVLC( uiCode, "sps_max_luma_transform_size_64_flag"); pcSPS->setLog2MaxTbSize( uiCode + 5 ); +#else // KJS: Not in syntax READ_UVLC( uiCode, "log2_max_luma_transform_block_size_minus2" ); pcSPS->setLog2MaxTbSize( uiCode + 2 ); #endif +#endif #if JVET_O0244_DELTA_POC READ_FLAG( uiCode, "sps_weighted_pred_flag" ); pcSPS->setUseWP( uiCode ? true : false ); READ_FLAG( uiCode, "sps_weighted_bipred_flag" ); pcSPS->setUseWPBiPred( uiCode ? true : false ); @@ -1329,7 +1333,11 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_FLAG(uiCode, "sbt_enable_flag"); pcSPS->setUseSBT(uiCode != 0); if( pcSPS->getUseSBT() ) { +#if JVET_O0545_MAX_TB_SIGNALLING + READ_FLAG(uiCode, "max_sbt_size_64_flag"); pcSPS->setMaxSbtSize(std::min((int)(1 << pcSPS->getLog2MaxTbSize()), uiCode != 0 ? 64 : 32)); +#else READ_FLAG(uiCode, "max_sbt_size_64_flag"); pcSPS->setMaxSbtSize(uiCode != 0 ? 64 : 32); +#endif } // KJS: not in draft yet READ_FLAG(uiCode, "sps_reshaper_enable_flag"); pcSPS->setUseReshaper(uiCode == 1); diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index 9976ecd95ba3bf5d4e0912e5e3668db23c07ab73..98149ec0dfc717f8df1c9640843daa621e5c268f 100755 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -2962,8 +2962,12 @@ void CABACWriter::residual_lfnst_mode( const CodingUnit& cu, CUCtx& cuCtx ) unsigned cctx = 0; #if JVET_O0368_LFNST_WITH_DCT2_ONLY if ( CS::isDualITree(*cu.cs) ) cctx++; +#else +#if JVET_O0545_MAX_TB_SIGNALLING + if( ( cu.firstTU->mtsIdx < MTS_DST7_DST7 || !TU::getCbf(*cu.firstTU, COMPONENT_Y) ) && CS::isDualITree( *cu.cs ) ) cctx++; #else if( cu.firstTU->mtsIdx < MTS_DST7_DST7 && CS::isDualITree( *cu.cs ) ) cctx++; +#endif #endif const uint32_t idxLFNST = cu.lfnstIdx; @@ -3623,7 +3627,11 @@ void CABACWriter::mip_flag( const CodingUnit& cu ) { return; } +#if JVET_O0545_MAX_TB_SIGNALLING + if( cu.lwidth() > cu.cs->sps->getMaxTbSize() || cu.lheight() > cu.cs->sps->getMaxTbSize()) +#else if( cu.lwidth() > MIP_MAX_WIDTH || cu.lheight() > MIP_MAX_HEIGHT ) +#endif { return; } diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index 2cf20638617afde7b335e2e2cbdb4a67fb53fc54..a753f7d396eb1ce5e864309c1eae3eda25f4575b 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -4183,10 +4183,12 @@ void EncCu::xEncodeInterResidual( CodingStructure *&tempCS sbtOffRootCbf = cu->rootCbf; currBestSbt = CU::getSbtInfo( cu->firstTU->mtsIdx > MTS_SKIP ? SBT_OFF_MTS : SBT_OFF_DCT, 0 ); currBestTrs = cu->firstTU->mtsIdx; +#if !JVET_O0545_MAX_TB_SIGNALLING if( cu->lwidth() <= MAX_TB_SIZEY && cu->lheight() <= MAX_TB_SIZEY ) { CHECK( tempCS->tus.size() != 1, "tu must be only one" ); } +#endif #if WCG_EXT DTRACE_MODE_COST( *tempCS, m_pcRdCost->getLambda( true ) ); diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index 4b4d20cbf12af108bd59883f4ca94e1edec9fdf5..6fdade2d5d17d78b44901c3ceb22bfa2e3dded80 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -912,7 +912,11 @@ void EncLib::xInitSPS(SPS &sps) sps.setUseSBT ( m_SBT ); if( sps.getUseSBT() ) { +#if JVET_O0545_MAX_TB_SIGNALLING + sps.setMaxSbtSize ( std::min((int)(1 << m_log2MaxTbSize), m_iSourceWidth >= 1920 ? 64 : 32) ); +#else sps.setMaxSbtSize ( m_iSourceWidth >= 1920 ? 64 : 32 ); +#endif } sps.setUseSMVD ( m_SMVD ); sps.setUseGBi ( m_GBi ); diff --git a/source/Lib/EncoderLib/InterSearch.cpp b/source/Lib/EncoderLib/InterSearch.cpp index a0df237fe25c80f466636c41a7ce48d2afcba6f4..25c08f520b284097cf7de596433f346a31b10651 100644 --- a/source/Lib/EncoderLib/InterSearch.cpp +++ b/source/Lib/EncoderLib/InterSearch.cpp @@ -6258,7 +6258,11 @@ void InterSearch::setWpScalingDistParam( int iRefIdx, RefPicList eRefPicListCur, void InterSearch::xEncodeInterResidualQT(CodingStructure &cs, Partitioner &partitioner, const ComponentID &compID) { const UnitArea& currArea = partitioner.currArea(); +#if JVET_O0545_MAX_TB_SIGNALLING + const TransformUnit &currTU = *cs.getTU(isLuma(partitioner.chType) ? currArea.lumaPos() : currArea.chromaPos(), partitioner.chType); +#else const TransformUnit &currTU = *cs.getTU(currArea.lumaPos(), partitioner.chType); +#endif const CodingUnit &cu = *currTU.cu; const unsigned currDepth = partitioner.currTrDepth; @@ -6281,7 +6285,11 @@ void InterSearch::xEncodeInterResidualQT(CodingStructure &cs, Partitioner &parti CHECK(CU::isIntra(cu), "Inter search provided with intra CU"); - if( cu.chromaFormat != CHROMA_400 ) + if( cu.chromaFormat != CHROMA_400 +#if JVET_O0545_MAX_TB_SIGNALLING + && (!CS::isDualITree(cs) || isChroma(partitioner.chType)) +#endif + ) { #if !JVET_O0596_CBF_SIG_ALIGN_TO_SPEC const bool firstCbfOfCU = ( currDepth == 0 ); @@ -6314,7 +6322,11 @@ void InterSearch::xEncodeInterResidualQT(CodingStructure &cs, Partitioner &parti } } - if( !bSubdiv && !( cu.sbtInfo && currTU.noResidual ) ) + if( !bSubdiv && !( cu.sbtInfo && currTU.noResidual ) +#if JVET_O0545_MAX_TB_SIGNALLING + && !isChroma(partitioner.chType) +#endif + ) { m_CABACEstimator->cbf_comp( cs, TU::getCbfAtDepth( currTU, COMPONENT_Y, currDepth ), currArea.Y(), currDepth ); } @@ -6655,7 +6667,11 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par if (bCheckFull) { +#if JVET_O0545_MAX_TB_SIGNALLING + TransformUnit &tu = csFull->addTU(CS::getArea(cs, currArea, partitioner.chType), partitioner.chType); +#else TransformUnit &tu = csFull->addTU(CS::isDualITree(cs) ? cu : currArea, partitioner.chType); +#endif tu.depth = currDepth; tu.mtsIdx = MTS_DCT2_DCT2; tu.checkTuNoResidual( partitioner.currPartIdx() ); @@ -6695,7 +6711,11 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par saveCS.picture = cs.picture; saveCS.area.repositionTo(currArea); saveCS.clearTUs(); +#if JVET_O0545_MAX_TB_SIGNALLING + TransformUnit & bestTU = saveCS.addTU(CS::getArea(cs, currArea, partitioner.chType), partitioner.chType); +#else TransformUnit & bestTU = saveCS.addTU(CS::isDualITree(cs) ? cu : currArea, partitioner.chType); +#endif for( uint32_t c = 0; c < numTBlocks; c++ ) { diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp index cc7c2a3bbb86529efdff2d49909b0a4f2070520d..339a1c7ea65425d5776af41d9fda28944d247f23 100644 --- a/source/Lib/EncoderLib/IntraSearch.cpp +++ b/source/Lib/EncoderLib/IntraSearch.cpp @@ -365,7 +365,11 @@ bool IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, //===== determine set of modes to be tested (using prediction signal only) ===== int numModesAvailable = NUM_LUMA_MODE; // total number of Intra modes const bool fastMip = sps.getUseMIP() && m_pcEncCfg->getUseFastMIP(); +#if JVET_O0545_MAX_TB_SIGNALLING + const bool mipAllowed = sps.getUseMIP() && ( cu.lfnstIdx == 0 ) && isLuma( partitioner.chType ) && pu.lwidth() <= cu.cs->sps->getMaxTbSize() && pu.lheight() <= cu.cs->sps->getMaxTbSize(); +#else const bool mipAllowed = sps.getUseMIP() && ( cu.lfnstIdx == 0 ) && isLuma( partitioner.chType ) && pu.lwidth() <= MIP_MAX_WIDTH && pu.lheight() <= MIP_MAX_HEIGHT; +#endif const bool testMip = mipAllowed && mipModesAvailable( pu.Y() ) && !(fastMip && (cu.lwidth() > 2 * cu.lheight() || cu.lheight() > 2 * cu.lwidth())); static_vector<ModeInfo, FAST_UDI_MAX_RDMODE_NUM> uiRdModeList; diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp index a8bf54794531cea3da19729d1b276520f9008948..4c7ac2f0ef3c303091fd765a66749a0b43a0c03b 100644 --- a/source/Lib/EncoderLib/VLCWriter.cpp +++ b/source/Lib/EncoderLib/VLCWriter.cpp @@ -828,9 +828,13 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) } #if MAX_TB_SIZE_SIGNALLING +#if JVET_O0545_MAX_TB_SIGNALLING + WRITE_UVLC( pcSPS->getLog2MaxTbSize() - 5, "sps_max_luma_transform_size_64_flag" ); +#else // KJS: Not in syntax WRITE_UVLC( pcSPS->getLog2MaxTbSize() - 2, "log2_max_luma_transform_block_size_minus2" ); #endif +#endif #if JVET_O0244_DELTA_POC WRITE_FLAG( pcSPS->getUseWP() ? 1 : 0, "sps_weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) WRITE_FLAG( pcSPS->getUseWPBiPred() ? 1 : 0, "sps_weighted_bipred_flag" ); // Use of Weighting Bi-Prediction (B_SLICE)