[FFmpeg-devel] [PATCH 01/12] Make av_d2q() manage the case where d is infinite.
Michael Niedermayer
michaelni
Sat Oct 2 05:26:56 CEST 2010
On Fri, Oct 01, 2010 at 11:56:41PM +0200, Stefano Sabatini wrote:
> 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
> rational.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
> 8fa431a6aa605f47f7dc500bffff31b7630e5800 0001-Avoid-cast-of-double-nan-to-int.patch
> From 5aecbff4474037496828b7aefac65fd719a3a8d6 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> Date: Fri, 1 Oct 2010 18:00:31 +0200
> Subject: [PATCH 01/13] Avoid cast of double nan to int.
> It may cause exceptions on some platform.
ok
[...]
> rational.c | 2 ++
> rational.h | 2 ++
> 2 files changed, 4 insertions(+)
> d11ea8d0d46128505f8bee4b37679d4e9b8c12fe 0002-Make-av_d2q-manage-the-case-in-which-the-value-to-co.patch
> From ae6bc76a5b29ab4ac799eba609957cd32094be8e Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> Date: Fri, 1 Oct 2010 23:52:15 +0200
> Subject: [PATCH 02/13] Make av_d2q() manage the case in which the value to convert is inf.
>
> ---
> 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 efed674..956b939 100644
> --- a/libavutil/rational.c
> +++ b/libavutil/rational.c
> @@ -100,6 +100,8 @@ AVRational av_d2q(double d, int max){
> int64_t den;
> if (isnan(d))
> return (AVRational){0,0};
> + if (isinf(d))
> + return (AVRational){1,0};
have you tried -inf?
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Incandescent light bulbs waste a lot of energy as heat so the EU forbids them.
Their replacement, compact fluorescent lamps, much more expensive, dont fit in
many old lamps, flicker, contain toxic mercury, produce a fraction of the light
that is claimed and in a unnatural spectrum rendering colors different than
in natural light. Ah and we now need to turn the heaters up more in winter to
compensate the lower wasted heat. Who wins? Not the environment, thats for sure
-------------- 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/20101002/1f6213c6/attachment.pgp>
More information about the ffmpeg-devel
mailing list