diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index 72681ba7a2dc841e7b021f166554c333f8beb6b9..7cf799322c155d9fb4f71158a890dc8894c01510 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -123,6 +123,9 @@ Slice::Slice() , m_numEntryPoints ( 0 ) #endif , m_cabacInitFlag ( false ) +#if JVET_P0126_SIGNALLING_SUBPICID + , m_sliceSubPicId ( 0 ) +#endif #if !JVET_P1006_PICTURE_HEADER , m_jointCbCrSignFlag ( false ) , m_bLMvdL1Zero ( false ) @@ -2025,6 +2028,9 @@ SPS::SPS() // Structure , m_maxWidthInLumaSamples (352) , m_maxHeightInLumaSamples (288) +#if JVET_P0126_SIGNALLING_SUBPICID +, m_subPicPresentFlag (0) +#endif #if JVET_P1006_PICTURE_HEADER , m_numSubPics(1) , m_subPicIdPresentFlag(0) diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index 12c9c3e61fb6a6d60ea232a13aef75bd0ec76401..d5e2825a4b48a6e10ef6b11769d56719d22db65d 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -977,6 +977,9 @@ private: // Structure uint32_t m_maxWidthInLumaSamples; uint32_t m_maxHeightInLumaSamples; +#if JVET_P0126_SIGNALLING_SUBPICID + bool m_subPicPresentFlag; // indicates the presence of sub-pictures + #endif #if JVET_P1006_PICTURE_HEADER uint8_t m_numSubPics; //!< number of sub-pictures used bool m_subPicIdPresentFlag; //!< indicates the presence of sub-picture IDs @@ -1146,6 +1149,12 @@ public: uint32_t getMaxPicWidthInLumaSamples() const { return m_maxWidthInLumaSamples; } void setMaxPicHeightInLumaSamples( uint32_t u ) { m_maxHeightInLumaSamples = u; } uint32_t getMaxPicHeightInLumaSamples() const { return m_maxHeightInLumaSamples; } + +#if JVET_P0126_SIGNALLING_SUBPICID + void setSubPicPresentFlag(bool b) { m_subPicPresentFlag = b; } + bool getSubPicPresentFlag() const { return m_subPicPresentFlag; } +#endif + #if JVET_P1006_PICTURE_HEADER void setNumSubPics( uint8_t u ) { m_numSubPics = u; } uint8_t getNumSubPics( ) const { return m_numSubPics; } @@ -2377,6 +2386,10 @@ private: bool m_cabacInitFlag; +#if JVET_P0126_SIGNALLING_SUBPICID + uint32_t m_sliceSubPicId; +#endif + #if !JVET_P1006_PICTURE_HEADER bool m_jointCbCrSignFlag; #endif @@ -2612,7 +2625,10 @@ public: void setSignDataHidingEnabledFlag( bool b ) { m_signDataHidingEnabledFlag = b; } bool getSignDataHidingEnabledFlag() const { return m_signDataHidingEnabledFlag; } #endif - +#if JVET_P0126_SIGNALLING_SUBPICID + void setSliceSubPicId(int i) { m_sliceSubPicId = i; } + uint32_t getSliceSubPicId() const { return m_sliceSubPicId; } +#endif #if JVET_P1006_PICTURE_HEADER uint32_t getCuQpDeltaSubdiv() const { return this->isIntra() ? m_pcPicHeader->getCuQpDeltaSubdivIntra() : m_pcPicHeader->getCuQpDeltaSubdivInter(); } uint32_t getCuChromaQpOffsetSubdiv() const { return this->isIntra() ? m_pcPicHeader->getCuChromaQpOffsetSubdivIntra() : m_pcPicHeader->getCuChromaQpOffsetSubdivInter(); } diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 119c2063ab561f03630fb33b5e8adb2db66c3e0e..ecd268eaa7bcc031a6d579c08f717073ae95d6de 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -50,6 +50,8 @@ #include <assert.h> #include <cassert> +#define JVET_P0126_SIGNALLING_SUBPICID 1 // JVET-P0126: Signalling of subpicture IDs + #define JVET_P1004_REMOVE_BRICKS 1 // JVET-P1004: Removal of bricks #define JVET_P0202_P0203_FIX_HRD_RELATED_SEI 1 // JVET-P0202 and JVET-P0203: CPB timing for sub-layers with DU and parsing independency to SPS diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index 3183b335d8f2eabccd0986653d24077d7c99b6a7..018bcf6791a02f22f6e3a4c493fb1b5f588f28fa 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -1374,6 +1374,10 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_UVLC( uiCode, "pic_width_max_in_luma_samples" ); pcSPS->setMaxPicWidthInLumaSamples( uiCode ); READ_UVLC( uiCode, "pic_height_max_in_luma_samples" ); pcSPS->setMaxPicHeightInLumaSamples( uiCode ); + #if JVET_P0126_SIGNALLING_SUBPICID + READ_FLAG( uiCode, "subpics_present_flag" ); pcSPS->setSubPicPresentFlag(uiCode); +#endif + #if JVET_P1006_PICTURE_HEADER pcSPS->setNumSubPics( 1 ); // TODO - need sub-picture syntax READ_FLAG(uiCode, "sps_subpic_id_present_flag"); pcSPS->setSubPicIdPresentFlag( uiCode != 0 ); @@ -2749,6 +2753,30 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para pcSlice->setPOC(iPOCmsb + iPOClsb); } #endif + +#if JVET_P0126_SIGNALLING_SUBPICID + if (sps->getSubPicPresentFlag()) + { + uint32_t bitsSubPicId; + if (sps->getSubPicIdSignallingPresentFlag()) + { + bitsSubPicId = sps->getSubPicIdLen(); + } + else if (picHeader->getSubPicIdSignallingPresentFlag()) + { + bitsSubPicId = picHeader->getSubPicIdLen(); + } + else if (pps->getSubPicIdSignallingPresentFlag()) + { + bitsSubPicId = pps->getSubPicIdLen(); + } + else + { + bitsSubPicId = ceilLog2(sps->getNumSubPics()); + } + READ_CODE(bitsSubPicId, uiCode, "slice_subpic_id"); pcSlice->setSliceSubPicId(uiCode); + } +#endif #if JVET_P1004_REMOVE_BRICKS // raster scan slices diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp index 0e12799af47acafd76ea279ca75f608729ae78f8..4ae4746e67623553e8c8e2ad74a39121b7efb84d 100644 --- a/source/Lib/EncoderLib/VLCWriter.cpp +++ b/source/Lib/EncoderLib/VLCWriter.cpp @@ -869,6 +869,10 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_UVLC( pcSPS->getMaxPicWidthInLumaSamples(), "pic_width_max_in_luma_samples" ); WRITE_UVLC( pcSPS->getMaxPicHeightInLumaSamples(), "pic_height_max_in_luma_samples" ); +#if JVET_P0126_SIGNALLING_SUBPICID + WRITE_FLAG(pcSPS->getSubPicPresentFlag(), "subpics_present_flag"); +#endif + #if JVET_P1006_PICTURE_HEADER WRITE_FLAG( pcSPS->getSubPicIdPresentFlag(), "sps_subpic_id_present_flag"); if( pcSPS->getSubPicIdPresentFlag() ) @@ -1898,6 +1902,31 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) #if !JVET_P1006_PICTURE_HEADER WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "slice_pic_parameter_set_id" ); #endif + + #if JVET_P0126_SIGNALLING_SUBPICID + if (pcSlice->getSPS()->getSubPicPresentFlag()) + { + uint32_t bitsSubPicId; + if (pcSlice->getSPS()->getSubPicIdSignallingPresentFlag()) + { + bitsSubPicId = pcSlice->getSPS()->getSubPicIdLen(); + } + else if (picHeader->getSubPicIdSignallingPresentFlag()) + { + bitsSubPicId = picHeader->getSubPicIdLen(); + } + else if (pcSlice->getPPS()->getSubPicIdSignallingPresentFlag()) + { + bitsSubPicId = pcSlice->getPPS()->getSubPicIdLen(); + } + else + { + bitsSubPicId = ceilLog2(pcSlice->getSPS()->getNumSubPics()); + } + WRITE_CODE(pcSlice->getSliceSubPicId(), bitsSubPicId, "slice_subpic_id"); + } +#endif + #if JVET_P1004_REMOVE_BRICKS // raster scan slices if( pcSlice->getPPS()->getRectSliceFlag() == 0 ) @@ -1922,6 +1951,7 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) } #else + int bitsSliceAddress = 1; if (!pcSlice->getPPS()->getRectSliceFlag()) {