[vlmc-devel] commit: Mixers: Fixing stuff. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Fri Aug 20 00:55:08 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Aug 19 23:00:21 2010 +0200| [ce002d78729e49fd07440df455e32ec7cd465fd8] | committer: Hugo Beauzée-Luyssen 

Mixers: Fixing stuff.

- Passing a correct time.
- Allowing a mixer to use a black frame (IE. two "valid" frames are no
  longer required)

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

 src/Renderer/WorkflowFileRenderer.cpp |    2 +-
 src/Renderer/WorkflowRenderer.cpp     |    2 +-
 src/Workflow/MainWorkflow.cpp         |    4 ++--
 src/Workflow/MainWorkflow.h           |    8 ++++----
 src/Workflow/TrackHandler.cpp         |    4 ++--
 src/Workflow/TrackHandler.h           |    2 +-
 src/Workflow/TrackWorkflow.cpp        |   26 ++++++++++++++++++--------
 src/Workflow/TrackWorkflow.h          |    4 +++-
 8 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/src/Renderer/WorkflowFileRenderer.cpp b/src/Renderer/WorkflowFileRenderer.cpp
index 3f4f18f..fd279f3 100644
--- a/src/Renderer/WorkflowFileRenderer.cpp
+++ b/src/Renderer/WorkflowFileRenderer.cpp
@@ -71,7 +71,7 @@ void        WorkflowFileRenderer::run( const QString& outputFileName, quint32 wi
     m_audioPts = 0;
 
     m_mainWorkflow->setFullSpeedRender( true );
-    m_mainWorkflow->startRender( width, height );
+    m_mainWorkflow->startRender( width, height, fps );
     //Waiting for renderers to preload some frames:
     SleepS( 1 );
     m_mediaPlayer->play();
diff --git a/src/Renderer/WorkflowRenderer.cpp b/src/Renderer/WorkflowRenderer.cpp
index 9cf959b..a6815c9 100644
--- a/src/Renderer/WorkflowRenderer.cpp
+++ b/src/Renderer/WorkflowRenderer.cpp
@@ -246,7 +246,7 @@ void        WorkflowRenderer::startPreview()
     m_mediaPlayer->setMedia( m_media );
 
     m_mainWorkflow->setFullSpeedRender( false );
-    m_mainWorkflow->startRender( m_width, m_height );
+    m_mainWorkflow->startRender( m_width, m_height, m_outputFps );
     m_isRendering = true;
     m_paused = false;
     m_stopping = false;
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index 79ae813..2033b5d 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -109,7 +109,7 @@ MainWorkflow::computeLength()
 }
 
 void
-MainWorkflow::startRender( quint32 width, quint32 height )
+MainWorkflow::startRender( quint32 width, quint32 height, double fps )
 {
     //Reinit the effects in case the width/height has change
     m_renderStarted = true;
@@ -120,7 +120,7 @@ MainWorkflow::startRender( quint32 width, quint32 height )
     blackOutput = new Workflow::Frame( m_width, m_height );
     memset( blackOutput->buffer(), 0, blackOutput->size() );
     for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i )
-        m_tracks[i]->startRender( width, height );
+        m_tracks[i]->startRender( width, height, fps );
     computeLength();
 }
 
diff --git a/src/Workflow/MainWorkflow.h b/src/Workflow/MainWorkflow.h
index d2f9572..0aaf9a3 100644
--- a/src/Workflow/MainWorkflow.h
+++ b/src/Workflow/MainWorkflow.h
@@ -121,7 +121,7 @@ class   MainWorkflow : public QObject, public Singleton<MainWorkflow>
          *  \param      height  The height to use with this render session.
          *  This will basically activate all the tracks, so they can render.
          */
-        void                    startRender( quint32 width, quint32 height );
+        void                    startRender( quint32 width, quint32 height, double fps );
         /**
          *  \brief      Gets a frame from the workflow
          *
@@ -355,6 +355,9 @@ class   MainWorkflow : public QObject, public Singleton<MainWorkflow>
          */
         void                    stopFrameComputing();
 
+        /// Pre-filled buffer used when there's nothing to render
+        static Workflow::Frame*         blackOutput;
+
     private:
         MainWorkflow( int trackCount = 64 );
         ~MainWorkflow();
@@ -408,9 +411,6 @@ class   MainWorkflow : public QObject, public Singleton<MainWorkflow>
         /// Height used for the render
         quint32                         m_height;
 
-        /// Pre-filled buffer used when there's nothing to render
-        static Workflow::Frame*         blackOutput;
-
         friend class                    Singleton<MainWorkflow>;
 
     private slots:
diff --git a/src/Workflow/TrackHandler.cpp b/src/Workflow/TrackHandler.cpp
index 18388af..afe2dc0 100644
--- a/src/Workflow/TrackHandler.cpp
+++ b/src/Workflow/TrackHandler.cpp
@@ -66,7 +66,7 @@ TrackHandler::addEffect( Effect *effect, quint32 trackId, const QUuid &uuid )
 }
 
 void
-TrackHandler::startRender( quint32 width, quint32 height )
+TrackHandler::startRender( quint32 width, quint32 height, double fps )
 {
     m_endReached = false;
     computeLength();
@@ -76,7 +76,7 @@ TrackHandler::startRender( quint32 width, quint32 height )
     {
         for ( unsigned int i = 0; i < m_trackCount; ++i )
         {
-            m_tracks[i]->initRender( width, height );
+            m_tracks[i]->initRender( width, height, fps );
         }
     }
 }
diff --git a/src/Workflow/TrackHandler.h b/src/Workflow/TrackHandler.h
index e8f497d..4a7b6f3 100644
--- a/src/Workflow/TrackHandler.h
+++ b/src/Workflow/TrackHandler.h
@@ -54,7 +54,7 @@ class   TrackHandler : public QObject
          */
         unsigned int            getTrackCount() const;
         qint64                  getLength() const;
-        void                    startRender( quint32 width, quint32 height );
+        void                    startRender( quint32 width, quint32 height, double fps );
         /**
          *  \param      currentFrame    The current rendering frame (ie the video frame, in all case)
          *  \param      subFrame        The type-dependent frame. IE, for a video track,
diff --git a/src/Workflow/TrackWorkflow.cpp b/src/Workflow/TrackWorkflow.cpp
index 60401b8..06af143 100644
--- a/src/Workflow/TrackWorkflow.cpp
+++ b/src/Workflow/TrackWorkflow.cpp
@@ -350,15 +350,24 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
     //Handle mixers:
     if ( m_trackType == MainWorkflow::VideoTrack )
     {
-        if ( frames[1] != NULL ) //More than one frame has been rendered, let's mix them !
+        EffectsEngine::MixerHelper* mixer = EffectsEngine::getMixer( m_mixers, currentFrame );
+        if ( mixer != NULL )
         {
-            EffectsEngine::MixerHelper* mixer = EffectsEngine::getMixer( m_mixers, currentFrame );
-            if ( mixer != NULL )
+            //FIXME: We don't handle mixer3 yet.
+            mixer->effect->process( currentFrame * 1000.0 / m_fps,
+                                    frames[0]->get()->buffer(),
+                                    frames[1] != NULL ? frames[1]->get()->buffer() : MainWorkflow::blackOutput->buffer(),
+                                    NULL, m_mixerBuffer->buffer() );
+            ret = m_mixerBuffer;
+        }
+        else //If no mixer, clean the potentially rendered extra frames.
+        {
+            for ( quint32 i = 1; i < EffectsEngine::MaxFramesForMixer; ++i )
             {
-                //FIXME: We don't handle mixer3 yet.
-                mixer->effect->process( 0.0, frames[0]->get()->buffer(),
-                                        frames[0]->get()->buffer(), NULL, m_mixerBuffer->buffer() );
-                ret = m_mixerBuffer;
+                if ( frames[i] != NULL )
+                    frames[i]->release();
+                else
+                    break;
             }
         }
     }
@@ -539,11 +548,12 @@ TrackWorkflow::unmuteClip( const QUuid &uuid )
 }
 
 void
-TrackWorkflow::initRender( quint32 width, quint32 height )
+TrackWorkflow::initRender( quint32 width, quint32 height, double fps )
 {
     QReadLocker     lock( m_clipsLock );
 
     m_mixerBuffer->resize( width, height );
+    m_fps = fps;
     QMap<qint64, ClipWorkflow*>::iterator       it = m_clips.begin();
     QMap<qint64, ClipWorkflow*>::iterator       end = m_clips.end();
     while ( it != end )
diff --git a/src/Workflow/TrackWorkflow.h b/src/Workflow/TrackWorkflow.h
index 027f4d2..c10b2a2 100644
--- a/src/Workflow/TrackWorkflow.h
+++ b/src/Workflow/TrackWorkflow.h
@@ -85,7 +85,8 @@ class   TrackWorkflow : public QObject
         void                                    muteClip( const QUuid& uuid );
         void                                    unmuteClip( const QUuid& uuid );
 
-        void                                    initRender( quint32 width, quint32 height );
+        void                                    initRender( quint32 width, quint32 height,
+                                                            double fps );
 
         bool                                    contains( const QUuid& uuid ) const;
 
@@ -122,6 +123,7 @@ class   TrackWorkflow : public QObject
         StackedBuffer<Workflow::Frame*>*        m_videoStackedBuffer;
         StackedBuffer<Workflow::AudioSample*>*  m_audioStackedBuffer;
         Workflow::Frame                         *m_mixerBuffer;
+        double                                  m_fps;
 };
 
 #endif // TRACKWORKFLOW_H



More information about the Vlmc-devel mailing list