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
}
Workflow::OutputBuffer*
AudioClipWorkflow::getOutput( ClipWorkflow::GetMode mode )
AudioClipWorkflow::getOutput( ClipWorkflow::GetMode mode, qint64 )
{
QMutexLocker lock( m_renderLock );
......
......@@ -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;
......
......@@ -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();
......
......@@ -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 )
......
......@@ -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;
......
......@@ -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 ||
......
......@@ -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 );
}
......@@ -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;
};
......
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