Commit 6fb8ea58 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Starting a big clean up in the workflow

Width and heigth are handled from config (but changes are not well
handled, and should lead to crash in some cases)
parent 9e190687
...@@ -48,8 +48,8 @@ void ProjectSettingsDefault::loadVideoDefaults( const QString& part ) ...@@ -48,8 +48,8 @@ void ProjectSettingsDefault::loadVideoDefaults( const QString& part )
{ {
SettingsManager* settingsMan = SettingsManager::getInstance(); SettingsManager* settingsMan = SettingsManager::getInstance();
QVariant defaultProjectFPS = 30; QVariant defaultProjectFPS = 30;
QVariant defaultProjectHeight = 800; QVariant defaultProjectWidth = 800;
QVariant defaultProjectWidth = 600; QVariant defaultProjectHeight = 600;
settingsMan->setValue( part, settingsMan->setValue( part,
"VideoProjectFPS", "VideoProjectFPS",
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "Timeline.h" #include "Timeline.h"
#include "SettingsManager.h" #include "SettingsManager.h"
uint8_t* WorkflowRenderer::m_silencedAudioBuffer = NULL; uint8_t* WorkflowRenderer::silencedAudioBuffer = NULL;
WorkflowRenderer::WorkflowRenderer() : WorkflowRenderer::WorkflowRenderer() :
m_mainWorkflow( MainWorkflow::getInstance() ), m_mainWorkflow( MainWorkflow::getInstance() ),
...@@ -44,9 +44,9 @@ void WorkflowRenderer::initializeRenderer() ...@@ -44,9 +44,9 @@ void WorkflowRenderer::initializeRenderer()
char audioParameters[256]; char audioParameters[256];
char callbacks[64]; char callbacks[64];
m_waitCond = new QWaitCondition; m_waitCond = new QWaitCondition;
m_renderVideoFrame = new unsigned char[VIDEOHEIGHT * VIDEOWIDTH * Pixel::NbComposantes]; m_renderVideoFrame = new unsigned char[m_mainWorkflow->getWidth()
* m_mainWorkflow->getHeight() * Pixel::NbComposantes];
m_videoEsHandler = new EsHandler; m_videoEsHandler = new EsHandler;
m_videoEsHandler->self = this; m_videoEsHandler->self = this;
...@@ -60,7 +60,7 @@ void WorkflowRenderer::initializeRenderer() ...@@ -60,7 +60,7 @@ void WorkflowRenderer::initializeRenderer()
m_rate = 48000; m_rate = 48000;
sprintf( videoString, "width=%i:height=%i:dar=%s:fps=%s:data=%lld:codec=%s:cat=2:caching=0", sprintf( videoString, "width=%i:height=%i:dar=%s:fps=%s:data=%lld:codec=%s:cat=2:caching=0",
VIDEOWIDTH, VIDEOHEIGHT, "4/3", "30/1", (qint64)m_videoEsHandler, "RV24" ); m_mainWorkflow->getWidth(), m_mainWorkflow->getHeight(), "4/3", "30/1", (qint64)m_videoEsHandler, "RV24" );
sprintf( audioParameters, "data=%lld:cat=1:codec=s16l:samplerate=%u:channels=%u", sprintf( audioParameters, "data=%lld:cat=1:codec=s16l:samplerate=%u:channels=%u",
(qint64)m_audioEsHandler, m_rate, m_nbChannels ); (qint64)m_audioEsHandler, m_rate, m_nbChannels );
strcpy( inputSlave, ":input-slave=imem://" ); strcpy( inputSlave, ":input-slave=imem://" );
...@@ -160,10 +160,10 @@ int WorkflowRenderer::lockAudio( WorkflowRenderer* self, int64_t *pts, size ...@@ -160,10 +160,10 @@ int WorkflowRenderer::lockAudio( WorkflowRenderer* self, int64_t *pts, size
//by 100. //by 100.
nbSample = self->m_rate / self->m_outputFps; nbSample = self->m_rate / self->m_outputFps;
unsigned int buffSize = self->m_nbChannels * 2 * nbSample; unsigned int buffSize = self->m_nbChannels * 2 * nbSample;
if ( WorkflowRenderer::m_silencedAudioBuffer == NULL ) if ( WorkflowRenderer::silencedAudioBuffer == NULL )
WorkflowRenderer::m_silencedAudioBuffer = new uint8_t[ buffSize ]; WorkflowRenderer::silencedAudioBuffer = new uint8_t[ buffSize ];
memset( WorkflowRenderer::m_silencedAudioBuffer, 0, buffSize ); memset( WorkflowRenderer::silencedAudioBuffer, 0, buffSize );
*buffer = WorkflowRenderer::m_silencedAudioBuffer; *buffer = WorkflowRenderer::silencedAudioBuffer;
*bufferSize = buffSize; *bufferSize = buffSize;
ptsDiff = self->m_pts - self->m_audioPts; ptsDiff = self->m_pts - self->m_audioPts;
} }
...@@ -449,4 +449,3 @@ void WorkflowRenderer::__videoPaused() ...@@ -449,4 +449,3 @@ void WorkflowRenderer::__videoPaused()
{ {
emit paused(); emit paused();
} }
...@@ -112,7 +112,7 @@ class WorkflowRenderer : public GenericRenderer ...@@ -112,7 +112,7 @@ class WorkflowRenderer : public GenericRenderer
* \brief When there's no sound to play, this is the buffer that'll * \brief When there's no sound to play, this is the buffer that'll
* be injected * be injected
*/ */
static uint8_t* m_silencedAudioBuffer; static uint8_t* silencedAudioBuffer;
size_t m_videoBuffSize; size_t m_videoBuffSize;
AudioClipWorkflow::AudioSample* m_renderAudioSample; AudioClipWorkflow::AudioSample* m_renderAudioSample;
Action::Stack m_actions; Action::Stack m_actions;
......
/***************************************************************************** /*****************************************************************************
* ClipWorkflow.h : Clip workflow. Will extract a single frame from a VLCMedia * ClipWorkflow.h : Clip workflow. Will extract a single frame from a VLCMedia
***************************************************************************** *****************************************************************************
* Copyright (C) 2008-2009 the VLMC team * Copyright (C) 2008-2009 the VLMC team
...@@ -23,12 +23,6 @@ ...@@ -23,12 +23,6 @@
#ifndef CLIPWORKFLOW_H #ifndef CLIPWORKFLOW_H
#define CLIPWORKFLOW_H #define CLIPWORKFLOW_H
//TODO: THIS HAS TO GO REALLY REALLY REALLY SOON !!!!
//FIXME:
//UGLY:
#define VIDEOWIDTH 640
#define VIDEOHEIGHT 480
#include <QReadWriteLock> #include <QReadWriteLock>
#include <QMutex> #include <QMutex>
#include <QObject> #include <QObject>
......
...@@ -27,13 +27,9 @@ ...@@ -27,13 +27,9 @@
#include "TrackWorkflow.h" #include "TrackWorkflow.h"
#include "TrackHandler.h" #include "TrackHandler.h"
#include "Library.h" #include "Library.h"
#include "SettingsManager.h"
//JUST FOR THE DEFINES ! LightVideoFrame* MainWorkflow::blackOutput = NULL;
//TODO:
//FIXME: remove this !
#include "ClipWorkflow.h"
LightVideoFrame* MainWorkflow::blackOutput = NULL;
MainWorkflow::MainWorkflow( int trackCount ) : MainWorkflow::MainWorkflow( int trackCount ) :
m_lengthFrame( 0 ), m_lengthFrame( 0 ),
...@@ -46,6 +42,13 @@ MainWorkflow::MainWorkflow( int trackCount ) : ...@@ -46,6 +42,13 @@ MainWorkflow::MainWorkflow( int trackCount ) :
m_synchroneRenderWaitConditionMutex = new QMutex; m_synchroneRenderWaitConditionMutex = new QMutex;
m_pauseWaitCond = new WaitCondition; m_pauseWaitCond = new WaitCondition;
const SettingValue* width = SettingsManager::getInstance()->getValue( "project", "VideoProjectWidth" );
connect( width, SIGNAL( changed( QVariant ) ), this, SLOT( widthChanged( QVariant ) ) );
m_width = width->get().toUInt();
const SettingValue* height = SettingsManager::getInstance()->getValue( "project", "VideoProjectHeight" );
connect( height, SIGNAL( changed( QVariant ) ), this, SLOT( widthChanged( QVariant ) ) );
m_height = height->get().toUInt();
m_effectEngine = new EffectsEngine; m_effectEngine = new EffectsEngine;
m_effectEngine->disable(); m_effectEngine->disable();
...@@ -62,9 +65,10 @@ MainWorkflow::MainWorkflow( int trackCount ) : ...@@ -62,9 +65,10 @@ MainWorkflow::MainWorkflow( int trackCount ) :
m_currentFrame[i] = 0; m_currentFrame[i] = 0;
} }
m_outputBuffers = new OutputBuffers; m_outputBuffers = new OutputBuffers;
blackOutput = new LightVideoFrame( VIDEOHEIGHT * VIDEOWIDTH * Pixel::NbComposantes );
memset( (*blackOutput)->frame.octets, 0, (*blackOutput)->nboctets );
m_nbTrackHandlerToRenderMutex = new QMutex; m_nbTrackHandlerToRenderMutex = new QMutex;
blackOutput = new LightVideoFrame( m_width * m_height * Pixel::NbComposantes );
memset( (*blackOutput)->frame.octets, 0, (*blackOutput)->nboctets );
} }
MainWorkflow::~MainWorkflow() MainWorkflow::~MainWorkflow()
...@@ -472,3 +476,24 @@ qint64 MainWorkflow::getCurrentFrame() const ...@@ -472,3 +476,24 @@ qint64 MainWorkflow::getCurrentFrame() const
return m_currentFrame[MainWorkflow::VideoTrack]; return m_currentFrame[MainWorkflow::VideoTrack];
} }
void MainWorkflow::widthChanged( const QVariant& width )
{
m_width = width.toUInt();
}
void MainWorkflow::heightChanged( const QVariant& height )
{
m_height = height.toUInt();
}
uint32_t MainWorkflow::getWidth() const
{
return m_width;
}
uint32_t MainWorkflow::getHeight() const
{
return m_height;
}
...@@ -142,14 +142,15 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -142,14 +142,15 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
void setFullSpeedRender( bool value ); void setFullSpeedRender( bool value );
int getTrackCount( MainWorkflow::TrackType trackType ) const; int getTrackCount( MainWorkflow::TrackType trackType ) const;
uint32_t getWidth() const;
uint32_t getHeight() const;
private: private:
MainWorkflow( int trackCount = 64 ); MainWorkflow( int trackCount = 64 );
~MainWorkflow(); ~MainWorkflow();
void computeLength(); void computeLength();
void activateTrack( unsigned int trackId ); void activateTrack( unsigned int trackId );
static LightVideoFrame* blackOutput;
private: private:
QReadWriteLock* m_currentFrameLock; QReadWriteLock* m_currentFrameLock;
qint64* m_currentFrame; qint64* m_currentFrame;
...@@ -171,6 +172,10 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -171,6 +172,10 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
OutputBuffers* m_outputBuffers; OutputBuffers* m_outputBuffers;
EffectsEngine* m_effectEngine; EffectsEngine* m_effectEngine;
uint32_t m_width;
uint32_t m_height;
static LightVideoFrame* blackOutput;
friend class Singleton<MainWorkflow>; friend class Singleton<MainWorkflow>;
...@@ -179,6 +184,9 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -179,6 +184,9 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
void tracksUnpaused(); void tracksUnpaused();
void tracksRenderCompleted(); void tracksRenderCompleted();
void tracksEndReached(); void tracksEndReached();
void widthChanged( const QVariant& );
void heightChanged( const QVariant& );
public slots: public slots:
void loadProject( const QDomElement& project ); void loadProject( const QDomElement& project );
......
...@@ -21,10 +21,13 @@ ...@@ -21,10 +21,13 @@
*****************************************************************************/ *****************************************************************************/
#include "VideoClipWorkflow.h" #include "VideoClipWorkflow.h"
#include "MainWorkflow.h"
VideoClipWorkflow::VideoClipWorkflow( Clip* clip ) : ClipWorkflow( clip ) VideoClipWorkflow::VideoClipWorkflow( Clip* clip ) : ClipWorkflow( clip )
{ {
m_buffer = new LightVideoFrame( VIDEOHEIGHT * VIDEOWIDTH * Pixel::NbComposantes ); m_buffer = new LightVideoFrame( MainWorkflow::getInstance()->getWidth()
* MainWorkflow::getInstance()->getHeight()
* Pixel::NbComposantes );
} }
VideoClipWorkflow::~VideoClipWorkflow() VideoClipWorkflow::~VideoClipWorkflow()
...@@ -53,18 +56,15 @@ void VideoClipWorkflow::initVlcOutput() ...@@ -53,18 +56,15 @@ void VideoClipWorkflow::initVlcOutput()
else else
m_vlcMedia->addOption( ":sout-smem-time-sync" ); m_vlcMedia->addOption( ":sout-smem-time-sync" );
sprintf( buffer, ":sout-transcode-width=%i", VIDEOWIDTH ); sprintf( buffer, ":sout-transcode-width=%i", MainWorkflow::getInstance()->getWidth() );
m_vlcMedia->addOption( buffer ); m_vlcMedia->addOption( buffer );
sprintf( buffer, ":sout-transcode-height=%i", VIDEOHEIGHT ); sprintf( buffer, ":sout-transcode-height=%i", MainWorkflow::getInstance()->getHeight() );
m_vlcMedia->addOption( buffer ); m_vlcMedia->addOption( buffer );
//Forced output fps //Forced output fps
sprintf( buffer, ":sout-transcode-fps=%f", (float)Clip::DefaultFPS ); sprintf( buffer, ":sout-transcode-fps=%f", (float)Clip::DefaultFPS );
m_vlcMedia->addOption( buffer ); m_vlcMedia->addOption( buffer );
//sprintf( buffer, "sout-smem-video-pitch=%i", VIDEOWIDTH * 3 );
//m_vlcMedia->addOption( buffer );
} }
void* VideoClipWorkflow::getLockCallback() void* VideoClipWorkflow::getLockCallback()
......
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