Improve buffering and fix memory leaks

Use a dedicated class to handle frame buffer
Fix memory leak in stream handler and frame allocation
This commit is contained in:
jfmcarreira committed 2017-09-22 00:54:46 +01:00
1 parent 58146a6b06
commit 1d07dd6b38
12 files changed
+159 -160

No files matched your search

+39 -20
View File
@@ -689,6 +689,33 @@ Void VideoSubWindow::refreshFrame( Bool bThreaded )
}
}
Bool VideoSubWindow::goToNextFrame( Bool bThreaded )
{
#ifndef QT_NO_CONCURRENT
m_cRefreshResult.waitForFinished();
m_cReadResult.waitForFinished();
#endif
Bool bEndOfSeq = m_pCurrStream->setNextFrame();
if( !bEndOfSeq )
{
#ifndef QT_NO_CONCURRENT
m_cRefreshResult.waitForFinished();
if( bThreaded )
{
refreshFrame();
m_cReadResult =
QtConcurrent::run( m_pCurrStream, &PlaYUVerStream::readNextFrameFillRGBBuffer );
}
else
#endif
{
refreshFrame();
m_pCurrStream->readNextFrameFillRGBBuffer();
}
}
return bEndOfSeq;
}
Bool VideoSubWindow::save( QString filename )
{
Bool iRet = false;
@@ -727,20 +754,7 @@ 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();
if( !bEndOfSeq )
{
refreshFrame();
#ifndef QT_NO_CONCURRENT
m_cReadResult = QtConcurrent::run( m_pCurrStream, &PlaYUVerStream::readNextFrameFillRGBBuffer );
#else
m_pCurrStream->readNextFrameFillRGBBuffer();
#endif
}
bEndOfSeq = goToNextFrame( true );
}
return bEndOfSeq;
}
@@ -754,22 +768,27 @@ Void VideoSubWindow::pause()
Void VideoSubWindow::seekAbsoluteEvent( UInt new_frame_num )
{
if( m_pCurrStream )
{
if( m_pCurrStream->seekInput( new_frame_num ) )
{
refreshFrame();
}
}
}
Void VideoSubWindow::seekRelativeEvent( Bool bIsFoward )
{
Bool bRefresh = false;
if( m_pCurrStream )
{
if( m_pCurrStream->seekInputRelative( bIsFoward ) )
if( bIsFoward )
{
refreshFrame();
goToNextFrame( true );
}
else
{
bRefresh = m_pCurrStream->seekInputRelative( bIsFoward );
}
}
if( bRefresh )
{
refreshFrame();
}
}