aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/rational.h
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2010-10-05 01:43:31 +0000
committerMichael Niedermayer <michaelni@gmx.at>2010-10-05 01:43:31 +0000
commitdec112691561bddaea07e0ad455a71bf29ade60d (patch)
treeccee1a26797919b8435d837ab057a628479d5b3d /libavutil/rational.h
parentcfa5a81ea672ac355afad88ea239f7ba5c3d72f0 (diff)
downloadffmpeg-dec112691561bddaea07e0ad455a71bf29ade60d.tar.gz
Make av_cmp_q() work with infinities and NAN.
Originally committed as revision 25338 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/rational.h')
-rw-r--r--libavutil/rational.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavutil/rational.h b/libavutil/rational.h
index 21542a8abe..15df06f4af 100644
--- a/libavutil/rational.h
+++ b/libavutil/rational.h
@@ -29,6 +29,7 @@
#define AVUTIL_RATIONAL_H
#include <stdint.h>
+#include <limits.h>
#include "attributes.h"
/**
@@ -49,7 +50,9 @@ static inline int av_cmp_q(AVRational a, AVRational b){
const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den;
if(tmp) return ((tmp ^ a.den ^ b.den)>>63)|1;
- else return 0;
+ else if(b.den && a.den) return 0;
+ else if(a.num && b.num) return (a.num>>31) - (b.num>>31);
+ else return INT_MIN;
}
/**