diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp index e5ebd2ca1e6dad1709a3834c858029c500ecfb7f..a377c23eb2475a42a91fe5532d1cb82820dbec18 100644 --- a/source/App/EncoderApp/EncApp.cpp +++ b/source/App/EncoderApp/EncApp.cpp @@ -401,6 +401,10 @@ void EncApp::xInitLibCfg() m_cEncLib.setUseSplitConsOverride ( m_SplitConsOverrideEnabledFlag ); m_cEncLib.setMinQTSizes ( m_uiMinQT ); m_cEncLib.setMaxMTTHierarchyDepth ( m_uiMaxMTTHierarchyDepth, m_uiMaxMTTHierarchyDepthI, m_uiMaxMTTHierarchyDepthIChroma ); +#if JVET_Q0330_BLOCK_PARTITION + m_cEncLib.setMaxBTSizes ( m_uiMaxBT ); + m_cEncLib.setMaxTTSizes ( m_uiMaxTT ); +#endif m_cEncLib.setDualITree ( m_dualTree ); m_cEncLib.setLFNST ( m_LFNST ); m_cEncLib.setUseFastLFNST ( m_useFastLFNST ); diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index 6417fb0896eb46ef01e78befd8d312a24fb3dee6..9a7a332658fc102488330ca82bca3c9446aa35a9 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -891,6 +891,14 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("MaxMTTHierarchyDepthI", m_uiMaxMTTHierarchyDepthI, 3u, "MaxMTTHierarchyDepthI") ("MaxMTTHierarchyDepthISliceL", m_uiMaxMTTHierarchyDepthI, 3u, "MaxMTTHierarchyDepthISliceL") ("MaxMTTHierarchyDepthISliceC", m_uiMaxMTTHierarchyDepthIChroma, 3u, "MaxMTTHierarchyDepthISliceC") +#if JVET_Q0330_BLOCK_PARTITION + ("MaxBTLumaISlice", m_uiMaxBT[0], 32u, "MaxBTLumaISlice") + ("MaxBTChromaISlice", m_uiMaxBT[2], 64u, "MaxBTChromaISlice") + ("MaxBTNonISlice", m_uiMaxBT[1], 128u, "MaxBTNonISlice") + ("MaxTTLumaISlice", m_uiMaxTT[0], 32u, "MaxTTLumaISlice") + ("MaxTTChromaISlice", m_uiMaxTT[2], 32u, "MaxTTChromaISlice") + ("MaxTTNonISlice", m_uiMaxTT[1], 64u, "MaxTTNonISlice") +#endif ("DualITree", m_dualTree, false, "Use separate QTBT trees for intra slice luma and chroma channel types") ( "LFNST", m_LFNST, false, "Enable LFNST (0:off, 1:on) [default: off]" ) ( "FastLFNST", m_useFastLFNST, false, "Fast methods for LFNST" ) diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h index 2bfc490580cc58af3c5e4ff4b097cb8dddd606b9..31430ed3d94339fbbe0e8baafcb55b3024c629b0 100644 --- a/source/App/EncoderApp/EncAppCfg.h +++ b/source/App/EncoderApp/EncAppCfg.h @@ -290,6 +290,10 @@ protected: unsigned m_uiMaxMTTHierarchyDepth; unsigned m_uiMaxMTTHierarchyDepthI; unsigned m_uiMaxMTTHierarchyDepthIChroma; +#if JVET_Q0330_BLOCK_PARTITION + unsigned m_uiMaxBT[3]; + unsigned m_uiMaxTT[3]; +#endif bool m_dualTree; bool m_LFNST; bool m_useFastLFNST; diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h index 4f1864b5f21ee9cd9fb760c1feed4ece53561611..90d7f066b4c1c39e2e4496f8f8db3653e0dc778a 100644 --- a/source/Lib/CommonLib/CommonDef.h +++ b/source/Lib/CommonLib/CommonDef.h @@ -381,19 +381,24 @@ static const int DMVR_NUM_ITERATION = 2; //QTBT high level parameters //for I slice luma CTB configuration para. static const int MAX_BT_DEPTH = 4; ///< <=7 +#if !JVET_Q0330_BLOCK_PARTITION static const int MAX_BT_SIZE = 32; ///< [1<<MIN_QT_SIZE, 1<<CTU_LOG2] static const int MAX_TT_SIZE = 32; ///< [1<<MIN_QT_SIZE, 1<<CTU_LOG2] static const int MAX_TT_SIZE_C = 32; ///< [1<<MIN_QT_SIZE, 1<<CTU_LOG2] +#endif //for P/B slice CTU config. para. static const int MAX_BT_DEPTH_INTER = 4; ///< <=7 +#if !JVET_Q0330_BLOCK_PARTITION static const int MAX_BT_SIZE_INTER = 128; ///< for initialization, [1<<MIN_BT_SIZE_INTER, 1<<CTU_LOG2] - +#endif //for I slice chroma CTB configuration para. (in luma samples) static const int MAX_BT_DEPTH_C = 0; ///< <=7 +#if !JVET_Q0330_BLOCK_PARTITION static const int MAX_BT_SIZE_C = 64; ///< [1<<MIN_QT_SIZE_C, 1<<CTU_LOG2], in luma samples static const int MAX_TT_SIZE_INTER = 64; ///< for initialization, [1<<MIN_CU_LOG2, 64] +#endif static const int MIN_DUALTREE_CHROMA_WIDTH = 4; static const int MIN_DUALTREE_CHROMA_SIZE = 16; static const SplitSeries SPLIT_BITS = 5; diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index c4ad7c567b36e1247f505f6de8d141b3b1d4aa85..5cd414cf3bfc02eed8f0102f87d605ba5d0b343c 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -1862,8 +1862,13 @@ SPS::SPS() , m_CTUSize(0) , m_minQT{ 0, 0, 0 } , m_maxMTTHierarchyDepth{ MAX_BT_DEPTH, MAX_BT_DEPTH_INTER, MAX_BT_DEPTH_C } +#if JVET_Q0330_BLOCK_PARTITION +, m_maxBTSize{ 0, 0, 0 } +, m_maxTTSize{ 0, 0, 0 } +#else , m_maxBTSize{ MAX_BT_SIZE, MAX_BT_SIZE_INTER, MAX_BT_SIZE_C } , m_maxTTSize{ MAX_TT_SIZE, MAX_TT_SIZE_INTER, MAX_TT_SIZE_C } +#endif , m_uiMaxCUWidth ( 32) , m_uiMaxCUHeight ( 32) , m_uiMaxCodingDepth ( 3) diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 52745d048ae5e34fc2e07f2c85953b09b44eeedd..9cb64582e5434471a6b637fb3a56ef6c3bfe67a6 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -50,11 +50,14 @@ #include <assert.h> #include <cassert> +#define JVET_Q0330_BLOCK_PARTITION 1 // JVET-Q0330: fix the block partitioning at picture boundary + #define JVET_Q0172_CHROMA_FORMAT_BITDEPTH_CONSTRAINT 1 //JVET-Q0172: Disallow differing chroma format and different bit depths for cross-layer prediction. #define JVET_Q0491_PLT_ESCAPE 1 // JVET-Q0491: Palette escape binarization #define JVET_Q414_CONSTRAINT_ON_GDR_PIC_FLAG 1 //JVET-Q0414: when gdr_enabled_flag is equal to 0, gdr_pic_flag shall be 0 + #define JVET_Q0413_SKIP_LAST_SUBPIC_SIG 1 //JVET-Q0413 modification 2: skip the width and height signaling of last subpicture #define JVET_Q0169_SUBPIC_LEN_CONFORM 1 // JVET-Q0169: add bitstream conformance check on subpic length diff --git a/source/Lib/CommonLib/UnitPartitioner.cpp b/source/Lib/CommonLib/UnitPartitioner.cpp index 65803b7063ac660785fe203b667e3df49efbf825..70e9059ed9fde44ed5f27c58ca6d0dcf1589a173 100644 --- a/source/Lib/CommonLib/UnitPartitioner.cpp +++ b/source/Lib/CommonLib/UnitPartitioner.cpp @@ -411,6 +411,9 @@ void QTBTPartitioner::canSplit( const CodingStructure &cs, bool& canNo, bool& ca if (areaC && areaC->width == 4) canBv = false; #else if (chType == CHANNEL_TYPE_CHROMA && areaC.width == 4) canBv = false; +#endif +#if JVET_Q0330_BLOCK_PARTITION + if( !canBh && !canBv && !canQt ) canQt = true; #endif return; } @@ -554,7 +557,11 @@ PartSplit QTBTPartitioner::getImplicitSplit( const CodingStructure &cs ) const CompArea& area = currArea().Y(); const unsigned maxBtSize = cs.pcv->getMaxBtSize( *cs.slice, chType ); +#if JVET_Q0330_BLOCK_PARTITION + const bool isBtAllowed = area.width <= maxBtSize && area.height <= maxBtSize && currMtDepth < (cs.pcv->getMaxBtDepth(*cs.slice, chType) + currImplicitBtDepth); +#else const bool isBtAllowed = area.width <= maxBtSize && area.height <= maxBtSize; +#endif const unsigned minQtSize = cs.pcv->getMinQtSize( *cs.slice, chType ); const bool isQtAllowed = area.width > minQtSize && area.height > minQtSize && currBtDepth == 0; @@ -562,11 +569,19 @@ PartSplit QTBTPartitioner::getImplicitSplit( const CodingStructure &cs ) { split = CU_QUAD_SPLIT; } +#if JVET_Q0330_BLOCK_PARTITION + else if( !isBlInPic && isBtAllowed && area.width <= MAX_TB_SIZEY ) +#else else if( !isBlInPic && isBtAllowed ) +#endif { split = CU_HORZ_SPLIT; } +#if JVET_Q0330_BLOCK_PARTITION + else if( !isTrInPic && isBtAllowed && area.height <= MAX_TB_SIZEY ) +#else else if( !isTrInPic && isBtAllowed ) +#endif { split = CU_VERT_SPLIT; } @@ -578,10 +593,17 @@ PartSplit QTBTPartitioner::getImplicitSplit( const CodingStructure &cs ) { split = CU_QUAD_SPLIT; } +#if JVET_Q0330_BLOCK_PARTITION + if( (!isBlInPic || !isTrInPic) && split == CU_DONT_SPLIT ) + { + split = CU_QUAD_SPLIT; + } +#else if ((!isBlInPic || !isTrInPic) && (currArea().Y().width > MAX_TB_SIZEY || currArea().Y().height > MAX_TB_SIZEY)) { split = CU_QUAD_SPLIT; } +#endif } m_partStack.back().checkdIfImplicit = true; diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h index b795a2a410ea39fb1d1476bcf975e6423c73f66f..cb5e43773de90f826cde91c190783a850b655c8f 100644 --- a/source/Lib/EncoderLib/EncCfg.h +++ b/source/Lib/EncoderLib/EncCfg.h @@ -280,6 +280,10 @@ protected: uint32_t m_subPicId[MAX_NUM_SUB_PICS]; bool m_useSplitConsOverride; unsigned m_uiMinQT[3]; //0: I slice; 1: P/B slice, 2: I slice chroma +#if JVET_Q0330_BLOCK_PARTITION + unsigned m_uiMaxBT[3]; //0: I slice; 1: P/B slice, 2: I slice chroma + unsigned m_uiMaxTT[3]; //0: I slice; 1: P/B slice, 2: I slice chroma +#endif unsigned m_uiMaxMTTHierarchyDepth; unsigned m_uiMaxMTTHierarchyDepthI; unsigned m_uiMaxMTTHierarchyDepthIChroma; @@ -931,6 +935,10 @@ public: void setCTUSize ( unsigned u ) { m_CTUSize = u; } void setMinQTSizes ( unsigned* minQT) { m_uiMinQT[0] = minQT[0]; m_uiMinQT[1] = minQT[1]; m_uiMinQT[2] = minQT[2]; } +#if JVET_Q0330_BLOCK_PARTITION + void setMaxBTSizes ( unsigned* maxBT) { m_uiMaxBT[0] = maxBT[0]; m_uiMaxBT[1] = maxBT[1]; m_uiMaxBT[2] = maxBT[2]; } + void setMaxTTSizes ( unsigned* maxTT) { m_uiMaxTT[0] = maxTT[0]; m_uiMaxTT[1] = maxTT[1]; m_uiMaxTT[2] = maxTT[2]; } +#endif void setMaxMTTHierarchyDepth ( unsigned uiMaxMTTHierarchyDepth, unsigned uiMaxMTTHierarchyDepthI, unsigned uiMaxMTTHierarchyDepthIChroma ) { m_uiMaxMTTHierarchyDepth = uiMaxMTTHierarchyDepth; m_uiMaxMTTHierarchyDepthI = uiMaxMTTHierarchyDepthI; m_uiMaxMTTHierarchyDepthIChroma = uiMaxMTTHierarchyDepthIChroma; } unsigned getMaxMTTHierarchyDepth () const { return m_uiMaxMTTHierarchyDepth; } diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index 76cb70195c92c9807f46d2a19bdd998433feb945..ca4e8f35ba538748f642a4c3d277440a5019626f 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -2364,6 +2364,9 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, if( refLayer >= 0 && m_uiNumBlk[refLayer] != 0 ) { +#if JVET_Q0330_BLOCK_PARTITION + const int MAX_BT_SIZE_INTER = 128; +#endif picHeader->setSplitConsOverrideFlag(true); double dBlkSize = sqrt( ( double ) m_uiBlkSize[refLayer] / m_uiNumBlk[refLayer] ); if( dBlkSize < AMAXBT_TH32 || pcPic->cs->sps->getCTUSize()==32 ) diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index 5b59d3243a724510b940f99c8f436146c350ba53..4c0ffdcf14d491cd588fac95bfdb759c58a6eff1 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -1067,6 +1067,10 @@ void EncLib::xInitSPS( SPS& sps, VPS& vps ) sps.setSplitConsOverrideEnabledFlag ( m_useSplitConsOverride ); sps.setMinQTSizes ( m_uiMinQT ); sps.setMaxMTTHierarchyDepth ( m_uiMaxMTTHierarchyDepth, m_uiMaxMTTHierarchyDepthI, m_uiMaxMTTHierarchyDepthIChroma ); +#if JVET_Q0330_BLOCK_PARTITION + sps.setMaxBTSize( m_uiMaxBT[1], m_uiMaxBT[0], m_uiMaxBT[2] ); + sps.setMaxTTSize( m_uiMaxTT[1], m_uiMaxTT[0], m_uiMaxTT[2] ); +#else unsigned maxBtSize[3], maxTtSize[3]; memcpy(maxBtSize, m_uiMinQT, sizeof(maxBtSize)); memcpy(maxTtSize, m_uiMinQT, sizeof(maxTtSize)); @@ -1087,6 +1091,7 @@ void EncLib::xInitSPS( SPS& sps, VPS& vps ) } sps.setMaxBTSize ( maxBtSize[1], maxBtSize[0], maxBtSize[2] ); sps.setMaxTTSize ( maxTtSize[1], maxTtSize[0], maxTtSize[2] ); +#endif sps.setIDRRefParamListPresent ( m_idrRefParamList ); sps.setUseDualITree ( m_dualITree ); sps.setUseLFNST ( m_LFNST );