[FFmpeg-devel] [PATCH] Make parse_date return INT64_MIN in case of unparsable input

Stefano Sabatini stefano.sabatini-lala
Tue Sep 18 15:56:01 CEST 2007


On date Thursday 2007-09-13 14:02:48 +0200, Stefano Sabatini encoded:
> On date Wednesday 2007-09-12 18:01:25 +0200, Michael Niedermayer encoded:
[...]
> > > Index: libavformat/utils.c
> > > ===================================================================
> > > --- libavformat/utils.c	(revision 10474)
> > > +++ libavformat/utils.c	(working copy)
> > > @@ -2621,10 +2621,7 @@
> > >  
> > >      /* Now we have all the fields that we can get */
> > >      if (!q) {
> > > -        if (duration)
> > > -            return 0;
> > > -        else
> > > -            return now * INT64_C(1000000);
> > > +        return INT64_MIN;
> > >      }
> > >  
> > >      if (duration) {
> > 
> > ok if it doesnt break anything
> 
> I just noticed that it fails wherever the error condition is raised
> and isn't handled, that is everywhere the function is actually used
> (in every ff*).
> 
> So the patch as it is is *not* OK.

The attached patch also manages the situations when the input parsed by
parse_date is unvalid.

Actually the code doesn't manage such errors, and uses the value of 0
for a duration and of the current time for a date.

For example:
ffmpeg -t foo -ss bar -timestamp baz INPUT OUTPUT
is equivalent to:
ffmpeg -t 0 -ss 0 -timestamp $(date "+%Y-%m-%d %H:%M:%S") INPUT OUTPUT

With the patch applied we get:
./ffmpeg -t foo
FFmpeg version SVN-r10526, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  configuration: --prefix=/home/sds --enable-gpl --enable-pp --enable-libfaad --enable-libfaac --enable-libamr-nb --enable-libamr-wb --enable-x11grab --enable-libmp3lame
  libavutil version: 49.5.0
  libavcodec version: 51.44.0
  libavformat version: 51.13.3
  built on Sep 18 2007 15:07:31, gcc: 4.1.2 20061028 (prerelease) (Debian 4.1.1-19)
Unparsable duration specification: foo

Since the patch changes the behaviour of an api function, I also
increased the micro version number of libavutil.

Another related problem: parse_date() is also used by
libavformat/rtsp.c:rtsp_parse_range_npt(), which returns void, so it
can't signal errors and I didn't change its code.

Should I fix this rather than leaving the eventul parsing error
unmanaged in rtsp_parse_range_npt as it currently is?

Regards and thanks for your review.
-- 
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: make-parse-date-return-int64min-if-unparsable-input-02.patch
Type: text/x-diff
Size: 5596 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070918/8f9857bf/attachment.patch>



More information about the ffmpeg-devel mailing list