Move it into the loader producer so apps other than melt can use it too.
To use it, an app must set the profile to explicit.
mlt_frame_close( fr );
mlt_service_get_frame( MLT_PRODUCER_SERVICE(melt), &fr, 0 );
p = MLT_FRAME_PROPERTIES( fr );
+// mlt_properties_dump(p, stderr);
if ( mlt_properties_get_int( p, "meta.media.frame_rate_den" ) && mlt_properties_get_int( p, "meta.media.sample_aspect_den" ) )
{
profile->width = mlt_properties_get_int( p, "meta.media.width" );
profile->sample_aspect_den = mlt_properties_get_int( p, "meta.media.sample_aspect_den" );
profile->display_aspect_num = (int) ( (double) profile->sample_aspect_num * profile->width / profile->sample_aspect_den + 0.5 );
profile->display_aspect_den = profile->height;
+ free( profile->description );
+ profile->description = strdup( "automatic" );
+ profile->is_explicit = 0;
}
}
}
FILE *store = NULL;
char *name = NULL;
mlt_profile profile = NULL;
- mlt_profile backup_profile = NULL;
int is_progress = 0;
int is_silent = 0;
- int is_profile_explicit = 0;
// Construct the factory
mlt_repository repo = mlt_factory_init( NULL );
if ( profile == NULL )
profile = mlt_profile_init( NULL );
else
- is_profile_explicit = 1;
+ profile->is_explicit = 1;
// Look for the consumer option to load profile settings from consumer properties
load_consumer( &consumer, profile, argc, argv );
- // Make backup of profile for determining if we need to use 'consumer' producer.
- backup_profile = mlt_profile_init( NULL );
- memcpy( backup_profile, profile, sizeof( struct mlt_profile_s ) );
- backup_profile->description = strdup( "" );
-
// Get melt producer
if ( argc > 1 )
melt = mlt_factory_producer( profile, "melt", &argv[ 1 ] );
if ( melt )
{
- // If the producer changed the profile then do not try to guess it.
- if ( profile->width != backup_profile->width ||
- profile->height != backup_profile->height ||
- profile->sample_aspect_num != backup_profile->sample_aspect_num ||
- profile->sample_aspect_den != backup_profile->sample_aspect_den )
- {
- if ( is_profile_explicit )
- {
- // We need to use the 'consumer' producer.
- mlt_producer_close( melt );
- mlt_profile_close( profile );
- profile = backup_profile;
- backup_profile = NULL;
- if ( profile->description )
- free( profile->description );
- // This is a hack to signal create_producer() in producer_melt.c.
- profile->description = strdup( "consumer:" );
- melt = mlt_factory_producer( profile, "melt", &argv[ 1 ] );
- }
- }
- else if ( ! is_profile_explicit )
- {
+ // Generate an automatic profile if needed.
+ if ( ! profile->is_explicit )
guess_profile( melt, profile );
- }
// Reload the consumer with the fully qualified profile
load_consumer( &consumer, profile, argc, argv );
// Close the factory
mlt_profile_close( profile );
- mlt_profile_close( backup_profile );
exit_factory:
{
cx->profile = mlt_profile_init( profile_name );
cx->is_close_profile = 1;
+ cx->profile->is_explicit = 1;
}
else
{
cx->profile = profile;
cx->is_close_profile = 0;
+ cx->profile->is_explicit = 0;
}
// For now, we must conform the nested network's frame rate to the parent network's
char *lookup = strdup( file );
char *p = lookup;
+ // Make backup of profile for determining if we need to use 'consumer' producer.
+ mlt_profile backup_profile = mlt_profile_clone( profile );
+
// We only need to load the dictionary once
if ( dictionary == NULL )
{
char *name = mlt_properties_get_name( dictionary, i );
if ( fnmatch( name, lookup, 0 ) == 0 )
result = create_from( profile, file, mlt_properties_get_value( dictionary, i ) );
+ }
+
+ // Check if the producer changed the profile - xml does this.
+ if ( result && backup_profile->is_explicit && (
+ profile->width != backup_profile->width ||
+ profile->height != backup_profile->height ||
+ profile->sample_aspect_num != backup_profile->sample_aspect_num ||
+ profile->sample_aspect_den != backup_profile->sample_aspect_den ) )
+ {
+ // Restore the original profile attributes.
+ profile->display_aspect_den = backup_profile->display_aspect_den;
+ profile->display_aspect_num = backup_profile->display_aspect_num;
+ profile->frame_rate_den = backup_profile->frame_rate_den;
+ profile->frame_rate_num = backup_profile->frame_rate_num;
+ profile->height = backup_profile->height;
+ profile->progressive = backup_profile->progressive;
+ profile->sample_aspect_den = backup_profile->sample_aspect_den;
+ profile->sample_aspect_num = backup_profile->sample_aspect_num;
+ profile->width = backup_profile->width;
+
+ // Use the 'consumer' producer.
+ mlt_producer_close( result );
+ result = mlt_factory_producer( profile, "consumer", file );
}
+ mlt_profile_close( backup_profile );
free( lookup );
}
static mlt_producer create_producer( mlt_profile profile, mlt_field field, char *file )
{
- char *filedup;
- if ( profile->description && strncmp( file, "consumer:", 9 ) && !strcmp( profile->description, "consumer:" ) )
- {
- filedup = calloc( 1, strlen( file ) + strlen( profile->description ) + 1 );
- strcat( filedup, profile->description );
- strcat( filedup, file );
- }
- else
- {
- filedup = strdup( file );
- }
- mlt_producer result = mlt_factory_producer( profile, NULL, filedup );
- free( filedup );
+ mlt_producer result = mlt_factory_producer( profile, NULL, file );
if ( result != NULL )
track_service( field, result, ( mlt_destructor )mlt_producer_close );
p->progressive = my_profile->progressive;
p->sample_aspect_den = my_profile->sample_aspect_den;
p->sample_aspect_num = my_profile->sample_aspect_num;
+ p->is_explicit = 1;
mlt_profile_close( my_profile );
}
}
if ( p->description )
free( p->description );
p->description = strdup( _s(atts[ 1 ]) );
+ p->is_explicit = 1;
}
else if ( xmlStrcmp( atts[ 0 ], _x("display_aspect_den") ) == 0 )
p->display_aspect_den = strtol( _s(atts[ 1 ]), NULL, 0 );