]> git.sesse.net Git - mlt/blobdiff - src/modules/core/filter_data_show.c
Add #frame# variable substitution in data_show filter.
[mlt] / src / modules / core / filter_data_show.c
index 7c9ab3d606c0dbd9da87e364a81be7007b0a56ee..7a7a654eb5ad4d701253d568de14185b8be9ed5f 100644 (file)
@@ -50,9 +50,9 @@ static mlt_filter obtain_filter( mlt_filter filter, char *type )
 
                // If none is specified, pick up the default for this normalisation
                if ( profile == NULL )
-                       sprintf( temp, "%s/feeds/%s/data_fx.properties", mlt_factory_prefix( ), mlt_environment( "MLT_NORMALISATION" ) );
+                       sprintf( temp, "%s/feeds/%s/data_fx.properties", mlt_environment( "MLT_DATA" ), mlt_environment( "MLT_NORMALISATION" ) );
                else if ( strchr( profile, '%' ) )
-                       sprintf( temp, "%s/feeds/%s/%s", mlt_factory_prefix( ), mlt_environment( "MLT_NORMALISATION" ), strchr( profile, '%' ) + 1 );
+                       sprintf( temp, "%s/feeds/%s/%s", mlt_environment( "MLT_DATA" ), mlt_environment( "MLT_NORMALISATION" ), strchr( profile, '%' ) + 1 );
                else
                        strcpy( temp, profile );
 
@@ -98,12 +98,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;
@@ -144,7 +144,7 @@ static int process_feed( mlt_properties feed, mlt_filter filter, mlt_frame frame
        {
                int i = 0;
                mlt_properties properties = MLT_FILTER_PROPERTIES( requested );
-               static char *prefix = "properties.";
+               static const char *prefix = "properties.";
                int len = strlen( prefix );
 
                // Determine if this is an absolute or relative feed
@@ -205,10 +205,18 @@ 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( NULL ) );
+                                                                       char *tc = frame_to_timecode( pos, mlt_profile_fps( mlt_service_profile( MLT_FILTER_SERVICE( filter ) ) ) );
                                                                        strcat( result, tc );
                                                                        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 );
+                                                                       strcat( result, s );
+                                                               }
                                                                else
                                                                {
                                                                        // replace keyword with metadata value