Reorganize functions
This commit is contained in:
1 parent
1f12968b90
commit
7c608e9d38
5 files changed
+67
-40
No files matched your search
@@ -33,10 +33,10 @@
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
PlaYUVerCmdParser::PlaYUVerCmdParser( Int argc, Char *argv[] )
|
||||
PlaYUVerCmdParser::PlaYUVerCmdParser()
|
||||
{
|
||||
m_iArgc = argc;
|
||||
m_apcArgv = argv;
|
||||
m_iArgc = 0;
|
||||
m_apcArgv = NULL;
|
||||
m_ParserOptions.add( GetCommandOpts() );
|
||||
}
|
||||
|
||||
@@ -45,6 +45,12 @@ PlaYUVerCmdParser::~PlaYUVerCmdParser()
|
||||
|
||||
}
|
||||
|
||||
Void PlaYUVerCmdParser::Config( Int argc, Char *argv[] )
|
||||
{
|
||||
m_iArgc = argc;
|
||||
m_apcArgv = argv;
|
||||
}
|
||||
|
||||
po::options_description PlaYUVerCmdParser::GetCommandOpts()
|
||||
{
|
||||
po::options_description inputOpts( "Input" );
|
||||
|
||||
@@ -32,9 +32,10 @@ namespace plaYUVer
|
||||
class PlaYUVerCmdParser
|
||||
{
|
||||
public:
|
||||
PlaYUVerCmdParser( Int argc, Char *argv[] );
|
||||
PlaYUVerCmdParser();
|
||||
~PlaYUVerCmdParser();
|
||||
|
||||
Void Config( Int argc, Char *argv[] );
|
||||
Void addOptions( po::options_description );
|
||||
Bool parse();
|
||||
|
||||
|
||||
+40
-34
@@ -45,33 +45,25 @@ PlaYUVerTools::~PlaYUVerTools()
|
||||
}
|
||||
}
|
||||
|
||||
Int PlaYUVerTools::Open( Int argc, Char *argv[] )
|
||||
Int PlaYUVerTools::openInputs()
|
||||
{
|
||||
|
||||
PlaYUVerCmdParser cCommandLineParser( argc, argv );
|
||||
|
||||
if( !cCommandLineParser.parse() )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create input streams
|
||||
*/
|
||||
if( cCommandLineParser.getOptionsMap().count( "input" ) )
|
||||
if( m_cCommandLineParser.getOptionsMap().count( "input" ) )
|
||||
{
|
||||
std::string resolutionString;
|
||||
if( cCommandLineParser.getOptionsMap().count( "size" ) )
|
||||
if( m_cCommandLineParser.getOptionsMap().count( "size" ) )
|
||||
{
|
||||
resolutionString = cCommandLineParser.getOptionsMap()["size"].as<std::string>();
|
||||
resolutionString = m_cCommandLineParser.getOptionsMap()["size"].as<std::string>();
|
||||
}
|
||||
std::string fmtString( "yuv420p" );
|
||||
if( cCommandLineParser.getOptionsMap().count( "pel_fmt" ) )
|
||||
if( m_cCommandLineParser.getOptionsMap().count( "pel_fmt" ) )
|
||||
{
|
||||
fmtString = cCommandLineParser.getOptionsMap()["pel_fmt"].as<std::string>();
|
||||
fmtString = m_cCommandLineParser.getOptionsMap()["pel_fmt"].as<std::string>();
|
||||
}
|
||||
|
||||
std::vector<std::string> inputFileNames = cCommandLineParser.getOptionsMap()["input"].as<std::vector<std::string> >();
|
||||
std::vector<std::string> inputFileNames = m_cCommandLineParser.getOptionsMap()["input"].as<std::vector<std::string> >();
|
||||
|
||||
PlaYUVerStream* pcStream;
|
||||
for( UInt i = 0; i < inputFileNames.size(); i++ )
|
||||
@@ -85,9 +77,9 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
|
||||
m_apcInputStreams.push_back( pcStream );
|
||||
}
|
||||
m_uiNumberOfFrames = MAX_UINT;
|
||||
if( cCommandLineParser.getOptionsMap().count( "frames" ) )
|
||||
if( m_cCommandLineParser.getOptionsMap().count( "frames" ) )
|
||||
{
|
||||
m_uiNumberOfFrames = cCommandLineParser.getOptionsMap()["frames"].as<UInt>();
|
||||
m_uiNumberOfFrames = m_cCommandLineParser.getOptionsMap()["frames"].as<UInt>();
|
||||
}
|
||||
|
||||
m_uiNumberOfComponents = MAX_UINT;
|
||||
@@ -99,21 +91,38 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
|
||||
m_uiNumberOfComponents = m_apcInputStreams[i]->getCurrFrame()->getNumberChannels();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create output streams
|
||||
*/
|
||||
if( cCommandLineParser.getOptionsMap().count( "output" ) )
|
||||
Int PlaYUVerTools::openOutputs()
|
||||
{
|
||||
if( m_cCommandLineParser.getOptionsMap().count( "output" ) )
|
||||
{
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Int PlaYUVerTools::Open( Int argc, Char *argv[] )
|
||||
{
|
||||
m_cCommandLineParser.Config( argc, argv );
|
||||
if( !m_cCommandLineParser.parse() )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( openInputs() > 0 || openOutputs() > 0 )
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Quality operation
|
||||
*/
|
||||
if( cCommandLineParser.getOptionsMap().count( "quality" ) )
|
||||
if( m_cCommandLineParser.getOptionsMap().count( "quality" ) )
|
||||
{
|
||||
m_uiOperationIndex = -1;
|
||||
std::string qualityMetric = cCommandLineParser.getOptionsMap()["quality"].as<std::string>();
|
||||
std::string qualityMetric = m_cCommandLineParser.getOptionsMap()["quality"].as<std::string>();
|
||||
if( m_apcInputStreams.size() != 2 )
|
||||
{
|
||||
printf( "Invalid number of inputs! " );
|
||||
@@ -132,12 +141,13 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
|
||||
return 2;
|
||||
}
|
||||
m_uiOperation = QUALITY_OPERATION;
|
||||
m_fpProcess = &PlaYUVerTools::QualityOperation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Module operation
|
||||
*/
|
||||
if( cCommandLineParser.getOptionsMap().count( "module" ) )
|
||||
if( m_cCommandLineParser.getOptionsMap().count( "module" ) )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -152,14 +162,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
|
||||
|
||||
Int PlaYUVerTools::Process()
|
||||
{
|
||||
switch( m_uiOperation )
|
||||
{
|
||||
case QUALITY_OPERATION:
|
||||
printf( " Measuring Quality using %s ... \n", PlaYUVerFrame::supportedQualityMetricsList()[m_uiOperationIndex].c_str() );
|
||||
qualityOperation();
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return (this->*m_fpProcess)();
|
||||
}
|
||||
|
||||
Int PlaYUVerTools::Close()
|
||||
@@ -168,13 +171,15 @@ Int PlaYUVerTools::Close()
|
||||
return 0;
|
||||
}
|
||||
|
||||
Void PlaYUVerTools::qualityOperation()
|
||||
Int PlaYUVerTools::QualityOperation()
|
||||
{
|
||||
PlaYUVerFrame* apcCurrFrame[m_apcInputStreams.size()];
|
||||
Bool abEOF[m_apcInputStreams.size()];
|
||||
Double adAverageQuality[m_apcInputStreams.size() - 1][m_uiNumberOfComponents];
|
||||
Double dQuality;
|
||||
|
||||
printf( " Measuring Quality using %s ... \n", PlaYUVerFrame::supportedQualityMetricsList()[m_uiOperationIndex].c_str() );
|
||||
|
||||
for( UInt s = 0; s < m_apcInputStreams.size(); s++ )
|
||||
{
|
||||
abEOF[s] = false;
|
||||
@@ -218,7 +223,8 @@ Void PlaYUVerTools::qualityOperation()
|
||||
printf( " %5.3f", adAverageQuality[s][c] );
|
||||
}
|
||||
}
|
||||
printf( "\n");
|
||||
printf( "\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // NAMESPACE
|
||||
@@ -45,6 +45,8 @@ public:
|
||||
Int Close();
|
||||
|
||||
private:
|
||||
PlaYUVerCmdParser m_cCommandLineParser;
|
||||
|
||||
UInt m_uiOperation;
|
||||
Int m_uiOperationIndex;
|
||||
enum TOOLS_OPERATIONS_LIST
|
||||
@@ -59,7 +61,13 @@ private:
|
||||
std::vector<PlaYUVerStream*> m_apcInputStreams;
|
||||
std::vector<PlaYUVerStream*> m_apcOutputStreams;
|
||||
|
||||
Void qualityOperation();
|
||||
Int openInputs();
|
||||
Int openOutputs();
|
||||
|
||||
typedef Int (PlaYUVerTools::*FpProcess) ();
|
||||
FpProcess m_fpProcess;
|
||||
|
||||
Int QualityOperation();
|
||||
};
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
+7
-1
@@ -29,9 +29,15 @@ using namespace plaYUVer;
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
Int iRet = 0;
|
||||
PlaYUVerTools PlaYUVerToolsApp;
|
||||
|
||||
if( PlaYUVerToolsApp.Open( argc, argv ) > 1 )
|
||||
iRet = PlaYUVerToolsApp.Open( argc, argv );
|
||||
if( iRet == 1 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if( iRet > 1 )
|
||||
{
|
||||
printf( "Exiting\n" );
|
||||
return 1;
|
||||
|
||||
Reference in new issue
Block a user