From f1d230149a61d241f4525cd5d51a719f7f3c1f76 Mon Sep 17 00:00:00 2001
From: jennylai <jenny.lai@mediatek.com>
Date: Mon, 11 May 2020 09:15:26 +0800
Subject: [PATCH] JVET-R0055 handle non-existent QM in 4:0:0 case

---
 source/Lib/CommonLib/TypeDef.h      |  2 ++
 source/Lib/DecoderLib/VLCReader.cpp | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h
index 23b294555..1824ed678 100644
--- a/source/Lib/CommonLib/TypeDef.h
+++ b/source/Lib/CommonLib/TypeDef.h
@@ -51,6 +51,8 @@
 #include <cassert>
 
 //########### place macros to be removed in next cycle below this line ###############
+#define JVET_R0055_HANDLING_NON_EXISTENT_QM               1 // JVET-R0055: infer chroma scaling lists to be all 16 in 4:0:0 by copy mode flag
+
 #define JVET_R0483_SH_TSRC_DISABLED_FLAG_CLEANUP          1 // JVET-R0483 Comb 4: R0049 + R0271, only R0049 method 3 aspect (Skip signaling sh_ts_residual_coding_disabled_flag when sps_transform_skip_enabled_flag = 0, also proposed in R0068, R0097, R0142, R0153) as R0271 has its own macro 
 
 #define R0324_PH_SYNTAX_CONDITION_MODIFY                  1 // JVET-R0324 add conditions on PH syntax to conder whether current pic is bi-predictive picture
diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp
index 8d9788e8f..e867f0c08 100644
--- a/source/Lib/DecoderLib/VLCReader.cpp
+++ b/source/Lib/DecoderLib/VLCReader.cpp
@@ -4840,7 +4840,18 @@ void HLSyntaxReader::parseScalingList(ScalingList* scalingList)
   }
   else
   {
+#if JVET_R0055_HANDLING_NON_EXISTENT_QM
+    scalingListCopyModeFlag = true;
+    scalingList->setScalingListCopyModeFlag(scalingListId, scalingListCopyModeFlag);
+    scalingList->setRefMatrixId(scalingListId, (uint32_t)((int)(scalingListId)));
+    if (scalingListId >= SCALING_LIST_1D_START_16x16)
+    {
+      scalingList->setScalingListDC(scalingListId, 16);
+    }
+    scalingList->processRefMatrix(scalingListId, scalingList->getRefMatrixId(scalingListId));
+#else
     scalingList->processDefaultMatrix(scalingListId);
+#endif
   }
   }
 
-- 
GitLab