From 1a362f98f7bdd65a58725c504871056f5bba511c Mon Sep 17 00:00:00 2001
From: Antti Hallapuro <antti.hallapuro@nokia.com>
Date: Tue, 29 Aug 2023 16:11:49 +0300
Subject: [PATCH] JVET-AE0049 item 3: Change the index range in input picture
 assignment for repeated inference at the end of a bitstream

---
 source/Lib/CommonLib/SEINeuralNetworkPostFiltering.cpp | 4 ++++
 source/Lib/CommonLib/TypeDef.h                         | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/source/Lib/CommonLib/SEINeuralNetworkPostFiltering.cpp b/source/Lib/CommonLib/SEINeuralNetworkPostFiltering.cpp
index 0241477b4..075398a79 100644
--- a/source/Lib/CommonLib/SEINeuralNetworkPostFiltering.cpp
+++ b/source/Lib/CommonLib/SEINeuralNetworkPostFiltering.cpp
@@ -364,7 +364,11 @@ void SEINeuralNetworkPostFiltering::checkInputPics(
 
       if (numInputPics > 1)
       {
+#if JVET_AE0049_INDEX_RANGE
+        for (int i = j + 1; i <= (numInputPics - 1); i++)
+#else
         for (int i = j + 1; i <= (numInputPics - j - 1); i++)
+#endif
         {
           Picture *prevPic                                   = nullptr;
           Picture *prevPicWithTemporalInterleaveFramePacking = nullptr;
diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h
index f5e5779ab..8474f3a9c 100644
--- a/source/Lib/CommonLib/TypeDef.h
+++ b/source/Lib/CommonLib/TypeDef.h
@@ -85,6 +85,8 @@
 
 #define JVET_AE0049_REPEATED_INFERENCE_CONSTRAINT         1  // JVET-AE0049 item 2: Constrain the repeated inference to generate interpolated pictures up to the end of the bitstream to NNPFs that perform only picture rate upsampling
 
+#define JVET_AE0049_INDEX_RANGE                           1  // JVET-AE0049 item 3: Change the index range in input picture assignment for repeated inference at the end of a bitstream
+
 #define JVET_AE0181_SCALING_WINDOW_ENABLED                1  // JVET-AE0181: Scaling window support
 
 //########### place macros to be be kept below this line ###############
-- 
GitLab