diff --git a/source/App/BitstreamExtractorApp/BitstreamExtractorApp.cpp b/source/App/BitstreamExtractorApp/BitstreamExtractorApp.cpp index ccc3cdee9fa7752bc6171280fd43eba42fedf3e8..6b7c117e6f08e1c035164f392f858bd261549b52 100644 --- a/source/App/BitstreamExtractorApp/BitstreamExtractorApp.cpp +++ b/source/App/BitstreamExtractorApp/BitstreamExtractorApp.cpp @@ -443,21 +443,21 @@ bool BitstreamExtractorApp::xCheckSEIsSubPicture(SEIMessages& SEIs, InputNALUnit CHECK ( scalableNestingSEIs.size() > 1, "There shall be only one Scalable Nesting SEI in one NAL unit" ); CHECK ( scalableNestingSEIs.size() != SEIs.size(), "Scalable Nesting SEI shall not be in the same NAL unit as other SEIs" ); // check, if the scalable nesting SEI applies to the target subpicture - SEIScalableNesting *sei = (SEIScalableNesting*) scalableNestingSEIs.front(); + auto sn = (SEIScalableNesting*) scalableNestingSEIs.front(); - if (sei->subpicId.empty()) + if (sn->subpicId.empty()) { // does not apply to a subpicture -> remove return false; } - if (std::find(sei->subpicId.begin(), sei->subpicId.end(), subpicId) != sei->subpicId.end()) + if (std::find(sn->subpicId.begin(), sn->subpicId.end(), subpicId) != sn->subpicId.end()) { // C.7 step 7.c - if (!sei->olsIdx.empty() || vps->getNumLayersInOls(m_targetOlsIdx) == 1) + if (!sn->olsIdx.empty() || vps->getNumLayersInOls(m_targetOlsIdx) == 1) { // applies to target subpicture -> extract OutputNALUnit outNalu( nalu.m_nalUnitType, nalu.m_nuhLayerId, nalu.m_temporalId ); - m_seiWriter.writeSEImessages(outNalu.m_bitstream, sei->m_nestedSEIs, m_hrd, false, nalu.m_temporalId); + m_seiWriter.writeSEImessages(outNalu.m_bitstream, sn->m_nestedSEIs, m_hrd, false, nalu.m_temporalId); NALUnitEBSP naluWithHeader(outNalu); writeAnnexBNalUnit(out, naluWithHeader, true); return false; @@ -812,22 +812,20 @@ uint32_t BitstreamExtractorApp::decode() // remove unqualified scalable nesting SEI if (sei->payloadType() == SEI::PayloadType::SCALABLE_NESTING) { - SEIScalableNesting *seiNesting = (SEIScalableNesting *)sei; - if (!seiNesting->olsIdx.empty()) + auto sn = (SEIScalableNesting*) sei; + if (!sn->olsIdx.empty()) { bool targetOlsIdxInNestingAppliedOls = - std::find(seiNesting->olsIdx.begin(), seiNesting->olsIdx.end(), m_targetOlsIdx) - != seiNesting->olsIdx.end(); + std::find(sn->olsIdx.begin(), sn->olsIdx.end(), m_targetOlsIdx) != sn->olsIdx.end(); writeInpuNalUnitToStream &= targetOlsIdxInNestingAppliedOls; } // C.6 step 9.c - if (writeInpuNalUnitToStream && !targetOlsIncludeAllVclLayers && seiNesting->subpicId.empty()) + if (writeInpuNalUnitToStream && !targetOlsIncludeAllVclLayers && sn->subpicId.empty()) { - if (!seiNesting->olsIdx.empty() || vps->getNumLayersInOls(m_targetOlsIdx) == 1) + if (!sn->olsIdx.empty() || vps->getNumLayersInOls(m_targetOlsIdx) == 1) { OutputNALUnit outNalu(nalu.m_nalUnitType, nalu.m_nuhLayerId, nalu.m_temporalId); - m_seiWriter.writeSEImessages(outNalu.m_bitstream, seiNesting->m_nestedSEIs, m_hrd, false, - nalu.m_temporalId); + m_seiWriter.writeSEImessages(outNalu.m_bitstream, sn->m_nestedSEIs, m_hrd, false, nalu.m_temporalId); NALUnitEBSP naluWithHeader(outNalu); writeAnnexBNalUnit(bitstreamFileOut, naluWithHeader, true); writeInpuNalUnitToStream = false; diff --git a/source/App/SubpicMergeApp/SubpicMergeApp.cpp b/source/App/SubpicMergeApp/SubpicMergeApp.cpp index 2b678e4d172909f74f806eca72f1e2b3f33914c6..47cfb99902de8b1f29dd15f6b563cd97f9624e2e 100644 --- a/source/App/SubpicMergeApp/SubpicMergeApp.cpp +++ b/source/App/SubpicMergeApp/SubpicMergeApp.cpp @@ -1070,13 +1070,13 @@ void SubpicMergeApp::generateMergedPic(ParameterSetManager &psManager, bool mixe const std::vector<uint16_t> subPicIds = { (uint16_t)subpicId }; std::vector<int> targetOLS; std::vector<int> targetLayers = { (int)subpic.nalus[0].m_nuhLayerId }; - SEIScalableNesting *nestingSEI = new SEIScalableNesting(); + auto sn = new SEIScalableNesting(); seiEncoder.init(0, 0, 0); const uint16_t maxSubpicIdInPic = subPicIds.size() == 0 ? 0 : *std::max_element(subPicIds.begin(), subPicIds.end()); - seiEncoder.initSEIScalableNesting(nestingSEI, nestedSEI, targetOLS, targetLayers, subPicIds, maxSubpicIdInPic); + seiEncoder.initSEIScalableNesting(sn, nestedSEI, targetOLS, targetLayers, subPicIds, maxSubpicIdInPic); OutputNALUnit nalu( NAL_UNIT_SUFFIX_SEI, layerId, temporalId ); - seiMessages.push_back(nestingSEI); + seiMessages.push_back(sn); seiWriter.writeSEImessages(nalu.m_bitstream, seiMessages, hrd, false, temporalId); accessUnit.push_back(new NALUnitEBSP(nalu)); } diff --git a/source/Lib/CommonLib/SEI.cpp b/source/Lib/CommonLib/SEI.cpp index a702d96589d4312bce8630ae721321334dc59b1d..c15bc1e781b8c469f84ca380a00d658f08e34143 100644 --- a/source/Lib/CommonLib/SEI.cpp +++ b/source/Lib/CommonLib/SEI.cpp @@ -831,14 +831,7 @@ SEIMasteringDisplayColourVolume::SEIMasteringDisplayColourVolume(const SEIMaster std::memcpy(values.whitePoint, sei.values.whitePoint, sizeof(sei.values.whitePoint)); } -SEIScalableNesting::SEIScalableNesting(const SEIScalableNesting& sei) -{ - olsIdx = sei.olsIdx; - layerId = sei.layerId; - subpicIdLen = sei.subpicIdLen; - subpicId = sei.subpicId; - m_nestedSEIs = sei.m_nestedSEIs; -} +SEIScalableNesting::SEIScalableNesting(const SEIScalableNesting& sei) = default; SEIAlternativeTransferCharacteristics::SEIAlternativeTransferCharacteristics(const SEIAlternativeTransferCharacteristics& sei) { diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index b2d391f6585c1bf860bd9829d3eb4d3c46619b8a..f0f91e285a06dc76564ea7c3552ba0a7c167a246 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -930,12 +930,11 @@ void DecLib::finishPicture(int &poc, PicList *&rpcListPic, MsgLevel msgl, bool a SEIMessages scalableNestingSeis = getSeisByType(m_pcPic->SEIs, SEI::PayloadType::SCALABLE_NESTING); for (auto seiIt : scalableNestingSeis) { - SEIScalableNesting *nestingSei = dynamic_cast<SEIScalableNesting*>(seiIt); - if (!nestingSei->subpicId.empty()) + SEIScalableNesting* sn = dynamic_cast<SEIScalableNesting*>(seiIt); + if (!sn->subpicId.empty()) { - uint32_t subpicId = nestingSei->subpicId.front(); - SEIMessages nestedPictureHashes = - getSeisByType(nestingSei->m_nestedSEIs, SEI::PayloadType::DECODED_PICTURE_HASH); + uint32_t subpicId = sn->subpicId.front(); + SEIMessages nestedPictureHashes = getSeisByType(sn->m_nestedSEIs, SEI::PayloadType::DECODED_PICTURE_HASH); for (auto decPicHash : nestedPictureHashes) { const SubPic& subpic = pcSlice->getPPS()->getSubPic(subpicId); @@ -2598,16 +2597,16 @@ void DecLib::xParsePrefixSEImessages() SEIMessages scalableNestingSEIs = getSeisByType(m_SEIs, SEI::PayloadType::SCALABLE_NESTING); if (scalableNestingSEIs.size()) { - SEIScalableNesting *nestedSei = (SEIScalableNesting*)scalableNestingSEIs.front(); - SEIMessages nestedSliSei = getSeisByType(nestedSei->m_nestedSEIs, SEI::PayloadType::SUBPICTURE_LEVEL_INFO); + SEIScalableNesting* sn = (SEIScalableNesting*) scalableNestingSEIs.front(); + SEIMessages nestedSliSei = getSeisByType(sn->m_nestedSEIs, SEI::PayloadType::SUBPICTURE_LEVEL_INFO); if (nestedSliSei.size() > 0) { AccessUnitNestedSliSeiInfo sliSeiInfo; sliSeiInfo.m_nestedSliPresent = true; - sliSeiInfo.m_numOlssNestedSli = (uint32_t) nestedSei->olsIdx.size(); - for (size_t i = 0; i < nestedSei->olsIdx.size(); i++) + sliSeiInfo.m_numOlssNestedSli = (uint32_t) sn->olsIdx.size(); + for (size_t i = 0; i < sn->olsIdx.size(); i++) { - sliSeiInfo.m_olsIdxNestedSLI[i] = nestedSei->olsIdx[i]; + sliSeiInfo.m_olsIdxNestedSLI[i] = sn->olsIdx[i]; } m_accessUnitNestedSliSeiInfo.push_back(sliSeiInfo); } diff --git a/source/Lib/DecoderLib/SEIread.cpp b/source/Lib/DecoderLib/SEIread.cpp index 2702ddaf0feee77c5392ce20fe89b91907344eb9..406a1f5e69ba601c871e2c371a7c367a1cf577dd 100644 --- a/source/Lib/DecoderLib/SEIread.cpp +++ b/source/Lib/DecoderLib/SEIread.cpp @@ -953,11 +953,13 @@ void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, uint32_t } } -void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, const uint32_t nuhLayerId, uint32_t payloadSize, const VPS* vps, const SPS* sps, HRD &hrd, std::ostream* decodedMessageOutputStream) +void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sn, const NalUnitType nalUnitType, + const uint32_t nuhLayerId, uint32_t payloadSize, const VPS* vps, + const SPS* sps, HRD& hrd, std::ostream* decodedMessageOutputStream) { uint32_t symbol; SEIMessages seis; - output_sei_message_header(sei, decodedMessageOutputStream, payloadSize); + output_sei_message_header(sn, decodedMessageOutputStream, payloadSize); sei_read_flag(decodedMessageOutputStream, symbol, "sn_ols_flag"); const bool hasOldIdx = symbol != 0; @@ -968,19 +970,19 @@ void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitT if (hasOldIdx) { sei_read_uvlc(decodedMessageOutputStream, symbol, "sn_num_olss_minus1"); - sei.olsIdx.resize(symbol + 1); + sn.olsIdx.resize(symbol + 1); - for (uint32_t i = 0; i <= sei.olsIdx.size(); i++) + for (uint32_t i = 0; i < sn.olsIdx.size(); i++) { - const uint32_t pred = i == 0 ? 0 : sei.olsIdx[i - 1] + 1; + const uint32_t pred = i == 0 ? 0 : sn.olsIdx[i - 1] + 1; sei_read_uvlc(decodedMessageOutputStream, symbol, "sn_ols_idx_delta_minus1[i]"); - sei.olsIdx[i] = pred + symbol; + sn.olsIdx[i] = pred + symbol; } if (vps && vps->getVPSId() != 0) { uint32_t lowestLayerId = std::numeric_limits<uint32_t>::max(); - for (uint32_t olsIdx: sei.olsIdx) + for (uint32_t olsIdx: sn.olsIdx) { for (int layerIdx = 0; layerIdx < vps->getNumLayersInOls(olsIdx); layerIdx++) { @@ -997,31 +999,31 @@ void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitT if (!allLayersFlag) { sei_read_uvlc(decodedMessageOutputStream, symbol, "sn_num_layers_minus1"); - sei.layerId.resize(symbol + 1); - sei.layerId[0] = nuhLayerId; - for (uint32_t i = 1; i < sei.layerId.size(); i++) + sn.layerId.resize(symbol + 1); + sn.layerId[0] = nuhLayerId; + for (uint32_t i = 1; i < sn.layerId.size(); i++) { sei_read_code(decodedMessageOutputStream, 6, symbol, "sn_layer_id[i]"); - sei.layerId[i] = symbol; + sn.layerId[i] = symbol; } } else { - sei.layerId.clear(); + sn.layerId.clear(); } } if (hasSubpicId) { sei_read_uvlc(decodedMessageOutputStream, symbol, "sn_num_subpics_minus1"); - sei.subpicId.resize(symbol + 1); + sn.subpicId.resize(symbol + 1); sei_read_uvlc(decodedMessageOutputStream, symbol, "sn_subpic_id_len_minus1"); - sei.subpicIdLen = symbol + 1; + sn.subpicIdLen = symbol + 1; - for (uint32_t i = 0; i < sei.subpicId.size(); i++) + for (uint32_t i = 0; i < sn.subpicId.size(); i++) { - sei_read_code(decodedMessageOutputStream, sei.subpicIdLen, symbol, "sn_subpic_id[i]"); - sei.subpicId[i] = symbol; + sei_read_code(decodedMessageOutputStream, sn.subpicIdLen, symbol, "sn_subpic_id[i]"); + sn.subpicId[i] = symbol; } } @@ -1052,7 +1054,7 @@ void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitT checkBPSyntaxElementLength(nonNestedBp, bp); } } - sei.m_nestedSEIs.push_back(tmpSEIs.front()); + sn.m_nestedSEIs.push_back(tmpSEIs.front()); tmpSEIs.clear(); } } @@ -1062,8 +1064,8 @@ void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitT : sps->getGeneralHrdParametersPresentFlag() ? sps->getGeneralHrdParameters() : nullptr; - - xCheckScalableNestingConstraints(sei, nalUnitType, generalHrd); + + xCheckScalableNestingConstraints(sn, nalUnitType, generalHrd); if (decodedMessageOutputStream) { @@ -1216,14 +1218,14 @@ void SEIReader::xParseSEIGreenMetadataInfo(SEIGreenMetadataInfo& sei, uint32_t p } } -void SEIReader::xParseSEIScalableNestingBinary(SEIScalableNesting &sei, const NalUnitType nalUnitType, - const uint32_t nuhLayerId, uint32_t payloadSize, const VPS *vps, - const SPS *sps, HRD &hrd, std::ostream *decodedMessageOutputStream, - std::vector<SeiPayload> *seiList) +void SEIReader::xParseSEIScalableNestingBinary(SEIScalableNesting& sn, const NalUnitType nalUnitType, + const uint32_t nuhLayerId, uint32_t payloadSize, const VPS* vps, + const SPS* sps, HRD& hrd, std::ostream* decodedMessageOutputStream, + std::vector<SeiPayload>* seiList) { uint32_t symbol; SEIMessages seis; - output_sei_message_header(sei, decodedMessageOutputStream, payloadSize); + output_sei_message_header(sn, decodedMessageOutputStream, payloadSize); sei_read_flag(decodedMessageOutputStream, symbol, "sn_ols_flag"); const bool hasOldIdx = symbol != 0; @@ -1234,19 +1236,19 @@ void SEIReader::xParseSEIScalableNestingBinary(SEIScalableNesting &sei, const Na if (hasOldIdx) { sei_read_uvlc(decodedMessageOutputStream, symbol, "sn_num_olss_minus1"); - sei.olsIdx.resize(symbol + 1); + sn.olsIdx.resize(symbol + 1); - for (uint32_t i = 0; i <= sei.olsIdx.size(); i++) + for (uint32_t i = 0; i < sn.olsIdx.size(); i++) { - const uint32_t pred = i == 0 ? 0 : sei.olsIdx[i - 1] + 1; + const uint32_t pred = i == 0 ? 0 : sn.olsIdx[i - 1] + 1; sei_read_uvlc(decodedMessageOutputStream, symbol, "sn_ols_idx_delta_minus1[i]"); - sei.olsIdx[i] = pred + symbol; + sn.olsIdx[i] = pred + symbol; } if (vps && vps->getVPSId() != 0) { uint32_t lowestLayerId = std::numeric_limits<uint32_t>::max(); - for (uint32_t olsIdx: sei.olsIdx) + for (uint32_t olsIdx: sn.olsIdx) { for (int layerIdx = 0; layerIdx < vps->getNumLayersInOls(olsIdx); layerIdx++) { @@ -1263,31 +1265,31 @@ void SEIReader::xParseSEIScalableNestingBinary(SEIScalableNesting &sei, const Na if (!allLayersFlag) { sei_read_uvlc(decodedMessageOutputStream, symbol, "sn_num_layers_minus1"); - sei.layerId.resize(symbol + 1); - sei.layerId[0] = nuhLayerId; - for (uint32_t i = 1; i < sei.layerId.size(); i++) + sn.layerId.resize(symbol + 1); + sn.layerId[0] = nuhLayerId; + for (uint32_t i = 1; i < sn.layerId.size(); i++) { sei_read_code(decodedMessageOutputStream, 6, symbol, "sn_layer_id[i]"); - sei.layerId[i] = symbol; + sn.layerId[i] = symbol; } } else { - sei.layerId.clear(); + sn.layerId.clear(); } } if (hasSubpicId) { sei_read_uvlc(decodedMessageOutputStream, symbol, "sn_num_subpics_minus1"); - sei.subpicId.resize(symbol + 1); + sn.subpicId.resize(symbol + 1); sei_read_uvlc(decodedMessageOutputStream, symbol, "sn_subpic_id_len_minus1"); - sei.subpicIdLen = symbol + 1; + sn.subpicIdLen = symbol + 1; - for (uint32_t i = 0; i < sei.subpicId.size(); i++) + for (uint32_t i = 0; i < sn.subpicId.size(); i++) { - sei_read_code(decodedMessageOutputStream, sei.subpicIdLen, symbol, "sn_subpic_id[i]"); - sei.subpicId[i] = symbol; + sei_read_code(decodedMessageOutputStream, sn.subpicIdLen, symbol, "sn_subpic_id[i]"); + sn.subpicId[i] = symbol; } } @@ -1345,68 +1347,68 @@ void SEIReader::xParseSEIScalableNestingBinary(SEIScalableNesting &sei, const Na setBitstream(bs); } } - const size_t numSubPics = std::max<size_t>(sei.subpicId.size(), 1); + const size_t numSubPics = std::max<size_t>(sn.subpicId.size(), 1); for (uint32_t j = 0; j < payloadSize; j++) { sei_read_code(nullptr, 8, val, "payload_content"); payload[j] = (uint8_t)val; } - if (!sei.olsIdx.empty()) + if (!sn.olsIdx.empty()) { - for (uint32_t j = 0; j < sei.olsIdx.size(); j++) + for (uint32_t j = 0; j < sn.olsIdx.size(); j++) { for (uint32_t k = 0; k < numSubPics; k++) { if (j == 0 && k == 0) { - seiList->push_back(SeiPayload{ payloadType, sei.olsIdx[j], false, payloadSize, payload, duiIdx, - !sei.subpicId.empty() ? sei.subpicId[k] : 0 }); + seiList->push_back(SeiPayload{ payloadType, sn.olsIdx[j], false, payloadSize, payload, duiIdx, + !sn.subpicId.empty() ? sn.subpicId[k] : 0 }); } else { uint8_t *payloadTemp = new uint8_t[payloadSize]; memcpy(payloadTemp, payload, payloadSize *sizeof(uint8_t)); - seiList->push_back(SeiPayload{ payloadType, sei.olsIdx[j], false, payloadSize, payloadTemp, duiIdx, - !sei.subpicId.empty() ? sei.subpicId[k] : 0 }); + seiList->push_back(SeiPayload{ payloadType, sn.olsIdx[j], false, payloadSize, payloadTemp, duiIdx, + !sn.subpicId.empty() ? sn.subpicId[k] : 0 }); } } } } - else if (sei.allLayersFlag()) + else if (sn.allLayersFlag()) { for (uint32_t k = 0; k < numSubPics; k++) { if (k == 0) { seiList->push_back(SeiPayload{ payloadType, nuhLayerId, true, payloadSize, payload, duiIdx, - !sei.subpicId.empty() ? sei.subpicId[k] : 0 }); + !sn.subpicId.empty() ? sn.subpicId[k] : 0 }); } else { uint8_t *payloadTemp = new uint8_t[payloadSize]; memcpy(payloadTemp, payload, payloadSize *sizeof(uint8_t)); seiList->push_back( - SeiPayload{ payloadType, nuhLayerId, true, payloadSize, payloadTemp, duiIdx, sei.subpicId[k] }); + SeiPayload{ payloadType, nuhLayerId, true, payloadSize, payloadTemp, duiIdx, sn.subpicId[k] }); } } } else { - for (uint32_t j = 0; j < sei.layerId.size(); j++) + for (uint32_t j = 0; j < sn.layerId.size(); j++) { for (uint32_t k = 0; k < numSubPics; k++) { if (j == 0 && k == 0) { - seiList->push_back(SeiPayload{ payloadType, sei.layerId[j], false, payloadSize, payload, duiIdx, - !sei.subpicId.empty() ? sei.subpicId[k] : 0 }); + seiList->push_back(SeiPayload{ payloadType, sn.layerId[j], false, payloadSize, payload, duiIdx, + !sn.subpicId.empty() ? sn.subpicId[k] : 0 }); } else { uint8_t *payloadTemp = new uint8_t[payloadSize]; memcpy(payloadTemp, payload, payloadSize *sizeof(uint8_t)); - seiList->push_back(SeiPayload{ payloadType, sei.layerId[j], false, payloadSize, payloadTemp, duiIdx, - !sei.subpicId.empty() ? sei.subpicId[k] : 0 }); + seiList->push_back(SeiPayload{ payloadType, sn.layerId[j], false, payloadSize, payloadTemp, duiIdx, + !sn.subpicId.empty() ? sn.subpicId[k] : 0 }); } } } @@ -1414,7 +1416,8 @@ void SEIReader::xParseSEIScalableNestingBinary(SEIScalableNesting &sei, const Na } } -void SEIReader::xCheckScalableNestingConstraints(const SEIScalableNesting& sei, const NalUnitType nalUnitType, const GeneralHrdParams* generalHrd) +void SEIReader::xCheckScalableNestingConstraints(const SEIScalableNesting& sn, const NalUnitType nalUnitType, + const GeneralHrdParams* generalHrd) { const std::vector<SEI::PayloadType> vclAssociatedSeiList{ SEI::PayloadType::FILLER_PAYLOAD, @@ -1444,7 +1447,7 @@ void SEIReader::xCheckScalableNestingConstraints(const SEIScalableNesting& sei, bool containBPorPTorDUIorSLI = false; bool containNoBPorPTorDUIorSLI = false; - for (auto nestedsei : sei.m_nestedSEIs) + for (auto nestedsei: sn.m_nestedSEIs) { CHECK(nestedsei->payloadType() == SEI::PayloadType::FILLER_PAYLOAD || nestedsei->payloadType() == SEI::PayloadType::SCALABLE_NESTING, @@ -1467,11 +1470,11 @@ void SEIReader::xCheckScalableNestingConstraints(const SEIScalableNesting& sei, "When a scalable nesting SEI message contains an SEI message that has payloadType equal to decoded picture hash, " "the SEI NAL unit containing the scalable nesting SEI message shall have nal_unit_type equal to SUFFIX_SEI_NUT"); - CHECK(nestedsei->payloadType() == SEI::PayloadType::DECODED_PICTURE_HASH && sei.subpicId.empty(), + CHECK(nestedsei->payloadType() == SEI::PayloadType::DECODED_PICTURE_HASH && sn.subpicId.empty(), "When the scalable nesting SEI message contains an SEI message that has payloadType equal to decoded picture " "hash, the value of sn_subpic_flag shall be equal to 1"); - CHECK(nestedsei->payloadType() == SEI::PayloadType::SUBPICTURE_LEVEL_INFO && !sei.subpicId.empty(), + CHECK(nestedsei->payloadType() == SEI::PayloadType::SUBPICTURE_LEVEL_INFO && !sn.subpicId.empty(), "When the scalable nesting SEI message contains an SEI message that has payloadType equal to SLI, the value " "of sn_subpic_flag shall be equal to 0"); @@ -1482,7 +1485,7 @@ void SEIReader::xCheckScalableNestingConstraints(const SEIScalableNesting& sei, for (int i = 0; i < vclAssociatedSeiList.size(); i++) { - CHECK(nestedsei->payloadType() == vclAssociatedSeiList[i] && !sei.olsIdx.empty(), + CHECK(nestedsei->payloadType() == vclAssociatedSeiList[i] && !sn.olsIdx.empty(), "When the scalable nesting SEI message contains an SEI message that has payloadType equal to a value in " "vclAssociatedSeiList, the value of sn_ols_flag shall be equal to 0"); } @@ -1493,7 +1496,7 @@ void SEIReader::xCheckScalableNestingConstraints(const SEIScalableNesting& sei, || nestedsei->payloadType() == SEI::PayloadType::SUBPICTURE_LEVEL_INFO) { containBPorPTorDUIorSLI = true; - CHECK(sei.olsIdx.empty(), + CHECK(sn.olsIdx.empty(), "When the scalable nesting SEI message contains an SEI message that has payloadType equal to BP, " "PT, or DUI, or SLI, the value of sn_ols_flag shall be equal to 1"); } diff --git a/source/Lib/DecoderLib/SEIread.h b/source/Lib/DecoderLib/SEIread.h index 68d681c8c965e9135b84ddb53c05e71cb4b335f3..4bd071d077eb3f1569a55fefb80629ae5e57c4f4 100644 --- a/source/Lib/DecoderLib/SEIread.h +++ b/source/Lib/DecoderLib/SEIread.h @@ -75,11 +75,14 @@ protected: std::ostream* pDecodedMessageOutputStream); void xParseSEIPictureTiming(SEIPictureTiming& pt, uint32_t payloadSize, const uint32_t temporalId, const SEIBufferingPeriod& bp, std::ostream* pDecodedMessageOutputStream); - void xParseSEIScalableNesting (SEIScalableNesting& sei, const NalUnitType nalUnitType, const uint32_t nuhLayerId, uint32_t payloadSize, const VPS* vps, const SPS* sps, HRD &hrd, std::ostream* decodedMessageOutputStream); - void xParseSEIScalableNestingBinary(SEIScalableNesting &sei, const NalUnitType nalUnitType, const uint32_t nuhLayerId, - uint32_t payloadSize, const VPS *vps, const SPS *sps, HRD &hrd, - std::ostream *decodedMessageOutputStream, std::vector<SeiPayload> *seiList); - void xCheckScalableNestingConstraints (const SEIScalableNesting& sei, const NalUnitType nalUnitType, const GeneralHrdParams* generalHrd); + void xParseSEIScalableNesting(SEIScalableNesting& sn, const NalUnitType nalUnitType, const uint32_t nuhLayerId, + uint32_t payloadSize, const VPS* vps, const SPS* sps, HRD& hrd, + std::ostream* decodedMessageOutputStream); + void xParseSEIScalableNestingBinary(SEIScalableNesting& sn, const NalUnitType nalUnitType, const uint32_t nuhLayerId, + uint32_t payloadSize, const VPS* vps, const SPS* sps, HRD& hrd, + std::ostream* decodedMessageOutputStream, std::vector<SeiPayload>* seiList); + void xCheckScalableNestingConstraints(const SEIScalableNesting& sn, const NalUnitType nalUnitType, + const GeneralHrdParams* generalHrd); void xParseSEIFrameFieldinfo (SEIFrameFieldInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); void xParseSEIGreenMetadataInfo (SEIGreenMetadataInfo& sei, uint32_t payLoadSize, std::ostream *pDecodedMessageOutputStream); void xParseSEIDependentRAPIndication (SEIDependentRAPIndication& sei, uint32_t payLoadSize, std::ostream *pDecodedMessageOutputStream); diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index c539859893ac28d378e75251390ace0bf0e3fbec..2f60bec779d98407488b2d3eac82009997e231e5 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -1074,9 +1074,9 @@ void EncGOP::xCreateScalableNestingSEI(SEIMessages& seiMessages, SEIMessages& ne SEI* sei = nestedSeiMessages.front(); nestedSeiMessages.pop_front(); tmpMessages.push_back(sei); - SEIScalableNesting *nestingSEI = new SEIScalableNesting(); - m_seiEncoder.initSEIScalableNesting(nestingSEI, tmpMessages, targetOLSs, targetLayers, subpicIDs, maxSubpicIdInPic); - seiMessages.push_back(nestingSEI); + auto sn = new SEIScalableNesting(); + m_seiEncoder.initSEIScalableNesting(sn, tmpMessages, targetOLSs, targetLayers, subpicIDs, maxSubpicIdInPic); + seiMessages.push_back(sn); tmpMessages.clear(); } } diff --git a/source/Lib/EncoderLib/SEIEncoder.cpp b/source/Lib/EncoderLib/SEIEncoder.cpp index 8fa062d57cb74ec8494aa509ed910c9ad6fbf87e..c4562dd859d9dbe8aa36015b953b9409d992a5dc 100644 --- a/source/Lib/EncoderLib/SEIEncoder.cpp +++ b/source/Lib/EncoderLib/SEIEncoder.cpp @@ -449,19 +449,21 @@ void SEIEncoder::initSEIPhaseIndication(SEIPhaseIndication* seiPhaseIndication, //! Note: The SEI message structures input into this function will become part of the scalable nesting SEI and will be //! automatically freed, when the nesting SEI is disposed. // either targetOLS or targetLayer should be active, call with empty vector for the inactive mode -void SEIEncoder::initSEIScalableNesting(SEIScalableNesting *scalableNestingSEI, SEIMessages &nestedSEIs, const std::vector<int> &targetOLSs, const std::vector<int> &targetLayers, const std::vector<uint16_t> &subpictureIDs, uint16_t maxSubpicIdInPic) +void SEIEncoder::initSEIScalableNesting(SEIScalableNesting* sn, SEIMessages& nestedSEIs, + const std::vector<int>& targetOLSs, const std::vector<int>& targetLayers, + const std::vector<uint16_t>& subpictureIDs, uint16_t maxSubpicIdInPic) { CHECK(!(m_isInitialized), "Scalable Nesting SEI already initialized "); - CHECK(!(scalableNestingSEI != nullptr), "No Scalable Nesting SEI object passed"); + CHECK(!(sn != nullptr), "No Scalable Nesting SEI object passed"); CHECK (targetOLSs.size() > 0 && targetLayers.size() > 0, "Scalable Nesting SEI can apply to either OLS or layer(s), not both"); - scalableNestingSEI->olsIdx.resize(targetOLSs.size()); + sn->olsIdx.resize(targetOLSs.size()); // If the nested SEI messages are picture buffering SEI messages, picture timing SEI messages or // sub-picture timing SEI messages, nesting_ols_flag shall be equal to 1, by default case - if (scalableNestingSEI->olsIdx.size() > 0) + if (sn->olsIdx.size() > 0) { // initialize absolute indexes - for (int i = 0; i < scalableNestingSEI->olsIdx.size(); i++) + for (int i = 0; i < sn->olsIdx.size(); i++) { if (i == 0) { @@ -471,27 +473,27 @@ void SEIEncoder::initSEIScalableNesting(SEIScalableNesting *scalableNestingSEI, { CHECK(targetOLSs[i] <= targetOLSs[i - 1], "OLS indexes must be in ascending order"); } - scalableNestingSEI->olsIdx[i] = targetOLSs[i]; + sn->olsIdx[i] = targetOLSs[i]; } } else { - scalableNestingSEI->layerId.resize(targetLayers.size()); - for (int i = 0; i < scalableNestingSEI->layerId.size(); i++) + sn->layerId.resize(targetLayers.size()); + for (int i = 0; i < sn->layerId.size(); i++) { - scalableNestingSEI->layerId[i] = targetLayers[i]; + sn->layerId[i] = targetLayers[i]; } } if (!subpictureIDs.empty()) { - scalableNestingSEI->subpicId = subpictureIDs; - scalableNestingSEI->subpicIdLen = std::max(1, ceilLog2(maxSubpicIdInPic + 1)); - CHECK(scalableNestingSEI->subpicIdLen > 16, "Subpicture ID too large. Length must be <= 16 bits"); + sn->subpicId = subpictureIDs; + sn->subpicIdLen = std::max(1, ceilLog2(maxSubpicIdInPic + 1)); + CHECK(sn->subpicIdLen > 16, "Subpicture ID too large. Length must be <= 16 bits"); } - scalableNestingSEI->m_nestedSEIs.clear(); - for (SEIMessages::iterator it = nestedSEIs.begin(); it != nestedSEIs.end(); it++) + sn->m_nestedSEIs.clear(); + for (auto& sei: nestedSEIs) { - scalableNestingSEI->m_nestedSEIs.push_back((*it)); + sn->m_nestedSEIs.push_back(sei); } } diff --git a/source/Lib/EncoderLib/SEIEncoder.h b/source/Lib/EncoderLib/SEIEncoder.h index df965ceda5a7fe02ed06c85c4fb51888b17130cf..3754c3974cfd8023a958c59adbc38508396033e7 100644 --- a/source/Lib/EncoderLib/SEIEncoder.h +++ b/source/Lib/EncoderLib/SEIEncoder.h @@ -66,7 +66,9 @@ public: void initSEIExtendedDrapIndication(SEIExtendedDrapIndication *sei); void initSEIBufferingPeriod(SEIBufferingPeriod *sei, bool noLeadingPictures); void initSEIAlternativeTransferCharacteristics(SEIAlternativeTransferCharacteristics *sei); - void initSEIScalableNesting(SEIScalableNesting *scalableNestingSEI, SEIMessages &nestedSEIs, const std::vector<int> &targetOLSs, const std::vector<int> &targetLayers, const std::vector<uint16_t> &subpictureIDs, uint16_t maxSubpicIdInPic); + void initSEIScalableNesting(SEIScalableNesting* sn, SEIMessages& nestedSEIs, const std::vector<int>& targetOLSs, + const std::vector<int>& targetLayers, const std::vector<uint16_t>& subpictureIDs, + uint16_t maxSubpicIdInPic); void initDecodedPictureHashSEI(SEIDecodedPictureHash *sei, PelUnitBuf& pic, std::string &rHashString, const BitDepths &bitDepths); void initSEIErp(SEIEquirectangularProjection *sei); void initSEISphereRotation(SEISphereRotation *sei); diff --git a/source/Lib/EncoderLib/SEIwrite.cpp b/source/Lib/EncoderLib/SEIwrite.cpp index 22ece860f1f08bc030e1f81c7ff826b152f9f6ad..785a6dda0cafc83ee819dd42d08672b14b050e49 100644 --- a/source/Lib/EncoderLib/SEIwrite.cpp +++ b/source/Lib/EncoderLib/SEIwrite.cpp @@ -610,46 +610,46 @@ void SEIWriter::xWriteSEIEdrapIndication(const SEIExtendedDrapIndication& sei) } } -void SEIWriter::xWriteSEIScalableNesting(OutputBitstream& bs, const SEIScalableNesting& sei) +void SEIWriter::xWriteSEIScalableNesting(OutputBitstream& bs, const SEIScalableNesting& sn) { - CHECK (sei.m_nestedSEIs.size()<1, "There must be at lease one SEI message nested in the scalable nesting SEI.") + CHECK(sn.m_nestedSEIs.size() < 1, "There must be at lease one SEI message nested in the scalable nesting SEI.") - xWriteFlag(!sei.olsIdx.empty() ? 1 : 0, "sn_ols_flag"); - xWriteFlag(!sei.subpicId.empty() ? 1 : 0, "sn_subpic_flag"); - if (!sei.olsIdx.empty()) + xWriteFlag(!sn.olsIdx.empty() ? 1 : 0, "sn_ols_flag"); + xWriteFlag(!sn.subpicId.empty() ? 1 : 0, "sn_subpic_flag"); + if (!sn.olsIdx.empty()) { - xWriteUvlc((uint32_t) sei.olsIdx.size(), "sn_num_olss_minus1"); - for (uint32_t i = 0; i < sei.olsIdx.size(); i++) + xWriteUvlc((uint32_t) sn.olsIdx.size() - 1, "sn_num_olss_minus1"); + for (uint32_t i = 0; i < sn.olsIdx.size(); i++) { - const uint32_t pred = i == 0 ? 0 : sei.olsIdx[i - 1] + 1; - CHECK(sei.olsIdx[i] < pred, "sn_ols_idx_delta_minus1 cannot be negative"); - xWriteUvlc(sei.olsIdx[i] - pred, "sn_ols_idx_delta_minus1[i]"); + const uint32_t pred = i == 0 ? 0 : sn.olsIdx[i - 1] + 1; + CHECK(sn.olsIdx[i] < pred, "sn_ols_idx_delta_minus1 cannot be negative"); + xWriteUvlc(sn.olsIdx[i] - pred, "sn_ols_idx_delta_minus1[i]"); } } else { - xWriteFlag(sei.allLayersFlag() ? 1 : 0, "sn_all_layers_flag"); - if (!sei.allLayersFlag()) + xWriteFlag(sn.allLayersFlag() ? 1 : 0, "sn_all_layers_flag"); + if (!sn.allLayersFlag()) { - xWriteUvlc((uint32_t) sei.layerId.size() - 1, "sn_num_layers_minus1"); - for (uint32_t i = 1; i < sei.layerId.size(); i++) + xWriteUvlc((uint32_t) sn.layerId.size() - 1, "sn_num_layers_minus1"); + for (uint32_t i = 1; i < sn.layerId.size(); i++) { - xWriteCode(sei.layerId[i], 6, "sn_layer_id"); + xWriteCode(sn.layerId[i], 6, "sn_layer_id"); } } } - if (!sei.subpicId.empty()) + if (!sn.subpicId.empty()) { - xWriteUvlc((uint32_t) sei.subpicId.size() - 1, "sn_num_subpics_minus1"); - CHECK(sei.subpicIdLen <= 1, "subpicIdLen must be at least 1"); - xWriteUvlc(sei.subpicIdLen - 1, "sn_subpic_id_len_minus1"); - for (uint32_t i = 0; i < sei.subpicId.size(); i++) + xWriteUvlc((uint32_t) sn.subpicId.size() - 1, "sn_num_subpics_minus1"); + CHECK(sn.subpicIdLen <= 1, "subpicIdLen must be at least 1"); + xWriteUvlc(sn.subpicIdLen - 1, "sn_subpic_id_len_minus1"); + for (uint32_t i = 0; i < sn.subpicId.size(); i++) { - xWriteCode(sei.subpicId[i], sei.subpicIdLen, "sn_subpic_id[i]"); + xWriteCode(sn.subpicId[i], sn.subpicIdLen, "sn_subpic_id[i]"); } } - xWriteUvlc( (uint32_t)sei.m_nestedSEIs.size() - 1, "sn_num_seis_minus1"); + xWriteUvlc((uint32_t) sn.m_nestedSEIs.size() - 1, "sn_num_seis_minus1"); // byte alignment while (m_pcBitIf->getNumberOfWrittenBits() % 8 != 0) @@ -657,7 +657,7 @@ void SEIWriter::xWriteSEIScalableNesting(OutputBitstream& bs, const SEIScalableN xWriteFlag(0, "sn_zero_bit"); } - SEIMessages bufferingPeriod = getSeisByType(sei.m_nestedSEIs, SEI::PayloadType::BUFFERING_PERIOD); + SEIMessages bufferingPeriod = getSeisByType(sn.m_nestedSEIs, SEI::PayloadType::BUFFERING_PERIOD); if (!bufferingPeriod.empty()) { SEIBufferingPeriod *bp = (SEIBufferingPeriod*)bufferingPeriod.front(); @@ -665,7 +665,7 @@ void SEIWriter::xWriteSEIScalableNesting(OutputBitstream& bs, const SEIScalableN } // write nested SEI messages - writeSEImessages(bs, sei.m_nestedSEIs, m_nestingHrd, true, 0); + writeSEImessages(bs, sn.m_nestedSEIs, m_nestingHrd, true, 0); } void SEIWriter::xWriteSEIFramePacking(const SEIFramePacking &sei, int SEIPrefixIndicationIdx) diff --git a/source/Lib/EncoderLib/SEIwrite.h b/source/Lib/EncoderLib/SEIwrite.h index fd890d63d8c74cc68118c9b454724dc45df7e588..8c1a02dfd2f00dae5451d6b5c6a28c9914539727 100644 --- a/source/Lib/EncoderLib/SEIwrite.h +++ b/source/Lib/EncoderLib/SEIwrite.h @@ -63,7 +63,7 @@ protected: void xWriteSEIFrameFieldInfo(const SEIFrameFieldInfo& sei); void xWriteSEIDependentRAPIndication(const SEIDependentRAPIndication& sei); void xWriteSEIEdrapIndication(const SEIExtendedDrapIndication& sei); - void xWriteSEIScalableNesting(OutputBitstream &bs, const SEIScalableNesting &sei); + void xWriteSEIScalableNesting(OutputBitstream& bs, const SEIScalableNesting& sn); void xWriteSEIFramePacking(const SEIFramePacking &sei, int SEIPrefixIndicationIdx = 0); void xWriteSEIDisplayOrientation(const SEIDisplayOrientation& sei); void xWriteSEIParameterSetsInclusionIndication(const SEIParameterSetsInclusionIndication& sei);