From 8249fb795f5c51451baf0e1966e0a80ea6b4e67e Mon Sep 17 00:00:00 2001
From: Nikolai Shostak <nikolai.shostak@vicuesoft.com>
Date: Wed, 31 Aug 2022 15:51:37 +0300
Subject: [PATCH] Reset list of Prefix SEI NALUs if frame is skipped

Otherwise this list is appended by SEI NALUs from the next frame
and checkSeiContentInAccessUnit() may falsely fail.
---
 source/Lib/DecoderLib/DecLib.cpp | 13 +++++++++++++
 source/Lib/DecoderLib/DecLib.h   |  1 +
 2 files changed, 14 insertions(+)

diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp
index 71e712d6c..d64337d08 100644
--- a/source/Lib/DecoderLib/DecLib.cpp
+++ b/source/Lib/DecoderLib/DecLib.cpp
@@ -1453,6 +1453,18 @@ void DecLib::resetPictureSeiNalus()
   }
 }
 
+/**
+ - Reset list of Prefix SEI NAL units from the current picture
+ */
+void DecLib::resetPrefixSeiNalus()
+{
+  while (!m_prefixSEINALUs.empty())
+  {
+    delete m_prefixSEINALUs.front();
+    m_prefixSEINALUs.pop_front();
+  }
+}
+
 void DecLib::checkSeiContentInAccessUnit()
 {
   if (m_accessUnitSeiNalus.empty())
@@ -2926,6 +2938,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl
     resetAccessUnitApsNals();
     resetAccessUnitPicInfo();
     resetPictureUnitNals();
+    resetPrefixSeiNalus();
     m_maxDecSubPicIdx = 0;
     m_maxDecSliceAddrInSubPic = -1;
     return false;
diff --git a/source/Lib/DecoderLib/DecLib.h b/source/Lib/DecoderLib/DecLib.h
index 1f38522bf..ca18d1ed4 100644
--- a/source/Lib/DecoderLib/DecLib.h
+++ b/source/Lib/DecoderLib/DecLib.h
@@ -291,6 +291,7 @@ public:
   void resetIsFirstAuInCvs();
   void checkSeiInPictureUnit();
   void resetPictureSeiNalus();
+  void resetPrefixSeiNalus();
   bool isSliceNaluFirstInAU( bool newPicture, InputNALUnit &nalu );
   void processSuffixApsNalus();
 
-- 
GitLab