Commit acaa0135 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

ImageClipWorkflow: Use filters.

parent 4812de32
......@@ -29,6 +29,9 @@
#include "VLCMedia.h"
#include "Workflow/Types.h"
#include <QReadWriteLock>
#include <QtDebug>
ImageClipWorkflow::ImageClipWorkflow( ClipHelper *ch ) :
ClipWorkflow( ch ),
m_buffer( NULL )
......@@ -37,11 +40,16 @@ ImageClipWorkflow::ImageClipWorkflow( ClipHelper *ch ) :
//from vlc's input thread (well it can but it will deadlock)
connect( this, SIGNAL( computedFinished() ),
this, SLOT( stopComputation() ), Qt::QueuedConnection );
m_effectsLock = new QReadWriteLock;
m_effectFrame = new Workflow::Frame;
}
ImageClipWorkflow::~ImageClipWorkflow()
{
stop();
qDeleteAll( m_filters );
delete m_effectFrame;
delete m_effectsLock;
}
void
......@@ -70,6 +78,9 @@ ImageClipWorkflow::initVlcOutput()
m_vlcMedia->addOption( buffer );
sprintf( buffer, ":fake-fps=%f", m_clipHelper->clip()->getMedia()->fps() );
m_vlcMedia->addOption( buffer );
m_effectFrame->resize( MainWorkflow::getInstance()->getWidth(),
MainWorkflow::getInstance()->getHeight() );
}
void*
......@@ -89,6 +100,13 @@ ImageClipWorkflow::getOutput( ClipWorkflow::GetMode )
{
QMutexLocker lock( m_renderLock );
QReadLocker lock2( m_effectsLock );
quint32 *buff = EffectsEngine::applyFilters( m_filters, m_buffer, 0, 0 );
if ( buff != NULL )
{
m_effectFrame->setBuffer( buff );
return m_effectFrame;
}
return m_buffer;
}
......@@ -137,3 +155,18 @@ void
ImageClipWorkflow::flushComputedBuffers()
{
}
EffectsEngine::EffectHelper*
ImageClipWorkflow::appendEffect( Effect *effect, qint64 start, qint64 end )
{
if ( effect->type() != Effect::Filter )
{
qWarning() << "VideoClipWorkflow does not handle non filter effects.";
return NULL;
}
EffectInstance *effectInstance = effect->createInstance();
QWriteLocker lock( m_effectsLock );
EffectsEngine::EffectHelper *ret = new EffectsEngine::EffectHelper( effectInstance, start, end );
m_filters.push_back( ret );
return ret;
}
......@@ -37,7 +37,7 @@ class ImageClipWorkflow : public ClipWorkflow
void *getUnlockCallback() const;
virtual Workflow::OutputBuffer *getOutput( ClipWorkflow::GetMode mode );
virtual void saveEffects( QXmlStreamWriter & ) const {} //Nothing to do here now.
virtual EffectsEngine::EffectHelper *appendEffect( Effect *, qint64, qint64 ) { return NULL; } //Nothing to do here now.
virtual EffectsEngine::EffectHelper *appendEffect( Effect *, qint64, qint64 );
protected:
virtual void initVlcOutput();
virtual quint32 getNbComputedBuffers() const;
......@@ -51,7 +51,10 @@ class ImageClipWorkflow : public ClipWorkflow
int width, int height, int bpp, int size,
qint64 pts );
private:
Workflow::Frame *m_buffer;
Workflow::Frame *m_buffer;
EffectsEngine::EffectList m_filters;
QReadWriteLock *m_effectsLock;
Workflow::Frame *m_effectFrame;
private slots:
void stopComputation();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment