From 3dd743bdbc7262ed4210b1587db3d6fc403a8b52 Mon Sep 17 00:00:00 2001
From: Antti Hallapuro <antti.hallapuro@nokia.com>
Date: Mon, 18 Nov 2024 15:54:46 +0200
Subject: [PATCH] JVET-AJ0241: Text description SEI purpose for encoder
 description

---
 cfg/sei_vui/text_description_information.cfg | 2 +-
 source/App/EncoderApp/EncAppCfg.cpp          | 8 ++++++++
 source/Lib/CommonLib/TypeDef.h               | 3 +++
 source/Lib/EncoderLib/SEIwrite.cpp           | 4 ++++
 4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/cfg/sei_vui/text_description_information.cfg b/cfg/sei_vui/text_description_information.cfg
index 802960971..054761476 100644
--- a/cfg/sei_vui/text_description_information.cfg
+++ b/cfg/sei_vui/text_description_information.cfg
@@ -3,7 +3,7 @@ SEITextDescriptionID:                                        1 # Indentifier val
 SEITextDescriptionCancelFlag:                                0 # if 1 cancels the persistence of any previous text description information SEI message with the same txt_descr_id
 SEITextDescriptionIDCancelFlag:                              0 # if 1 cancels the persistence of any previous text description information SEI message with the same txt_descr_id and the same txt_descr_purpose
 SEITextDescriptionPersistenceFlag:                           1 # if 1 enables the the persistence of the text information description message for the current layer
-SEITextDescriptionPurpose:                                   1 # Indicates the purpose of the text description, must be in the range 0-5
+SEITextDescriptionPurpose:                                   1 # Indicates the purpose of the text description, must be in the range 0-6
 SEITextDescriptionsNumStringsMinus1:                         0 # Specifies the number of entries plus 1 for  SEITextDescriptionStringLang[i] and SEITextDescriptionString[i]
 SEITextDescriptionStringLang0:                           en-US # Specifies the language of the txt_descr_string[ i ]
 SEITextDescriptionString0:                                test # Specifies i-th text description information string
diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp
index 7dbd3c3f3..32cac35ec 100644
--- a/source/App/EncoderApp/EncAppCfg.cpp
+++ b/source/App/EncoderApp/EncAppCfg.cpp
@@ -2105,7 +2105,11 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   opts.addOptions()("SEITextDescriptionCancelFlag", m_SEITextCancelFlag, true, "Cancels the persistence of any previous text description information SEI message with the same txt_descr_id");
 #endif
   opts.addOptions()("SEITextDescriptionPersistenceFlag", m_SEITextPersistenceFlag, true, "Specifies the persistence of the text information description message for the current layer");
+#if JVET_AJ0241_TXTDESCRINFO_SEI_ENCODER_DESCR
+  opts.addOptions()("SEITextDescriptionPurpose", m_SEITextDescriptionPurpose, 0u, "Indicates the purpose of the text description, must be in the range 0-6");
+#else
   opts.addOptions()("SEITextDescriptionPurpose", m_SEITextDescriptionPurpose, 0u, "Indicates the purpose of the text description, must be in the range 0-5");
+#endif
   opts.addOptions()("SEITextDescriptionsNumStringsMinus1", m_SEITextNumStringsMinus1, 0u, "Indicates the number of entries plus 1 for txt_descr_string_lang[ i ] and txt_descr_string[ i ]");
   m_SEITextDescriptionStringLang.resize(256);
   m_SEITextDescriptionString.resize(256);
@@ -5420,7 +5424,11 @@ bool EncAppCfg::xCheckParameter()
 
 #if JVET_AH2006_TXTDESCRINFO_SEI
   xConfirmPara(m_SEITextDescriptionID < 1 && m_SEITextDescriptionID > 16383, "m_SEITextDescriptionID must be in the range of 1 to 16383, inclusive");
+#if  JVET_AJ0241_TXTDESCRINFO_SEI_ENCODER_DESCR
+  xConfirmPara(m_SEITextDescriptionPurpose > 6, "m_SEITextDescriptionPurpose must be in the range of 0 to 6, inclusive");
+#else
   xConfirmPara(m_SEITextDescriptionPurpose > 5, "m_SEITextDescriptionPurpose must be in the range of 0 to 5, inclusive");
+#endif
   xConfirmPara(m_SEITextNumStringsMinus1 > 255, "m_SEITextNumStringsMinus1 must be in the range 0f 0 to 255, inclusive");
 #endif
 
diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h
index bdbe06138..fcb8cffb1 100644
--- a/source/Lib/CommonLib/TypeDef.h
+++ b/source/Lib/CommonLib/TypeDef.h
@@ -87,6 +87,9 @@
 #if JVET_AH2006_TXTDESCRINFO_SEI
 #define JVET_AI0059_TXTDESCRINFO_SEI_PERSISTANCE          1 // Define persistence scop for text description information SEI to be purpose specific
 #endif
+#if JVET_AH2006_TXTDESCRINFO_SEI
+#define JVET_AJ0241_TXTDESCRINFO_SEI_ENCODER_DESCR        1 // Text description SEI purpose for encoder description
+#endif
 
 
 #define REUSE_CU_RESULTS                                  1
diff --git a/source/Lib/EncoderLib/SEIwrite.cpp b/source/Lib/EncoderLib/SEIwrite.cpp
index 18c0246f1..62988ca2b 100644
--- a/source/Lib/EncoderLib/SEIwrite.cpp
+++ b/source/Lib/EncoderLib/SEIwrite.cpp
@@ -2104,7 +2104,11 @@ void SEIWriter::xWriteSEINeuralNetworkPostFilterActivation(const SEINeuralNetwor
 void SEIWriter::xWriteSEITextDescription(const SEITextDescription &sei)
 {
 #if JVET_AI0059_TXTDESCRINFO_SEI_PERSISTANCE
+#if JVET_AJ0241_TXTDESCRINFO_SEI_ENCODER_DESCR
+  CHECK(sei.m_textDescriptionPurpose > 6, "txt_descr_purpose shall be in the range 0-6");
+#else
   CHECK(sei.m_textDescriptionPurpose > 5, "txt_descr_purpose shall be in the range 0-5");
+#endif
   xWriteCode(sei.m_textDescriptionPurpose, 8, "txt_descr_purpose");
 #else
   CHECK((sei.m_textDescriptionID < 1 || sei.m_textDescriptionID > 16383), "text description id must be in the range 1-16383");
-- 
GitLab