00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00028 #ifndef AVUTIL_RATIONAL_H
00029 #define AVUTIL_RATIONAL_H
00030
00031 #include <stdint.h>
00032 #include "common.h"
00033
00037 typedef struct AVRational{
00038 int num;
00039 int den;
00040 } AVRational;
00041
00048 static inline int av_cmp_q(AVRational a, AVRational b){
00049 const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den;
00050
00051 if(tmp) return (tmp>>63)|1;
00052 else return 0;
00053 }
00054
00060 static inline double av_q2d(AVRational a){
00061 return a.num / (double) a.den;
00062 }
00063
00074 int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max);
00075
00082 AVRational av_mul_q(AVRational b, AVRational c) av_const;
00083
00090 AVRational av_div_q(AVRational b, AVRational c) av_const;
00091
00098 AVRational av_add_q(AVRational b, AVRational c) av_const;
00099
00106 AVRational av_sub_q(AVRational b, AVRational c) av_const;
00107
00114 AVRational av_d2q(double d, int max) av_const;
00115
00120 int av_nearer_q(AVRational q, AVRational q1, AVRational q2);
00121
00127 int av_find_nearest_q_idx(AVRational q, const AVRational* q_list);
00128
00129 #endif