diff --git a/CMakeLists.txt b/CMakeLists.txt index 619037f..7c6557d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,9 +41,6 @@ OPTION( PLAYUVER_WERROR "Warnings as errors" OFF ) OPTION( PLAYUVER_THREADED_MODULES "Use threads for modules" OFF ) OPTION( USE_QT4 "Build with QT4" OFF ) -ADD_FEATURE_INFO(Fervor USE_FERVOR "Fervor lib includes check for updates feature.") -ADD_FEATURE_INFO(WErrors PLAYUVER_WERROR "Warnings as errors" ) - ##################################################################################### # Qt library ###################################################################################### @@ -102,6 +99,9 @@ IF( USE_FFMPEG ) ENDIF() SET_PACKAGE_PROPERTIES(FFmpeg PROPERTIES URL "http://ffmpeg.org/" DESCRIPTION "Libav library support in PlaYUVerStream" TYPE OPTIONAL) +ADD_FEATURE_INFO(Fervor USE_FERVOR "Fervor lib includes check for updates feature.") +ADD_FEATURE_INFO(WErrors PLAYUVER_WERROR "Warnings as errors" ) + IF( WIN32 ) INCLUDE( cmake/Win32.cmake ) ENDIF() diff --git a/app/ConfigureFormatDialog.cpp b/app/ConfigureFormatDialog.cpp index eb71e77..dc47ec6 100644 --- a/app/ConfigureFormatDialog.cpp +++ b/app/ConfigureFormatDialog.cpp @@ -159,7 +159,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : m_comboBoxPixelFormat->clear(); for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ ) { - m_comboBoxPixelFormat->insertItem( i, PlaYUVerFrame::supportedPixelFormatListNames()[i].data() ); + m_comboBoxPixelFormat->insertItem( i, PlaYUVerFrame::supportedPixelFormatListNames()[i].c_str() ); } m_comboBoxPixelFormat->setCurrentIndex( 1 ); diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index a96cbf5..d481017 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -452,22 +452,23 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) QString supported = tr( "Supported Files (" ); QStringList formatsList; - QStringList formatsExt = PlaYUVerStream::supportedWriteFormatsExt(); - QStringList formatsName = PlaYUVerStream::supportedWriteFormatsName(); + std::vector formatsExt = PlaYUVerStream::supportedWriteFormatsExt(); + std::vector formatsName = PlaYUVerStream::supportedWriteFormatsName(); - for( Int i = 0; i < formatsName.size(); i++ ) + for( UInt i = 0; i < formatsName.size(); i++ ) { QString currFmt; supported.append( " *." ); - supported.append( formatsExt[i] ); - currFmt.append( formatsName[i] ); + supported.append( QString::fromStdString( formatsExt[i] ) ); + currFmt.append( QString::fromStdString( formatsName[i] ) ); currFmt.append( " (*." ); - currFmt.append( formatsExt[i] ); + currFmt.append( QString::fromStdString( formatsExt[i] ) ); currFmt.append( ")" ); formatsList << currFmt; } supported.append( " )" ); + QStringList filter; filter << supported << formatsList diff --git a/app/QualityHandle.cpp b/app/QualityHandle.cpp index 24efc55..2252a3b 100644 --- a/app/QualityHandle.cpp +++ b/app/QualityHandle.cpp @@ -131,7 +131,7 @@ Void QualityHandle::slotQualityMetricChanged( Int idx ) Void QualityHandle::slotSelectReference() { - DialogSubWindowSelector dialogWindowSelection( this, m_pcMainWindowManager, 1, 1 ); + DialogSubWindowSelector dialogWindowSelection( this, m_pcMainWindowManager, SubWindowHandle::VIDEO_SUBWINDOW, 1, 1 ); if( dialogWindowSelection.exec() == QDialog::Accepted ) { VideoSubWindow* pcVideoSubWindow; diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index e88b401..c48200a 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -192,6 +192,7 @@ Void VideoHandle::readSettings() { QSettings appSettings; m_arrayActions[VIDEO_LOOP_ACT]->setChecked( appSettings.value( "VideoHandle/Repeat", false ).toBool() ); + m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->setChecked( appSettings.value( "VideoHandle/VideoZoomLock", false ).toBool() ); if( !appSettings.value( "VideoHandle/FrameProperties", true ).toBool() ) m_pcFramePropertiesDock->close(); } @@ -200,6 +201,7 @@ Void VideoHandle::writeSettings() { QSettings appSettings; appSettings.setValue( "VideoHandle/Repeat", m_arrayActions[VIDEO_LOOP_ACT]->isChecked() ); + appSettings.setValue( "VideoHandle/VideoZoomLock", m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() ); appSettings.setValue( "VideoHandle/FrameProperties", m_pcFramePropertiesSideBar->isVisible() ); } diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index d6335ce..2e003bf 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -91,8 +91,8 @@ Void plaYUVerApp::parseArgs( Int argc, Char *argv[] ) { loadFile( argv[i] ); } -// m_pcWindowHandle->tileSubWindows(); -// zoomToFitAll(); + m_pcWindowHandle->tileSubWindows(); + zoomToFitAll(); } } @@ -218,17 +218,17 @@ Void plaYUVerApp::open() { QString supported = tr( "Supported Files (" ); QStringList formatsList; - QStringList formatsExt = PlaYUVerStream::supportedReadFormatsExt(); - QStringList formatsName = PlaYUVerStream::supportedReadFormatsName(); + std::vector formatsExt = PlaYUVerStream::supportedReadFormatsExt(); + std::vector formatsName = PlaYUVerStream::supportedReadFormatsName(); - for( Int i = 0; i < formatsName.size(); i++ ) + for( UInt i = 0; i < formatsName.size(); i++ ) { QString currFmt; supported.append( " *." ); - supported.append( formatsExt[i] ); - currFmt.append( formatsName[i] ); + supported.append( QString::fromStdString( formatsExt[i] ) ); + currFmt.append( QString::fromStdString( formatsName[i] ) ); currFmt.append( " (*." ); - currFmt.append( formatsExt[i] ); + currFmt.append( QString::fromStdString( formatsExt[i] ) ); currFmt.append( ")" ); formatsList << currFmt; } @@ -265,17 +265,17 @@ Void plaYUVerApp::save() VideoSubWindow *saveWindow = m_pcCurrentVideoSubWindow; QString supported = tr( "Supported Files (" ); QStringList formatsList; - QStringList formatsExt = PlaYUVerStream::supportedSaveFormatsExt(); - QStringList formatsName = PlaYUVerStream::supportedSaveFormatsName(); + std::vector formatsExt = PlaYUVerStream::supportedSaveFormatsExt(); + std::vector formatsName = PlaYUVerStream::supportedSaveFormatsName(); - for( Int i = 0; i < formatsName.size(); i++ ) + for( UInt i = 0; i < formatsName.size(); i++ ) { QString currFmt; supported.append( " *." ); - supported.append( formatsExt[i] ); - currFmt.append( formatsName[i] ); + supported.append( QString::fromStdString( formatsExt[i] ) ); + currFmt.append( QString::fromStdString( formatsName[i] ) ); currFmt.append( " (*." ); - currFmt.append( formatsExt[i] ); + currFmt.append( QString::fromStdString( formatsExt[i] ) ); currFmt.append( ")" ); formatsList << currFmt; } @@ -409,7 +409,6 @@ Void plaYUVerApp::zoomToFitAll() updateZoomFactorSBox(); } - Void plaYUVerApp::scaleFrame( int ratio ) { if( m_pcCurrentSubWindow ) @@ -846,6 +845,20 @@ Void plaYUVerApp::updateRecentFileActions() m_arrayMenu[RECENT_MENU]->setEnabled( m_aRecentFileStreamInfo.size() > 0 ? true : false ); } +Void plaYUVerApp::checkRecentFileActions() +{ + Int i = 0; + while( i < m_aRecentFileStreamInfo.size() ) + { + if( !QFileInfo::exists( m_aRecentFileStreamInfo.at( i ).m_cFilename ) ) + { + m_aRecentFileStreamInfo.remove( i ); + continue; + } + i++; + } +} + Void plaYUVerApp::readSettings() { QSettings appSettings; @@ -862,6 +875,7 @@ Void plaYUVerApp::readSettings() QVariant value = appSettings.value( "MainWindow/RecentFileList" ); m_aRecentFileStreamInfo = value.value(); + checkRecentFileActions(); updateRecentFileActions(); m_appModuleVideo->readSettings(); diff --git a/app/plaYUVerApp.h b/app/plaYUVerApp.h index 95e4f22..45372c3 100644 --- a/app/plaYUVerApp.h +++ b/app/plaYUVerApp.h @@ -124,6 +124,7 @@ private: Void addStreamInfoToRecentList( PlaYUVerStreamInfo streamInfo ); Void updateRecentFileActions(); + Void checkRecentFileActions(); Void readSettings(); Void writeSettings(); diff --git a/lib/PlaYUVerDefs.h b/lib/PlaYUVerDefs.h index 26c6516..2976e92 100644 --- a/lib/PlaYUVerDefs.h +++ b/lib/PlaYUVerDefs.h @@ -26,6 +26,7 @@ #define __TYPEDEF_H__ #include +#include namespace plaYUVer { @@ -116,6 +117,13 @@ enum RGBcomponent COLOR_A, }; +inline std::string lowercase( const std::string& in ) +{ + std::string out; + transform( in.begin(), in.end(), std::back_inserter( out ), tolower ); + return out; +} + } // NAMESPACE #endif // __TYPEDEF_H__ diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 96f1aae..2d5d1c6 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -27,116 +27,73 @@ #include #include "LibMemory.h" #include "PlaYUVerStream.h" -#include -#include -#include #ifdef USE_FFMPEG #include "LibAvContextHandle.h" #endif +#ifdef USE_OPENCV +#include +#endif namespace plaYUVer { -enum PlaYUVerStreamInputFormats +std::vector PlaYUVerStream::supportedReadFormatsExt() { - INVALID_INPUT = -1, - YUVINPUT = 0, -#ifdef USE_FFMPEG - AVIINPUT, - MP4INPUT, - WMVINPUT, - PGMINPUT, - PNGINPUT, - BMPINPUT, - JPEGINPUT, -#endif - TOTAL_INPUT_FORMATS -}; - -QStringList PlaYUVerStream::supportedReadFormatsExt() -{ - QStringList formatsExt; - formatsExt << "yuv" - // Raw video -#ifdef USE_FFMPEG - << "avi" - // Audio video interleaved - << "mp4" - // MP4 - << "wmv" - // Windows media video - << "pgm" - << "png" - << "bmp" - << "jpg" -#endif - ; - //assert( formatsExt.size() == TOTAL_INPUT_FORMATS ); + std::vector formatsExt; + formatsExt.push_back( "yuv" ); + std::vector libAvFmt = LibAvContextHandle::supportedReadFormatsExt(); + formatsExt.insert( formatsExt.end(), libAvFmt.begin(), libAvFmt.end() ); return formatsExt; } -QStringList PlaYUVerStream::supportedReadFormatsName() +std::vector PlaYUVerStream::supportedReadFormatsName() { - QStringList formatsName; - formatsName << "Raw video" -#ifdef USE_FFMPEG - << "Audio video interleaved" - << "MPEG4" - << "Windows media video" - << "Portable Grayscale Map" - << "Portable Network Graphics" - << "Windows Bitmap" - << "Joint Photographic Experts Group" -#endif - ; - //assert( formatsName.size() == TOTAL_INPUT_FORMATS ); + std::vector formatsName; + formatsName.push_back( "Raw video" ); + std::vector libAvFmt = LibAvContextHandle::supportedReadFormatsName(); + formatsName.insert( formatsName.end(), libAvFmt.begin(), libAvFmt.end() ); return formatsName; } -enum PlaYUVerStreamOutputFormats +std::vector PlaYUVerStream::supportedWriteFormatsExt() { - INVALID_OUTPUT = -1, - YUVOUTPUT = 0, - TOTAL_OUTPUT_FORMATS -}; - -QStringList PlaYUVerStream::supportedWriteFormatsExt() -{ - QStringList formatsExt; - formatsExt << "yuv" // raw video - ; - assert( formatsExt.size() == TOTAL_OUTPUT_FORMATS ); + std::vector formatsExt; + formatsExt.push_back( "yuv" ); return formatsExt; } -QStringList PlaYUVerStream::supportedWriteFormatsName() +std::vector PlaYUVerStream::supportedWriteFormatsName() { - QStringList formatsName; - formatsName << "Raw video"; - assert( formatsName.size() == TOTAL_OUTPUT_FORMATS ); + std::vector formatsName; + formatsName.push_back( "Raw video" ); return formatsName; } -QStringList PlaYUVerStream::supportedSaveFormatsExt() +std::vector PlaYUVerStream::supportedSaveFormatsExt() { - QStringList formatsExt; - formatsExt << supportedWriteFormatsExt() - << "bmp" - << "jpeg" - << "png" // portable network graphics - ; - formatsExt.removeDuplicates(); + std::vector formatsExt; + std::vector writeExt = supportedWriteFormatsExt(); + formatsExt.insert( formatsExt.begin(), writeExt.begin(), writeExt.end() ); + formatsExt.push_back( "bmp" ); + formatsExt.push_back( "bmp" ); + formatsExt.push_back( "jpeg" ); + formatsExt.push_back( "png" ); + sort( formatsExt.begin(), formatsExt.end() ); + formatsExt.erase( unique( formatsExt.begin(), formatsExt.end() ), formatsExt.end() ); return formatsExt; } -QStringList PlaYUVerStream::supportedSaveFormatsName() +std::vector PlaYUVerStream::supportedSaveFormatsName() { - QStringList formatsName; - formatsName << supportedWriteFormatsName() - << "Windows Bitmap" - << "Joint Photographic Experts Group" - << "Portable Network Graphics"; - formatsName.removeDuplicates(); + std::vector formatsName; + std::vector writeName = supportedWriteFormatsName(); + formatsName.insert( formatsName.begin(), writeName.begin(), writeName.end() ); + formatsName.push_back( "Windows Bitmap" ); + formatsName.push_back( "Windows Bitmap" ); + formatsName.push_back( "Joint Photographic Experts Group" ); + formatsName.push_back( "Portable Network Graphics" ); + sort( formatsName.begin(), formatsName.end() ); + formatsName.erase( unique( formatsName.begin(), formatsName.end() ), formatsName.end() ); return formatsName; } @@ -199,15 +156,38 @@ PlaYUVerStream::~PlaYUVerStream() close(); } +Bool PlaYUVerStream::open( std::string filename, std::string resolution, std::string input_format_name, UInt frame_rate, Bool bInput ) +{ + UInt width; + UInt height; + Int input_format = -1; + + sscanf( resolution.c_str(), "%ux%u", &width, &height ); + if( width <= 0 || height <= 0 ) + { + return false; + } + for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ ) + { + if( PlaYUVerFrame::supportedPixelFormatListNames()[i] == input_format_name ) + { + input_format = i; + break; + } + } + if( width > 0 && height > 0 && input_format >= 0 ) + { + return open( filename, width, height, input_format, frame_rate, bInput ); + } + return false; +} + Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput ) { if( m_bInit ) { close(); } - - QString qtFilename = QString::fromStdString( filename ); - m_bInit = false; m_bIsInput = bInput; m_cFilename = filename; @@ -224,11 +204,15 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in { m_iFileFormat = INVALID_HANDLER; - QStringList formatsExt = PlaYUVerStream::supportedReadFormatsExt(); - QString currExt = QFileInfo( qtFilename ).suffix(); - if( formatsExt.contains( currExt ) ) + std::string currExt = filename.substr( filename.find_last_of( "." ) + 1 ); + for( UInt i = 0; i < PlaYUVerStream::supportedReadFormatsExt().size(); i++ ) { - m_iFileFormat = formatsExt.indexOf( currExt ); + if( PlaYUVerStream::supportedReadFormatsExt()[i] == currExt ) + { + m_iFileFormat = i; + m_cFormatName = PlaYUVerStream::supportedReadFormatsExt()[i]; + break; + } } if( m_iFileFormat == INVALID_HANDLER ) { @@ -236,15 +220,13 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in throw "Invalid file format"; return m_bInit; } - m_cFormatName = PlaYUVerStream::supportedReadFormatsExt().at( m_iFileFormat ).toUpper().toStdString(); - if( m_iFileFormat == YUVINPUT ) + if( m_cFormatName == "yuv" ) { m_uiStreamHandler = YUV_IO; } - #ifdef USE_FFMPEG - if( m_iFileFormat != YUVINPUT ) + else { m_uiStreamHandler = FFMPEG; } @@ -264,7 +246,7 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in } else { - m_iFileFormat = YUVOUTPUT; + m_iFileFormat = 0; m_uiStreamHandler = YUV_IO; m_uiFrameBufferSize = 1; } @@ -407,7 +389,7 @@ Void PlaYUVerStream::close() freeMem1D( m_pStreamBuffer ); if( m_pchFilename ) - delete [] m_pchFilename; + delete[] m_pchFilename; m_bLoadAll = false; m_bInit = false; @@ -574,32 +556,52 @@ Bool PlaYUVerStream::saveFrame( const std::string& filename ) Bool PlaYUVerStream::saveFrame( const std::string& filename, PlaYUVerFrame *saveFrame ) { - QString qtString = QString::fromStdString( filename ); - Int iFileFormat = INVALID_OUTPUT; + Int iFileFormat = INVALID_HANDLER; + std::string fmtExt; - QStringList formatsExt = PlaYUVerStream::supportedSaveFormatsExt(); - QString currExt = QFileInfo( qtString ).suffix(); - if( formatsExt.contains( currExt ) ) - { - iFileFormat = formatsExt.indexOf( currExt ); - } + //std::string currExt = QFileInfo( qtString ).suffix().toStdString(); + std::string currExt = filename.substr( filename.find_last_of( "." ) + 1 ); - if( iFileFormat < TOTAL_OUTPUT_FORMATS ) + for( UInt i = 0; i < PlaYUVerStream::supportedSaveFormatsExt().size(); i++ ) { - PlaYUVerStream auxFrameStream; - if( !auxFrameStream.open( filename, saveFrame->getWidth(), saveFrame->getHeight(), saveFrame->getPelFormat(), 1, false ) ) + if( PlaYUVerStream::supportedSaveFormatsExt()[i] == currExt ) { - return false; + iFileFormat = i; + fmtExt = PlaYUVerStream::supportedSaveFormatsExt()[i]; + break; } - auxFrameStream.writeFrame( saveFrame ); - auxFrameStream.close(); - return true; } - else + + if( iFileFormat != INVALID_HANDLER ) { - saveFrame->fillRGBBuffer(); - QImage qimg = QImage( saveFrame->getRGBBuffer(), saveFrame->getWidth(), saveFrame->getHeight(), QImage::Format_RGB32 ); - return qimg.save( qtString ); + if( fmtExt == "yuv" ) + { + PlaYUVerStream auxFrameStream; + if( !auxFrameStream.open( filename, saveFrame->getWidth(), saveFrame->getHeight(), saveFrame->getPelFormat(), 1, false ) ) + { + return false; + } + auxFrameStream.writeFrame( saveFrame ); + auxFrameStream.close(); + return true; + } +#if 0 + else + { + saveFrame->fillRGBBuffer(); + QImage qimg = QImage( saveFrame->getRGBBuffer(), saveFrame->getWidth(), saveFrame->getHeight(), QImage::Format_RGB32 ); + return qimg.save( qtString ); + } +#endif +#ifdef USE_OPENCV + else + { + cv::Mat* image; + saveFrame->getCvMat( (Void**)&image ); + return cv::imwrite( filename, *image ); + } + +#endif } return false; } diff --git a/lib/PlaYUVerStream.h b/lib/PlaYUVerStream.h index 968fd67..09245ef 100644 --- a/lib/PlaYUVerStream.h +++ b/lib/PlaYUVerStream.h @@ -29,7 +29,6 @@ #include #include #include -#include #include "PlaYUVerFrame.h" namespace plaYUVer @@ -95,12 +94,12 @@ private: public: - static QStringList supportedReadFormatsExt(); - static QStringList supportedReadFormatsName(); - static QStringList supportedWriteFormatsExt(); - static QStringList supportedWriteFormatsName(); - static QStringList supportedSaveFormatsExt(); - static QStringList supportedSaveFormatsName(); + static std::vector supportedReadFormatsExt(); + static std::vector supportedReadFormatsName(); + static std::vector supportedWriteFormatsExt(); + static std::vector supportedWriteFormatsName(); + static std::vector supportedSaveFormatsExt(); + static std::vector supportedSaveFormatsName(); static std::vector stdResolutionSizes(); @@ -116,6 +115,7 @@ public: END_OF_SEQ, }; + Bool open( std::string filename, std::string resolution, std::string input_format, UInt frame_rate, Bool bInput = true ); Bool open( std::string filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput = true ); Void close(); diff --git a/modules/AbsoluteFrameDifference.cpp b/modules/AbsoluteFrameDifference.cpp index a2e0ac9..8af3b45 100644 --- a/modules/AbsoluteFrameDifference.cpp +++ b/modules/AbsoluteFrameDifference.cpp @@ -23,6 +23,7 @@ */ #include "AbsoluteFrameDifference.h" +#include namespace plaYUVer { diff --git a/modules/FilterComponent.cpp b/modules/FilterComponent.cpp index cf53e0b..a030bdf 100644 --- a/modules/FilterComponent.cpp +++ b/modules/FilterComponent.cpp @@ -23,6 +23,7 @@ */ #include +#include #include "FilterComponent.h" namespace plaYUVer diff --git a/modules/PlaYUVerModuleFactory.h b/modules/PlaYUVerModuleFactory.h index 8d1f64f..c276508 100644 --- a/modules/PlaYUVerModuleFactory.h +++ b/modules/PlaYUVerModuleFactory.h @@ -26,6 +26,7 @@ #define __PLAYUVERMODULESFACTORY_H__ #include +#include #include "PlaYUVerModuleIf.h" namespace plaYUVer