Revision 0b006599

View differences:

libavutil/rational.c
75 75
    return den==0;
76 76
}
77 77

  
78
/**
79
 * returns b*c.
80
 */
81 78
AVRational av_mul_q(AVRational b, AVRational c){
82 79
    av_reduce(&b.num, &b.den, b.num * (int64_t)c.num, b.den * (int64_t)c.den, INT_MAX);
83 80
    return b;
84 81
}
85 82

  
86
/**
87
 * returns b/c.
88
 */
89 83
AVRational av_div_q(AVRational b, AVRational c){
90 84
    return av_mul_q(b, (AVRational){c.den, c.num});
91 85
}
92 86

  
93
/**
94
 * returns b+c.
95
 */
96 87
AVRational av_add_q(AVRational b, AVRational c){
97 88
    av_reduce(&b.num, &b.den, b.num * (int64_t)c.den + c.num * (int64_t)b.den, b.den * (int64_t)c.den, INT_MAX);
98 89
    return b;
99 90
}
100 91

  
101
/**
102
 * returns b-c.
103
 */
104 92
AVRational av_sub_q(AVRational b, AVRational c){
105 93
    return av_add_q(b, (AVRational){-c.num, c.den});
106 94
}
107 95

  
108
/**
109
 * Converts a double precission floating point number to a AVRational.
110
 * @param max the maximum allowed numerator and denominator
111
 */
112 96
AVRational av_d2q(double d, int max){
113 97
    AVRational a;
114 98
#define LOG2  0.69314718055994530941723212145817656807550013436025
libavutil/rational.h
51 51
}
52 52

  
53 53
/**
54
 * Rational to double conversion
54
 * Rational to double conversion.
55 55
 * @param a rational to convert
56 56
 * @return (double) a
57 57
 */
......
71 71
 */
72 72
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
73 73

  
74
/**
75
 * Multiplies two rationals.
76
 * @param b first rational.
77
 * @param c second rational.
78
 * @return b*c.
79
 */
74 80
AVRational av_mul_q(AVRational b, AVRational c);
81

  
82
/**
83
 * Divides two rationals.
84
 * @param b first rational.
85
 * @param c second rational.
86
 * @return b/c.
87
 */
75 88
AVRational av_div_q(AVRational b, AVRational c);
89

  
90
/**
91
 * Adds two rationals.
92
 * @param b first rational.
93
 * @param c second rational.
94
 * @return b+c.
95
 */
76 96
AVRational av_add_q(AVRational b, AVRational c);
97

  
98
/**
99
 * Substracts two rationals.
100
 * @param b first rational.
101
 * @param c second rational.
102
 * returns b-c.
103
 */
77 104
AVRational av_sub_q(AVRational b, AVRational c);
105

  
106
/**
107
 * Converts a double precision floating point number to a rational.
108
 * @param d double to convert
109
 * @param max the maximum allowed numerator and denominator
110
 * @return (AVRational) d.
111
 */
78 112
AVRational av_d2q(double d, int max);
79 113

  
80 114
#endif // RATIONAL_H

Also available in: Unified diff