diff --git a/libavutil/rational.c b/libavutil/rational.c index 3217b7daeb..3e8b885d49 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 (isnan(d)) + return (AVRational){0,0}; av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max); return a;