diff --git a/app/PlaYUVerAppModuleIf.cpp b/app/PlaYUVerAppModuleIf.cpp index e71b17d..c4d15d8 100644 --- a/app/PlaYUVerAppModuleIf.cpp +++ b/app/PlaYUVerAppModuleIf.cpp @@ -58,14 +58,18 @@ Void PlaYUVerAppModuleIf::update() Bool PlaYUVerAppModuleIf::apply( Bool isPlaying, Bool disableThreads ) { Bool bRet = false; + QApplication::setOverrideCursor( Qt::WaitCursor ); - if( m_pcDisplaySubWindow ) + if( m_pcModule->m_iModuleType == FRAME_PROCESSING_MODULE ) { - m_pcDisplaySubWindow->setFillWindow( true ); - } - else - { - m_pcSubWindow[0]->setFillWindow( true ); + if( m_pcDisplaySubWindow ) + { + m_pcDisplaySubWindow->setFillWindow( true ); + } + else + { + m_pcSubWindow[0]->setFillWindow( true ); + } } if( !( isPlaying && ( m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_SKIP_WHILE_PLAY ) ) ) { diff --git a/app/PlaYUVerAppModuleIf.h b/app/PlaYUVerAppModuleIf.h index 3bfb424..817055b 100644 --- a/app/PlaYUVerAppModuleIf.h +++ b/app/PlaYUVerAppModuleIf.h @@ -40,7 +40,7 @@ class QAction; namespace plaYUVer { -#define PLAYUVER_THREADED_MODULES +//#define PLAYUVER_THREADED_MODULES class VideoSubWindow; diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index ec3f4aa..2f4ebc9 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -9,7 +9,7 @@ set(PlaYUVer_Lib_SRCS PlaYUVerFrame.cpp PlaYUVerPixel.cpp PlaYUVerFramePixelFormats.cpp - # PlaYUVerFrameStats.cpp + # PlaYUVerFrameStats.cpp # Stream PlaYUVerStream.cpp StreamHandlerRaw.cpp diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index db5a07e..c45cca9 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -43,6 +43,7 @@ ADD_MODULE( SetChromaHalfScale "SetChromaHalfScale" ) ADD_MODULE( EightBitsSampling "EightBitsSampling" ) ADD_MODULE( FrameCrop "FrameCrop" ) ADD_MODULE( LumaAverage "LumaAverage" ) +ADD_MODULE( WeightedPSNR "WeightedPSNR" ) IF( USE_OPENCV ) ADD_MODULE( DisparityStereoBM "DisparityStereoBM" ) ADD_MODULE( DisparityStereoSGBM "DisparityStereoSGBM" ) diff --git a/modules/PlaYUVerModuleFactory.cpp b/modules/PlaYUVerModuleFactory.cpp index 961295b..957aa10 100644 --- a/modules/PlaYUVerModuleFactory.cpp +++ b/modules/PlaYUVerModuleFactory.cpp @@ -48,6 +48,7 @@ PlaYUVerModuleFactory::PlaYUVerModuleFactory() Register( "FrameShift", &FrameShift::Create ); Register( "EightBitsSampling", &EightBitsSampling::Create ); Register( "LumaAverage", &LumaAverage::Create ); + Register( "WeightedPSNR", &WeightedPSNR::Create ); #ifdef USE_OPENCV //Register( "DisparityStereoVar", &DisparityStereoVar::Create ); Register( "DisparityStereoBM", &DisparityStereoBM::Create ); diff --git a/modules/WeightedPSNR.cpp b/modules/WeightedPSNR.cpp new file mode 100644 index 0000000..85130ce --- /dev/null +++ b/modules/WeightedPSNR.cpp @@ -0,0 +1,116 @@ +/* This file is a part of plaYUVer project + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file WeightedPSNR.cpp + * \brief Weighted PSNR quality module + */ + +#include "WeightedPSNR.h" +#include +#include + +namespace plaYUVer +{ + +WeightedPSNR::WeightedPSNR() +{ + /* Module Definition */ + m_iModuleAPI = MODULE_API_2; + m_iModuleType = FRAME_MEASUREMENT_MODULE; + m_pchModuleCategory = "Quality"; + m_pchModuleName = "WeightedPSNR"; + m_pchModuleTooltip = "Measure the weighted PSNR between two images"; + m_uiModuleRequirements = MODULE_REQUIRES_OPTIONS; + m_uiNumberOfFrames = MODULE_REQUIRES_THREE_FRAMES; + + m_cModuleOptions.addOptions()/**/ + ( "Component", m_uiComponent, "Select the component to compute quality [0]" ); + + m_uiComponent = 0; + +} + +Bool WeightedPSNR::create( std::vector apcFrameList ) +{ + _BASIC_MODULE_API_2_CHECK_ + + for( UInt i = 1; i < apcFrameList.size(); i++ ) + { + if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], PlaYUVerFrame::MATCH_COLOR_SPACE | PlaYUVerFrame::MATCH_RESOLUTION | PlaYUVerFrame::MATCH_BITS ) ) + return false; + } + return true; +} + +Double measureWMSE( Int component, PlaYUVerFrame* Org, PlaYUVerFrame* Rec, PlaYUVerFrame* Mask ) +{ + Pel* pMaskPelYUV = Mask->getPelBufferYUV()[0][0]; + Pel* pRecPelYUV = Rec->getPelBufferYUV()[component][0]; + Pel* pOrgPelYUV = Org->getPelBufferYUV()[component][0]; + + Double aux_pel_1, aux_pel_2, aux_pel_mask; + Int diff = 0; + Double ssd = 0; + UInt count = 0; + + UInt numberOfPixels = 0; + if( component == LUMA ) + { + numberOfPixels = Org->getHeight() * Org->getWidth(); + } + else + { + numberOfPixels = Rec->getChromaLength(); + } + + for( UInt i = 0; i < numberOfPixels; i++ ) + { + aux_pel_mask = *pMaskPelYUV++; + aux_pel_1 = *pRecPelYUV++; + aux_pel_2 = *pOrgPelYUV++; + diff = aux_pel_1 - aux_pel_2; + ssd += ( aux_pel_mask * diff * diff ); + count += aux_pel_mask; + } + if( ssd == 0.0 ) + { + return 0.0; + } + return ssd / Double( count ); +} + + +Double WeightedPSNR::measure( std::vector apcFrameList ) +{ + Double dPSNR = 100; + Double dMaxValue = ( 1 << apcFrameList[1]->getBitsPel() ) - 1; + Double dMSE = measureWMSE( m_uiComponent, apcFrameList[1], apcFrameList[2], apcFrameList[0] ); + if( dMSE != 0 ) + dPSNR = 10 * log10( ( dMaxValue * dMaxValue ) / dMSE ); + return dPSNR; +} + +Void WeightedPSNR::destroy() +{ + +} + +} // NAMESPACE + diff --git a/modules/WeightedPSNR.h b/modules/WeightedPSNR.h new file mode 100644 index 0000000..0ca0f06 --- /dev/null +++ b/modules/WeightedPSNR.h @@ -0,0 +1,56 @@ +/* This file is a part of plaYUVer project + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file WeightedPSNR.h + * \brief Frame Difference module + */ + +#ifndef __WEIGHTEDPSNR_H__ +#define __WEIGHTEDPSNR_H__ + +#include "lib/PlaYUVerModuleIf.h" + +#include + +namespace plaYUVer +{ + +class WeightedPSNR: public PlaYUVerModuleIf +{ +REGISTER_CLASS_FACTORY( WeightedPSNR ) + +private: + UInt m_uiComponent; + +public: + WeightedPSNR(); + virtual ~WeightedPSNR() + { + } + Bool create( std::vector apcFrameList ); + Double measure( std::vector apcFrameList ); + Void destroy(); + +}; + +} // NAMESPACE + +#endif // __WEIGHTEDPSNR_H__ +