From f7f7a6012534bf35322a729835acf4e51a6eb0d0 Mon Sep 17 00:00:00 2001
From: guichunli <guichunli@tencent.com>
Date: Mon, 10 Feb 2020 16:24:27 -0800
Subject: [PATCH] In MR 1361, intra chroma minQT size are configured in chroma
 samples and converted in luma samle units in software, change the equation to
 align with the change; Added notes about the MinQTChromaISlice setting in
 software manual

---
 doc/software-manual.tex                  |  5 +++++
 source/Lib/CommonLib/UnitPartitioner.cpp | 14 ++++++--------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/doc/software-manual.tex b/doc/software-manual.tex
index 6c82974f6..1abd52b58 100644
--- a/doc/software-manual.tex
+++ b/doc/software-manual.tex
@@ -1204,6 +1204,11 @@ Defines the initial maximum depth of the multi-type tree in dual tree for luma c
 %\ShortOption{\None} &
 \Default{4} &
 Defines the initial minimum size of the quad tree in dual tree for chroma components.
+
+Note: this size is defined in chroma sample unit in configuration, and it is converted
+into luma sample unit according to the horizontal chroma subsampling ratio when applied
+in the software. In chroma format 4:2:2 case, this value shall be set to the value of
+the height of minimum chroma QT node in chroma samples.
 \\
 
 \Option{MinQTISlice} &
diff --git a/source/Lib/CommonLib/UnitPartitioner.cpp b/source/Lib/CommonLib/UnitPartitioner.cpp
index bb832878d..5b9db75c5 100644
--- a/source/Lib/CommonLib/UnitPartitioner.cpp
+++ b/source/Lib/CommonLib/UnitPartitioner.cpp
@@ -391,12 +391,9 @@ void QTBTPartitioner::canSplit( const CodingStructure &cs, bool& canNo, bool& ca
   // don't allow QT-splitting below a BT split
   if( lastSplit != CTU_LEVEL && lastSplit != CU_QUAD_SPLIT ) canQt = false;
 #if JVET_Q0471_CHROMA_QT_SPLIT_ON_HEIGHT
-#if JVET_Q0438_MONOCHROME_BUGFIXES
-  SizeType side = (chType == CHANNEL_TYPE_CHROMA) ? areaC->height : area.height;
-#else
-  SizeType side = chType == CHANNEL_TYPE_CHROMA ? areaC.height : area.height;
-#endif
-  if (side <= minQtSize)                                     canQt = false;
+  // minQtSize is in luma samples unit
+  const unsigned minQTThreshold = minQtSize >> ((int) getChannelTypeScaleX(CHANNEL_TYPE_CHROMA, area.chromaFormat) - (int) getChannelTypeScaleY(CHANNEL_TYPE_CHROMA, area.chromaFormat));
+  if( area.width <= minQTThreshold )                         canQt = false;
 #else
   if( area.width <= minQtSize )                              canQt = false;
 #endif
@@ -574,8 +571,9 @@ PartSplit QTBTPartitioner::getImplicitSplit( const CodingStructure &cs )
 #endif
     const unsigned minQtSize  = cs.pcv->getMinQtSize( *cs.slice, chType );
 #if JVET_Q0471_CHROMA_QT_SPLIT_ON_HEIGHT
-    SizeType   side           = chType == CHANNEL_TYPE_CHROMA ? currArea().Cb().height : area.height;
-    const bool isQtAllowed    = side > minQtSize && currBtDepth == 0;
+    // minQtSize is in luma samples unit
+    const unsigned minQTThreshold = minQtSize >> ((int) getChannelTypeScaleX(CHANNEL_TYPE_CHROMA, area.chromaFormat) - (int) getChannelTypeScaleY(CHANNEL_TYPE_CHROMA, area.chromaFormat));
+    const bool isQtAllowed    = area.width > minQTThreshold && currBtDepth == 0;
 #else
     const bool isQtAllowed    = area.width >  minQtSize && area.height >  minQtSize && currBtDepth == 0;
 #endif
-- 
GitLab