diff --git a/source/App/DecoderApp/DecApp.cpp b/source/App/DecoderApp/DecApp.cpp index d288bb0206af302fdf06b9bf4f865cda125d0710..075911c5ced1f605dee121ff65b9e7124ea1052a 100644 --- a/source/App/DecoderApp/DecApp.cpp +++ b/source/App/DecoderApp/DecApp.cpp @@ -210,6 +210,9 @@ uint32_t DecApp::decode() } m_cDecLib.updateAssociatedIRAP(); +#if JVET_R0041 + m_cDecLib.updatePrevGDRInSameLayer(); +#endif } else if ( (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS ) && m_cDecLib.getFirstSliceInSequence(nalu.m_nuhLayerId)) diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index 4a78e2490c1cb719bdd7c188d6602ed884982fb1..c96c9c7e6f97fe76dd6a0840b795a16e9a7072b8 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -49,6 +49,9 @@ Slice::Slice() : m_iPOC ( 0 ) , m_iLastIDR ( 0 ) +#if JVET_R0041 +, m_PrevGDRInSameLayerPOC ( 0 ) +#endif , m_iAssociatedIRAP ( 0 ) , m_iAssociatedIRAPType ( NAL_UNIT_INVALID ) , m_rpl0Idx ( -1 ) @@ -704,36 +707,55 @@ void Slice::checkRPL(const ReferencePictureList* pRPL0, const ReferencePictureLi } refPicDecodingOrderNumber = pcRefPic->getDecodingOrderNumber(); +#if !JVET_R0041 // Checking this: "When the current picture follows an IRAP picture having the same value of nuh_layer_id in both decoding order - // and output order, there shall be no picture referred to by an active entry in RefPicList[ 0 ] or RefPicList[ 1 ] that + // and output order, there shall be no picture referred to by an active entry in RefPicList[ 0 ] or RefPicList[ 1 ] that // precedes that IRAP picture in output order or decoding order." +#endif #if JVET_R0267_IDR_RPL if (m_eNalUnitType == NAL_UNIT_CODED_SLICE_CRA || m_eNalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_eNalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP ) #else if (m_eNalUnitType == NAL_UNIT_CODED_SLICE_CRA) #endif { +#if JVET_R0041 + CHECK(refPicPOC < irapPOC || refPicDecodingOrderNumber < associatedIRAPDecodingOrderNumber, "When the current picture follows an IRAP picture having the same value of nuh_layer_id in both decoding order and output order, there shall be no picture referred to by an active entry in RefPicList[ 0 ] or RefPicList[ 1 ] that precedes that IRAP picture in output order or decoding order."); +#else CHECK(refPicPOC < irapPOC || refPicDecodingOrderNumber < associatedIRAPDecodingOrderNumber, "IRAP picture detected that violate the rule that no entry in RefPicList[] shall precede, in output order or decoding order, any preceding IRAP picture in decoding order (when present)."); +#endif } +#if JVET_R0041 + if (irapPOC < getPOC() && !fieldSeqFlag) + { + CHECK(refPicPOC < irapPOC || refPicDecodingOrderNumber < associatedIRAPDecodingOrderNumber, "When the current picture follows an IRAP picture having the same value of nuh_layer_id and the leading pictures, if any, associated with that IRAP picture, in both decoding order and output order, there shall be no picture referred to by an entry in RefPicList[ 0 ] or RefPicList[ 1 ] that precedes that IRAP picture in output order or decoding order."); + } +#else // Checking this: "When the current picture is a trailing picture that follows in both decoding orderand output order one // or more leading pictures associated with the same IRAP picture, if any, there shall be no picture referred to by an // entry in RefPicList[0] or RefPicList[1] that precedes the associated IRAP picture in output order or decoding order" // Note that when not in field coding, we know that all leading pictures of an IRAP precedes all trailing pictures of the // same IRAP picture. - if (currentPictureIsTrailing && !fieldSeqFlag) // + if (currentPictureIsTrailing && !fieldSeqFlag) { CHECK(refPicPOC < irapPOC || refPicDecodingOrderNumber < associatedIRAPDecodingOrderNumber, "Trailing picture detected that follows one or more leading pictures, if any, and violates the rule that no entry in RefPicList[] shall precede the associated IRAP picture in output order or decoding order."); } - +#endif if (i < numActiveEntriesL0) { +#if JVET_R0041 + if (irapPOC < getPOC()) + { + CHECK(refPicPOC < irapPOC || refPicDecodingOrderNumber < associatedIRAPDecodingOrderNumber, "When the current picture follows an IRAP picture having the same value of nuh_layer_id in both decoding order and output order, there shall be no picture referred to by an active entry in RefPicList[ 0 ] or RefPicList[ 1 ] that precedes that IRAP picture in output order or decoding order."); + } +#else // Checking this "When the current picture is a trailing picture, there shall be no picture referred to by an active // entry in RefPicList[ 0 ] or RefPicList[ 1 ] that precedes the associated IRAP picture in output order or decoding order" if (currentPictureIsTrailing) { CHECK(refPicPOC < irapPOC || refPicDecodingOrderNumber < associatedIRAPDecodingOrderNumber, "Trailing picture detected that violate the rule that no active entry in RefPicList[] shall precede the associated IRAP picture in output order or decoding order"); } +#endif // Checking this: "When the current picture is a RADL picture, there shall be no active entry in RefPicList[ 0 ] or // RefPicList[ 1 ] that is any of the following: A picture that precedes the associated IRAP picture in decoding order" @@ -771,21 +793,43 @@ void Slice::checkRPL(const ReferencePictureList* pRPL0, const ReferencePictureLi } refPicDecodingOrderNumber = pcRefPic->getDecodingOrderNumber(); +#if JVET_R0041 + if ((m_eNalUnitType == NAL_UNIT_CODED_SLICE_CRA || m_eNalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_eNalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP)) + { + CHECK(refPicPOC < irapPOC || refPicDecodingOrderNumber < associatedIRAPDecodingOrderNumber, "When the current picture follows an IRAP picture having the same value of nuh_layer_id in both decoding order and output order, there shall be no picture referred to by an active entry in RefPicList[ 0 ] or RefPicList[ 1 ] that precedes that IRAP picture in output order or decoding order."); + } +#else if (m_eNalUnitType == NAL_UNIT_CODED_SLICE_CRA) { CHECK(refPicPOC < irapPOC || refPicDecodingOrderNumber < associatedIRAPDecodingOrderNumber, "CRA picture detected that violate the rule that no entry in RefPicList[] shall precede, in output order or decoding order, any preceding IRAP picture in decoding order (when present)."); } +#endif + +#if JVET_R0041 + if (irapPOC < getPOC() && !fieldSeqFlag) + { + CHECK(refPicPOC < irapPOC || refPicDecodingOrderNumber < associatedIRAPDecodingOrderNumber, "When the current picture follows an IRAP picture having the same value of nuh_layer_id and the leading pictures, if any, associated with that IRAP picture, in both decoding order and output order, there shall be no picture referred to by an entry in RefPicList[ 0 ] or RefPicList[ 1 ] that precedes that IRAP picture in output order or decoding order."); + } +#else if (currentPictureIsTrailing && !fieldSeqFlag) { CHECK(refPicPOC < irapPOC || refPicDecodingOrderNumber < associatedIRAPDecodingOrderNumber, "Trailing picture detected that follows one or more leading pictures, if any, and violates the rule that no entry in RefPicList[] shall precede the associated IRAP picture in output order or decoding order."); } +#endif if (i < numActiveEntriesL1) { +#if JVET_R0041 + if (irapPOC < getPOC()) + { + CHECK(refPicPOC < irapPOC || refPicDecodingOrderNumber < associatedIRAPDecodingOrderNumber, "When the current picture follows an IRAP picture having the same value of nuh_layer_id in both decoding order and output order, there shall be no picture referred to by an active entry in RefPicList[ 0 ] or RefPicList[ 1 ] that precedes that IRAP picture in output order or decoding order."); + } +#else if (currentPictureIsTrailing) { CHECK(refPicPOC < irapPOC || refPicDecodingOrderNumber < associatedIRAPDecodingOrderNumber, "Trailing picture detected that violate the rule that no active entry in RefPicList[] shall precede the associated IRAP picture in output order or decoding order"); } +#endif if (m_eNalUnitType == NAL_UNIT_CODED_SLICE_RADL) { CHECK(refPicDecodingOrderNumber < associatedIRAPDecodingOrderNumber, "RADL picture detected that violate the rule that no active entry in RefPicList[] shall precede the associated IRAP picture in decoding order"); @@ -1142,8 +1186,13 @@ void Slice::checkLeadingPictureRestrictions(PicList& rcListPic, const PPS& pps) } } +#if JVET_R0041 + // When a picture is not a leading picture, it shall not be a RADL or RASL picture. + if (this->getAssociatedIRAPPOC() <= this->getPOC()) +#else // When a picture is a trailing picture, it shall not be a RADL or RASL picture. if(this->getAssociatedIRAPPOC() < this->getPOC()) +#endif { //check this only when mixed_nalu_types_in_pic_flag is equal to 0 if (pps.getMixedNaluTypesInPicFlag() == 0) @@ -1173,7 +1222,11 @@ void Slice::checkLeadingPictureRestrictions(PicList& rcListPic, const PPS& pps) // loop through all pictures in the reference picture buffer PicList::iterator iterPic = rcListPic.begin(); +#if JVET_R0041 + int numNonLPFound = 0; +#else int numLeadingPicsFound = 0; +#endif while ( iterPic != rcListPic.end()) { Picture* pcPic = *(iterPic++); @@ -1187,10 +1240,18 @@ void Slice::checkLeadingPictureRestrictions(PicList& rcListPic, const PPS& pps) } const Slice* pcSlice = pcPic->slices[0]; +#if JVET_R0041 + // Any picture, with nuh_layer_id equal to a particular value layerId, that precedes an IRAP picture with + // nuh_layer_id equal to layerId in decoding order shall precede the IRAP picture in output order. + // (Note that any picture following in output order would be present in the DPB) + if (pcSlice->getPicHeader()->getPicOutputFlag() == 1 && !this->getPicHeader()->getNoOutputOfPriorPicsFlag() + && pcPic->layerId == this->m_nuhLayerId) +#else // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture // in decoding order shall precede the IRAP picture in output order. // (Note that any picture following in output order would be present in the DPB) if(pcSlice->getPicHeader()->getPicOutputFlag() == 1 && !this->getPicHeader()->getNoOutputOfPriorPicsFlag()) +#endif { if (nalUnitType == NAL_UNIT_CODED_SLICE_CRA || nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || @@ -1200,10 +1261,17 @@ void Slice::checkLeadingPictureRestrictions(PicList& rcListPic, const PPS& pps) } } +#if JVET_R0041 + // Any picture, with nuh_layer_id equal to a particular value layerId, that precedes an IRAP picture with + // nuh_layer_id equal to layerId in decoding order shall precede any RADL picture associated with the IRAP + // picture in output order. + if (pcSlice->getPicHeader()->getPicOutputFlag() == 1 && pcPic->layerId == this->m_nuhLayerId) +#else // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture // in decoding order shall precede any RADL picture associated with the IRAP // picture in output order. if(pcSlice->getPicHeader()->getPicOutputFlag() == 1) +#endif { if (nalUnitType == NAL_UNIT_CODED_SLICE_RADL) { @@ -1219,8 +1287,40 @@ void Slice::checkLeadingPictureRestrictions(PicList& rcListPic, const PPS& pps) } } - // When a picture is a leading picture, it shall precede, in decoding order, - // all trailing pictures that are associated with the same IRAP picture. +#if JVET_R0041 + // Any picture, with nuh_layer_id equal to a particular value layerId, that precedes a recovery point picture + // with nuh_layer_id equal to layerId in decoding order shall precede the recovery point picture in output order. + if (pcSlice->getPicHeader()->getPicOutputFlag() == 1 && !this->getPicHeader()->getNoOutputBeforeRecoveryFlag() + && pcPic->layerId == this->m_nuhLayerId) + { + if (this->getPOC() == this->getPicHeader()->getRecoveryPocCnt() + this->getPrevGDRInSameLayerPOC()) + { + CHECK(pcPic->poc >= this->getPOC(), "Invalid POC"); + } + } +#endif + +#if JVET_R0041 + // If field_seq_flag is equal to 0 and the current picture, with nuh_layer_id equal to a particular value layerId, is a leading picture + // associated with an IRAP picture, it shall precede, in decoding order, all non-leading pictures that are associated with the same + // IRAP picture.Otherwise, let picA and picB be the first and the last leading pictures, in decoding order, associated with an IRAP + // picture, respectively, there shall be at most one non-leading picture with nuh_layer_id equal to layerId preceding picA in decoding + // order, and there shall be no non-leading picture with nuh_layer_id equal to layerId between picA and picB in decoding order. + if ((nalUnitType == NAL_UNIT_CODED_SLICE_RASL || nalUnitType == NAL_UNIT_CODED_SLICE_RADL) && + (pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL && pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL)) + { + if (pcSlice->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC() && pcPic->layerId == this->m_nuhLayerId) + { + numNonLPFound++; + int limitNonLP = 0; + if (pcSlice->getSPS()->getFieldSeqFlag()) + limitNonLP = 1; + CHECK(pcPic->poc > this->getAssociatedIRAPPOC() && numNonLPFound > limitNonLP, "Invalid POC"); + } + } +#else + // When a picture, with nuh_layer_id equal to a particular value layerId, is a leading picture, it shall precede, in decoding order, + // all non-leading pictures that are associated with the same IRAP picture. if ((nalUnitType == NAL_UNIT_CODED_SLICE_RASL || nalUnitType == NAL_UNIT_CODED_SLICE_RADL) && (pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL && pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL) ) { @@ -1233,6 +1333,7 @@ void Slice::checkLeadingPictureRestrictions(PicList& rcListPic, const PPS& pps) CHECK(pcPic->poc > this->getAssociatedIRAPPOC() && numLeadingPicsFound > limitNonLP, "Invalid POC"); } } +#endif // Any RASL picture associated with a CRA or BLA picture shall precede any // RADL picture associated with the CRA or BLA picture in output order @@ -1248,8 +1349,13 @@ void Slice::checkLeadingPictureRestrictions(PicList& rcListPic, const PPS& pps) } } +#if JVET_R0041 + // Any RASL picture, with nuh_layer_id equal to a particular value layerId, associated with a CRA picture shall follow, + // in output order, any IRAP or GDR picture with nuh_layer_id equal to layerId that precedes the CRA picture in decoding order. +#else // Any RASL picture associated with a CRA picture shall follow, in output // order, any IRAP picture that precedes the CRA picture in decoding order. +#endif if (nalUnitType == NAL_UNIT_CODED_SLICE_RASL) { if(this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) @@ -1258,7 +1364,13 @@ void Slice::checkLeadingPictureRestrictions(PicList& rcListPic, const PPS& pps) ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || +#if JVET_R0041 + pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA || + pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR) && + pcPic->layerId == this->m_nuhLayerId) +#else pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) +#endif { CHECK(this->getPOC() <= pcSlice->getPOC(), "Invalid POC"); } diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index 3c6b66fb7aad65c166d741955702c1a95c4f03a2..063484d7c7a6b47d87c074cda9d241aaf8c4bee7 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -2618,6 +2618,9 @@ private: bool m_saoEnabledFlag[MAX_NUM_CHANNEL_TYPE]; int m_iPOC; int m_iLastIDR; +#if JVET_R0041 + int m_PrevGDRInSameLayerPOC; //< the previous GDR in the same layer +#endif int m_iAssociatedIRAP; NalUnitType m_iAssociatedIRAPType; bool m_enableDRAPSEI; @@ -2767,6 +2770,10 @@ public: int getRPL1idx() const { return m_rpl1Idx; } void setLastIDR(int iIDRPOC) { m_iLastIDR = iIDRPOC; } int getLastIDR() const { return m_iLastIDR; } +#if JVET_R0041 + void setPrevGDRInSameLayerPOC(int iPrevGDRInSameLayerPOC) { m_PrevGDRInSameLayerPOC = iPrevGDRInSameLayerPOC; } + int getPrevGDRInSameLayerPOC() const { return m_PrevGDRInSameLayerPOC; } +#endif void setAssociatedIRAPPOC(int iAssociatedIRAPPOC) { m_iAssociatedIRAP = iAssociatedIRAPPOC; } int getAssociatedIRAPPOC() const { return m_iAssociatedIRAP; } void setAssociatedIRAPType(NalUnitType associatedIRAPType) { m_iAssociatedIRAPType = associatedIRAPType; } diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 1e61cb22d9aecabdddbefb9218d1bc8dd5f18351..a6fe87cf98b7775d80fe13a0cce614527a7f3643 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -51,6 +51,8 @@ #include <cassert> //########### place macros to be removed in next cycle below this line ############### +#define JVET_R0041 1 // JVET-R0041: Picture types related constraints + #define JVET_R0064 1 // JVET-R0064, aspect 2: Move the flag scaling_matrix_for_lfnst_disabled_flag from the scaling_list_data( ) syntax to the SPS. #define RETRAIN_CABAC 1 // CABAC initial values retrained on VTM-9.0rc1 diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index 04faab51b41a0131cb23d0338dc598afb5a827d1..b987325e07ddff8844cecf0f7c2b7c91404840d8 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -392,10 +392,19 @@ DecLib::DecLib() : m_iMaxRefPicNum(0) , m_isFirstGeneralHrd(true) , m_prevGeneralHrdParams() +#if JVET_R0041 + , m_associatedIRAPDecodingOrderNumber{ 0 } +#else , m_associatedIRAPType(NAL_UNIT_INVALID) , m_associatedIRAPDecodingOrderNumber(0) +#endif , m_decodingOrderCounter(0) +#if JVET_R0041 + , m_PrevGDRInSameLayerPOC{ 0 } + , m_pocCRA{ 0 } +#else , m_pocCRA(0) +#endif , m_pocRandomAccess(MAX_INT) , m_lastRasPoc(MAX_INT) , m_cListPic() @@ -427,7 +436,11 @@ DecLib::DecLib() , m_skippedPOC(0) , m_lastPOCNoOutputPriorPics(-1) , m_isNoOutputPriorPics(false) +#if JVET_R0041 + , m_lastNoOutputBeforeRecoveryFlag{ false } +#else , m_lastNoOutputBeforeRecoveryFlag( false ) +#endif , m_sliceLmcsApsId(-1) , m_pDecodedSEIOutputStream(NULL) , m_decodedPictureHashSEIEnabled(false) @@ -444,6 +457,12 @@ DecLib::DecLib() #if ENABLE_SIMD_OPT_BUFFER g_pelBufOP.initPelBufOpsX86(); #endif +#if JVET_R0041 + for (int i = 0; i < MAX_VPS_LAYERS; i++) + { + m_associatedIRAPType[i] = NAL_UNIT_INVALID; + } +#endif } DecLib::~DecLib() @@ -1853,8 +1872,14 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl xUpdatePreviousTid0POC(m_apcSlicePilot); +#if JVET_R0041 + m_apcSlicePilot->setPrevGDRInSameLayerPOC(m_PrevGDRInSameLayerPOC[nalu.m_nuhLayerId]); + m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA[nalu.m_nuhLayerId]); + m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType[nalu.m_nuhLayerId]); +#else m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA); m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); +#endif if( m_apcSlicePilot->getRapPicFlag() || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR ) { @@ -1891,7 +1916,11 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR) { +#if JVET_R0041 + m_lastNoOutputBeforeRecoveryFlag[nalu.m_nuhLayerId] = m_picHeader.getNoOutputBeforeRecoveryFlag(); +#else m_lastNoOutputBeforeRecoveryFlag = m_picHeader.getNoOutputBeforeRecoveryFlag(); +#endif } if( m_picHeader.getNoOutputOfPriorPicsFlag() ) @@ -1908,7 +1937,11 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl //For inference of PicOutputFlag if( !pps->getMixedNaluTypesInPicFlag() && ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL ) ) { +#if JVET_R0041 + if( m_lastNoOutputBeforeRecoveryFlag[nalu.m_nuhLayerId] ) +#else if( m_lastNoOutputBeforeRecoveryFlag ) +#endif { m_picHeader.setPicOutputFlag(false); } @@ -1931,7 +1964,11 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl } //Reset POC MSB when CRA or GDR has NoOutputBeforeRecoveryFlag equal to 1 +#if JVET_R0041 + if (!pps->getMixedNaluTypesInPicFlag() && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR) && m_lastNoOutputBeforeRecoveryFlag[nalu.m_nuhLayerId]) +#else if( !pps->getMixedNaluTypesInPicFlag() && ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR ) && m_lastNoOutputBeforeRecoveryFlag ) +#endif { int iMaxPOClsb = 1 << sps->getBitsForPOC(); m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) ); @@ -2107,9 +2144,17 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl } #endif } +#if JVET_R0041 + pcSlice->checkCRA(pcSlice->getRPL0(), pcSlice->getRPL1(), m_pocCRA[nalu.m_nuhLayerId], m_cListPic); +#else pcSlice->checkCRA(pcSlice->getRPL0(), pcSlice->getRPL1(), m_pocCRA, m_cListPic); +#endif pcSlice->constructRefPicList(m_cListPic); +#if JVET_R0041 + pcSlice->checkRPL(pcSlice->getRPL0(), pcSlice->getRPL1(), m_associatedIRAPDecodingOrderNumber[nalu.m_nuhLayerId], m_cListPic); +#else pcSlice->checkRPL(pcSlice->getRPL0(), pcSlice->getRPL1(), m_associatedIRAPDecodingOrderNumber, m_cListPic); +#endif pcSlice->checkSTSA(m_cListPic); #if JVET_R0058 if (m_pcPic->cs->vps && !m_pcPic->cs->vps->getIndependentLayerFlag(m_pcPic->cs->vps->getGeneralLayerIdx(nalu.m_nuhLayerId)) && m_pcPic->cs->pps->getNumSubPics() > 1) @@ -2437,14 +2482,33 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl return false; } +#if JVET_R0041 +void DecLib::updatePrevGDRInSameLayer() +{ + const NalUnitType pictureType = m_pcPic->getPictureType(); + + if (pictureType == NAL_UNIT_CODED_SLICE_GDR) + { + m_PrevGDRInSameLayerPOC[m_pcPic->layerId] = m_pcPic->getPOC(); + } +} +#endif + void DecLib::updateAssociatedIRAP() { const NalUnitType pictureType = m_pcPic->getPictureType(); + if (pictureType == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pictureType == NAL_UNIT_CODED_SLICE_IDR_N_LP || pictureType == NAL_UNIT_CODED_SLICE_CRA) { +#if JVET_R0041 + m_associatedIRAPDecodingOrderNumber[m_pcPic->layerId] = m_pcPic->getDecodingOrderNumber(); + m_pocCRA[m_pcPic->layerId] = m_pcPic->getPOC(); + m_associatedIRAPType[m_pcPic->layerId] = pictureType; +#else m_associatedIRAPDecodingOrderNumber = m_pcPic->getDecodingOrderNumber(); m_pocCRA = m_pcPic->getPOC(); m_associatedIRAPType = pictureType; +#endif } } @@ -2595,8 +2659,14 @@ bool DecLib::decode(InputNALUnit& nalu, int& iSkipFrame, int& iPOCLastDisplay, i return ret; case NAL_UNIT_EOS: +#if JVET_R0041 + m_associatedIRAPType[nalu.m_nuhLayerId] = NAL_UNIT_INVALID; + m_pocCRA[nalu.m_nuhLayerId] = 0; + m_PrevGDRInSameLayerPOC[nalu.m_nuhLayerId] = 0; +#else m_associatedIRAPType = NAL_UNIT_INVALID; m_pocCRA = 0; +#endif m_pocRandomAccess = MAX_INT; m_prevLayerID = MAX_INT; m_prevPOC = MAX_INT; diff --git a/source/Lib/DecoderLib/DecLib.h b/source/Lib/DecoderLib/DecLib.h index f7a1b0cf268c4f6c69563f6a1ff7aee37ae57a9e..7ee8d5c06c73f7e2477ead41d15252147b9f6565 100644 --- a/source/Lib/DecoderLib/DecLib.h +++ b/source/Lib/DecoderLib/DecLib.h @@ -72,10 +72,19 @@ private: bool m_isFirstGeneralHrd; GeneralHrdParams m_prevGeneralHrdParams; +#if JVET_R0041 + int m_PrevGDRInSameLayerPOC[MAX_VPS_LAYERS]; ///< POC number of the latest GDR picture + NalUnitType m_associatedIRAPType[MAX_VPS_LAYERS]; ///< NAL unit type of the previous IRAP picture + int m_pocCRA[MAX_VPS_LAYERS]; ///< POC number of the previous CRA picture + int m_associatedIRAPDecodingOrderNumber[MAX_VPS_LAYERS]; ///< Decoding order number of the previous IRAP picture +#else NalUnitType m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture int m_associatedIRAPDecodingOrderNumber; ///< Decoding order number of the associated IRAP picture +#endif int m_decodingOrderCounter; +#if !JVET_R0041 int m_pocCRA; ///< POC number of the latest CRA picture +#endif int m_pocRandomAccess; ///< POC number of the random access point (the first IDR or CRA picture) int m_lastRasPoc; @@ -121,7 +130,11 @@ private: int m_skippedPOC; int m_lastPOCNoOutputPriorPics; bool m_isNoOutputPriorPics; +#if JVET_R0041 + bool m_lastNoOutputBeforeRecoveryFlag[MAX_VPS_LAYERS]; //value of variable NoOutputBeforeRecoveryFlag of the assocated CRA/GDR pic +#else bool m_lastNoOutputBeforeRecoveryFlag; //value of variable NoOutputBeforeRecoveryFlag of the last CRA / GDR pic +#endif int m_sliceLmcsApsId; //value of LmcsApsId, constraint is same id for all slices in one picture std::ostream *m_pDecodedSEIOutputStream; @@ -195,6 +208,9 @@ public: void checkNoOutputPriorPics (PicList* rpcListPic); void checkNalUnitConstraints( uint32_t naluType ); void updateAssociatedIRAP(); +#if JVET_R0041 + void updatePrevGDRInSameLayer(); +#endif bool getNoOutputPriorPicsFlag () const { return m_isNoOutputPriorPics; } diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index e6ef5219d886923866c582a775a060d46c8e7aa7..e8b53be40eb13b4c5ff29c493172c5bfece35cfd 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -105,8 +105,16 @@ EncGOP::EncGOP() ::memset(m_lastBPSEI, 0, sizeof(m_lastBPSEI)); m_rapWithLeading = false; m_bufferingPeriodSEIPresentInAU = false; +#if JVET_R0041 + for (int i = 0; i < MAX_VPS_LAYERS; i++) + { + m_associatedIRAPType[i] = NAL_UNIT_CODED_SLICE_IDR_N_LP; + } + ::memset(m_associatedIRAPPOC, 0, sizeof(m_associatedIRAPPOC)); +#else m_associatedIRAPType = NAL_UNIT_CODED_SLICE_IDR_N_LP; m_associatedIRAPPOC = 0; +#endif #if W0038_DB_OPT m_pcDeblockingTempPicYuv = NULL; #endif @@ -2086,11 +2094,21 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) // IRAP picture { +#if JVET_R0041 + m_associatedIRAPType[pcPic->layerId] = pcSlice->getNalUnitType(); + m_associatedIRAPPOC[pcPic->layerId] = pocCurr; +#else m_associatedIRAPType = pcSlice->getNalUnitType(); m_associatedIRAPPOC = pocCurr; +#endif } +#if JVET_R0041 + pcSlice->setAssociatedIRAPType(m_associatedIRAPType[pcPic->layerId]); + pcSlice->setAssociatedIRAPPOC(m_associatedIRAPPOC[pcPic->layerId]); +#else pcSlice->setAssociatedIRAPType(m_associatedIRAPType); pcSlice->setAssociatedIRAPPOC(m_associatedIRAPPOC); +#endif } pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic, m_pcCfg->getEfficientFieldIRAPEnabled()); @@ -2124,11 +2142,21 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) // IRAP picture { +#if JVET_R0041 + m_associatedIRAPType[pcPic->layerId] = pcSlice->getNalUnitType(); + m_associatedIRAPPOC[pcPic->layerId] = pocCurr; +#else m_associatedIRAPType = pcSlice->getNalUnitType(); m_associatedIRAPPOC = pocCurr; +#endif } +#if JVET_R0041 + pcSlice->setAssociatedIRAPType(m_associatedIRAPType[pcPic->layerId]); + pcSlice->setAssociatedIRAPPOC(m_associatedIRAPPOC[pcPic->layerId]); +#else pcSlice->setAssociatedIRAPType(m_associatedIRAPType); pcSlice->setAssociatedIRAPPOC(m_associatedIRAPPOC); +#endif } pcSlice->setEnableDRAPSEI(m_pcEncLib->getDependentRAPIndicationSEIEnabled()); diff --git a/source/Lib/EncoderLib/EncGOP.h b/source/Lib/EncoderLib/EncGOP.h index 26b890e196b12d55925a1b648131f2dfb15b021f..97ace412087c07cd5bcda5ba10c9629d5eb7525c 100644 --- a/source/Lib/EncoderLib/EncGOP.h +++ b/source/Lib/EncoderLib/EncGOP.h @@ -161,8 +161,13 @@ private: // clean decoding refresh bool m_bRefreshPending; int m_pocCRA; +#if JVET_R0041 + NalUnitType m_associatedIRAPType[MAX_VPS_LAYERS]; + int m_associatedIRAPPOC[MAX_VPS_LAYERS]; +#else NalUnitType m_associatedIRAPType; int m_associatedIRAPPOC; +#endif std::vector<int> m_vRVM_RP; uint32_t m_lastBPSEI[MAX_TLAYER];