ffmpeg_the_third/software/resampling/
extensions.rs1use super::Context;
2use crate::util::format;
3use crate::{decoder, frame, Error};
4
5use crate::ChannelLayout;
6
7#[cfg(not(feature = "ffmpeg_7_0"))]
8use crate::ChannelLayoutMask;
9
10impl frame::Audio {
11 #[cfg(not(feature = "ffmpeg_7_0"))]
12 #[inline]
13 pub fn resampler(
14 &self,
15 format: format::Sample,
16 channel_layout: ChannelLayoutMask,
17 rate: u32,
18 ) -> Result<Context, Error> {
19 Context::get(
20 self.format(),
21 self.channel_layout(),
22 unsafe { (*self.as_ptr()).sample_rate as u32 },
23 format,
24 channel_layout,
25 rate,
26 )
27 }
28
29 #[inline]
30 pub fn resampler2(
31 &self,
32 format: format::Sample,
33 ch_layout: ChannelLayout,
34 rate: u32,
35 ) -> Result<Context, Error> {
36 Context::get2(
37 self.format(),
38 self.ch_layout(),
39 unsafe { (*self.as_ptr()).sample_rate as u32 },
40 format,
41 ch_layout,
42 rate,
43 )
44 }
45}
46
47impl decoder::Audio {
48 #[cfg(not(feature = "ffmpeg_7_0"))]
49 #[inline]
50 pub fn resampler(
51 &self,
52 format: format::Sample,
53 channel_layout: ChannelLayoutMask,
54 rate: u32,
55 ) -> Result<Context, Error> {
56 Context::get(
57 self.format(),
58 self.channel_layout(),
59 self.rate(),
60 format,
61 channel_layout,
62 rate,
63 )
64 }
65
66 #[inline]
67 pub fn resampler2(
68 &self,
69 format: format::Sample,
70 ch_layout: ChannelLayout,
71 rate: u32,
72 ) -> Result<Context, Error> {
73 Context::get2(
74 self.format(),
75 self.ch_layout(),
76 self.rate(),
77 format,
78 ch_layout,
79 rate,
80 )
81 }
82}