From b6185d9154709ba73728e3293b83166a49aa2baf Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 17 Jun 2014 15:28:48 +0100 Subject: [PATCH 01/15] add zip package generator --- cmake/Install.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Install.cmake b/cmake/Install.cmake index b06a425..9248255 100644 --- a/cmake/Install.cmake +++ b/cmake/Install.cmake @@ -49,7 +49,7 @@ ENDIF() ###################################################################################### # Create deb package ###################################################################################### -SET(CPACK_GENERATOR "DEB") +SET(CPACK_GENERATOR "DEB;ZIP") SET(CPACK_PACKAGE_NAME ${PROJECT_NAME}) SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "plaYUVer is an open-source QT based raw video player") From 44c3f505114eb73fdf5c79ab2eae5452c5c3b82a Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 16 Jun 2014 22:47:30 +0100 Subject: [PATCH 02/15] Add reload and reload all functions --- source/app/plaYUVerApp.cpp | 45 +++++++++++++++++++++++++++++++------- source/app/plaYUVerApp.h | 4 ++++ 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index 5ce8b56..074abe8 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -220,6 +220,22 @@ Void plaYUVerApp::format() m_pcCurrentSubWindow->loadFile( m_pcCurrentSubWindow->currentFile(), true ); } +Void plaYUVerApp::reload() +{ + if( m_pcCurrentSubWindow ) + m_pcCurrentSubWindow->loadFile( m_pcCurrentSubWindow->currentFile(), false ); +} + +Void plaYUVerApp::reloadAll() +{ + SubWindowHandle *subWindow; + for( Int i = 0; i < mdiArea->subWindowList().size(); i++ ) + { + subWindow = qobject_cast( mdiArea->subWindowList().at( i ) ); + subWindow->loadFile( m_pcCurrentSubWindow->currentFile(), false ); + } +} + Void plaYUVerApp::loadAll() { if( m_pcCurrentSubWindow ) @@ -873,17 +889,27 @@ Void plaYUVerApp::createActions() m_arrayActions[SAVE_ACT]->setStatusTip( tr( "Save current frame" ) ); connect( m_arrayActions[SAVE_ACT], SIGNAL( triggered() ), this, SLOT( save() ) ); - m_arrayActions[LOAD_ALL_ACT] = new QAction( tr( "&Load All" ), this ); - //m_arrayActions[LOAD_ALL_ACT]->setIcon( QIcon( ":/images/configuredialog.png" ) ); - m_arrayActions[LOAD_ALL_ACT]->setStatusTip( tr( "Load sequence into memory (caution)" ) ); - connect( m_arrayActions[LOAD_ALL_ACT], SIGNAL( triggered() ), this, SLOT( loadAll() ) ); - m_arrayActions[FORMAT_ACT] = new QAction( tr( "&Format" ), this ); m_arrayActions[FORMAT_ACT]->setIcon( QIcon( ":/images/configuredialog.png" ) ); m_arrayActions[FORMAT_ACT]->setStatusTip( tr( "Open format dialog" ) ); connect( m_arrayActions[FORMAT_ACT], SIGNAL( triggered() ), this, SLOT( format() ) ); - m_arrayActions[CLOSE_ACT] = new QAction( tr( "Cl&ose" ), this ); + m_arrayActions[RELOAD_ACT] = new QAction( tr( "&Reload" ), this ); + m_arrayActions[RELOAD_ACT]->setIcon( style()->standardIcon( QStyle::SP_BrowserReload ) ); + m_arrayActions[RELOAD_ACT]->setStatusTip( tr( "Reload current sequence" ) ); + connect( m_arrayActions[RELOAD_ACT], SIGNAL( triggered() ), this, SLOT( reload() ) ); + + m_arrayActions[RELOAD_ALL_ACT] = new QAction( tr( "Reload All" ), this ); + //m_arrayActions[RELOAD_ACT]->setIcon( QIcon( ":/images/configuredialog.png" ) ); + m_arrayActions[RELOAD_ALL_ACT]->setStatusTip( tr( "Reload all sequences" ) ); + connect( m_arrayActions[RELOAD_ALL_ACT], SIGNAL( triggered() ), this, SLOT( reload() ) ); + + m_arrayActions[LOAD_ALL_ACT] = new QAction( tr( "Preload" ), this ); + //m_arrayActions[LOAD_ALL_ACT]->setIcon( QIcon( ":/images/configuredialog.png" ) ); + m_arrayActions[LOAD_ALL_ACT]->setStatusTip( tr( "Load sequence into memory (caution)" ) ); + connect( m_arrayActions[LOAD_ALL_ACT], SIGNAL( triggered() ), this, SLOT( loadAll() ) ); + + m_arrayActions[CLOSE_ACT] = new QAction( tr( "&Close" ), this ); // m_arrayActions[CLOSE_ACT]->setIcon( QIcon( ":/images/close.png" ) ); m_arrayActions[CLOSE_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogCloseButton ) ); @@ -997,12 +1023,12 @@ Void plaYUVerApp::createActions() // ------------ Window ------------ - m_arrayActions[TILE_WINDOWS_ACT] = new QAction( tr( "&Tile" ), this ); + m_arrayActions[TILE_WINDOWS_ACT] = new QAction( tr( "Tile" ), this ); m_arrayActions[TILE_WINDOWS_ACT]->setIcon( QIcon( ":images/windowstile.png" ) ); m_arrayActions[TILE_WINDOWS_ACT]->setStatusTip( tr( "Tile the windows" ) ); connect( m_arrayActions[TILE_WINDOWS_ACT], SIGNAL( triggered() ), mdiArea, SLOT( tileSubWindows() ) ); - m_arrayActions[CASCADE_WINDOWS_ACT] = new QAction( tr( "&Cascade" ), this ); + m_arrayActions[CASCADE_WINDOWS_ACT] = new QAction( tr( "Cascade" ), this ); m_arrayActions[CASCADE_WINDOWS_ACT]->setIcon( QIcon( ":images/windowscascade.png" ) ); m_arrayActions[CASCADE_WINDOWS_ACT]->setStatusTip( tr( "Cascade the windows" ) ); connect( m_arrayActions[CASCADE_WINDOWS_ACT], SIGNAL( triggered() ), mdiArea, SLOT( cascadeSubWindows() ) ); @@ -1049,6 +1075,8 @@ Void plaYUVerApp::createMenus() m_arrayMenu[FILE_MENU]->addAction( m_arrayActions[SAVE_ACT] ); m_arrayMenu[FILE_MENU]->addSeparator(); m_arrayMenu[FILE_MENU]->addAction( m_arrayActions[FORMAT_ACT] ); + m_arrayMenu[FILE_MENU]->addAction( m_arrayActions[RELOAD_ACT] ); + m_arrayMenu[FILE_MENU]->addAction( m_arrayActions[RELOAD_ALL_ACT] ); m_arrayMenu[FILE_MENU]->addAction( m_arrayActions[LOAD_ALL_ACT] ); m_arrayMenu[FILE_MENU]->addSeparator(); m_arrayMenu[FILE_MENU]->addAction( m_arrayActions[CLOSE_ACT] ); @@ -1112,6 +1140,7 @@ Void plaYUVerApp::createToolBars() m_arrayToolBars[FILE_TOOLBAR]->addAction( m_arrayActions[OPEN_ACT] ); m_arrayToolBars[FILE_TOOLBAR]->addAction( m_arrayActions[SAVE_ACT] ); m_arrayToolBars[FILE_TOOLBAR]->addAction( m_arrayActions[FORMAT_ACT] ); + m_arrayToolBars[FILE_TOOLBAR]->addAction( m_arrayActions[RELOAD_ACT] ); m_arrayToolBars[FILE_TOOLBAR]->addAction( m_arrayActions[CLOSE_ACT] ); m_arrayToolBars[FILE_TOOLBAR]->setMovable( false ); diff --git a/source/app/plaYUVerApp.h b/source/app/plaYUVerApp.h index 26c2c4a..004e780 100644 --- a/source/app/plaYUVerApp.h +++ b/source/app/plaYUVerApp.h @@ -59,6 +59,8 @@ private Q_SLOTS: void open(); void save(); void format(); + void reload(); + void reloadAll(); void loadAll(); void closeActiveWindow(); void closeAll(); @@ -198,6 +200,8 @@ private: OPEN_ACT = 0, SAVE_ACT, FORMAT_ACT, + RELOAD_ACT, + RELOAD_ALL_ACT, LOAD_ALL_ACT, CLOSE_ACT, CLOSEALL_ACT, From c8855b8fdc35ea95698bdec42a9ee63820cbe03a Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 16 Jun 2014 22:59:14 +0100 Subject: [PATCH 03/15] keep same frame num when reloading --- source/app/SubWindowHandle.cpp | 7 +++++++ source/app/SubWindowHandle.h | 1 + source/app/plaYUVerApp.cpp | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source/app/SubWindowHandle.cpp b/source/app/SubWindowHandle.cpp index d65b706..def455a 100644 --- a/source/app/SubWindowHandle.cpp +++ b/source/app/SubWindowHandle.cpp @@ -73,6 +73,13 @@ SubWindowHandle::~SubWindowHandle() delete m_pCurrStream; } +Void SubWindowHandle::reloadFile() +{ + Int currFrameNum = m_pCurrStream->getCurrFrameNum(); + loadFile( m_cCurrFileName, false ); + seekAbsoluteEvent( currFrameNum ); +} + Bool SubWindowHandle::loadFile( const QString &rcFilename, Bool bForceDialog ) { UInt Width = 0, Height = 0, FrameRate = 30; diff --git a/source/app/SubWindowHandle.h b/source/app/SubWindowHandle.h index 8a78ed8..d9c8c10 100644 --- a/source/app/SubWindowHandle.h +++ b/source/app/SubWindowHandle.h @@ -67,6 +67,7 @@ public: Bool mayClose(); Bool loadFile( const QString &rcFilename, Bool bForceDialog = false ); + Void reloadFile(); Bool save(); Void play(); diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index 074abe8..09d9e99 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -223,7 +223,7 @@ Void plaYUVerApp::format() Void plaYUVerApp::reload() { if( m_pcCurrentSubWindow ) - m_pcCurrentSubWindow->loadFile( m_pcCurrentSubWindow->currentFile(), false ); + m_pcCurrentSubWindow->reloadFile(); } Void plaYUVerApp::reloadAll() @@ -232,7 +232,7 @@ Void plaYUVerApp::reloadAll() for( Int i = 0; i < mdiArea->subWindowList().size(); i++ ) { subWindow = qobject_cast( mdiArea->subWindowList().at( i ) ); - subWindow->loadFile( m_pcCurrentSubWindow->currentFile(), false ); + subWindow->reloadFile(); } } From 703341cc487a678d88fe774eb9b3253a5508a46e Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 16 Jun 2014 22:47:30 +0100 Subject: [PATCH 04/15] Add reload and reload all functions --- source/app/plaYUVerApp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index 09d9e99..8da67f2 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -224,6 +224,7 @@ Void plaYUVerApp::reload() { if( m_pcCurrentSubWindow ) m_pcCurrentSubWindow->reloadFile(); + } Void plaYUVerApp::reloadAll() From 5c0d265f62f5d381025f7248ca87370f93dc89d4 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 16 Jun 2014 22:59:14 +0100 Subject: [PATCH 05/15] keep same frame num when reloading --- source/app/plaYUVerApp.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index 8da67f2..09d9e99 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -224,7 +224,6 @@ Void plaYUVerApp::reload() { if( m_pcCurrentSubWindow ) m_pcCurrentSubWindow->reloadFile(); - } Void plaYUVerApp::reloadAll() From 98010928b5cfb1a7db500532222c2e4114b2b4a6 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 17 Jun 2014 16:27:08 +0100 Subject: [PATCH 06/15] Improve cmake cpack install on windows --- cmake/Install.cmake | 52 +++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/cmake/Install.cmake b/cmake/Install.cmake index 9248255..640a812 100644 --- a/cmake/Install.cmake +++ b/cmake/Install.cmake @@ -49,43 +49,59 @@ ENDIF() ###################################################################################### # Create deb package ###################################################################################### -SET(CPACK_GENERATOR "DEB;ZIP") SET(CPACK_PACKAGE_NAME ${PROJECT_NAME}) -SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "plaYUVer is an open-source QT based raw video player") -SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Joao Carreira (jfmcarreira@gmail.com), Luis Lucas (luisfrlucas@gmail.com)") SET(CPACK_PACKAGE_CONTACT "Joao Carreira (jfmcarreira@gmail.com), Luis Lucas (luisfrlucas@gmail.com)") - SET(CPACK_PACKAGE_VERSION_MAJOR ${PLAYUVER_VERSION_MAJOR}) SET(CPACK_PACKAGE_VERSION_MINOR ${PLAYUVER_VERSION_MINOR}) SET(CPACK_PACKAGE_VERSION_PATCH ${PLAYUVER_VERSION_PATH}) SET(CPACK_PACKAGE_VERSION ${PLAYUVER_VERSION}) -SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") -SET(CPACK_DEBIAN_PACKAGE_DEPENDS "") + +IF( UNIX ) + + SET(CPACK_GENERATOR "DEB;ZIP") + + SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "plaYUVer is an open-source QT based raw video player") + SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Joao Carreira (jfmcarreira@gmail.com), Luis Lucas (luisfrlucas@gmail.com)") + SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "") + IF( USE_QT4 ) + LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libqtcore4 (>= 4:4.8.5~), libqtgui4 (>= 4:4.8.5~)" ) + ELSE() + LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5core5a, libqt5gui5, libqt5widgets5") + ENDIF() + IF( USE_FFMPEG ) + LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS ",") + LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libavformat53 (>= 6:0.8.10~), libcodec53 (>= 6:0.8.3-1~), libavutil51 (>= 6:0.8.3-1~)") + ENDIF() + + EXECUTE_PROCESS(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE DAY) + string(STRIP ${DAY} DAY) + +ENDIF() + +IF( WIN32 ) + + SET(CPACK_GENERATOR "ZIP") + + EXECUTE_PROCESS(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${DAY}) + string(REGEX REPLACE "(..)/(..)/..(..).*" "\\1/\\2/\\3" ${DAY} ${${DAY}}) + +ENDIF() + IF( USE_QT4 ) - LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libqtcore4 (>= 4:4.8.5~), libqtgui4 (>= 4:4.8.5~)" ) SET( APPEND_VERSION "${APPEND_VERSION}_wQT4" ) -ELSE() - LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5core5a, libqt5gui5, libqt5widgets5") +ELSE() SET( APPEND_VERSION "${APPEND_VERSION}_wQT5" ) ENDIF() - IF( USE_FFMPEG ) - LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS ",") - LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libavformat53 (>= 6:0.8.10~), libcodec53 (>= 6:0.8.3-1~), libavutil51 (>= 6:0.8.3-1~)") SET( APPEND_VERSION "${APPEND_VERSION}_wFFmpeg" ) ENDIF() - IF( USE_OPENCV ) SET( APPEND_VERSION "${APPEND_VERSION}_wOpenCV" ) ENDIF() -IF(UNIX) - EXECUTE_PROCESS(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE DAY) - string(STRIP ${DAY} DAY) -ENDIF(UNIX) - SET( CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}${APPEND_VERSION}-Linux-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}" ) INCLUDE(CPack) From 97812bc0346c49ffba3403fec86fdf353e0761a4 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 17 Jun 2014 16:29:56 +0100 Subject: [PATCH 07/15] remove day information --- cmake/Install.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/Install.cmake b/cmake/Install.cmake index 640a812..5af6b26 100644 --- a/cmake/Install.cmake +++ b/cmake/Install.cmake @@ -76,8 +76,8 @@ IF( UNIX ) LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libavformat53 (>= 6:0.8.10~), libcodec53 (>= 6:0.8.3-1~), libavutil51 (>= 6:0.8.3-1~)") ENDIF() - EXECUTE_PROCESS(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE DAY) - string(STRIP ${DAY} DAY) + #EXECUTE_PROCESS(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE DAY) + #string(STRIP ${DAY} DAY) ENDIF() @@ -85,8 +85,8 @@ IF( WIN32 ) SET(CPACK_GENERATOR "ZIP") - EXECUTE_PROCESS(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${DAY}) - string(REGEX REPLACE "(..)/(..)/..(..).*" "\\1/\\2/\\3" ${DAY} ${${DAY}}) + #EXECUTE_PROCESS(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${DAY}) + #string(REGEX REPLACE "(..)/(..)/..(..).*" "\\1/\\2/\\3" ${DAY} ${${DAY}}) ENDIF() From 8857b6d2f4864deb08b50bf97e93f887e82ca167 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 17 Jun 2014 16:31:32 +0100 Subject: [PATCH 08/15] add missing files --- source/lib/PlaYUVerStream.cpp | 491 ++++++++++++++++++++++++++++++++++ source/lib/PlaYUVerStream.h | 188 +++++++++++++ 2 files changed, 679 insertions(+) create mode 100644 source/lib/PlaYUVerStream.cpp create mode 100644 source/lib/PlaYUVerStream.h diff --git a/source/lib/PlaYUVerStream.cpp b/source/lib/PlaYUVerStream.cpp new file mode 100644 index 0000000..4f65926 --- /dev/null +++ b/source/lib/PlaYUVerStream.cpp @@ -0,0 +1,491 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014 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 PlaYUVerStream.cpp + * \brief Input stream handling + */ + +#include "config.h" + +#include +#include "PlaYUVerStream.h" +#ifdef USE_FFMPEG +#include "LibAvContextHandle.h" +#include "LibMemory.h" +#endif + +namespace plaYUVer +{ + +InputStream::InputStream() +{ + m_bInit = false; + m_bLoadAll = false; + m_iErrorStatus = 0; + + m_pFile = NULL; + m_uiWidth = 0; + m_uiHeight = 0; + m_uiTotalFrameNum = 0; + m_iCurrFrameNum = -1; + m_iPixelFormat = -1; + m_uiFrameRate = 30; + m_iFileFormat = INVALID; + m_pInputBuffer = NULL; + m_cFilename = QString( "" ); + m_cStreamInformationString = QString( "" ); + m_pcCurrFrame = NULL; + m_pcNextFrame = NULL; + m_ppcFrameBuffer = NULL; + m_uiFrameBufferSize = 2; + m_uiFrameBufferIndex = 0; + m_uiAveragePlayInterval = 0; +} + +InputStream::~InputStream() +{ + close(); +} + +QString InputStream::supportedReadFormats() +{ + QString formats; + formats = "*.yuv " // Raw video +#ifdef USE_FFMPEG + "*.avi " // Audio video interleaved + "*.mp4 " + "*.wmv "// Windows media video +#endif + ; + return formats; +} + +QString InputStream::supportedWriteFormats() +{ + QString formats; + formats = "*.bmp " // Windows Bitmap + "*.jpg "// Joint Photographic Experts Group + "*.jpeg "// Joint Photographic Experts Group + "*.png "// Portable Network Graphics + ; + return formats; +} + +QStringList InputStream::supportedReadFormatsList() +{ + QStringList formats; + formats << "Raw video (*.yuv)" +#ifdef USE_FFMPEG + << "Audio video interleaved (*.avi)" + << "MPEG4 (*.mp4)" + << "Windows media video (*.wmv)" +#endif + ; + return formats; +} + +QStringList InputStream::supportedWriteFormatsList() +{ + QStringList formats; + formats << "Windows Bitmap (*.bmp)" + << "Joint Photographic Experts Group (*.jpg *.jpeg)" + << "Portable Network Graphics (*.png)"; + return formats; +} + +Bool InputStream::open( QString filename, UInt width, UInt height, Int input_format, UInt frame_rate ) +{ + Bool avStatus = false; + + if( m_bInit ) + { + close(); + } + + m_bInit = false; + m_cFilename = filename; + m_uiWidth = width; + m_uiHeight = height; + m_uiFrameRate = frame_rate; + + m_iFileFormat = YUVFormat; + m_iPixelFormat = input_format; + +#ifdef USE_FFMPEG + if( QFileInfo( filename ).suffix().compare( QString( "yuv" ) ) ) + { + avStatus = m_cLibAvContext.initAvFormat( m_cFilename.toLocal8Bit().data(), m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate, m_uiTotalFrameNum ); + m_cFormatName = QFileInfo( filename ).completeSuffix().toUpper(); + m_cCodedName = QString::fromUtf8( m_cLibAvContext.getCodecName() ).toUpper(); + } +#endif + + if( m_uiWidth <= 0 || m_uiHeight <= 0 || m_iPixelFormat < 0 ) + { + close(); + return m_bInit; + } + + m_uiFrameBufferSize = 2; + getMem1D( &m_ppcFrameBuffer, m_uiFrameBufferSize ); + for( UInt i = 0; i < m_uiFrameBufferSize; i++ ) + { + m_ppcFrameBuffer[i] = new PlaYUVerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat ); + if( !m_ppcFrameBuffer[i] ) + { + close(); + return m_bInit; + } + } + m_uiFrameBufferIndex = 0; + m_pcCurrFrame = m_ppcFrameBuffer[m_uiFrameBufferIndex]; + + UInt64 frame_bytes_input = m_pcCurrFrame->getBytesPerFrame(); + + if( !avStatus ) + { + m_pFile = NULL; + Char *filename = m_cFilename.toLocal8Bit().data(); + m_pFile = fopen( filename, "rb" ); + if( m_pFile == NULL ) + { + close(); + return m_bInit; + } + fseek( m_pFile, 0, SEEK_END ); + m_uiTotalFrameNum = ftell( m_pFile ) / ( frame_bytes_input ); + fseek( m_pFile, 0, SEEK_SET ); + m_cFormatName = QString::fromUtf8( "YUV" ); + m_cCodedName = QString::fromUtf8( "Raw Video" ); + } + if( !getMem1D( &m_pInputBuffer, m_pcCurrFrame->getBytesPerFrame() ) ) + { + close(); + return m_bInit; + } + + m_cStreamInformationString = QString( "[" ); + m_cStreamInformationString.append( m_cFormatName ); + m_cStreamInformationString.append( QString( " / " ) ); + m_cStreamInformationString.append( m_cCodedName ); + m_cStreamInformationString.append( QString( " / " ) ); + m_cStreamInformationString.append( PlaYUVerFrame::supportedPixelFormatList().at( m_iPixelFormat ) ); + m_cStreamInformationString.append( "] " ); + m_cStreamInformationString.append( QFileInfo( m_cFilename ).fileName() ); + + m_iCurrFrameNum = -1; + seekInput( 0 ); + //loadAll(); + + m_cTimer.start(); + m_uiAveragePlayInterval = 0; + + m_bInit = true; + return m_bInit; +} + +Void InputStream::close() +{ + if( m_pFile ) + fclose( m_pFile ); + +#ifdef USE_FFMPEG + m_cLibAvContext.closeAvFormat(); +#endif + + if( m_ppcFrameBuffer ) + { + for( UInt i = 0; i < m_uiFrameBufferSize; i++ ) + { + if( m_ppcFrameBuffer[i] ) + delete m_ppcFrameBuffer[i]; + m_ppcFrameBuffer[i] = NULL; + } + freeMem1D( m_ppcFrameBuffer ); + m_ppcFrameBuffer = NULL; + } + + if( m_pInputBuffer ) + freeMem1D( m_pInputBuffer ); + + qDebug( ) << "Frame read time: " + << QString::number( 1000 / ( m_uiAveragePlayInterval + 1 ) ) + << " fps"; + + m_bLoadAll = false; + m_bInit = false; +} + +Void InputStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ) +{ + if( m_bInit ) + { + rWidth = m_uiWidth; + rHeight = m_uiHeight; + rInputFormat = m_iPixelFormat; + rFrameRate = m_uiFrameRate; + } + else + { + rWidth = 0; + rHeight = 0; + rInputFormat = -1; + rFrameRate = 30; + } +} + +Bool InputStream::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ) +{ + Bool bRet = false; + QString fileExtension = QFileInfo( filename ).suffix(); + if( !fileExtension.compare( "yuv" ) ) + { + bRet = true; + // Guess resolution - match %dx%d +#if( QT_VERSION_PLAYUVER == 5 ) + QRegularExpressionMatch resolutionMatch = QRegularExpression( "_\\d*x\\d*_" ).match( filename ); + if( resolutionMatch.hasMatch() ) + { + QString resolutionString = resolutionMatch.captured( 0 ); + if( resolutionString.startsWith( "_" ) && resolutionString.endsWith( "_" ) ) + { + resolutionString.remove( "_" ); + QStringList resolutionArgs = resolutionString.split( "x" ); + qDebug( ) << "Found resolution = " + << resolutionArgs; + if( resolutionArgs.size() == 2 ) + { + rWidth = resolutionArgs.at( 0 ).toUInt(); + rHeight = resolutionArgs.at( 1 ).toUInt(); + } + } + } +#endif + // Guess pixel format + QStringList formats_list = PlaYUVerFrame::supportedPixelFormatList(); + for( Int i = 0; i < formats_list.size(); i++ ) + { + if( filename.contains( formats_list.at( i ), Qt::CaseInsensitive ) ) + { + rInputFormat = i; + break; + } + } + if( rWidth > 0 && rHeight > 0 && rInputFormat >= 0 ) + bRet = false; + } + return bRet; +} + +Void InputStream::loadAll() +{ + if( m_bLoadAll ) + return; + + if( m_ppcFrameBuffer ) + { + for( UInt i = 0; i < m_uiFrameBufferSize; i++ ) + { + if( m_ppcFrameBuffer[i] ) + delete m_ppcFrameBuffer[i]; + m_ppcFrameBuffer[i] = NULL; + } + freeMem1D( m_ppcFrameBuffer ); + m_ppcFrameBuffer = NULL; + } + m_uiFrameBufferSize = m_uiTotalFrameNum; + getMem1D( &m_ppcFrameBuffer, m_uiFrameBufferSize ); + for( UInt i = 0; i < m_uiFrameBufferSize; i++ ) + { + m_ppcFrameBuffer[i] = new PlaYUVerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat ); + if( !m_ppcFrameBuffer[i] ) + { + close(); + } + } + m_uiFrameBufferIndex = 0; + m_pcCurrFrame = m_ppcFrameBuffer[m_uiFrameBufferIndex]; + m_iCurrFrameNum = -1; + seekInput( 0 ); + for( UInt i = 0; i < m_uiFrameBufferSize-1; i++ ) + { + readNextFrame(); + setNextFrame(); + } + m_bLoadAll = true; + seekInput( 0 ); +} + +Void InputStream::getDuration( Int* duration_array ) +{ + Int hours, mins, secs; +#ifdef USE_FFMPEG + if( m_cLibAvContext.getStatus() ) + { + secs = m_cLibAvContext.getStreamDuration(); + } + else +#endif + { + secs = m_uiTotalFrameNum / m_uiFrameRate; + } + mins = secs / 60; + secs %= 60; + hours = mins / 60; + mins %= 60; + *duration_array++ = hours; + *duration_array++ = mins; + *duration_array++ = secs; +} + +Void InputStream::readNextFrame() +{ + UInt64 bytes_read = 0; + //m_cTimer.restart(); + + if( m_iCurrFrameNum + 1 >= (Int64)m_uiTotalFrameNum ) + { + m_iErrorStatus = LAST_FRAME; + m_pcNextFrame = NULL; + return; + } + + if( m_bLoadAll ) + { + return; + } + +#ifdef USE_FFMPEG + if( m_cLibAvContext.getStatus() ) + { + m_cLibAvContext.decodeAvFormat(); + m_pcNextFrame->FrameFromBuffer( m_cLibAvContext.video_dst_data[0], m_iPixelFormat ); + } + else +#endif + { + UInt64 frame_bytes_input = m_pcNextFrame->getBytesPerFrame(); + bytes_read = fread( m_pInputBuffer, sizeof(Pel), frame_bytes_input, m_pFile ); + if( bytes_read != frame_bytes_input ) + { + m_iErrorStatus = READING; + qDebug( ) << " Reading error !!!" + << endl; + return; + } + m_pcNextFrame->FrameFromBuffer( m_pInputBuffer, m_iPixelFormat ); + } + //Int time = m_cTimer.elapsed(); + //m_uiAveragePlayInterval = ( m_uiAveragePlayInterval + time) / 2; + m_pcNextFrame->FrametoRGB8(); + return; +} + +Bool InputStream::writeFrame( const QString& filename ) +{ + //m_pcCurrFrame->getQimage().save( filename ); + return true; +} + +Void InputStream::setNextFrame() +{ + if( m_pcNextFrame ) + { + m_pcCurrFrame = m_pcNextFrame; + m_iCurrFrameNum++; + m_uiFrameBufferIndex++; + if( m_uiFrameBufferIndex == m_uiFrameBufferSize ) + { + m_uiFrameBufferIndex = 0; + } + m_pcNextFrame = m_ppcFrameBuffer[m_uiFrameBufferIndex]; + } + else + { + m_iErrorStatus = END_OF_SEQ; + seekInput( 0 ); + } +} + +PlaYUVerFrame* InputStream::getCurrFrame( PlaYUVerFrame *pyuv_image ) +{ + if( pyuv_image == NULL ) + pyuv_image = new PlaYUVerFrame( m_pcCurrFrame ); + else + pyuv_image->copyFrom( m_pcCurrFrame ); + return pyuv_image; +} + +PlaYUVerFrame* InputStream::getCurrFrame() +{ + return m_pcCurrFrame; +} + +Void InputStream::seekInput( UInt64 new_frame_num ) +{ + if( !m_pFile || new_frame_num < 0 || new_frame_num >= m_uiTotalFrameNum || (Int64)new_frame_num == m_iCurrFrameNum ) + return; + + m_iCurrFrameNum = new_frame_num - 1; + + if( m_bLoadAll ) + { + m_uiFrameBufferIndex = new_frame_num; + m_pcNextFrame = m_ppcFrameBuffer[m_uiFrameBufferIndex]; + setNextFrame(); + return; + } +#ifdef USE_FFMPEG + if( m_cLibAvContext.getStatus() ) + { + m_cLibAvContext.seekAvFormat( new_frame_num ); + } + else +#endif + { + UInt64 frame_bytes_input = m_ppcFrameBuffer[0]->getBytesPerFrame(); + UInt64 nbytes_seek = frame_bytes_input * new_frame_num; + fseek( m_pFile, nbytes_seek, SEEK_SET ); + } + m_uiFrameBufferIndex = 0; + m_pcCurrFrame = m_pcNextFrame = m_ppcFrameBuffer[m_uiFrameBufferIndex]; + + readNextFrame(); + setNextFrame(); + if( m_uiTotalFrameNum > 1 ) + readNextFrame(); +} + +Bool InputStream::checkErrors( Int error_type ) +{ + if( m_iErrorStatus == error_type ) + { + m_iErrorStatus = NO_STREAM_ERROR; + return true; + } + if( m_iErrorStatus == error_type ) + { + m_iErrorStatus = NO_STREAM_ERROR; + return true; + } + return false; +} + +} // NAMESPACE diff --git a/source/lib/PlaYUVerStream.h b/source/lib/PlaYUVerStream.h new file mode 100644 index 0000000..5a3e8c1 --- /dev/null +++ b/source/lib/PlaYUVerStream.h @@ -0,0 +1,188 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014 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 PlaYUVerStream.h + * \brief Input stream handling + */ + +#ifndef __INPUTSTREAM_H__ +#define __INPUTSTREAM_H__ + +#ifdef PLAYUVER +#include "config.h" +#endif +#include "PlaYUVerDefs.h" +#include +#include +#include +#ifdef USE_OPENCV +#include +#endif + +#ifdef USE_FFMPEG +#include "LibAvContextHandle.h" +#endif +#include "PlaYUVerFrame.h" + +namespace plaYUVer +{ + +class InputStream +{ +private: + + Bool m_bInit; + Bool m_bLoadAll; + Int m_iErrorStatus; + +#ifdef USE_FFMPEG + LibAvContextHandle m_cLibAvContext; +#endif + + QString m_cFilename; + QString m_cFormatName; + QString m_cCodedName; + QString m_cStreamInformationString; + + QTime m_cTimer; + UInt m_uiAveragePlayInterval; + + FILE* m_pFile; /**< The input file pointer >*/ + Int m_iFileFormat; + Int m_iPixelFormat; + + Pel* m_pInputBuffer; + + UInt m_uiFrameBufferSize; + PlaYUVerFrame **m_ppcFrameBuffer; + PlaYUVerFrame *m_pcCurrFrame; + PlaYUVerFrame *m_pcNextFrame; + UInt m_uiFrameBufferIndex; + + UInt m_uiWidth; + UInt m_uiHeight; + UInt m_uiFrameRate; + UInt64 m_uiTotalFrameNum; + Int64 m_iCurrFrameNum; + +public: + InputStream(); + ~InputStream(); + + static QString supportedReadFormats(); + static QString supportedWriteFormats(); + static QStringList supportedReadFormatsList(); + static QStringList supportedWriteFormatsList(); + + enum InputStreamFormats + { + INVALID = -1, + YUVFormat = 0, // Use color space. + }; + + enum InputStreamErrors + { + NO_STREAM_ERROR = 0, + READING, + LAST_FRAME, + END_OF_SEQ, + }; + + Bool open( QString filename, UInt width, UInt height, Int input_format, UInt frame_rate ); + Void close(); + + Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ); + Void getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ); + + Void loadAll(); + + Void readNextFrame(); + + Bool writeFrame( const QString& filename ); + + Void setNextFrame(); + PlaYUVerFrame* getCurrFrame(); + PlaYUVerFrame* getCurrFrame( PlaYUVerFrame * ); + + Void seekInput( UInt64 new_frame_num ); + + Bool checkErrors( Int error_type ); + + Bool isInit() + { + return m_bInit; + } + QString getFileName() + { + return m_cFilename; + } + QString getStreamInformationString() + { + return m_cStreamInformationString; + } + QString getFormatName() + { + return m_cFormatName; + } + QString getCodecName() + { + return m_cCodedName; + } + UInt getFrameNum() + { + return m_uiTotalFrameNum; + } + UInt getWidth() const + { + return m_uiWidth; + } + UInt getHeight() const + { + return m_uiHeight; + } + Int getCurrFrameNum() + { + return m_iCurrFrameNum; + } + UInt getFrameRate() + { + return m_uiFrameRate; + } + Void getDuration( Int* duration_array ); + + Void setWidth( UInt new_width ) + { + if( new_width > 0 && new_width % 2 == 0 ) + { + m_uiWidth = new_width; + } + } + Void setHeight( UInt new_height ) + { + if( new_height > 0 && new_height % 2 == 0 ) + { + m_uiHeight = new_height; + } + } +}; + +} // NAMESPACE + +#endif // __INPUTSTREAM_H__ From f89c8d060129bddb722082af4ef7495f179fea49 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 17 Jun 2014 16:42:46 +0100 Subject: [PATCH 09/15] bugfix in PlaYUVerStream --- source/lib/PlaYUVerStream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/lib/PlaYUVerStream.cpp b/source/lib/PlaYUVerStream.cpp index 4f65926..5d3f2df 100644 --- a/source/lib/PlaYUVerStream.cpp +++ b/source/lib/PlaYUVerStream.cpp @@ -28,8 +28,8 @@ #include "PlaYUVerStream.h" #ifdef USE_FFMPEG #include "LibAvContextHandle.h" -#include "LibMemory.h" #endif +#include "LibMemory.h" namespace plaYUVer { From 52aa84e240e05807d76d9f4c2f1d5a46c2deea73 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 17 Jun 2014 16:45:17 +0100 Subject: [PATCH 10/15] add arch to a global win linux var --- cmake/Install.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/Install.cmake b/cmake/Install.cmake index 5af6b26..c5a1c51 100644 --- a/cmake/Install.cmake +++ b/cmake/Install.cmake @@ -57,6 +57,7 @@ SET(CPACK_PACKAGE_VERSION_MINOR ${PLAYUVER_VERSION_MINOR}) SET(CPACK_PACKAGE_VERSION_PATCH ${PLAYUVER_VERSION_PATH}) SET(CPACK_PACKAGE_VERSION ${PLAYUVER_VERSION}) +SET(CPACK_PACKAGE_ARCHITECTURE "amd64") IF( UNIX ) @@ -64,7 +65,7 @@ IF( UNIX ) SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "plaYUVer is an open-source QT based raw video player") SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Joao Carreira (jfmcarreira@gmail.com), Luis Lucas (luisfrlucas@gmail.com)") - SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") + SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CPACK_PACKAGE_ARCHITECTURE} ) SET(CPACK_DEBIAN_PACKAGE_DEPENDS "") IF( USE_QT4 ) LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libqtcore4 (>= 4:4.8.5~), libqtgui4 (>= 4:4.8.5~)" ) @@ -102,6 +103,6 @@ IF( USE_OPENCV ) SET( APPEND_VERSION "${APPEND_VERSION}_wOpenCV" ) ENDIF() -SET( CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}${APPEND_VERSION}-Linux-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}" ) +SET( CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}${APPEND_VERSION}-Linux-${CPACK_PACKAGE_ARCHITECTURE}" ) INCLUDE(CPack) From cf9edc1b595f0f9d82ec682b9ddd4696356631d5 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 17 Jun 2014 17:13:44 +0100 Subject: [PATCH 11/15] add new variable to support dbg on windows --- cmake/Install.cmake | 10 +++++----- cmake/LibQT.cmake | 3 ++- source/lib/PlaYUVerStream.cpp | 2 -- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cmake/Install.cmake b/cmake/Install.cmake index c5a1c51..287eba9 100644 --- a/cmake/Install.cmake +++ b/cmake/Install.cmake @@ -9,11 +9,11 @@ INSTALL(FILES resources/x-raw.xml DESTINATION share/mime/video ) IF( WIN32 ) IF( NOT USE_QT4 ) - INSTALL(FILES ${QT_DIR}/bin/QT5Core.dll DESTINATION bin ) - INSTALL(FILES ${QT_DIR}/bin/Qt5Gui.dll DESTINATION bin ) - INSTALL(FILES ${QT_DIR}/bin/Qt5Widgets.dll DESTINATION bin ) - INSTALL(FILES ${QT_DIR}/bin/libGLESv2.dll DESTINATION bin ) - INSTALL(FILES ${QT_DIR}/bin/libEGL.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/QT5Core${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/Qt5Gui${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/Qt5Widgets${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/libGLESv2${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/libEGL${QT_DLL_POSTFIX}.dll DESTINATION bin ) INSTALL(FILES ${QT_DIR}/bin/icudt52.dll DESTINATION bin ) INSTALL(FILES ${QT_DIR}/bin/icuin52.dll DESTINATION bin ) INSTALL(FILES ${QT_DIR}/bin/icuuc52.dll DESTINATION bin ) diff --git a/cmake/LibQT.cmake b/cmake/LibQT.cmake index 565a48d..7698bc8 100644 --- a/cmake/LibQT.cmake +++ b/cmake/LibQT.cmake @@ -4,7 +4,8 @@ IF( WIN32 ) SET(QT_DIR "QT-Dir" CACHE PATH "Where to find QT Lib on Windows") - SET (CMAKE_PREFIX_PATH ${QT_DIR} ) + SET(QT_DLL_POSTFIX "" CACHE STRING "Postfix to dll's name for debug" ) + SET(CMAKE_PREFIX_PATH ${QT_DIR} ) ENDIF() IF( USE_QT4 ) diff --git a/source/lib/PlaYUVerStream.cpp b/source/lib/PlaYUVerStream.cpp index 5d3f2df..87fa16a 100644 --- a/source/lib/PlaYUVerStream.cpp +++ b/source/lib/PlaYUVerStream.cpp @@ -22,8 +22,6 @@ * \brief Input stream handling */ -#include "config.h" - #include #include "PlaYUVerStream.h" #ifdef USE_FFMPEG From aaaeb9da14a2406ef20514cd028cf0929d445a2e Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 17 Jun 2014 17:27:22 +0100 Subject: [PATCH 12/15] Change InputStream class name and minor fix in open function --- source/app/PropertiesSidebar.cpp | 2 +- source/app/PropertiesSidebar.h | 4 ++-- source/app/SubWindowHandle.cpp | 20 ++++++++--------- source/app/SubWindowHandle.h | 6 ++--- source/app/ViewArea.cpp | 4 ++-- source/app/ViewArea.h | 8 +++---- source/app/plaYUVerApp.cpp | 4 ++-- source/app/plaYUVerApp.h | 2 +- source/lib/PlaYUVerStream.cpp | 38 ++++++++++++++++---------------- source/lib/PlaYUVerStream.h | 16 +++++++------- 10 files changed, 52 insertions(+), 52 deletions(-) diff --git a/source/app/PropertiesSidebar.cpp b/source/app/PropertiesSidebar.cpp index 98214b8..668bfde 100644 --- a/source/app/PropertiesSidebar.cpp +++ b/source/app/PropertiesSidebar.cpp @@ -123,7 +123,7 @@ QSize StreamPropertiesSideBar::sizeHint() const return bestSize( size() ); } -Void StreamPropertiesSideBar::setData( InputStream* pcStream ) +Void StreamPropertiesSideBar::setData( PlaYUVerStream* pcStream ) { // Clear information. labelFormatValue->clear(); diff --git a/source/app/PropertiesSidebar.h b/source/app/PropertiesSidebar.h index 6dac0da..96bc195 100644 --- a/source/app/PropertiesSidebar.h +++ b/source/app/PropertiesSidebar.h @@ -49,10 +49,10 @@ public: QSize sizeHint() const; - Void setData( InputStream* m_pcStream ); + Void setData( PlaYUVerStream* m_pcStream ); private: - InputStream* m_pcStream; + PlaYUVerStream* m_pcStream; Bool m_bIsVisible; QLabel* labelFormatValue; diff --git a/source/app/SubWindowHandle.cpp b/source/app/SubWindowHandle.cpp index def455a..490be73 100644 --- a/source/app/SubWindowHandle.cpp +++ b/source/app/SubWindowHandle.cpp @@ -55,7 +55,7 @@ SubWindowHandle::SubWindowHandle( QWidget * parent, Bool isModule ) : m_cScrollArea->setWidgetResizable( true ); m_pCurrStream = NULL; - //m_pCurrStream = new InputStream; + //m_pCurrStream = new PlaYUVerStream; m_pcCurrFrame = NULL; m_pcCurrentModule = NULL; @@ -80,19 +80,19 @@ Void SubWindowHandle::reloadFile() seekAbsoluteEvent( currFrameNum ); } -Bool SubWindowHandle::loadFile( const QString &rcFilename, Bool bForceDialog ) +Bool SubWindowHandle::loadFile( QString cFilename, Bool bForceDialog ) { UInt Width = 0, Height = 0, FrameRate = 30; Int InputFormat = -1; if( !m_pCurrStream ) { - m_pCurrStream = new InputStream; + m_pCurrStream = new PlaYUVerStream; } m_pCurrStream->getFormat( Width, Height, InputFormat, FrameRate ); - if( m_pCurrStream->guessFormat( rcFilename, Width, Height, InputFormat, FrameRate ) || bForceDialog ) + if( m_pCurrStream->guessFormat( cFilename, Width, Height, InputFormat, FrameRate ) || bForceDialog ) { ConfigureFormatDialog formatDialog( this ); if( formatDialog.runConfigureFormatDialog( Width, Height, InputFormat, FrameRate ) == QDialog::Rejected ) @@ -102,7 +102,7 @@ Bool SubWindowHandle::loadFile( const QString &rcFilename, Bool bForceDialog ) } QApplication::setOverrideCursor( Qt::WaitCursor ); QApplication::restoreOverrideCursor(); - if( !m_pCurrStream->open( rcFilename, Width, Height, InputFormat, FrameRate ) ) + if( !m_pCurrStream->open( cFilename, Width, Height, InputFormat, FrameRate ) ) { return false; } @@ -113,7 +113,7 @@ Bool SubWindowHandle::loadFile( const QString &rcFilename, Bool bForceDialog ) refreshFrame(); - m_cCurrFileName = rcFilename; + m_cCurrFileName = cFilename; m_cWindowName = m_pCurrStream->getStreamInformationString(); setWindowTitle( m_cWindowName ); return true; @@ -194,13 +194,13 @@ Void SubWindowHandle::refreshFrame() Bool SubWindowHandle::save() { QString supported = tr( "Supported Files" ); - QString formats = InputStream::supportedWriteFormats(); + QString formats = PlaYUVerStream::supportedWriteFormats(); formats.prepend( " (" ); formats.append( ")" ); supported.append( formats ); // supported=="Supported Files (*.pbm *.jpg...)" QStringList filter; filter << supported - << InputStream::supportedWriteFormatsList() + << PlaYUVerStream::supportedWriteFormatsList() << tr( "All Files (*)" ); QString fileName = QFileDialog::getSaveFileName( this, tr( "Save As" ), m_cCurrFileName, filter.join( ";;" ) ); if( fileName.isEmpty() ) @@ -231,12 +231,12 @@ Int SubWindowHandle::playEvent() { m_pCurrStream->setNextFrame(); refreshFrame(); - if( m_pCurrStream->checkErrors( InputStream::END_OF_SEQ ) ) + if( m_pCurrStream->checkErrors( PlaYUVerStream::END_OF_SEQ ) ) { return -2; } m_pCurrStream->readNextFrame(); - if( m_pCurrStream->checkErrors( InputStream::READING ) ) + if( m_pCurrStream->checkErrors( PlaYUVerStream::READING ) ) { QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot read %1." ).arg( m_cCurrFileName ) ); return -3; diff --git a/source/app/SubWindowHandle.h b/source/app/SubWindowHandle.h index d9c8c10..8715a13 100644 --- a/source/app/SubWindowHandle.h +++ b/source/app/SubWindowHandle.h @@ -50,7 +50,7 @@ private: PlaYUVerModuleIf* m_pcCurrentModule; - InputStream* m_pCurrStream; + PlaYUVerStream* m_pCurrStream; PlaYUVerFrame* m_pcCurrFrame; QString m_cWindowName; @@ -66,7 +66,7 @@ public: ~SubWindowHandle(); Bool mayClose(); - Bool loadFile( const QString &rcFilename, Bool bForceDialog = false ); + Bool loadFile( QString cFilename, Bool bForceDialog = false ); Void reloadFile(); Bool save(); @@ -88,7 +88,7 @@ public: Void refreshFrame(); Void setCurrFrame( PlaYUVerFrame* pcCurrFrame ); - InputStream* getInputStream() + PlaYUVerStream* getInputStream() { return m_pCurrStream; } diff --git a/source/app/ViewArea.cpp b/source/app/ViewArea.cpp index 6d80445..3751631 100644 --- a/source/app/ViewArea.cpp +++ b/source/app/ViewArea.cpp @@ -875,12 +875,12 @@ void ViewArea::updateMask( const QRect &rect ) } -void ViewArea::setInputStream( InputStream *stream ) +void ViewArea::setInputStream( PlaYUVerStream *stream ) { m_pStream = stream; } -InputStream* ViewArea::getInputStream() +PlaYUVerStream* ViewArea::getInputStream() { return m_pStream; } diff --git a/source/app/ViewArea.h b/source/app/ViewArea.h index af31821..3659066 100644 --- a/source/app/ViewArea.h +++ b/source/app/ViewArea.h @@ -38,7 +38,7 @@ namespace plaYUVer { -class InputStream; +class PlaYUVerStream; /** * @@ -99,8 +99,8 @@ public: return m_maskColor; } - void setInputStream( InputStream *stream ); - InputStream* getInputStream(); + void setInputStream( PlaYUVerStream *stream ); + PlaYUVerStream* getInputStream(); Void zoomChangeEvent(Double factor, QPoint center); Double getZoomFactor(); @@ -167,7 +167,7 @@ private: bool m_snapToGrid; bool m_cursorInGrid; - InputStream *m_pStream; + PlaYUVerStream *m_pStream; }; diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index 09d9e99..5d05f9d 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -189,14 +189,14 @@ Void plaYUVerApp::loadFile( QString fileName ) Void plaYUVerApp::open() { QString supported = tr( "Supported Files" ); - QString formats = InputStream::supportedReadFormats(); + QString formats = PlaYUVerStream::supportedReadFormats(); formats.prepend( " (" ); formats.append( ")" ); supported.append( formats ); // supported=="Supported Files (*.pbm *.jpg...)" QStringList filter; filter << supported - << InputStream::supportedReadFormatsList() + << PlaYUVerStream::supportedReadFormatsList() << tr( "All Files (*)" ); QString fileName = QFileDialog::getOpenFileName( this, tr( "Open File" ), m_cLastOpenPath, filter.join( ";;" ) ); diff --git a/source/app/plaYUVerApp.h b/source/app/plaYUVerApp.h index 004e780..7bfd1dd 100644 --- a/source/app/plaYUVerApp.h +++ b/source/app/plaYUVerApp.h @@ -40,7 +40,7 @@ namespace plaYUVer { class SubWindowHandle; -class InputStream; +class PlaYUVerStream; class plaYUVerApp: public QMainWindow { diff --git a/source/lib/PlaYUVerStream.cpp b/source/lib/PlaYUVerStream.cpp index 87fa16a..216c868 100644 --- a/source/lib/PlaYUVerStream.cpp +++ b/source/lib/PlaYUVerStream.cpp @@ -32,7 +32,7 @@ namespace plaYUVer { -InputStream::InputStream() +PlaYUVerStream::PlaYUVerStream() { m_bInit = false; m_bLoadAll = false; @@ -57,12 +57,12 @@ InputStream::InputStream() m_uiAveragePlayInterval = 0; } -InputStream::~InputStream() +PlaYUVerStream::~PlaYUVerStream() { close(); } -QString InputStream::supportedReadFormats() +QString PlaYUVerStream::supportedReadFormats() { QString formats; formats = "*.yuv " // Raw video @@ -75,7 +75,7 @@ QString InputStream::supportedReadFormats() return formats; } -QString InputStream::supportedWriteFormats() +QString PlaYUVerStream::supportedWriteFormats() { QString formats; formats = "*.bmp " // Windows Bitmap @@ -86,7 +86,7 @@ QString InputStream::supportedWriteFormats() return formats; } -QStringList InputStream::supportedReadFormatsList() +QStringList PlaYUVerStream::supportedReadFormatsList() { QStringList formats; formats << "Raw video (*.yuv)" @@ -99,7 +99,7 @@ QStringList InputStream::supportedReadFormatsList() return formats; } -QStringList InputStream::supportedWriteFormatsList() +QStringList PlaYUVerStream::supportedWriteFormatsList() { QStringList formats; formats << "Windows Bitmap (*.bmp)" @@ -108,7 +108,7 @@ QStringList InputStream::supportedWriteFormatsList() return formats; } -Bool InputStream::open( QString filename, UInt width, UInt height, Int input_format, UInt frame_rate ) +Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_format, UInt frame_rate ) { Bool avStatus = false; @@ -199,7 +199,7 @@ Bool InputStream::open( QString filename, UInt width, UInt height, Int input_for return m_bInit; } -Void InputStream::close() +Void PlaYUVerStream::close() { if( m_pFile ) fclose( m_pFile ); @@ -231,7 +231,7 @@ Void InputStream::close() m_bInit = false; } -Void InputStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ) +Void PlaYUVerStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ) { if( m_bInit ) { @@ -249,7 +249,7 @@ Void InputStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UIn } } -Bool InputStream::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ) +Bool PlaYUVerStream::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ) { Bool bRet = false; QString fileExtension = QFileInfo( filename ).suffix(); @@ -292,7 +292,7 @@ Bool InputStream::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, In return bRet; } -Void InputStream::loadAll() +Void PlaYUVerStream::loadAll() { if( m_bLoadAll ) return; @@ -331,7 +331,7 @@ Void InputStream::loadAll() seekInput( 0 ); } -Void InputStream::getDuration( Int* duration_array ) +Void PlaYUVerStream::getDuration( Int* duration_array ) { Int hours, mins, secs; #ifdef USE_FFMPEG @@ -353,7 +353,7 @@ Void InputStream::getDuration( Int* duration_array ) *duration_array++ = secs; } -Void InputStream::readNextFrame() +Void PlaYUVerStream::readNextFrame() { UInt64 bytes_read = 0; //m_cTimer.restart(); @@ -396,13 +396,13 @@ Void InputStream::readNextFrame() return; } -Bool InputStream::writeFrame( const QString& filename ) +Bool PlaYUVerStream::writeFrame( const QString& filename ) { //m_pcCurrFrame->getQimage().save( filename ); return true; } -Void InputStream::setNextFrame() +Void PlaYUVerStream::setNextFrame() { if( m_pcNextFrame ) { @@ -422,7 +422,7 @@ Void InputStream::setNextFrame() } } -PlaYUVerFrame* InputStream::getCurrFrame( PlaYUVerFrame *pyuv_image ) +PlaYUVerFrame* PlaYUVerStream::getCurrFrame( PlaYUVerFrame *pyuv_image ) { if( pyuv_image == NULL ) pyuv_image = new PlaYUVerFrame( m_pcCurrFrame ); @@ -431,12 +431,12 @@ PlaYUVerFrame* InputStream::getCurrFrame( PlaYUVerFrame *pyuv_image ) return pyuv_image; } -PlaYUVerFrame* InputStream::getCurrFrame() +PlaYUVerFrame* PlaYUVerStream::getCurrFrame() { return m_pcCurrFrame; } -Void InputStream::seekInput( UInt64 new_frame_num ) +Void PlaYUVerStream::seekInput( UInt64 new_frame_num ) { if( !m_pFile || new_frame_num < 0 || new_frame_num >= m_uiTotalFrameNum || (Int64)new_frame_num == m_iCurrFrameNum ) return; @@ -471,7 +471,7 @@ Void InputStream::seekInput( UInt64 new_frame_num ) readNextFrame(); } -Bool InputStream::checkErrors( Int error_type ) +Bool PlaYUVerStream::checkErrors( Int error_type ) { if( m_iErrorStatus == error_type ) { diff --git a/source/lib/PlaYUVerStream.h b/source/lib/PlaYUVerStream.h index 5a3e8c1..31d00a1 100644 --- a/source/lib/PlaYUVerStream.h +++ b/source/lib/PlaYUVerStream.h @@ -22,8 +22,8 @@ * \brief Input stream handling */ -#ifndef __INPUTSTREAM_H__ -#define __INPUTSTREAM_H__ +#ifndef __PLAYUVERSTREAM_H__ +#define __PLAYUVERSTREAM_H__ #ifdef PLAYUVER #include "config.h" @@ -44,7 +44,7 @@ namespace plaYUVer { -class InputStream +class PlaYUVerStream { private: @@ -83,21 +83,21 @@ private: Int64 m_iCurrFrameNum; public: - InputStream(); - ~InputStream(); + PlaYUVerStream(); + ~PlaYUVerStream(); static QString supportedReadFormats(); static QString supportedWriteFormats(); static QStringList supportedReadFormatsList(); static QStringList supportedWriteFormatsList(); - enum InputStreamFormats + enum PlaYUVerStreamFormats { INVALID = -1, YUVFormat = 0, // Use color space. }; - enum InputStreamErrors + enum PlaYUVerStreamErrors { NO_STREAM_ERROR = 0, READING, @@ -185,4 +185,4 @@ public: } // NAMESPACE -#endif // __INPUTSTREAM_H__ +#endif // __PLAYUVERSTREAM_H__ From ff1cfbf9e1b6eaa3c462de54880e78fd4509fa31 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 17 Jun 2014 17:44:00 +0100 Subject: [PATCH 13/15] fix wrong conversion on windows from QString to char* --- source/lib/PlaYUVerStream.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/lib/PlaYUVerStream.cpp b/source/lib/PlaYUVerStream.cpp index 216c868..9b098e6 100644 --- a/source/lib/PlaYUVerStream.cpp +++ b/source/lib/PlaYUVerStream.cpp @@ -160,13 +160,15 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_ if( !avStatus ) { m_pFile = NULL; - Char *filename = m_cFilename.toLocal8Bit().data(); + Char *filename = new char[m_cFilename.length() + 1]; + memcpy(filename, m_cFilename.toUtf8().constData(), m_cFilename.length() + 1 * sizeof(char)); m_pFile = fopen( filename, "rb" ); if( m_pFile == NULL ) { close(); return m_bInit; } + delete[] filename; fseek( m_pFile, 0, SEEK_END ); m_uiTotalFrameNum = ftell( m_pFile ) / ( frame_bytes_input ); fseek( m_pFile, 0, SEEK_SET ); From 2a50526c3081e4ba9e408352ccadd55be71bb8aa Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 17 Jun 2014 17:53:37 +0100 Subject: [PATCH 14/15] Remove the discard of mouse events on windows inside ViewArea --- source/app/ViewArea.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/app/ViewArea.cpp b/source/app/ViewArea.cpp index 3751631..3eba98b 100644 --- a/source/app/ViewArea.cpp +++ b/source/app/ViewArea.cpp @@ -605,9 +605,12 @@ void ViewArea::mouseMoveEvent( QMouseEvent *event ) { event->accept(); +#ifndef _MSC_VER // Add this code line to avoid slow navigation with some specific mouses + // This seems to always appear on windows if(qApp->hasPendingEvents()) return; +#endif QPoint actualPos = windowToView( event->pos() ); QRect updateRect; From e6fa5401e7179730e8c08118f5fa1575f5005b96 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 22 Jun 2014 13:54:43 +0100 Subject: [PATCH 15/15] Change some files location and add install of the PlaYUVer libs --- CMakeLists.txt | 12 ++++++++++-- cmake/CMakeMacros.cmake | 6 ------ cmake/Install.cmake | 12 +++++++++--- config.h.in | 1 + source/{lib => app}/PlaYUVerFrameStatistics.cpp | 0 source/{lib => app}/PlaYUVerFrameStatistics.h | 0 6 files changed, 20 insertions(+), 11 deletions(-) rename source/{lib => app}/PlaYUVerFrameStatistics.cpp (100%) rename source/{lib => app}/PlaYUVerFrameStatistics.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa7d12d..81eaf28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ SET( CMAKE_AUTOMOC ON ) INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${SRC_DIR}/app ${SRC_DIR}/lib ) -FILE( GLOB SOURCES_FILES ${SRC_DIR}/app/*.cpp ${SRC_DIR}/lib/*.cpp ) +FILE( GLOB SOURCES_FILES ${SRC_DIR}/app/*.cpp ) FILE( GLOB FORMS_FILES ${UI_DIR}/*.ui ) FILE( GLOB RESOURCES_FILES ${RSC_DIR}/*.qrc ${RSC_DIR}/*.rc ) @@ -58,12 +58,20 @@ ADD_DEFINITIONS( "-DPLAYUVER" ) ###################################################################################### ADD_OPTION(PLAYUVER_WERROR "Warnings as errors" OFF ) ADD_OPTION(PLAYUVER_THREADED_MODULES "Warnings as errors" ON ) +ADD_OPTION(PLAYUVER_INSTALL_LIBS "Install PlaYUVer Lib" ON ) ADD_OPTION(USE_QT4 "Build with QT4" OFF ) ADD_OPTION(USE_OPENCV "Add OpenCV support" OFF ) ADD_OPTION(USE_FFMPEG "Add FFMPEG support" OFF ) ADD_OPTION(USE_FERVOR "Add Fervor support" OFF ) ADD_OPTION(USE_PIXFC "Add PIXFC support" OFF ) +###################################################################################### +# PlaYUVer lib +###################################################################################### +FILE( GLOB PLAYUVER_LIB_SOURCES_FILES ${SRC_DIR}/lib/*.cpp ) +INCLUDE_DIRECTORIES( ${SRC_DIR}/lib ) +ADD_LIBRARY( PlaYUVerLib ${PLAYUVER_LIB_SOURCES_FILES} ) + ###################################################################################### # Dependencies ###################################################################################### @@ -117,7 +125,7 @@ SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" ) ADD_EXECUTABLE( ${PROJECT_NAME} ${SOURCES_FILES} ${HEADERS_MOC_FILES} ${FORMS_HEADERS_FILES} ${RESOURCES_RCC_FILES} ) -TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${PLAYUVER_LIBS} ${MODULES_LIBS} ${LINKER_LIBS} ) +TARGET_LINK_LIBRARIES( ${PROJECT_NAME} PlaYUVerLib ${MODULES_LIBS} ${LINKER_LIBS} ) IF( NOT USE_QT4) QT5_USE_MODULES( ${PROJECT_NAME} ${CURR_QT_MODULES} ) diff --git a/cmake/CMakeMacros.cmake b/cmake/CMakeMacros.cmake index d4e9725..f81bb7c 100644 --- a/cmake/CMakeMacros.cmake +++ b/cmake/CMakeMacros.cmake @@ -110,9 +110,3 @@ macro(ADD_MODULE name file ) endif() unset(__modulename) endmacro() - -macro(ADD_LIB name ) - include_directories( ${SRC_DIR}/lib/${name} ) - add_library( ${name} ${SRC_DIR}/lib/${files} ) - set(PLAYUVER_LIBS ${PLAYUVER_LIBS} ${name}) -endmacro() \ No newline at end of file diff --git a/cmake/Install.cmake b/cmake/Install.cmake index 287eba9..427741c 100644 --- a/cmake/Install.cmake +++ b/cmake/Install.cmake @@ -3,9 +3,9 @@ ###################################################################################### INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin ) -INSTALL(FILES resources/playuver.desktop DESTINATION share/applications ) -INSTALL(FILES resources/playuver.png DESTINATION share/icons ) -INSTALL(FILES resources/x-raw.xml DESTINATION share/mime/video ) +INSTALL(FILES ${RSC_DIR}/playuver.desktop DESTINATION share/applications ) +INSTALL(FILES ${RSC_DIR}/playuver.png DESTINATION share/icons ) +INSTALL(FILES ${RSC_DIR}/x-raw.xml DESTINATION share/mime/video ) IF( WIN32 ) IF( NOT USE_QT4 ) @@ -45,6 +45,12 @@ IF( WIN32 ) ENDIF() ENDIF() +IF( PLAYUVER_INSTALL_LIBS ) + FILE( GLOB PLAYUVER_LIB_INCLUDE_FILES ${SRC_DIR}/lib/*.h ) + INSTALL(FILES ${PLAYUVER_LIB_INCLUDE_FILES} DESTINATION include ) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libPlaYUVerLib.a DESTINATION lib ) +ENDIF() + ###################################################################################### # Create deb package diff --git a/config.h.in b/config.h.in index e73d935..011d3f2 100644 --- a/config.h.in +++ b/config.h.in @@ -30,6 +30,7 @@ /* QT definition */ #cmakedefine USE_QT4 +#undef QT_VERSION_PLAYUVER #ifndef USE_QT4 #define QT_VERSION_PLAYUVER 5 #else diff --git a/source/lib/PlaYUVerFrameStatistics.cpp b/source/app/PlaYUVerFrameStatistics.cpp similarity index 100% rename from source/lib/PlaYUVerFrameStatistics.cpp rename to source/app/PlaYUVerFrameStatistics.cpp diff --git a/source/lib/PlaYUVerFrameStatistics.h b/source/app/PlaYUVerFrameStatistics.h similarity index 100% rename from source/lib/PlaYUVerFrameStatistics.h rename to source/app/PlaYUVerFrameStatistics.h