From c64511d9d46aa0f126ac3060b0c4afe095763b49 Mon Sep 17 00:00:00 2001
From: Vadim Seregin <vseregin@qti.qualcomm.com>
Date: Wed, 3 Nov 2021 03:16:22 +0000
Subject: [PATCH] Remove leftover shift in SSE and add initialization for all
 tIDs for MTT depth

---
 source/App/EncoderApp/EncAppCfg.cpp  | 7 ++++++-
 source/Lib/CommonLib/TypeDef.h       | 4 ++--
 source/Lib/CommonLib/x86/RdCostX86.h | 2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp
index bbc0ef67c..b0e1889da 100644
--- a/source/App/EncoderApp/EncAppCfg.cpp
+++ b/source/App/EncoderApp/EncAppCfg.cpp
@@ -2694,11 +2694,16 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
 #if JVET_X0144_MAX_MTT_DEPTH_TID
   CHECK( m_sMaxMTTHierarchyDepthByTid.size() > MAX_TLAYER, "MaxMTTHierarchyDepthByTid is greater than MAX_TLAYER" );
 
-  for( int i = 0; i < m_sMaxMTTHierarchyDepthByTid.size(); i++ )
+  for( int i = 0; i < (int)m_sMaxMTTHierarchyDepthByTid.size(); i++ )
   {
     CHECK( i >= MAX_TLAYER, "Index exceeds MAX_TLAYER" );
     m_maxMTTHierarchyDepthByTid[i] = std::stoul( m_sMaxMTTHierarchyDepthByTid.substr( i, 1 ) );
   }
+
+  for( int i = (int)m_sMaxMTTHierarchyDepthByTid.size(); i < MAX_TLAYER; i++ )
+  {
+    m_maxMTTHierarchyDepthByTid[i] = m_uiMaxMTTHierarchyDepth;
+  }
 #endif
 
   // check validity of input parameters
diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h
index 38d9110f4..a0834f899 100644
--- a/source/Lib/CommonLib/TypeDef.h
+++ b/source/Lib/CommonLib/TypeDef.h
@@ -116,7 +116,7 @@
 #define JVET_X0124_TMP_SIGNAL                             1 // JVET-X0124: cleanup on signalling of intra template matching
 #endif
 #define JVET_V0130_INTRA_TMP                              1 // JVET-V0130: template matching prediction
-#define JVET_W0069_TMP_BOUNDARY								            1 // JVET-W0069: boundary handling for TMP
+#define JVET_W0069_TMP_BOUNDARY                           1 // JVET-W0069: boundary handling for TMP
 #define JVET_W0123_TIMD_FUSION                            1 // JVET-W0123: Template based intra mode derivation and fusion
 #if JVET_W0123_TIMD_FUSION
 #define JVET_X0148_TIMD_PDPC                              1 // JVET-X0148: PDPC handling for TIMD
@@ -189,7 +189,7 @@
 #define ENABLE_SIMD_SIGN_PREDICTION                       1
 #endif
 #if JVET_V0130_INTRA_TMP
-#define ENABLE_SIMD_TMP									                  1
+#define ENABLE_SIMD_TMP                                   1
 #endif
 #if JVET_V0094_BILATERAL_FILTER
 #define ENABLE_SIMD_BILATERAL_FILTER                      1
diff --git a/source/Lib/CommonLib/x86/RdCostX86.h b/source/Lib/CommonLib/x86/RdCostX86.h
index 0bbbe46e5..6225c46a6 100644
--- a/source/Lib/CommonLib/x86/RdCostX86.h
+++ b/source/Lib/CommonLib/x86/RdCostX86.h
@@ -421,7 +421,7 @@ Distortion RdCost::xGetSSE_NxN_SIMD(const DistParam &rcDtParam)
         Sum = _mm256_add_epi64( _mm256_unpacklo_epi32( Sum, vzero ), _mm256_unpackhi_epi32( Sum, vzero ) );
         Sum = _mm256_add_epi64( Sum, _mm256_permute4x64_epi64( Sum, 14 ) );
         Sum = _mm256_add_epi64( Sum, _mm256_permute4x64_epi64( Sum, 1 ) );
-        uiRet += _mm_cvtsi128_si64( _mm256_castsi256_si128( Sum ) ) >> uiShift;
+        uiRet += _mm_cvtsi128_si64( _mm256_castsi256_si128( Sum ) );
       }
       uiRet >>= uiShift;
 #endif
-- 
GitLab