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

Stefano Sabatini stefasab at gmail.com
Sun Dec 2 11:43:30 CET 2012


On date Saturday 2012-12-01 21:01:46 +0100, Nicolas George encoded:
> Allow to parse durations >= 24:00:00.
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  libavutil/parseutils.c |    5 +++--
>  libavutil/parseutils.h |    1 +
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> 
> Replaced %h by %J.
> 
> Concerning the principle of the use of strptime to parse durations: whether
> it is a good idea or not is moot, as changing it would be breaking backward
> compatibility.
> 
> 
> diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
> index a335978..f188e81 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 'J':
> +                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, "%J:%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..1f56a7a 100644
> --- a/libavutil/parseutils.h
> +++ b/libavutil/parseutils.h
> @@ -141,6 +141,7 @@ 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'
> + * - %J: hours as a decimal number, in the range '0' 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

Fine with me. Reminder: micro bump.
-- 
FFmpeg = Furious and Formidable Magic Perfectionist Exuberant Gangster


More information about the ffmpeg-devel mailing list