diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index f9fb0b9..2feee91 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -495,7 +495,7 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) if( !pcCurrModuleIf->m_pcModuleStream ) { UInt Width = 0, Height = 0, FrameRate = 30; - Int BitsPixel, InputFormat = -1; + Int BitsPixel, Endianness, InputFormat = -1; QString supported = tr( "Supported Files (" ); QStringList formatsList; @@ -525,10 +525,11 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) Height = pcCurrModuleIf->m_pcProcessedFrame->getHeight(); InputFormat = pcCurrModuleIf->m_pcProcessedFrame->getPelFormat(); BitsPixel = pcCurrModuleIf->m_pcProcessedFrame->getBitsPel(); + Endianness = pcCurrModuleIf->m_pcProcessedFrame->getEndianness(); FrameRate = pcCurrModuleIf->m_pcSubWindow[0]->getInputStream()->getFrameRate(); pcCurrModuleIf->m_pcModuleStream = new PlaYUVerStream; - if( !pcCurrModuleIf->m_pcModuleStream->open( fileName.toStdString(), Width, Height, InputFormat, BitsPixel, FrameRate, false ) ) + if( !pcCurrModuleIf->m_pcModuleStream->open( fileName.toStdString(), Width, Height, InputFormat, BitsPixel, Endianness, FrameRate, false ) ) { delete pcCurrModuleIf->m_pcModuleStream; pcCurrModuleIf->m_pcModuleStream = NULL; diff --git a/app/ModulesHandleOptDialog.cpp b/app/ModulesHandleOptDialog.cpp index ac8bdd4..6e1a61b 100644 --- a/app/ModulesHandleOptDialog.cpp +++ b/app/ModulesHandleOptDialog.cpp @@ -86,11 +86,11 @@ ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget *parent, PlaYUVerAppModu resize( 400, 10 ); setWindowTitle( "Select module parameters" ); - const Options::OptionsList& moduleOptions = m_pcCurrModuleIf->m_pcModule->m_cModuleOptions.getOptionList(); + const PlaYUVerOptions::OptionsList& moduleOptions = m_pcCurrModuleIf->m_pcModule->m_cModuleOptions.getOptionList(); QVBoxLayout* optionsLayout = new QVBoxLayout; OpionConfiguration* pcOption; - for( Options::OptionsList::const_iterator it = moduleOptions.begin(); it != moduleOptions.end(); ++it ) + for( PlaYUVerOptions::OptionsList::const_iterator it = moduleOptions.begin(); it != moduleOptions.end(); ++it ) { pcOption = new OpionConfiguration( ( *it )->opt ); m_apcOptionList.append( pcOption ); @@ -142,7 +142,7 @@ Int ModulesHandleOptDialog::runConfiguration() } if( argsArray.size() > 0 ) { - m_pcCurrModuleIf->m_pcModule->m_cModuleOptions.scanArgs( argsArray ); + m_pcCurrModuleIf->m_pcModule->m_cModuleOptions.parse( argsArray ); } return QDialog::Accepted; } diff --git a/app/PlaYUVerApp.cpp b/app/PlaYUVerApp.cpp index 11ee89a..798fa98 100644 --- a/app/PlaYUVerApp.cpp +++ b/app/PlaYUVerApp.cpp @@ -94,37 +94,36 @@ PlaYUVerApp::PlaYUVerApp() : Bool PlaYUVerApp::parseArgs( Int argc, Char *argv[] ) { Bool bRet = false; - m_pcCmdParser = new PlaYUVerCmdParser(); - m_pcCmdParser->config( argc, argv ); + PlaYUVerOptions pcCmdParser; std::vector m_apcInputs; String strResolution( "" ); String strPelFmt( "" ); - m_pcCmdParser->Opts().addOptions()/**/ + pcCmdParser.addOptions()/**/ ( "input,i", m_apcInputs, "input file" ) /**/ ( "size,s", strResolution, "size (WxH)" ) /**/ ( "pel_fmt", strPelFmt, "pixel format" ); - if( !m_pcCmdParser->parse() ) + if( !pcCmdParser.parse( argc, argv ) ) { bRet |= true; } - if( m_pcCmdParser->Opts()["help"]->count() ) + if( pcCmdParser.hasOpt("help") ) { printf( "Usage: %s [options] input_file[s]\n", argv[0] ); - m_pcCmdParser->Opts().doHelp( std::cout ); + pcCmdParser.doHelp( std::cout ); bRet |= true; } - if( m_pcCmdParser->Opts()["input"]->count() ) + if( pcCmdParser.hasOpt("input") ) { for( UInt i = 1; i < m_apcInputs.size(); i++ ) { loadFile( QString::fromStdString( m_apcInputs[i] ) ); } } - std::list& argv_unhandled = m_pcCmdParser->getNoArgs(); + std::list& argv_unhandled = pcCmdParser.getUnhandledArgs(); for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ ) { loadFile( QString::fromStdString( *it ) ); diff --git a/app/PlaYUVerApp.h b/app/PlaYUVerApp.h index a83d450..02826b7 100644 --- a/app/PlaYUVerApp.h +++ b/app/PlaYUVerApp.h @@ -55,7 +55,7 @@ class QAction; class QSignalMapper; -class PlaYUVerCmdParser; +class PlaYUVerOptions; class PlaYUVerStream; class PlaYUVerSubWindowHandle; class VideoHandle; @@ -118,7 +118,7 @@ private Q_SLOTS: private: PlaYUVerAppAdaptor* m_pDBusAdaptor; - PlaYUVerCmdParser* m_pcCmdParser; + PlaYUVerOptions* m_pcCmdParser; /** * Save the current subwindow for every category */ diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index ef158e4..7413d1e 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -328,7 +328,7 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog ) try { - m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate ); + m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate, true ); } catch( const char *msg ) { @@ -336,7 +336,7 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog ) { return false; } - m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate ); + m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate, true ); } m_sStreamInfo.m_cFilename = cFilename; @@ -367,7 +367,7 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo ) } if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight, streamInfo->m_iPelFormat, - streamInfo->m_uiBitsPelPixel, streamInfo->m_iEndianness, streamInfo->m_uiFrameRate ) ) + streamInfo->m_uiBitsPelPixel, streamInfo->m_iEndianness, streamInfo->m_uiFrameRate, true) ) { return false; } diff --git a/lib/PlaYUVerDefs.h b/lib/PlaYUVerDefs.h index 6262817..b89e5f2 100644 --- a/lib/PlaYUVerDefs.h +++ b/lib/PlaYUVerDefs.h @@ -134,6 +134,22 @@ inline String uppercase( const String& in ) return out; } +struct PlaYUVerFailure: public std::exception +{ + String m_class_name; + String m_error_msg; + PlaYUVerFailure( String error_msg ) throw() : + m_error_msg( error_msg ) { } + PlaYUVerFailure( String class_name, String error_msg ) throw() : + m_class_name( class_name ), + m_error_msg( error_msg ) { } + ~PlaYUVerFailure() throw() { } + const Char* what() const throw() + { + String* msg = new String( "[" + m_class_name + "] " + m_error_msg ); + return msg->c_str(); + } +}; #endif // __PLAYUVERDEFS_H__ diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 8f440fe..0f5b2c4 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -216,13 +216,13 @@ Void PlaYUVerFramePrivate::init( UInt width, UInt height, Int pel_format, Int bi m_iEndianness = endianness; if( m_uiBitsPel > 8 && m_iEndianness == -1 ) { - throw "Invalid endianness type for Bits per Pixel greater than 8"; + throw PlaYUVerFailure( "PlaYUVerFrame", "Invalid endianness type for Bits per Pixel greater than 8" ); } m_uiHalfPelValue = 1 << ( m_uiBitsPel - 1 ); if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || bitsPixel > 16 ) { - throw "Cannot create a PlYUVerFrame of this type"; + throw PlaYUVerFailure( "PlaYUVerFrame", "Cannot create a PlYUVerFrame of this type" ); } m_pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[pel_format] ); @@ -1090,14 +1090,14 @@ Void PlaYUVerFrame::fromCvMat( cv::Mat* pcCvFrame ) { switch( pcCvFrame->channels() ) { - case 1: - d->m_iPixelFormat = findPixelFormat( "GRAY" ); - break; - case 3: - d->m_iPixelFormat = findPixelFormat( "BGR24" ); - break; - default: - return; + case 1: + d->m_iPixelFormat = findPixelFormat( "GRAY" ); + break; + case 3: + d->m_iPixelFormat = findPixelFormat( "BGR24" ); + break; + default: + return; } } d->init( pcCvFrame->cols, pcCvFrame->rows, d->m_iPixelFormat, 8, -1 ); diff --git a/lib/PlaYUVerOptions.cpp b/lib/PlaYUVerOptions.cpp index 58451c8..816dba2 100644 --- a/lib/PlaYUVerOptions.cpp +++ b/lib/PlaYUVerOptions.cpp @@ -65,73 +65,27 @@ struct ParseFailure: public std::exception arg( arg0 ), val( val0 ) { } ~ParseFailure() throw() { } - const char* what() const throw() + const Char* what() const throw() { return "Option Parse Failure"; } }; -/** OptionBase: Virtual base class for storing information relating to a - * specific option This base class describes common elements. Type specific - * information should be stored in a derived class. */ -class OptionBase -{ -public: - OptionBase( const String& name, const String& desc ) : - arg_count( 0 ), - opt_string( name ), - opt_desc( desc ) - { - } - - virtual ~OptionBase() - { - } - - /* parse argument arg, to obtain a value for the option */ - virtual void parse( const String& arg ) = 0; - /* set the argument to the default value */ - //virtual void setDefault() = 0; - int count() - { - return arg_count; - } - Bool isBinary() - { - return is_binary; - } - - int arg_count; - String opt_string; - String opt_desc; - Bool is_binary; -}; - /** Type specific option storage */ class BoolOption: public OptionBase { public: - BoolOption( const String& name, Bool default_val, const String& desc ) : - OptionBase( name, desc ), - opt_storage( false ), - opt_default_val( default_val ) + BoolOption( const String& name, const String& desc ) : + OptionBase( name, desc ) { is_binary = true; } void parse( const String& arg ) { - opt_storage = true; arg_count++; } - - void setDefault() - { - opt_storage = opt_default_val; - } - Bool opt_storage; - Bool opt_default_val; }; /** Type specific option storage */ @@ -148,21 +102,25 @@ public: void parse( const String& arg ); T& opt_storage; + std::vector opt_storage_array; }; /* Generic parsing */ template inline void StandardOption::parse( const String& arg ) { - std::istringstream arg_ss( arg, std::istringstream::in ); - arg_ss.exceptions( std::ios::failbit ); - try + if( !is_binary ) { - arg_ss >> opt_storage; - } - catch( ... ) - { - throw ParseFailure( opt_string, arg ); + std::istringstream arg_ss( arg, std::istringstream::in ); + arg_ss.exceptions( std::ios::failbit ); + try + { + arg_ss >> opt_storage; + } + catch( ... ) + { + throw ParseFailure( opt_string, arg ); + } } arg_count++; } @@ -239,47 +197,63 @@ public: arg_count++; } - void setDefault() - { - return; - } - private: PlaYUVerOptions& parent; void ( *func )( PlaYUVerOptions&, const String& ); }; -struct PlaYUVerOptions::Option +/* Helper method to initiate adding options to Options */ + +/** + * Add option described by name to the parent Options list, + * with storage for the option's value + * with default_val as the default value + * with desc as an optional help description + */ +PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, const String& desc ) { - Option() : - opt( 0 ) - { - } - ~Option() - { - if( opt ) - delete opt; - } - std::list opt_long; - std::list opt_short; - OptionBase* opt; -}; + addOption( new BoolOption( name, desc ) ); + return *this; +} + +/** + * Add option described by name to the parent Options list, + * with storage for the option's value + * with desc as an optional help description + */ +template +PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, T& storage, const String& desc ) +{ + addOption( new StandardOption( name, storage, desc ) ); + return *this; +} + +template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, Bool& storage, const String& desc ); +template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, UInt& storage, const String& desc ); +template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, Int& storage, const String& desc ); +template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, Int64& storage, const String& desc ); +template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, String& storage, const String& desc ); +template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector& storage, const String& desc ); +template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector& storage, const String& desc ); +template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector& storage, const String& desc ); + +/** + * Add option described by name to the parent Options list, + * with desc as an optional help description + * instead of storing the value somewhere, a function of type + * FunctionOption::Func is called. It is upto this function to correctly + * handle evaluating the option's value. + */ +// PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, FunctionOption::Func *func, const String& desc ) +// { +// addOption( new FunctionOption( name, parent, func, desc ) ); +// return *this; +// } PlaYUVerOptions::PlaYUVerOptions( const String& name ) { m_cOptionGroupName = name; m_bAllowUnkonw = true; - - /** - * Add default options - */ - addOptions()/**/ - ( "help", "produce help message" )/**/ - ( "version", "show version and exit" )/**/ - ( "pel_fmts", "list pixel formats" ) /**/ - ( "quality_metrics", "list supported quality metrics" )/**/ - ( "module_list", "list supported modules" ) /**/ - ( "module_list_full", "detailed list supported modules" ); } PlaYUVerOptions::~PlaYUVerOptions() @@ -321,12 +295,25 @@ OptionBase* PlaYUVerOptions::getOption( const String& optName ) Bool PlaYUVerOptions::hasOpt( const String& optName ) { - return getOption( optName )->count() > 0 ? true : false; + OptionBase* opt = getOption( optName ); + return opt ? opt->count() > 0 ? true : false : false; } -OptionSpecific PlaYUVerOptions::addOptions() +Void PlaYUVerOptions::addDefaultOptions() { - return OptionSpecific( *this ); + addOptions()/**/ + ( "help,h", "produce help message" )/**/ + ( "version", "show version and exit" )/**/ + ( "pel_fmts", "list pixel formats" ) /**/ + ( "quality_metrics", "list supported quality metrics" )/**/ + ( "module_list", "list supported modules" ) /**/ + ( "module_list_full", "detailed list supported modules" ); +} + + +PlaYUVerOptions& PlaYUVerOptions::addOptions() +{ + return *this; } void PlaYUVerOptions::addOption( OptionBase *opt ) @@ -361,67 +348,7 @@ void PlaYUVerOptions::addOption( OptionBase *opt ) opt_list.push_back( names ); } -/* Helper method to initiate adding options to Options */ -/** - * Add option described by name to the parent Options list, - * with storage for the option's value - * with default_val as the default value - * with desc as an optional help description - */ -template -OptionSpecific& OptionSpecific::operator()( const String& name, T& storage, const String& desc ) -{ - parent.addOption( new StandardOption( name, storage, desc ) ); - return *this; -} - -/** - * Add option described by name to the parent Options list, - * with storage for the option's value - * with default_val as the default value - * with desc as an optional help description - */ -OptionSpecific& OptionSpecific::operator()( const String& name, const String& desc ) -{ - parent.addOption( new BoolOption( name, false, desc ) ); - return *this; -} - -/** - * Add option described by name to the parent Options list, - * with storage for the option's value - * with default_val as the default value - * with desc as an optional help description - */ -OptionSpecific& OptionSpecific::operator()( const String& name, Bool default_val, const String& desc ) -{ - parent.addOption( new BoolOption( name, default_val, desc ) ); - return *this; -} - -/** - * Add option described by name to the parent Options list, - * with desc as an optional help description - * instead of storing the value somewhere, a function of type - * FunctionOption::Func is called. It is upto this function to correctly - * handle evaluating the option's value. - */ -// OptionSpecific& OptionSpecific::operator()( const String& name, FunctionOption::Func *func, const String& desc ) -// { -// parent.addOption( new FunctionOption( name, parent, func, desc ) ); -// return *this; -// } - -/* for all options in opts, set their storage to their specified - * default value */ -Void PlaYUVerOptions::setDefaults() -{ -// for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) -// { -// ( *it )->opt->setDefault(); -// } -} static void setOptions( PlaYUVerOptions::OptionsList& opt_list, const string& value ) { @@ -483,7 +410,7 @@ Bool PlaYUVerOptions::storePair( const string& name, const string& value ) /** * returns number of extra arguments consumed */ -UInt PlaYUVerOptions::parseLONG( unsigned argc, const char* argv[] ) +UInt PlaYUVerOptions::parseLONG( UInt argc, Char* argv[] ) { /* gnu style long options can take the forms: * --option=arg @@ -494,7 +421,7 @@ UInt PlaYUVerOptions::parseLONG( unsigned argc, const char* argv[] ) size_t arg_opt_sep = arg.find_first_of( '=' ); string option = arg.substr( arg_opt_start, arg_opt_sep - arg_opt_start ); - unsigned extra_argc_consumed = 0; + UInt extra_argc_consumed = 0; if( arg_opt_sep == string::npos ) { /* no argument found => argument in argv[1] (maybe) */ @@ -534,7 +461,7 @@ UInt PlaYUVerOptions::parseLONG( string arg ) size_t arg_opt_sep = arg.find_first_of( '=' ); string option = arg.substr( arg_opt_start, arg_opt_sep - arg_opt_start ); - unsigned extra_argc_consumed = 0; + UInt extra_argc_consumed = 0; if( arg_opt_sep == string::npos ) { /* no argument found => argument in argv[1] (maybe) */ @@ -553,7 +480,7 @@ UInt PlaYUVerOptions::parseLONG( string arg ) return extra_argc_consumed; } -unsigned PlaYUVerOptions::parseSHORT( unsigned argc, const char* argv[] ) +UInt PlaYUVerOptions::parseSHORT( UInt argc, Char* argv[] ) { /* short options can take the forms: * --option arg @@ -579,11 +506,11 @@ unsigned PlaYUVerOptions::parseSHORT( unsigned argc, const char* argv[] ) return 1; } -Bool PlaYUVerOptions::parse( Int argc, Char *argv[] ) +Bool PlaYUVerOptions::parse( UInt argc, Char *argv[] ) { try { - m_aUnhandledArgs = scanArgv( argc, ( const Char** )argv ); + m_aUnhandledArgs = scanArgv( argc, argv ); if( checkListingOpts() ) { @@ -605,12 +532,12 @@ Bool PlaYUVerOptions::parse( Int argc, Char *argv[] ) } -list PlaYUVerOptions::scanArgv( unsigned argc, const char* argv[] ) +list PlaYUVerOptions::scanArgv( UInt argc, Char *argv[] ) { /* a list for anything that didn't get handled as an option */ - list non_option_arguments; + list non_option_arguments; - for( unsigned i = 1; i < argc; i++ ) + for( UInt i = 1; i < argc; i++ ) { if( argv[i][0] != '-' ) { @@ -651,9 +578,9 @@ list PlaYUVerOptions::scanArgv( unsigned argc, const char* argv[] ) return non_option_arguments; } -Void PlaYUVerOptions::scanArgs( std::vector args_array ) +Void PlaYUVerOptions::parse( std::vector args_array ) { - for( unsigned i = 0; i < args_array.size(); i++ ) + for( UInt i = 0; i < args_array.size(); i++ ) { i += parseLONG( args_array[i] ); } @@ -666,13 +593,13 @@ static const char spaces[41] = " "; * using the formatting: "-x, --long", * if a short/long option isn't specified, it is not printed */ -static void doHelpOpt( ostream& out, const PlaYUVerOptions::Option& entry, unsigned pad_short = 0 ) +static void doHelpOpt( ostream& out, const PlaYUVerOptions::Option& entry, UInt pad_short = 0 ) { pad_short = min( pad_short, 8u ); if( !entry.opt_short.empty() ) { - unsigned pad = max( ( int )pad_short - ( int )entry.opt_short.front().size(), 0 ); + UInt pad = max( ( int )pad_short - ( int )entry.opt_short.front().size(), 0 ); out << "-" << entry.opt_short.front(); if( !entry.opt_long.empty() ) @@ -695,20 +622,20 @@ static void doHelpOpt( ostream& out, const PlaYUVerOptions::Option& entry, unsig } /* format the help text */ -Void PlaYUVerOptions::doHelp( ostream& out, unsigned columns ) +Void PlaYUVerOptions::doHelp( ostream& out, UInt columns ) { - const unsigned pad_short = 3; + const UInt pad_short = 3; /* first pass: work out the longest option name */ - unsigned max_width = 0; + UInt max_width = 0; for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) { ostringstream line( ios_base::out ); doHelpOpt( line, **it, pad_short ); - max_width = max( max_width, ( unsigned )line.tellp() ); + max_width = max( max_width, ( UInt )line.tellp() ); } - unsigned opt_width = min( max_width + 2, 28u + pad_short ) + 2; - unsigned desc_width = columns - opt_width; + UInt opt_width = min( max_width + 2, 28u + pad_short ) + 2; + UInt desc_width = columns - opt_width; /* second pass: write out formatted option and help text. * - align start of help text to start at opt_width diff --git a/lib/PlaYUVerOptions.h b/lib/PlaYUVerOptions.h index 75f19e7..599e935 100644 --- a/lib/PlaYUVerOptions.h +++ b/lib/PlaYUVerOptions.h @@ -48,26 +48,89 @@ #include "PlaYUVerDefs.h" -struct OptionBase; -class PlaYUVerOptions; -/* Class with templated overloaded operator(), for use by Options::addOptions() */ -class OptionSpecific +/** OptionBase: Virtual base class for storing information relating to a + * specific option This base class describes common elements. + * Type specific information should be stored in a derived class. + */ +class OptionBase { public: - OptionSpecific( PlaYUVerOptions& parent_ ) : - parent( parent_ ) + OptionBase( const String& name, const String& desc ) : + arg_count( 0 ), + opt_string( name ), + opt_desc( desc ) { } - /** - * Add option described by name to the parent Options list, - * with storage for the option's value - * with default_val as the default value - * with desc as an optional help description - */ - template - OptionSpecific& - operator()( const String& name, T& storage, const String& desc ); + virtual ~OptionBase() {} + + /* parse argument arg, to obtain a value for the option */ + virtual void parse( const String& arg ) = 0; + Int count() + { + return arg_count; + } + Bool isBinary() + { + return is_binary; + } + + int arg_count; + String opt_string; + String opt_desc; + Bool is_binary; +}; + + +class PlaYUVerOptions +{ +public: + + struct Option + { + Option() : + opt( 0 ) + { + } + ~Option() + { + if( opt ) + delete opt; + } + std::list opt_long; + std::list opt_short; + OptionBase* opt; + }; + + + typedef std::list OptionsList; + + PlaYUVerOptions( const String& name = "" ); + ~PlaYUVerOptions(); + + Bool parse( UInt argc, Char *argv[] ); + Void parse( std::vector args_array ); + + std::list& getUnhandledArgs() + { + return m_aUnhandledArgs; + } + + Void doHelp( std::ostream& out, unsigned columns = 80 ); + + OptionBase* operator[]( const String& optName ); + OptionBase* getOption( const String& optName ); + + Bool hasOpt( const String& optName ); + + OptionsList getOptionList() + { + return opt_list; + } + + Void addDefaultOptions(); + PlaYUVerOptions& addOptions(); + void addOption( OptionBase *opt ); /** * Add option described by name to the parent Options list, @@ -75,7 +138,7 @@ public: * with default_val as the default value * with desc as an optional help description */ - OptionSpecific& + PlaYUVerOptions& operator()( const String& name, const String& desc ); /** @@ -84,8 +147,10 @@ public: * with default_val as the default value * with desc as an optional help description */ - OptionSpecific& - operator()( const String& name, Bool default_val, const String& desc ); + template + PlaYUVerOptions& + operator()( const String& name, T& storage, const String& desc ); + /** * Add option described by name to the parent Options list, @@ -94,40 +159,12 @@ public: * OptionFunc::Func is called. It is upto this function to correctly * handle evaluating the option's value. */ -// OptionSpecific& -// operator()( const String& name, OptionFunc::Func *func, const String& desc ) -private: - PlaYUVerOptions& parent; -}; +// PlaYUVerOptions& +// operator()( const String& name, OptionFunc::Func *func, const String& desc ); -class PlaYUVerOptions -{ -public: - - struct Option; - - typedef std::list OptionsList; - - PlaYUVerOptions( const String& name = "" ); - ~PlaYUVerOptions(); - - Bool parse( Int argc, Char *argv[] ); - std::list scanArgv( unsigned argc, const char* argv[] ); - Void scanArgs( std::vector args_array ); - Void doHelp( std::ostream& out, unsigned columns = 80 ); - Bool checkListingOpts(); Void listModules(); - Void setDefaults(); - - OptionBase* operator[]( const String& optName ); - OptionBase* getOption( const String& optName ); - - Bool hasOpt( const String& optName ); - - OptionSpecific addOptions(); - void addOption( OptionBase *opt ); private: typedef std::map OptionMap; @@ -142,12 +179,12 @@ private: Bool storePair( Bool allow_long, Bool allow_short, const String& name, const String& value ); Bool storePair( const String& name, const String& value ); - UInt parseLONG( unsigned argc, const char* argv[] ); + UInt parseLONG( UInt argc, Char* argv[] ); UInt parseLONG( String arg ); - UInt parseSHORT( unsigned argc, const char* argv[] ); + UInt parseSHORT( UInt argc, Char* argv[] ); + std::list scanArgv( UInt argc, Char* argv[] ); }; - #endif // __PROGRAMOPTIONS_H__ diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 586cc96..c7b1a3e 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -196,14 +196,14 @@ Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_f m_pfctCreateHandler = PlaYUVerStream::findStreamHandler( filename, m_bIsInput ); if( !m_pfctCreateHandler ) { - throw "[PlaYUVerStream] Invalid handler"; + throw PlaYUVerFailure("PlaYUVerStream", "Invalid handler"); } m_pcHandler = m_pfctCreateHandler(); if( !m_pcHandler ) { - throw "[PlaYUVerStream] Cannot create handler"; + throw PlaYUVerFailure("PlaYUVerStream", "Cannot create handler"); } m_cFilename = filename; @@ -220,7 +220,7 @@ Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_f if( !m_pcHandler->openHandler( m_cFilename, m_bIsInput ) ) { close(); - throw "[PlaYUVerStream] Cannot open file"; + throw PlaYUVerFailure("PlaYUVerStream", "Cannot open file " + m_cFilename ); return m_bInit; } @@ -228,7 +228,7 @@ Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_f if( m_pcHandler->m_uiWidth <= 0 || m_pcHandler->m_uiHeight <= 0 || m_pcHandler->m_iPixelFormat < 0 ) { close(); - throw "[PlaYUVerStream] Incorrect configuration"; + throw PlaYUVerFailure("PlaYUVerStream", "Incorrect configuration"); return m_bInit; } @@ -244,7 +244,7 @@ Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_f catch( const char *msg ) { close(); - throw "[PlaYUVerStream] Cannot allocated frame buffer"; + throw PlaYUVerFailure("PlaYUVerStream", "Cannot allocated frame buffer"); return m_bInit; } } @@ -261,14 +261,14 @@ Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_f if( m_bIsInput && m_uiTotalFrameNum <= 0 ) { close(); - throw "[PlaYUVerStream] Incorrect configuration: less than one frame"; + throw PlaYUVerFailure("PlaYUVerStream", "Incorrect configuration: less than one frame"); return m_bInit; } if( !m_pcHandler->configureBuffer( m_pcCurrFrame ) ) { close(); - throw "[PlaYUVerStream] Cannot allocated memory"; + throw PlaYUVerFailure("PlaYUVerStream", "Cannot allocated memory"); return m_bInit; } @@ -286,7 +286,7 @@ Bool PlaYUVerStream::reload() m_pcHandler->closeHandler(); if( !m_pcHandler->openHandler( m_cFilename, m_bIsInput ) ) { - throw "[PlaYUVerStream] Cannot open file using FFmpeg libs"; + throw PlaYUVerFailure("PlaYUVerStream", "Cannot open file"); } m_pcHandler->setBytesPerFrame( m_pcCurrFrame->getBytesPerFrame() ); m_uiTotalFrameNum = m_pcHandler->calculateFrameNumber(); @@ -466,7 +466,7 @@ Void PlaYUVerStream::readFrame() if( !m_pcHandler->read( m_pcNextFrame ) ) { - throw "[PlaYUVerStream] Cannot read file"; + throw PlaYUVerFailure("PlaYUVerStream", "Cannot read file"); return; } @@ -483,7 +483,7 @@ Void PlaYUVerStream::writeFrame( PlaYUVerFrame *pcFrame ) { if( !m_pcHandler->write( pcFrame ) ) { - throw "[PlaYUVerStream] Cannot write into the file"; + throw PlaYUVerFailure("PlaYUVerStream", "Cannot write into the file"); } return; } @@ -588,7 +588,7 @@ Bool PlaYUVerStream::seekInput( UInt64 new_frame_num ) if( !m_pcHandler->seek( new_frame_num ) ) { - throw "[PlaYUVerStream] Cannot write into the file"; + throw PlaYUVerFailure("PlaYUVerStream", "Cannot write into the file"); } m_uiCurrFrameFileIdx = new_frame_num; diff --git a/lib/PlaYUVerStream.h b/lib/PlaYUVerStream.h index 3449985..690c2dc 100644 --- a/lib/PlaYUVerStream.h +++ b/lib/PlaYUVerStream.h @@ -103,8 +103,8 @@ public: String getFormatName(); String getCodecName(); - Bool open( String filename, String resolution, String input_format, UInt bitsPel, Int endianness, UInt frame_rate, Bool bInput = true ); - Bool open( String filename, UInt width, UInt height, Int input_format, UInt bitsPel, Int endianness, UInt frame_rate, Bool bInput = true ); + Bool open( String filename, String resolution, String input_format, UInt bitsPel, Int endianness, UInt frame_rate, Bool bInput ); + Bool open( String filename, UInt width, UInt height, Int input_format, UInt bitsPel, Int endianness, UInt frame_rate, Bool bInput ); Bool reload(); Void close(); diff --git a/lib/StreamHandlerLibav.cpp b/lib/StreamHandlerLibav.cpp index 8b9e9aa..d62216e 100644 --- a/lib/StreamHandlerLibav.cpp +++ b/lib/StreamHandlerLibav.cpp @@ -216,7 +216,7 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput ) } if( m_iPixelFormat == PlaYUVerFrame::NO_FMT ) { - throw "Cannot open file using FFmpeg libs - unsupported pixel format"; + throw PlaYUVerFailure("Cannot open file using FFmpeg libs - unsupported pixel format"); return false; } diff --git a/tools/PlaYUVerTools.cpp b/tools/PlaYUVerTools.cpp index a714ad6..5c2c1a1 100644 --- a/tools/PlaYUVerTools.cpp +++ b/tools/PlaYUVerTools.cpp @@ -60,9 +60,9 @@ Int PlaYUVerTools::openInputs() /** * Create input streams */ - if( m_cCmdLineHandler.Opts().hasOpt( "input" ) ) + if( Opts().hasOpt( "input" ) ) { - std::vector inputFileNames = m_cCmdLineHandler.m_apcInputs; + std::vector inputFileNames = m_apcInputs; String resolutionString( "" ); String fmtString( "yuv420p" ); @@ -72,25 +72,25 @@ Int PlaYUVerTools::openInputs() PlaYUVerStream* pcStream; for( UInt i = 0; i < inputFileNames.size() && i < MAX_NUMBER_INPUTS; i++ ) { - if( m_cCmdLineHandler.Opts().hasOpt( "size" ) ) + if( Opts().hasOpt( "size" ) ) { - resolutionString = GET_PARAM( m_cCmdLineHandler.m_strResolution, 0 ); + resolutionString = GET_PARAM( m_strResolution, 0 ); } - if( m_cCmdLineHandler.Opts().hasOpt( "pel_fmt" ) ) + if( Opts().hasOpt( "pel_fmt" ) ) { - fmtString = GET_PARAM( m_cCmdLineHandler.m_strPelFmt, i ); + fmtString = GET_PARAM( m_strPelFmt, i ); } - if( m_cCmdLineHandler.Opts().hasOpt( "bits_pel" ) ) + if( Opts().hasOpt( "bits_pel" ) ) { - uiBitPerPixel = GET_PARAM( m_cCmdLineHandler.m_uiBitsPerPixel, i ); + uiBitPerPixel = GET_PARAM( m_uiBitsPerPixel, i ); } - if( m_cCmdLineHandler.Opts().hasOpt( "endianness" ) ) + if( Opts().hasOpt( "endianness" ) ) { - if( GET_PARAM( m_cCmdLineHandler.m_strEndianness, i ) == "big" ) + if( GET_PARAM( m_strEndianness, i ) == "big" ) { uiEndianness = 0; } - if( GET_PARAM( m_cCmdLineHandler.m_strEndianness, i ) == "little" ) + if( GET_PARAM( m_strEndianness, i ) == "little" ) { uiEndianness = 1; } @@ -98,25 +98,25 @@ Int PlaYUVerTools::openInputs() pcStream = new PlaYUVerStream; try { - if( !pcStream->open( inputFileNames[i], resolutionString, fmtString, uiBitPerPixel, uiEndianness, 1 ) ) + if( !pcStream->open( inputFileNames[i], resolutionString, fmtString, uiBitPerPixel, uiEndianness, 1, true ) ) { - m_cCmdLineHandler.log( LOG_ERROR, "Cannot open input stream %s! ", inputFileNames[i].c_str() ); + log( LOG_ERROR, "Cannot open input stream %s! ", inputFileNames[i].c_str() ); return 2; } m_apcInputStreams.push_back( pcStream ); } catch( const char *msg ) { - m_cCmdLineHandler.log( LOG_ERROR, "Cannot open input stream %s with the following error: \n%s\n", inputFileNames[i].c_str(), msg ); + log( LOG_ERROR, "Cannot open input stream %s with the following error: \n%s\n", inputFileNames[i].c_str(), msg ); return 2; } } } m_uiNumberOfFrames = MAX_UINT; - if( m_cCmdLineHandler.Opts().hasOpt( "frames" ) ) + if( Opts().hasOpt( "frames" ) ) { - m_uiNumberOfFrames = m_cCmdLineHandler.m_iFrames; + m_uiNumberOfFrames = m_iFrames; } m_uiNumberOfComponents = MAX_UINT; @@ -135,7 +135,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) { Int iRet = 0; - if( ( iRet = m_cCmdLineHandler.parseToolsArgs( argc, argv ) ) > 0 ) + if( ( iRet = parseToolsArgs( argc, argv ) ) > 0 ) { return iRet; } @@ -145,11 +145,11 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) return 2; } - if( m_cCmdLineHandler.Opts().hasOpt( "save" ) ) + if( Opts().hasOpt( "save" ) ) { if( m_apcInputStreams.size() == 0 ) { - m_cCmdLineHandler.log( LOG_ERROR, "Invalid number of input streams! " ); + log( LOG_ERROR, "Invalid number of input streams! " ); return 2; } Int64 currFrames = 0; @@ -160,34 +160,34 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) if( currFrames < numberOfFrames ) numberOfFrames = currFrames; } - m_iFrameNum = m_cCmdLineHandler.m_iFrames; + m_iFrameNum = m_iFrames; if( !( m_iFrameNum >= 0 && m_iFrameNum < numberOfFrames ) ) { - m_cCmdLineHandler.log( LOG_ERROR, "Invalid frame number! Use --frame option " ); + log( LOG_ERROR, "Invalid frame number! Use --frame option " ); return 2; } - if( m_cCmdLineHandler.Opts().hasOpt( "output" ) ) - m_pcOutputFileNames.push_back( m_cCmdLineHandler.m_strOutput ); + if( Opts().hasOpt( "output" ) ) + m_pcOutputFileNames.push_back( m_strOutput ); if( m_pcOutputFileNames.size() != m_apcInputStreams.size() ) { - m_cCmdLineHandler.log( LOG_ERROR, "Invalid number of outputs! Each input must have an output filename. " ); + log( LOG_ERROR, "Invalid number of outputs! Each input must have an output filename. " ); return 2; } m_uiOperation = SAVE_OPERATION; m_fpProcess = &PlaYUVerTools::SaveOperation; - m_cCmdLineHandler.log( LOG_INFO, "PlaYUVer Save Frame\n" ); + log( LOG_INFO, "PlaYUVer Save Frame\n" ); } /** * Check Quality operation */ - if( m_cCmdLineHandler.Opts().hasOpt( "quality" ) ) + if( Opts().hasOpt( "quality" ) ) { - String qualityMetric = m_cCmdLineHandler.m_strQualityMetric; + String qualityMetric = m_strQualityMetric; if( m_apcInputStreams.size() < 2 ) { - m_cCmdLineHandler.log( LOG_ERROR, "Invalid number of inputs! " ); + log( LOG_ERROR, "Invalid number of inputs! " ); return 2; } for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ ) @@ -199,20 +199,20 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) } if( m_uiQualityMetric == -1 ) { - m_cCmdLineHandler.log( LOG_ERROR, "Invalid quality metric! " ); + log( LOG_ERROR, "Invalid quality metric! " ); return 2; } m_uiOperation = QUALITY_OPERATION; m_fpProcess = &PlaYUVerTools::QualityOperation; - m_cCmdLineHandler.log( LOG_INFO, "PlaYUVer Quality\n" ); + log( LOG_INFO, "PlaYUVer Quality\n" ); } /** * Check Module operation */ - if( m_cCmdLineHandler.Opts().hasOpt( "module" ) ) + if( Opts().hasOpt( "module" ) ) { - String moduleName = m_cCmdLineHandler.m_strModule; + String moduleName = m_strModule; PlaYUVerModuleFactoryMap& PlaYUVerModuleFactoryMap = PlaYUVerModuleFactory::Get()->getMap(); PlaYUVerModuleFactoryMap::iterator it = PlaYUVerModuleFactoryMap.begin(); @@ -226,17 +226,17 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) } if( !m_pcCurrModuleIf ) { - m_cCmdLineHandler.log( LOG_ERROR, "Invalid module! " ); + log( LOG_ERROR, "Invalid module! " ); return 2; } if( m_apcInputStreams.size() != m_pcCurrModuleIf->m_uiNumberOfFrames ) { - m_cCmdLineHandler.log( LOG_ERROR, "Invalid number of inputs! " ); + log( LOG_ERROR, "Invalid number of inputs! " ); return 2; } - m_pcCurrModuleIf->m_cModuleOptions.scanArgv( argc, ( const Char** )argv ); + m_pcCurrModuleIf->m_cModuleOptions.parse( argc, argv ); // Create Module Bool moduleCreated = false; @@ -256,7 +256,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) } if( !moduleCreated ) { - m_cCmdLineHandler.log( LOG_ERROR, "Module is not supported with the selected inputs! " ); + log( LOG_ERROR, "Module is not supported with the selected inputs! " ); return 2; } @@ -264,8 +264,8 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) { // Check outputs std::vector outputFileNames; - if( m_cCmdLineHandler.Opts().hasOpt( "output" ) ) - outputFileNames.push_back( m_cCmdLineHandler.m_strOutput ); + if( Opts().hasOpt( "output" ) ) + outputFileNames.push_back( m_strOutput ); if( outputFileNames.size() == 1 ) { @@ -279,7 +279,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) pcModFrame = applyFrameModule(); } PlaYUVerStream* pcModStream = new PlaYUVerStream; - if( !pcModStream->open( outputFileNames[0], pcModFrame->getWidth(), pcModFrame->getHeight(), pcModFrame->getPelFormat(), pcModFrame->getBitsPel(), 1, false ) ) + if( !pcModStream->open( outputFileNames[0], pcModFrame->getWidth(), pcModFrame->getHeight(), pcModFrame->getPelFormat(), pcModFrame->getBitsPel(), pcModFrame->getEndianness(), 1, false ) ) { delete pcModStream; pcModStream = NULL; @@ -289,19 +289,19 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) } else { - m_cCmdLineHandler.log( LOG_ERROR, "One output is required! " ); + log( LOG_ERROR, "One output is required! " ); return 2; } } m_uiOperation = MODULE_OPERATION; m_fpProcess = &PlaYUVerTools::ModuleOperation; - m_cCmdLineHandler.log( LOG_INFO, "PlaYUVer Module\n" ); + log( LOG_INFO, "PlaYUVer Module\n" ); } if( m_uiOperation == INVALID_OPERATION ) { - m_cCmdLineHandler.log( LOG_ERROR, "No operation was selected! " ); + log( LOG_ERROR, "No operation was selected! " ); return 2; } return iRet; @@ -361,19 +361,19 @@ Int PlaYUVerTools::QualityOperation() } metric_fmt += " "; - m_cCmdLineHandler.log( LOG_INFO, " Measuring Quality using %s ... \n", pchQualityMetricName ); - m_cCmdLineHandler.log( LOG_INFO, "# Frame ", pchQualityMetricName ); + log( LOG_INFO, " Measuring Quality using %s ... \n", pchQualityMetricName ); + log( LOG_INFO, "# Frame ", pchQualityMetricName ); for( UInt s = 1; s < m_apcInputStreams.size(); s++ ) { for( UInt c = 0; c < m_uiNumberOfComponents; c++ ) { - m_cCmdLineHandler.log( LOG_INFO, "%s_%d_%d ", pchQualityMetricName, s, c ); + log( LOG_INFO, "%s_%d_%d ", pchQualityMetricName, s, c ); } - m_cCmdLineHandler.log( LOG_INFO, " " ); + log( LOG_INFO, " " ); } - m_cCmdLineHandler.log( LOG_INFO, "\n" ); + log( LOG_INFO, "\n" ); for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) { @@ -385,22 +385,22 @@ Int PlaYUVerTools::QualityOperation() } for( UInt frame = 0; frame < m_uiNumberOfFrames; frame++ ) { - m_cCmdLineHandler.log( LOG_INFO, " %3d ", frame ); + log( LOG_INFO, " %3d ", frame ); for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) apcCurrFrame[s] = m_apcInputStreams[s]->getCurrFrame(); for( UInt s = 1; s < m_apcInputStreams.size(); s++ ) { - m_cCmdLineHandler.log( LOG_RESULT, " " ); + log( LOG_RESULT, " " ); for( UInt c = 0; c < m_uiNumberOfComponents; c++ ) { dQuality = apcCurrFrame[s]->getQuality( m_uiQualityMetric, apcCurrFrame[0], c ); adAverageQuality[s - 1][c] = ( adAverageQuality[s - 1][c] * Double( frame ) + dQuality ) / Double( frame + 1 ); - m_cCmdLineHandler.log( LOG_RESULT, metric_fmt.c_str(), dQuality ); + log( LOG_RESULT, metric_fmt.c_str(), dQuality ); } - m_cCmdLineHandler.log( LOG_RESULT, " " ); + log( LOG_RESULT, " " ); } - m_cCmdLineHandler.log( LOG_RESULT, "\n" ); + log( LOG_RESULT, "\n" ); for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) { abEOF[s] = m_apcInputStreams[s]->setNextFrame(); @@ -410,16 +410,16 @@ Int PlaYUVerTools::QualityOperation() } } } - m_cCmdLineHandler.log( LOG_INFO, "\n Mean Values: \n " ); + log( LOG_INFO, "\n Mean Values: \n " ); for( UInt s = 0; s < m_apcInputStreams.size() - 1; s++ ) { for( UInt c = 0; c < m_uiNumberOfComponents; c++ ) { - m_cCmdLineHandler.log( LOG_INFO, metric_fmt.c_str(), adAverageQuality[s][c] ); + log( LOG_INFO, metric_fmt.c_str(), adAverageQuality[s][c] ); } - m_cCmdLineHandler.log( LOG_RESULT, " " ); + log( LOG_RESULT, " " ); } - m_cCmdLineHandler.log( LOG_INFO, "\n" ); + log( LOG_INFO, "\n" ); return 0; } @@ -436,7 +436,7 @@ PlaYUVerFrame* PlaYUVerTools::applyFrameModule() Int PlaYUVerTools::ModuleOperation() { std::vector apcFrameList; - m_cCmdLineHandler.log( LOG_INFO, " Applying Module %s/%s ...\n", m_pcCurrModuleIf->m_pchModuleCategory, m_pcCurrModuleIf->m_pchModuleName ); + log( LOG_INFO, " Applying Module %s/%s ...\n", m_pcCurrModuleIf->m_pchModuleCategory, m_pcCurrModuleIf->m_pchModuleName ); PlaYUVerFrame* pcProcessedFrame = NULL; Double dMeasurementResult = 0.0; @@ -477,8 +477,8 @@ Int PlaYUVerTools::ModuleOperation() { dMeasurementResult = m_pcCurrModuleIf->measure( m_apcInputStreams[0]->getCurrFrame() ); } - m_cCmdLineHandler.log( LOG_INFO, " %3d", frame ); - m_cCmdLineHandler.log( LOG_RESULT, " %8.3f \n", dMeasurementResult ); + log( LOG_INFO, " %3d", frame ); + log( LOG_RESULT, " %8.3f \n", dMeasurementResult ); dAveragedMeasurementResult = ( dAveragedMeasurementResult * Double( frame ) + dMeasurementResult ) / Double( frame + 1 ); } @@ -494,7 +494,7 @@ Int PlaYUVerTools::ModuleOperation() if( m_pcCurrModuleIf->m_iModuleType == FRAME_MEASUREMENT_MODULE ) { - m_cCmdLineHandler.log( LOG_INFO, "\n Mean Value: \n %8.3f\n", dAveragedMeasurementResult ); + log( LOG_INFO, "\n Mean Value: \n %8.3f\n", dAveragedMeasurementResult ); } return 0; diff --git a/tools/PlaYUVerTools.h b/tools/PlaYUVerTools.h index baf0fcd..1b8634f 100644 --- a/tools/PlaYUVerTools.h +++ b/tools/PlaYUVerTools.h @@ -36,7 +36,7 @@ class PlaYUVerModuleIf; #define MAX_NUMBER_INPUTS 10 -class PlaYUVerTools +class PlaYUVerTools: public PlaYUVerToolsCmdParser { public: PlaYUVerTools(); @@ -47,7 +47,6 @@ public: Int Close(); private: - PlaYUVerToolsCmdParser m_cCmdLineHandler; Bool m_bVerbose; UInt m_uiOperation; diff --git a/tools/PlaYUVerToolsCmdParser.cpp b/tools/PlaYUVerToolsCmdParser.cpp index 1d5c1c1..012f492 100644 --- a/tools/PlaYUVerToolsCmdParser.cpp +++ b/tools/PlaYUVerToolsCmdParser.cpp @@ -36,6 +36,8 @@ PlaYUVerToolsCmdParser::PlaYUVerToolsCmdParser() m_uiLogLevel = 0; m_bQuiet = false; m_iFrames = -1; + + m_cOptions.addDefaultOptions(); } PlaYUVerToolsCmdParser::~PlaYUVerToolsCmdParser() @@ -92,12 +94,6 @@ Int PlaYUVerToolsCmdParser::parseToolsArgs( Int argc, Char *argv[] ) m_cOptions.doHelp( std::cout ); iRet = 1; } - - if( m_cOptions.hasOpt("module_list") || m_cOptions.hasOpt("module_list_full") ) - { - m_cOptions.listModules(); - iRet = 1; - } return iRet; } diff --git a/tools/PlaYUVerToolsCmdParser.h b/tools/PlaYUVerToolsCmdParser.h index 0796fd2..6aa4e12 100644 --- a/tools/PlaYUVerToolsCmdParser.h +++ b/tools/PlaYUVerToolsCmdParser.h @@ -34,7 +34,6 @@ class PlaYUVerStream; class PlaYUVerToolsCmdParser { - friend class PlaYUVerTools; public: PlaYUVerToolsCmdParser(); ~PlaYUVerToolsCmdParser(); @@ -65,7 +64,7 @@ public: return m_cOptions; } -private: +protected: PlaYUVerOptions m_cOptions; UInt m_uiLogLevel; diff --git a/tools/main.cpp b/tools/main.cpp index 6a4088e..97fbaf7 100644 --- a/tools/main.cpp +++ b/tools/main.cpp @@ -25,7 +25,7 @@ #include "PlaYUVerTools.h" -int main( int argc, char *argv[] ) +int main( int argc, Char *argv[] ) { Int iRet = 0; PlaYUVerTools PlaYUVerToolsApp;