From d2215da2cd5454247eac4d385bf6de37f491ba4c Mon Sep 17 00:00:00 2001
From: Zizheng Liu <lzz8246@whu.edu.cn>
Date: Sat, 18 May 2019 20:53:30 +0200
Subject: [PATCH] Fix the huge loss in rate control with the macro WCG_EXT
 enabled by In-Loop Reshaping by saving the unadjusted lambda for RD cost
 before encoding current CTU. This commit has removed the macro as
 recommended.

---
 source/Lib/EncoderLib/EncSlice.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/source/Lib/EncoderLib/EncSlice.cpp b/source/Lib/EncoderLib/EncSlice.cpp
index 6162902dfa..be6ec8168c 100644
--- a/source/Lib/EncoderLib/EncSlice.cpp
+++ b/source/Lib/EncoderLib/EncSlice.cpp
@@ -1702,6 +1702,9 @@ void EncSlice::encodeCtus( Picture* pcPic, const bool bCompressEntireSlice, cons
 
         estQP     = Clip3( -pcSlice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, estQP );
 
+#if WCG_EXT
+        pRdCost->saveUnadjustedLambda();
+#endif
         pRdCost->setLambda(estLambda, pcSlice->getSPS()->getBitDepths());
 
 #if RDOQ_CHROMA_LAMBDA
-- 
GitLab