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

Workflow: Getting rid of void*.

Buffers are now hard typed.
parent 219da3e0
......@@ -159,13 +159,13 @@ int
WorkflowRenderer::lockVideo( EsHandler *handler, qint64 *pts, size_t *bufferSize, const void **buffer )
{
qint64 ptsDiff = 0;
MainWorkflow::OutputBuffers* ret;
Workflow::Frame *ret;
if ( m_stopping == true )
return 1;
ret = m_mainWorkflow->getOutput( Workflow::VideoTrack, m_paused );
ptsDiff = ret->video->ptsDiff;
ret = static_cast<Workflow::Frame*>( m_mainWorkflow->getOutput( Workflow::VideoTrack, m_paused ) );
ptsDiff = ret->ptsDiff;
if ( ptsDiff == 0 )
{
//If no ptsDiff has been computed, we have to fake it, so we compute
......@@ -175,13 +175,13 @@ WorkflowRenderer::lockVideo( EsHandler *handler, qint64 *pts, size_t *bufferSize
}
{
QReadLocker lock( m_effectsLock );
EffectsEngine::applyFilters( m_filters, ret->video,
EffectsEngine::applyFilters( m_filters, ret,
m_mainWorkflow->getCurrentFrame(),
m_mainWorkflow->getCurrentFrame() * 1000.0 / handler->fps );
}
m_pts = *pts = ptsDiff + m_pts;
*buffer = ret->video->buffer();
*bufferSize = ret->video->size();
*buffer = ret->buffer();
*bufferSize = ret->size();
return 0;
}
......@@ -194,9 +194,8 @@ WorkflowRenderer::lockAudio( EsHandler *handler, qint64 *pts, size_t *bufferSize
if ( m_stopping == false && m_paused == false )
{
MainWorkflow::OutputBuffers* ret = m_mainWorkflow->getOutput( Workflow::AudioTrack,
m_paused );
renderAudioSample = ret->audio;
renderAudioSample = static_cast<Workflow::AudioSample*>( m_mainWorkflow->getOutput( Workflow::AudioTrack,
m_paused ) );
}
else
renderAudioSample = NULL;
......
......@@ -77,7 +77,7 @@ AudioClipWorkflow::getUnlockCallback() const
return reinterpret_cast<void*>( &AudioClipWorkflow::unlock );
}
void*
Workflow::OutputBuffer*
AudioClipWorkflow::getOutput( ClipWorkflow::GetMode mode )
{
QMutexLocker lock( m_renderLock );
......
......@@ -42,7 +42,7 @@ class AudioClipWorkflow : public ClipWorkflow
~AudioClipWorkflow();
void *getLockCallback() const;
void *getUnlockCallback() const;
virtual void *getOutput( ClipWorkflow::GetMode mode );
virtual Workflow::OutputBuffer *getOutput( ClipWorkflow::GetMode mode );
virtual void saveEffects( QXmlStreamWriter & ) const {} //Nothing to do here now.
virtual bool appendEffect( Effect *, qint64, qint64 ) { return false; } //Nothing to do here now.
protected:
......
......@@ -25,6 +25,7 @@
#include "mdate.h"
#include "ClipHelper.h"
#include "Types.h"
#include <QObject>
#include <QUuid>
......@@ -106,7 +107,7 @@ class ClipWorkflow : public QObject
* therefore, you can call this method blindly, without taking care
* of the rendering process advancement.
*/
virtual void* getOutput( ClipWorkflow::GetMode mode ) = 0;
virtual Workflow::OutputBuffer *getOutput( ClipWorkflow::GetMode mode ) = 0;
void postGetOutput();
virtual void initVlcOutput() = 0;
void initialize();
......
......@@ -84,7 +84,7 @@ ImageClipWorkflow::getUnlockCallback() const
return reinterpret_cast<void*>( &ImageClipWorkflow::unlock );
}
void*
Workflow::OutputBuffer*
ImageClipWorkflow::getOutput( ClipWorkflow::GetMode )
{
QMutexLocker lock( m_renderLock );
......
......@@ -35,7 +35,7 @@ class ImageClipWorkflow : public ClipWorkflow
void *getLockCallback() const;
void *getUnlockCallback() const;
virtual void *getOutput( ClipWorkflow::GetMode mode );
virtual Workflow::OutputBuffer *getOutput( ClipWorkflow::GetMode mode );
virtual void saveEffects( QXmlStreamWriter & ) const {} //Nothing to do here now.
virtual bool appendEffect( Effect *, qint64, qint64 ) { return false; } //Nothing to do here now.
protected:
......
......@@ -59,7 +59,6 @@ MainWorkflow::MainWorkflow( int trackCount ) :
this, SLOT( tracksEndReached() ) );
m_currentFrame[i] = 0;
}
m_outputBuffers = new OutputBuffers;
}
MainWorkflow::~MainWorkflow()
......@@ -125,7 +124,7 @@ MainWorkflow::startRender( quint32 width, quint32 height, double fps )
computeLength();
}
MainWorkflow::OutputBuffers*
Workflow::OutputBuffer*
MainWorkflow::getOutput( Workflow::TrackType trackType, bool paused )
{
QMutexLocker lock( m_renderStartedMutex );
......@@ -134,22 +133,16 @@ MainWorkflow::getOutput( Workflow::TrackType trackType, bool paused )
{
QReadLocker lock2( m_currentFrameLock );
void* ret = m_tracks[trackType]->getOutput( m_currentFrame[Workflow::VideoTrack],
m_currentFrame[trackType], paused );
Workflow::OutputBuffer *ret = m_tracks[trackType]->getOutput( m_currentFrame[Workflow::VideoTrack],
m_currentFrame[trackType], paused );
if ( trackType == Workflow::VideoTrack )
{
Workflow::Frame* frame = static_cast<Workflow::Frame*>( ret );
if ( frame == NULL )
m_outputBuffers->video = MainWorkflow::blackOutput;
else
m_outputBuffers->video = frame;
}
else
{
m_outputBuffers->audio = static_cast<Workflow::AudioSample*>( ret );
if ( ret == NULL )
return MainWorkflow::blackOutput;
}
return ret;
}
return m_outputBuffers;
return NULL;
}
void
......
......@@ -56,16 +56,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
Q_OBJECT
public:
/**
* \struct Represents an output, with both audio and video buffers.
* Note that an OutputBuffers will not necessarly have its both
* fields filed out.
*/
struct OutputBuffers
{
Workflow::Frame *video;
Workflow::AudioSample *audio;
};
/**
* \enum Used to know which part required a change of rendered frame.
* The main use of this enum is to avoid infinite information propagation
......@@ -125,7 +115,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
* \param trackType The type of track you wish to get the render from.
* \param paused The paused state of the renderer
*/
OutputBuffers* getOutput( Workflow::TrackType trackType, bool paused );
Workflow::OutputBuffer *getOutput( Workflow::TrackType trackType, bool paused );
/**
* \brief Set the workflow position by the desired frame
* \param currentFrame: The desired frame to render from
......@@ -395,8 +385,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
/// Contains the trackhandler, indexed by Workflow::TrackType
TrackHandler** m_tracks;
/// Pre-allocated buffer, that will contain every computed outputs.
OutputBuffers* m_outputBuffers;
/// Width used for the render
quint32 m_width;
......
......@@ -100,7 +100,7 @@ TrackHandler::getLength() const
return m_length;
}
void*
Workflow::OutputBuffer*
TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
{
bool validTrack = false;
......@@ -110,7 +110,7 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
if ( m_tracks[i].activated() == false || m_tracks[i]->hasFrameToRender( currentFrame ) )
continue ;
validTrack = true;
void* ret = m_tracks[i]->getOutput( currentFrame, subFrame, paused );
Workflow::OutputBuffer *ret = m_tracks[i]->getOutput( currentFrame, subFrame, paused );
if ( ret == NULL )
continue ;
else
......
......@@ -62,7 +62,7 @@ class TrackHandler : public QObject
* track, it will be different.
* \param paused The renderer paused state
*/
void *getOutput( qint64 currentFrame, qint64 subFrame,
Workflow::OutputBuffer *getOutput( qint64 currentFrame, qint64 subFrame,
bool paused );
qint64 getClipPosition( const QUuid& uuid, unsigned int trackId ) const;
void stop();
......
......@@ -152,7 +152,7 @@ TrackWorkflow::getClip( const QUuid& uuid )
return NULL;
}
void*
Workflow::OutputBuffer*
TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
qint64 start , bool needRepositioning,
bool renderOneFrame, bool paused )
......@@ -265,7 +265,7 @@ TrackWorkflow::stop()
m_lastFrame = 0;
}
void*
Workflow::OutputBuffer*
TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
{
QReadLocker lock( m_clipsLock );
......@@ -273,7 +273,7 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
QMap<qint64, ClipWorkflow*>::iterator it = m_clips.begin();
QMap<qint64, ClipWorkflow*>::iterator end = m_clips.end();
bool needRepositioning;
void *ret = NULL;
Workflow::OutputBuffer *ret = NULL;
Workflow::Frame *frames[EffectsEngine::MaxFramesForMixer];
quint32 frameId = 0;
bool renderOneFrame = false;
......@@ -312,7 +312,7 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
renderOneFrame, paused );
if ( m_trackType == Workflow::VideoTrack )
{
frames[frameId] = reinterpret_cast<Workflow::Frame*>( ret );
frames[frameId] = static_cast<Workflow::Frame*>( ret );
++frameId;
}
}
......@@ -344,11 +344,7 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
ret = frames[0];
}
m_lastFrame = subFrame;
if ( ret == NULL )
return NULL;
if ( m_trackType == Workflow::VideoTrack )
return reinterpret_cast<Workflow::Frame*>( ret );
return reinterpret_cast<Workflow::AudioSample*>( ret );
return ret;
}
void TrackWorkflow::moveClip( const QUuid& id, qint64 startingFrame )
......
......@@ -49,7 +49,7 @@ class TrackWorkflow : public QObject
TrackWorkflow( Workflow::TrackType type );
~TrackWorkflow();
void* getOutput( qint64 currentFrame,
Workflow::OutputBuffer *getOutput( qint64 currentFrame,
qint64 subFrame, bool paused );
qint64 getLength() const;
void stop();
......@@ -94,7 +94,7 @@ class TrackWorkflow : public QObject
private:
void computeLength();
void* renderClip( ClipWorkflow* cw, qint64 currentFrame,
Workflow::OutputBuffer *renderClip( ClipWorkflow* cw, qint64 currentFrame,
qint64 start, bool needRepositioning,
bool renderOneFrame, bool paused );
void preloadClip( ClipWorkflow* cw );
......
......@@ -27,6 +27,7 @@ using namespace Workflow;
#include <cstring> //memcpy
Frame::Frame() :
OutputBuffer( VideoTrack ),
ptsDiff( 0 ),
m_width( 0 ),
m_height( 0 ),
......@@ -37,6 +38,7 @@ Frame::Frame() :
}
Frame::Frame( quint32 width, quint32 height ) :
OutputBuffer( VideoTrack ),
ptsDiff( 0 ),
m_width( width ),
m_height( height )
......
......@@ -39,7 +39,14 @@ namespace Workflow
NbTrackType, ///< Used to know how many types we have
};
class Frame
struct OutputBuffer
{
TrackType type;
protected:
OutputBuffer( TrackType _type ) : type( _type ) {}
};
class Frame : public OutputBuffer
{
public:
explicit Frame();
......@@ -83,8 +90,9 @@ namespace Workflow
quint32 m_size;
quint32 m_nbPixels;
};
struct AudioSample
struct AudioSample : public OutputBuffer
{
AudioSample() : OutputBuffer( AudioTrack ){}
unsigned char* buff;
size_t size;
quint32 nbSample;
......
......@@ -118,7 +118,7 @@ VideoClipWorkflow::getUnlockCallback() const
return reinterpret_cast<void*>( &VideoClipWorkflow::unlock );
}
void*
Workflow::OutputBuffer*
VideoClipWorkflow::getOutput( ClipWorkflow::GetMode mode )
{
QMutexLocker lock( m_renderLock );
......
......@@ -39,7 +39,7 @@ class VideoClipWorkflow : public ClipWorkflow
~VideoClipWorkflow();
void *getLockCallback() const;
void *getUnlockCallback() const;
virtual void *getOutput( ClipWorkflow::GetMode mode );
virtual Workflow::OutputBuffer *getOutput( ClipWorkflow::GetMode mode );
virtual bool appendEffect( Effect *effect, qint64 start = 0, qint64 end = -1 );
virtual void setTime( qint64 time, qint64 frame );
virtual void saveEffects( QXmlStreamWriter &project ) const;
......
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