From ecfbd36dd3e5e352f2ac86c5eecf0ea51424b022 Mon Sep 17 00:00:00 2001
From: hallapur <antti.hallapuro@nokia.com>
Date: Fri, 26 Feb 2021 16:36:42 +0200
Subject: [PATCH] Check subpicture specific decoded picture hashes in decoder

---
 source/Lib/DecoderLib/DecLib.cpp | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp
index 6949b7e76..644028059 100644
--- a/source/Lib/DecoderLib/DecLib.cpp
+++ b/source/Lib/DecoderLib/DecLib.cpp
@@ -767,6 +767,27 @@ void DecLib::finishPicture(int &poc, PicList *&rpcListPic, MsgLevel msgl, bool a
       msg( WARNING, "Warning: Got multiple decoded picture hash SEI messages. Using first.");
     }
     m_numberOfChecksumErrorsDetected += calcAndPrintHashStatus(((const Picture*) m_pcPic)->getRecoBuf(), hash, pcSlice->getSPS()->getBitDepths(), msgl);
+
+    if (!hash && pcSlice->getSPS()->getNumSubPics() > 1)
+    {
+      SEIMessages scalableNestingSeis = getSeisByType(m_pcPic->SEIs, SEI::SCALABLE_NESTING );
+      for (auto seiIt : scalableNestingSeis)
+      {
+        SEIScalableNesting *nestingSei = dynamic_cast<SEIScalableNesting*>(seiIt);
+        if (nestingSei->m_snSubpicFlag)
+        {
+          uint32_t subpicId = nestingSei->m_snSubpicId.front();
+          SEIMessages nestedPictureHashes = getSeisByType(nestingSei->m_nestedSEIs, SEI::DECODED_PICTURE_HASH);
+          for (auto decPicHash : nestedPictureHashes)
+          {
+            const SubPic& subpic = pcSlice->getPPS()->getSubPic(subpicId);
+            const UnitArea area = UnitArea(pcSlice->getSPS()->getChromaFormatIdc(), Area(subpic.getSubPicLeft(), subpic.getSubPicTop(), subpic.getSubPicWidthInLumaSample(), subpic.getSubPicHeightInLumaSample()));
+            PelUnitBuf recoBuf = m_pcPic->cs->getRecoBuf(area);
+            m_numberOfChecksumErrorsDetected += calcAndPrintHashStatus(recoBuf, dynamic_cast<SEIDecodedPictureHash*>(decPicHash), pcSlice->getSPS()->getBitDepths(), msgl);
+          }
+        }
+      }
+    }
   }
 
   msg( msgl, "\n");
-- 
GitLab