annotate rational.h @ 271:38e9c99c3aad libavutil

Move av_mod_i()'s comment to the header file. The moved comment is unmodified.
author takis
date Sun, 04 Mar 2007 23:10:38 +0000
parents add2141ed7b0
children f21d1907d47c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
1 /*
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
2 * Rational numbers
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
3 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
4 *
116
d76a36742464 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 15
diff changeset
5 * This file is part of FFmpeg.
d76a36742464 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 15
diff changeset
6 *
d76a36742464 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 15
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
116
d76a36742464 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 15
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
11 *
116
d76a36742464 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 15
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
15 * Lesser General Public License for more details.
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
16 *
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
116
d76a36742464 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 15
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
15
af59e84e283d Update licensing information: The FSF changed postal address.
diego
parents: 12
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
20 *
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
21 */
12
ce8f9f4390c3 COSMETICS: Remove all trailing whitespace.
diego
parents: 0
diff changeset
22
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
23 /**
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
24 * @file rational.h
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
25 * Rational numbers.
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
26 * @author Michael Niedermayer <michaelni@gmx.at>
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
27 */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
28
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
29 #ifndef RATIONAL_H
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
30 #define RATIONAL_H
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
31
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
32 /**
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
33 * Rational number num/den.
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
34 */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
35 typedef struct AVRational{
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
36 int num; ///< numerator
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
37 int den; ///< denominator
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
38 } AVRational;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
39
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
40 /**
253
5647be712b27 Doxygenize some comments
gpoirier
parents: 248
diff changeset
41 * Compare two rationals.
5647be712b27 Doxygenize some comments
gpoirier
parents: 248
diff changeset
42 * @param a first rational
5647be712b27 Doxygenize some comments
gpoirier
parents: 248
diff changeset
43 * @param b second rational
5647be712b27 Doxygenize some comments
gpoirier
parents: 248
diff changeset
44 * @return 0 if a==b, 1 if a>b and -1 if a<b.
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
45 */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
46 static inline int av_cmp_q(AVRational a, AVRational b){
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
47 const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
48
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
49 if(tmp) return (tmp>>63)|1;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
50 else return 0;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
51 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
52
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
53 /**
254
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
54 * Rational to double conversion.
253
5647be712b27 Doxygenize some comments
gpoirier
parents: 248
diff changeset
55 * @param a rational to convert
5647be712b27 Doxygenize some comments
gpoirier
parents: 248
diff changeset
56 * @return (double) a
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
57 */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
58 static inline double av_q2d(AVRational a){
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
59 return a.num / (double) a.den;
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
60 }
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
61
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
62 /**
253
5647be712b27 Doxygenize some comments
gpoirier
parents: 248
diff changeset
63 * Reduce a fraction.
248
5feb5bb5d89f cosmetics: fix usefuLL --> usefuL typo
diego
parents: 116
diff changeset
64 * This is useful for framerate calculations.
253
5647be712b27 Doxygenize some comments
gpoirier
parents: 248
diff changeset
65 * @param dst_nom destination numerator
5647be712b27 Doxygenize some comments
gpoirier
parents: 248
diff changeset
66 * @param dst_den destination denominator
5647be712b27 Doxygenize some comments
gpoirier
parents: 248
diff changeset
67 * @param nom source numerator
5647be712b27 Doxygenize some comments
gpoirier
parents: 248
diff changeset
68 * @param den source denominator
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
69 * @param max the maximum allowed for dst_nom & dst_den
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
70 * @return 1 if exact, 0 otherwise
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
71 */
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
72 int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
73
254
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
74 /**
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
75 * Multiplies two rationals.
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
76 * @param b first rational.
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
77 * @param c second rational.
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
78 * @return b*c.
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
79 */
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
80 AVRational av_mul_q(AVRational b, AVRational c);
254
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
81
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
82 /**
255
add2141ed7b0 fix 2 mistakes in doxy comments, spotted by Michael
gpoirier
parents: 254
diff changeset
83 * Divides one rational by another.
254
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
84 * @param b first rational.
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
85 * @param c second rational.
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
86 * @return b/c.
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
87 */
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
88 AVRational av_div_q(AVRational b, AVRational c);
254
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
89
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
90 /**
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
91 * Adds two rationals.
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
92 * @param b first rational.
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
93 * @param c second rational.
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
94 * @return b+c.
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
95 */
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
96 AVRational av_add_q(AVRational b, AVRational c);
254
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
97
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
98 /**
255
add2141ed7b0 fix 2 mistakes in doxy comments, spotted by Michael
gpoirier
parents: 254
diff changeset
99 * Subtracts one rational from another.
254
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
100 * @param b first rational.
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
101 * @param c second rational.
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
102 * returns b-c.
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
103 */
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
104 AVRational av_sub_q(AVRational b, AVRational c);
254
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
105
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
106 /**
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
107 * Converts a double precision floating point number to a rational.
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
108 * @param d double to convert
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
109 * @param max the maximum allowed numerator and denominator
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
110 * @return (AVRational) d.
77e39bbb7219 move doxy comments from rational.c to rational.h and add some new comments
gpoirier
parents: 253
diff changeset
111 */
0
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
112 AVRational av_d2q(double d, int max);
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
113
ee8f44bb7c4d libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff changeset
114 #endif // RATIONAL_H