Beispiel #1
0
// Parse the geometry specification for a given length and normalised width/height (-1 for default)
// data is constructed as: [frame=]X/Y:WxH[:mix][!][;[frame=]X/Y:WxH[:mix][!]]*
// and X, Y, W and H can have trailing % chars to indicate percentage of normalised size
// Append a pair's value with ! to enable distort.
int mlt_geometry_parse( mlt_geometry self, char *data, int length, int nw, int nh )
{
	int i = 0;

	// Create a tokeniser
	mlt_tokeniser tokens = mlt_tokeniser_init( );

	// Get the local/private structure
	geometry g = self->local;

	// Clean the existing geometry
	mlt_geometry_clean( self );

	// Update the info on the data
	if ( length != -1 )
		g->length = length;
	if ( nw != -1 )
		g->nw = nw;
	if ( nh != -1 )
		g->nh = nh;
	if ( data != NULL )
		g->data = strdup( data );

	// Tokenise
	if ( data != NULL )
		mlt_tokeniser_parse_new( tokens, data, ";" );

	// Iterate through each token
	for ( i = 0; i < mlt_tokeniser_count( tokens ); i ++ )
	{
		struct mlt_geometry_item_s item;
		char *value = mlt_tokeniser_get_string( tokens, i );

		// If no data in keyframe, drop it (trailing semicolon)
		if ( value == NULL || !strcmp( value, "" ) )
			continue;

		// Set item to 0
		memset( &item, 0, sizeof( struct mlt_geometry_item_s ) );

		// Now parse the item
		mlt_geometry_parse_item( self, &item, value );

		// Now insert into place
		mlt_geometry_insert( self, &item );
	}
	mlt_geometry_interpolate( self );

	// Remove the tokeniser
	mlt_tokeniser_close( tokens );

	// ???
	return 0;
}
Beispiel #2
0
int mlt_animation_parse(mlt_animation self, const char *data, int length, double fps, locale_t locale )
{
	int error = 0;
	int i = 0;
	struct mlt_animation_item_s item;
	mlt_tokeniser tokens = mlt_tokeniser_init( );

	// Clean the existing geometry
	mlt_animation_clean( self );

	// Update the info on the data
	if ( data )
		self->data = strdup( data );
	self->length = length;
	self->fps = fps;
	self->locale = locale;
	item.property = mlt_property_init();

	// Tokenise
	if ( data )
		mlt_tokeniser_parse_new( tokens, (char*) data, ";" );

	// Iterate through each token
	for ( i = 0; i < mlt_tokeniser_count( tokens ); i++ )
	{
		char *value = mlt_tokeniser_get_string( tokens, i );

		// If no data in keyframe, drop it (trailing semicolon)
		if ( !value || !strcmp( value, "" ) )
			continue;

		// Reset item
		item.frame = item.is_key = 0;

		// Now parse the item
		mlt_animation_parse_item( self, &item, value );

		// Now insert into place
		mlt_animation_insert( self, &item );
	}
	mlt_animation_interpolate( self );

	// Cleanup
	mlt_tokeniser_close( tokens );
	mlt_property_close( item.property );

	return error;
}
Beispiel #3
0
static void * create_frei0r_item ( mlt_profile profile, mlt_service_type type, const char *id, void *arg){

	mlt_tokeniser tokeniser = mlt_tokeniser_init ( );
	char *frei0r_path = get_frei0r_path();
	int dircount=mlt_tokeniser_parse_new (
		tokeniser,
		frei0r_path,
		 ":"
	);
	void* ret=NULL;
	while (dircount--){
		char soname[PATH_MAX];
		char *myid = strdup( id );

#ifdef WIN32
		char *firstname = strtok( myid, "." );
#else
		char *save_firstptr = NULL;
		char *firstname = strtok_r( myid, ".", &save_firstptr );
#endif
		char* directory = mlt_tokeniser_get_string (tokeniser, dircount);

#ifdef WIN32
		firstname = strtok( NULL, "." );
#else
		firstname = strtok_r( NULL, ".", &save_firstptr );
#endif
		if (strncmp(directory, "$HOME", 5))
			snprintf(soname, PATH_MAX, "%s/%s" LIBSUF, directory, firstname );
		else
			snprintf(soname, PATH_MAX, "%s%s/%s" LIBSUF, getenv("HOME"), strchr(directory, '/'), firstname );

		if (firstname){

			void* handle=dlopen(soname,RTLD_LAZY);

			if (handle ){
				ret=load_lib ( profile , type , handle, firstname );
			}else{
				dlerror();
			}
		}
		free( myid );
	}
	mlt_tokeniser_close ( tokeniser );
	free( frei0r_path );
	return ret;
}
Beispiel #4
0
mlt_properties mlt_repository_languages( mlt_repository self )
{
	mlt_properties languages = mlt_properties_get_data( &self->parent, "languages", NULL );
	if ( languages )
		return languages;

	languages = mlt_properties_new();
	char *locale = getenv_locale();
	if ( locale )
	{
		locale = strdup( locale );
		mlt_tokeniser tokeniser = mlt_tokeniser_init();
		int count = mlt_tokeniser_parse_new( tokeniser, locale, ":" );
		if ( count )
		{
			int i;
			for ( i = 0; i < count; i++ )
			{
				char *locale = mlt_tokeniser_get_string( tokeniser, i );
				if ( strcmp( locale, "C" ) == 0 || strcmp( locale, "POSIX" ) == 0 )
					locale = "en";
				else if ( strlen( locale ) > 2 )
					locale[2] = 0;
				char string[21];
				snprintf( string, sizeof(string), "%d", i );
				mlt_properties_set( languages, string, locale );
			}
		}
		else
		{
			mlt_properties_set( languages, "0", "en" );
		}
		free( locale );
		mlt_tokeniser_close( tokeniser );
	}
	else
	{
		mlt_properties_set( languages, "0", "en" );
	}
	mlt_properties_set_data( &self->parent, "languages", languages, 0, ( mlt_destructor )mlt_properties_close, NULL );
	return languages;
}
Beispiel #5
0
static void attach_normalisers( mlt_profile profile, mlt_service service )
{
    // Loop variable
    int i;

    // Tokeniser
    mlt_tokeniser tokeniser = mlt_tokeniser_init( );

    // We only need to load the normalising properties once
    if ( normalisers == NULL )
    {
        char temp[ 1024 ];
        snprintf( temp, sizeof(temp), "%s/core/loader.ini", mlt_environment( "MLT_DATA" ) );
        normalisers = mlt_properties_load( temp );
        mlt_factory_register_for_clean_up( normalisers, ( mlt_destructor )mlt_properties_close );
    }

    // Apply normalisers
    for ( i = 0; i < mlt_properties_count( normalisers ); i ++ )
    {
        int j = 0;
        int created = 0;
        char *value = mlt_properties_get_value( normalisers, i );
        mlt_tokeniser_parse_new( tokeniser, value, "," );
        for ( j = 0; !created && j < mlt_tokeniser_count( tokeniser ); j ++ )
            create_filter( profile, service, mlt_tokeniser_get_string( tokeniser, j ), &created );
    }

    // Close the tokeniser
    mlt_tokeniser_close( tokeniser );

    // Attach the audio and video format converters
    int created = 0;
    create_filter( profile, service, "avcolor_space", &created );
    if ( !created )
        create_filter( profile, service, "imageconvert", &created );
    create_filter( profile, service, "audioconvert", &created );
}