[FFmpeg-devel] Set AV_TIMECODE_FLAG_ALLOWNEGATIVE in avutil/timecode.c av_timecode_init_from_string

jon jon at tweaksoftware.com
Tue Sep 9 21:24:21 CEST 2014


If the timecode value is negative it certainly seems safe to set the 
AV_TIMECODE_FLAG_ALLOWNEGATIVE on the AVTimecode object.
-------------- next part --------------
>From 35ae38f9557e1ff01040d0e681e843d1727f979b Mon Sep 17 00:00:00 2001
From: Jon Morley <jon at tweaksoftware.com>
Date: Tue, 9 Sep 2014 12:12:17 -0700
Subject: [PATCH 2/2] libavutil/timecode.c: improve flag setting when init tc
 from string

If the string begins with a negative HH (hour) value then make sure to
set the AV_TIMECODE_FLAG_ALLOW_NEGATIVE flag for the resulting
tc->flags.
---
 libavutil/timecode.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavutil/timecode.c b/libavutil/timecode.c
index 1dfd040..b96a4d1 100644
--- a/libavutil/timecode.c
+++ b/libavutil/timecode.c
@@ -201,9 +201,10 @@ int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *st
     }
 
     memset(tc, 0, sizeof(*tc));
-    tc->flags = c != ':' ? AV_TIMECODE_FLAG_DROPFRAME : 0; // drop if ';', '.', ...
-    tc->rate  = rate;
-    tc->fps   = fps_from_frame_rate(rate);
+    tc->flags  = c != ':' ? AV_TIMECODE_FLAG_DROPFRAME : 0; // drop if ';', '.', ...
+    tc->flags |= (hh < 0) ? AV_TIMECODE_FLAG_ALLOWNEGATIVE : 0; // neg if starts with '-'
+    tc->rate   = rate;
+    tc->fps    = fps_from_frame_rate(rate);
 
     ret = check_timecode(log_ctx, tc);
     if (ret < 0)
-- 
1.8.5.2 (Apple Git-48)



More information about the ffmpeg-devel mailing list