From 0eace342d114c47dd7943de9a21ec59312716c13 Mon Sep 17 00:00:00 2001 From: zhipin <zhipin.deng@bytedance.com> Date: Mon, 13 Jul 2020 18:42:26 +0800 Subject: [PATCH] JVET-S0178: General SEI semantics and constraints --- source/Lib/CommonLib/TypeDef.h | 2 ++ source/Lib/DecoderLib/DecLib.cpp | 52 ++++++++++++++++++++++++++++++- source/Lib/DecoderLib/SEIread.cpp | 3 ++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 8ca78240a..f29a6e93a 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -89,6 +89,8 @@ #define JVET_R0068_ASPECT6_ENC_RESTRICTION 1 // encoder restriction for JVET-R0068 apsect 6 +#define JVET_S0178_GENERAL_SEI_CHECK 1 // JVET-S0178: General SEI semantics and constraints + #define JVET_S0186_SPS_CLEANUP 1 // JVET-S0186: Proposal 1, move sps_chroma_format_idc and sps_log2_ctu_size_minus5 to take place sps_reserved_zero_4bits //########### place macros to be be kept below this line ############### diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index a94f901e0..4c530ffbb 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -1042,6 +1042,36 @@ void DecLib::checkSEIInAccessUnit() enum NalUnitType naluType = std::get<0>(sei); int nuhLayerId = std::get<1>(sei); enum SEI::PayloadType payloadType = std::get<2>(sei); +#if JVET_S0178_GENERAL_SEI_CHECK + if (m_vps != nullptr && naluType == NAL_UNIT_PREFIX_SEI && ((payloadType == SEI::BUFFERING_PERIOD || payloadType == SEI::PICTURE_TIMING || payloadType == SEI::DECODING_UNIT_INFO || payloadType == SEI::SUBPICTURE_LEVEL_INFO))) + { + bool olsIncludeAllLayersFind = false; + for (int i = 0; i < m_vps->getNumOutputLayerSets(); i++) + { + for (auto pic = m_firstAccessUnitPicInfo.begin(); pic != m_firstAccessUnitPicInfo.end(); pic++) + { + int targetLayerId = pic->m_nuhLayerId; + for (int j = 0; j < m_vps->getNumLayersInOls(i); j++) + { + olsIncludeAllLayersFind = m_vps->getLayerIdInOls(i, j) == targetLayerId ? true : false; + if (olsIncludeAllLayersFind) + { + break; + } + } + if (!olsIncludeAllLayersFind) + { + break; + } + } + if (olsIncludeAllLayersFind) + { + break; + } + } + CHECK(!olsIncludeAllLayersFind, "When there is no OLS that includes all layers in the current CVS in the entire bitstream, there shall be no non-scalable-nested SEI message with payloadType equal to 0 (BP), 1 (PT), 130 (DUI), or 203 (SLI)"); + } +#else if (m_vps != nullptr && naluType == NAL_UNIT_PREFIX_SEI && ((payloadType == SEI::BUFFERING_PERIOD || payloadType == SEI::PICTURE_TIMING || payloadType == SEI::DECODING_UNIT_INFO))) { int numlayersInZeroOls = m_vps->getNumLayersInOls(0); @@ -1059,6 +1089,7 @@ void DecLib::checkSEIInAccessUnit() int layerId = m_vps->getLayerId(0); CHECK(nuhLayerId != layerId, "the nuh_layer_id of non-scalable-nested timing related SEI shall be equal to vps_layer_id[0]"); } +#endif } } @@ -1073,10 +1104,14 @@ void DecLib::checkSeiInPictureUnit() // payload types subject to constrained SEI repetition int picUnitRepConSeiList[SEI_REPETITION_CONSTRAINT_LIST_SIZE] = { 0, 1, 19, 45, 129, 132, 133, 137, 144, 145, 147, 148, 149, 150, 153, 154, 155, 156, 168, 203, 204}; - + // extract SEI messages from NAL units for (auto &sei : m_pictureSeiNalus) { +#if JVET_S0178_GENERAL_SEI_CHECK + bool isFillerPayloadInOneSeiNalUnit = false; + bool isNonFillerPayloadInOneSeiNalUnit = false; +#endif InputBitstream bs = sei->getBitstream(); do @@ -1104,8 +1139,23 @@ void DecLib::checkSeiInPictureUnit() payload[i] = (uint8_t)val; } seiList.push_back(std::tuple<int, uint32_t, uint8_t*>(payloadType, payloadSize, payload)); + +#if JVET_S0178_GENERAL_SEI_CHECK + if (payloadType == SEI::FILLER_PAYLOAD) + { + isFillerPayloadInOneSeiNalUnit = true; + } + else + { + isNonFillerPayloadInOneSeiNalUnit = true; + } + +#endif } while (bs.getNumBitsLeft() > 8); +#if JVET_S0178_GENERAL_SEI_CHECK + CHECK(isFillerPayloadInOneSeiNalUnit && isNonFillerPayloadInOneSeiNalUnit, "When an SEI NAL unit contains an SEI message with payloadType equal to filler payload, the SEI NAL unit shall not contain any other SEI message with payloadType not equal to filler payload"); +#endif } // count repeated messages in list diff --git a/source/Lib/DecoderLib/SEIread.cpp b/source/Lib/DecoderLib/SEIread.cpp index 616665a43..1e7906fc9 100644 --- a/source/Lib/DecoderLib/SEIread.cpp +++ b/source/Lib/DecoderLib/SEIread.cpp @@ -588,6 +588,9 @@ void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitT bool containNoBPorPTorDUI = false; for (auto nestedsei : sei.m_nestedSEIs) { +#if JVET_S0178_GENERAL_SEI_CHECK + CHECK(vps->getGeneralHrdParameters()->getGeneralSamePicTimingInAllOlsFlag() && nestedsei->payloadType() == SEI::PICTURE_TIMING, "When general_same_pic_timing_in_all_ols_flag is equal to 1, there shall be no SEI NAL unit that contain a scalable-nested SEI message with payloadType equal to PT"); +#endif if (nestedsei->payloadType() == SEI::BUFFERING_PERIOD || nestedsei->payloadType() == SEI::PICTURE_TIMING || nestedsei->payloadType() == SEI::DECODING_UNIT_INFO) { containBPorPTorDUI = true; -- GitLab