2 * factory.c -- the factory method interfaces
3 * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
4 * Author: Charles Yates <charles.yates@pandora.be>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <framework/mlt_factory.h>
25 #include "producer_avformat.h"
26 #include "consumer_avformat.h"
27 #include "filter_avcolour_space.h"
28 #include "filter_avdeinterlace.h"
29 #include "filter_avresample.h"
31 // ffmpeg Header files
34 // A static flag used to determine if avformat has been initialised
35 static int avformat_initialised = 0;
38 static pthread_mutex_t avformat_mutex;
41 // These 3 functions should override the alloc functions in libavformat
42 // but some formats or codecs seem to crash when used (wmv in particular)
44 void *av_malloc( unsigned int size )
46 return mlt_pool_alloc( size );
49 void *av_realloc( void *ptr, unsigned int size )
51 return mlt_pool_realloc( ptr, size );
54 void av_free( void *ptr )
56 return mlt_pool_release( ptr );
60 void avformat_destroy( void *ignore )
66 pthread_mutex_destroy( &avformat_mutex );
72 pthread_mutex_lock( &avformat_mutex );
75 void avformat_unlock( )
77 // Unlock the mutex now
78 pthread_mutex_unlock( &avformat_mutex );
81 static void avformat_init( )
83 // Initialise avformat if necessary
84 if ( avformat_initialised == 0 )
86 avformat_initialised = 1;
87 pthread_mutex_init( &avformat_mutex, NULL );
89 mlt_factory_register_for_clean_up( NULL, avformat_destroy );
90 av_log_set_level( -1 );
94 void *mlt_create_producer( char *id, void *arg )
97 if ( !strcmp( id, "avformat" ) )
98 return producer_avformat_init( arg );
102 void *mlt_create_filter( char *id, void *arg )
105 if ( !strcmp( id, "avcolour_space" ) )
106 return filter_avcolour_space_init( arg );
108 if ( !strcmp( id, "avdeinterlace" ) )
109 return filter_avdeinterlace_init( arg );
111 if ( !strcmp( id, "avresample" ) )
112 return filter_avresample_init( arg );
116 void *mlt_create_transition( char *id, void *arg )
121 void *mlt_create_consumer( char *id, void *arg )
124 if ( !strcmp( id, "avformat" ) )
125 return consumer_avformat_init( arg );