コード例 #1
0
ファイル: factory.c プロジェクト: elfring/mlt
static void *create_service( mlt_profile profile, mlt_service_type type, const char *id, void *arg )
{
	avformat_init( );
#ifdef CODECS
	if ( !strncmp( id, "avformat", 8 ) )
	{
		if ( type == producer_type )
			return producer_avformat_init( profile, id, arg );
		else if ( type == consumer_type )
			return consumer_avformat_init( profile, arg );
	}
#endif
#ifdef FILTERS
	if ( !strcmp( id, "avcolor_space" ) )
		return filter_avcolour_space_init( arg );
	if ( !strcmp( id, "avcolour_space" ) )
		return filter_avcolour_space_init( arg );
	if ( !strcmp( id, "avdeinterlace" ) )
		return filter_avdeinterlace_init( arg );
#if defined(FFUDIV) || (LIBAVCODEC_VERSION_INT < ((54<<16)+(26<<8)+0))
	if ( !strcmp( id, "avresample" ) )
		return filter_avresample_init( arg );
#endif
	if ( !strcmp( id, "swscale" ) )
		return filter_swscale_init( profile, arg );
#endif
	return NULL;
}
コード例 #2
0
ファイル: factory.c プロジェクト: gmarco/mlt-orig
static void *create_service( mlt_profile profile, mlt_service_type type, const char *id, void *arg )
{
	avformat_init( );
#ifdef CODECS
	if ( !strncmp( id, "avformat", 8 ) )
	{
		if ( type == producer_type )
			return producer_avformat_init( profile, id, arg );
		else if ( type == consumer_type )
			return consumer_avformat_init( profile, arg );
	}
#endif
#ifdef FILTERS
	if ( !strcmp( id, "avcolor_space" ) )
		return filter_avcolour_space_init( arg );
	if ( !strcmp( id, "avcolour_space" ) )
		return filter_avcolour_space_init( arg );
	if ( !strcmp( id, "avdeinterlace" ) )
		return filter_avdeinterlace_init( arg );
	if ( !strcmp( id, "avresample" ) )
		return filter_avresample_init( arg );
#ifdef SWSCALE
	if ( !strcmp( id, "swscale" ) )
		return filter_swscale_init( profile, arg );
#endif
#endif
	return NULL;
}
コード例 #3
0
ファイル: factory.c プロジェクト: elfring/mlt
static mlt_properties avformat_metadata( mlt_service_type type, const char *id, void *data )
{
	char file[ PATH_MAX ];
	const char *service_type = NULL;
	mlt_properties result = NULL;

	// Convert the service type to a string.
	switch ( type )
	{
		case consumer_type:
			service_type = "consumer";
			break;
		case filter_type:
			service_type = "filter";
			break;
		case producer_type:
			service_type = "producer";
			break;
		case transition_type:
			service_type = "transition";
			break;
		default:
			return NULL;
	}
	// Load the yaml file
	snprintf( file, PATH_MAX, "%s/avformat/%s_%s.yml", mlt_environment( "MLT_DATA" ), service_type, id );
	result = mlt_properties_parse_yaml( file );
	if ( result && ( type == consumer_type || type == producer_type ) )
	{
		// Annotate the yaml properties with AVOptions.
		mlt_properties params = (mlt_properties) mlt_properties_get_data( result, "parameters", NULL );
		AVFormatContext *avformat = avformat_alloc_context();
#if LIBAVCODEC_VERSION_INT > ((53<<16)+(8<<8)+0)
		AVCodecContext *avcodec = avcodec_alloc_context3( NULL );
#else
		AVCodecContext *avcodec = avcodec_alloc_context();
#endif
		int flags = ( type == consumer_type )? AV_OPT_FLAG_ENCODING_PARAM : AV_OPT_FLAG_DECODING_PARAM;

		add_parameters( params, avformat, flags, NULL, NULL );
#if LIBAVFORMAT_VERSION_MAJOR >= 53
		avformat_init();
		if ( type == producer_type )
		{
			AVInputFormat *f = NULL;
			while ( ( f = av_iformat_next( f ) ) )
				if ( f->priv_class )
					add_parameters( params, &f->priv_class, flags, NULL, f->name );
		}
		else
		{
			AVOutputFormat *f = NULL;
			while ( ( f = av_oformat_next( f ) ) )
				if ( f->priv_class )
					add_parameters( params, &f->priv_class, flags, NULL, f->name );
		}
#endif

		add_parameters( params, avcodec, flags, NULL, NULL );
#if LIBAVCODEC_VERSION_MAJOR >= 53
		AVCodec *c = NULL;
		while ( ( c = av_codec_next( c ) ) )
			if ( c->priv_class )
				add_parameters( params, &c->priv_class, flags, NULL, c->name );
#endif

		av_free( avformat );
		av_free( avcodec );
	}
	return result;
}