[FFmpeg-devel] [PATCH] parseutils: accept only full "ms" and "us" prefixes
Bodecs Bela
bodecsb at vivanet.hu
Sat Mar 3 22:46:33 EET 2018
2018.03.03. 21:19 keltezéssel, Rostislav Pehlivanov írta:
> The commit which added those was pushed prematurely before anyone could object
> to illogical suffixes like just m for milliseconds. Without this, we'd be locked
> into never being able to implement the "m" suffix for minutes.
>
> Signed-off-by: Rostislav Pehlivanov <atomnuker at gmail.com>
> ---
> libavutil/parseutils.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
> index 44c845577a..1b81757aab 100644
> --- a/libavutil/parseutils.c
> +++ b/libavutil/parseutils.c
> @@ -689,17 +689,15 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration)
>
> if (duration) {
> t = dt.tm_hour * 3600 + dt.tm_min * 60 + dt.tm_sec;
> - if (*q == 'm') {
> + if (q[0] == 'm' && q[1] == 's') {
> suffix = 1000;
> microseconds /= 1000;
> - q++;
> - } else if (*q == 'u') {
> + q += 2;
> + } else if (q[0] == 'u' && q[1] == 's') {
> suffix = 1;
> microseconds = 0;
> - q++;
> + q += 2;
> }
> - if (*q == 's')
> - q++;
> } else {
> int is_utc = *q == 'Z' || *q == 'z';
> int tzoffset = 0;
I read the other thread about this problem.
I think the problem is that SI prefixes u (micro) m (mili) h (hecto) d
(deci) k (kilo) M (mega) etc may overlap with time period names: s
(second) m (minutes) h (hour) d (day) etc.
Because only second can have prefixes (mili sec, micro sec, nano sec )
among time period names, thus your solution is good workaround.
But it will be complete only if we use this logic for nano sec also. But
I am not sure if ffmpeg uses nano sec anywhere.
bb
More information about the ffmpeg-devel
mailing list