[FFmpeg-devel] [PATCH 01/12] Make av_d2q() manage the case where d is infinite.
Stefano Sabatini
stefano.sabatini-lala
Sun Oct 3 23:08:12 CEST 2010
On date Saturday 2010-10-02 11:54:51 +0200, Stefano Sabatini encoded:
[...]
> On date Saturday 2010-10-02 05:26:56 +0200, Michael Niedermayer encoded:
> > > 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?
>
> Patch updated.
> --
> FFmpeg = Fantastic and Free Magic Proud Ermetic Gnome
> From ef2cd4e1ee26d4c075dfaaa4571cd97c6dc17add 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 01/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..fc7271b 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){ d<0 ? -1 : 1, 0 };
> exponent = FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0);
> den = 1LL << (61 - exponent);
> av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max);
> diff --git a/libavutil/rational.h b/libavutil/rational.h
> index 7c6605c..21542a8 100644
> --- a/libavutil/rational.h
> +++ b/libavutil/rational.h
> @@ -107,6 +107,8 @@ AVRational av_sub_q(AVRational b, AVRational c) av_const;
>
> /**
> * Convert a double precision floating point number to a rational.
> + * inf is expressed as {1,0} or {-1,0} depending on the sign.
> + *
> * @param d double to convert
> * @param max the maximum allowed numerator and denominator
Ping.
--
FFmpeg = Frightening & Fierce Mastering Puritan Erratic Game
More information about the ffmpeg-devel
mailing list