summaryrefslogtreecommitdiff
path: root/libavcodec/rational.h
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2004-07-15 14:06:39 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-07-15 14:06:39 +0000
commit5c07b9e914695a596874fabbe1c86b56d8afeca0 (patch)
tree586120acf93d818260f5b0b74d4efe44b391af33 /libavcodec/rational.h
parentf4888b830f44349de0bb137bc913ea6193adbe9e (diff)
more comments
Originally committed as revision 3317 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/rational.h')
-rw-r--r--libavcodec/rational.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/libavcodec/rational.h b/libavcodec/rational.h
index d5fc77f1a6..fcda759c4c 100644
--- a/libavcodec/rational.h
+++ b/libavcodec/rational.h
@@ -27,19 +27,27 @@
#ifndef RATIONAL_H
#define RATIONAL_H
+/**
+ * Rational number num/den.
+ */
typedef struct AVRational{
- int num;
- int den;
+ int num; ///< numerator
+ int den; ///< denominator
} AVRational;
+/**
+ * returns 0 if a==b, 1 if a>b and -1 if a<b.
+ */
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 < 0) return -1;
- else if(tmp == 0) return 0;
- else return 1;
+ if(tmp) return (tmp>>63)|1;
+ else return 0;
}
+/**
+ * converts the given AVRational to a double.
+ */
static inline double av_q2d(AVRational a){
return a.num / (double) a.den;
}