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

Removing distinction between effects and mixer.

Too much pain, almost no benefit.
parent a14425e9
......@@ -10,8 +10,6 @@ SET(VLMC_SRCS
EffectsEngine/Effect.cpp
EffectsEngine/EffectInstance.cpp
EffectsEngine/EffectSettingValue.cpp
EffectsEngine/FilterInstance.cpp
EffectsEngine/MixerInstance.cpp
Library/Library.cpp
Library/MediaContainer.cpp
LibVLCpp/VLCInstance.cpp
......
......@@ -21,8 +21,7 @@
*****************************************************************************/
#include "Effect.h"
#include "FilterInstance.h"
#include "MixerInstance.h"
#include "EffectInstance.h"
#include <QtDebug>
......@@ -145,15 +144,7 @@ EffectInstance*
Effect::createInstance()
{
m_instCount.fetchAndAddAcquire( 1 );
switch ( type() )
{
case Filter:
return new FilterInstance( this );
case Mixer2:
return new MixerInstance( this );
default:
return NULL;
}
return new EffectInstance( this );
}
void
......
......@@ -105,3 +105,18 @@ EffectInstance::params()
{
return m_params;
}
void
EffectInstance::process( double time, const quint32 *frame1, const quint32 *frame2,
const quint32 *frame3, quint32 *output )
{
Q_ASSERT( m_effect->type() == Effect::Mixer2 );
m_effect->m_f0r_update2( m_instance, time, frame1, frame2, frame3, output );
}
void
EffectInstance::process( double time, const quint32 *input, quint32 *output ) const
{
Q_ASSERT( m_effect->type() == Effect::Filter );
m_effect->m_f0r_update( m_instance, time, input, output );
}
......@@ -38,6 +38,10 @@ class EffectInstance
Effect* effect();
const ParamList &params() const;
ParamList &params();
void process( double time, const quint32* input, quint32* output ) const;
void process( double time, const quint32 *frame1, const quint32 *frame2,
const quint32 *frame3, quint32 *output );
protected:
EffectInstance( Effect *effect );
virtual ~EffectInstance();
......
......@@ -23,8 +23,7 @@
#include "EffectsEngine.h"
#include "Effect.h"
#include "FilterInstance.h"
#include "MixerInstance.h"
#include "EffectInstance.h"
#include "Types.h"
#include <QDesktopServices>
......@@ -111,13 +110,13 @@ EffectsEngine::browseDirectory( const QString &path )
}
quint32*
EffectsEngine::applyFilters( const FilterList &effects, const Workflow::Frame* frame,
EffectsEngine::applyFilters( const EffectList &effects, const Workflow::Frame* frame,
qint64 currentFrame, double time )
{
if ( effects.size() == 0 )
return NULL;
FilterList::const_iterator it = effects.constBegin();
FilterList::const_iterator ite = effects.constEnd();
EffectList::const_iterator it = effects.constBegin();
EffectList::const_iterator ite = effects.constEnd();
quint32 *buff1 = NULL;
quint32 *buff2 = NULL;
......@@ -136,7 +135,7 @@ EffectsEngine::applyFilters( const FilterList &effects, const Workflow::Frame* f
buff = &buff2;
if ( *buff == NULL )
*buff = new quint32[frame->nbPixels()];
FilterInstance *effect = (*it)->effect;
EffectInstance *effect = (*it)->effect;
effect->process( time, input, *buff );
input = *buff;
firstBuff = !firstBuff;
......@@ -160,12 +159,12 @@ EffectsEngine::applyFilters( const FilterList &effects, const Workflow::Frame* f
}
void
EffectsEngine::saveFilters( const FilterList &effects, QXmlStreamWriter &project )
EffectsEngine::saveFilters( const EffectList &effects, QXmlStreamWriter &project )
{
if ( effects.size() <= 0 )
return ;
EffectsEngine::FilterList::const_iterator it = effects.begin();
EffectsEngine::FilterList::const_iterator ite = effects.end();
EffectsEngine::EffectList::const_iterator it = effects.begin();
EffectsEngine::EffectList::const_iterator ite = effects.end();
project.writeStartElement( "effects" );
while ( it != ite )
{
......@@ -180,10 +179,10 @@ EffectsEngine::saveFilters( const FilterList &effects, QXmlStreamWriter &project
}
void
EffectsEngine::initFilters( const FilterList &effects, quint32 width, quint32 height )
EffectsEngine::initFilters( const EffectList &effects, quint32 width, quint32 height )
{
EffectsEngine::FilterList::const_iterator it = effects.begin();
EffectsEngine::FilterList::const_iterator ite = effects.end();
EffectsEngine::EffectList::const_iterator it = effects.begin();
EffectsEngine::EffectList::const_iterator ite = effects.end();
while ( it != ite )
{
......@@ -192,7 +191,7 @@ EffectsEngine::initFilters( const FilterList &effects, quint32 width, quint32 he
}
}
EffectsEngine::MixerHelper*
EffectsEngine::EffectHelper*
EffectsEngine::getMixer( const MixerList &mixers, qint64 currentFrame )
{
MixerList::const_iterator it = mixers.constBegin();
......@@ -201,7 +200,10 @@ EffectsEngine::getMixer( const MixerList &mixers, qint64 currentFrame )
while ( it != ite )
{
if ( it.key() <= currentFrame && currentFrame <= it.value()->end )
{
Q_ASSERT( it.value()->effect->effect()->type() == Effect::Mixer2 );
return it.value();
}
++it;
}
return NULL;
......
......@@ -49,10 +49,9 @@ class EffectsEngine : public QObject, public Singleton<EffectsEngine>
Q_OBJECT
public:
template <typename T>
struct EffectHelper
{
EffectHelper( T *_effect, qint64 _start = 0, qint64 _end = -1,
EffectHelper( EffectInstance *_effect, qint64 _start = 0, qint64 _end = -1,
const QString& _uuid = QString() ) :
effect( _effect ),
start( _start ),
......@@ -64,15 +63,13 @@ class EffectsEngine : public QObject, public Singleton<EffectsEngine>
uuid = _uuid;
}
T* effect;
qint64 start;
qint64 end;
QUuid uuid;
EffectInstance *effect;
qint64 start;
qint64 end;
QUuid uuid;
};
typedef EffectHelper<FilterInstance> FilterHelper;
typedef QList<FilterHelper*> FilterList;
typedef EffectHelper<MixerInstance> MixerHelper;
typedef QHash<qint64, MixerHelper*> MixerList;
typedef QList<EffectHelper*> EffectList;
typedef QHash<qint64, EffectHelper*> MixerList;
static const quint32 MaxFramesForMixer = 3;
Effect* effect( const QString& name );
......@@ -80,13 +77,13 @@ class EffectsEngine : public QObject, public Singleton<EffectsEngine>
void loadEffects();
//Filters methods:
static quint32 *applyFilters( const FilterList &effects,
static quint32 *applyFilters( const EffectList &effects,
const Workflow::Frame *frame, qint64 currentFrame, double time );
static void saveFilters( const FilterList &effects, QXmlStreamWriter &project );
static void initFilters( const FilterList &effects, quint32 width, quint32 height );
static void saveFilters( const EffectList &effects, QXmlStreamWriter &project );
static void initFilters( const EffectList &effects, quint32 width, quint32 height );
//Mixers methods:
static MixerHelper* getMixer( const MixerList& mixers, qint64 currentFrame );
static EffectHelper *getMixer( const MixerList& mixers, qint64 currentFrame );
static void initMixers( const MixerList& mixers, quint32 width,
quint32 height );
......
/*****************************************************************************
* FilterInstance.cpp: Handle a filter instance.
*****************************************************************************
* 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 "FilterInstance.h"
#include "Effect.h"
FilterInstance::FilterInstance( Effect *effect ) :
EffectInstance( effect )
{
}
void
FilterInstance::process( double time, const quint32 *input, quint32 *output ) const
{
m_effect->m_f0r_update( m_instance, time, input, output );
}
/*****************************************************************************
* FilterInstance.h: Handle a filter instance.
*****************************************************************************
* 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 FILTERINSTANCE_H
#define FILTERINSTANCE_H
#include "EffectInstance.h"
class FilterInstance : public EffectInstance
{
public:
FilterInstance( Effect *effect );
void process( double time, const quint32* input, quint32* output ) const;
};
#endif // FILTERINSTANCE_H
/*****************************************************************************
* MixerInstance.cpp: Handle a filter instance.
*****************************************************************************
* 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 "MixerInstance.h"
#include "Effect.h"
MixerInstance::MixerInstance( Effect *effect ) :
EffectInstance( effect )
{
}
void
MixerInstance::process( double time, const quint32 *frame1, const quint32 *frame2,
const quint32 *frame3, quint32 *output )
{
m_effect->m_f0r_update2( m_instance, time, frame1, frame2, frame3, output );
}
/*****************************************************************************
* MixerInstance.h: Handle a filter instance.
*****************************************************************************
* 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 MIXERINSTANCE_H
#define MIXERINSTANCE_H
#include "EffectInstance.h"
class MixerInstance : public EffectInstance
{
public:
MixerInstance( Effect *effect );
void process( double time, const quint32 *frame1, const quint32 *frame2,
const quint32 *frame3, quint32 *output );
};
#endif // MIXERINSTANCE_H
......@@ -266,7 +266,7 @@ Timeline::dropEvent( QDropEvent *event )
{
Effect* effect = EffectsEngine::getInstance()->effect( event->mimeData()->data( "vlmc/effect_name") );
if ( effect != NULL )
m_renderer->appendFilter( effect );
m_renderer->appendEffect( effect );
else
qWarning() << "Can't find effect name" << event->mimeData()->data( "vlmc/effect_name");
}
......@@ -26,7 +26,7 @@
#include "WorkflowRenderer.h"
#include "Clip.h"
#include "FilterInstance.h"
#include "EffectInstance.h"
#include "GenericRenderer.h"
#include "MainWorkflow.h"
#include "SettingsManager.h"
......@@ -398,20 +398,20 @@ WorkflowRenderer::paramsHasChanged( quint32 width, quint32 height, double fps )
newOutputFps != fps );
}
EffectsEngine::FilterHelper*
WorkflowRenderer::appendFilter( Effect *effect, qint64 start, qint64 end )
EffectsEngine::EffectHelper*
WorkflowRenderer::appendEffect( Effect *effect, qint64 start, qint64 end )
{
if ( effect->type() != Effect::Filter )
{
qWarning() << "WorkflowRenderer does not handle non filter effects.";
return NULL;
}
FilterInstance *filterInstance = static_cast<FilterInstance*>( effect->createInstance() );
EffectInstance *effectInstance = effect->createInstance();
if ( isRendering() == true )
filterInstance->init( m_width, m_height );
effectInstance->init( m_width, m_height );
QWriteLocker lock( m_effectsLock );
EffectsEngine::FilterHelper *ret = new EffectsEngine::FilterHelper( filterInstance, start, end );
EffectsEngine::EffectHelper *ret = new EffectsEngine::EffectHelper( effectInstance, start, end );
m_filters.push_back( ret );
return ret;
}
......@@ -445,7 +445,7 @@ WorkflowRenderer::loadProject( const QDomElement &project )
{
Effect *e = EffectsEngine::getInstance()->effect( effect.attribute( "name" ) );
if ( e != NULL )
appendFilter( e, effect.attribute( "start" ).toLongLong(),
appendEffect( e, effect.attribute( "start" ).toLongLong(),
effect.attribute( "end" ).toLongLong() );
else
qCritical() << "Renderer: Can't load effect" << effect.attribute( "name" );
......
......@@ -131,7 +131,8 @@ class WorkflowRenderer : public GenericRenderer
*/
void killRenderer();
EffectsEngine::FilterHelper *appendFilter( Effect* effect, qint64 start = 0, qint64 end = -1 );
EffectsEngine::EffectHelper *appendEffect( Effect* effect, qint64 start = 0,
qint64 end = -1 );
void saveProject( QXmlStreamWriter &project ) const;
void loadProject( const QDomElement& project );
......@@ -284,7 +285,7 @@ class WorkflowRenderer : public GenericRenderer
qint64 m_oldLength;
QReadWriteLock *m_effectsLock;
EffectsEngine::FilterList m_filters;
EffectsEngine::EffectList m_filters;
quint32 *m_effectFrame;
......
......@@ -44,7 +44,7 @@ class AudioClipWorkflow : public ClipWorkflow
void *getUnlockCallback() const;
virtual Workflow::OutputBuffer *getOutput( ClipWorkflow::GetMode mode );
virtual void saveEffects( QXmlStreamWriter & ) const {} //Nothing to do here now.
virtual EffectsEngine::FilterHelper *appendEffect( Effect *, qint64, qint64 ) { return NULL; } //Nothing to do here now.
virtual EffectsEngine::EffectHelper *appendEffect( Effect *, qint64, qint64 ) { return NULL; } //Nothing to do here now.
protected:
virtual quint32 getNbComputedBuffers() const;
virtual quint32 getMaxComputedBuffers() const;
......
......@@ -203,7 +203,7 @@ class ClipWorkflow : public QObject
void save( QXmlStreamWriter& project ) const;
virtual void saveEffects( QXmlStreamWriter& ) const = 0;
virtual EffectsEngine::FilterHelper *appendEffect( Effect *effect, qint64 start = 0,
virtual EffectsEngine::EffectHelper *appendEffect( Effect *effect, qint64 start = 0,
qint64 end = -1 ) = 0;
private:
......
......@@ -37,7 +37,7 @@ class ImageClipWorkflow : public ClipWorkflow
void *getUnlockCallback() const;
virtual Workflow::OutputBuffer *getOutput( ClipWorkflow::GetMode mode );
virtual void saveEffects( QXmlStreamWriter & ) const {} //Nothing to do here now.
virtual EffectsEngine::FilterHelper *appendEffect( Effect *, qint64, qint64 ) { return NULL; } //Nothing to do here now.
virtual EffectsEngine::EffectHelper *appendEffect( Effect *, qint64, qint64 ) { return NULL; } //Nothing to do here now.
protected:
virtual void initVlcOutput();
virtual quint32 getNbComputedBuffers() const;
......
......@@ -81,8 +81,8 @@ MainWorkflow::addClip( ClipHelper *clipHelper, unsigned int trackId,
emit clipAdded( clipHelper, trackId, start, trackType );
}
EffectsEngine::FilterHelper*
MainWorkflow::addFilter( Effect *effect, quint32 trackId, const QUuid &uuid, Workflow::TrackType type )
EffectsEngine::EffectHelper*
MainWorkflow::addEffect( Effect *effect, quint32 trackId, const QUuid &uuid, Workflow::TrackType type )
{
return m_tracks[type]->addEffect( effect, trackId, uuid );
}
......@@ -343,7 +343,7 @@ MainWorkflow::loadProject( const QDomElement &root )
{
Effect *e = EffectsEngine::getInstance()->effect( effect.attribute( "name" ) );
if ( e != NULL )
addFilter( e, trackId, uuid, type );
addEffect( e, trackId, uuid, type );
else
qCritical() << "Workflow: Can't load effect" << effect.attribute( "name" );
}
......
......@@ -75,7 +75,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
Workflow::TrackType type, bool informGui );
EffectsEngine::FilterHelper *addFilter( Effect* effect, quint32 trackId,
EffectsEngine::EffectHelper *addEffect( Effect* effect, quint32 trackId,
const QUuid &uuid, Workflow::TrackType type );
/**
......
......@@ -59,7 +59,7 @@ TrackHandler::addClip( ClipHelper* ch, unsigned int trackId, qint64 start )
m_length = m_tracks[trackId]->getLength();
}
EffectsEngine::FilterHelper*
EffectsEngine::EffectHelper*
TrackHandler::addEffect( Effect *effect, quint32 trackId, const QUuid &uuid )
{
return m_tracks[trackId]->addEffect( effect, uuid );
......
......@@ -48,7 +48,7 @@ class TrackHandler : public QObject
*/
void addClip( ClipHelper* clip, unsigned int trackId, qint64 start );
EffectsEngine::FilterHelper *addEffect( Effect *effect, quint32 trackId, const QUuid &uuid );
EffectsEngine::EffectHelper *addEffect( Effect *effect, quint32 trackId, const QUuid &uuid );
/**
* Returns the number of tracks in this handler
*/
......
......@@ -29,7 +29,7 @@
#include "ImageClipWorkflow.h"
#include "MainWorkflow.h"
#include "Media.h"
#include "MixerInstance.h"
#include "EffectInstance.h"
#include "Types.h"
#include "VideoClipWorkflow.h"
#include "vlmc.h"
......@@ -90,7 +90,7 @@ TrackWorkflow::addClip( ClipWorkflow* cw, qint64 start )
computeLength();
}
EffectsEngine::FilterHelper*
EffectsEngine::EffectHelper*
TrackWorkflow::addEffect( Effect *effect, const QUuid &uuid )
{
QMap<qint64, ClipWorkflow*>::const_iterator it = m_clips.begin();
......@@ -330,7 +330,7 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
//Handle mixers:
if ( m_trackType == Workflow::VideoTrack )
{
EffectsEngine::MixerHelper* mixer = EffectsEngine::getMixer( m_mixers, currentFrame );
EffectsEngine::EffectHelper* mixer = EffectsEngine::getMixer( m_mixers, currentFrame );
if ( mixer != NULL && frames[0] != NULL ) //There's no point using the mixer if there's no frame rendered.
{
//FIXME: We don't handle mixer3 yet.
......
......@@ -59,7 +59,7 @@ class TrackWorkflow : public QObject
ClipWorkflow* removeClipWorkflow( const QUuid& id );
void addClip( ClipHelper*, qint64 start );
void addClip( ClipWorkflow*, qint64 start );
EffectsEngine::FilterHelper *addEffect( Effect *effect, const QUuid &uuid );
EffectsEngine::EffectHelper *addEffect( Effect *effect, const QUuid &uuid );
qint64 getClipPosition( const QUuid& uuid ) const;
ClipHelper *getClipHelper( const QUuid& uuid );
......
......@@ -21,7 +21,7 @@
*****************************************************************************/
#include "Clip.h"
#include "FilterInstance.h"
#include "EffectInstance.h"
#include "MainWorkflow.h"
#include "Media.h"
#include "VideoClipWorkflow.h"
......@@ -212,7 +212,7 @@ VideoClipWorkflow::flushComputedBuffers()
m_availableBuffers.enqueue( m_computedBuffers.dequeue() );
}
EffectsEngine::FilterHelper*
EffectsEngine::EffectHelper*
VideoClipWorkflow::appendEffect( Effect *effect, qint64 start, qint64 end )
{
if ( effect->type() != Effect::Filter )
......@@ -220,9 +220,9 @@ VideoClipWorkflow::appendEffect( Effect *effect, qint64 start, qint64 end )
qWarning() << "VideoClipWorkflow does not handle non filter effects.";
return NULL;
}
FilterInstance *filterInstance = static_cast<FilterInstance*>( effect->createInstance() );
EffectInstance *effectInstance = effect->createInstance();
QWriteLocker lock( m_effectsLock );
EffectsEngine::FilterHelper *ret = new EffectsEngine::FilterHelper( filterInstance, start, end );
EffectsEngine::EffectHelper *ret = new EffectsEngine::EffectHelper( effectInstance, start, end );
m_filters.push_back( ret );
return ret;
}
......
......@@ -40,7 +40,7 @@ class VideoClipWorkflow : public ClipWorkflow
void *getLockCallback() const;
void *getUnlockCallback() const;
virtual Workflow::OutputBuffer *getOutput( ClipWorkflow::GetMode mode );
virtual EffectsEngine::FilterHelper *appendEffect( Effect *effect, qint64 start = 0, qint64 end = -1 );
virtual EffectsEngine::EffectHelper *appendEffect( Effect *effect, qint64 start = 0, qint64 end = -1 );
virtual void setTime( qint64 time, qint64 frame );
virtual void saveEffects( QXmlStreamWriter &project ) const;
......@@ -71,7 +71,7 @@ class VideoClipWorkflow : public ClipWorkflow
QMutex *m_renderedFrameMutex;
qint64 m_renderedFrame;
Workflow::Frame *m_lastReturnedBuffer;
QList<EffectsEngine::FilterHelper*> m_filters;
EffectsEngine::EffectList m_filters;
};
#endif // VIDEOCLIPWORKFLOW_H
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