#include <framework/mlt.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
/** Handle the profile.
*/
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 );
/** 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;
// 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++;
// 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 );
}