From 18da04524bf1fa2dfdac14ad8dfe2ccb3432f247 Mon Sep 17 00:00:00 2001
From: Luong Pham Van <lphamvan@qti.qualcomm.com>
Date: Fri, 2 Aug 2019 15:03:51 -0700
Subject: [PATCH] Consistent  check for encoder and decoder

---
 source/App/EncoderApp/EncAppCfg.cpp | 10 +++++-----
 source/Lib/DecoderLib/VLCReader.cpp |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp
index f78c1673e9..4715e0e251 100644
--- a/source/App/EncoderApp/EncAppCfg.cpp
+++ b/source/App/EncoderApp/EncAppCfg.cpp
@@ -2515,10 +2515,7 @@ bool EncAppCfg::xCheckParameter()
   xConfirmPara( m_uiMinQT[1] < 1<<MIN_CU_LOG2,                                              "Minimum QT size should be larger than or equal to 4");
   xConfirmPara( m_uiCTUSize < 16,                                                           "Maximum partition width size should be larger than or equal to 16");
   xConfirmPara( m_uiCTUSize < 16,                                                           "Maximum partition height size should be larger than or equal to 16");
-#if JVET_O0640_PICTURE_SIZE_CONSTRAINT
-  xConfirmPara( (m_iSourceWidth  % (1<<std::max(3, MIN_CU_LOG2)))!=0,                       "Resulting coded frame width must be a multiple of Max(8, the minimum unit size)");
-  xConfirmPara( (m_iSourceHeight % (1<<std::max(3, MIN_CU_LOG2)))!=0,                       "Resulting coded frame height must be a multiple of Max(8, the minimum unit size)");
-#else
+#if !JVET_O0640_PICTURE_SIZE_CONSTRAINT
   xConfirmPara( (m_iSourceWidth  % (1<<MIN_CU_LOG2))!=0,                                    "Resulting coded frame width must be a multiple of the minimum unit size");
   xConfirmPara( (m_iSourceHeight % (1<<MIN_CU_LOG2))!=0,                                    "Resulting coded frame height must be a multiple of the minimum unit size");
   xConfirmPara( (m_iSourceWidth  % (1<<MIN_CU_LOG2))!=0,                                    "Resulting coded frame width must be a multiple of the minimum unit size");
@@ -2531,7 +2528,10 @@ bool EncAppCfg::xCheckParameter()
   xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4,                                    "Minimum partition height size should be larger than or equal to 8");
   xConfirmPara( m_uiMaxCUWidth < 16,                                                        "Maximum partition width size should be larger than or equal to 16");
   xConfirmPara( m_uiMaxCUHeight < 16,                                                       "Maximum partition height size should be larger than or equal to 16");
-#if !JVET_O0640_PICTURE_SIZE_CONSTRAINT
+#if JVET_O0640_PICTURE_SIZE_CONSTRAINT
+  xConfirmPara( (m_iSourceWidth  % (std::max(8, int(m_uiMaxCUWidth  >> (m_uiMaxCUDepth - 1))))) != 0, "Resulting coded frame width must be a multiple of Max(8, the minimum CU size)");
+  xConfirmPara( (m_iSourceHeight % (std::max(8, int(m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1))))) != 0, "Resulting coded frame height must be a multiple of Max(8, the minimum CU size)");
+#else
   xConfirmPara( (m_iSourceWidth  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame width must be a multiple of the minimum CU size");
   xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame height must be a multiple of the minimum CU size");
 #endif
diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp
index 90636109e1..8b13b830dc 100644
--- a/source/Lib/DecoderLib/VLCReader.cpp
+++ b/source/Lib/DecoderLib/VLCReader.cpp
@@ -1191,8 +1191,8 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS)
   pcSPS->setLog2MinCodingBlockSize(log2MinCUSize);
 
 #if JVET_O0640_PICTURE_SIZE_CONSTRAINT
-  CHECK((pcSPS->getPicWidthInLumaSamples() % (1 << std::max(3, log2MinCUSize))) != 0, "Coded frame width must be a multiple of Max(8, the minimum unit size)");
-  CHECK((pcSPS->getPicHeightInLumaSamples() % (1 << std::max(3, log2MinCUSize))) != 0, "Coded frame height must be a multiple of Max(8, the minimum unit size)");
+  CHECK((pcSPS->getPicWidthInLumaSamples()  % (std::max(8, int(pcSPS->getMaxCUWidth()  >> (pcSPS->getMaxCodingDepth() - 1))))) != 0, "Coded frame width must be a multiple of Max(8, the minimum unit size)");
+  CHECK((pcSPS->getPicHeightInLumaSamples() % (std::max(8, int(pcSPS->getMaxCUHeight() >> (pcSPS->getMaxCodingDepth() - 1))))) != 0, "Coded frame height must be a multiple of Max(8, the minimum unit size)");
 #endif
 
   READ_FLAG(uiCode, "partition_constraints_override_enabled_flag"); pcSPS->setSplitConsOverrideEnabledFlag(uiCode);
-- 
GitLab