diff --git a/source/Lib/CommonLib/Picture.h b/source/Lib/CommonLib/Picture.h index 4a0b4ab8b4d01c255ec75af1b8c5a9ff47985475..867642699e0e9d794ff843bb3525019d7536bbab 100644 --- a/source/Lib/CommonLib/Picture.h +++ b/source/Lib/CommonLib/Picture.h @@ -214,6 +214,10 @@ public: bool interLayerRefPicFlag; +#if JVET_R0276_REORDERED_SUBPICS + std::vector<int> subPicIDs; +#endif + #if ENABLE_SPLIT_PARALLELISM PelStorage m_bufs[PARL_SPLIT_MAX_NUM_JOBS][NUM_PIC_TYPES]; #else diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 3ba52903d6dcbe59a45e5684eae9f04286f5a95b..bc8b804c50b7604158b1669f9d26512359fc0cff 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -65,6 +65,8 @@ #define JVET_R0278_CONSTRAINT 1 // JVET-R0278: ph_inter_slice_allowed_flag constraint +#define JVET_R0276_REORDERED_SUBPICS 1 // JVET-R0276: reference picture constraint for reordered sub-pictures + #define JVET_R0130_TC_DERIVATION_BUGFIX 1 // JVET-R0130: Cleanup of tC derivation for deblocking filter #define JVET_R0334_PLT_CLEANUP 1 // JVET-R0334: Disable chroma palette for local dual tree diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index 3b0ea52c9ffeeb99cd4c3108d498244616056cb0..1410e994f20ae2d631604e670ad1eedcd002fb9e 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -1494,6 +1494,7 @@ void DecLib::xCheckParameterSetConstraints(const int layerId) CHECK(levelIdcSps > maxLevelIdxDci, "max level signaled in the DCI shall not be less than the level signaled in the SPS"); } +#if !JVET_R0276_REORDERED_SUBPICS // When the current picture is not the first picture of the CLVS, if the value of SubpicId[ i ] is not equal to the value of SubpicId[ i ] of previous picture in decoding order in the same layer, // the nal_unit_type for all coded slice NAL units of the the subpicture with subpicture index i shall be in the range of IDR_W_RADL to CRA_NUT, inclusive. if( sps->getSubPicInfoPresentFlag() ) @@ -1538,6 +1539,7 @@ void DecLib::xCheckParameterSetConstraints(const int layerId) } } } +#endif #if JVET_R0278_CONSTRAINT if( slice->getPicHeader()->getGdrOrIrapPicFlag() && !slice->getPicHeader()->getGdrPicFlag() && ( !vps || vps->getIndependentLayerFlag( vps->getGeneralLayerIdx( layerId ) ) ) ) @@ -1912,6 +1914,51 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl pcSlice->scaleRefPicList( scaledRefPic, m_pcPic->cs->picHeader, m_parameterSetManager.getAPSs(), m_picHeader.getLmcsAPS(), m_picHeader.getScalingListAPS(), true ); +#if JVET_R0276_REORDERED_SUBPICS + // For each value of i in the range of 0 to sps_num_subpics_minus1, inclusive, when the value of SubpicIdVal[ i ] of a current picture is not equal to the value of SubpicIdVal[ i ] of a reference picture, + // the active entries of the RPLs of the coded slices in the i-th subpicture of the current picture shall not include that reference picture. + + if( sps->getSubPicInfoPresentFlag() ) + { + // store sub-picture IDs with a picture + if( m_bFirstSliceInPicture ) + { + pcSlice->getPic()->subPicIDs.clear(); + for( int subPicIdx = 0; subPicIdx < sps->getNumSubPics(); subPicIdx++ ) + { + pcSlice->getPic()->subPicIDs.push_back( pps->getSubPic( subPicIdx ).getSubPicID() ); + } + } + + if( !pcSlice->isIntra() ) + { + int currentSubPicIdx = NOT_VALID; + + // derive sub-picture index for a slice + for( int subPicIdx = 0; subPicIdx < sps->getNumSubPics(); subPicIdx++ ) + { + if( pps->getSubPic( subPicIdx ).getSubPicID() == pcSlice->getSliceSubPicId() ) + { + currentSubPicIdx = subPicIdx; + break; + } + } + + CHECK( currentSubPicIdx == NOT_VALID, "Sub-picture was not found" ); + + // check collocated sub-picture ID of each active reference picture + for( int refPicList = 0; refPicList < NUM_REF_PIC_LIST_01; refPicList++ ) + { + for( int refIdx = 0; refIdx < pcSlice->getNumRefIdx( RefPicList( refPicList ) ); refIdx++ ) + { + CHECK( currentSubPicIdx >= pcSlice->getRefPic( RefPicList( refPicList ), refIdx )->subPicIDs.size(), "Number of sub-pictures in a reference picture is less then the current slice sub-picture index" ); + CHECK( pcSlice->getRefPic( RefPicList( refPicList ), refIdx )->subPicIDs[currentSubPicIdx] != pcSlice->getSliceSubPicId(), "A picture with different sub-picture ID of the collocated sub-picture cannot be used as an active reference picture" ); + } + } + } + } +#endif + if (!pcSlice->isIntra()) { bool bLowDelay = true;