From 29820a95f9d9d548e9ca8c58a1f9a6f9d215abfe Mon Sep 17 00:00:00 2001
From: zhipin <zhipin.deng@bytedance.com>
Date: Tue, 21 Jul 2020 12:40:38 +0800
Subject: [PATCH] move the filler payload check to parseSEImessage()

---
 source/Lib/DecoderLib/DecLib.cpp  | 18 ------------------
 source/Lib/DecoderLib/SEIread.cpp | 14 ++++++++++++--
 2 files changed, 12 insertions(+), 20 deletions(-)

diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp
index 9826ec8ab1..b1a8c6380d 100644
--- a/source/Lib/DecoderLib/DecLib.cpp
+++ b/source/Lib/DecoderLib/DecLib.cpp
@@ -1110,10 +1110,6 @@ void DecLib::checkSeiInPictureUnit()
   // 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
@@ -1141,22 +1137,8 @@ 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 1e7906fc9b..21820a9db0 100644
--- a/source/Lib/DecoderLib/SEIread.cpp
+++ b/source/Lib/DecoderLib/SEIread.cpp
@@ -117,19 +117,29 @@ static inline void output_sei_message_header(SEI &sei, std::ostream *pDecodedMes
  // note: for independent parsing no parameter set should not be required here
 void SEIReader::parseSEImessage(InputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const uint32_t nuh_layer_id, const uint32_t temporalId, const VPS *vps, const SPS *sps, HRD &hrd, std::ostream *pDecodedMessageOutputStream)
 {
+#if JVET_S0178_GENERAL_SEI_CHECK
+  SEIMessages   seiListInCurNalu;
+#endif
   setBitstream(bs);
-
   CHECK(m_pcBitstream->getNumBitsUntilByteAligned(), "Bitstream not aligned");
+
   do
   {
     xReadSEImessage(seis, nalUnitType, nuh_layer_id, temporalId, vps, sps, hrd, pDecodedMessageOutputStream);
-
+#if JVET_S0178_GENERAL_SEI_CHECK
+    seiListInCurNalu.push_back(seis.back());
+#endif
     /* SEI messages are an integer number of bytes, something has failed
     * in the parsing if bitstream not byte-aligned */
     CHECK(m_pcBitstream->getNumBitsUntilByteAligned(), "Bitstream not aligned");
   }
   while (m_pcBitstream->getNumBitsLeft() > 8);
 
+#if JVET_S0178_GENERAL_SEI_CHECK
+  SEIMessages fillerData = getSeisByType(seiListInCurNalu, SEI::FILLER_PAYLOAD);
+  CHECK(fillerData.size() > 0 && fillerData.size() != seiListInCurNalu.size(), "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
+
   xReadRbspTrailingBits();
 }
 
-- 
GitLab