diff options
Diffstat (limited to 'thirdparties/iphone/include/libavutil/rational.h')
-rwxr-xr-x | thirdparties/iphone/include/libavutil/rational.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/thirdparties/iphone/include/libavutil/rational.h b/thirdparties/iphone/include/libavutil/rational.h index 417e29e..84ce7a0 100755 --- a/thirdparties/iphone/include/libavutil/rational.h +++ b/thirdparties/iphone/include/libavutil/rational.h @@ -40,7 +40,7 @@ /** * rational number numerator/denominator */ -typedef struct AVRational{ +typedef struct AVRational { int num; ///< numerator int den; ///< denominator } AVRational; @@ -52,13 +52,22 @@ typedef struct AVRational{ * @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){ +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 if(b.den && a.den) return 0; - else if(a.num && b.num) return (a.num>>31) - (b.num>>31); - else return INT_MIN; + if(tmp) { + return ((tmp ^ a.den ^ b.den)>>63)|1; + } + 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; + } } /** @@ -66,7 +75,8 @@ static inline int av_cmp_q(AVRational a, AVRational b){ * @param a rational to convert * @return (double) a */ -static inline double av_q2d(AVRational a){ +static inline double av_q2d(AVRational a) +{ return a.num / (double) a.den; } |