1 | use ffi::*; |
2 | use {Rational, Rounding}; |
3 | |
4 | pub const TIME_BASE: Rational = Rational(AV_TIME_BASE_Q.num, AV_TIME_BASE_Q.den); |
5 | |
6 | pub trait Rescale { |
7 | fn rescale<S, D>(&self, source: S, destination: D) -> i64 |
8 | where |
9 | S: Into<Rational>, |
10 | D: Into<Rational>; |
11 | |
12 | fn rescale_with<S, D>(&self, source: S, destination: D, rounding: Rounding) -> i64 |
13 | where |
14 | S: Into<Rational>, |
15 | D: Into<Rational>; |
16 | } |
17 | |
18 | impl<T: Into<i64> + Clone> Rescale for T { |
19 | fn rescale<S, D>(&self, source: S, destination: D) -> i64 |
20 | where |
21 | S: Into<Rational>, |
22 | D: Into<Rational>, |
23 | { |
24 | unsafe { |
25 | av_rescale_q( |
26 | self.clone().into(), |
27 | source.into().into(), |
28 | destination.into().into(), |
29 | ) |
30 | } |
31 | } |
32 | |
33 | fn rescale_with<S, D>(&self, source: S, destination: D, rounding: Rounding) -> i64 |
34 | where |
35 | S: Into<Rational>, |
36 | D: Into<Rational>, |
37 | { |
38 | unsafe { |
39 | av_rescale_q_rnd( |
40 | self.clone().into(), |
41 | source.into().into(), |
42 | destination.into().into(), |
43 | rounding.into(), |
44 | ) |
45 | } |
46 | } |
47 | } |
48 | |