Add option to output the module frames into a file. write frame is not complete yet

This commit is contained in:
jfmcarreira committed 2014-06-25 00:05:55 +01:00
1 parent 0ee5f300df
commit 6774248987
8 files changed
+163 -34

No files matched your search

+75 -6
View File
@@ -86,6 +86,10 @@ SubWindowHandle* ModulesHandle::processModuleHandlingOpt()
case SWAP_FRAMES_OPT:
pcSubWindow->swapModuleFrames();
break;
case APPLY_ALL_OPT:
openModuleIfStream( pcSubWindow->getModule() );
pcSubWindow->applyModuleAllFrames();
break;
default:
Q_ASSERT( 0 );
}
@@ -184,16 +188,18 @@ Void ModulesHandle::destroyAllModulesIf()
}
}
Bool ModulesHandle::applyModuleIf( PlaYUVerModuleIf *pcCurrModuleIf, Bool isPlaying )
Bool ModulesHandle::applyModuleIf( PlaYUVerModuleIf *pcCurrModuleIf, Bool isPlaying, Bool disableThreads )
{
Bool bRet = false;
if( !isPlaying || ( isPlaying && pcCurrModuleIf->m_cModuleDef.m_bApplyWhilePlaying ) )
{
#ifdef PLAYUVER_THREADED_MODULES
pcCurrModuleIf->start();
#else
pcCurrModuleIf->run();
if( !disableThreads )
pcCurrModuleIf->start();
else
#endif
pcCurrModuleIf->run();
if( pcCurrModuleIf->m_pcDisplaySubWindow )
{
bRet = true;
@@ -208,7 +214,63 @@ Bool ModulesHandle::applyModuleIf( PlaYUVerModuleIf *pcCurrModuleIf, Bool isPlay
Void ModulesHandle::applyAllModuleIf( PlaYUVerModuleIf *pcCurrModuleIf )
{
if( pcCurrModuleIf->m_pcModuleStream )
{
UInt numberOfWindows = pcCurrModuleIf->m_cModuleDef.m_uiNumberOfFrames;
UInt currFrames;
UInt64 numberOfFrames = INT_MAX;
for( UInt i = 0; i < numberOfWindows; i++ )
{
currFrames = pcCurrModuleIf->m_pcSubWindow[i]->getInputStream()->getFrameNum();
if( currFrames < numberOfFrames )
numberOfFrames = currFrames;
}
for( UInt f = 0; f < numberOfFrames; f++ )
{
for( UInt i = 0; i < numberOfWindows; i++ )
{
pcCurrModuleIf->m_pcSubWindow[i]->play();
pcCurrModuleIf->m_pcSubWindow[i]->playEvent();
}
applyModuleIf( pcCurrModuleIf, false, false );
pcCurrModuleIf->m_pcModuleStream->writeFrame( pcCurrModuleIf->m_pcProcessedFrame );
}
}
}
Void ModulesHandle::openModuleIfStream( PlaYUVerModuleIf *pcCurrModuleIf )
{
if( pcCurrModuleIf )
{
if( !pcCurrModuleIf->m_pcModuleStream )
{
UInt Width = 0, Height = 0, FrameRate = 30;
Int InputFormat = -1;
QString supported = tr( "Supported Files" );
QString formats = PlaYUVerStream::supportedWriteFormats();
formats.prepend( " (" );
formats.append( ")" );
supported.append( formats ); // supported=="Supported Files (*.pbm *.jpg...)"
QStringList filter;
filter << supported
<< PlaYUVerStream::supportedWriteFormatsList()
<< tr( "All Files (*)" );
QString fileName = QFileDialog::getSaveFileName( m_pcParent, tr( "Open File" ), QString(), filter.join( ";;" ) );
pcCurrModuleIf->m_pcSubWindow[0]->getInputStream()->getFormat( Width, Height, InputFormat, FrameRate );
pcCurrModuleIf->m_pcModuleStream = new PlaYUVerStream;
if( !pcCurrModuleIf->m_pcModuleStream->open( fileName, Width, Height, InputFormat, FrameRate, false ) )
{
delete pcCurrModuleIf->m_pcModuleStream;
pcCurrModuleIf->m_pcModuleStream = NULL;
return;
}
}
}
}
Bool ModulesHandle::showModuleIf( PlaYUVerModuleIf *pcCurrModuleIf, PlaYUVerFrame* processedFrame )
@@ -300,8 +362,6 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar )
pcCurrModuleIf->m_pcAction = currAction;
}
m_arrayActions[DISABLE_ALL_ACT] = new QAction( "Disable All Modules", parent() );
connect( m_arrayActions[DISABLE_ALL_ACT], SIGNAL( triggered() ), this, SLOT( destroyAllModulesIf() ) );
m_arrayActions[FORCE_NEW_WINDOW_ACT] = new QAction( "Use New Window", parent() );
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setStatusTip( "Show module result in a new window. Some modules already force this feature" );
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setCheckable( true );
@@ -309,12 +369,21 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar )
m_arrayActions[FORCE_PLAYING_REFRESH_ACT]->setStatusTip( "Force module refreshing while playing" );
m_arrayActions[FORCE_PLAYING_REFRESH_ACT]->setCheckable( true );
m_arrayActions[APPLY_ALL_ACT] = new QAction( "Apply to All", parent() );
m_arrayActions[APPLY_ALL_ACT]->setStatusTip( "Apply module to all frames and save the result" );
connect( m_arrayActions[APPLY_ALL_ACT], SIGNAL( triggered() ), m_pcActionMapper, SLOT( map() ) );
m_pcActionMapper->setMapping( m_arrayActions[APPLY_ALL_ACT], APPLY_ALL_OPT );
m_arrayActions[SWAP_FRAMES_ACT] = new QAction( "Swap frames", parent() );
m_arrayActions[SWAP_FRAMES_ACT]->setStatusTip( "Swap Sub Window order" );
connect( m_arrayActions[SWAP_FRAMES_ACT], SIGNAL( triggered() ), m_pcActionMapper, SLOT( map() ) );
m_pcActionMapper->setMapping( m_arrayActions[SWAP_FRAMES_ACT], SWAP_FRAMES_OPT );
m_arrayActions[DISABLE_ALL_ACT] = new QAction( "Disable All Modules", parent() );
connect( m_arrayActions[DISABLE_ALL_ACT], SIGNAL( triggered() ), this, SLOT( destroyAllModulesIf() ) );
m_pcModulesMenu->addSeparator();
m_pcModulesMenu->addAction( m_arrayActions[APPLY_ALL_ACT] );
m_pcModulesMenu->addAction( m_arrayActions[SWAP_FRAMES_ACT] );
m_pcModulesMenu->addAction( m_arrayActions[DISABLE_ALL_ACT] );
m_pcModulesMenu->addAction( m_arrayActions[FORCE_NEW_WINDOW_ACT] );
+6 -2
View File
@@ -56,7 +56,7 @@ public:
SubWindowHandle* processModuleHandlingOpt();
static Void destroyModuleIf( PlaYUVerModuleIf* pcCurrModuleIf );
static Bool applyModuleIf( PlaYUVerModuleIf* pcCurrModuleIf, Bool isPlaying = false );
static Bool applyModuleIf( PlaYUVerModuleIf* pcCurrModuleIf, Bool isPlaying, Bool disableThreads = false );
static Void swapModulesWindowsIf( PlaYUVerModuleIf *pcCurrModuleIf );
static Bool showModuleIf( PlaYUVerModuleIf *pcCurrModuleIf, PlaYUVerFrame* processedFrame );
@@ -72,6 +72,7 @@ private:
{
INVALID_OPT = -1,
SWAP_FRAMES_OPT = -2,
APPLY_ALL_OPT = -3,
};
QMenu* m_pcModulesMenu;
@@ -84,14 +85,17 @@ private:
{
FORCE_NEW_WINDOW_ACT = 0,
FORCE_PLAYING_REFRESH_ACT,
DISABLE_ALL_ACT,
APPLY_ALL_ACT,
SWAP_FRAMES_ACT,
DISABLE_ALL_ACT,
MODULES_TOTAL_ACT
};
QVector<QAction*> m_arrayActions;
Void appendModule( PlaYUVerModuleIf* pcCurrModuleIf );
SubWindowHandle* enableModuleIf( PlaYUVerModuleIf* pcCurrModuleIf );
Void openModuleIfStream( PlaYUVerModuleIf *pcCurrModuleIf );
Void customEvent( QEvent *event );
private Q_SLOTS:
+9 -8
View File
@@ -30,7 +30,9 @@ namespace plaYUVer
PlaYUVerModuleIf::PlaYUVerModuleIf() :
m_pcAction( NULL ),
m_pcDisplaySubWindow( NULL )
m_pcDisplaySubWindow( NULL ),
m_pcProcessedFrame( NULL ),
m_pcModuleStream( NULL )
{
for( Int i = 0; i < MAX_NUMBER_FRAMES; i++ )
{
@@ -40,20 +42,19 @@ PlaYUVerModuleIf::PlaYUVerModuleIf() :
void PlaYUVerModuleIf::run()
{
PlaYUVerFrame* pcProcessedFrame = NULL;
switch( m_cModuleDef.m_uiNumberOfFrames )
{
case MODULE_REQUIRES_ONE_FRAME:
pcProcessedFrame = process( m_pcSubWindow[0]->getCurrFrame() );
m_pcProcessedFrame = process( m_pcSubWindow[0]->getCurrFrame() );
break;
case MODULE_REQUIRES_TWO_FRAMES:
pcProcessedFrame = process( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame() );
m_pcProcessedFrame = process( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame() );
break;
case MODULE_REQUIRES_THREE_FRAMES:
pcProcessedFrame = process( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame(), m_pcSubWindow[2]->getCurrFrame() );
m_pcProcessedFrame = process( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame(), m_pcSubWindow[2]->getCurrFrame() );
break;
}
postProgress( true, pcProcessedFrame );
postProgress( true, m_pcProcessedFrame );
}
Void PlaYUVerModuleIf::postProgress( Bool success, PlaYUVerFrame* pcProcessedFrame )
@@ -62,8 +63,8 @@ Void PlaYUVerModuleIf::postProgress( Bool success, PlaYUVerFrame* pcProcessedFra
eventData->m_bSuccess = success;
eventData->m_pcProcessedFrame = pcProcessedFrame;
eventData->m_pcModule = this;
if( parent() )
QCoreApplication::postEvent( parent(), eventData );
if( parent() && pcProcessedFrame )
QCoreApplication::postEvent( parent(), eventData );
}
} // NAMESPACE
+2
View File
@@ -97,7 +97,9 @@ private:
SubWindowHandle* m_pcSubWindow[MAX_NUMBER_FRAMES];
SubWindowHandle* m_pcDisplaySubWindow;
PlaYUVerModuleDefinition m_cModuleDef;
PlaYUVerStream* m_pcModuleStream;
PlaYUVerFrame* m_pcProcessedFrame;
Void postProgress( Bool success, PlaYUVerFrame* pcProcessedFrame );
public:
+9
View File
@@ -153,6 +153,15 @@ Void SubWindowHandle::swapModuleFrames()
}
}
Void SubWindowHandle::applyModuleAllFrames()
{
if( m_pcCurrentModule )
{
ModulesHandle::applyAllModuleIf( m_pcCurrentModule );
stop();
}
}
Void SubWindowHandle::setCurrFrame( PlaYUVerFrame* pcCurrFrame )
{
m_pcCurrFrame = pcCurrFrame;
+6
View File
@@ -112,6 +112,10 @@ public:
{
m_pcCurrentModule = pcCurrentModule;
}
PlaYUVerModuleIf* getModule()
{
return m_pcCurrentModule;
}
/**
* Functions to enable a module in the
@@ -120,6 +124,8 @@ public:
Void enableModule( PlaYUVerModuleIf* select_module );
Void disableModule();
Void swapModuleFrames();
Void applyModuleAllFrames();
/**
* Show the image at its original size
*/