From d97657388d89fea7a69836c9300e9da62397e561 Mon Sep 17 00:00:00 2001 From: biaowang <biao.wang@huawei.com> Date: Fri, 6 Mar 2020 16:27:09 +0100 Subject: [PATCH] add cleanup operations for vector --- source/Lib/DecoderLib/DecLib.cpp | 39 ++++++++++++++++---------------- source/Lib/DecoderLib/DecLib.h | 2 +- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index ab9179fa15..2a2cfd6d2a 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -2152,7 +2152,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl naluInfo.m_firstCTUinSlice = pcSlice->getFirstCtuRsAddrInSlice(); naluInfo.m_POC = pcSlice->getPOC(); xCheckMixedNalUnit(pcSlice, sps, nalu); - m_nalUnitInfo.push_back(naluInfo); + m_nalUnitInfo[naluInfo.m_nuhLayerId].push_back(naluInfo); #endif SEIMessages drapSEIs = getSeisByType(m_pcPic->SEIs, SEI::DEPENDENT_RAP_INDICATION ); if (!drapSEIs.empty()) @@ -2590,18 +2590,17 @@ void DecLib::xCheckMixedNalUnit(Slice* pcSlice, SPS *sps, InputNALUnit &nalu) else { // check reference list constraint - if (!m_nalUnitInfo.empty()) + if (!m_nalUnitInfo[nalu.m_nuhLayerId].empty()) { //find out the closest IRAP nal unit that are in the same layer and in the corresponding subpicture NalUnitInfo *latestIRAPNalUnit = nullptr; - int size = (int)m_nalUnitInfo.size(); + int size = (int)m_nalUnitInfo[nalu.m_nuhLayerId].size(); int naluIdx; for (naluIdx = size - 1; naluIdx >= 0; naluIdx--) { - NalUnitInfo *iterNalu = &m_nalUnitInfo[naluIdx]; - bool isTheSameLayer = iterNalu->m_nuhLayerId == nalu.m_nuhLayerId; + NalUnitInfo *iterNalu = &m_nalUnitInfo[nalu.m_nuhLayerId][naluIdx]; bool isIRAPSlice = iterNalu->m_nalUnitType >= NAL_UNIT_CODED_SLICE_IDR_W_RADL && iterNalu->m_nalUnitType <= NAL_UNIT_CODED_SLICE_CRA; - if (isTheSameLayer && isIRAPSlice) + if (isIRAPSlice) { latestIRAPNalUnit = iterNalu; break; @@ -2609,7 +2608,9 @@ void DecLib::xCheckMixedNalUnit(Slice* pcSlice, SPS *sps, InputNALUnit &nalu) } if (latestIRAPNalUnit != nullptr) { - // only check the current slice, as previous slice have been checked + // clear the nalu unit before the latest IRAP slice + m_nalUnitInfo[nalu.m_nuhLayerId].erase(m_nalUnitInfo[nalu.m_nuhLayerId].begin(), m_nalUnitInfo[nalu.m_nuhLayerId].begin() + naluIdx); + const unsigned ctuRsAddrIRAP = latestIRAPNalUnit->m_firstCTUinSlice; const unsigned ctuXPosInCtusIRAP = ctuRsAddrIRAP % pcSlice->getPPS()->getPicWidthInCtu(); const unsigned ctuYPosInCtusIRAP = ctuRsAddrIRAP / pcSlice->getPPS()->getPicWidthInCtu(); @@ -2621,27 +2622,27 @@ void DecLib::xCheckMixedNalUnit(Slice* pcSlice, SPS *sps, InputNALUnit &nalu) for (int refIdx = 0; refIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0); refIdx++) { int POC = pcSlice->getRefPOC(REF_PIC_LIST_0, refIdx); - for (int i = 0; i < naluIdx; i++) + bool notInPOCAfterIRAP = true; + // check all ref pics of the current slice are from poc after the IRAP slice + for (auto iterNalu : m_nalUnitInfo[nalu.m_nuhLayerId]) { - NalUnitInfo *iterNalu = &m_nalUnitInfo[i]; - if (iterNalu->m_nuhLayerId == nalu.m_nuhLayerId) - { - CHECK(POC == iterNalu->m_POC, "preIRAP picture shall not be used as the reference picture of a slice after the IRAP picture"); - } + if (POC == iterNalu.m_POC) + notInPOCAfterIRAP = false; } + CHECK(notInPOCAfterIRAP, "all reference pictures of a slice after the IRAP picture are from pictures after the IRAP"); } // check RefPicList[1] for (int refIdx = 0; refIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1); refIdx++) { int POC = pcSlice->getRefPOC(REF_PIC_LIST_1, refIdx); - for (int i = 0; i < naluIdx; i++) + bool notInPOCAfterIRAP = true; + // check all ref pics of the current slice are from poc after the IRAP slice + for (auto iterNalu : m_nalUnitInfo[nalu.m_nuhLayerId]) { - NalUnitInfo *iterNalu = &m_nalUnitInfo[i]; - if (iterNalu->m_nuhLayerId == nalu.m_nuhLayerId) - { - CHECK(POC == iterNalu->m_POC, "preIRAP picture shall not be used as the reference picture of a slice after the IRAP picture"); - } + if (POC == iterNalu.m_POC) + notInPOCAfterIRAP = false; } + CHECK(notInPOCAfterIRAP, "all reference pictures of a slice after the IRAP picture are from pictures after the IRAP"); } } } diff --git a/source/Lib/DecoderLib/DecLib.h b/source/Lib/DecoderLib/DecLib.h index 160512cce1..3c85593eb9 100644 --- a/source/Lib/DecoderLib/DecLib.h +++ b/source/Lib/DecoderLib/DecLib.h @@ -153,7 +153,7 @@ private: uint32_t m_firstCTUinSlice; /// the first CTU in slice, specified with raster scan order ctu address int m_POC; /// the picture order }; - std::vector<NalUnitInfo> m_nalUnitInfo; + std::vector<NalUnitInfo> m_nalUnitInfo[MAX_VPS_LAYERS]; #endif std::vector<int> m_accessUnitApsNals; #if JVET_P0125_ASPECT_TID_LAYER_ID_NUH -- GitLab