]> git.sesse.net Git - mlt/blobdiff - src/modules/core/producer_loader.c
add mlt_frame_original_position()
[mlt] / src / modules / core / producer_loader.c
index a6c8fc2b4f9ba65e49ea6a0a76d4ef6b9917363d..7b43c0c2e8722a2bda658e02562e15625d50d514 100644 (file)
@@ -53,7 +53,8 @@ static mlt_producer create_producer( mlt_profile profile, char *file )
        mlt_producer result = NULL;
 
        // 1st Line - check for service:resource handling
-       if ( strchr( file, ':' ) )
+       // And ignore drive letters on Win32 - no single char services supported.
+       if ( strchr( file, ':' ) > file + 1 )
        {
                char *temp = strdup( file );
                char *service = temp;
@@ -70,6 +71,9 @@ static mlt_producer create_producer( mlt_profile profile, char *file )
                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 )
                {
@@ -86,14 +90,45 @@ static mlt_producer create_producer( mlt_profile profile, char *file )
                        p ++;
                }
 
+               // Strip file:// prefix
+               p = lookup;
+               if ( strncmp( lookup, "file://", 7 ) == 0 )
+                       p += 7;
+
                // Iterate through the dictionary
                for ( i = 0; result == NULL && i < mlt_properties_count( dictionary ); i ++ )
                {
                        char *name = mlt_properties_get_name( dictionary, i );
-                       if ( fnmatch( name, lookup, 0 ) == 0 )
+                       if ( fnmatch( name, p, 0 ) == 0 )
                                result = create_from( profile, file, mlt_properties_get_value( dictionary, i ) );
+               }       
+
+               // Check if the producer changed the profile - xml does this.
+               // The consumer producer does not handle frame rate differences.
+               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 ||
+                    profile->colorspace != backup_profile->colorspace ) )
+               {
+                       // 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 );
        }
 
@@ -113,7 +148,7 @@ static void create_filter( mlt_profile profile, mlt_producer producer, char *eff
 
        // The swscale and avcolor_space filters require resolution as arg to test compatibility
        if ( strncmp( effect, "swscale", 7 ) == 0 || strncmp( effect, "avcolo", 6 ) == 0 )
-               arg = (char*) mlt_properties_get_int( MLT_PRODUCER_PROPERTIES( producer ), "_real_width" );
+               arg = (char*) mlt_properties_get_int( MLT_PRODUCER_PROPERTIES( producer ), "meta.media.width" );
 
        mlt_filter filter = mlt_factory_filter( profile, id, arg );
        if ( filter != NULL )
@@ -172,6 +207,7 @@ mlt_producer producer_loader_init( mlt_profile profile, mlt_service_type type, c
 
        // Attach filters if we have a producer and it isn't already xml'd :-)
        if ( producer && strcmp( id, "abnormal" ) &&
+               strncmp( arg, "abnormal:", 9 ) &&
                mlt_properties_get( properties, "xml" ) == NULL &&
                mlt_properties_get( properties, "_xml" ) == NULL &&
                mlt_properties_get( properties, "loader_normalised" ) == NULL )
@@ -181,10 +217,8 @@ mlt_producer producer_loader_init( mlt_profile profile, mlt_service_type type, c
        {
                // Always let the image and audio be converted
                int created = 0;
-#ifndef __DARWIN__
                create_filter( profile, producer, "avcolor_space", &created );
                if ( !created )
-#endif
                        create_filter( profile, producer, "imageconvert", &created );
                create_filter( profile, producer, "audioconvert", &created );
        }