Add Save Operation into playuverTools
This commit is contained in:
1 parent
66203da1d7
commit
f309ed6f3c
4 files changed
+58
-3
No files matched your search
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
#include <climits>
|
||||
#include "PlaYUVerTools.h"
|
||||
#include "lib/PlaYUVerModuleIf.h"
|
||||
#include "modules/PlaYUVerModuleFactory.h"
|
||||
@@ -131,6 +132,40 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
|
||||
return 2;
|
||||
}
|
||||
|
||||
if( m_cCmdLineHandler.Opts()["save"]->count() )
|
||||
{
|
||||
if( m_apcInputStreams.size() == 0 )
|
||||
{
|
||||
m_cCmdLineHandler.log( LOG_ERROR, "Invalid number of input streams! " );
|
||||
return 2;
|
||||
}
|
||||
Int64 currFrames = 0;
|
||||
Int64 numberOfFrames = LONG_MAX;
|
||||
for( UInt i = 0; i < m_apcInputStreams.size(); i++ )
|
||||
{
|
||||
currFrames = m_apcInputStreams[i]->getFrameNum();
|
||||
if( currFrames < numberOfFrames )
|
||||
numberOfFrames = currFrames;
|
||||
}
|
||||
m_iFrameNum = m_cCmdLineHandler.m_iFrames;
|
||||
if( !( m_iFrameNum >= 0 && m_iFrameNum < numberOfFrames ) )
|
||||
{
|
||||
m_cCmdLineHandler.log( LOG_ERROR, "Invalid frame number! Use --frame option " );
|
||||
return 2;
|
||||
}
|
||||
if( m_cCmdLineHandler.Opts()["output"]->count() )
|
||||
m_pcOutputFileNames.push_back( m_cCmdLineHandler.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. " );
|
||||
return 2;
|
||||
}
|
||||
|
||||
m_uiOperation = SAVE_OPERATION;
|
||||
m_fpProcess = &PlaYUVerTools::SaveOperation;
|
||||
m_cCmdLineHandler.log( LOG_INFO, "PlaYUVer Save Frame\n" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Quality operation
|
||||
*/
|
||||
@@ -265,6 +300,21 @@ Int PlaYUVerTools::Close()
|
||||
return 0;
|
||||
}
|
||||
|
||||
Int PlaYUVerTools::SaveOperation()
|
||||
{
|
||||
Bool bRet = true;
|
||||
for( UInt s = 0; s < m_apcInputStreams.size(); s++ )
|
||||
{
|
||||
bRet = m_apcInputStreams[s]->seekInput( m_iFrameNum );
|
||||
if( bRet == false )
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
m_apcInputStreams[s]->saveFrame( m_pcOutputFileNames[s] );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Int PlaYUVerTools::QualityOperation()
|
||||
{
|
||||
PlaYUVerFrame* apcCurrFrame[MAX_NUMBER_INPUTS];
|
||||
|
||||
@@ -56,6 +56,7 @@ private:
|
||||
enum TOOLS_OPERATIONS_LIST
|
||||
{
|
||||
INVALID_OPERATION,
|
||||
SAVE_OPERATION,
|
||||
QUALITY_OPERATION,
|
||||
MODULE_OPERATION,
|
||||
};
|
||||
@@ -70,6 +71,9 @@ private:
|
||||
typedef Int (PlaYUVerTools::*FpProcess) ();
|
||||
FpProcess m_fpProcess;
|
||||
|
||||
Int64 m_iFrameNum;
|
||||
std::vector<std::string> m_pcOutputFileNames;
|
||||
Int SaveOperation();
|
||||
|
||||
Int m_uiQualityMetric;
|
||||
Int QualityOperation();
|
||||
|
||||
@@ -75,7 +75,8 @@ Int PlaYUVerToolsCmdParser::parseToolsArgs( Int argc, Char *argv[] )
|
||||
|
||||
Opts().addOptions()/**/
|
||||
( "quality", m_strQualityMetric, "select a quality metric" ) /**/
|
||||
( "module", m_strModule, "select a module (use internal name)" );
|
||||
( "module", m_strModule, "select a module (use internal name)" ) /**/
|
||||
( "save", "save a specific frame" );
|
||||
|
||||
config( argc, argv );
|
||||
if( !parse() )
|
||||
@@ -95,7 +96,7 @@ Int PlaYUVerToolsCmdParser::parseToolsArgs( Int argc, Char *argv[] )
|
||||
}
|
||||
else if( Opts()["help"]->count() )
|
||||
{
|
||||
printf( "Usage: %s modules/quality [options] -input=input_file [--output=output_file]\n", argv[0] );
|
||||
printf( "Usage: %s modules/quality/save [options] -input=input_file [--output=output_file]\n", argv[0] );
|
||||
Opts().doHelp( std::cout );
|
||||
iRet = 1;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ private:
|
||||
std::string m_strPelFmt;
|
||||
UInt m_uiBitsPerPixel;
|
||||
Bool m_bListPelFmts;
|
||||
Int m_iFrames;
|
||||
Int64 m_iFrames;
|
||||
|
||||
Bool m_bListQuality;
|
||||
std::string m_strQualityMetric;
|
||||
|
||||
Reference in new issue
Block a user