### Example Usage Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dst1ConvertToFft.html Example of how to compute a DST Type 1 using Dst1ConvertToFft. ```APIDOC ```rust // Computes a DST Type 1 of size 1234 use rustdct::Dst1; use rustdct::algorithm::Dst1ConvertToFft; use rustdct::rustfft::FftPlanner; let len = 1234; let mut planner = FftPlanner::new(); let fft = planner.plan_fft_forward(2 * (len + 1)); let dct = Dst1ConvertToFft::new(fft); let mut buffer = vec![0f32; len]; dct.process_dst1(&mut buffer); ``` ``` -------------------------------- ### Compute naive DCT1 Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dct1Naive.html Example showing how to initialize and process a DCT1 using Dct1Naive. ```rust // Computes a naive DCT1 of size 23 use rustdct::Dct1; use rustdct::algorithm::Dct1Naive; let len = 23; let dct = Dct1Naive::new(len); let mut buffer = vec![0f32; len]; dct.process_dct1(&mut buffer); ``` -------------------------------- ### Compute DST6 and DST7 with Dst6And7Naive Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dst6And7Naive.html Example showing how to initialize the algorithm and process buffers for both DST6 and DST7. ```rust // Computes a naive DST6 and DST7 of size 23 use rustdct::{Dst6, Dst7}; use rustdct::algorithm::Dst6And7Naive; let len = 23; let naive = Dst6And7Naive::new(len); let mut dst6_buffer = vec![0f32; len]; naive.process_dst6(&mut dst6_buffer); let mut dst7_buffer = vec![0f32; len]; naive.process_dst7(&mut dst7_buffer); ``` -------------------------------- ### Compute DCT-4 and DST-4 with Type4ConvertToFftOdd Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Type4ConvertToFftOdd.html Example usage showing how to initialize the algorithm with an FFT planner and process buffers for both DCT-4 and DST-4. ```rust // Computes a DCT Type 4 and DST Type 4 of size 1233 use rustdct::{Dct4, Dst4}; use rustdct::algorithm::Type4ConvertToFftOdd; use rustdct::rustfft::FftPlanner; let len = 1233; let mut planner = FftPlanner::new(); let fft = planner.plan_fft_forward(len); let dct = Type4ConvertToFftOdd::new(fft); let mut dct4_buffer = vec![0f32; len]; dct.process_dct4(&mut dct4_buffer); let mut dst4_buffer = vec![0f32; len]; dct.process_dst4(&mut dst4_buffer); ``` -------------------------------- ### Compute DCT and DST using FFT Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Type2And3ConvertToFft.html Example showing how to initialize and use Type2And3ConvertToFft to compute DCT2, DST2, DCT3, and DST3 transforms. ```rust // Computes a O(NlogN) DCT2, DST2, DCT3, and DST3 of size 1234 by converting them to FFTs use rustdct::{Dct2, Dst2, Dct3, Dst3}; use rustdct::algorithm::Type2And3ConvertToFft; use rustdct::rustfft::FftPlanner; let len = 1234; let mut planner = FftPlanner::new(); let fft = planner.plan_fft_forward(len); let dct = Type2And3ConvertToFft::new(fft); let mut dct2_buffer = vec![0f32; len]; dct.process_dct2(&mut dct2_buffer); let mut dst2_buffer = vec![0f32; len]; dct.process_dst2(&mut dst2_buffer); let mut dct3_buffer = vec![0f32; len]; dct.process_dct3(&mut dct3_buffer); let mut dst3_buffer = vec![0f32; len]; dct.process_dst3(&mut dst3_buffer); ``` -------------------------------- ### Compute naive MDCT Source: https://docs.rs/rustdct/0.7.1/rustdct/mdct/struct.MdctNaive.html Example showing how to initialize and process a naive MDCT with a specific window function. ```rust // Computes a naive MDCT of output size 124, using the MP3 window function use rustdct::mdct::{Mdct, MdctNaive, window_fn}; use rustdct::RequiredScratch; let len = 124; let dct = MdctNaive::new(len, window_fn::mp3); let input = vec![0f32; len * 2]; let (input_a, input_b) = input.split_at(len); let mut output = vec![0f32; len]; let mut scratch = vec![0f32; dct.get_scratch_len()]; dct.process_mdct_with_scratch(input_a, input_b, &mut output, &mut scratch); ``` -------------------------------- ### Compute DCT4 and DST4 using Type4Naive Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Type4Naive.html Example demonstrating how to initialize a Type4Naive context and perform DCT4 and DST4 transforms on a buffer. ```rust // Computes a naive DCT4 of size 23 use rustdct::{Dct4, Dst4}; use rustdct::algorithm::Type4Naive; let len = 23; let naive = Type4Naive::new(len); let mut dct4_buffer: Vec = vec![0f32; len]; naive.process_dct4(&mut dct4_buffer); let mut dst4_buffer: Vec = vec![0f32; len]; naive.process_dst4(&mut dst4_buffer); ``` -------------------------------- ### Compute MDCT via DCT4 Source: https://docs.rs/rustdct/0.7.1/rustdct/mdct/struct.MdctViaDct4.html Example showing how to compute an MDCT of a specific size using a DCT4 planner and the MP3 window function. ```rust // Computes a MDCT of input size 1234 via a DCT4, using the MP3 window function use rustdct::mdct::{Mdct, MdctViaDct4, window_fn}; use rustdct::{DctPlanner, RequiredScratch}; let len = 1234; let mut planner = DctPlanner::new(); let inner_dct4 = planner.plan_dct4(len); let dct = MdctViaDct4::new(inner_dct4, window_fn::mp3); let input = vec![0f32; len * 2]; let (input_a, input_b) = input.split_at(len); let mut output = vec![0f32; len]; let mut scratch = vec![0f32; dct.get_scratch_len()]; dct.process_mdct_with_scratch(input_a, input_b, &mut output, &mut scratch); ``` -------------------------------- ### Compute DST Type 1 using Dst1ConvertToFft Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dst1ConvertToFft.html Example showing how to initialize and use Dst1ConvertToFft to compute a DST Type 1 of a specific length. ```rust // Computes a DST Type 1 of size 1234 use rustdct::Dst1; use rustdct::algorithm::Dst1ConvertToFft; use rustdct::rustfft::FftPlanner; let len = 1234; let mut planner = FftPlanner::new(); let fft = planner.plan_fft_forward(2 * (len + 1)); let dct = Dst1ConvertToFft::new(fft); let mut buffer = vec![0f32; len]; dct.process_dst1(&mut buffer); ``` -------------------------------- ### Create and Use Type2And3SplitRadix for DCT Type 2 Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Type2And3SplitRadix.html This example demonstrates how to create a Type2And3SplitRadix context and use it to compute a DCT Type 2 of size 1024. It requires pre-planning DCT transforms for half and quarter lengths. ```rust use rustdct::algorithm::Type2And3SplitRadix; use rustdct::Dct2; use rustdct::DctPlanner; let len = 1024; let mut planner = DctPlanner::new(); let quarter_dct = planner.plan_dct2(len / 4); let half_dct = planner.plan_dct2(len / 2); let dct = Type2And3SplitRadix::new(half_dct, quarter_dct); let mut buffer = vec![0f32; len]; dct.process_dct2(&mut buffer); ``` -------------------------------- ### Get Type ID Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dct6And7Naive.html Gets the `TypeId` of the current type. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### Get FFT Size Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dct6And7Naive.html Returns the FFT size that this algorithm can process. ```rust fn len(&self) -> usize ``` -------------------------------- ### Length Implementation for Type4Naive Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Type4Naive.html Provides a method to get the FFT size that this algorithm can process. ```APIDOC ### impl Length for Type4Naive #### fn len(&self) -> usize The FFT size that this algorithm can process ``` -------------------------------- ### Get Required Scratch Buffer Length Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dct6And7Naive.html Returns the required length for the scratch buffer. ```rust fn get_scratch_len(&self) -> usize ``` -------------------------------- ### Dct1Naive Initialization and Processing Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dct1Naive.html How to instantiate the Dct1Naive algorithm and process a buffer using the DCT Type 1 transformation. ```APIDOC ## Dct1Naive::new ### Description Creates a new instance of the Dct1Naive algorithm for a specific length. ### Parameters #### Request Body - **len** (usize) - Required - The size of the DCT1 transformation. ### Request Example let len = 23; let dct = Dct1Naive::new(len); ## Dct1Naive::process_dct1 ### Description Computes the DCT Type 1 on the provided buffer in-place. ### Parameters #### Request Body - **buffer** (&mut [T]) - Required - The data buffer to process in-place. ### Request Example let mut buffer = vec![0f32; len]; dct.process_dct1(&mut buffer); ``` -------------------------------- ### Length Implementation for Type2And3Naive Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Type2And3Naive.html Provides the `len` method to get the FFT size that this algorithm can process. ```APIDOC ### impl Length for Type2And3Naive #### fn len(&self) -> usize The FFT size that this algorithm can process. ``` -------------------------------- ### Dct6And7Naive Initialization and Processing Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dct6And7Naive.html How to instantiate the Dct6And7Naive struct and perform DCT-6 and DCT-7 transforms on a buffer. ```APIDOC ## Dct6And7Naive::new ### Description Creates a new DCT6 and DCT7 context that will process signals of a specific length. ### Parameters #### Path Parameters - **len** (usize) - Required - The length of the signal to be processed. ### Request Example ```rust let len = 23; let naive = Dct6And7Naive::new(len); ``` ## process_dct6 / process_dct7 ### Description Computes the DCT Type 6 or Type 7 on the provided buffer, in-place. ### Parameters #### Request Body - **buffer** (&mut [T]) - Required - The data buffer to transform in-place. ### Response Example ```rust let mut dct6_buffer = vec![0f32; len]; naive.process_dct6(&mut dct6_buffer); let mut dct7_buffer = vec![0f32; len]; naive.process_dct7(&mut dct7_buffer); ``` ``` -------------------------------- ### Create and Process DCT8 with Dct8Naive Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dct8Naive.html Demonstrates how to create a new DCT8 context for a given length and process a buffer in-place using the naive O(n^2) implementation. Ensure the buffer is initialized. ```rust use rustdct::Dct8; use rustdct::algorithm::Dct8Naive; let len = 23; let naive = Dct8Naive::new(len); let mut buffer = vec![0f32; len]; naive.process_dct8(&mut buffer); ``` -------------------------------- ### Create and Process DST6/DST7 with Dst6And7ConvertToFft Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dst6And7ConvertToFft.html Computes a O(NlogN) DST6 and DST7 of a specified size by converting them to FFTs. Requires initializing an FftPlanner and planning the FFT, then creating the Dst6And7ConvertToFft context. ```rust use rustdct::{Dst6, Dst7}; use rustdct::algorithm::Dst6And7ConvertToFft; use rustdct::rustfft::FftPlanner; let len = 1234; let mut planner = FftPlanner::new(); let fft = planner.plan_fft_forward(len * 2 + 1); let dct = Dst6And7ConvertToFft::new(fft); let mut dst6_buffer = vec![0f32; len]; dct.process_dst6(&mut dst6_buffer); let mut dst7_buffer = vec![0f32; len]; dct.process_dst7(&mut dst6_buffer); ``` -------------------------------- ### Get invertible MDCT window function Source: https://docs.rs/rustdct/0.7.1/rustdct/mdct/window_fn/fn.invertible.html Returns a vector of ones representing a window function that allows for invertible MDCT operations. ```rust pub fn invertible(len: usize) -> Vec ``` -------------------------------- ### Create and Process DST8 with Dst8Naive Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dst8Naive.html Demonstrates how to create a Dst8Naive context for a given length and process a buffer in-place using the `process_dst8` method. Ensure the buffer is initialized with zeros. ```rust use rustdct::Dst8; use rustdct::algorithm::Dst8Naive; let len = 23; let naive = Dst8Naive::new(len); let mut buffer = vec![0f32; len]; naive.process_dst8(&mut buffer); ``` -------------------------------- ### Dst6And7Naive Initialization and Processing Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dst6And7Naive.html How to initialize the Dst6And7Naive struct and process data for DST6 and DST7. ```APIDOC ## Dst6And7Naive::new ### Description Creates a new DST6 and DST7 context that will process signals of a specified length. ### Parameters #### Arguments - **len** (usize) - Required - The length of the signals to be processed. ### Request Example ```rust let len = 23; let naive = Dst6And7Naive::new(len); ``` ## Dst6And7Naive::process_dst6 ### Description Computes the DST Type 6 on the provided buffer, in-place. ### Parameters #### Arguments - **buffer** (&mut [T]) - Required - The data buffer to process. ## Dst6And7Naive::process_dst7 ### Description Computes the DST Type 7 on the provided buffer, in-place. ### Parameters #### Arguments - **buffer** (&mut [T]) - Required - The data buffer to process. ``` -------------------------------- ### Create and Use DCT Type 4 Instance Source: https://docs.rs/rustdct/0.7.1/rustdct/struct.DctPlanner.html Demonstrates creating a DctPlanner, planning a DCT Type 4 of a specific size, and processing a buffer. The planner should be reused for multiple instances to save resources. The DCT instance is cloneable via Arc. ```rust use std::sync::Arc; use rustdct::DctPlanner; let mut planner = DctPlanner::new(); let dct4 = planner.plan_dct4(1234); let mut buffer = vec![0f32; 1234]; dct4.process_dct4(&mut buffer); // The DCT instance returned by the planner is stored behind an `Arc`, so it's cheap to clone let dct4_clone = Arc::clone(&dct4); ``` -------------------------------- ### Initialize and Process DCT/DST with Type2And3Naive Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Type2And3Naive.html Demonstrates how to create a Type2And3Naive context and process DCT Type 2, DST Type 2, DCT Type 3, and DST Type 3 on separate buffers. Ensure the input buffer length matches the context's configured length. ```rust use rustdct::{Dct2, Dst2, Dct3, Dst3}; use rustdct::algorithm::Type2And3Naive; let len = 23; let naive = Type2And3Naive::new(len); let mut dct2_buffer = vec![0f32; len]; naive.process_dct2(&mut dct2_buffer); let mut dst2_buffer = vec![0f32; len]; naive.process_dst2(&mut dst2_buffer); let mut dct3_buffer = vec![0f32; len]; naive.process_dct3(&mut dct3_buffer); let mut dst3_buffer = vec![0f32; len]; naive.process_dst3(&mut dst3_buffer); ``` -------------------------------- ### Create and Process DST Type 5 with Dst5Naive Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dst5Naive.html Demonstrates how to create a Dst5Naive context for a given length and process a buffer in-place. Ensure the buffer is initialized. ```rust use rustdct::Dst5; use rustdct::algorithm::Dst5Naive; let len = 23; let mut buffer = vec![0f32; len]; let dst = Dst5Naive::new(len); dst.process_dst5(&mut buffer); ``` -------------------------------- ### Compute DCT6 and DCT7 with Dct6And7Naive Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dct6And7Naive.html Computes a naive DCT6 and DCT7 of a specified size using the Dct6And7Naive implementation. Requires importing Dct6, Dct7, and Dct6And7Naive from the rustdct crate. ```rust // Computes a naive DCT6 and DCT7 of size 23 use rustdct::{Dct6, Dct7}; use rustdct::algorithm::Dct6And7Naive; let len = 23; let naive = Dct6And7Naive::new(len); let mut dct6_buffer = vec![0f32; len]; naive.process_dct6(&mut dct6_buffer); let mut dct7_buffer = vec![0f32; len]; naive.process_dct7(&mut dct7_buffer); ``` -------------------------------- ### DctPlanner Overview Source: https://docs.rs/rustdct/0.7.1/rustdct/struct.DctPlanner.html The DctPlanner is responsible for creating new DCT algorithm instances. It selects the most suitable algorithm for a given DCT type and problem size, and initializes it. Reusing a planner for multiple DCT instances is recommended for performance. ```APIDOC ## DctPlanner ### Description The DCT planner is used to make new DCT algorithm instances. RustDCT has several DCT algorithms available for each DCT type; For a given DCT type and problem size, the DctPlanner decides which of the available DCT algorithms to use and then initializes them. If you plan on creating multiple DCT instances, it is recommnded to reuse the same planner for all of them. This is because the planner re-uses internal data across DCT instances wherever possible, saving memory and reducing setup time. (DCT instances created with one planner will never re-use data and buffers with DCT instances created by a different planner) Each DCT instance owns `Arc`s to its shared internal data, rather than borrowing it from the planner, so it’s perfectly safe to drop the planner after creating DCT instances. ### Example Usage ```rust use std::sync::Arc; use rustdct::DctPlanner; let mut planner = DctPlanner::new(); let dct4 = planner.plan_dct4(1234); let mut buffer = vec![0f32; 1234]; dct4.process_dct4(&mut buffer); // The DCT instance returned by the planner is stored behind an `Arc`, so it's cheap to clone let dct4_clone = Arc::clone(&dct4); ``` ``` -------------------------------- ### DctPlanner Methods Source: https://docs.rs/rustdct/0.7.1/rustdct/struct.DctPlanner.html This section details the methods available on the DctPlanner struct for planning various DCT and DST types. ```APIDOC ## DctPlanner Methods ### `new()` Creates a new `DctPlanner` instance. ### `plan_dct1(len: usize)` Returns a DCT Type 1 instance which processes signals of size `len`. If this is called multiple times, it will attempt to re-use internal data between instances. ### `plan_dct2(len: usize)` Returns a DCT Type 2 instance which processes signals of size `len`. If this is called multiple times, it will attempt to re-use internal data between instances. ### `plan_dct3(len: usize)` Returns DCT Type 3 instance which processes signals of size `len`. If this is called multiple times, it will attempt to re-use internal data between instances. ### `plan_dct4(len: usize)` Returns a DCT Type 4 instance which processes signals of size `len`. If this is called multiple times, it will attempt to re-use internal data between instances. ### `plan_dct5(len: usize)` Returns a DCT Type 5 instance which processes signals of size `len`. If this is called multiple times, it will attempt to re-use internal data between instances. ### `plan_dct6(len: usize)` Returns a DCT Type 6 instance which processes signals of size `len`. If this is called multiple times, it will attempt to re-use internal data between instances. ### `plan_dct7(len: usize)` Returns DCT Type 7 instance which processes signals of size `len`. If this is called multiple times, it will attempt to re-use internal data between instances. ### `plan_dct8(len: usize)` Returns a DCT Type 8 instance which processes signals of size `len`. If this is called multiple times, it will attempt to re-use internal data between instances. ### `plan_dst1(len: usize)` Returns a DST Type 1 instance which processes signals of size `len`. If this is called multiple times, it will attempt to re-use internal data between instances. ### `plan_dst2(len: usize)` Returns DST Type 2 instance which processes signals of size `len`. If this is called multiple times, it will attempt to re-use internal data between instances. ### `plan_dst3(len: usize)` Returns DST Type 3 instance which processes signals of size `len`. If this is called multiple times, it will attempt to re-use internal data between instances. ### `plan_dst4(len: usize)` Returns DST Type 4 instance which processes signals of size `len`. If this is called multiple times, it will attempt to re-use internal data between instances. ### `plan_dst5(len: usize)` Returns a DST Type 5 instance which processes signals of size `len`. If this is called multiple times, it will attempt to re-use internal data between instances. ### `plan_dst6(len: usize)` Returns a DST Type 6 instance which processes signals of size `len`. If this is called multiple times, it will attempt to re-use internal data between instances. ``` -------------------------------- ### impl Dst6And7ConvertToFft Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dst6And7ConvertToFft.html Constructor for Dst6And7ConvertToFft. ```APIDOC ### impl Dst6And7ConvertToFft #### pub fn new(inner_fft: Arc>) -> Self Creates a new DST6 and DST7 context that will process signals of length `(inner_fft.len() - 1) / 2`. ``` -------------------------------- ### Type2And3Butterfly16 Methods Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/type2and3_butterflies/struct.Type2And3Butterfly16.html Methods for initializing and performing in-place DCT and DST transformations. ```APIDOC ## Type2And3Butterfly16 Methods ### Description Provides methods to perform in-place DCT-2, DCT-3, DST-2, and DST-3 transformations on a buffer of size 16. ### Methods - **new()** -> Self: Creates a new instance of Type2And3Butterfly16. - **process_inplace_dct2(&mut [T])**: Computes the DCT Type 2 on the provided buffer. - **process_inplace_dst2(&mut [T])**: Computes the DST Type 2 on the provided buffer. - **process_inplace_dct3(&mut [T])**: Computes the DCT Type 3 on the provided buffer. - **process_inplace_dst3(&mut [T])**: Computes the DST Type 3 on the provided buffer. ### Parameters - **buffer** (&mut [T]) - Required - The data buffer to transform in-place. ``` -------------------------------- ### Dst5Naive Constructor Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dst5Naive.html Creates a new instance of the Dst5Naive algorithm for a specific signal length. ```APIDOC ## new(len: usize) ### Description Creates a new DST5 context that will process signals of length `len`. ### Parameters #### Path Parameters - **len** (usize) - Required - The length of the signal to be processed. ``` -------------------------------- ### Type2And3ConvertToFft Constructor Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Type2And3ConvertToFft.html Creates a new instance of the Type2And3ConvertToFft context. ```APIDOC ## pub fn new(inner_fft: Arc>) -> Self ### Description Creates a new DCT2, DST2, DCT3, and DST3 context that will process signals of length `inner_fft.len()`. ### Parameters #### Request Body - **inner_fft** (Arc>) - Required - The underlying FFT algorithm to use for the conversion. ``` -------------------------------- ### Rustdct Crate Overview Source: https://docs.rs/rustdct/0.7.1/rustdct/index.html This section provides an overview of the rustdct crate, including its re-exports and modules. ```APIDOC ## Crate rustdct ### Summary Re-exports: `pub use rustfft;` `pub use rustfft::num_complex;` `pub use rustfft::num_traits;` Modules: - `algorithm` - `mdct`: Algorithms for computing the Modified Discrete Cosine Transform Structs: - `DctPlanner`: The DCT planner is used to make new DCT algorithm instances. Traits: - `Dct1` to `Dct8`: Traits for algorithms computing Discrete Cosine Transform types 1 through 8. - `Dct6And7`: Trait for algorithms that can compute both DCT6 and DCT7. - `DctNum`: Generic floating point number trait. - `Dst1` to `Dst8`: Traits for algorithms computing Discrete Sine Transform types 1 through 8. - `Dst6And7`: Trait for algorithms that can compute both DST6 and DST7. - `RequiredScratch` - `TransformType4`: Trait for algorithms that can compute both DCT4 and DST4. - `TransformType2And3`: Trait for algorithms that can compute DCT2, DCT3, DST2, DST3. ``` -------------------------------- ### Create Dct6And7Naive Context Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dct6And7Naive.html Creates a new DCT6 and DCT7 context that will process signals of a specified length. ```rust pub fn new(len: usize) -> Self> ``` -------------------------------- ### Struct Dst6And7ConvertToFft Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dst6And7ConvertToFft.html DST6 and DST7 implementation that converts the problem into a FFT of the same size. ```APIDOC ## Struct Dst6And7ConvertToFft ### Description DST6 and DST7 implementation that converts the problem into a FFT of the same size. ### Example ```rust // Computes a O(NlogN) DST6 and DST7 of size 1234 by converting them to FFTs use rustdct::{Dst6, Dst7}; use rustdct::algorithm::Dst6And7ConvertToFft; use rustdct::rustfft::FftPlanner; let len = 1234; let mut planner = FftPlanner::new(); let fft = planner.plan_fft_forward(len * 2 + 1); let dct = Dst6And7ConvertToFft::new(fft); let mut dst6_buffer = vec![0f32; len]; dct.process_dst6(&mut dst6_buffer); let mut dst7_buffer = vec![0f32; len]; dct.process_dst7(&mut dst6_buffer); ``` ``` -------------------------------- ### Dst1Naive::new Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dst1Naive.html Creates a new DST1 context that will process signals of a specified length. ```APIDOC ## `impl Dst1Naive` ### `pub fn new(len: usize) -> Self` Creates a new DST1 context that will process signals of length `len`. ``` -------------------------------- ### process_imdct_with_scratch Method Source: https://docs.rs/rustdct/0.7.1/rustdct/mdct/trait.Mdct.html Computes the IMDCT. Splits the output into two buffers. Does not zero out the output buffer, instead summing results to handle overlapping output segments. Normalization depends on the chosen window function. ```rust fn process_imdct_with_scratch( &self, input: &[T], output_a: &mut [T], output_b: &mut [T], scratch: &mut [T], ); ``` -------------------------------- ### Create and Use Dct1ConvertToFft Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dct1ConvertToFft.html Computes a DCT Type 1 of a specified size using Dct1ConvertToFft. Requires an FftPlanner to create the necessary FFT context. ```rust use rustdct::Dct1; use rustdct::algorithm::Dct1ConvertToFft; use rustdct::rustfft::FftPlanner; let len = 1234; let mut planner = FftPlanner::new(); let fft = planner.plan_fft_forward(2 * (len - 1)); let dct = Dct1ConvertToFft::new(fft); let mut buffer = vec![0f32; len]; dct.process_dct1(&mut buffer); ``` -------------------------------- ### Generate MP3 window function Source: https://docs.rs/rustdct/0.7.1/rustdct/mdct/window_fn/fn.mp3.html Calculates the MP3 window function for a given length. ```rust pub fn mp3(len: usize) -> Vec ``` -------------------------------- ### Create from Value Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dct6And7Naive.html Returns the argument unchanged. This is a simple identity conversion. ```rust fn from(t: T) -> T ``` -------------------------------- ### Dct8Naive::new Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dct8Naive.html Creates a new DCT8 context for processing signals of a specified length. ```APIDOC ## impl Dct8Naive ### pub fn new(len: usize) -> Self Creates a new DCT8 context that will process signals of length `len`. ``` -------------------------------- ### Type2And3Naive::new Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Type2And3Naive.html Creates a new DCT2, DCT3, DST2, and DST3 context that will process signals of length `len`. ```APIDOC ## impl Type2And3Naive ### pub fn new(len: usize) -> Self Creates a new DCT2, DCT3, DST2, and DST3 context that will process signals of length `len`. ``` -------------------------------- ### Type2And3Butterfly4 Implementations Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/type2and3_butterflies/struct.Type2And3Butterfly4.html Provides methods for initializing and processing DCT/DST transformations using the Type2And3Butterfly4 algorithm. ```APIDOC ## impl Type2And3Butterfly4 ### Description Implementations for the Type2And3Butterfly4 struct. #### pub fn new() -> Self Creates a new instance of Type2And3Butterfly4. #### pub unsafe fn process_inplace_dct2(&self, buffer: &mut [T]) Processes an in-place DCT Type 2 transformation on the buffer. #### pub unsafe fn process_inplace_dct3(&self, buffer: &mut [T]) Processes an in-place DCT Type 3 transformation on the buffer. #### pub unsafe fn process_inplace_dst2(&self, buffer: &mut [T]) Processes an in-place DST Type 2 transformation on the buffer. #### pub unsafe fn process_inplace_dst3(&self, buffer: &mut [T]) Processes an in-place DST Type 3 transformation on the buffer. ``` -------------------------------- ### Dst8Naive::new Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dst8Naive.html Creates a new instance of the Dst8Naive algorithm for a specified signal length. ```APIDOC ## Dst8Naive::new ### Description Creates a new DST8 context that will process signals of length `len`. ### Parameters #### Arguments - **len** (usize) - Required - The length of the signal to be processed. ``` -------------------------------- ### Process DCT2 (Provided Method) Source: https://docs.rs/rustdct/0.7.1/rustdct/trait.Dct2.html Computes the DCT Type 2 in-place on a buffer. This method may allocate scratch space internally. For performance, consider using `process_dct2_with_scratch` if scratch space can be reused. ```rust fn process_dct2(&self, buffer: &mut [T]) { // ... } ``` -------------------------------- ### Create and Process DST1 with Dst1Naive Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dst1Naive.html Instantiate Dst1Naive with a specified length and then use it to process a mutable buffer in-place. Ensure the buffer has the same length as specified during initialization. ```rust use rustdct::Dst1; use rustdct::algorithm::Dst1Naive; let len = 23; let dst = Dst1Naive::new(len); let mut buffer = vec![0f32; len]; dst.process_dst1(&mut buffer); ``` -------------------------------- ### Dct8Naive::process_dct8_with_scratch Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dct8Naive.html Computes the DCT Type 8 in-place using a provided scratch buffer. ```APIDOC ### impl Dct8 for Dct8Naive #### fn process_dct8_with_scratch(&self, buffer: &mut [T], scratch: &mut [T]) Computes the DCT Type 8 on the provided buffer, in-place. Uses the provided `scratch` buffer as scratch space. Read more ``` -------------------------------- ### Trait Implementations Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/type2and3_butterflies/struct.Type2And3Butterfly16.html Standard trait implementations for DCT and DST processing with scratch space support. ```APIDOC ## Trait Implementations ### Description Implementations for Dct2, Dct3, Dst2, and Dst3 traits, allowing for transformations with optional scratch space. ### Methods - **process_dct2_with_scratch(&mut [T], &mut [T])**: Computes DCT Type 2 using a scratch buffer. - **process_dct3_with_scratch(&mut [T], &mut [T])**: Computes DCT Type 3 using a scratch buffer. - **process_dst2_with_scratch(&mut [T], &mut [T])**: Computes DST Type 2 using a scratch buffer. - **process_dst3_with_scratch(&mut [T], &mut [T])**: Computes DST Type 3 using a scratch buffer. - **len() -> usize**: Returns the algorithm size (16). - **get_scratch_len() -> usize**: Returns the required length for the scratch buffer. ``` -------------------------------- ### Implement Dct6And7 for Dct6And7Naive Source: https://docs.rs/rustdct/0.7.1/rustdct/trait.Dct6And7.html Provides an implementation of the Dct6And7 trait for the Dct6And7Naive struct. This is a naive implementation for computing DCT6 and DCT7. ```rust impl Dct6And7 for Dct6And7Naive { } ``` -------------------------------- ### process_dct1_with_scratch Method Source: https://docs.rs/rustdct/0.7.1/rustdct/trait.Dct1.html Computes the DCT Type 1 in-place on the provided buffer using the given scratch space. Outputs are not normalized. ```rust fn process_dct1_with_scratch(&self, buffer: &mut [T], scratch: &mut [T]) ``` -------------------------------- ### MDCT Window Functions Source: https://docs.rs/rustdct/0.7.1/rustdct/mdct/window_fn/index.html Overview of available window functions for MDCT processing within the rustdct crate. ```APIDOC ## Window Functions ### Description The `window_fn` module provides pre-defined window functions for MDCT. Some functions include normalization scaling to ensure the process is invertible. ### Available Functions - **invertible**: MDCT window function which is all ones. Combines a scale for normalization. - **mp3**: MP3 window function for MDCT. - **mp3_invertible**: MP3 window function for MDCT with normalization scale for invertibility. - **one**: MDCT window function which is all ones (no windowing applied). - **vorbis**: Ogg Vorbis window function for MDCT. - **vorbis_invertible**: Ogg Vorbis window function for MDCT with normalization scale for invertibility. ``` -------------------------------- ### Dst1Naive::process_dst1_with_scratch Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dst1Naive.html Computes the DST Type 1 on the provided buffer, in-place, using a scratch buffer for temporary storage. ```APIDOC ## `impl Dst1 for Dst1Naive` ### `fn process_dst1_with_scratch(&self, buffer: &mut [T], scratch: &mut [T])` Computes the DST Type 1 on the provided buffer, in-place. Uses the provided `scratch` buffer as scratch space. ``` -------------------------------- ### process_dct1 Method Source: https://docs.rs/rustdct/0.7.1/rustdct/trait.Dct1.html Computes the DCT Type 1 in-place on the provided buffer. This method may allocate scratch space internally. For performance-critical applications or to reuse allocations, consider using `process_dct1_with_scratch`. Outputs are not normalized. ```rust fn process_dct1(&self, buffer: &mut [T]) ``` -------------------------------- ### Plan MDCT Instance Source: https://docs.rs/rustdct/0.7.1/rustdct/struct.DctPlanner.html Returns an MDCT instance that processes inputs of size `len * 2` and produces outputs of size `len`. A window function is required. Internal data can be reused across multiple calls. ```rust pub fn plan_mdct(&mut self, len: usize, window_fn: F) -> Arc> where F: FnOnce(usize) -> Vec ``` -------------------------------- ### process_dst5_with_scratch Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dst5Naive.html Computes the DST Type 5 on the provided buffer using an additional scratch buffer. ```APIDOC ## process_dst5_with_scratch(buffer: &mut [T], scratch: &mut [T]) ### Description Computes the DST Type 5 on the provided buffer, in-place. Uses the provided `scratch` buffer as scratch space. ### Parameters #### Request Body - **buffer** (&mut [T]) - Required - The signal buffer to be transformed. - **scratch** (&mut [T]) - Required - The scratch space buffer. ``` -------------------------------- ### Plan DST Type 7 Instance Source: https://docs.rs/rustdct/0.7.1/rustdct/struct.DctPlanner.html Returns a DST Type 7 instance for signals of a given length. Internal data can be reused across multiple calls. ```rust pub fn plan_dst7(&mut self, len: usize) -> Arc> ``` -------------------------------- ### Plan DCT Type 5 Instance Source: https://docs.rs/rustdct/0.7.1/rustdct/struct.DctPlanner.html Plans a DCT Type 5 instance for signals of a given length. Re-use of internal data is attempted if called multiple times. ```rust pub fn plan_dct5(&mut self, len: usize) -> Arc> ``` -------------------------------- ### Dst4 Implementation for Type4Naive Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Type4Naive.html Provides methods for computing the DST Type 4 using the Type4Naive implementation. Supports in-place processing with and without scratch buffers. ```APIDOC ### impl Dst4 for Type4Naive #### fn process_dst4_with_scratch(&self, buffer: &mut [T], scratch: &mut [T]) Computes the DST Type 4 on the provided buffer, in-place. Uses the provided `scratch` buffer as scratch space. Read more #### fn process_dst4(&self, buffer: &mut [T]) Computes the DST Type 4 on the provided buffer, in-place. Read more ``` -------------------------------- ### Plan DST Type 5 Instance Source: https://docs.rs/rustdct/0.7.1/rustdct/struct.DctPlanner.html Plans a DST Type 5 instance for signals of a given length. Re-use of internal data is attempted if called multiple times. ```rust pub fn plan_dst5(&mut self, len: usize) -> Arc> ``` -------------------------------- ### Plan DCT Type 7 Instance Source: https://docs.rs/rustdct/0.7.1/rustdct/struct.DctPlanner.html Plans a DCT Type 7 instance for signals of a given length. Re-use of internal data is attempted if called multiple times. ```rust pub fn plan_dct7(&mut self, len: usize) -> Arc> ``` -------------------------------- ### rustdct::mdct::window_fn::mp3 Source: https://docs.rs/rustdct/0.7.1/rustdct/mdct/window_fn/fn.mp3.html Generates the MP3 window function for MDCT. ```APIDOC ## Function mp3 ### Description MP3 window function for MDCT. ### Method N/A (This is a function, not an API endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **Vec** (Vec) - A vector containing the MP3 window function values. #### Response Example N/A ``` -------------------------------- ### process_dct3_with_scratch Method Source: https://docs.rs/rustdct/0.7.1/rustdct/trait.Dct3.html Computes the DCT Type 3 in-place using the provided buffer and scratch space. Does not normalize outputs. ```rust fn process_dct3_with_scratch(&self, buffer: &mut [T], scratch: &mut [T]) ``` -------------------------------- ### Plan DCT Type 8 Instance Source: https://docs.rs/rustdct/0.7.1/rustdct/struct.DctPlanner.html Plans a DCT Type 8 instance for signals of a given length. Re-use of internal data is attempted if called multiple times. ```rust pub fn plan_dct8(&mut self, len: usize) -> Arc> ``` -------------------------------- ### Dct4 Implementation for Type4Naive Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Type4Naive.html Provides methods for computing the DCT Type 4 using the Type4Naive implementation. Supports in-place processing with and without scratch buffers. ```APIDOC ### impl Dct4 for Type4Naive #### fn process_dct4_with_scratch(&self, buffer: &mut [T], scratch: &mut [T]) Computes the DCT Type 4 on the provided buffer, in-place. Uses the provided `scratch` buffer as scratch space. Read more #### fn process_dct4(&self, buffer: &mut [T]) Computes the DCT Type 4 on the provided buffer, in-place. Read more ``` -------------------------------- ### Process DCT Type 7 In-Place (No Scratch) Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dct6And7Naive.html Computes the DCT Type 7 on the provided buffer, in-place, without using an explicit scratch buffer. ```rust fn process_dct7(&self, buffer: &mut [T]) ``` -------------------------------- ### Type4Naive::new Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Type4Naive.html Creates a new DCT4 and DTS4 context that will process signals of a specified length. ```APIDOC ## impl Type4Naive ### pub fn new(len: usize) -> Self Creates a new DCT4 and DTS4 context that will process signals of length `len`. ``` -------------------------------- ### Trait Dst5 Methods Source: https://docs.rs/rustdct/0.7.1/rustdct/trait.Dst5.html Documentation for the methods provided by the Dst5 trait for computing DST5 transforms. ```APIDOC ## fn process_dst5_with_scratch(&self, buffer: &mut [T], scratch: &mut [T]) ### Description Computes the DST Type 5 on the provided buffer, in-place. Uses the provided `scratch` buffer as scratch space. Does not normalize outputs. ### Parameters - **buffer** (&mut [T]) - Required - The data buffer to transform in-place. - **scratch** (&mut [T]) - Required - The scratch space buffer to be used during computation. --- ## fn process_dst5(&self, buffer: &mut [T]) ### Description Computes the DST Type 5 on the provided buffer, in-place. This method may allocate a Vec of scratch space as needed. Does not normalize outputs. ### Parameters - **buffer** (&mut [T]) - Required - The data buffer to transform in-place. ``` -------------------------------- ### process_dst8_with_scratch Method Source: https://docs.rs/rustdct/0.7.1/rustdct/trait.Dst8.html Computes the DST Type 8 on the provided buffer in-place, utilizing the given scratch buffer. Outputs are not normalized. ```rust fn process_dst8_with_scratch(&self, buffer: &mut [T], scratch: &mut [T]) ``` -------------------------------- ### Plan DST Type 8 Instance Source: https://docs.rs/rustdct/0.7.1/rustdct/struct.DctPlanner.html Returns a DST Type 8 instance for signals of a given length. Internal data can be reused across multiple calls. ```rust pub fn plan_dst8(&mut self, len: usize) -> Arc> ``` -------------------------------- ### Plan DCT Type 6 Instance Source: https://docs.rs/rustdct/0.7.1/rustdct/struct.DctPlanner.html Plans a DCT Type 6 instance for signals of a given length. Re-use of internal data is attempted if called multiple times. ```rust pub fn plan_dct6(&mut self, len: usize) -> Arc> ``` -------------------------------- ### Process DCT2 with Scratch Buffer Source: https://docs.rs/rustdct/0.7.1/rustdct/trait.Dct2.html Computes the DCT Type 2 in-place on a buffer using a provided scratch buffer. Outputs are not normalized. This method is suitable when scratch space can be reused. ```rust fn process_dct2_with_scratch(&self, buffer: &mut [T], scratch: &mut [T]) ``` -------------------------------- ### impl Dst6And7 for Dst6And7ConvertToFft Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/struct.Dst6And7ConvertToFft.html Implementation for the Dst6And7 trait. ```APIDOC ### impl Dst6And7 for Dst6And7ConvertToFft ``` -------------------------------- ### process_dst8 Method Source: https://docs.rs/rustdct/0.7.1/rustdct/trait.Dst8.html Computes the DST Type 8 on the provided buffer in-place. This method may allocate scratch space internally. For performance, consider using `process_dst8_with_scratch` if scratch space can be reused. Outputs are not normalized. ```rust fn process_dst8(&self, buffer: &mut [T]) ``` -------------------------------- ### Plan DCT Type 1 Instance Source: https://docs.rs/rustdct/0.7.1/rustdct/struct.DctPlanner.html Plans a DCT Type 1 instance for signals of a given length. Re-use of internal data is attempted if called multiple times. ```rust pub fn plan_dct1(&mut self, len: usize) -> Arc> ``` -------------------------------- ### Process In-place DCT/DST Type 2 and 3 Source: https://docs.rs/rustdct/0.7.1/rustdct/algorithm/type2and3_butterflies/struct.Type2And3Butterfly16.html Performs in-place DCT or DST type 2 or 3 computations on a mutable buffer. These methods are unsafe and require careful handling of the buffer. ```rust pub unsafe fn process_inplace_dct2(&self, buffer: &mut [T]) ``` ```rust pub unsafe fn process_inplace_dst2(&self, buffer: &mut [T]) ``` ```rust pub unsafe fn process_inplace_dct3(&self, buffer: &mut [T]) ``` ```rust pub unsafe fn process_inplace_dst3(&self, buffer: &mut [T]) ``` -------------------------------- ### Plan DST Type 1 Instance Source: https://docs.rs/rustdct/0.7.1/rustdct/struct.DctPlanner.html Plans a DST Type 1 instance for signals of a given length. Re-use of internal data is attempted if called multiple times. ```rust pub fn plan_dst1(&mut self, len: usize) -> Arc> ```