[FFmpeg-devel] [PATCH] lavu/parseutils: accept %h for hours >= 24.
Nicolas George
nicolas.george at normalesup.org
Sat Dec 1 17:00:32 CET 2012
Allow to parse durations >= 24:00:00.
Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
libavutil/parseutils.c | 5 +++--
libavutil/parseutils.h | 2 ++
libavutil/version.h | 2 +-
3 files changed, 6 insertions(+), 3 deletions(-)
This is the other suggested solution, but I must say I prefer the other one
(adding an argument to the internal implementation of strptime) by far.
Does anyone else have an opinion?
diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index a335978..2a23262 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -454,7 +454,8 @@ 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);
+ case 'h':
+ val = date_get_num(&p, 0, c == 'H' ? 23 : INT_MAX, 2);
if (val == -1)
return NULL;
dt->tm_hour = val;
@@ -581,7 +582,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(p, "%h:%M:%S", &dt);
if (!q) {
/* parse timestr as S+ */
dt.tm_sec = strtol(p, (void *)&q, 10);
diff --git a/libavutil/parseutils.h b/libavutil/parseutils.h
index da7d345..24481ec 100644
--- a/libavutil/parseutils.h
+++ b/libavutil/parseutils.h
@@ -141,6 +141,8 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration);
* In particular it actually supports the parameters:
* - %H: the hour as a decimal number, using a 24-hour clock, in the
* range '00' through '23'
+ * - %h: the hour as a decimal number, using a 24-hour clock, in the
+ * range '00' through INT_MAX
* - %M: the minute as a decimal number, using a 24-hour clock, in the
* range '00' through '59'
* - %S: the second as a decimal number, using a 24-hour clock, in the
diff --git a/libavutil/version.h b/libavutil/version.h
index 9f22ff7..b46c3f2 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -75,7 +75,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 52
-#define LIBAVUTIL_VERSION_MINOR 10
+#define LIBAVUTIL_VERSION_MINOR 11
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
--
1.7.10.4
More information about the ffmpeg-devel
mailing list