Add support for multiple configurations in playuverTools

This commit is contained in:
jfmcarreira committed 2016-04-07 00:08:11 +01:00
1 parent eff93de754
commit d151b11c8c
6 files changed
+113 -75

No files matched your search

-5
View File
@@ -66,11 +66,6 @@ Bool PlaYUVerCmdParser::parse()
// m_cParserOptions.setDefaults();
m_aUnhandledArgs = m_cParserOptions.scanArgv( m_iArgc, ( const Char** )m_ppArgv );
// for( std::list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ )
// {
// fprintf( stderr, "Unhandled argument ignored: `%s'\n", *it );
// }
if( checkListingOpts() )
{
return false;
+6 -1
View File
@@ -1,7 +1,7 @@
/* The copyright in this software is being made available under the BSD
* License, included below. This software may be subject to other third party
* and contributor rights, including patent rights, and no such rights are
* granted under this license.
* granted under this license.
*
* Copyright (c) 2010-2014, ITU/ISO/IEC
* All rights reserved.
@@ -94,6 +94,11 @@ OptionBase* Options::getOption( const std::string& optName )
return NULL;
}
Bool Options::hasOpt( const std::string& optName )
{
return getOption( optName )->count() > 0 ? true : false;
}
void Options::addOption( OptionBase *opt )
{
Option* names = new Option();
+41 -5
View File
@@ -1,7 +1,7 @@
/* The copyright in this software is being made available under the BSD
* License, included below. This software may be subject to other third party
* and contributor rights, including patent rights, and no such rights are
* granted under this license.
* granted under this license.
*
* Copyright (c) 2010-2014, ITU/ISO/IEC
* All rights reserved.
@@ -171,8 +171,43 @@ inline void StandardOpt<T>::parse( const std::string& arg )
arg_count++;
}
/* string parsing is specialized -- copy the whole string, not just the
* first word */
template<>
inline void StandardOpt< std::vector<UInt> >::parse( const std::string& arg )
{
UInt aux_opt_storage;
std::istringstream arg_ss( arg, std::istringstream::in );
arg_ss.exceptions( std::ios::failbit );
try
{
arg_ss >> aux_opt_storage;
opt_storage.push_back( aux_opt_storage );
}
catch( ... )
{
throw ParseFailure( opt_string, arg );
}
arg_count++;
}
template<>
inline void StandardOpt< std::vector<Int> >::parse( const std::string& arg )
{
Int aux_opt_storage;
std::istringstream arg_ss( arg, std::istringstream::in );
arg_ss.exceptions( std::ios::failbit );
try
{
arg_ss >> aux_opt_storage;
opt_storage.push_back( aux_opt_storage );
}
catch( ... )
{
throw ParseFailure( opt_string, arg );
}
arg_count++;
}
/* string parsing is specialized */
template<>
inline void StandardOpt<std::string>::parse( const std::string& arg )
{
@@ -180,8 +215,7 @@ inline void StandardOpt<std::string>::parse( const std::string& arg )
arg_count++;
}
/* string parsing is specialized -- copy the whole string, not just the
* first word */
/* string vector parsing is specialized */
template<>
inline void StandardOpt<std::vector<std::string> >::parse( const std::string& arg )
{
@@ -259,6 +293,8 @@ public:
return opt_list;
}
Bool hasOpt( const std::string& optName );
void addOption( OptionBase *opt );
private:
+52 -49
View File
@@ -54,46 +54,49 @@ PlaYUVerTools::~PlaYUVerTools()
}
}
#define GET_PARAM( X , i ) X[X.size() > i ? i : X.size() - 1]
Int PlaYUVerTools::openInputs()
{
/**
* Create input streams
*/
if( m_cCmdLineHandler.Opts()["input"]->count() )
if( m_cCmdLineHandler.Opts().hasOpt( "input" ) )
{
std::string resolutionString( "" );
if( m_cCmdLineHandler.Opts()["size"]->count() )
{
resolutionString = m_cCmdLineHandler.m_strResolution;
}
std::string fmtString( "yuv420p" );
if( m_cCmdLineHandler.Opts()["pel_fmt"]->count() )
{
fmtString = m_cCmdLineHandler.m_strPelFmt;
}
UInt uiBitPerPixel = 8;
if( m_cCmdLineHandler.Opts()["bits_pel"]->count() )
{
uiBitPerPixel = m_cCmdLineHandler.m_uiBitsPerPixel;
}
UInt uiEndianness = 0;
if( m_cCmdLineHandler.Opts()["endianness"]->count() )
{
if( m_cCmdLineHandler.m_strEndianness == "big" )
{
uiEndianness = 0;
}
if( m_cCmdLineHandler.m_strEndianness == "little" )
{
uiEndianness = 1;
}
}
std::vector<std::string> inputFileNames = m_cCmdLineHandler.m_apcInputs;
std::string resolutionString( "" );
std::string fmtString( "yuv420p" );
UInt uiBitPerPixel = 8;
UInt uiEndianness = 0;
PlaYUVerStream* pcStream;
for( UInt i = 0; i < inputFileNames.size() && i < MAX_NUMBER_INPUTS; i++ )
{
if( m_cCmdLineHandler.Opts().hasOpt( "size" ) )
{
resolutionString = GET_PARAM( m_cCmdLineHandler.m_strResolution, 0 );
}
if( m_cCmdLineHandler.Opts().hasOpt( "pel_fmt" ) )
{
fmtString = GET_PARAM( m_cCmdLineHandler.m_strPelFmt, i );
}
if( m_cCmdLineHandler.Opts().hasOpt( "bits_pel" ) )
{
uiBitPerPixel = GET_PARAM( m_cCmdLineHandler.m_uiBitsPerPixel, i );
}
if( m_cCmdLineHandler.Opts().hasOpt( "endianness" ) )
{
if( GET_PARAM( m_cCmdLineHandler.m_strEndianness, i ) == "big" )
{
uiEndianness = 0;
}
if( GET_PARAM( m_cCmdLineHandler.m_strEndianness, i ) == "little" )
{
uiEndianness = 1;
}
}
pcStream = new PlaYUVerStream;
try
{
@@ -113,7 +116,7 @@ Int PlaYUVerTools::openInputs()
}
m_uiNumberOfFrames = MAX_UINT;
if( m_cCmdLineHandler.Opts()["frames"]->count() )
if( m_cCmdLineHandler.Opts().hasOpt( "frames" ) )
{
m_uiNumberOfFrames = m_cCmdLineHandler.m_iFrames;
}
@@ -144,7 +147,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
return 2;
}
if( m_cCmdLineHandler.Opts()["save"]->count() )
if( m_cCmdLineHandler.Opts().hasOpt( "save" ) )
{
if( m_apcInputStreams.size() == 0 )
{
@@ -165,7 +168,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
m_cCmdLineHandler.log( LOG_ERROR, "Invalid frame number! Use --frame option " );
return 2;
}
if( m_cCmdLineHandler.Opts()["output"]->count() )
if( m_cCmdLineHandler.Opts().hasOpt( "output" ) )
m_pcOutputFileNames.push_back( m_cCmdLineHandler.m_strOutput );
if( m_pcOutputFileNames.size() != m_apcInputStreams.size() )
{
@@ -181,7 +184,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
/**
* Check Quality operation
*/
if( m_cCmdLineHandler.Opts()["quality"]->count() )
if( m_cCmdLineHandler.Opts().hasOpt( "quality" ) )
{
std::string qualityMetric = m_cCmdLineHandler.m_strQualityMetric;
if( m_apcInputStreams.size() < 2 )
@@ -209,7 +212,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
/**
* Check Module operation
*/
if( m_cCmdLineHandler.Opts()["module"]->count() )
if( m_cCmdLineHandler.Opts().hasOpt( "module" ) )
{
std::string moduleName = m_cCmdLineHandler.m_strModule;
@@ -263,7 +266,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
{
// Check outputs
std::vector<std::string> outputFileNames;
if( m_cCmdLineHandler.Opts()["output"]->count() )
if( m_cCmdLineHandler.Opts().hasOpt( "output" ) )
outputFileNames.push_back( m_cCmdLineHandler.m_strOutput );
if( outputFileNames.size() == 1 )
@@ -343,20 +346,20 @@ Int PlaYUVerTools::QualityOperation()
std::string metric_fmt = " ";
switch( m_uiQualityMetric )
{
case PlaYUVerFrame::PSNR_METRIC:
//"PSNR_0_0"
metric_fmt += " %6.3f ";
break;
case PlaYUVerFrame::SSIM_METRIC:
//"SSIM_0_0"
metric_fmt += " %6.4f ";
break;
case PlaYUVerFrame::MSE_METRIC:
//"MSE_0_0"
metric_fmt += "%7.2f";
break;
default:
metric_fmt += " %6.3f ";
case PlaYUVerFrame::PSNR_METRIC:
//"PSNR_0_0"
metric_fmt += " %6.3f ";
break;
case PlaYUVerFrame::SSIM_METRIC:
//"SSIM_0_0"
metric_fmt += " %6.4f ";
break;
case PlaYUVerFrame::MSE_METRIC:
//"MSE_0_0"
metric_fmt += "%7.2f";
break;
default:
metric_fmt += " %6.3f ";
}
metric_fmt += " ";
+5 -6
View File
@@ -37,7 +37,6 @@ PlaYUVerToolsCmdParser::PlaYUVerToolsCmdParser()
{
m_uiLogLevel = 0;
m_bQuiet = false;
m_strPelFmt = std::string( "YUV420p" );
m_iFrames = -1;
}
@@ -69,7 +68,7 @@ Int PlaYUVerToolsCmdParser::parseToolsArgs( Int argc, Char *argv[] )
//( "input,i", m_strInput, "input file" ) /**/
( "output,o", m_strOutput, "output file" ) /**/
( "size,s", m_strResolution, "size (WxH)" ) /**/
( "pel_fmt", m_strPelFmt, "pixel format" ) /**/
( "pel_fmt,p", m_strPelFmt, "pixel format" ) /**/
( "bits_pel", m_uiBitsPerPixel, "bits per pixel" ) /**/
( "endianness", m_strEndianness, "File endianness (big, little)" ) /**/
( "frames,f", m_iFrames, "number of frames to parse" );
@@ -90,19 +89,19 @@ Int PlaYUVerToolsCmdParser::parseToolsArgs( Int argc, Char *argv[] )
m_uiLogLevel = LOG_RESULT;
}
if( Opts()["module"]->count() && Opts()["help"]->count() )
if( Opts().hasOpt("module") && Opts().hasOpt("help") )
{
listModuleHelp();
iRet = 1;
}
else if( Opts()["help"]->count() )
else if( Opts().hasOpt("help") )
{
printf( "Usage: %s modules/quality/save [options] -input=input_file [--output=output_file]\n", argv[0] );
Opts().doHelp( std::cout );
iRet = 1;
}
if( Opts()["module_list"]->count() || Opts()["module_list_full"]->count() )
if( Opts().hasOpt("module_list") || Opts().hasOpt("module_list_full") )
{
listModules();
iRet = 1;
@@ -114,7 +113,7 @@ Void PlaYUVerToolsCmdParser::listModules()
{
Bool bDetailed = false;
if( Opts()["module_list_full"]->count() )
if( Opts().hasOpt("module_list_full") )
bDetailed = true;
PlaYUVerModuleIf* pcCurrModuleIf;
+9 -9
View File
@@ -72,22 +72,22 @@ private:
Bool m_bShowHelp;
Bool m_bShowVersion;
Bool m_bQuiet;
std::vector<std::string> m_apcInputs;
std::string m_strInput;
std::vector<std::string> m_strResolution;
std::vector<std::string> m_strPelFmt;
std::vector<UInt> m_uiBitsPerPixel;
std::vector<std::string> m_strEndianness;
std::string m_strOutput;
std::string m_strResolution;
std::string m_strPelFmt;
UInt m_uiBitsPerPixel;
std::string m_strEndianness;
UInt m_uiEndianness;
Bool m_bListPelFmts;
Int64 m_iFrames;
Bool m_bListQuality;
std::string m_strQualityMetric;
Bool m_bListModules;
std::string m_strModule;
Bool m_bListPelFmts;
Bool m_bListQuality;
Bool m_bListModules;
Void listModules();
Void listModuleHelp();