Skip to content

Commit a1db797

Browse files
committed
Add comments for rational apis
1 parent 2500059 commit a1db797

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/avutil/rational.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,26 @@
33
/// Ref: https://github.com/rust-lang/rust-bindgen/issues/1344
44
use 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()
612
pub 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`
1026
pub 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()
2444
pub 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
2851
pub fn av_inv_q(q: AVRational) -> AVRational {
2952
AVRational {
3053
num: q.den,

0 commit comments

Comments
 (0)