Commit 93a4c87c authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

VideoClipWorkflow: Compute effect in getOutput.

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