rustdct/mdct/mod.rs
1use rustfft::Length;
2
3mod mdct_naive;
4mod mdct_via_dct4;
5
6pub mod window_fn;
7
8/// An umbrella trait for algorithms which compute the Modified Discrete Cosine Transform (MDCT)
9pub trait Mdct<T: DctNum>: RequiredScratch + Length + Sync + Send {
10 /// Computes the MDCT on the `input` buffer and places the result in the `output` buffer.
11 /// Uses `input_a` for the first half of the input, and `input_b` for the second half of the input
12 ///
13 /// To make overlapping array segments easier, this method DOES NOT modify the input buffer.
14 ///
15 /// Normalization depends on which window function was chosen when planning the mdct --
16 /// each built-in window function documents whether it does normalization or not.
17 fn process_mdct_with_scratch(
18 &self,
19 input_a: &[T],
20 input_b: &[T],
21 output: &mut [T],
22 scratch: &mut [T],
23 );
24
25 /// Computes the IMDCT on the `input` buffer and places the result in the `output` buffer.
26 /// Puts the first half of the output in `output_a`, and puts the first half of the output in `output_b`.
27 ///
28 /// Since the IMDCT is designed with overlapping output segments in mind, this method DOES NOT zero
29 /// out the output buffer before writing like most other DCT algorithms. Instead, it sums
30 /// the result of the IMDCT with what's already in the output buffer.
31 ///
32 /// Normalization depends on which window function was chosen when planning the mdct --
33 /// each built-in window function documents whether it does normalization or not.
34 fn process_imdct_with_scratch(
35 &self,
36 input: &[T],
37 output_a: &mut [T],
38 output_b: &mut [T],
39 scratch: &mut [T],
40 );
41}
42
43use crate::{DctNum, RequiredScratch};
44
45pub use self::mdct_naive::MdctNaive;
46pub use self::mdct_via_dct4::MdctViaDct4;