[vlmc-devel] commit: EffectEngine: Handle the time parameter correctly. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Sat Jul 31 17:36:01 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sat Jul 31 19:18:34 2010 +0200| [b0317573134ddeff2ba0dc11a44a5bce2042f635] | committer: Hugo Beauzée-Luyssen 

EffectEngine: Handle the time parameter correctly.

The calculation may lack of precision, but that should be enough for
now.

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

 src/EffectsEngine/EffectsEngine.cpp |    4 ++--
 src/EffectsEngine/EffectsEngine.h   |    5 ++++-
 src/Renderer/WorkflowRenderer.cpp   |    4 +++-
 src/Workflow/VideoClipWorkflow.cpp  |    3 ++-
 4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/EffectsEngine/EffectsEngine.cpp b/src/EffectsEngine/EffectsEngine.cpp
index e7c5e00..cf484e8 100644
--- a/src/EffectsEngine/EffectsEngine.cpp
+++ b/src/EffectsEngine/EffectsEngine.cpp
@@ -113,7 +113,7 @@ EffectsEngine::browseDirectory( const QString &path )
 
 void
 EffectsEngine::applyEffects( const EffectList &effects, Workflow::Frame* frame,
-                             qint64 currentFrame  )
+                             qint64 currentFrame, double time )
 {
     if ( effects.size() == 0 )
         return ;
@@ -138,7 +138,7 @@ EffectsEngine::applyEffects( const EffectList &effects, Workflow::Frame* frame,
             if ( *buff == NULL )
                 *buff = new quint8[frame->size()];
             EffectInstance      *effect = (*it)->effect;
-            effect->process( 0.0, (quint32*)input, (quint32*)*buff );
+            effect->process( time, (quint32*)input, (quint32*)*buff );
             input = *buff;
             firstBuff = !firstBuff;
         }
diff --git a/src/EffectsEngine/EffectsEngine.h b/src/EffectsEngine/EffectsEngine.h
index 558d292..19b26b2 100644
--- a/src/EffectsEngine/EffectsEngine.h
+++ b/src/EffectsEngine/EffectsEngine.h
@@ -25,6 +25,8 @@
 
 #include "Singleton.hpp"
 
+class   QTime;
+
 #include "Effect.h"
 #include "MainWorkflow.h"
 
@@ -54,7 +56,7 @@ class   EffectsEngine : public QObject, public Singleton<EffectsEngine>
         void        browseDirectory( const QString& path );
 
         static void applyEffects( const EffectList &effects,
-                                  Workflow::Frame *frame, qint64 currentFrame );
+                                  Workflow::Frame *frame, qint64 currentFrame, double time );
         static void saveEffects( const EffectList &effects, QXmlStreamWriter &project );
         static void initEffects( const EffectList &effects, quint32 width, quint32 height );
 
@@ -64,6 +66,7 @@ class   EffectsEngine : public QObject, public Singleton<EffectsEngine>
 
         QHash<QString, Effect*> m_effects;
         QSettings               *m_cache;
+        QTime                   *m_time;
 
     signals:
         void        effectAdded( Effect*, const QString& name, Effect::Type );
diff --git a/src/Renderer/WorkflowRenderer.cpp b/src/Renderer/WorkflowRenderer.cpp
index 0e0cb9f..140e758 100644
--- a/src/Renderer/WorkflowRenderer.cpp
+++ b/src/Renderer/WorkflowRenderer.cpp
@@ -175,7 +175,9 @@ WorkflowRenderer::lockVideo( EsHandler *handler, qint64 *pts, size_t *bufferSize
     }
     {
         QReadLocker lock( m_effectsLock );
-        EffectsEngine::applyEffects( m_effects, ret->video, m_mainWorkflow->getCurrentFrame() );
+        EffectsEngine::applyEffects( m_effects, ret->video,
+                                     m_mainWorkflow->getCurrentFrame(),
+                                     m_mainWorkflow->getCurrentFrame() * 1000.0 / handler->fps );
     }
     m_pts = *pts = ptsDiff + m_pts;
     *buffer = ret->video->buffer();
diff --git a/src/Workflow/VideoClipWorkflow.cpp b/src/Workflow/VideoClipWorkflow.cpp
index ef4de1a..1f52c9a 100644
--- a/src/Workflow/VideoClipWorkflow.cpp
+++ b/src/Workflow/VideoClipWorkflow.cpp
@@ -168,7 +168,8 @@ VideoClipWorkflow::unlock( VideoClipWorkflow *cw, void *buffer, int width,
     Workflow::Frame     *frame = cw->m_computedBuffers.last();
     {
         QWriteLocker    lock( cw->m_effectsLock );
-        EffectsEngine::applyEffects( cw->m_effects, frame, cw->m_renderedFrame );
+        EffectsEngine::applyEffects( cw->m_effects, frame, cw->m_renderedFrame,
+                                     cw->m_renderedFrame * 1000.0 / (double)Clip::DefaultFPS );
     }
     {
         QMutexLocker    lock( cw->m_renderedFrameMutex );



More information about the Vlmc-devel mailing list