File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 3
3
/// Ref: https://github.com/rust-lang/rust-bindgen/issues/1344
4
4
use crate :: ffi:: AVRational ;
5
5
6
+ /// Create an AVRational.
7
+ ///
8
+ /// Useful for compilers that do not support compound literals.
9
+ ///
10
+ /// @note The return value is not reduced.
11
+ /// @see av_reduce()
6
12
pub fn av_make_q ( num : libc:: c_int , den : libc:: c_int ) -> AVRational {
7
13
AVRational { num, den }
8
14
}
9
15
16
+ /// Compare two rationals.
17
+ ///
18
+ /// @param a First rational
19
+ /// @param b Second rational
20
+ ///
21
+ /// @return One of the following values:
22
+ /// - 0 if `a == b`
23
+ /// - 1 if `a > b`
24
+ /// - -1 if `a < b`
25
+ /// - `INT_MIN` if one of the values is of the form `0 / 0`
10
26
pub fn av_cmp_q ( a : AVRational , b : AVRational ) -> libc:: c_int {
11
27
let tmp = i64:: from ( a. num ) * i64:: from ( b. den ) - i64:: from ( b. num ) * i64:: from ( a. den ) ;
12
28
@@ -21,10 +37,17 @@ pub fn av_cmp_q(a: AVRational, b: AVRational) -> libc::c_int {
21
37
}
22
38
}
23
39
40
+ /// Convert an AVRational to a `double`.
41
+ /// @param a AVRational to convert
42
+ /// @return `a` in floating-point form
43
+ /// @see av_d2q()
24
44
pub fn av_q2d ( a : AVRational ) -> libc:: c_double {
25
45
libc:: c_double:: from ( a. num ) / libc:: c_double:: from ( a. den )
26
46
}
27
47
48
+ /// Invert a rational.
49
+ /// @param q value
50
+ /// @return 1 / q
28
51
pub fn av_inv_q ( q : AVRational ) -> AVRational {
29
52
AVRational {
30
53
num : q. den ,
You can’t perform that action at this time.
0 commit comments