]> git.sesse.net Git - mlt/commitdiff
add image cache size property to avformat producer
authorDan Dennedy <dan@dennedy.org>
Sun, 5 Aug 2012 04:05:16 +0000 (21:05 -0700)
committerDan Dennedy <dan@dennedy.org>
Sun, 5 Aug 2012 04:08:10 +0000 (21:08 -0700)
src/modules/avformat/producer_avformat.c
src/modules/avformat/producer_avformat.yml

index 2254ad1d06bd805ea43d910a058c7f4d426b64da..85cf346a4e91fa4444ccb09fa5d12f3dda723aab 100644 (file)
@@ -1402,9 +1402,26 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        int image_size = 0;
 
        // Get the image cache
-       if ( ! self->image_cache && ! mlt_properties_get_int( properties, "noimagecache" ) )
+       if ( ! self->image_cache )
        {
-               self->image_cache = mlt_cache_init();
+               // if cache size supplied by environment variable
+               int cache_supplied = getenv( "MLT_AVFORMAT_CACHE" ) != NULL;
+               int cache_size = cache_supplied? atoi( getenv( "MLT_AVFORMAT_CACHE" ) ) : 0;
+
+               // cache size supplied via property
+               if ( mlt_properties_get( properties, "cache" ) )
+               {
+                       cache_supplied = 1;
+                       cache_size = mlt_properties_get_int( properties, "cache" );
+               }
+               if ( mlt_properties_get_int( properties, "noimagecache" ) )
+                       cache_size = 0;
+               // create cache if not disabled
+               if ( !cache_supplied || cache_size > 0 )
+                       self->image_cache = mlt_cache_init();
+               // set cache size if supplied
+               if ( self->image_cache && cache_supplied )
+                       mlt_cache_set_size( self->image_cache, cache_size );
        }
        if ( self->image_cache )
        {
index c2a56133fc56a949bac08cf7f2f40fd61a0baea6..07c41c90e1d8d3a7548eab591288a92cb5b1ba4c 100644 (file)
@@ -119,6 +119,20 @@ parameters:
     default: 0
     widget: checkbox
 
+  - identifier: cache
+    title: Number of images cache
+    type: integer
+    description: >
+      By default, this producer caches images to facilitate YADIF deinterlace,
+      which needs previous and next frames. Also, caching helps with frame-
+      stepping within a player. The default number of images cached is supplied
+      by the MLT framework, which is currently 4, but you can override it
+      with this property. You can also disable caching by setting it to 0.
+      If you are using parallel processing with YADIF deinterlacing, then
+      you might need to increase caching to prevent inadvertent backward seeks.
+      One can also set this value globally for all instances of avformat by
+      setting the environment variable MLT_AVFORMAT_CACHE.
+
   - identifier: use_pts
     title: Use video PTS
     description: >