Commit 587a27a2 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Merge new version with Workflow

parent c9810abf
......@@ -46,7 +46,7 @@ void EffectsEngine::render( void )
// return ;
// }
void EffectsEngine::setInputFrame( VideoFrame& frame, quint32 tracknumber )
void EffectsEngine::setInputFrame( LightVideoFrame& frame, quint32 tracknumber )
{
QWriteLocker lock( m_inputLock );
......@@ -56,9 +56,9 @@ void EffectsEngine::setInputFrame( VideoFrame& frame, quint32 tracknumber )
// TO REPLACE BY A REF
VideoFrame const & EffectsEngine::getOutputFrame( quint32 tracknumber ) const
LightVideoFrame const & EffectsEngine::getOutputFrame( quint32 tracknumber ) const
{
return ( ( VideoFrame const & )( ( LightVideoFrame const & ) (m_videoOutputs[tracknumber] ) ) );
return m_videoOutputs[tracknumber];
}
//
......
......@@ -32,8 +32,8 @@ class EffectsEngine
// INPUTS & OUTPUTS METHODS
/* void setClock( Parameter currentframenumber ); */
void setInputFrame( VideoFrame& frame, quint32 tracknumber );
VideoFrame const & getOutputFrame( quint32 tracknumber ) const;
void setInputFrame( LightVideoFrame& frame, quint32 tracknumber );
LightVideoFrame const & getOutputFrame( quint32 tracknumber ) const;
private:
......
......@@ -51,48 +51,49 @@ LightVideoFrame::LightVideoFrame(LightVideoFrame const & tocopy) : m_videoFrame(
LightVideoFrame& LightVideoFrame::operator=(LightVideoFrame const & tocopy)
{
if ( m_videoFrame->frame.octets == NULL )
{
if ( tocopy.m_videoFrame->frame.octets != NULL )
{
m_videoFrame->frame.octets = new quint8[tocopy.m_videoFrame->nboctets];
m_videoFrame->nboctets = tocopy.m_videoFrame->nboctets;
m_videoFrame->nbpixels = tocopy.m_videoFrame->nboctets / Pixel::NbComposantes;
quint32 i;
for ( i = 0; i < m_videoFrame->nboctets; ++i )
m_videoFrame->frame.octets[i] = tocopy.m_videoFrame->frame.octets[i];
}
}
else
{
if ( tocopy.m_videoFrame->frame.octets != NULL )
{
if ( m_videoFrame->nboctets != tocopy.m_videoFrame->nboctets )
{
qDebug() << __LINE__ << "\n"
<< "this pixels = " << m_videoFrame->nbpixels
<< "tocopy.m_videoFrame pixels = " << tocopy.m_videoFrame->nbpixels;
delete [] m_videoFrame->frame.octets;
m_videoFrame->frame.octets = new quint8[tocopy.m_videoFrame->nboctets];
m_videoFrame->nboctets = tocopy.m_videoFrame->nboctets;
m_videoFrame->nbpixels = tocopy.m_videoFrame->nboctets / Pixel::NbComposantes;
}
quint32 i;
for ( i = 0; i < m_videoFrame->nboctets; ++i )
m_videoFrame->frame.octets[i] = tocopy.m_videoFrame->frame.octets[i];
}
else
{
delete [] m_videoFrame->frame.octets;
m_videoFrame->frame.octets = NULL;
m_videoFrame->nboctets = 0;
m_videoFrame->nbpixels = 0;
}
}
return ( *this );
// if ( m_videoFrame->frame.octets == NULL )
// {
// if ( tocopy.m_videoFrame->frame.octets != NULL )
// {
// m_videoFrame->frame.octets = new quint8[tocopy.m_videoFrame->nboctets];
// m_videoFrame->nboctets = tocopy.m_videoFrame->nboctets;
// m_videoFrame->nbpixels = tocopy.m_videoFrame->nboctets / Pixel::NbComposantes;
// quint32 i;
//
// for ( i = 0; i < m_videoFrame->nboctets; ++i )
// m_videoFrame->frame.octets[i] = tocopy.m_videoFrame->frame.octets[i];
// }
// }
// else
// {
// if ( tocopy.m_videoFrame->frame.octets != NULL )
// {
// if ( m_videoFrame->nboctets != tocopy.m_videoFrame->nboctets )
// {
// qDebug() << __LINE__ << "\n"
// << "this pixels = " << m_videoFrame->nbpixels
// << "tocopy.m_videoFrame pixels = " << tocopy.m_videoFrame->nbpixels;
// delete [] m_videoFrame->frame.octets;
// m_videoFrame->frame.octets = new quint8[tocopy.m_videoFrame->nboctets];
// m_videoFrame->nboctets = tocopy.m_videoFrame->nboctets;
// m_videoFrame->nbpixels = tocopy.m_videoFrame->nboctets / Pixel::NbComposantes;
// }
// quint32 i;
//
// for ( i = 0; i < m_videoFrame->nboctets; ++i )
// m_videoFrame->frame.octets[i] = tocopy.m_videoFrame->frame.octets[i];
// }
// else
// {
// delete [] m_videoFrame->frame.octets;
// m_videoFrame->frame.octets = NULL;
// m_videoFrame->nboctets = 0;
// m_videoFrame->nbpixels = 0;
// }
// }
//
m_videoFrame = tocopy.m_videoFrame;
return ( *this );
};
LightVideoFrame::LightVideoFrame(quint32 nboctets)
......
......@@ -83,15 +83,14 @@ MixerEffect::~MixerEffect()
void MixerEffect::render( void )
{
quint32 i;
QHash< QString, InSlot<LightVideoFrame> >::iterator it = m_videoInputs.begin();
QHash< QString, InSlot<LightVideoFrame> >::iterator end = m_videoInputs.end();
while ( it != end )
{
const VideoFrame& lvf = static_cast<VideoFrame>( static_cast<LightVideoFrame>( ( it.value() ) ) );
if ( lvf.rvf.raw != NULL )
const LightVideoFrame& lvf = it.value();
if ( lvf->frame.octets != NULL )
{
m_videoOutputs["out"] << lvf;
return ;
......
......@@ -22,12 +22,12 @@ void PouetEffect::render( void )
LightVideoFrame tmp;
( m_videoInputs["in"] ) >> tmp;
if (tmp.rvf.raw != NULL)
if (tmp->frame.octets != NULL)
{
for ( i = 0; i < tmp.nbpixels; ++i )
for ( i = 0; i < tmp->nbpixels; ++i )
{
tmp.rvf.pixel[i].Red = 0;
tmp.rvf.pixel[i].Blue = 0;
tmp->frame.pixels[i].Red = 0;
tmp->frame.pixels[i].Blue = 0;
}
(m_videoOutputs["out"]) << tmp;
}
......
......@@ -73,11 +73,7 @@ class WorkflowRenderer : public GenericRenderer
bool m_stopping;
private:
<<<<<<< HEAD:src/Renderer/WorkflowRenderer.h
MainWorkflow::OutputBuffers* m_lastFrame;
=======
const VideoFrame* m_lastFrame;
>>>>>>> Merging EffectsEngine with Workflow.:src/Renderer/WorkflowRenderer.h
QStack<Actions> m_actions;
QReadWriteLock* m_actionsLock;
bool m_pauseAsked;
......
......@@ -25,7 +25,7 @@
#include "vlmc.h"
#include "ClipWorkflow.h"
#include "Pool.hpp"
#include "VideoFrame.h"
#include "LightVideoFrame.h"
ClipWorkflow::ClipWorkflow( Clip::Clip* clip ) :
m_clip( clip ),
......@@ -36,7 +36,6 @@ ClipWorkflow::ClipWorkflow( Clip::Clip* clip ) :
m_state( ClipWorkflow::Stopped ),
m_fullSpeedRender( false )
{
m_frame = new VideoFrame( VIDEOHEIGHT * VIDEOWIDTH * 4 );
m_stateLock = new QReadWriteLock;
m_requiredStateLock = new QMutex;
m_waitCond = new QWaitCondition;
......
......@@ -30,17 +30,15 @@
//FIXME: remove this !
#include "ClipWorkflow.h"
VideoFrame* MainWorkflow::nullOutput = NULL;
VideoFrame* MainWorkflow::blackOutput = NULL;
unsigned char* MainWorkflow::blackOutput = NULL;
MainWorkflow::MainWorkflow( int trackCount ) :
m_currentFrame( 0 ),
m_length( 0 ),
m_renderStarted( false )
{
MainWorkflow::nullOutput = new VideoFrame();
MainWorkflow::blackOutput = new VideoFrame( VIDEOWIDTH * VIDEOHEIGHT * 3 );
memset(MainWorkflow::blackOutput->rvf.raw, 0, (VIDEOWIDTH * VIDEOHEIGHT * 3) );
MainWorkflow::blackOutput = new unsigned char[VIDEOHEIGHT * VIDEOWIDTH * 3];
memset( MainWorkflow::blackOutput, 0, VIDEOHEIGHT * VIDEOWIDTH * 3 );
m_renderStartedLock = new QReadWriteLock;
m_renderMutex = new QMutex;
......@@ -206,7 +204,48 @@ Clip* MainWorkflow::removeClip( const QUuid& uuid, unsigned int trackId, T
return m_tracks[trackType]->removeClip( uuid, trackId );
}
<<<<<<< HEAD:src/Workflow/MainWorkflow.cpp
MainWorkflow::OutputBuffers* MainWorkflow::getSynchroneOutput()
=======
void MainWorkflow::trackUnpaused()
{
m_nbTracksToUnpause.fetchAndAddAcquire( -1 );
if ( m_nbTracksToUnpause <= 0 )
{
m_paused = false;
emit mainWorkflowUnpaused();
}
}
void MainWorkflow::tracksRenderCompleted( unsigned int trackId )
{
// qDebug() << "tracksRenderCompleted";
QMutexLocker lockNbTracks( m_nbTracksToRenderMutex );
--m_nbTracksToRender;
{
LightVideoFrame* buff = m_tracks[trackId]->getSynchroneOutput();
if ( buff == NULL )
m_effectEngine->setInputFrame( *MainWorkflow::nullOutput, trackId );
else
m_effectEngine->setInputFrame( *buff, trackId );
}
//We check for minus or equal, since we can have 0 frame to compute,
//therefore, m_nbTracksToRender will be equal to -1
if ( m_nbTracksToRender <= 0 )
{
// qDebug() << "main workflow render completed";
//Just a synchronisation barriere
{
QMutexLocker lock( m_synchroneRenderWaitConditionMutex );
}
//FIXME: This is uggly.... god probably just killed a kitten :(
m_synchroneRenderWaitCondition->wakeAll();
}
}
const LightVideoFrame* MainWorkflow::getSynchroneOutput()
>>>>>>> Merge new version with Workflow:src/Workflow/MainWorkflow.cpp
{
m_synchroneRenderWaitConditionMutex->lock();
getOutput();
......@@ -216,9 +255,17 @@ MainWorkflow::OutputBuffers* MainWorkflow::getSynchroneOutput()
m_effectEngine->render();
m_synchroneRenderingBuffer = &( m_effectEngine->getOutputFrame( 0 ) );
m_synchroneRenderWaitConditionMutex->unlock();
<<<<<<< HEAD:src/Workflow/MainWorkflow.cpp
m_outputBuffers->video = m_tracks[TrackWorkflow::Video]->getSynchroneOutput();
m_outputBuffers->audio = m_tracks[TrackWorkflow::Audio]->getSynchroneOutput();
return m_outputBuffers;
=======
if ( (*m_synchroneRenderingBuffer)->frame.octets == NULL )
return MainWorkflow::blackOutput;
return m_synchroneRenderingBuffer;
>>>>>>> Merge new version with Workflow:src/Workflow/MainWorkflow.cpp
}
void MainWorkflow::cancelSynchronisation()
......
......@@ -34,7 +34,7 @@
#include "TrackWorkflow.h"
#include "TrackHandler.h"
#include "Clip.h"
#include "VideoFrame.h"
#include "LightVideoFrame.h"
#include "EffectsEngine.h"
class MainWorkflow : public QObject, public Singleton<MainWorkflow>
......@@ -124,8 +124,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
void activateTrack( unsigned int trackId );
private:
static VideoFrame* nullOutput;
static VideoFrame* blackOutput;
static unsigned char* blackOutput;
qint64 m_currentFrame;
qint64 m_length;
......
......@@ -479,7 +479,7 @@ void TrackWorkflow::clipWorkflowRenderCompleted( ClipWorkflow* cw )
// qDebug() << "Track render not completed yet";
}
VideoFrame* TrackWorkflow::getSynchroneOutput()
LightVideoFrame* TrackWorkflow::getSynchroneOutput()
{
return m_synchroneRenderBuffer;
}
......
......@@ -32,7 +32,7 @@
#include <QDomElement>
#include "ClipWorkflow.h"
#include "VideoFrame.h"
#include "LightVideoFrame.h"
//TODO: REMOVE THIS
#ifndef FPS
......@@ -73,7 +73,7 @@ class TrackWorkflow : public QObject
/**
* Returns the output that has been computed in synchrone mode.
*/
VideoFrame* getSynchroneOutput();
LightVideoFrame* getSynchroneOutput();
//FIXME: this won't be reliable as soon as we change the fps from the configuration
static const unsigned int nbFrameBeforePreload = 60;
......@@ -120,7 +120,7 @@ class TrackWorkflow : public QObject
QAtomicInt m_nbClipToUnpause;
QAtomicInt m_nbClipToRender;
VideoFrame* m_synchroneRenderBuffer;
LightVideoFrame* m_synchroneRenderBuffer;
TrackType m_trackType;
......
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