From 54507e3a81f5bd9d0fbac0fd786004b04c3e19bb Mon Sep 17 00:00:00 2001
From: Tung Nguyen <tung.nguyen@hhi.fraunhofer.de>
Date: Fri, 1 Nov 2019 09:01:29 +0100
Subject: [PATCH] cost calculation checked, fixed issue when RDPCM is on

---
 source/Lib/CommonLib/RdCost.cpp       | 2 +-
 source/Lib/EncoderLib/IntraSearch.cpp | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source/Lib/CommonLib/RdCost.cpp b/source/Lib/CommonLib/RdCost.cpp
index b0b617a18..0b384017a 100644
--- a/source/Lib/CommonLib/RdCost.cpp
+++ b/source/Lib/CommonLib/RdCost.cpp
@@ -68,7 +68,7 @@ double RdCost::calcRdCost( uint64_t fracBits, Distortion distortion )
 #if JVET_AHG14_LOSSLESS
   if( m_costMode == COST_LOSSLESS_CODING && 0 != distortion )
   {
-    return MAX_DOUBLE / 8;
+    return MAX_DOUBLE;
   }
 #endif
 #if WCG_EXT
diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp
index 8343f7aeb..0acd202fb 100644
--- a/source/Lib/EncoderLib/IntraSearch.cpp
+++ b/source/Lib/EncoderLib/IntraSearch.cpp
@@ -3188,7 +3188,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp
 #endif
     }
 #if JVET_AHG14_LOSSLESS
-    if( !( m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && tu.mtsIdx[compID] == 0 ) )
+    if( !( m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && tu.mtsIdx[compID] == 0 ) || tu.cu->bdpcmMode != 0 )
     {
       m_pcTrQuant->transformNxN(tu, compID, cQP, uiAbsSum, m_CABACEstimator->getCtx(), loadTr);
     }
@@ -3207,7 +3207,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp
   }
 
 #if JVET_AHG14_LOSSLESS
-  if( m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && tu.mtsIdx[compID] == 0 )
+  if( ( m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && tu.mtsIdx[compID] == 0 ) && 0 == tu.cu->bdpcmMode )
   {
     uiAbsSum = 0;
     tu.getCoeffs( compID ).fill( 0 );
-- 
GitLab