From 343c8c65d447e74f2792898fbf44c84a4cc0d6dd Mon Sep 17 00:00:00 2001
From: Taoran Lu <tlu@dolby.com>
Date: Mon, 25 Sep 2023 12:49:27 -0700
Subject: [PATCH] fix1612

---
 cfg/sei_vui/sei_processing_order.cfg | 1 +
 source/App/EncoderApp/EncAppCfg.cpp  | 2 +-
 source/Lib/DecoderLib/SEIread.cpp    | 1 +
 source/Lib/EncoderLib/SEIwrite.cpp   | 5 +++--
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/cfg/sei_vui/sei_processing_order.cfg b/cfg/sei_vui/sei_processing_order.cfg
index c246a96be..34a01dafd 100644
--- a/cfg/sei_vui/sei_processing_order.cfg
+++ b/cfg/sei_vui/sei_processing_order.cfg
@@ -1,5 +1,6 @@
 #======== SEI messages processing order ===============
 SEIPOEnabled                 : 1 			      #Enabling SEI processing order flag
+SEIPOPrefixFlag              : 1 0  0   0   1 
 SEIPOPayLoadType             : 4 19 142 211 4     #SEI PayloadTypes to be processed
 SEIPOProcessingOrder         : 3 2  1   0   4     #Processing order of SEI payload types
 SEIPONumofPrefixByte         : 6 0  0   0   5
diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp
index 6a311cebc..62ee368f2 100644
--- a/source/App/EncoderApp/EncAppCfg.cpp
+++ b/source/App/EncoderApp/EncAppCfg.cpp
@@ -728,7 +728,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   SMultiValueInput<uint32_t>   cfg_FgcSEICompModelValueComp1              (0, 65535,  0, 256 * 6);
   SMultiValueInput<uint32_t>   cfg_FgcSEICompModelValueComp2              (0, 65535,  0, 256 * 6);
   SMultiValueInput<unsigned>   cfg_siiSEIInputNumUnitsInSI(0, std::numeric_limits<uint32_t>::max(), 0, 7);
-  SMultiValueInput<bool>       cfg_poSEIPrefixFlag(false, true, 0, 1);
+  SMultiValueInput<bool>       cfg_poSEIPrefixFlag(0, 1, 0, 256);
   SMultiValueInput<uint16_t>   cfg_poSEIPayloadType(0, 32768, 0, 256 * 2);
   SMultiValueInput<uint16_t>   cfg_poSEIProcessingOrder(0, 65535, 0, 65536);
 
diff --git a/source/Lib/DecoderLib/SEIread.cpp b/source/Lib/DecoderLib/SEIread.cpp
index 6955ebc63..99169bc65 100644
--- a/source/Lib/DecoderLib/SEIread.cpp
+++ b/source/Lib/DecoderLib/SEIread.cpp
@@ -747,6 +747,7 @@ void SEIReader::xParseSEIProcessingOrder(SEIProcessingOrderInfo& sei, uint32_t p
   //Since each entry is at least 4 bytes (2 byte "sei_payloadType" + 2 byte "sei_payloadOrder"),
   //the maximum number of entry is payloadSize/4
   numMaxSeiMessages = payloadSize / 4;
+  sei.m_posPrefixFlag.resize(numMaxSeiMessages);
   sei.m_posPayloadType.resize(numMaxSeiMessages);
   sei.m_posProcessingOrder.resize(numMaxSeiMessages);
   sei.m_posPrefixByte.resize(numMaxSeiMessages);
diff --git a/source/Lib/EncoderLib/SEIwrite.cpp b/source/Lib/EncoderLib/SEIwrite.cpp
index d9b9884d7..838eef217 100644
--- a/source/Lib/EncoderLib/SEIwrite.cpp
+++ b/source/Lib/EncoderLib/SEIwrite.cpp
@@ -1548,7 +1548,8 @@ void SEIWriter::xWriteSEIProcessingOrder(const SEIProcessingOrderInfo &sei)
   CHECK(sei.m_posPayloadType.size() < 2, "An SEI processing order SEI message shall contain at least two pairs sei_payloadType[i] and sei_processingOrder[i]");
   for (uint32_t i = 0; i < sei.m_posPayloadType.size(); i++)
   {
-    xWriteCode(sei.m_posPayloadType[i], 16, "po_sei_payload_type[i]");
+    xWriteFlag(sei.m_posPrefixFlag[i], "po_sei_prefix_flag[i]");
+    xWriteCode(sei.m_posPayloadType[i], 15, "po_sei_payload_type[i]");
 
     if (sei.m_posPayloadType[i] == (uint16_t) SEI::PayloadType::USER_DATA_REGISTERED_ITU_T_T35)
     {
@@ -1557,8 +1558,8 @@ void SEIWriter::xWriteSEIProcessingOrder(const SEIProcessingOrderInfo &sei)
       {
         xWriteCode(sei.m_posPrefixByte[i][j], 8, "po_t35_byte[i][j]");
       }
-      xWriteCode(sei.m_posProcessingOrder[i], 16, "po_sei_processing_order[i]");
     }
+    xWriteCode(sei.m_posProcessingOrder[i], 16, "po_sei_processing_order[i]");
   }
 }
 
-- 
GitLab