00001 /* 00002 * Rational numbers 00003 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 * 00019 */ 00020 00027 #ifndef RATIONAL_H 00028 #define RATIONAL_H 00029 00033 typedef struct AVRational{ 00034 int num; 00035 int den; 00036 } AVRational; 00037 00041 static inline int av_cmp_q(AVRational a, AVRational b){ 00042 const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den; 00043 00044 if(tmp) return (tmp>>63)|1; 00045 else return 0; 00046 } 00047 00051 static inline double av_q2d(AVRational a){ 00052 return a.num / (double) a.den; 00053 } 00054 00055 AVRational av_mul_q(AVRational b, AVRational c); 00056 AVRational av_div_q(AVRational b, AVRational c); 00057 AVRational av_add_q(AVRational b, AVRational c); 00058 AVRational av_sub_q(AVRational b, AVRational c); 00059 AVRational av_d2q(double d, int max); 00060 00061 #endif // RATIONAL_H
1.5.5