From 322dad0237af32864ba00e9a7e8ba8f33735c706 Mon Sep 17 00:00:00 2001
From: Frank Bossen <fbossen@gmail.com>
Date: Sun, 3 Feb 2019 12:12:50 -0500
Subject: [PATCH] Partial fix for #161: be mindful of large blocks

Large blocks, i.e. with either width or height equal to 64, have
fewer coefficients. The number of coefficients should thus be
set accordingly
---
 source/Lib/CommonLib/DepQuant.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/source/Lib/CommonLib/DepQuant.cpp b/source/Lib/CommonLib/DepQuant.cpp
index e2dafc30..314cf117 100644
--- a/source/Lib/CommonLib/DepQuant.cpp
+++ b/source/Lib/CommonLib/DepQuant.cpp
@@ -402,7 +402,13 @@ namespace DQIntern
     m_chType              = chType;
     m_width               = width;
     m_height              = height;
+#if JVET_M0257
+    const uint32_t nonzeroWidth  = std::min<uint32_t>(JVET_C0024_ZERO_OUT_TH, m_width);
+    const uint32_t nonzeroHeight = std::min<uint32_t>(JVET_C0024_ZERO_OUT_TH, m_height);
+    m_numCoeff                   = nonzeroWidth * nonzeroHeight;
+#else
     m_numCoeff            = m_width * m_height;
+#endif
 #if JVET_M0102_INTRA_SUBPARTITIONS
     m_log2SbbWidth        = g_log2SbbSize[m_chType][ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][0];
     m_log2SbbHeight       = g_log2SbbSize[m_chType][ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][1];
@@ -415,8 +421,8 @@ namespace DQIntern
     m_sbbSize             = ( 1 << m_log2SbbSize );
     m_sbbMask             = m_sbbSize - 1;
 #if JVET_M0257
-    m_widthInSbb = std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_width) >> m_log2SbbWidth;
-    m_heightInSbb = std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_height) >> m_log2SbbHeight;
+    m_widthInSbb  = nonzeroWidth >> m_log2SbbWidth;
+    m_heightInSbb = nonzeroHeight >> m_log2SbbHeight;
 #else
     m_widthInSbb          = m_width  >> m_log2SbbWidth;
     m_heightInSbb         = m_height >> m_log2SbbHeight;
-- 
GitLab