diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-10-04 13:41:01 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-10-04 13:41:01 +0000 |
commit | 6b4ed22f7512056f47bc7f39cd16bbbb83b2781d (patch) | |
tree | a035682ce9a76f2cba4194018c96717cd7965ad3 /libavutil | |
parent | 9276bdddca3dba697ffead22ce591657b7b33e24 (diff) | |
download | ffmpeg-6b4ed22f7512056f47bc7f39cd16bbbb83b2781d.tar.gz |
Make av_d2q() manage the case in which the value to convert is inf.
Originally committed as revision 25332 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/avutil.h | 2 | ||||
-rw-r--r-- | libavutil/rational.c | 2 | ||||
-rw-r--r-- | libavutil/rational.h | 2 |
3 files changed, 5 insertions, 1 deletions
diff --git a/libavutil/avutil.h b/libavutil/avutil.h index e3391e58a2..3e23b6e0c6 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -41,7 +41,7 @@ #define LIBAVUTIL_VERSION_MAJOR 50 #define LIBAVUTIL_VERSION_MINOR 32 -#define LIBAVUTIL_VERSION_MICRO 0 +#define LIBAVUTIL_VERSION_MICRO 1 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ diff --git a/libavutil/rational.c b/libavutil/rational.c index efed674a32..a82bc84ad4 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 7c6605cce7..21542a8abe 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 * @return (AVRational) d |