[Mlt-devel] mlt++/src MltPushConsumer.cpp,NONE,1.1 MltPushConsumer.h,NONE,1.1 Makefile,1.15,1.16 Mlt
Brought to you by:
ddennedy,
lilo_booter
From: Charles Y. <lil...@us...> - 2005-09-28 14:00:47
|
Update of /cvsroot/mlt/mlt++/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12734/src Modified Files: Makefile Mlt.h Added Files: MltPushConsumer.cpp MltPushConsumer.h Log Message: + Added a push based consumer wrapper --- NEW FILE: MltPushConsumer.h --- /** * MltPushConsumer.h - MLT Wrapper * Copyright (C) 2004-2005 Charles Yates * Author: Charles Yates <cha...@pa...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef MLTPP_PUSH_CONSUMER_H #define MLTPP_PUSH_CONSUMER_H #include "MltConsumer.h" namespace Mlt { class Frame; class Service; class PushPrivate; class PushConsumer : public Consumer { private: PushPrivate *m_private; public: PushConsumer( char *id , char *service = NULL ); virtual ~PushConsumer( ); void set_render( int width, int height, double aspect_ratio ); virtual int connect( Service &service ); int push( Frame *frame ); int push( Frame &frame ); int drain( ); Frame *construct( int ); }; } #endif Index: Makefile =================================================================== RCS file: /cvsroot/mlt/mlt++/src/Makefile,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- Makefile 24 Dec 2004 10:09:14 -0000 1.15 +++ Makefile 28 Sep 2005 14:00:34 -0000 1.16 @@ -20,6 +20,7 @@ MltPlaylist.o \ MltProducer.o \ MltProperties.o \ + MltPushConsumer.o \ MltResponse.o \ MltService.o \ MltTokeniser.o \ --- NEW FILE: MltPushConsumer.cpp --- /** * MltPushConsumer.cpp - MLT Wrapper * Copyright (C) 2004-2005 Charles Yates * Author: Charles Yates <cha...@pa...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "MltPushConsumer.h" #include "MltFilter.h" using namespace Mlt; namespace Mlt { class PushPrivate { public: PushPrivate( ) { } }; } static void filter_destructor( void *arg ) { Filter *filter = ( Filter * )arg; delete filter; } PushConsumer::PushConsumer( char *id , char *service ) : Consumer( id, service ), m_private( new PushPrivate( ) ) { if ( is_valid( ) ) { // Set up push mode (known as put mode in mlt) set( "real_time", 0 ); set( "put_mode", 1 ); set( "terminate_on_pause", 0 ); set( "buffer", 0 ); // We might need resize and rescale filters so we'll create them now // NB: Try to use the best rescaler available here Filter *resize = new Filter( "resize" ); Filter *rescale = new Filter( "mcrescale" ); if ( !rescale->is_valid( ) ) { delete rescale; rescale = new Filter( "gtkrescale" ); } if ( !rescale->is_valid( ) ) { delete rescale; rescale = new Filter( "rescale" ); } Filter *convert = new Filter( "avcolour_space" ); set( "filter_convert", convert, 0, filter_destructor ); set( "filter_resize", resize, 0, filter_destructor ); set( "filter_rescale", rescale, 0, filter_destructor ); } } PushConsumer::~PushConsumer( ) { } void PushConsumer::set_render( int width, int height, double aspect_ratio ) { set( "render_width", width ); set( "render_height", height ); set( "render_aspect_ratio", aspect_ratio ); } int PushConsumer::connect( Service &service ) { return -1; } int PushConsumer::push( Frame *frame ) { frame->inc_ref( ); // Here we have the option to process the frame at a render resolution (this will // typically be PAL or NTSC) prior to scaling according to the consumers profile // This is done to optimise quality, esp. with regard to compositing positions if ( get_int( "render_width" ) ) { // Process the projects render resolution first mlt_image_format format = mlt_image_yuv422; int w = get_int( "render_width" ); int h = get_int( "render_height" ); frame->set( "consumer_aspect_ratio", get_double( "render_aspect_ratio" ) ); frame->set( "consumer_deinterlace", get_int( "deinterlace" ) ); frame->set( "deinterlace_method", get_int( "deinterlace_method" ) ); frame->set( "rescale.interp", get( "rescale" ) ); // Render the frame frame->get_image( format, w, h ); // Now set up the post image scaling Filter *convert = ( Filter * )get_data( "filter_convert" ); mlt_filter_process( convert->get_filter( ), frame->get_frame( ) ); Filter *rescale = ( Filter * )get_data( "filter_rescale" ); mlt_filter_process( rescale->get_filter( ), frame->get_frame( ) ); Filter *resize = ( Filter * )get_data( "filter_resize" ); mlt_filter_process( resize->get_filter( ), frame->get_frame( ) ); } return mlt_consumer_put_frame( ( mlt_consumer )get_service( ), frame->get_frame( ) ); } int PushConsumer::push( Frame &frame ) { return push( &frame ); } int PushConsumer::drain( ) { return 0; } // Convenience function - generates a frame with an image of a given size Frame *PushConsumer::construct( int size ) { mlt_frame f = mlt_frame_init( ); Frame *frame = new Frame( f ); uint8_t *buffer = ( uint8_t * )mlt_pool_alloc( size ); frame->set( "image", buffer, size, mlt_pool_release ); return frame; } Index: Mlt.h =================================================================== RCS file: /cvsroot/mlt/mlt++/src/Mlt.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- Mlt.h 24 Dec 2004 10:09:14 -0000 1.11 +++ Mlt.h 28 Sep 2005 14:00:34 -0000 1.12 @@ -36,6 +36,7 @@ #include "MltPlaylist.h" #include "MltProducer.h" #include "MltProperties.h" +#include "MltPushConsumer.h" #include "MltResponse.h" #include "MltService.h" #include "MltTokeniser.h" |