From 49575fb512affda6e85a52d3d865abf8b69186eb Mon Sep 17 00:00:00 2001
From: "hm.jang" <hm.jang@lge.com>
Date: Wed, 29 Jul 2020 08:59:17 +0900
Subject: [PATCH] implement JVET-S0219 aspect2 below.

Move the signalling of aps_params_type to an earlier position and change the signalling of aps_adaptation_parameter_set_id

AHG Recommendation (cleanup): Just change the order to put the type before the ID.
---
 source/Lib/CommonLib/TypeDef.h      | 1 +
 source/Lib/DecoderLib/VLCReader.cpp | 8 +++++++-
 source/Lib/EncoderLib/VLCWriter.cpp | 5 +++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h
index 8c101eb5a..00064bcc8 100644
--- a/source/Lib/CommonLib/TypeDef.h
+++ b/source/Lib/CommonLib/TypeDef.h
@@ -51,6 +51,7 @@
 #include <cassert>
 
 //########### place macros to be removed in next cycle below this line ###############
+#define JVET_S0219_ASPECT2_CHANGE_ORDER_APS_PARAMS_TYPE   1 // JVET-S0219 aspect2: change the order to put the aps_params_type before the aps_adaptation_parameter_set_id.
 
 #define JVET_S0081_NON_REFERENCED_PIC                     1 // JVET-S0081: exclude non-referenced picture to be used as prevTid0 picture
 
diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp
index d53a40127..32dce813f 100644
--- a/source/Lib/DecoderLib/VLCReader.cpp
+++ b/source/Lib/DecoderLib/VLCReader.cpp
@@ -913,13 +913,19 @@ void HLSyntaxReader::parseAPS( APS* aps )
 #endif
 
   uint32_t  code;
+#if JVET_S0219_ASPECT2_CHANGE_ORDER_APS_PARAMS_TYPE
+  READ_CODE(3, code, "aps_params_type");
+  aps->setAPSType(ApsType(code));
 
   READ_CODE(5, code, "adaptation_parameter_set_id");
   aps->setAPSId(code);
+#else
+  READ_CODE(5, code, "adaptation_parameter_set_id");
+  aps->setAPSId(code);
 
   READ_CODE(3, code, "aps_params_type");
   aps->setAPSType( ApsType(code) );
-
+#endif
 #if JVET_R0433
   uint32_t codeApsChromaPresentFlag;
   READ_FLAG(codeApsChromaPresentFlag, "aps_chroma_present_flag");
diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp
index bf9ab2d34..02d20201a 100644
--- a/source/Lib/EncoderLib/VLCWriter.cpp
+++ b/source/Lib/EncoderLib/VLCWriter.cpp
@@ -515,8 +515,13 @@ void HLSWriter::codeAPS( APS* pcAPS )
   xTraceAPSHeader();
 #endif
 
+#if JVET_S0219_ASPECT2_CHANGE_ORDER_APS_PARAMS_TYPE
+  WRITE_CODE((int)pcAPS->getAPSType(), 3, "aps_params_type");
+  WRITE_CODE(pcAPS->getAPSId(), 5, "adaptation_parameter_set_id");
+#else
   WRITE_CODE(pcAPS->getAPSId(), 5, "adaptation_parameter_set_id");
   WRITE_CODE( (int)pcAPS->getAPSType(), 3, "aps_params_type" );
+#endif
 #if JVET_R0433
   WRITE_FLAG(pcAPS->chromaPresentFlag, "aps_chroma_present_flag");
 #endif
-- 
GitLab