From e62a7000f29f863fdc8fef384c21a23c8b6a2a17 Mon Sep 17 00:00:00 2001 From: Maksym Veremeyenko Date: Sat, 18 Jun 2011 16:14:39 +0300 Subject: [PATCH] timecode parser added --- src/timecode.c | 14 ++++++++++++++ src/timecode.h | 1 + 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/src/timecode.c b/src/timecode.c index f5559de..7f7363d 100644 --- a/src/timecode.c +++ b/src/timecode.c @@ -42,3 +42,17 @@ char* frames2tc(int f, float fps, char* buf) } +int tc2frames(char* tc, float fps, int *f) +{ + int hh, mm, ss, ff; + + *f = 0; + + if(4 != sscanf(tc, "%d:%d:%d:%d", + &hh, &mm, &ss, &ff)) + return -1; + + *f = ff + fps * (ss + 60 * (mm + 60 * hh)); + + return 0; +} diff --git a/src/timecode.h b/src/timecode.h index b99d96a..e238cb6 100644 --- a/src/timecode.h +++ b/src/timecode.h @@ -26,6 +26,7 @@ extern "C" #endif /* __cplusplus */ char* frames2tc(int f, float fps, char* buf); +int tc2frames(char* tc, float fps, int *f); #ifdef __cplusplus }; -- 1.7.4.4