[FFmpeg-devel] [PATCH] Make parse_date return INT64_MIN in case of unparsable input
Michael Niedermayer
michaelni
Wed Sep 12 18:01:25 CEST 2007
Hi
On Wed, Sep 12, 2007 at 04:49:16PM +0200, Stefano Sabatini wrote:
> On date Wednesday 2007-09-12 13:24:10 +0200, Michael Niedermayer encoded:
> > Hi
> >
> > On Wed, Sep 12, 2007 at 12:32:12PM +0200, Stefano Sabatini wrote:
> > > On date Wednesday 2007-09-12 12:00:50 +0200, Michael Niedermayer encoded:
> > > > Hi
> > > >
> > > > On Wed, Sep 12, 2007 at 11:13:24AM +0200, Stefano Sabatini wrote:
> > > > [...]
> > > > > + * Returns the number of microseconds since 1st of January, 1970 up
> > > > > + * to the time of the parsed date or up to the current time if \p
> > > > > + * datestr cannot be successfully parsed.
> > > >
> > > > i do not think that this is the intended behavior but rather a "bug"
> > > > in the implementation thus you change the API by hardcoding the bug in
> > > > it and would need to bump the respective versions but i wont accept that
> > >
> > > Got the point.
> > >
> > > > using the current date in case a string cannot be parsed is a very odd
> > > > way to handle an error
> > >
> > > Completely agree.
> > >
> > > Possible solutions:
> > >
> > > 1. make parse_date return a negative number in case of error (what
> > > happens if the date parsed is before 1970-01-01?)
> >
> > return INT64_MIN for an error, that wont collide with pre 1970 dates
>
> Here it is.
>
> Suggested log: $subject.
>
> If you're OK I can also eventually apply the second proposed solution,
> that is to deprecate parse_date in favour of a function like:
> int av_parse_date (int64_t *us, char *timestr, int is_duration)
>
> which is imho cleaner (yes I know, I'm risking to be flamed here ;-)).
[...]
> 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
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070912/f27ee86b/attachment.pgp>
More information about the ffmpeg-devel
mailing list