[PATCH 04/13] Add a special case for av_cmp_q() when one of the values to be compared is 0/0.
Stefano Sabatini
stefano.sabatini-lala
Thu Sep 30 21:42:56 CEST 2010
---
libavutil/rational.h | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/libavutil/rational.h b/libavutil/rational.h
index 21542a8..c7332c0 100644
--- a/libavutil/rational.h
+++ b/libavutil/rational.h
@@ -28,6 +28,7 @@
#ifndef AVUTIL_RATIONAL_H
#define AVUTIL_RATIONAL_H
+#include <limits.h>
#include <stdint.h>
#include "attributes.h"
@@ -43,10 +44,13 @@ typedef struct AVRational{
* Compare two rationals.
* @param a first rational
* @param b second rational
- * @return 0 if a==b, 1 if a>b and -1 if a<b
+ * @return 0 if a==b, 1 if a>b, -1 if a<b, and INT_MIN if one of the
+ * values is of the form 0/0
*/
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 (a.num == 0 && a.den == 0 || b.num == 0 && b.den == 0)
+ return INT_MIN;
if(tmp) return ((tmp ^ a.den ^ b.den)>>63)|1;
else return 0;
--
1.7.1
--oyUTqETQ0mS9luUI--
More information about the ffmpeg-devel
mailing list