From d6023cffcfa9832d65906d367e7299d64f97c575 Mon Sep 17 00:00:00 2001
From: Vadim Seregin <vseregin@qti.qualcomm.com>
Date: Thu, 22 Aug 2019 16:25:04 -0700
Subject: [PATCH] replace assert and make config parameter to take fraction of
 encoded frames

---
 source/App/EncoderApp/EncAppCfg.cpp | 6 +++---
 source/App/EncoderApp/EncAppCfg.h   | 2 +-
 source/Lib/Utilities/VideoIOYuv.cpp | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp
index 7f60c40df..80bdead40 100644
--- a/source/App/EncoderApp/EncAppCfg.cpp
+++ b/source/App/EncoderApp/EncAppCfg.cpp
@@ -1385,7 +1385,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
 #if JVET_O1164_RPR
   ( "ScalingRatioHor",                                m_scalingRatioHor,                          1.0, "Scaling ratio in hor direction" )
   ( "ScalingRatioVer",                                m_scalingRatioVer,                          1.0, "Scaling ratio in ver direction" )
-  ( "HalfFrames",                                     m_halfFrames,                             false, "Encode half of the specified in FramesToBeEncoded" )
+  ( "FractionNumFrames",                              m_fractionOfFrames,                         1.0, "Encode a fraction of the specified in FramesToBeEncoded frames" )
   ( "SwitchPocPeriod",                                m_switchPocPeriod,                            0, "Switch POC period for RPR" )
   ( "UpscaledOutput",                                 m_upscaledOutput,                             0, "Upscaled output for RPR" )
 #endif
@@ -1416,9 +1416,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
    
 #if JVET_O1164_RPR
   m_rprEnabled = m_scalingRatioHor != 1.0 || m_scalingRatioVer != 1.0;
-  if( m_halfFrames )
+  if( m_fractionOfFrames != 1.0 )
   {
-    m_framesToBeEncoded >>= 1;
+    m_framesToBeEncoded = int( m_framesToBeEncoded * m_fractionOfFrames );
   }
 
   if( m_rprEnabled && !m_switchPocPeriod )
diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h
index c347a34af..9e3a47729 100644
--- a/source/App/EncoderApp/EncAppCfg.h
+++ b/source/App/EncoderApp/EncAppCfg.h
@@ -614,7 +614,7 @@ protected:
   double      m_scalingRatioHor;
   double      m_scalingRatioVer;
   bool        m_rprEnabled;
-  bool        m_halfFrames;                                   ///< encode only half of the frames as specified in CTC
+  double      m_fractionOfFrames;                             ///< encode a fraction of the frames as specified in FramesToBeEncoded
   int         m_switchPocPeriod;
   int         m_upscaledOutput;                               ////< Output upscaled (2), decoded cropped but in full resolution buffer (1) or decoded cropped (0, default) picture for RPR.
 #endif
diff --git a/source/Lib/Utilities/VideoIOYuv.cpp b/source/Lib/Utilities/VideoIOYuv.cpp
index c465a7342..1f5dc4bf9 100644
--- a/source/Lib/Utilities/VideoIOYuv.cpp
+++ b/source/Lib/Utilities/VideoIOYuv.cpp
@@ -477,8 +477,8 @@ static bool writePlane(ostream& fd, const Pel* src,
   const bool     writePYUV   = (packedYUVOutputMode > 0) && (fileBitDepth == 10 || fileBitDepth == 12) && ((width_file & (1 + (fileBitDepth & 3))) == 0);
 
 #if JVET_O1164_RPR
-  assert( writePYUV == 0 ); // only support this so far
-  assert( csx_file == csx_src ); // only support this so far
+  CHECK( writePYUV, "Not supported" );
+  CHECK( csx_file != csx_src, "Not supported" );
   const uint32_t stride_file = writePYUV ? ( orgWidth * fileBitDepth ) >> ( csx_file + 3 ) : ( orgWidth * ( is16bit ? 2 : 1 ) ) >> csx_file;
 #else
   const uint32_t stride_file = writePYUV ? (width444 * fileBitDepth) >> (csx_file + 3) : (width444 * (is16bit ? 2 : 1)) >> csx_file;
-- 
GitLab