Merge branch devel

This commit is contained in:
2017-09-23 02:15:29 +01:00
parent ed075fcbd3
commit eb31fc0287
16 changed files with 231 additions and 205 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ set( PROJECT_NAME "playuver" CACHE INTERNAL "" FORCE )
PROJECT( ${PROJECT_NAME} ) PROJECT( ${PROJECT_NAME} )
SET( PLAYUVER_VERSION_MAJOR "0" ) SET( PLAYUVER_VERSION_MAJOR "0" )
SET( PLAYUVER_VERSION_MINOR "14" ) SET( PLAYUVER_VERSION_MINOR "14" )
SET( PLAYUVER_VERSION_PATCH "0" ) SET( PLAYUVER_VERSION_PATCH "1" )
SET( PLAYUVER_VERSION "${PLAYUVER_VERSION_MAJOR}.${PLAYUVER_VERSION_MINOR}.${PLAYUVER_VERSION_PATCH}" CACHE INTERNAL "" FORCE ) SET( PLAYUVER_VERSION "${PLAYUVER_VERSION_MAJOR}.${PLAYUVER_VERSION_MINOR}.${PLAYUVER_VERSION_PATCH}" CACHE INTERNAL "" FORCE )
###################################################################################### ######################################################################################
+1 -2
View File
@@ -347,7 +347,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget* parent ) : QDialog( paren
m_spinBoxFrameRate = new QSpinBox(); m_spinBoxFrameRate = new QSpinBox();
m_spinBoxFrameRate->setSuffix( QStringLiteral( " Hz" ) ); m_spinBoxFrameRate->setSuffix( QStringLiteral( " Hz" ) );
m_spinBoxFrameRate->setMinimumWidth( 30 ); m_spinBoxFrameRate->setMinimumWidth( 30 );
m_spinBoxFrameRate->setRange( 0, 200 ); m_spinBoxFrameRate->setRange( 0, 1000 );
m_spinBoxFrameRate->setValue( 30 ); m_spinBoxFrameRate->setValue( 30 );
framerateFormatLayout->addWidget( framerateFormatLabel ); framerateFormatLayout->addWidget( framerateFormatLabel );
framerateFormatLayout->addItem( framerateFormatLayout->addItem(
@@ -442,7 +442,6 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename,
if( standardResolutionSizes.at( i ) == QSize( rWidth, rHeight ) ) if( standardResolutionSizes.at( i ) == QSize( rWidth, rHeight ) )
{ {
m_comboBoxStandardResolution->setCurrentIndex( i ); m_comboBoxStandardResolution->setCurrentIndex( i );
qDebug() << "ola";
break; break;
} }
} }
+4 -4
View File
@@ -896,10 +896,10 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
guidePos = d->colorGuide.blue(); guidePos = d->colorGuide.blue();
break; break;
// case HistogramWidget::LumaHistogram: // case HistogramWidget::LumaHistogram:
// guidePos = qMax( qMax( d->colorGuide.red(), d->colorGuide.green() // guidePos = qMax( qMax( d->colorGuide.red(), d->colorGuide.green()
// ), d->colorGuide.blue() ); // ), d->colorGuide.blue() );
// break; // break;
default: // Alpha. default: // Alpha.
guidePos = -1; guidePos = -1;
+24 -14
View File
@@ -61,13 +61,15 @@ Void VideoHandle::createActions()
m_arrayActions.resize( TOTAL_ACT ); m_arrayActions.resize( TOTAL_ACT );
m_arrayActions[PLAY_ACT] = new QAction( "Play", this ); m_arrayActions[PLAY_ACT] = new QAction( "Play", this );
m_arrayActions[PLAY_ACT]->setStatusTip( "Play/Pause" ); m_arrayActions[PLAY_ACT]->setStatusTip( "Play/Pause" );
m_arrayActions[PLAY_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ) ); m_arrayActions[PLAY_ACT]->setIcon(
QIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaPlay ) ) );
m_arrayActions[PLAY_ACT]->setShortcut( Qt::Key_Space ); m_arrayActions[PLAY_ACT]->setShortcut( Qt::Key_Space );
connect( m_arrayActions[PLAY_ACT], SIGNAL( triggered() ), this, SLOT( play() ) ); connect( m_arrayActions[PLAY_ACT], SIGNAL( triggered() ), this, SLOT( play() ) );
m_arrayActions[STOP_ACT] = new QAction( "Stop", this ); m_arrayActions[STOP_ACT] = new QAction( "Stop", this );
m_arrayActions[STOP_ACT]->setStatusTip( "Stop" ); m_arrayActions[STOP_ACT]->setStatusTip( "Stop" );
m_arrayActions[STOP_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaStop ) ) ); m_arrayActions[STOP_ACT]->setIcon(
QIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaStop ) ) );
connect( m_arrayActions[STOP_ACT], SIGNAL( triggered() ), this, SLOT( stop() ) ); connect( m_arrayActions[STOP_ACT], SIGNAL( triggered() ), this, SLOT( stop() ) );
m_mapperVideoSeek = new QSignalMapper( this ); m_mapperVideoSeek = new QSignalMapper( this );
@@ -76,7 +78,7 @@ Void VideoHandle::createActions()
m_arrayActions[VIDEO_BACKWARD_ACT] = new QAction( "Video Backward", this ); m_arrayActions[VIDEO_BACKWARD_ACT] = new QAction( "Video Backward", this );
m_arrayActions[VIDEO_BACKWARD_ACT]->setStatusTip( "Seek backward" ); m_arrayActions[VIDEO_BACKWARD_ACT]->setStatusTip( "Seek backward" );
m_arrayActions[VIDEO_BACKWARD_ACT]->setIcon( m_arrayActions[VIDEO_BACKWARD_ACT]->setIcon(
QIcon( style()->standardIcon( QStyle::SP_MediaSeekBackward ) ) ); QIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaSeekBackward ) ) );
m_arrayActions[VIDEO_BACKWARD_ACT]->setShortcut( Qt::Key_Left ); m_arrayActions[VIDEO_BACKWARD_ACT]->setShortcut( Qt::Key_Left );
connect( m_arrayActions[VIDEO_BACKWARD_ACT], SIGNAL( triggered() ), m_mapperVideoSeek, connect( m_arrayActions[VIDEO_BACKWARD_ACT], SIGNAL( triggered() ), m_mapperVideoSeek,
SLOT( map() ) ); SLOT( map() ) );
@@ -85,7 +87,7 @@ Void VideoHandle::createActions()
m_arrayActions[VIDEO_FORWARD_ACT] = new QAction( "Video Forward", this ); m_arrayActions[VIDEO_FORWARD_ACT] = new QAction( "Video Forward", this );
m_arrayActions[VIDEO_FORWARD_ACT]->setStatusTip( "Seek forward" ); m_arrayActions[VIDEO_FORWARD_ACT]->setStatusTip( "Seek forward" );
m_arrayActions[VIDEO_FORWARD_ACT]->setIcon( m_arrayActions[VIDEO_FORWARD_ACT]->setIcon(
QIcon( style()->standardIcon( QStyle::SP_MediaSeekForward ) ) ); QIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaSeekForward ) ) );
m_arrayActions[VIDEO_FORWARD_ACT]->setShortcut( Qt::Key_Right ); m_arrayActions[VIDEO_FORWARD_ACT]->setShortcut( Qt::Key_Right );
connect( m_arrayActions[VIDEO_FORWARD_ACT], SIGNAL( triggered() ), m_mapperVideoSeek, connect( m_arrayActions[VIDEO_FORWARD_ACT], SIGNAL( triggered() ), m_mapperVideoSeek,
SLOT( map() ) ); SLOT( map() ) );
@@ -170,7 +172,7 @@ Void VideoHandle::createActions()
QMenu* VideoHandle::createVideoMenu() QMenu* VideoHandle::createVideoMenu()
{ {
m_pcMenuVideo = new QMenu( "Video", this ); m_pcMenuVideo = new QMenu( "Video", m_pcParet );
m_pcMenuVideo->addAction( m_arrayActions[PLAY_ACT] ); m_pcMenuVideo->addAction( m_arrayActions[PLAY_ACT] );
m_pcMenuVideo->addAction( m_arrayActions[STOP_ACT] ); m_pcMenuVideo->addAction( m_arrayActions[STOP_ACT] );
m_pcMenuVideo->addAction( m_arrayActions[VIDEO_BACKWARD_ACT] ); m_pcMenuVideo->addAction( m_arrayActions[VIDEO_BACKWARD_ACT] );
@@ -185,7 +187,7 @@ QMenu* VideoHandle::createVideoMenu()
QMenu* VideoHandle::createImageMenu() QMenu* VideoHandle::createImageMenu()
{ {
m_pcMenuImage = new QMenu( "Image", this ); m_pcMenuImage = new QMenu( "Image", m_pcParet );
m_pcMenuImage->addAction( m_arrayActions[NAVIGATION_TOOL_ACT] ); m_pcMenuImage->addAction( m_arrayActions[NAVIGATION_TOOL_ACT] );
m_pcMenuImage->addAction( m_arrayActions[SELECTION_TOOL_ACT] ); m_pcMenuImage->addAction( m_arrayActions[SELECTION_TOOL_ACT] );
m_pcMenuImage->addAction( m_arrayActions[BLOCK_SELECTION_TOOL_ACT] ); m_pcMenuImage->addAction( m_arrayActions[BLOCK_SELECTION_TOOL_ACT] );
@@ -201,7 +203,7 @@ QToolBar* VideoHandle::createToolBar()
m_toolbarVideo->addAction( m_arrayActions[PLAY_ACT] ); m_toolbarVideo->addAction( m_arrayActions[PLAY_ACT] );
m_toolbarVideo->addAction( m_arrayActions[STOP_ACT] ); m_toolbarVideo->addAction( m_arrayActions[STOP_ACT] );
QLabel* pcLockLabel = new QLabel( "PlayingLock", this ); QLabel* pcLockLabel = new QLabel( "PlayingLock" );
pcLockLabel->setAlignment( Qt::AlignCenter ); pcLockLabel->setAlignment( Qt::AlignCenter );
m_arrayActions[VIDEO_LOCK_ACT] = m_toolbarVideo->addWidget( pcLockLabel ); m_arrayActions[VIDEO_LOCK_ACT] = m_toolbarVideo->addWidget( pcLockLabel );
m_arrayActions[VIDEO_LOCK_ACT]->setVisible( false ); m_arrayActions[VIDEO_LOCK_ACT]->setVisible( false );
@@ -218,8 +220,8 @@ QToolBar* VideoHandle::createToolBar()
QDockWidget* VideoHandle::createDock() QDockWidget* VideoHandle::createDock()
{ {
m_pcFramePropertiesSideBar = new FramePropertiesDock( this, &m_bIsPlaying ); m_pcFramePropertiesSideBar = new FramePropertiesDock( m_pcParet, &m_bIsPlaying );
m_pcFramePropertiesDock = new QDockWidget( tr( "Frame Information" ), this ); m_pcFramePropertiesDock = new QDockWidget( tr( "Frame Information" ), m_pcParet );
m_pcFramePropertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); m_pcFramePropertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
m_pcFramePropertiesDock->setWidget( m_pcFramePropertiesSideBar ); m_pcFramePropertiesDock->setWidget( m_pcFramePropertiesSideBar );
connect( m_pcFramePropertiesDock, SIGNAL( visibilityChanged( bool ) ), this, SLOT( update() ) ); connect( m_pcFramePropertiesDock, SIGNAL( visibilityChanged( bool ) ), this, SLOT( update() ) );
@@ -263,14 +265,21 @@ Void VideoHandle::updateMenus()
m_arrayActions[VIDEO_BACKWARD_ACT]->setEnabled( hasSubWindow ); m_arrayActions[VIDEO_BACKWARD_ACT]->setEnabled( hasSubWindow );
m_arrayActions[VIDEO_FORWARD_ACT]->setEnabled( hasSubWindow ); m_arrayActions[VIDEO_FORWARD_ACT]->setEnabled( hasSubWindow );
m_arrayActions[VIDEO_REPEAT_ACT]->setEnabled( hasSubWindow ); m_arrayActions[VIDEO_REPEAT_ACT]->setEnabled( hasSubWindow );
m_arrayActions[VIDEO_GOTO_ACT]->setEnabled( hasSubWindow );
m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->setEnabled( hasSubWindow ); m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->setEnabled( hasSubWindow );
m_arrayActions[VIDEO_LOCK_SELECTION_ACT]->setEnabled( hasSubWindow ); m_arrayActions[VIDEO_LOCK_SELECTION_ACT]->setEnabled( hasSubWindow );
m_pcFrameSlider->setEnabled( hasSubWindow ); m_pcFrameSlider->setEnabled( hasSubWindow );
if( !hasSubWindow ) if( !hasSubWindow )
{ {
disconnect( m_pcFrameSlider, SIGNAL( valueChanged( int ) ), this,
SLOT( seekSliderEvent( int ) ) );
m_pcFrameSlider->setValue( 0 ); m_pcFrameSlider->setValue( 0 );
m_pcFrameNumInfo->clear(); m_pcFrameNumInfo->clear();
} }
else
{
connect( m_pcFrameSlider, SIGNAL( valueChanged( int ) ), this, SLOT( seekSliderEvent( int ) ) );
}
m_arrayActions[NAVIGATION_TOOL_ACT]->setEnabled( hasSubWindow ); m_arrayActions[NAVIGATION_TOOL_ACT]->setEnabled( hasSubWindow );
m_arrayActions[SELECTION_TOOL_ACT]->setEnabled( hasSubWindow ); m_arrayActions[SELECTION_TOOL_ACT]->setEnabled( hasSubWindow );
@@ -357,12 +366,13 @@ Void VideoHandle::update()
if( m_pcCurrentVideoSubWindow->isPlaying() ) if( m_pcCurrentVideoSubWindow->isPlaying() )
{ {
m_arrayActions[PLAY_ACT]->setText( "Pause" ); m_arrayActions[PLAY_ACT]->setText( "Pause" );
m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPause ) ); m_arrayActions[PLAY_ACT]->setIcon(
m_pcParet->style()->standardIcon( QStyle::SP_MediaPause ) );
} }
else else
{ {
m_arrayActions[PLAY_ACT]->setText( "Play" ); m_arrayActions[PLAY_ACT]->setText( "Play" );
m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ); m_arrayActions[PLAY_ACT]->setIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaPlay ) );
} }
} }
else else
@@ -643,7 +653,7 @@ Void VideoHandle::playEvent()
QString warningMsg = "Error while playing " + QString warningMsg = "Error while playing " +
QFileInfo( m_pcCurrentVideoSubWindow->getCurrentFileName() ).fileName() + QFileInfo( m_pcCurrentVideoSubWindow->getCurrentFileName() ).fileName() +
" with the following error: \n" + msg; " with the following error: \n" + msg;
QMessageBox::warning( this, QApplication::applicationName(), warningMsg ); QMessageBox::warning( m_pcParet, QApplication::applicationName(), warningMsg );
qDebug() << warningMsg; qDebug() << warningMsg;
stop(); stop();
m_pcCurrentVideoSubWindow->close(); m_pcCurrentVideoSubWindow->close();
@@ -683,7 +693,7 @@ Void VideoHandle::seekVideo()
if( m_pcCurrentVideoSubWindow->getInputStream() ) if( m_pcCurrentVideoSubWindow->getInputStream() )
{ {
SeekStreamDialog* dialogSeekVideo = SeekStreamDialog* dialogSeekVideo =
new SeekStreamDialog( m_pcCurrentVideoSubWindow->getInputStream(), this ); new SeekStreamDialog( m_pcCurrentVideoSubWindow->getInputStream(), m_pcParet );
Int newFrameNum = dialogSeekVideo->runDialog(); Int newFrameNum = dialogSeekVideo->runDialog();
if( newFrameNum >= 0 ) if( newFrameNum >= 0 )
{ {
@@ -741,7 +751,7 @@ Void VideoHandle::videoSelectionButtonEvent()
} }
else else
{ {
DialogSubWindowSelector dialogWindowsSelection( this, m_pcMainWindowManager, DialogSubWindowSelector dialogWindowsSelection( m_pcParet, m_pcMainWindowManager,
SubWindowAbstract::VIDEO_STREAM_SUBWINDOW ); SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
QStringList cWindowListNames; QStringList cWindowListNames;
for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ )
+2 -1
View File
@@ -31,6 +31,7 @@
#include <QMenu> #include <QMenu>
#include <QPoint> #include <QPoint>
#include <QVector> #include <QVector>
#include <QThread>
#include <QWidget> #include <QWidget>
#define _CONTROL_PLAYING_TIME_ 0 #define _CONTROL_PLAYING_TIME_ 0
@@ -48,7 +49,7 @@ class VideoSubWindow;
class FramePropertiesDock; class FramePropertiesDock;
class WidgetFrameNumber; class WidgetFrameNumber;
class VideoHandle : public QWidget class VideoHandle : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
+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 VideoSubWindow::save( QString filename )
{ {
Bool iRet = false; Bool iRet = false;
@@ -727,20 +754,7 @@ Bool VideoSubWindow::playEvent()
Bool bEndOfSeq = false; Bool bEndOfSeq = false;
if( m_pCurrStream && m_bIsPlaying ) if( m_pCurrStream && m_bIsPlaying )
{ {
#ifndef QT_NO_CONCURRENT bEndOfSeq = goToNextFrame( true );
m_cRefreshResult.waitForFinished();
m_cReadResult.waitForFinished();
#endif
bEndOfSeq = m_pCurrStream->setNextFrame();
if( !bEndOfSeq )
{
refreshFrame( true );
#ifndef QT_NO_CONCURRENT
m_cReadResult = QtConcurrent::run( m_pCurrStream, &PlaYUVerStream::readFrameFillRGBBuffer );
#else
m_pCurrStream->readFrameFillRGBBuffer();
#endif
}
} }
return bEndOfSeq; return bEndOfSeq;
} }
@@ -754,22 +768,27 @@ Void VideoSubWindow::pause()
Void VideoSubWindow::seekAbsoluteEvent( UInt new_frame_num ) Void VideoSubWindow::seekAbsoluteEvent( UInt new_frame_num )
{ {
if( m_pCurrStream ) if( m_pCurrStream )
{
if( m_pCurrStream->seekInput( new_frame_num ) ) if( m_pCurrStream->seekInput( new_frame_num ) )
{
refreshFrame(); refreshFrame();
}
}
} }
Void VideoSubWindow::seekRelativeEvent( Bool bIsFoward ) Void VideoSubWindow::seekRelativeEvent( Bool bIsFoward )
{ {
Bool bRefresh = false;
if( m_pCurrStream ) if( m_pCurrStream )
{ {
if( m_pCurrStream->seekInputRelative( bIsFoward ) ) if( bIsFoward )
{ {
refreshFrame(); goToNextFrame( true );
} }
else
{
bRefresh = m_pCurrStream->seekInputRelative( bIsFoward );
}
}
if( bRefresh )
{
refreshFrame();
} }
} }
+1
View File
@@ -101,6 +101,7 @@ private:
QFuture<Void> m_cReadResult; QFuture<Void> m_cReadResult;
Void refreshFrameOperation(); Void refreshFrameOperation();
Bool goToNextFrame( Bool bThreaded = false );
static Bool guessFormat( QString filename, static Bool guessFormat( QString filename,
UInt& rWidth, UInt& rWidth,
+18 -15
View File
@@ -214,6 +214,24 @@ struct PlaYUVerFramePrivate
m_bInit = true; m_bInit = true;
} }
~PlaYUVerFramePrivate()
{
if( m_puiHistogram )
{
freeMem1D( m_puiHistogram );
}
m_puiHistogram = NULL;
m_bHasHistogram = false;
if( m_pppcInputPel )
freeImgMemory( m_pppcInputPel );
m_pppcInputPel = NULL;
if( m_pcARGB32 )
freeMem1D( m_pcARGB32 );
m_pcARGB32 = NULL;
}
}; };
/*! /*!
@@ -302,21 +320,6 @@ PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame* other,
PlaYUVerFrame::~PlaYUVerFrame() PlaYUVerFrame::~PlaYUVerFrame()
{ {
if( d->m_puiHistogram )
{
freeMem1D( d->m_puiHistogram );
}
d->m_puiHistogram = NULL;
d->m_bHasHistogram = false;
if( d->m_pppcInputPel )
freeImgMemory( d->m_pppcInputPel );
d->m_pppcInputPel = NULL;
if( d->m_pcARGB32 )
freeMem1D( d->m_pcARGB32 );
d->m_pcARGB32 = NULL;
delete d; delete d;
} }
+106 -127
View File
@@ -42,6 +42,52 @@
#include "StreamHandlerOpenCV.h" #include "StreamHandlerOpenCV.h"
#endif #endif
class PlaYUVerStreamBufferPrivate
{
private:
std::vector<PlaYUVerFrame*> m_apcFrameBuffer;
UInt m_uiIndex;
public:
PlaYUVerStreamBufferPrivate( UInt size, UInt width, UInt height, Int pelFormat, Int bitsPixel )
{
for( UInt i = 0; i < size; i++ )
{
PlaYUVerFrame* pFrame = new PlaYUVerFrame( width, height, pelFormat, bitsPixel );
m_apcFrameBuffer.push_back( pFrame );
}
m_uiIndex = 0;
}
~PlaYUVerStreamBufferPrivate()
{
while( m_apcFrameBuffer.size() > 0 )
{
delete m_apcFrameBuffer.back();
m_apcFrameBuffer.pop_back();
}
}
Void increase( UInt newSize )
{
for( UInt i = m_apcFrameBuffer.size(); i < newSize; i++ )
{
PlaYUVerFrame* pFrame = new PlaYUVerFrame( m_apcFrameBuffer.at( 0 ) );
m_apcFrameBuffer.push_back( pFrame );
}
}
UInt size() { return m_apcFrameBuffer.size(); }
Void setIndex( UInt i ) { m_uiIndex = i; }
PlaYUVerFrame* frame( Int i ) { return m_apcFrameBuffer.at( i ); }
PlaYUVerFrame* current() { return m_apcFrameBuffer.at( m_uiIndex ); }
PlaYUVerFrame* next() { return m_apcFrameBuffer.at( nextIndex() ); }
Void setNextFrame() { m_uiIndex = nextIndex(); }
private:
inline Int nextIndex() { return m_uiIndex + 1 >= m_apcFrameBuffer.size() ? 0 : m_uiIndex + 1; }
inline Int prevIndex() { return m_uiIndex - 1 < 0 ? m_apcFrameBuffer.size() - 1 : m_uiIndex - 1; }
};
std::vector<PlaYUVerSupportedFormat> PlaYUVerStream::supportedReadFormats() std::vector<PlaYUVerSupportedFormat> PlaYUVerStream::supportedReadFormats()
{ {
INI_REGIST_PLAYUVER_SUPPORTED_FMT; INI_REGIST_PLAYUVER_SUPPORTED_FMT;
@@ -138,12 +184,6 @@ PlaYUVerStream::PlaYUVerStream()
m_uiTotalFrameNum = 0; m_uiTotalFrameNum = 0;
m_iCurrFrameNum = -1; m_iCurrFrameNum = -1;
m_cFilename = ""; m_cFilename = "";
m_pcCurrFrame = NULL;
m_pcNextFrame = NULL;
m_ppcFrameBuffer = NULL;
m_uiFrameBufferSize = 2;
m_uiFrameBufferIndex = 0;
m_uiCurrFrameFileIdx = 0;
} }
PlaYUVerStream::~PlaYUVerStream() PlaYUVerStream::~PlaYUVerStream()
@@ -246,28 +286,21 @@ Bool PlaYUVerStream::open( String filename,
return m_bInit; return m_bInit;
} }
m_uiFrameBufferSize = m_bIsInput ? 2 : 1; // Keep past, current and future frames
try
getMem1D<PlaYUVerFrame*>( &m_ppcFrameBuffer, m_uiFrameBufferSize );
for( UInt i = 0; i < m_uiFrameBufferSize; i++ )
{ {
try m_frameBuffer = new PlaYUVerStreamBufferPrivate(
{ m_bIsInput ? 3 : 1, m_pcHandler->m_uiWidth, m_pcHandler->m_uiHeight,
m_ppcFrameBuffer[i] = m_pcHandler->m_iPixelFormat, m_pcHandler->m_uiBitsPerPixel );
new PlaYUVerFrame( m_pcHandler->m_uiWidth, m_pcHandler->m_uiHeight, }
m_pcHandler->m_iPixelFormat, m_pcHandler->m_uiBitsPerPixel ); catch( PlaYUVerFailure& e )
} {
catch( PlaYUVerFailure& e ) close();
{ throw PlaYUVerFailure( "PlaYUVerStream", "Cannot allocated frame buffer" );
close(); return m_bInit;
throw PlaYUVerFailure( "PlaYUVerStream", "Cannot allocated frame buffer" );
return m_bInit;
}
} }
m_uiFrameBufferIndex = 0;
m_pcCurrFrame = m_ppcFrameBuffer[m_uiFrameBufferIndex];
m_pcHandler->setBytesPerFrame( m_pcCurrFrame->getBytesPerFrame() ); m_pcHandler->setBytesPerFrame( m_frameBuffer->current()->getBytesPerFrame() );
if( m_bIsInput ) if( m_bIsInput )
{ {
@@ -281,7 +314,7 @@ Bool PlaYUVerStream::open( String filename,
return m_bInit; return m_bInit;
} }
if( !m_pcHandler->configureBuffer( m_pcCurrFrame ) ) if( !m_pcHandler->configureBuffer( m_frameBuffer->current() ) )
{ {
close(); close();
throw PlaYUVerFailure( "PlaYUVerStream", "Cannot allocated memory" ); throw PlaYUVerFailure( "PlaYUVerStream", "Cannot allocated memory" );
@@ -304,7 +337,7 @@ Bool PlaYUVerStream::reload()
{ {
throw PlaYUVerFailure( "PlaYUVerStream", "Cannot open file" ); throw PlaYUVerFailure( "PlaYUVerStream", "Cannot open file" );
} }
m_pcHandler->setBytesPerFrame( m_pcCurrFrame->getBytesPerFrame() ); m_pcHandler->setBytesPerFrame( m_frameBuffer->current()->getBytesPerFrame() );
m_uiTotalFrameNum = m_pcHandler->calculateFrameNumber(); m_uiTotalFrameNum = m_pcHandler->calculateFrameNumber();
if( m_pcHandler->m_uiWidth <= 0 || m_pcHandler->m_uiHeight <= 0 || if( m_pcHandler->m_uiWidth <= 0 || m_pcHandler->m_uiHeight <= 0 ||
@@ -331,17 +364,7 @@ Void PlaYUVerStream::close()
m_pcHandler->closeHandler(); m_pcHandler->closeHandler();
m_pcHandler->Delete(); m_pcHandler->Delete();
if( m_ppcFrameBuffer ) delete m_frameBuffer;
{
for( UInt i = 0; i < m_uiFrameBufferSize; i++ )
{
if( m_ppcFrameBuffer[i] )
delete m_ppcFrameBuffer[i];
m_ppcFrameBuffer[i] = NULL;
}
freeMem1D<PlaYUVerFrame*>( m_ppcFrameBuffer );
m_ppcFrameBuffer = NULL;
}
m_bLoadAll = false; m_bLoadAll = false;
m_bInit = false; m_bInit = false;
@@ -410,43 +433,23 @@ Void PlaYUVerStream::loadAll()
if( m_bLoadAll || !m_bIsInput ) if( m_bLoadAll || !m_bIsInput )
return; return;
if( m_ppcFrameBuffer ) try
{ {
for( UInt i = 0; i < m_uiFrameBufferSize; i++ ) m_frameBuffer->increase( m_uiTotalFrameNum );
{
if( m_ppcFrameBuffer[i] )
delete m_ppcFrameBuffer[i];
m_ppcFrameBuffer[i] = NULL;
}
freeMem1D<PlaYUVerFrame*>( m_ppcFrameBuffer );
m_ppcFrameBuffer = NULL;
} }
m_uiFrameBufferSize = m_uiTotalFrameNum; catch( PlaYUVerFailure& e )
getMem1D<PlaYUVerFrame*>( &m_ppcFrameBuffer, m_uiFrameBufferSize );
for( UInt i = 0; i < m_uiFrameBufferSize; i++ )
{ {
m_ppcFrameBuffer[i] = close();
new PlaYUVerFrame( m_pcHandler->m_uiWidth, m_pcHandler->m_uiHeight, throw PlaYUVerFailure( "PlaYUVerStream", "Cannot allocated frame buffer" );
m_pcHandler->m_iPixelFormat, m_pcHandler->m_uiBitsPerPixel );
if( !m_ppcFrameBuffer[i] )
{
close();
}
} }
m_uiFrameBufferIndex = 0;
m_pcCurrFrame = m_ppcFrameBuffer[m_uiFrameBufferIndex];
m_iCurrFrameNum = -1;
seekInput( 0 ); seekInput( 0 );
for( UInt i = m_uiFrameBufferIndex + 1; i < m_uiFrameBufferSize; i++ ) for( UInt i = 2; i < m_frameBuffer->size(); i++ )
{ {
m_pcNextFrame = m_ppcFrameBuffer[i]; readFrame( m_frameBuffer->frame( i ) );
readFrame();
} }
m_bLoadAll = true; m_bLoadAll = true;
m_uiFrameBufferIndex = 0; m_iCurrFrameNum = 0;
m_pcNextFrame = m_ppcFrameBuffer[m_uiFrameBufferIndex];
m_iCurrFrameNum = -1;
setNextFrame();
} }
Void PlaYUVerStream::getDuration( Int* duration_array ) Void PlaYUVerStream::getDuration( Int* duration_array )
@@ -472,38 +475,25 @@ Void PlaYUVerStream::getDuration( Int* duration_array )
// *duration_array++ = secs; // *duration_array++ = secs;
} }
Void PlaYUVerStream::readFrameFillRGBBuffer() Bool PlaYUVerStream::readFrame( PlaYUVerFrame* frame )
{ {
readFrame(); if( !m_bInit || !m_bIsInput || m_pcHandler->m_uiCurrFrameFileIdx >= m_uiTotalFrameNum )
if( m_pcNextFrame ) return false;
m_pcNextFrame->fillRGBBuffer();
return;
}
Void PlaYUVerStream::readFrame() if( m_bLoadAll )
{ return true;
if( !m_bInit || !m_bIsInput || m_bLoadAll )
return;
if( m_uiCurrFrameFileIdx >= m_uiTotalFrameNum ) if( !m_pcHandler->read( frame ) )
{
m_pcNextFrame = NULL;
return;
}
if( !m_pcHandler->read( m_pcNextFrame ) )
{ {
throw PlaYUVerFailure( "PlaYUVerStream", "Cannot read file" ); throw PlaYUVerFailure( "PlaYUVerStream", "Cannot read file" );
return; return false;
} }
return true;
m_uiCurrFrameFileIdx++;
return;
} }
Void PlaYUVerStream::writeFrame() Void PlaYUVerStream::writeFrame()
{ {
writeFrame( m_pcCurrFrame ); writeFrame( m_frameBuffer->current() );
} }
Void PlaYUVerStream::writeFrame( PlaYUVerFrame* pcFrame ) Void PlaYUVerStream::writeFrame( PlaYUVerFrame* pcFrame )
@@ -517,7 +507,7 @@ Void PlaYUVerStream::writeFrame( PlaYUVerFrame* pcFrame )
Bool PlaYUVerStream::saveFrame( const String& filename ) Bool PlaYUVerStream::saveFrame( const String& filename )
{ {
return saveFrame( filename, m_pcCurrFrame ); return saveFrame( filename, m_frameBuffer->current() );
} }
Bool PlaYUVerStream::saveFrame( const String& filename, PlaYUVerFrame* saveFrame ) Bool PlaYUVerStream::saveFrame( const String& filename, PlaYUVerFrame* saveFrame )
@@ -537,23 +527,11 @@ Bool PlaYUVerStream::saveFrame( const String& filename, PlaYUVerFrame* saveFrame
Bool PlaYUVerStream::setNextFrame() Bool PlaYUVerStream::setNextFrame()
{ {
Bool bEndOfSeq = false; Bool bEndOfSeq = false;
if( m_pcNextFrame )
if( m_iCurrFrameNum + 1 < Int( m_uiTotalFrameNum ) )
{ {
m_pcCurrFrame = m_pcNextFrame; m_frameBuffer->setNextFrame();
m_iCurrFrameNum++; m_iCurrFrameNum++;
if( m_iCurrFrameNum + 1 < Int( m_uiTotalFrameNum ) )
{
m_uiFrameBufferIndex++;
if( m_uiFrameBufferIndex == m_uiFrameBufferSize )
{
m_uiFrameBufferIndex = 0;
}
m_pcNextFrame = m_ppcFrameBuffer[m_uiFrameBufferIndex];
}
else
{
m_pcNextFrame = NULL;
}
} }
else else
{ {
@@ -562,23 +540,30 @@ Bool PlaYUVerStream::setNextFrame()
return bEndOfSeq; return bEndOfSeq;
} }
Void PlaYUVerStream::readNextFrame()
{
readFrame( m_frameBuffer->next() );
}
Void PlaYUVerStream::readNextFrameFillRGBBuffer()
{
readNextFrame();
m_frameBuffer->next()->fillRGBBuffer();
return;
}
PlaYUVerFrame* PlaYUVerStream::getCurrFrame( PlaYUVerFrame* pyuv_image ) PlaYUVerFrame* PlaYUVerStream::getCurrFrame( PlaYUVerFrame* pyuv_image )
{ {
if( pyuv_image == NULL ) if( pyuv_image == NULL )
pyuv_image = new PlaYUVerFrame( m_pcCurrFrame ); pyuv_image = new PlaYUVerFrame( m_frameBuffer->current() );
else else
pyuv_image->copyFrom( m_pcCurrFrame ); pyuv_image->copyFrom( m_frameBuffer->current() );
return pyuv_image; return pyuv_image;
} }
PlaYUVerFrame* PlaYUVerStream::getCurrFrame() PlaYUVerFrame* PlaYUVerStream::getCurrFrame()
{ {
return m_pcCurrFrame; return m_frameBuffer->current();
}
PlaYUVerFrame* PlaYUVerStream::getNextFrame()
{
return m_pcNextFrame;
} }
Bool PlaYUVerStream::seekInputRelative( Bool bIsFoward ) Bool PlaYUVerStream::seekInputRelative( Bool bIsFoward )
@@ -590,7 +575,7 @@ Bool PlaYUVerStream::seekInputRelative( Bool bIsFoward )
if( bIsFoward ) if( bIsFoward )
{ {
bRet = !setNextFrame(); bRet = !setNextFrame();
readFrame(); readFrame( m_frameBuffer->next() );
} }
else else
{ {
@@ -605,29 +590,23 @@ Bool PlaYUVerStream::seekInput( UInt64 new_frame_num )
if( !m_bInit || new_frame_num >= m_uiTotalFrameNum || (Int64)new_frame_num == m_iCurrFrameNum ) if( !m_bInit || new_frame_num >= m_uiTotalFrameNum || (Int64)new_frame_num == m_iCurrFrameNum )
return false; return false;
m_iCurrFrameNum = new_frame_num - 1; m_iCurrFrameNum = new_frame_num;
if( m_bLoadAll ) if( m_bLoadAll )
{ {
m_uiFrameBufferIndex = new_frame_num; m_frameBuffer->setIndex( m_iCurrFrameNum );
m_pcNextFrame = m_ppcFrameBuffer[m_uiFrameBufferIndex];
setNextFrame();
return true; return true;
} }
if( !m_pcHandler->seek( new_frame_num ) ) if( !m_pcHandler->seek( m_iCurrFrameNum ) )
{ {
throw PlaYUVerFailure( "PlaYUVerStream", "Cannot write into the file" ); throw PlaYUVerFailure( "PlaYUVerStream", "Cannot write into the file" );
} }
m_uiCurrFrameFileIdx = new_frame_num; m_frameBuffer->setIndex( 0 );
readFrame( m_frameBuffer->current() );
m_uiFrameBufferIndex = 0;
m_pcCurrFrame = m_pcNextFrame = m_ppcFrameBuffer[m_uiFrameBufferIndex];
readFrame();
setNextFrame();
if( m_uiTotalFrameNum > 1 ) if( m_uiTotalFrameNum > 1 )
readFrame(); readFrame( m_frameBuffer->next() );
return true; return true;
} }
+11 -11
View File
@@ -29,6 +29,7 @@
class PlaYUVerFrame; class PlaYUVerFrame;
class PlaYUVerStreamHandlerIf; class PlaYUVerStreamHandlerIf;
class PlaYUVerStreamBufferPrivate;
typedef struct typedef struct
{ {
@@ -133,18 +134,19 @@ public:
Void loadAll(); Void loadAll();
Void readFrame();
Void readFrameFillRGBBuffer();
Void writeFrame(); Void writeFrame();
Void writeFrame( PlaYUVerFrame* pcFrame ); Void writeFrame( PlaYUVerFrame* pcFrame );
Bool saveFrame( const String& filename ); Bool saveFrame( const String& filename );
static Bool saveFrame( const String& filename, PlaYUVerFrame* saveFrame ); static Bool saveFrame( const String& filename, PlaYUVerFrame* saveFrame );
Bool setNextFrame();
PlaYUVerFrame* getCurrFrame();
PlaYUVerFrame* getCurrFrame( PlaYUVerFrame* ); PlaYUVerFrame* getCurrFrame( PlaYUVerFrame* );
PlaYUVerFrame* getNextFrame();
// continuous read control
Bool setNextFrame();
Void readNextFrame();
Void readNextFrameFillRGBBuffer();
PlaYUVerFrame* getCurrFrame();
Bool seekInputRelative( Bool bIsFoward ); Bool seekInputRelative( Bool bIsFoward );
Bool seekInput( UInt64 new_frame_num ); Bool seekInput( UInt64 new_frame_num );
@@ -152,6 +154,9 @@ public:
Bool isInit() { return m_bInit; } Bool isInit() { return m_bInit; }
Void getDuration( Int* duration_array ); Void getDuration( Int* duration_array );
private:
Bool readFrame( PlaYUVerFrame* frame );
private: private:
Bool m_bInit; Bool m_bInit;
CreateStreamHandlerFn m_pfctCreateHandler; CreateStreamHandlerFn m_pfctCreateHandler;
@@ -164,12 +169,7 @@ private:
Bool m_bLoadAll; Bool m_bLoadAll;
UInt m_uiFrameBufferSize; PlaYUVerStreamBufferPrivate* m_frameBuffer;
PlaYUVerFrame** m_ppcFrameBuffer;
PlaYUVerFrame* m_pcCurrFrame;
PlaYUVerFrame* m_pcNextFrame;
UInt m_uiFrameBufferIndex;
UInt64 m_uiCurrFrameFileIdx;
}; };
#endif // __PLAYUVERSTREAM_H__ #endif // __PLAYUVERSTREAM_H__
+10 -7
View File
@@ -45,14 +45,16 @@ class PlaYUVerStreamHandlerIf
public: public:
PlaYUVerStreamHandlerIf() PlaYUVerStreamHandlerIf()
: m_bIsInput( true )
, m_uiCurrFrameFileIdx( 0 )
, m_uiWidth( 0 )
, m_uiHeight( 0 )
, m_iPixelFormat( -1 )
, m_uiBitsPerPixel( 8 )
, m_iEndianness( -1 )
, m_dFrameRate( 30 )
, m_pStreamBuffer( NULL )
{ {
m_bIsInput = true;
m_uiWidth = 0;
m_uiHeight = 0;
m_iPixelFormat = -1;
m_uiBitsPerPixel = 8;
m_iEndianness = -1;
m_dFrameRate = 30;
} }
virtual ~PlaYUVerStreamHandlerIf() {} virtual ~PlaYUVerStreamHandlerIf() {}
virtual void Delete() = 0; virtual void Delete() = 0;
@@ -71,6 +73,7 @@ public:
protected: protected:
Bool m_bIsInput; Bool m_bIsInput;
UInt64 m_uiCurrFrameFileIdx;
String m_cFilename; String m_cFilename;
UInt m_uiWidth; UInt m_uiWidth;
UInt m_uiHeight; UInt m_uiHeight;
+2
View File
@@ -389,6 +389,7 @@ Bool StreamHandlerLibav::read( PlaYUVerFrame* pcFrame )
#endif #endif
pcFrame->frameFromBuffer( m_pStreamBuffer, m_iEndianness ); pcFrame->frameFromBuffer( m_pStreamBuffer, m_iEndianness );
m_uiCurrFrameFileIdx++;
return true; return true;
} }
return false; return false;
@@ -402,5 +403,6 @@ Bool StreamHandlerLibav::write( PlaYUVerFrame* pcFrame )
Bool StreamHandlerLibav::seek( UInt64 iFrameNum ) Bool StreamHandlerLibav::seek( UInt64 iFrameNum )
{ {
av_seek_frame( m_cFmtCtx, m_iStreamIdx, iFrameNum, AVSEEK_FLAG_FRAME ); av_seek_frame( m_cFmtCtx, m_iStreamIdx, iFrameNum, AVSEEK_FLAG_FRAME );
m_uiCurrFrameFileIdx = iFrameNum;
return true; return true;
} }
+3
View File
@@ -129,6 +129,7 @@ UInt64 StreamHandlerOpenCV::calculateFrameNumber()
Bool StreamHandlerOpenCV::seek( UInt64 iFrameNum ) Bool StreamHandlerOpenCV::seek( UInt64 iFrameNum )
{ {
// m_uiCurrFrameFileIdx =
return true; return true;
} }
@@ -147,6 +148,8 @@ Bool StreamHandlerOpenCV::read( PlaYUVerFrame* pcFrame )
Mat cvMat = cv::imread( m_cFilename ); Mat cvMat = cv::imread( m_cFilename );
bRet = pcFrame->fromMat( cvMat ); bRet = pcFrame->fromMat( cvMat );
} }
if( bRet )
m_uiCurrFrameFileIdx++;
return bRet; return bRet;
} }
+2
View File
@@ -113,6 +113,7 @@ UInt64 StreamHandlerPortableMap::calculateFrameNumber()
Bool StreamHandlerPortableMap::seek( UInt64 iFrameNum ) Bool StreamHandlerPortableMap::seek( UInt64 iFrameNum )
{ {
// m_uiCurrFrameFileIdx =
return true; return true;
} }
@@ -122,6 +123,7 @@ Bool StreamHandlerPortableMap::read( PlaYUVerFrame* pcFrame )
if( processed_bytes != m_uiNBytesPerFrame ) if( processed_bytes != m_uiNBytesPerFrame )
return false; return false;
pcFrame->frameFromBuffer( m_pStreamBuffer, PLAYUVER_BIG_ENDIAN ); pcFrame->frameFromBuffer( m_pStreamBuffer, PLAYUVER_BIG_ENDIAN );
m_uiCurrFrameFileIdx++;
return true; return true;
} }
+4
View File
@@ -48,6 +48,8 @@ Void StreamHandlerRaw::closeHandler()
{ {
if( m_pFile ) if( m_pFile )
fclose( m_pFile ); fclose( m_pFile );
if( m_pStreamBuffer )
freeMem1D( m_pStreamBuffer );
} }
Bool StreamHandlerRaw::configureBuffer( PlaYUVerFrame* pcFrame ) Bool StreamHandlerRaw::configureBuffer( PlaYUVerFrame* pcFrame )
@@ -70,6 +72,7 @@ Bool StreamHandlerRaw::seek( UInt64 iFrameNum )
if( m_bIsInput && m_pFile ) if( m_bIsInput && m_pFile )
{ {
fseek( m_pFile, iFrameNum >= 0 ? iFrameNum * m_uiNBytesPerFrame : 0, SEEK_SET ); fseek( m_pFile, iFrameNum >= 0 ? iFrameNum * m_uiNBytesPerFrame : 0, SEEK_SET );
m_uiCurrFrameFileIdx = iFrameNum;
return true; return true;
} }
return false; return false;
@@ -80,6 +83,7 @@ Bool StreamHandlerRaw::read( PlaYUVerFrame* pcFrame )
UInt64 processed_bytes = fread( m_pStreamBuffer, sizeof( Byte ), m_uiNBytesPerFrame, m_pFile ); UInt64 processed_bytes = fread( m_pStreamBuffer, sizeof( Byte ), m_uiNBytesPerFrame, m_pFile );
if( processed_bytes != m_uiNBytesPerFrame ) if( processed_bytes != m_uiNBytesPerFrame )
return false; return false;
m_uiCurrFrameFileIdx++;
pcFrame->frameFromBuffer( m_pStreamBuffer, m_iEndianness ); pcFrame->frameFromBuffer( m_pStreamBuffer, m_iEndianness );
return true; return true;
} }
+3 -3
View File
@@ -419,7 +419,7 @@ Int PlaYUVerTools::RateReductionOperation()
abEOF = m_apcInputStreams[0]->setNextFrame(); abEOF = m_apcInputStreams[0]->setNextFrame();
if( !abEOF ) if( !abEOF )
{ {
m_apcInputStreams[0]->readFrame(); m_apcInputStreams[0]->readNextFrame();
} }
} }
return 0; return 0;
@@ -500,7 +500,7 @@ Int PlaYUVerTools::QualityOperation()
abEOF[s] = m_apcInputStreams[s]->setNextFrame(); abEOF[s] = m_apcInputStreams[s]->setNextFrame();
if( !abEOF[s] ) if( !abEOF[s] )
{ {
m_apcInputStreams[s]->readFrame(); m_apcInputStreams[s]->readNextFrame();
} }
} }
} }
@@ -584,7 +584,7 @@ Int PlaYUVerTools::ModuleOperation()
abEOF[s] = m_apcInputStreams[s]->setNextFrame(); abEOF[s] = m_apcInputStreams[s]->setNextFrame();
if( !abEOF[s] ) if( !abEOF[s] )
{ {
m_apcInputStreams[s]->readFrame(); m_apcInputStreams[s]->readNextFrame();
} }
} }
} }