Add interface to measure quality using command line
This commit is contained in:
1 parent
64ecfbf016
commit
a8ee5c9658
5 files changed
+87
-45
No files matched your search
@@ -23,6 +23,8 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "PlaYUVerCmdParser.h"
|
||||
@@ -30,11 +32,25 @@
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
PlaYUVerCmdParser::PlaYUVerCmdParser( Int argc, Char *argv[] )
|
||||
{
|
||||
m_iArgc = argc;
|
||||
m_apcArgv = argv;
|
||||
m_ParserOptions.add( GetCommandOpts() );
|
||||
}
|
||||
|
||||
PlaYUVerCmdParser::~PlaYUVerCmdParser()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
po::options_description PlaYUVerCmdParser::GetCommandOpts()
|
||||
{
|
||||
po::options_description inputOpts( "Input" );
|
||||
inputOpts.add_options()
|
||||
( "input,i", po::value<std::string>(), "input file" )
|
||||
( "input,i", po::value<std::vector<std::string> >(), "input file" )
|
||||
( "size,s", po::value<std::string>(), "size (WxH)" )
|
||||
( "pel_fmt", po::value<std::string>(), "pixel format name" )
|
||||
( "width,w", po::value<Int>(), "width" )
|
||||
( "height,h", po::value<Int>(), "height" );
|
||||
|
||||
@@ -45,9 +61,49 @@ po::options_description PlaYUVerCmdParser::GetCommandOpts()
|
||||
|
||||
po::options_description commonOpts( "Common" );
|
||||
commonOpts.add_options()
|
||||
( "help", "produce help message" );
|
||||
( "help", "produce help message" )
|
||||
( "version", "show version and exit" );
|
||||
commonOpts.add( inputOpts ).add( operationOpts );
|
||||
return commonOpts;
|
||||
}
|
||||
|
||||
Void PlaYUVerCmdParser::addOptions( po::options_description opts )
|
||||
{
|
||||
m_ParserOptions.add( opts );
|
||||
}
|
||||
|
||||
Bool PlaYUVerCmdParser::parse()
|
||||
{
|
||||
try
|
||||
{
|
||||
po::store( po::command_line_parser( m_iArgc, m_apcArgv ).options( m_ParserOptions ).allow_unregistered().run(), m_cOptionsMap );
|
||||
po::notify( m_cOptionsMap );
|
||||
|
||||
if( m_cOptionsMap.count( "help" ) )
|
||||
{
|
||||
std::cout << m_ParserOptions
|
||||
<< "\n";
|
||||
return false;
|
||||
}
|
||||
if( m_cOptionsMap.count( "version" ) )
|
||||
{
|
||||
std::cout << "PlaYUVer version "
|
||||
<< PLAYUVER_VERSION_STRING
|
||||
<< "\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch( std::exception& e )
|
||||
{
|
||||
std::cerr << "error: " << e.what() << "\n";
|
||||
return false;
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
std::cerr << "Exception of unknown type!\n";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // NAMESPACE
|
||||
+15
-2
@@ -32,11 +32,24 @@ namespace plaYUVer
|
||||
class PlaYUVerCmdParser
|
||||
{
|
||||
public:
|
||||
PlaYUVerCmdParser() {} ;
|
||||
~PlaYUVerCmdParser() {} ;
|
||||
PlaYUVerCmdParser( Int argc, Char *argv[] );
|
||||
~PlaYUVerCmdParser();
|
||||
|
||||
Void addOptions( po::options_description );
|
||||
Bool parse();
|
||||
|
||||
po::variables_map getOptionsMap()
|
||||
{
|
||||
return m_cOptionsMap;
|
||||
}
|
||||
|
||||
static po::options_description GetCommandOpts();
|
||||
|
||||
private:
|
||||
Int m_iArgc;
|
||||
Char** m_apcArgv;
|
||||
po::options_description m_ParserOptions;
|
||||
po::variables_map m_cOptionsMap;
|
||||
};
|
||||
|
||||
} // NAMESPACE
|
||||
@@ -167,9 +167,10 @@ Bool PlaYUVerStream::open( std::string filename, std::string resolution, std::st
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ )
|
||||
{
|
||||
if( PlaYUVerFrame::supportedPixelFormatListNames()[i] == input_format_name )
|
||||
if( lowercase( PlaYUVerFrame::supportedPixelFormatListNames()[i] ) == lowercase( input_format_name ) )
|
||||
{
|
||||
input_format = i;
|
||||
break;
|
||||
|
||||
@@ -9,8 +9,9 @@ INCLUDE_DIRECTORIES(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../ )
|
||||
|
||||
set(plaYUver_Tools_SRCS
|
||||
# Main
|
||||
main.cpp
|
||||
# Main
|
||||
main.cpp
|
||||
PlaYUVerTools.cpp
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE( ${PROJECT_NAME}Tools ${plaYUver_Tools_SRCS} )
|
||||
|
||||
+9
-38
@@ -1,6 +1,7 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
|
||||
* Joao Carreira (jfmcarreira@gmail.com)
|
||||
* Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com)
|
||||
*
|
||||
* Joao Carreira (jfmcarreira@gmail.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,50 +23,20 @@
|
||||
* \brief main file
|
||||
*/
|
||||
|
||||
#include <lib/PlaYUVerCmdParser.h>
|
||||
#include <lib/PlaYUVerFrame.h>
|
||||
#include <lib/PlaYUVerStream.h>
|
||||
#include "PlaYUVerTools.h"
|
||||
|
||||
using namespace plaYUVer;
|
||||
using namespace std;
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
PlaYUVerTools PlaYUVerToolsApp;
|
||||
|
||||
try
|
||||
if( PlaYUVerToolsApp.Init( argc, argv ) > 1 )
|
||||
{
|
||||
|
||||
po::options_description toolsOpt;
|
||||
toolsOpt.add( PlaYUVerCmdParser::GetCommandOpts() );
|
||||
po::variables_map vm;
|
||||
po::store( po::parse_command_line( argc, argv, toolsOpt ), vm );
|
||||
po::notify( vm );
|
||||
|
||||
if( vm.count( "help" ) )
|
||||
{
|
||||
cout << toolsOpt << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( vm.count( "compression" ) )
|
||||
{
|
||||
cout << "Compression level was set to " << vm["compression"].as<double>() << ".\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Compression level was not set.\n";
|
||||
}
|
||||
}
|
||||
catch( exception& e )
|
||||
{
|
||||
cerr << "error: " << e.what() << "\n";
|
||||
printf( "Exiting\n" );
|
||||
return 1;
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
cerr << "Exception of unknown type!\n";
|
||||
}
|
||||
|
||||
PlaYUVerFrame pcFrameBuffer = new PlaYUVerFrame( 1024, 768, PlaYUVerFrame::YUV420p );
|
||||
return 0;
|
||||
PlaYUVerToolsApp.Process();
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user