From 5b6a64b7961ae0711f9b54675647b350b8b89356 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Sat, 2 Feb 2019 09:57:00 -0600 Subject: [PATCH] Add offset parameter to timer filter. --- src/modules/plus/filter_timer.c | 5 +++++ src/modules/plus/filter_timer.yml | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/modules/plus/filter_timer.c b/src/modules/plus/filter_timer.c index 554262cbb..27db344dd 100644 --- a/src/modules/plus/filter_timer.c +++ b/src/modules/plus/filter_timer.c @@ -40,6 +40,7 @@ static void get_timer_str( mlt_filter filter, mlt_frame frame, char* text ) char* direction = mlt_properties_get( properties, "direction" ); double timer_start = time_to_seconds( mlt_properties_get( properties, "start" ) ); double timer_duration = time_to_seconds( mlt_properties_get( properties, "duration" ) ); + double timer_offset = time_to_seconds( mlt_properties_get( properties, "offset" ) ); double value = time_to_seconds( mlt_properties_frames_to_time( properties, current_frame, mlt_time_clock ) ); if ( timer_duration <= 0.0 ) @@ -71,6 +72,9 @@ static void get_timer_str( mlt_filter filter, mlt_frame frame, char* text ) value = timer_duration - value; } + // Apply offset + value += timer_offset; + int hours = value / ( 60 * 60 ); int mins = ( value / 60 ) - ( hours * 60 ); double secs = value - (double)( mins * 60 ) - (double)( hours * 60 * 60 ); @@ -145,6 +149,7 @@ mlt_filter filter_timer_init( mlt_profile profile, mlt_service_type type, const mlt_properties_set( my_properties, "format", "SS.SS" ); mlt_properties_set( my_properties, "start", "00:00:00.000" ); mlt_properties_set( my_properties, "duration", "00:10:00.000" ); + mlt_properties_set( my_properties, "offset", "00:00:00.000" ); mlt_properties_set( my_properties, "direction", "up" ); mlt_properties_set( my_properties, "geometry", "0%/0%:100%x100%:100%" ); mlt_properties_set( my_properties, "family", "Sans" ); diff --git a/src/modules/plus/filter_timer.yml b/src/modules/plus/filter_timer.yml index fc904db22..e5b1a9dbe 100644 --- a/src/modules/plus/filter_timer.yml +++ b/src/modules/plus/filter_timer.yml @@ -55,6 +55,19 @@ parameters: mutable: yes widget: text + - identifier: offset + title: Offset + type: string + description: > + An offset to be added to the timer value. When the direction is "down", + the timer will count down to "offset" instead of 00:00:00.000. When the + direction is up, the timer will count up starting from "offset". + Must be in the format HH:MM:SS.SSS + default: 00:00:00.000 + readonly: no + mutable: yes + widget: text + - identifier: direction title: Direction type: string