diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index be5c85a..080403a 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -30,10 +30,10 @@ IF( USE_QT4 ) ENDIF() IF( NOT USE_QT4 ) - FIND_PACKAGE( Qt5 REQUIRED COMPONENTS Core Gui Widgets PrintSupport ) + FIND_PACKAGE( Qt5 REQUIRED COMPONENTS Core Gui Widgets PrintSupport Concurrent ) FIND_PACKAGE( Qt5DBus ) - LIST(APPEND QT_LINKER_LIBS Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport ) - LIST(APPEND QT_MODULES Core Gui Widgets ) + LIST(APPEND QT_LINKER_LIBS Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport Qt5::Concurrent ) + LIST(APPEND QT_MODULES Core Gui Widgets PrintSupport Concurrent ) IF( ${Qt5DBus_FOUND} ) SET( USE_QTDBUS ${Qt5DBus_FOUND} ) LIST(APPEND QT_LINKER_LIBS Qt5::DBus ) diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 74a383b..f1c48d2 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -454,16 +454,25 @@ Bool VideoSubWindow::play() return m_bIsPlaying; } +#include "QtConcurrent/qtconcurrentrun.h" + Bool VideoSubWindow::playEvent() { Bool bEndOfSeq = false; if( m_pCurrStream && m_bIsPlaying ) { +#ifndef QT_NO_CONCURRENT + m_cReadResult.waitForFinished(); +#endif bEndOfSeq = m_pCurrStream->setNextFrame(); if( !bEndOfSeq ) { refreshFrame(); +#ifndef QT_NO_CONCURRENT + m_cReadResult = QtConcurrent::run(m_pCurrStream, &PlaYUVerStream::readFrame); +#else m_pCurrStream->readFrame(); +#endif } } return bEndOfSeq; diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index 6000295..a6fe546 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -32,6 +32,7 @@ #elif( QT_VERSION_PLAYUVER == 4 ) #include #endif +#include "QFuture" #include "lib/PlaYUVerStream.h" #include "SubWindowHandle.h" #include "ViewArea.h" @@ -83,6 +84,12 @@ private: Bool m_bIsPlaying; Bool m_bIsModule; + /** + * Threads variables + * QtConcurrent + */ + QFuture m_cReadResult; + static Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ); /** diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index ad364e4..dd87108 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -481,7 +481,7 @@ Void PlaYUVerStream::readFrame() if( !m_bInit || !m_bIsInput || m_bLoadAll ) return; - if( m_uiCurrFrameFileIdx >= Int64( m_uiTotalFrameNum ) ) + if( m_uiCurrFrameFileIdx >= m_uiTotalFrameNum ) { m_pcNextFrame = NULL; return; @@ -641,7 +641,6 @@ PlaYUVerFrame* PlaYUVerStream::getNextFrame() return m_pcNextFrame; } - Bool PlaYUVerStream::seekInput( UInt64 new_frame_num ) { if( !m_bInit || new_frame_num < 0 || new_frame_num >= m_uiTotalFrameNum || ( Int64 )new_frame_num == m_iCurrFrameNum )