[vlmc-devel] commit: ImageClipWorkflow: Use filters. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Thu Aug 26 23:03:06 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Wed Aug 25 13:03:32 2010 +0200| [acaa013550eed49b2550cecdbf2d61377fde91a8] | committer: Hugo Beauzée-Luyssen 

ImageClipWorkflow: Use filters.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=acaa013550eed49b2550cecdbf2d61377fde91a8
---

 src/Workflow/ImageClipWorkflow.cpp |   33 +++++++++++++++++++++++++++++++++
 src/Workflow/ImageClipWorkflow.h   |    7 +++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/src/Workflow/ImageClipWorkflow.cpp b/src/Workflow/ImageClipWorkflow.cpp
index 68ee030..78e6a81 100644
--- a/src/Workflow/ImageClipWorkflow.cpp
+++ b/src/Workflow/ImageClipWorkflow.cpp
@@ -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;
+}
diff --git a/src/Workflow/ImageClipWorkflow.h b/src/Workflow/ImageClipWorkflow.h
index 21eb3e5..7eb459c 100644
--- a/src/Workflow/ImageClipWorkflow.h
+++ b/src/Workflow/ImageClipWorkflow.h
@@ -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();



More information about the Vlmc-devel mailing list