[FFmpeg-devel] [PATCH] lavu/parseutils: accept hours>=24 for durations.

Nicolas George nicolas.george at normalesup.org
Sat Dec 1 16:04:22 CET 2012


Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
 libavutil/parseutils.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index a335978..a3d5434 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -436,7 +436,8 @@ static int date_get_num(const char **pp,
     return val;
 }
 
-char *av_small_strptime(const char *p, const char *fmt, struct tm *dt)
+static char *av_small_strptime_int(const char *p, const char *fmt,
+                                   struct tm *dt, int hour_max)
 {
     int c, val;
 
@@ -454,7 +455,7 @@ char *av_small_strptime(const char *p, const char *fmt, struct tm *dt)
             c = *fmt++;
             switch(c) {
             case 'H':
-                val = date_get_num(&p, 0, 23, 2);
+                val = date_get_num(&p, 0, hour_max, 2);
                 if (val == -1)
                     return NULL;
                 dt->tm_hour = val;
@@ -503,6 +504,11 @@ char *av_small_strptime(const char *p, const char *fmt, struct tm *dt)
     }
 }
 
+char *av_small_strptime(const char *p, const char *fmt, struct tm *dt)
+{
+    return av_small_strptime_int(p, fmt, dt, 23);
+}
+
 time_t av_timegm(struct tm *tm)
 {
     time_t t;
@@ -581,7 +587,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration)
             ++p;
         }
         /* parse timestr as HH:MM:SS */
-        q = av_small_strptime(p, time_fmt[0], &dt);
+        q = av_small_strptime_int(p, time_fmt[0], &dt, INT_MAX);
         if (!q) {
             /* parse timestr as S+ */
             dt.tm_sec = strtol(p, (void *)&q, 10);
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list