summaryrefslogtreecommitdiff
path: root/libavutil/timecode.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2020-09-05 23:04:28 +0200
committerMarton Balint <cus@passwd.hu>2020-12-03 18:32:54 +0100
commiteca12f4d5a9231b0e6b71f55525518f104877ee6 (patch)
treeb52f3cd54e26eed79027977f2db57fe8c095ccbb /libavutil/timecode.c
parent2d90d51c561c2e4c36a00d1ba666adee5028663c (diff)
avutil/timecode: add av_timecode_init_from_components
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavutil/timecode.c')
-rw-r--r--libavutil/timecode.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/libavutil/timecode.c b/libavutil/timecode.c
index 7caa6c64f5..c1fa445d31 100644
--- a/libavutil/timecode.c
+++ b/libavutil/timecode.c
@@ -226,19 +226,12 @@ int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start
return check_timecode(log_ctx, tc);
}
-int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx)
+int av_timecode_init_from_components(AVTimecode *tc, AVRational rate, int flags, int hh, int mm, int ss, int ff, void *log_ctx)
{
- char c;
- int hh, mm, ss, ff, ret;
-
- if (sscanf(str, "%d:%d:%d%c%d", &hh, &mm, &ss, &c, &ff) != 5) {
- av_log(log_ctx, AV_LOG_ERROR, "Unable to parse timecode, "
- "syntax: hh:mm:ss[:;.]ff\n");
- return AVERROR_INVALIDDATA;
- }
+ int ret;
memset(tc, 0, sizeof(*tc));
- tc->flags = c != ':' ? AV_TIMECODE_FLAG_DROPFRAME : 0; // drop if ';', '.', ...
+ tc->flags = flags;
tc->rate = rate;
tc->fps = fps_from_frame_rate(rate);
@@ -253,3 +246,18 @@ int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *st
}
return 0;
}
+
+int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx)
+{
+ char c;
+ int hh, mm, ss, ff, flags;
+
+ if (sscanf(str, "%d:%d:%d%c%d", &hh, &mm, &ss, &c, &ff) != 5) {
+ av_log(log_ctx, AV_LOG_ERROR, "Unable to parse timecode, "
+ "syntax: hh:mm:ss[:;.]ff\n");
+ return AVERROR_INVALIDDATA;
+ }
+ flags = c != ':' ? AV_TIMECODE_FLAG_DROPFRAME : 0; // drop if ';', '.', ...
+
+ return av_timecode_init_from_components(tc, rate, flags, hh, mm, ss, ff, log_ctx);
+}