[vlmc-devel] commit: VideoClipWorkflow: Compute effect in getOutput. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Fri Sep 10 19:24:54 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Fri Sep 10 18:32:09 2010 +0200| [93a4c87c7f334eba5c7167f83da10a932f215322] | committer: Hugo Beauzée-Luyssen 

VideoClipWorkflow: Compute effect in getOutput.

This allow real time effect modification

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

 src/Workflow/AudioClipWorkflow.cpp |    2 +-
 src/Workflow/AudioClipWorkflow.h   |    2 +-
 src/Workflow/ClipWorkflow.h        |    2 +-
 src/Workflow/ImageClipWorkflow.cpp |    3 +--
 src/Workflow/ImageClipWorkflow.h   |    2 +-
 src/Workflow/TrackWorkflow.cpp     |    4 ++--
 src/Workflow/VideoClipWorkflow.cpp |   29 +++++++----------------------
 src/Workflow/VideoClipWorkflow.h   |    5 +----
 8 files changed, 15 insertions(+), 34 deletions(-)

diff --git a/src/Workflow/AudioClipWorkflow.cpp b/src/Workflow/AudioClipWorkflow.cpp
index b200c88..4c6e80d 100644
--- a/src/Workflow/AudioClipWorkflow.cpp
+++ b/src/Workflow/AudioClipWorkflow.cpp
@@ -81,7 +81,7 @@ AudioClipWorkflow::getUnlockCallback() const
 }
 
 Workflow::OutputBuffer*
-AudioClipWorkflow::getOutput( ClipWorkflow::GetMode mode )
+AudioClipWorkflow::getOutput( ClipWorkflow::GetMode mode, qint64 )
 {
     QMutexLocker    lock( m_renderLock );
 
diff --git a/src/Workflow/AudioClipWorkflow.h b/src/Workflow/AudioClipWorkflow.h
index 1b66d1c..667ffa7 100644
--- a/src/Workflow/AudioClipWorkflow.h
+++ b/src/Workflow/AudioClipWorkflow.h
@@ -42,7 +42,7 @@ class   AudioClipWorkflow : public ClipWorkflow
         ~AudioClipWorkflow();
         void                        *getLockCallback() const;
         void                        *getUnlockCallback() const;
-        virtual Workflow::OutputBuffer  *getOutput( ClipWorkflow::GetMode mode );
+        virtual Workflow::OutputBuffer  *getOutput( ClipWorkflow::GetMode mode, qint64 currentFrame );
     protected:
         virtual quint32             getNbComputedBuffers() const;
         virtual quint32             getMaxComputedBuffers() const;
diff --git a/src/Workflow/ClipWorkflow.h b/src/Workflow/ClipWorkflow.h
index b4c7277..9ee2909 100644
--- a/src/Workflow/ClipWorkflow.h
+++ b/src/Workflow/ClipWorkflow.h
@@ -109,7 +109,7 @@ class   ClipWorkflow : public EffectUser
          *  therefore, you can call this method blindly, without taking care
          *  of the rendering process advancement.
          */
-        virtual Workflow::OutputBuffer      *getOutput( ClipWorkflow::GetMode mode ) = 0;
+        virtual Workflow::OutputBuffer      *getOutput( ClipWorkflow::GetMode mode, qint64 currentFrame ) = 0;
         void                    postGetOutput();
         virtual void            initVlcOutput() = 0;
         void                    initialize();
diff --git a/src/Workflow/ImageClipWorkflow.cpp b/src/Workflow/ImageClipWorkflow.cpp
index df34ff2..2c6a648 100644
--- a/src/Workflow/ImageClipWorkflow.cpp
+++ b/src/Workflow/ImageClipWorkflow.cpp
@@ -95,11 +95,10 @@ ImageClipWorkflow::getUnlockCallback() const
 }
 
 Workflow::OutputBuffer*
-ImageClipWorkflow::getOutput( ClipWorkflow::GetMode )
+ImageClipWorkflow::getOutput( ClipWorkflow::GetMode, qint64 currentFrame )
 {
     QMutexLocker    lock( m_renderLock );
 
-    qint64          currentFrame = MainWorkflow::getInstance()->getCurrentFrame( false );
     quint32 *buff = applyFilters( m_buffer, currentFrame,
                                     currentFrame * 1000.0 / clip()->getMedia()->fps() );
     if ( buff != NULL )
diff --git a/src/Workflow/ImageClipWorkflow.h b/src/Workflow/ImageClipWorkflow.h
index 45e5821..0f37b70 100644
--- a/src/Workflow/ImageClipWorkflow.h
+++ b/src/Workflow/ImageClipWorkflow.h
@@ -35,7 +35,7 @@ class   ImageClipWorkflow : public ClipWorkflow
 
         void                    *getLockCallback() const;
         void                    *getUnlockCallback() const;
-        virtual Workflow::OutputBuffer  *getOutput( ClipWorkflow::GetMode mode );
+        virtual Workflow::OutputBuffer  *getOutput( ClipWorkflow::GetMode mode, qint64 currentFrame );
     protected:
         virtual void            initVlcOutput();
         virtual quint32         getNbComputedBuffers() const;
diff --git a/src/Workflow/TrackWorkflow.cpp b/src/Workflow/TrackWorkflow.cpp
index c13d58e..a7e486a 100644
--- a/src/Workflow/TrackWorkflow.cpp
+++ b/src/Workflow/TrackWorkflow.cpp
@@ -178,7 +178,7 @@ TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
 
         if ( cw->isResyncRequired() == true || needRepositioning == true )
             adjustClipTime( currentFrame, start, cw );
-        return cw->getOutput( mode );
+        return cw->getOutput( mode, currentFrame );
     }
     else if ( cw->getState() == ClipWorkflow::Stopped )
     {
@@ -193,7 +193,7 @@ TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
             //Clip was not started at its real begining: adjust the position
             adjustClipTime( currentFrame, start, cw );
         }
-        return cw->getOutput( mode );
+        return cw->getOutput( mode, currentFrame );
     }
     else if ( cw->getState() == ClipWorkflow::EndReached ||
               cw->getState() == ClipWorkflow::Muted ||
diff --git a/src/Workflow/VideoClipWorkflow.cpp b/src/Workflow/VideoClipWorkflow.cpp
index e78cbe7..c8ec7e0 100644
--- a/src/Workflow/VideoClipWorkflow.cpp
+++ b/src/Workflow/VideoClipWorkflow.cpp
@@ -34,17 +34,14 @@
 
 VideoClipWorkflow::VideoClipWorkflow( ClipHelper *ch ) :
         ClipWorkflow( ch ),
-        m_renderedFrame( 0 ),
         m_lastReturnedBuffer( NULL )
 {
     m_effectsLock = new QReadWriteLock();
-    m_renderedFrameMutex = new QMutex();
 }
 
 VideoClipWorkflow::~VideoClipWorkflow()
 {
     stop();
-    delete m_renderedFrameMutex;
 }
 
 void
@@ -115,7 +112,7 @@ VideoClipWorkflow::getUnlockCallback() const
 }
 
 Workflow::OutputBuffer*
-VideoClipWorkflow::getOutput( ClipWorkflow::GetMode mode )
+VideoClipWorkflow::getOutput( ClipWorkflow::GetMode mode, qint64 currentFrame )
 {
     QMutexLocker    lock( m_renderLock );
 
@@ -139,6 +136,12 @@ VideoClipWorkflow::getOutput( ClipWorkflow::GetMode mode )
     }
     else if ( mode == ClipWorkflow::Get )
         buff = m_computedBuffers.head();
+
+    quint32     *newFrame = applyFilters( buff, currentFrame,
+                                 currentFrame * 1000.0 / clip()->getMedia()->fps() );
+    if ( newFrame != NULL )
+        buff->setBuffer( newFrame );
+
     postGetOutput();
     return buff;
 }
@@ -170,14 +173,6 @@ VideoClipWorkflow::unlock( VideoClipWorkflow *cw, void *buffer, int width,
 
     cw->computePtsDiff( pts );
     Workflow::Frame     *frame = cw->m_computedBuffers.last();
-    quint32     *newFrame = cw->applyFilters( frame, cw->m_renderedFrame,
-                                 cw->m_renderedFrame * 1000.0 / cw->clip()->getMedia()->fps() );
-    if ( newFrame != NULL )
-        frame->setBuffer( newFrame );
-    {
-        QMutexLocker    lock( cw->m_renderedFrameMutex );
-        cw->m_renderedFrame++;
-    }
     frame->ptsDiff = cw->m_currentPts - cw->m_previousPts;
     cw->commonUnlock();
     cw->m_renderWaitCond->wakeAll();
@@ -204,13 +199,3 @@ VideoClipWorkflow::flushComputedBuffers()
     while ( m_computedBuffers.isEmpty() == false )
         m_availableBuffers.enqueue( m_computedBuffers.dequeue() );
 }
-
-void
-VideoClipWorkflow::setTime( qint64 time, qint64 frame )
-{
-    {
-        QMutexLocker    lock( m_renderedFrameMutex );
-        m_renderedFrame = frame;
-    }
-    ClipWorkflow::setTime( time, frame );
-}
diff --git a/src/Workflow/VideoClipWorkflow.h b/src/Workflow/VideoClipWorkflow.h
index a00a71f..55a3887 100644
--- a/src/Workflow/VideoClipWorkflow.h
+++ b/src/Workflow/VideoClipWorkflow.h
@@ -39,8 +39,7 @@ class   VideoClipWorkflow : public ClipWorkflow
         ~VideoClipWorkflow();
         void                    *getLockCallback() const;
         void                    *getUnlockCallback() const;
-        virtual Workflow::OutputBuffer  *getOutput( ClipWorkflow::GetMode mode );
-        virtual void            setTime( qint64 time, qint64 frame );
+        virtual Workflow::OutputBuffer  *getOutput( ClipWorkflow::GetMode mode, qint64 currentFrame );
 
         static const quint32    nbBuffers = 3 * 30; //3 seconds with an average fps of 30
 
@@ -63,8 +62,6 @@ class   VideoClipWorkflow : public ClipWorkflow
         static void                 unlock( VideoClipWorkflow* clipWorkflow, void* buffer,
                                             int width, int height, int bpp, int size,
                                             qint64 pts );
-        QMutex                      *m_renderedFrameMutex;
-        qint64                      m_renderedFrame;
         Workflow::Frame             *m_lastReturnedBuffer;
 };
 



More information about the Vlmc-devel mailing list