From 1ef23bfd9b0c392fe83c38f485627f756e304cf2 Mon Sep 17 00:00:00 2001
From: Frank Plowman <frankplow@xiaomi.com>
Date: Mon, 25 Nov 2024 17:13:14 +0000
Subject: [PATCH] Fix KEEP_PRED_AND_RESI_SIGNALS

---
 source/Lib/CommonLib/Picture.cpp |  8 ++++++++
 source/Lib/DecoderLib/DecCu.cpp  | 13 +++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/source/Lib/CommonLib/Picture.cpp b/source/Lib/CommonLib/Picture.cpp
index e1e609a75..6dbf17a2a 100644
--- a/source/Lib/CommonLib/Picture.cpp
+++ b/source/Lib/CommonLib/Picture.cpp
@@ -312,10 +312,18 @@ void Picture::createTempBuffers( const unsigned _maxCUSize, bool useFilterFrame,
 #endif
     if (!decoder)
     {
+#if JVET_AC0162_ALF_RESIDUAL_SAMPLES_INPUT && !KEEP_PRED_AND_RESI_SIGNALS
       M_BUFS(jId, PIC_TRUE_ORIGINAL).create(chromaFormat, aOld, _maxCUSize);
+#else
+      M_BUFS(jId, PIC_TRUE_ORIGINAL).create(chromaFormat, a, _maxCUSize);
+#endif
       if (useFilterFrame)
       {
+#if JVET_AC0162_ALF_RESIDUAL_SAMPLES_INPUT && !KEEP_PRED_AND_RESI_SIGNALS
         M_BUFS(jId, PIC_FILTERED_ORIGINAL).create(chromaFormat, aOld, _maxCUSize);
+#else
+        M_BUFS(jId, PIC_FILTERED_ORIGINAL).create(chromaFormat, a, _maxCUSize);
+#endif
       }
       if (resChange)
       {
diff --git a/source/Lib/DecoderLib/DecCu.cpp b/source/Lib/DecoderLib/DecCu.cpp
index f78eade4f..38ceb1e0c 100644
--- a/source/Lib/DecoderLib/DecCu.cpp
+++ b/source/Lib/DecoderLib/DecCu.cpp
@@ -1586,9 +1586,6 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID )
     }
 #endif
   }
-#if KEEP_PRED_AND_RESI_SIGNALS
-  pReco.reconstruct( piPred, piResi, tu.cu->cs->slice->clpRng( compID ) );
-#else
 #if JVET_AG0145_ADAPTIVE_CLIPPING
   ClpRng clpRng = tu.cu->cs->slice->clpRng(compID);
   if (compID == COMPONENT_Y)
@@ -1605,12 +1602,20 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID )
       clpRng.max = cs.slice->getLumaPelMax();
     }
   }
+#if KEEP_PRED_AND_RESI_SIGNALS
+  pReco.reconstruct(piPred, piResi, clpRng);
+#else
   piPred.reconstruct(piPred, piResi, clpRng);
+  pReco.copyFrom( piPred );
+#endif
+#else
+#if KEEP_PRED_AND_RESI_SIGNALS
+  pReco.reconstruct( piPred, piResi, tu.cu->cs->slice->clpRng( compID ) );
 #else
   piPred.reconstruct( piPred, piResi, tu.cu->cs->slice->clpRng( compID ) );
-#endif
   pReco.copyFrom( piPred );
 #endif
+#endif
 
 #if JVET_AC0071_DBV && JVET_AA0070_RRIBC
 #if JVET_AH0136_CHROMA_REORDERING
-- 
GitLab