]> git.sesse.net Git - mlt/commitdiff
Add producer variant avformat-novalidate.
authorDan Dennedy <dan@dennedy.org>
Mon, 14 Dec 2009 00:59:23 +0000 (16:59 -0800)
committerDan Dennedy <dan@dennedy.org>
Mon, 14 Dec 2009 00:59:23 +0000 (16:59 -0800)
The purpose of this is to increase the speed of loading playlists with
known good files. Use with care. This assumes a few properties have been
set, in particular "length." This was only tested thus far by modifying
the output of consumer xml to change mlt_service from "avformat" to
"avformat-novalidate".

src/modules/avformat/factory.c
src/modules/avformat/producer_avformat.c

index 54adf936d9026e1b41c6bc32b1e808d2920e23bd..a8559f8e24b57820eaadb06014f5e0809b1e758c 100644 (file)
@@ -29,7 +29,7 @@ extern mlt_filter filter_avcolour_space_init( void *arg );
 extern mlt_filter filter_avdeinterlace_init( void *arg );
 extern mlt_filter filter_avresample_init( char *arg );
 extern mlt_filter filter_swscale_init( mlt_profile profile, char *arg );
-extern mlt_producer producer_avformat_init( mlt_profile profile, char *file );
+extern mlt_producer producer_avformat_init( mlt_profile profile, const char *service, char *file );
 
 // ffmpeg Header files
 #include <avformat.h>
@@ -98,10 +98,10 @@ static void *create_service( mlt_profile profile, mlt_service_type type, const c
 {
        avformat_init( );
 #ifdef CODECS
-       if ( !strcmp( id, "avformat" ) )
+       if ( !strncmp( id, "avformat", 8 ) )
        {
                if ( type == producer_type )
-                       return producer_avformat_init( profile, arg );
+                       return producer_avformat_init( profile, id, arg );
                else if ( type == consumer_type )
                        return consumer_avformat_init( profile, arg );
        }
@@ -151,6 +151,7 @@ MLT_REPOSITORY
 #ifdef CODECS
        MLT_REGISTER( consumer_type, "avformat", create_service );
        MLT_REGISTER( producer_type, "avformat", create_service );
+       MLT_REGISTER( producer_type, "avformat-novalidate", create_service );
        MLT_REGISTER_METADATA( producer_type, "avformat", avformat_metadata, NULL );
 #endif
 #ifdef FILTERS
index aa9fa9542b4899aa286563a456c1b7676b7c92e9..21107493af2e5ab96f11c8d638284a2c6fff227a 100644 (file)
@@ -126,7 +126,7 @@ static void producer_close( mlt_producer parent );
 /** Constructor for libavformat.
 */
 
-mlt_producer producer_avformat_init( mlt_profile profile, char *file )
+mlt_producer producer_avformat_init( mlt_profile profile, const char *service, char *file )
 {
        int skip = 0;
 
@@ -185,27 +185,37 @@ mlt_producer producer_avformat_init( mlt_profile profile, char *file )
                        // Register our get_frame implementation
                        producer->get_frame = producer_get_frame;
                        
-                       // Open the file
-                       if ( producer_open( this, profile, file ) != 0 )
+                       if ( strcmp( service, "avformat-novalidate" ) )
                        {
-                               // Clean up
-                               mlt_producer_close( producer );
-                               producer = NULL;
+                               // Open the file
+                               if ( producer_open( this, profile, file ) != 0 )
+                               {
+                                       // Clean up
+                                       mlt_producer_close( producer );
+                                       producer = NULL;
+                               }
+                               else
+                               {
+                                       // Close the file to release resources for large playlists - reopen later as needed
+                                       producer_format_close( this->dummy_context );
+                                       this->dummy_context = NULL;
+                                       producer_format_close( this->audio_format );
+                                       this->audio_format = NULL;
+                                       producer_format_close( this->video_format );
+                                       this->video_format = NULL;
+       
+                                       // Default the user-selectable indices from the auto-detected indices
+                                       mlt_properties_set_int( properties, "audio_index",  this->audio_index );
+                                       mlt_properties_set_int( properties, "video_index",  this->video_index );
+                                       
+#ifdef VDPAU
+                                       mlt_service_cache_set_size( MLT_PRODUCER_SERVICE(producer), "producer_avformat", 5 );
+#endif
+                                       mlt_service_cache_put( MLT_PRODUCER_SERVICE(producer), "producer_avformat", this, 0, (mlt_destructor) producer_avformat_close );
+                               }
                        }
                        else
                        {
-                               // Close the file to release resources for large playlists - reopen later as needed
-                               producer_format_close( this->dummy_context );
-                               this->dummy_context = NULL;
-                               producer_format_close( this->audio_format );
-                               this->audio_format = NULL;
-                               producer_format_close( this->video_format );
-                               this->video_format = NULL;
-
-                               // Default the user-selectable indices from the auto-detected indices
-                               mlt_properties_set_int( properties, "audio_index",  this->audio_index );
-                               mlt_properties_set_int( properties, "video_index",  this->video_index );
-                               
 #ifdef VDPAU
                                mlt_service_cache_set_size( MLT_PRODUCER_SERVICE(producer), "producer_avformat", 5 );
 #endif