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

Removing LightVideoFrame, and using simpler class Frame.

parent 8b79091a
......@@ -6,7 +6,6 @@
SET(VLMC_SRCS
Commands/Commands.cpp
EffectsEngine/PluginsAPI/LightVideoFrame.cpp
Settings/SettingsManager.cpp
Settings/SettingValue.cpp
Library/Library.cpp
......@@ -38,6 +37,7 @@ SET(VLMC_SRCS
Workflow/StackedBuffer.hpp
Workflow/TrackHandler.cpp
Workflow/TrackWorkflow.cpp
Workflow/Types.cpp
Workflow/VideoClipWorkflow.cpp
)
......@@ -71,6 +71,7 @@ SET (VLMC_HDRS
Workflow/MainWorkflow.h
Workflow/TrackHandler.h
Workflow/TrackWorkflow.h
Workflow/Types.h
Workflow/VideoClipWorkflow.h
)
......@@ -89,7 +90,6 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}/src
.
Commands
EffectsEngine/PluginsAPI
Settings
Gui
Gui/import
......
......@@ -24,7 +24,6 @@
#include "WorkflowFileRenderer.h"
#include "SettingsManager.h"
#include "VLCMedia.h"
#include "LightVideoFrame.h"
#include "VLCMediaPlayer.h"
#include <QTime>
......@@ -98,7 +97,7 @@ float WorkflowFileRenderer::getFps() const
int
WorkflowFileRenderer::lock( void *datas, const char* cookie, qint64 *dts, qint64 *pts,
quint32 *flags, size_t *bufferSize, void **buffer )
quint32 *flags, size_t *bufferSize, const void **buffer )
{
int ret = WorkflowRenderer::lock( datas, cookie, dts, pts, flags, bufferSize, buffer );
EsHandler* handler = reinterpret_cast<EsHandler*>( datas );
......
......@@ -46,7 +46,7 @@ public:
quint32 height, double fps, quint32 vbitrate,
quint32 abitrate);
static int lock( void* datas, const char* cookie, qint64 *dts, qint64 *pts,
quint32 *flags, size_t *bufferSize, void **buffer );
quint32 *flags, size_t *bufferSize, const void **buffer );
virtual float getFps() const;
private:
......
......@@ -27,16 +27,16 @@
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include "WorkflowRenderer.h"
#include "timeline/Timeline.h"
#include "SettingsManager.h"
#include "LightVideoFrame.h"
#include "MainWorkflow.h"
#include "GenericRenderer.h"
#include "AudioClipWorkflow.h"
#include "VLCMedia.h"
#include "Clip.h"
#include "GenericRenderer.h"
#include "MainWorkflow.h"
#include "SettingsManager.h"
#include "VLCMedia.h"
#include "VLCMediaPlayer.h"
#include "WorkflowRenderer.h"
#include "Workflow/Types.h"
#include "timeline/Timeline.h"
WorkflowRenderer::WorkflowRenderer() :
m_mainWorkflow( MainWorkflow::getInstance() ),
......@@ -119,7 +119,7 @@ WorkflowRenderer::setupRenderer( quint32 width, quint32 height, double fps )
int
WorkflowRenderer::lock( void *datas, const char* cookie, qint64 *dts, qint64 *pts,
quint32 *flags, size_t *bufferSize, void **buffer )
quint32 *flags, size_t *bufferSize, const void **buffer )
{
int ret = 1;
EsHandler* handler = reinterpret_cast<EsHandler*>( datas );
......@@ -151,7 +151,7 @@ WorkflowRenderer::lock( void *datas, const char* cookie, qint64 *dts, qint64 *pt
}
int
WorkflowRenderer::lockVideo( EsHandler *handler, qint64 *pts, size_t *bufferSize, void **buffer )
WorkflowRenderer::lockVideo( EsHandler *handler, qint64 *pts, size_t *bufferSize, const void **buffer )
{
qint64 ptsDiff = 0;
MainWorkflow::OutputBuffers* ret;
......@@ -161,8 +161,8 @@ WorkflowRenderer::lockVideo( EsHandler *handler, qint64 *pts, size_t *bufferSize
else
{
ret = m_mainWorkflow->getOutput( MainWorkflow::VideoTrack, m_paused );
m_videoBuffSize = (*(ret->video))->nboctets;
ptsDiff = (*(ret->video))->ptsDiff;
m_videoBuffSize = ret->video->size();
ptsDiff = ret->video->ptsDiff;
}
if ( ptsDiff == 0 )
{
......@@ -172,13 +172,13 @@ WorkflowRenderer::lockVideo( EsHandler *handler, qint64 *pts, size_t *bufferSize
ptsDiff = 1000000 / handler->fps;
}
m_pts = *pts = ptsDiff + m_pts;
*buffer = (*(ret->video))->frame.octets;
*buffer = ret->video->buffer();
*bufferSize = m_videoBuffSize;
return 0;
}
int
WorkflowRenderer::lockAudio( EsHandler *handler, qint64 *pts, size_t *bufferSize, void **buffer )
WorkflowRenderer::lockAudio( EsHandler *handler, qint64 *pts, size_t *bufferSize, const void ** buffer )
{
qint64 ptsDiff;
quint32 nbSample;
......
......@@ -175,7 +175,7 @@ class WorkflowRenderer : public GenericRenderer
* \param buffer The buffer itself.
*/
static int lock( void *data, const char* cookie, qint64 *dts, qint64 *pts,
quint32 *flags, size_t *bufferSize, void **buffer );
quint32 *flags, size_t *bufferSize, const void **buffer );
/**
* \brief "Subcallback", for video frame injection
*
......@@ -184,7 +184,7 @@ class WorkflowRenderer : public GenericRenderer
* \param buffer The buffer itself.
*/
int lockVideo( EsHandler *handler, qint64 *pts,
size_t *bufferSize, void **buffer );
size_t *bufferSize, const void **buffer );
/**
* \brief "Subcallback", for audio sample injection
*
......@@ -193,7 +193,7 @@ class WorkflowRenderer : public GenericRenderer
* \param buffer The buffer itself.
*/
int lockAudio( EsHandler *handler, qint64 *pts,
size_t *bufferSize, void **buffer );
size_t *bufferSize, const void **buffer );
/**
* \brief unlock callback for the imem module
*
......
......@@ -24,10 +24,10 @@
#include "Clip.h"
#include "ClipHelper.h"
#include "ClipWorkflow.h"
#include "LightVideoFrame.h"
#include "Media.h"
#include "MemoryPool.hpp"
#include "WaitCondition.hpp"
#include "Workflow/Types.h"
#include "VLCMedia.h"
#include "VLCMediaPlayer.h"
......
......@@ -35,7 +35,11 @@ class QWaitCondition;
class Clip;
class WaitCondition;
class LightVideoFrame;
namespace Workflow
{
class Frame;
}
namespace LibVLCpp
{
......
......@@ -23,11 +23,11 @@
#include "ImageClipWorkflow.h"
#include "Clip.h"
#include "ClipHelper.h"
#include "LightVideoFrame.h"
#include "MainWorkflow.h"
#include "Media.h"
#include "VLCMediaPlayer.h"
#include "VLCMedia.h"
#include "Media.h"
#include "Workflow/Types.h"
ImageClipWorkflow::ImageClipWorkflow( ClipHelper *ch ) :
ClipWorkflow( ch ),
......@@ -94,12 +94,11 @@ ImageClipWorkflow::lock(ImageClipWorkflow *cw, void **pp_ret, int )
cw->m_renderLock->lock();
if ( cw->m_buffer == NULL )
{
// cw->m_buffer = new LightVideoFrame( size );
cw->m_buffer = new LightVideoFrame( MainWorkflow::getInstance()->getWidth(),
cw->m_buffer = new Workflow::Frame( MainWorkflow::getInstance()->getWidth(),
MainWorkflow::getInstance()->getHeight() );
cw->m_stackedBuffer = new StackedBuffer( cw->m_buffer );
}
*pp_ret = (*(cw->m_buffer))->frame.octets;
*pp_ret = cw->m_buffer->buffer();
}
void
......@@ -136,8 +135,8 @@ ImageClipWorkflow::flushComputedBuffers()
{
}
ImageClipWorkflow::StackedBuffer::StackedBuffer( LightVideoFrame *lvf ) :
::StackedBuffer<LightVideoFrame*>( lvf, false )
ImageClipWorkflow::StackedBuffer::StackedBuffer( Workflow::Frame *frame ) :
::StackedBuffer<Workflow::Frame*>( frame, false )
{
}
......
......@@ -31,10 +31,10 @@ class ImageClipWorkflow : public ClipWorkflow
Q_OBJECT
public:
class StackedBuffer : public ::StackedBuffer<LightVideoFrame*>
class StackedBuffer : public ::StackedBuffer<Workflow::Frame*>
{
public:
StackedBuffer( LightVideoFrame* lvf );
StackedBuffer( Workflow::Frame* frame );
virtual void release();
};
ImageClipWorkflow( ClipHelper* ch );
......@@ -55,7 +55,7 @@ class ImageClipWorkflow : public ClipWorkflow
int width, int height, int bpp, int size,
qint64 pts );
private:
LightVideoFrame *m_buffer;
Workflow::Frame *m_buffer;
StackedBuffer *m_stackedBuffer;
private slots:
......
......@@ -26,15 +26,15 @@
#include "vlmc.h"
#include "Clip.h"
#include "Library.h"
#include "LightVideoFrame.h"
#include "MainWorkflow.h"
#include "TrackWorkflow.h"
#include "TrackHandler.h"
#include "SettingsManager.h"
#include "Workflow/Types.h"
#include <QDomElement>
LightVideoFrame *MainWorkflow::blackOutput = NULL;
Workflow::Frame *MainWorkflow::blackOutput = NULL;
MainWorkflow::MainWorkflow( int trackCount ) :
m_lengthFrame( 0 ),
......@@ -108,9 +108,8 @@ MainWorkflow::startRender( quint32 width, quint32 height )
m_height = height;
if ( blackOutput != NULL )
delete blackOutput;
blackOutput = new LightVideoFrame( m_width, m_height );
// FIX ME vvvvvv , It doesn't update meta info (nbpixels, nboctets, etc.
memset( (*blackOutput)->frame.octets, 0, (*blackOutput)->nboctets );
blackOutput = new Workflow::Frame( m_width, m_height );
memset( blackOutput->buffer(), 0, blackOutput->size() );
for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i )
m_tracks[i]->startRender();
computeLength();
......@@ -129,7 +128,7 @@ MainWorkflow::getOutput( TrackType trackType, bool paused )
m_currentFrame[trackType], paused );
if ( trackType == MainWorkflow::VideoTrack )
{
LightVideoFrame* frame = static_cast<LightVideoFrame*>( ret );
Workflow::Frame* frame = static_cast<Workflow::Frame*>( ret );
if ( frame == NULL )
m_outputBuffers->video = MainWorkflow::blackOutput;
else
......
......@@ -36,9 +36,12 @@ class QReadWriteLock;
class Clip;
class ClipHelper;
class EffectsEngine;
class LightVideoFrame;
class TrackHandler;
class TrackWorkflow;
namespace Workflow
{
class Frame;
}
#include <QObject>
#include <QUuid>
......@@ -58,7 +61,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
*/
struct OutputBuffers
{
const LightVideoFrame* video;
const Workflow::Frame* video;
AudioClipWorkflow::AudioSample* audio;
};
/**
......@@ -401,7 +404,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
quint32 m_height;
/// Pre-filled buffer used when there's nothing to render
static LightVideoFrame* blackOutput;
static Workflow::Frame* blackOutput;
friend class Singleton<MainWorkflow>;
......
......@@ -20,21 +20,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "LightVideoFrame.h"
#include "TrackHandler.h"
#include "TrackWorkflow.h"
#include "Workflow/Types.h"
#include <QDomDocument>
#include <QDomElement>
LightVideoFrame* TrackHandler::nullOutput = NULL;
Workflow::Frame *TrackHandler::nullOutput = NULL;
TrackHandler::TrackHandler( unsigned int nbTracks, MainWorkflow::TrackType trackType ) :
m_trackCount( nbTracks ),
m_trackType( trackType ),
m_length( 0 )
{
TrackHandler::nullOutput = new LightVideoFrame();
//FIXME -> This should be a NULL pointer.
TrackHandler::nullOutput = new Workflow::Frame( 0, 0);
m_tracks = new Toggleable<TrackWorkflow*>[nbTracks];
for ( unsigned int i = 0; i < nbTracks; ++i )
......@@ -121,7 +122,7 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
else
{
void* ret = m_tracks[i]->getOutput( currentFrame, subFrame, paused );
StackedBuffer<LightVideoFrame*> *buff = reinterpret_cast<StackedBuffer<LightVideoFrame*>*>( ret );
StackedBuffer<Workflow::Frame*> *buff = reinterpret_cast<StackedBuffer<Workflow::Frame*>*>( ret );
if ( ret == NULL )
continue ;
else
......
......@@ -107,7 +107,7 @@ class TrackHandler : public QObject
void activateTrack( unsigned int tracKId );
private:
static LightVideoFrame* nullOutput;
static Workflow::Frame* nullOutput;
Toggleable<TrackWorkflow*>* m_tracks;
unsigned int m_trackCount;
MainWorkflow::TrackType m_trackType;
......
......@@ -317,7 +317,7 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
ret = renderClip( cw, currentFrame, start, needRepositioning,
renderOneFrame, paused );
if ( m_trackType == MainWorkflow::VideoTrack )
m_videoStackedBuffer = reinterpret_cast<StackedBuffer<LightVideoFrame*>*>( ret );
m_videoStackedBuffer = reinterpret_cast<StackedBuffer<Workflow::Frame*>*>( ret );
else
m_audioStackedBuffer = reinterpret_cast<StackedBuffer<AudioClipWorkflow::AudioSample*>*>( ret );
}
......
......@@ -30,7 +30,6 @@
#include <QXmlStreamWriter>
class ClipWorkflow;
class LightVideoFrame;
class QDomElement;
class QDomElement;
......@@ -119,7 +118,7 @@ class TrackWorkflow : public QObject
MainWorkflow::TrackType m_trackType;
qint64 m_lastFrame;
StackedBuffer<LightVideoFrame*>* m_videoStackedBuffer;
StackedBuffer<Workflow::Frame*>* m_videoStackedBuffer;
StackedBuffer<AudioClipWorkflow::AudioSample*>* m_audioStackedBuffer;
signals:
......
/*****************************************************************************
* Types.cpp: Workflow related types.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "Workflow/Types.h"
using namespace Workflow;
Frame::Frame( quint32 width, quint32 height ) :
ptsDiff( 0 ),
m_width( width ),
m_height( height )
{
m_size = width * height * Depth;
m_buffer = new quint8[m_size];
}
Frame::~Frame()
{
delete[] m_buffer;
}
quint8*
Frame::buffer()
{
return m_buffer;
}
const quint8*
Frame::buffer() const
{
return m_buffer;
}
quint32
Frame::width() const
{
return m_width;
}
quint32
Frame::height() const
{
return m_height;
}
quint32
Frame::size() const
{
return m_size;
}
/*****************************************************************************
* Types.h: Workflow related types.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef TYPES_H
#define TYPES_H
#include <qglobal.h>
namespace Workflow
{
const quint32 Depth = 3;
class Frame
{
public:
Frame( quint32 width, quint32 height );
~Frame();
quint32 width() const;
quint32 height() const;
quint8 *buffer();
const quint8 *buffer() const;
/**
* \returns The frame size in pixels
*
* This is equal to width * height * Depth
*/
quint32 size() const;
/**
* \warning Terrible hack !
*
* Remove this ASAP !!
*/
//FIXME
qint64 ptsDiff;
private:
quint32 m_width;
quint32 m_height;
quint8 *m_buffer;
quint32 m_size;
};
}
#endif // TYPES_H
......@@ -21,12 +21,12 @@
*****************************************************************************/
#include "Clip.h"
#include "LightVideoFrame.h"
#include "MainWorkflow.h"
#include "StackedBuffer.hpp"
#include "VideoClipWorkflow.h"
#include "VLCMedia.h"
#include "WaitCondition.hpp"
#include "Workflow/Types.h"
#include <QReadWriteLock>
......@@ -64,7 +64,7 @@ VideoClipWorkflow::preallocate()
delete m_availableBuffers.dequeue();
for ( unsigned int i = 0; i < VideoClipWorkflow::nbBuffers; ++i )
{
m_availableBuffers.enqueue( new LightVideoFrame( newWidth, newHeight ) );
m_availableBuffers.enqueue( new Workflow::Frame( newWidth, newHeight ) );
}
}
}
......@@ -119,7 +119,7 @@ VideoClipWorkflow::getOutput( ClipWorkflow::GetMode mode )
//Recheck again, as the WaitCondition may have been awaken when stopping.
if ( getNbComputedBuffers() == 0 )
return NULL;
::StackedBuffer<LightVideoFrame*>* buff;
::StackedBuffer<Workflow::Frame*>* buff;
if ( mode == ClipWorkflow::Pop )
buff = new StackedBuffer( m_computedBuffers.dequeue(), this, true );
else if ( mode == ClipWorkflow::Get )
......@@ -132,17 +132,17 @@ void
VideoClipWorkflow::lock( VideoClipWorkflow *cw, void **pp_ret, int size )
{
Q_UNUSED( size );
LightVideoFrame* lvf = NULL;
Workflow::Frame* frame = NULL;
cw->m_renderLock->lock();
if ( cw->m_availableBuffers.isEmpty() == true )
{
lvf = new LightVideoFrame( cw->m_width, cw->m_height );
frame = new Workflow::Frame( cw->m_width, cw->m_height );
}
else
lvf = cw->m_availableBuffers.dequeue();
cw->m_computedBuffers.enqueue( lvf );
*pp_ret = (*(lvf))->frame.octets;
frame = cw->m_availableBuffers.dequeue();
cw->m_computedBuffers.enqueue( frame );
*pp_ret = frame->buffer();
}
void
......@@ -156,31 +156,31 @@ VideoClipWorkflow::unlock( VideoClipWorkflow *cw, void *buffer, int width,
Q_UNUSED( size );
cw->computePtsDiff( pts );
LightVideoFrame *lvf = cw->m_computedBuffers.last();
(*(lvf))->ptsDiff = cw->m_currentPts - cw->m_previousPts;
Workflow::Frame *frame = cw->m_computedBuffers.last();
frame->ptsDiff = cw->m_currentPts - cw->m_previousPts;
cw->commonUnlock();
cw->m_renderWaitCond->wakeAll();
cw->m_renderLock->unlock();
}
uint32_t
quint32
VideoClipWorkflow::getNbComputedBuffers() const
{
return m_computedBuffers.count();
}
uint32_t
quint32
VideoClipWorkflow::getMaxComputedBuffers() const
{
return VideoClipWorkflow::nbBuffers;
}
void
VideoClipWorkflow::releaseBuffer( LightVideoFrame *lvf )
VideoClipWorkflow::releaseBuffer( Workflow::Frame *frame )
{
QMutexLocker lock( m_renderLock );
m_availableBuffers.enqueue( lvf );
m_availableBuffers.enqueue( frame );
}
void
......@@ -192,10 +192,10 @@ VideoClipWorkflow::flushComputedBuffers()
m_availableBuffers.enqueue( m_computedBuffers.dequeue() );
}
VideoClipWorkflow::StackedBuffer::StackedBuffer( LightVideoFrame *lvf,
VideoClipWorkflow::StackedBuffer::StackedBuffer( Workflow::Frame *frame,
VideoClipWorkflow *poolHandler,
bool mustBeReleased) :
::StackedBuffer<LightVideoFrame*>( lvf, mustBeReleased ),
::StackedBuffer<Workflow::Frame*>( frame, mustBeReleased ),
m_poolHandler( poolHandler )
{
}
......
......@@ -36,10 +36,10 @@ class VideoClipWorkflow : public ClipWorkflow
Q_OBJECT
public:
class StackedBuffer : public ::StackedBuffer<LightVideoFrame*>
class StackedBuffer : public ::StackedBuffer<Workflow::Frame*>
{
public:
StackedBuffer( LightVideoFrame* lvf, VideoClipWorkflow* poolHandler,
StackedBuffer( Workflow::Frame* frame, VideoClipWorkflow* poolHandler,
bool mustBeReleased = true);
virtual void release();
private:
......@@ -58,7 +58,7 @@ class VideoClipWorkflow : public ClipWorkflow
virtual void initVlcOutput();
virtual quint32 getNbComputedBuffers() const;
virtual quint32 getMaxComputedBuffers() const;
void releaseBuffer( LightVideoFrame* lvf );
void releaseBuffer( Workflow::Frame* frame );
void flushComputedBuffers();
/**
* \brief Pre-allocate some image buffers.
......@@ -67,8 +67,8 @@ class VideoClipWorkflow : public ClipWorkflow
void releasePrealocated();
private:
QQueue<LightVideoFrame*> m_computedBuffers;
QQueue<LightVideoFrame*> m_availableBuffers;
QQueue<Workflow::Frame*> m_computedBuffers;
QQueue<Workflow::Frame*> m_availableBuffers;
static void lock( VideoClipWorkflow* clipWorkflow, void** pp_ret,
int size );
static void unlock( VideoClipWorkflow* clipWorkflow, void* buffer,
......
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