Commit ce002d78 authored by Hugo Beauzée-Luyssen's avatar 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)
parent ce08eb4f
...@@ -71,7 +71,7 @@ void WorkflowFileRenderer::run( const QString& outputFileName, quint32 wi ...@@ -71,7 +71,7 @@ void WorkflowFileRenderer::run( const QString& outputFileName, quint32 wi
m_audioPts = 0; m_audioPts = 0;
m_mainWorkflow->setFullSpeedRender( true ); m_mainWorkflow->setFullSpeedRender( true );
m_mainWorkflow->startRender( width, height ); m_mainWorkflow->startRender( width, height, fps );
//Waiting for renderers to preload some frames: //Waiting for renderers to preload some frames:
SleepS( 1 ); SleepS( 1 );
m_mediaPlayer->play(); m_mediaPlayer->play();
......
...@@ -246,7 +246,7 @@ void WorkflowRenderer::startPreview() ...@@ -246,7 +246,7 @@ void WorkflowRenderer::startPreview()
m_mediaPlayer->setMedia( m_media ); m_mediaPlayer->setMedia( m_media );
m_mainWorkflow->setFullSpeedRender( false ); m_mainWorkflow->setFullSpeedRender( false );
m_mainWorkflow->startRender( m_width, m_height ); m_mainWorkflow->startRender( m_width, m_height, m_outputFps );
m_isRendering = true; m_isRendering = true;
m_paused = false; m_paused = false;
m_stopping = false; m_stopping = false;
......
...@@ -109,7 +109,7 @@ MainWorkflow::computeLength() ...@@ -109,7 +109,7 @@ MainWorkflow::computeLength()
} }
void 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 //Reinit the effects in case the width/height has change
m_renderStarted = true; m_renderStarted = true;
...@@ -120,7 +120,7 @@ MainWorkflow::startRender( quint32 width, quint32 height ) ...@@ -120,7 +120,7 @@ MainWorkflow::startRender( quint32 width, quint32 height )
blackOutput = new Workflow::Frame( m_width, m_height ); blackOutput = new Workflow::Frame( m_width, m_height );
memset( blackOutput->buffer(), 0, blackOutput->size() ); memset( blackOutput->buffer(), 0, blackOutput->size() );
for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i ) for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i )
m_tracks[i]->startRender( width, height ); m_tracks[i]->startRender( width, height, fps );
computeLength(); computeLength();
} }
......
...@@ -121,7 +121,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -121,7 +121,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
* \param height The height to use with this render session. * \param height The height to use with this render session.
* This will basically activate all the tracks, so they can render. * 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 * \brief Gets a frame from the workflow
* *
...@@ -355,6 +355,9 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -355,6 +355,9 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
*/ */
void stopFrameComputing(); void stopFrameComputing();
/// Pre-filled buffer used when there's nothing to render
static Workflow::Frame* blackOutput;
private: private:
MainWorkflow( int trackCount = 64 ); MainWorkflow( int trackCount = 64 );
~MainWorkflow(); ~MainWorkflow();
...@@ -408,9 +411,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -408,9 +411,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
/// Height used for the render /// Height used for the render
quint32 m_height; quint32 m_height;
/// Pre-filled buffer used when there's nothing to render
static Workflow::Frame* blackOutput;
friend class Singleton<MainWorkflow>; friend class Singleton<MainWorkflow>;
private slots: private slots:
......
...@@ -66,7 +66,7 @@ TrackHandler::addEffect( Effect *effect, quint32 trackId, const QUuid &uuid ) ...@@ -66,7 +66,7 @@ TrackHandler::addEffect( Effect *effect, quint32 trackId, const QUuid &uuid )
} }
void void
TrackHandler::startRender( quint32 width, quint32 height ) TrackHandler::startRender( quint32 width, quint32 height, double fps )
{ {
m_endReached = false; m_endReached = false;
computeLength(); computeLength();
...@@ -76,7 +76,7 @@ TrackHandler::startRender( quint32 width, quint32 height ) ...@@ -76,7 +76,7 @@ TrackHandler::startRender( quint32 width, quint32 height )
{ {
for ( unsigned int i = 0; i < m_trackCount; ++i ) for ( unsigned int i = 0; i < m_trackCount; ++i )
{ {
m_tracks[i]->initRender( width, height ); m_tracks[i]->initRender( width, height, fps );
} }
} }
} }
......
...@@ -54,7 +54,7 @@ class TrackHandler : public QObject ...@@ -54,7 +54,7 @@ class TrackHandler : public QObject
*/ */
unsigned int getTrackCount() const; unsigned int getTrackCount() const;
qint64 getLength() 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 currentFrame The current rendering frame (ie the video frame, in all case)
* \param subFrame The type-dependent frame. IE, for a video track, * \param subFrame The type-dependent frame. IE, for a video track,
......
...@@ -350,15 +350,24 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame, bool paused ) ...@@ -350,15 +350,24 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
//Handle mixers: //Handle mixers:
if ( m_trackType == MainWorkflow::VideoTrack ) 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 ); //FIXME: We don't handle mixer3 yet.
if ( mixer != NULL ) 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. if ( frames[i] != NULL )
mixer->effect->process( 0.0, frames[0]->get()->buffer(), frames[i]->release();
frames[0]->get()->buffer(), NULL, m_mixerBuffer->buffer() ); else
ret = m_mixerBuffer; break;
} }
} }
} }
...@@ -539,11 +548,12 @@ TrackWorkflow::unmuteClip( const QUuid &uuid ) ...@@ -539,11 +548,12 @@ TrackWorkflow::unmuteClip( const QUuid &uuid )
} }
void void
TrackWorkflow::initRender( quint32 width, quint32 height ) TrackWorkflow::initRender( quint32 width, quint32 height, double fps )
{ {
QReadLocker lock( m_clipsLock ); QReadLocker lock( m_clipsLock );
m_mixerBuffer->resize( width, height ); m_mixerBuffer->resize( width, height );
m_fps = fps;
QMap<qint64, ClipWorkflow*>::iterator it = m_clips.begin(); QMap<qint64, ClipWorkflow*>::iterator it = m_clips.begin();
QMap<qint64, ClipWorkflow*>::iterator end = m_clips.end(); QMap<qint64, ClipWorkflow*>::iterator end = m_clips.end();
while ( it != end ) while ( it != end )
......
...@@ -85,7 +85,8 @@ class TrackWorkflow : public QObject ...@@ -85,7 +85,8 @@ class TrackWorkflow : public QObject
void muteClip( const QUuid& uuid ); void muteClip( const QUuid& uuid );
void unmuteClip( 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; bool contains( const QUuid& uuid ) const;
...@@ -122,6 +123,7 @@ class TrackWorkflow : public QObject ...@@ -122,6 +123,7 @@ class TrackWorkflow : public QObject
StackedBuffer<Workflow::Frame*>* m_videoStackedBuffer; StackedBuffer<Workflow::Frame*>* m_videoStackedBuffer;
StackedBuffer<Workflow::AudioSample*>* m_audioStackedBuffer; StackedBuffer<Workflow::AudioSample*>* m_audioStackedBuffer;
Workflow::Frame *m_mixerBuffer; Workflow::Frame *m_mixerBuffer;
double m_fps;
}; };
#endif // TRACKWORKFLOW_H #endif // TRACKWORKFLOW_H
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