]> git.sesse.net Git - mlt/blobdiff - src/modules/core/filter_data_show.c
Tell loader how to use WebVfx.
[mlt] / src / modules / core / filter_data_show.c
index d62bd58991013f2200c01ed8ba7f8d0ca792d396..47f09f26645677737ca4297bc1ee95942c899f26 100644 (file)
@@ -21,6 +21,7 @@
 #include <framework/mlt.h>
 #include <stdlib.h>
 #include <string.h>
+#include <math.h>
 
 /** Handle the profile.
 */
@@ -54,7 +55,10 @@ static mlt_filter obtain_filter( mlt_filter filter, char *type )
                else if ( strchr( profile, '%' ) )
                        sprintf( temp, "%s/feeds/%s/%s", mlt_environment( "MLT_DATA" ), mlt_environment( "MLT_NORMALISATION" ), strchr( profile, '%' ) + 1 );
                else
-                       strcpy( temp, profile );
+               {
+                       strncpy( temp, profile, sizeof( temp ) );
+                       temp[ sizeof( temp ) - 1 ] = '\0';
+               }
 
                // Load the specified profile or use the default
                profile_properties = mlt_properties_load( temp );
@@ -98,12 +102,12 @@ char* metadata_value(mlt_properties properties, char* name)
 /** Convert frames to Timecode 
 */
 
-char* frame_to_timecode( int frames , int fps)
+char* frame_to_timecode( int frames, double fps)
 {
        if (fps == 0) return strdup("-");
        char *res = malloc(12);
-       int seconds = frames / (int) fps;
-       frames = frames % ((int) fps);
+       int seconds = frames / fps;
+       frames = frames % lrint( fps );
        int minutes = seconds / 60;
        seconds = seconds % 60;
        int hours = minutes / 60;
@@ -206,14 +210,23 @@ static int process_feed( mlt_properties feed, mlt_filter filter, mlt_frame frame
                                                                        // special case: replace #timecode# with current frame timecode
                                                                        int pos = mlt_properties_get_int( feed, "position" );
                                                                        char *tc = frame_to_timecode( pos, mlt_profile_fps( mlt_service_profile( MLT_FILTER_SERVICE( filter ) ) ) );
-                                                                       strcat( result, tc );
+                                                                       strncat( result, tc, sizeof( result ) - strlen( result ) - 1 );
                                                                        free( tc );
                                                                }
+                                                               else if ( !strcmp( keywords, "frame" ) )
+                                                               {
+                                                                       // special case: replace #frame# with current frame number
+                                                                       int pos = mlt_properties_get_int( feed, "position" );
+                                                                       char s[12];
+                                                                       snprintf( s, sizeof(s) - 1, "%d", pos );
+                                                                       s[sizeof( s ) - 1] = '\0';
+                                                                       strcat( result, s );
+                                                               }
                                                                else
                                                                {
                                                                        // replace keyword with metadata value
                                                                        char *metavalue = metadata_value( MLT_FRAME_PROPERTIES( frame ), keywords );
-                                                                       strcat( result, metavalue ? metavalue : "-" );
+                                                                       strncat( result, metavalue ? metavalue : "-", sizeof( result ) - strlen( result ) -1 );
                                                                }
                                                                keywords = strtok( NULL, "#" );
                                                                ct++;
@@ -291,12 +304,16 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
        // Get the frame properties
        mlt_properties frame_properties = MLT_FRAME_PROPERTIES( frame );
 
+       mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
+
        // Track specific
        process_queue( mlt_properties_get_data( frame_properties, "data_queue", NULL ), frame, filter );
 
        // Global
        process_queue( mlt_properties_get_data( frame_properties, "global_queue", NULL ), frame, filter );
 
+       mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
+
        // Need to get the image
        return mlt_frame_get_image( frame, image, format, width, height, 1 );
 }