Change formating and copyrights

This commit is contained in:
jfmcarreira committed 2018-01-15 23:47:58 +00:00
1 parent bc5258a94d
commit 06cdda6d8a
122 files changed
+14058 -12613

No files matched your search

+72 -39
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* This file is a part of PlaYUVer project
* Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@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
@@ -47,10 +47,12 @@ PlaYUVerTools::PlaYUVerTools()
PlaYUVerTools::~PlaYUVerTools()
{
for( UInt i = 0; i < m_apcInputStreams.size(); i++ ) {
for( UInt i = 0; i < m_apcInputStreams.size(); i++ )
{
m_apcInputStreams[i]->close();
}
for( UInt i = 0; i < m_apcOutputStreams.size(); i++ ) {
for( UInt i = 0; i < m_apcOutputStreams.size(); i++ )
{
m_apcOutputStreams[i]->close();
}
}
@@ -72,7 +74,8 @@ Int PlaYUVerTools::openInputs()
UInt uiEndianness = 0;
PlaYUVerStream* pcStream;
for( UInt i = 0; i < inputFileNames.size() && i < MAX_NUMBER_INPUTS; i++ ) {
for( UInt i = 0; i < inputFileNames.size() && i < MAX_NUMBER_INPUTS; i++ )
{
if( Opts().hasOpt( "size" ) )
{
resolutionString = GET_PARAM( m_strResolution, 0 );
@@ -108,7 +111,8 @@ Int PlaYUVerTools::openInputs()
}
catch( const char* msg )
{
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;
}
}
@@ -121,9 +125,11 @@ Int PlaYUVerTools::openInputs()
}
m_uiNumberOfComponents = UINT_MAX;
for( UInt i = 0; i < m_apcInputStreams.size(); i++ ) {
for( UInt i = 0; i < m_apcInputStreams.size(); i++ )
{
m_uiNumberOfFrames = std::min( m_uiNumberOfFrames, m_apcInputStreams[i]->getFrameNum() );
m_uiNumberOfComponents = std::min( m_uiNumberOfComponents, m_apcInputStreams[i]->getCurrFrame()->getNumberChannels() );
m_uiNumberOfComponents =
std::min( m_uiNumberOfComponents, m_apcInputStreams[i]->getCurrFrame()->getNumberChannels() );
}
return 0;
@@ -152,7 +158,8 @@ Int PlaYUVerTools::Open( Int argc, Char* argv[] )
}
Int64 currFrames = 0;
Int64 numberOfFrames = LONG_MAX;
for( UInt i = 0; i < m_apcInputStreams.size(); i++ ) {
for( UInt i = 0; i < m_apcInputStreams.size(); i++ )
{
currFrames = m_apcInputStreams[i]->getFrameNum();
if( currFrames < numberOfFrames )
numberOfFrames = currFrames;
@@ -186,7 +193,8 @@ Int PlaYUVerTools::Open( Int argc, Char* argv[] )
}
Int64 currFrames = 0;
Int64 numberOfFrames = LONG_MAX;
for( UInt i = 0; i < m_apcInputStreams.size(); i++ ) {
for( UInt i = 0; i < m_apcInputStreams.size(); i++ )
{
currFrames = m_apcInputStreams[i]->getFrameNum();
if( currFrames < numberOfFrames )
numberOfFrames = currFrames;
@@ -204,12 +212,14 @@ Int PlaYUVerTools::Open( Int argc, Char* argv[] )
PlaYUVerStream* pcOutputStream = new PlaYUVerStream;
try
{
pcOutputStream->open( m_pcOutputFileNames[0], pcInputFrame->getWidth(), pcInputFrame->getHeight(), pcInputFrame->getPelFormat(),
pcInputFrame->getBitsPel(), PLAYUVER_LITTLE_ENDIAN, 1, false );
pcOutputStream->open( m_pcOutputFileNames[0], pcInputFrame->getWidth(), pcInputFrame->getHeight(),
pcInputFrame->getPelFormat(), pcInputFrame->getBitsPel(), PLAYUVER_LITTLE_ENDIAN, 1,
false );
}
catch( const char* msg )
{
log( LOG_ERROR, "Cannot open input stream %s with the following error %s!\n", m_pcOutputFileNames[0].c_str(), msg );
log( LOG_ERROR, "Cannot open input stream %s with the following error %s!\n", m_pcOutputFileNames[0].c_str(),
msg );
delete pcOutputStream;
pcOutputStream = NULL;
return 2;
@@ -239,7 +249,8 @@ Int PlaYUVerTools::Open( Int argc, Char* argv[] )
log( LOG_ERROR, "Invalid number of inputs! " );
return 2;
}
for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ ) {
for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ )
{
if( lowercase( PlaYUVerFrame::supportedQualityMetricsList()[i] ) == lowercase( qualityMetric ) )
{
m_uiQualityMetric = i;
@@ -264,7 +275,8 @@ Int PlaYUVerTools::Open( Int argc, Char* argv[] )
PlaYUVerModuleFactoryMap& PlaYUVerModuleFactoryMap = PlaYUVerModuleFactory::Get()->getMap();
PlaYUVerModuleFactoryMap::iterator it = PlaYUVerModuleFactoryMap.begin();
for( UInt i = 0; it != PlaYUVerModuleFactoryMap.end(); ++it, i++ ) {
for( UInt i = 0; it != PlaYUVerModuleFactoryMap.end(); ++it, i++ )
{
if( strcmp( it->first, moduleName.c_str() ) == 0 )
{
m_pcCurrModuleIf = it->second();
@@ -288,7 +300,8 @@ Int PlaYUVerTools::Open( Int argc, Char* argv[] )
// Create Module
Bool moduleCreated = false;
std::vector<PlaYUVerFrame*> apcFrameList;
for( UInt i = 0; i < m_pcCurrModuleIf->m_uiNumberOfFrames; i++ ) {
for( UInt i = 0; i < m_pcCurrModuleIf->m_uiNumberOfFrames; i++ )
{
apcFrameList.push_back( m_apcInputStreams[i]->getCurrFrame() );
}
if( m_pcCurrModuleIf->m_iModuleAPI == MODULE_API_2 )
@@ -327,12 +340,13 @@ Int PlaYUVerTools::Open( Int argc, Char* argv[] )
PlaYUVerStream* pcModStream = new PlaYUVerStream;
try
{
pcModStream->open( outputFileNames[0], pcModFrame->getWidth(), pcModFrame->getHeight(), pcModFrame->getPelFormat(),
pcModFrame->getBitsPel(), PLAYUVER_LITTLE_ENDIAN, 1, false );
pcModStream->open( outputFileNames[0], pcModFrame->getWidth(), pcModFrame->getHeight(),
pcModFrame->getPelFormat(), pcModFrame->getBitsPel(), PLAYUVER_LITTLE_ENDIAN, 1, false );
}
catch( const char* msg )
{
log( LOG_ERROR, "Cannot open input stream %s with the following error %s!\n", outputFileNames[0].c_str(), msg );
log( LOG_ERROR, "Cannot open input stream %s with the following error %s!\n", outputFileNames[0].c_str(),
msg );
delete pcModStream;
pcModStream = NULL;
return 2;
@@ -373,7 +387,8 @@ Int PlaYUVerTools::Close()
Int PlaYUVerTools::SaveOperation()
{
Bool bRet = true;
for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) {
for( UInt s = 0; s < m_apcInputStreams.size(); s++ )
{
bRet = m_apcInputStreams[s]->seekInput( m_iFrameNum );
if( bRet == false )
{
@@ -388,7 +403,8 @@ Int PlaYUVerTools::RateReductionOperation()
{
Bool abEOF;
log( LOG_INFO, "\n Reducing frame rate by a factor of %d ... ", m_iRateReductionFactor );
for( UInt frame = 0; frame < m_uiNumberOfFrames; frame++ ) {
for( UInt frame = 0; frame < m_uiNumberOfFrames; frame++ )
{
log( LOG_INFO, "\n Reading frame %d ... ", frame );
if( ( frame % m_iRateReductionFactor ) == 0 )
{
@@ -435,8 +451,10 @@ Int PlaYUVerTools::QualityOperation()
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++ ) {
for( UInt s = 1; s < m_apcInputStreams.size(); s++ )
{
for( UInt c = 0; c < m_uiNumberOfComponents; c++ )
{
log( LOG_INFO, "%s_%d_%d ", pchQualityMetricName, s, c );
}
log( LOG_INFO, " " );
@@ -444,19 +462,25 @@ Int PlaYUVerTools::QualityOperation()
log( LOG_INFO, "\n" );
for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) {
for( UInt s = 0; s < m_apcInputStreams.size(); s++ )
{
abEOF[s] = false;
for( UInt c = 0; c < m_uiNumberOfComponents; c++ ) {
for( UInt c = 0; c < m_uiNumberOfComponents; c++ )
{
adAverageQuality[s][c] = 0;
}
}
for( UInt frame = 0; frame < m_uiNumberOfFrames; frame++ ) {
for( UInt frame = 0; frame < m_uiNumberOfFrames; frame++ )
{
log( LOG_INFO, " %3d ", frame );
for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) apcCurrFrame[s] = m_apcInputStreams[s]->getCurrFrame();
for( UInt s = 0; s < m_apcInputStreams.size(); s++ )
apcCurrFrame[s] = m_apcInputStreams[s]->getCurrFrame();
for( UInt s = 1; s < m_apcInputStreams.size(); s++ ) {
for( UInt s = 1; s < m_apcInputStreams.size(); s++ )
{
log( LOG_RESULT, " " );
for( UInt c = 0; c < m_uiNumberOfComponents; c++ ) {
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 );
log( LOG_RESULT, metric_fmt.c_str(), dQuality );
@@ -464,7 +488,8 @@ Int PlaYUVerTools::QualityOperation()
log( LOG_RESULT, " " );
}
log( LOG_RESULT, "\n" );
for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) {
for( UInt s = 0; s < m_apcInputStreams.size(); s++ )
{
abEOF[s] = m_apcInputStreams[s]->setNextFrame();
if( !abEOF[s] )
{
@@ -473,8 +498,10 @@ Int PlaYUVerTools::QualityOperation()
}
}
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++ ) {
for( UInt s = 0; s < m_apcInputStreams.size() - 1; s++ )
{
for( UInt c = 0; c < m_uiNumberOfComponents; c++ )
{
log( LOG_INFO, metric_fmt.c_str(), adAverageQuality[s][c] );
}
log( LOG_RESULT, " " );
@@ -496,20 +523,24 @@ PlaYUVerFrame* PlaYUVerTools::applyFrameModule()
Int PlaYUVerTools::ModuleOperation()
{
std::vector<PlaYUVerFrame*> apcFrameList;
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;
Double dAveragedMeasurementResult = 0;
Bool abEOF[MAX_NUMBER_INPUTS];
for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) {
for( UInt s = 0; s < m_apcInputStreams.size(); s++ )
{
abEOF[s] = false;
}
for( UInt frame = 0; frame < m_uiNumberOfFrames; frame++ ) {
for( UInt frame = 0; frame < m_uiNumberOfFrames; frame++ )
{
apcFrameList.clear();
for( UInt i = 0; i < m_pcCurrModuleIf->m_uiNumberOfFrames; i++ ) {
for( UInt i = 0; i < m_pcCurrModuleIf->m_uiNumberOfFrames; i++ )
{
apcFrameList.push_back( m_apcInputStreams[i]->getCurrFrame() );
}
if( m_pcCurrModuleIf->m_iModuleType == FRAME_PROCESSING_MODULE )
@@ -536,10 +567,12 @@ Int PlaYUVerTools::ModuleOperation()
}
log( LOG_INFO, " %3d", frame );
log( LOG_RESULT, " %8.3f \n", dMeasurementResult );
dAveragedMeasurementResult = ( dAveragedMeasurementResult * Double( frame ) + dMeasurementResult ) / Double( frame + 1 );
dAveragedMeasurementResult =
( dAveragedMeasurementResult * Double( frame ) + dMeasurementResult ) / Double( frame + 1 );
}
for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) {
for( UInt s = 0; s < m_apcInputStreams.size(); s++ )
{
abEOF[s] = m_apcInputStreams[s]->setNextFrame();
if( !abEOF[s] )
{