From db413b240d4a2692ffd39156af51bedad3c20d67 Mon Sep 17 00:00:00 2001
From: eeehey <eeehey@yahoo.com>
Date: Fri, 9 Dec 2022 22:17:59 -0800
Subject: [PATCH] JVET-AB0069 update on SEI processing order SEI message syntax
 element length change

---
 source/App/EncoderApp/EncAppCfg.cpp | 8 ++++++++
 source/App/EncoderApp/EncAppCfg.h   | 4 ++++
 source/Lib/DecoderLib/SEIread.cpp   | 4 ++++
 source/Lib/EncoderLib/EncCfg.h      | 9 +++++++++
 source/Lib/EncoderLib/SEIwrite.cpp  | 4 ++++
 5 files changed, 29 insertions(+)

diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp
index 2af1c94e65..9dc79c8c64 100644
--- a/source/App/EncoderApp/EncAppCfg.cpp
+++ b/source/App/EncoderApp/EncAppCfg.cpp
@@ -732,7 +732,11 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   SMultiValueInput<unsigned>   cfg_siiSEIInputNumUnitsInSI(0, std::numeric_limits<uint32_t>::max(), 0, 7);
 
   SMultiValueInput<uint16_t>   cfg_poSEIPayloadType     (0, 65535, 0, 256*2);
+#if JVET_AB0069_SEI_PROCESSING_ORDER
+  SMultiValueInput<uint16_t>   cfg_poSEIProcessingOrder(0, 65535, 0, 65536);
+#else
   SMultiValueInput<uint16_t>   cfg_poSEIProcessingOrder (0, 255, 0, 256);
+#endif
 
 #if ENABLE_TRACING
   string sTracingRule;
@@ -3309,7 +3313,11 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
     for (uint32_t i = 0; i < m_numofSEIMessages; i++)
     {
       m_poSEIPayloadType[i]  = cfg_poSEIPayloadType.values[i];
+#if JVET_AB0069_SEI_PROCESSING_ORDER
+      m_poSEIProcessingOrder[i] = (uint16_t)cfg_poSEIProcessingOrder.values[i];
+#else
       m_poSEIProcessingOrder[i] = (uint8_t)cfg_poSEIProcessingOrder.values[i];
+#endif
       //Error check, to avoid same PayloadType with different PayloadOrder
       for (uint32_t j = 0; j < i; j++)
       {
diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h
index 067a2c4f48..1612e80131 100644
--- a/source/App/EncoderApp/EncAppCfg.h
+++ b/source/App/EncoderApp/EncAppCfg.h
@@ -758,7 +758,11 @@ protected:
 
   bool                  m_poSEIEnabled;
   std::vector<uint16_t> m_poSEIPayloadType;
+#if JVET_AB0069_SEI_PROCESSING_ORDER
+  std::vector<uint16_t>  m_poSEIProcessingOrder;
+#else
   std::vector<uint8_t>  m_poSEIProcessingOrder;
+#endif
   uint32_t              m_numofSEIMessages;
 
   bool                  m_constrainedRaslEncoding;
diff --git a/source/Lib/DecoderLib/SEIread.cpp b/source/Lib/DecoderLib/SEIread.cpp
index d46f46bf12..9f99ef2ea5 100644
--- a/source/Lib/DecoderLib/SEIread.cpp
+++ b/source/Lib/DecoderLib/SEIread.cpp
@@ -632,7 +632,11 @@ void SEIReader::xParseSEIProcessingOrder(SEIProcessingOrderInfo& sei, uint32_t p
   {
     sei_read_code(decodedMessageOutputStream, 16, val, "sei_payloadType[i]");
     sei.m_posPayloadType[i] = val;
+#if JVET_AB0069_SEI_PROCESSING_ORDER
+    sei_read_code(decodedMessageOutputStream, 16, val, "sei_processingOrder[i]");
+#else
     sei_read_code(decodedMessageOutputStream, 8, val, "sei_processingOrder[i]");
+#endif
     sei.m_posProcessingOrder[i] = val;
   }
 }
diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h
index 7f06b40630..e8ebfe039e 100644
--- a/source/Lib/EncoderLib/EncCfg.h
+++ b/source/Lib/EncoderLib/EncCfg.h
@@ -849,7 +849,11 @@ protected:
   //SEI message processing order
   bool                  m_poSEIEnabled;
   std::vector<uint16_t> m_poSEIPayloadType;
+#if JVET_AB0069_SEI_PROCESSING_ORDER
+  std::vector<uint16_t>  m_poSEIProcessingOrder;
+#else
   std::vector<uint8_t>  m_poSEIProcessingOrder;
+#endif
   uint32_t              m_numofSEIMessages;
 
   bool      m_constrainedRaslEncoding;
@@ -2425,8 +2429,13 @@ public:
   bool     getPoSEIEnabled()                                         { return m_poSEIEnabled; }
   void     setPoSEIPayloadType(const std::vector<uint16_t>& b)       { m_poSEIPayloadType = b; }
   uint16_t getPoSEIPayloadType(uint16_t idx)                   const { return m_poSEIPayloadType[idx]; }
+#if JVET_AB0069_SEI_PROCESSING_ORDER
+  void     setPoSEIProcessingOrder(const std::vector<uint16_t>& b) { m_poSEIProcessingOrder = b; }
+  uint16_t  getPoSEIProcessingOrder(uint16_t idx)              const { return m_poSEIProcessingOrder[idx]; }
+#else
   void     setPoSEIProcessingOrder(const std::vector<uint8_t>& b)    { m_poSEIProcessingOrder = b; }
   uint8_t  getPoSEIProcessingOrder(uint8_t idx)                const { return m_poSEIProcessingOrder[idx]; }
+#endif
   void     setPoSEINumofSeiMessages(uint32_t i)                      { m_numofSEIMessages = i; }
   uint32_t getPoSEINumofSeiMessages()                          const { return m_numofSEIMessages; }
 
diff --git a/source/Lib/EncoderLib/SEIwrite.cpp b/source/Lib/EncoderLib/SEIwrite.cpp
index e120db2872..84c3385570 100644
--- a/source/Lib/EncoderLib/SEIwrite.cpp
+++ b/source/Lib/EncoderLib/SEIwrite.cpp
@@ -1619,7 +1619,11 @@ void SEIWriter::xWriteSEIProcessingOrder(const SEIProcessingOrderInfo &sei)
   for (uint32_t i=0; i < sei.m_posNumofSeiMessages; i++)
   {
     WRITE_CODE(sei.m_posPayloadType[i], 16, "sei_payloadType[i]");
+#if JVET_AB0069_SEI_PROCESSING_ORDER
+    WRITE_CODE(sei.m_posProcessingOrder[i], 16, "sei_processingOrder[i]");
+#else
     WRITE_CODE(sei.m_posProcessingOrder[i], 8, "sei_processingOrder[i]");
+#endif
   }
 }
 
-- 
GitLab