From a772f856a7b31f3ac93607741105a8785e59e972 Mon Sep 17 00:00:00 2001
From: Karl Sharman <karl.sharman@sony.com>
Date: Fri, 1 Feb 2019 14:55:03 +0000
Subject: [PATCH] Fix interaction with fast encoder search of M0464.

---
 source/Lib/CommonLib/TrQuant.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/source/Lib/CommonLib/TrQuant.cpp b/source/Lib/CommonLib/TrQuant.cpp
index f6192a5a1..7d03708bc 100644
--- a/source/Lib/CommonLib/TrQuant.cpp
+++ b/source/Lib/CommonLib/TrQuant.cpp
@@ -513,7 +513,16 @@ void TrQuant::transformNxN(TransformUnit &tu, const ComponentID &compID, const Q
       sumAbs += abs( tempCoeff.buf[pos] );
     }
 
+#if JVET_M0119_NO_TRANSFORM_SKIP_QUANTISATION_ADJUSTMENT
+    double scaleSAD=1.0;
+    if (isLuma(compID) && tu.mtsIdx==1 && ((g_aucLog2[width] + g_aucLog2[height]) & 1) == 1 )
+    {
+      scaleSAD=1.0/1.414213562; // compensate for not scaling transform skip coefficients by 1/sqrt(2)
+    }
+    trCosts.push_back( TrCost( int(sumAbs*scaleSAD), pos++ ) );
+#else
     trCosts.push_back( TrCost( sumAbs, pos++ ) );
+#endif
     it++;
   }
 
-- 
GitLab