Add support to refresh frame in a different thread - currently disable

This commit is contained in:
2015-03-03 01:14:03 +00:00
parent 159b33a74f
commit f3ffac6d9f
2 changed files with 29 additions and 11 deletions
+24 -9
View File
@@ -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 );
+5 -2
View File
@@ -88,8 +88,12 @@ private:
* Threads variables
* QtConcurrent
*/
QFuture<Void> m_cRefreshResult;
QFuture<Void> 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()