[FFmpeg-devel] [PATCH] parseutils: extend av_parse_time() syntax for durations
Stefano Sabatini
stefano.sabatini-lala at poste.it
Tue Jul 19 12:10:39 CEST 2011
Add support to more formats for expressing a duration, in particular
add support to the syntaxes HHhMMmSSs and HHhMMmSS.mmm.
---
libavutil/parseutils.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index f7e94f8..3c94370 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -507,6 +507,12 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration)
"%H:%M:%S",
"%H%M%S",
};
+ static const char * const duration_fmt[] = {
+ "%H:%M:%S",
+ "%Hh%Mm%Ss",
+ "%Hh%Mm%S",
+ };
+
const char *q;
int is_utc, len;
char lastch;
@@ -569,8 +575,13 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration)
negative = 1;
++p;
}
- /* parse timestr as HH:MM:SS */
- q = small_strptime(p, time_fmt[0], &dt);
+ /* parse the hour-minute-second part */
+ for (i = 0; i < FF_ARRAY_ELEMS(duration_fmt); i++) {
+ q = small_strptime(p, duration_fmt[i], &dt);
+ if (q) {
+ break;
+ }
+ }
if (!q) {
/* parse timestr as S+ */
dt.tm_sec = strtol(p, (char **)&q, 10);
--
1.7.2.5
More information about the ffmpeg-devel
mailing list