[FFmpeg-devel] [PATCH 01/12] Make av_d2q() manage the case where d is infinite.
Michael Niedermayer
michaelni
Fri Oct 1 21:44:44 CEST 2010
On Fri, Oct 01, 2010 at 08:55:08PM +0200, Stefano Sabatini wrote:
> On date Friday 2010-10-01 20:36:10 +0200, Michael Niedermayer encoded:
> > On Fri, Oct 01, 2010 at 06:08:49PM +0200, Stefano Sabatini wrote:
> > > ---
> > > libavutil/rational.c | 2 ++
> > > libavutil/rational.h | 2 ++
> > > 2 files changed, 4 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/libavutil/rational.c b/libavutil/rational.c
> > > index 0e0571e..b5af28e 100644
> > > --- a/libavutil/rational.c
> > > +++ b/libavutil/rational.c
> > > @@ -98,6 +98,8 @@ AVRational av_d2q(double d, int max){
> > > #define LOG2 0.69314718055994530941723212145817656807550013436025
> > > int exponent= FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0);
> > > int64_t den= 1LL << (61 - exponent);
> > > + if (isinf(d))
> > > + return (AVRational){1,0};
> >
> > if iam not mistaken then the int cast above has undefined behavior in this case
>
> Why?
well i thought casting infinity to int can at least trigger exceptions on
some platforms ...
nan aint better of course
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
It is not what we do, but why we do it that matters.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101001/92e05725/attachment.pgp>
More information about the ffmpeg-devel
mailing list