From b0087b9e1f4c0b711ebbadcf903ed70eb3011a96 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 19 Feb 2015 15:46:03 +0000 Subject: [PATCH 1/9] Add setting for video zoom lock --- app/VideoHandle.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index 6dfaf02..58916fb 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() ); } From 8300e99935f44c13f9827d049e3abb77d3bea527 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 19 Feb 2015 15:46:16 +0000 Subject: [PATCH 2/9] Fix quality handle subwindow selection --- app/QualityHandle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From d0e711732029f21414a4bab28818d0287e87e128 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 19 Feb 2015 15:52:22 +0000 Subject: [PATCH 3/9] Zoom to fit and tile subwindows when open them at startup --- app/plaYUVerApp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index d6335ce..f397ba9 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(); } } From 75a12a43ff54a32f6e22a4b45f36dc72fa509993 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Feb 2015 14:34:35 +0000 Subject: [PATCH 4/9] Minor changes in CMakeLists.txt --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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() From 60bc2953ed82b9b7846c0cbf9313641e36a86347 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Feb 2015 14:44:04 +0000 Subject: [PATCH 5/9] Add function to clean recent file that do not exist --- app/plaYUVerApp.cpp | 15 +++++++++++++++ app/plaYUVerApp.h | 1 + 2 files changed, 16 insertions(+) diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index f397ba9..3c74688 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -846,6 +846,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 +876,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(); From e751c5469ecb42adaa3f2062071dae16094d9916 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Feb 2015 15:26:42 +0000 Subject: [PATCH 6/9] Remove dependencies to Qt libs from PlaYUVStream. Only save frame depends on QString and QImage --- app/ConfigureFormatDialog.cpp | 2 +- app/ModulesHandle.cpp | 13 +- app/plaYUVerApp.cpp | 25 ++-- lib/PlaYUVerStream.cpp | 189 ++++++++++++---------------- lib/PlaYUVerStream.h | 13 +- modules/AbsoluteFrameDifference.cpp | 1 + modules/FilterComponent.cpp | 1 + modules/PlaYUVerModuleFactory.h | 1 + 8 files changed, 106 insertions(+), 139 deletions(-) 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/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index 3c74688..2e003bf 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -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 ) diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 96f1aae..7acda98 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -27,9 +27,8 @@ #include #include "LibMemory.h" #include "PlaYUVerStream.h" -#include #include -#include +#include #ifdef USE_FFMPEG #include "LibAvContextHandle.h" #endif @@ -37,106 +36,63 @@ 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; } @@ -205,9 +161,6 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in { close(); } - - QString qtFilename = QString::fromStdString( filename ); - m_bInit = false; m_bIsInput = bInput; m_cFilename = filename; @@ -224,11 +177,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 +193,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 +219,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 +362,7 @@ Void PlaYUVerStream::close() freeMem1D( m_pStreamBuffer ); if( m_pchFilename ) - delete [] m_pchFilename; + delete[] m_pchFilename; m_bLoadAll = false; m_bInit = false; @@ -575,31 +530,41 @@ 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; + } + else + { + saveFrame->fillRGBBuffer(); + QImage qimg = QImage( saveFrame->getRGBBuffer(), saveFrame->getWidth(), saveFrame->getHeight(), QImage::Format_RGB32 ); + return qimg.save( qtString ); + } } return false; } diff --git a/lib/PlaYUVerStream.h b/lib/PlaYUVerStream.h index 968fd67..565d005 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(); 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 From 21859b276f13d4a81c56c7b833abe16c68201a46 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Feb 2015 20:23:59 +0000 Subject: [PATCH 7/9] Add new open stream function --- lib/PlaYUVerStream.cpp | 26 ++++++++++++++++++++++++++ lib/PlaYUVerStream.h | 1 + 2 files changed, 27 insertions(+) diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 7acda98..80b7529 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -155,6 +155,32 @@ 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 ) diff --git a/lib/PlaYUVerStream.h b/lib/PlaYUVerStream.h index 565d005..09245ef 100644 --- a/lib/PlaYUVerStream.h +++ b/lib/PlaYUVerStream.h @@ -115,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(); From 77a6247addafc460260053ee74050fec02ce7f44 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Feb 2015 20:44:35 +0000 Subject: [PATCH 8/9] Use opencv to save images --- lib/PlaYUVerStream.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 80b7529..2d5d1c6 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -27,11 +27,12 @@ #include #include "LibMemory.h" #include "PlaYUVerStream.h" -#include -#include #ifdef USE_FFMPEG #include "LibAvContextHandle.h" #endif +#ifdef USE_OPENCV +#include +#endif namespace plaYUVer { @@ -555,7 +556,6 @@ Bool PlaYUVerStream::saveFrame( const std::string& filename ) Bool PlaYUVerStream::saveFrame( const std::string& filename, PlaYUVerFrame *saveFrame ) { - QString qtString = QString::fromStdString( filename ); Int iFileFormat = INVALID_HANDLER; std::string fmtExt; @@ -585,12 +585,23 @@ Bool PlaYUVerStream::saveFrame( const std::string& filename, PlaYUVerFrame *save 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; } From 60e3d37d02d586b8bc1c489b41f4f482190653e6 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Feb 2015 21:34:32 +0000 Subject: [PATCH 9/9] Add function to convert a string to lowercase --- lib/PlaYUVerDefs.h | 8 ++++++++ 1 file changed, 8 insertions(+) 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__