diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index f1c48d2..3a50280 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -26,6 +26,7 @@ #include "ModulesHandle.h" #include "SubWindowHandle.h" #include "ConfigureFormatDialog.h" +#include "QtConcurrent/qtconcurrentrun.h" namespace plaYUVer { @@ -399,7 +400,7 @@ Void VideoSubWindow::setCurrFrame( PlaYUVerFrame* pcCurrFrame ) m_cViewArea->setImage( m_pcCurrFrame ); } -Void VideoSubWindow::refreshFrame() +Void VideoSubWindow::refreshFrameOperation() { Bool bSetFrame = false; if( m_pCurrStream ) @@ -422,6 +423,21 @@ Void VideoSubWindow::refreshFrame() } } +Void VideoSubWindow::refreshFrame( Bool bThreaded ) +{ +#ifndef QT_NO_CONCURRENT + m_cRefreshResult.waitForFinished(); + if( bThreaded ) + { + m_cRefreshResult = QtConcurrent::run( this, &VideoSubWindow::refreshFrameOperation ); + } + else +#endif + { + refreshFrameOperation(); + } +} + Bool VideoSubWindow::save( QString filename ) { Bool iRet = false; @@ -454,14 +470,13 @@ 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_cRefreshResult.waitForFinished(); m_cReadResult.waitForFinished(); #endif bEndOfSeq = m_pCurrStream->setNextFrame(); @@ -469,9 +484,9 @@ Bool VideoSubWindow::playEvent() { refreshFrame(); #ifndef QT_NO_CONCURRENT - m_cReadResult = QtConcurrent::run(m_pCurrStream, &PlaYUVerStream::readFrame); + m_cReadResult = QtConcurrent::run( m_pCurrStream, &PlaYUVerStream::readFrameFillRGBBuffer ); #else - m_pCurrStream->readFrame(); + m_pCurrStream->readFrameFillRGBBuffer(); #endif } } @@ -527,7 +542,7 @@ Void VideoSubWindow::normalSize() Void VideoSubWindow::zoomToFit() { - // Scale to a smaller size that the real to a nicer look +// Scale to a smaller size that the real to a nicer look scaleView( getScrollSize() ); } @@ -564,7 +579,7 @@ Void VideoSubWindow::scaleView( const QSize & size, QPoint center ) QSize newSize = imgViewSize; newSize.scale( size, Qt::KeepAspectRatio ); - // Calc the zoom factor +// Calc the zoom factor Double wfactor = 1; Double hfactor = 1; Double factor; @@ -649,8 +664,8 @@ QSize VideoSubWindow::sizeHint( const QSize & maxSize ) const else if( m_pCurrStream ) isize = QSize( m_pCurrStream->getWidth() + 50, m_pCurrStream->getHeight() + 50 ); - // If the VideoSubWindow needs more space that the avaiable, we'll give - // to the subwindow a reasonable size preserving the image aspect ratio. +// If the VideoSubWindow needs more space that the avaiable, we'll give +// to the subwindow a reasonable size preserving the image aspect ratio. if( !( isize.width() < maxSize.width() && isize.height() < maxSize.height() ) ) { isize.scale( maxSize, Qt::KeepAspectRatio ); diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index a6fe546..fd9c2e5 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -88,8 +88,12 @@ private: * Threads variables * QtConcurrent */ + QFuture m_cRefreshResult; QFuture m_cReadResult; + Void refreshFrame( Bool bThreaded = false ); + Void refreshFrameOperation(); + static Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ); /** @@ -111,7 +115,7 @@ public: Bool loadFile( QString cFilename, Bool bForceDialog = false ); Bool loadFile( PlaYUVerStreamInfo* streamInfo ); - Void loadAll( ); + Void loadAll(); Void reloadFile(); Bool save( QString filename ); @@ -128,7 +132,6 @@ public: Void seekAbsoluteEvent( UInt new_frame_num ); Void seekRelativeEvent( Bool bIsFoward ); - Void refreshFrame(); Void setCurrFrame( PlaYUVerFrame* pcCurrFrame ); PlaYUVerStreamInfo getStreamInfo()