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 33/// Ref: https://github.com/rust-lang/rust-bindgen/issues/1344
44use crate :: ffi:: AVRational ;
55
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()
612pub fn av_make_q ( num : libc:: c_int , den : libc:: c_int ) -> AVRational {
713 AVRational { num, den }
814}
915
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`
1026pub fn av_cmp_q ( a : AVRational , b : AVRational ) -> libc:: c_int {
1127 let tmp = i64:: from ( a. num ) * i64:: from ( b. den ) - i64:: from ( b. num ) * i64:: from ( a. den ) ;
1228
@@ -21,10 +37,17 @@ pub fn av_cmp_q(a: AVRational, b: AVRational) -> libc::c_int {
2137 }
2238}
2339
40+ /// Convert an AVRational to a `double`.
41+ /// @param a AVRational to convert
42+ /// @return `a` in floating-point form
43+ /// @see av_d2q()
2444pub fn av_q2d ( a : AVRational ) -> libc:: c_double {
2545 libc:: c_double:: from ( a. num ) / libc:: c_double:: from ( a. den )
2646}
2747
48+ /// Invert a rational.
49+ /// @param q value
50+ /// @return 1 / q
2851pub fn av_inv_q ( q : AVRational ) -> AVRational {
2952 AVRational {
3053 num : q. den ,
You can’t perform that action at this time.
0 commit comments