From 9bee106fea319de2d9ecf09055026940ee4683f3 Mon Sep 17 00:00:00 2001
From: Frank Bossen <fbossen@gmail.com>
Date: Thu, 5 Dec 2019 12:31:03 -0500
Subject: [PATCH] Fix #748: reduce amount of picture padding for RPR, remove 4x
 RPR cfg

---
 cfg/rpr/scale4.0x.cfg                    | 6 ------
 source/Lib/CommonLib/CommonDef.h         | 2 +-
 source/Lib/CommonLib/InterPrediction.cpp | 2 +-
 3 files changed, 2 insertions(+), 8 deletions(-)
 delete mode 100644 cfg/rpr/scale4.0x.cfg

diff --git a/cfg/rpr/scale4.0x.cfg b/cfg/rpr/scale4.0x.cfg
deleted file mode 100644
index 62211a4aa6..0000000000
--- a/cfg/rpr/scale4.0x.cfg
+++ /dev/null
@@ -1,6 +0,0 @@
-# Reference picture resampling CE settings for scaling ratio and number of encoded frames
-
-ScalingRatioHor                     : 4.0
-ScalingRatioVer                     : 4.0
-FractionNumFrames                   : 0.5
-UpscaledOutput                      : 1
diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h
index acea627bf4..34ff090776 100644
--- a/source/Lib/CommonLib/CommonDef.h
+++ b/source/Lib/CommonLib/CommonDef.h
@@ -494,7 +494,7 @@ static const int  EPBIN_WEIGHT_FACTOR =                           4;
 #endif
 static const int ENC_PPS_ID_RPR =                                 3;
 static const int SCALE_RATIO_BITS =                              14;
-static const int MAX_SCALING_RATIO =                              8;  // max scaling ratio allowed in the software, it is used to allocated an internla buffer in the rescaling
+static const int MAX_SCALING_RATIO =                              2;  // max downsampling ratio for RPR
 static const std::pair<int, int> SCALE_1X = std::pair<int, int>( 1 << SCALE_RATIO_BITS, 1 << SCALE_RATIO_BITS );  // scale ratio 1x
 #if JVET_P0517_ADAPTIVE_COLOR_TRANSFORM
 static const int DELTA_QP_FOR_Y_Cg =                             -5;
diff --git a/source/Lib/CommonLib/InterPrediction.cpp b/source/Lib/CommonLib/InterPrediction.cpp
index 5fd27ca654..18c7a8f9e2 100644
--- a/source/Lib/CommonLib/InterPrediction.cpp
+++ b/source/Lib/CommonLib/InterPrediction.cpp
@@ -2766,7 +2766,7 @@ bool InterPrediction::xPredInterBlkRPR( const std::pair<int, int>& scalingRatio,
 
     refHeight = std::max<int>( 1, refHeight );
 
-    CHECK( MAX_CU_SIZE * MAX_SCALING_RATIO < refHeight + vFilterSize - 1 + extSize, "Buffer size is not enough, increase MAX_SCALING_RATIO" );
+    CHECK( MAX_CU_SIZE * MAX_SCALING_RATIO + 16 < refHeight + vFilterSize - 1 + extSize, "Buffer is not large enough, increase MAX_SCALING_RATIO" );
 
     Pel buffer[( MAX_CU_SIZE + 16 ) * ( MAX_CU_SIZE * MAX_SCALING_RATIO + 16 )];
 
-- 
GitLab