[FFmpeg-devel] [PATCH 01/12] Make av_d2q() manage the case where d is infinite.
Stefano Sabatini
stefano.sabatini-lala
Fri Oct 1 23:56:41 CEST 2010
On date Friday 2010-10-01 21:44:44 +0200, Michael Niedermayer encoded:
> 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
...
--
FFmpeg = Fierce Foolish Maxi Portentous Extensive God
More information about the ffmpeg-devel
mailing list