Add support for multiple configurations in playuverTools
This commit is contained in:
1 parent
eff93de754
commit
d151b11c8c
6 files changed
+113
-75
No files matched your search
+52
-49
@@ -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 += " ";
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in new issue
Block a user