Struct rustdct::DctPlanner
source · pub struct DctPlanner<T: DctNum> { /* private fields */ }
Expand 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.
// Perform a DCT Type 4 of size 1234
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);
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.
Implementations
sourceimpl<T: DctNum> DctPlanner<T>
impl<T: DctNum> DctPlanner<T>
pub fn new() -> Self
sourcepub fn plan_dct1(&mut self, len: usize) -> Arc<dyn Dct1<T>>
pub fn plan_dct1(&mut self, len: usize) -> Arc<dyn Dct1<T>>
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
sourcepub fn plan_dct2(&mut self, len: usize) -> Arc<dyn TransformType2And3<T>>
pub fn plan_dct2(&mut self, len: usize) -> Arc<dyn TransformType2And3<T>>
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
sourcepub fn plan_dct3(&mut self, len: usize) -> Arc<dyn TransformType2And3<T>>
pub fn plan_dct3(&mut self, len: usize) -> Arc<dyn TransformType2And3<T>>
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
sourcepub fn plan_dct4(&mut self, len: usize) -> Arc<dyn TransformType4<T>>
pub fn plan_dct4(&mut self, len: usize) -> Arc<dyn TransformType4<T>>
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
sourcepub fn plan_dct5(&mut self, len: usize) -> Arc<dyn Dct5<T>>
pub fn plan_dct5(&mut self, len: usize) -> Arc<dyn Dct5<T>>
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
sourcepub fn plan_dct6(&mut self, len: usize) -> Arc<dyn Dct6And7<T>>
pub fn plan_dct6(&mut self, len: usize) -> Arc<dyn Dct6And7<T>>
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
sourcepub fn plan_dct7(&mut self, len: usize) -> Arc<dyn Dct6And7<T>>
pub fn plan_dct7(&mut self, len: usize) -> Arc<dyn Dct6And7<T>>
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
sourcepub fn plan_dct8(&mut self, len: usize) -> Arc<dyn Dct8<T>>
pub fn plan_dct8(&mut self, len: usize) -> Arc<dyn Dct8<T>>
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
sourcepub fn plan_dst1(&mut self, len: usize) -> Arc<dyn Dst1<T>>
pub fn plan_dst1(&mut self, len: usize) -> Arc<dyn Dst1<T>>
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
sourcepub fn plan_dst2(&mut self, len: usize) -> Arc<dyn TransformType2And3<T>>
pub fn plan_dst2(&mut self, len: usize) -> Arc<dyn TransformType2And3<T>>
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
sourcepub fn plan_dst3(&mut self, len: usize) -> Arc<dyn TransformType2And3<T>>
pub fn plan_dst3(&mut self, len: usize) -> Arc<dyn TransformType2And3<T>>
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
sourcepub fn plan_dst4(&mut self, len: usize) -> Arc<dyn TransformType4<T>>
pub fn plan_dst4(&mut self, len: usize) -> Arc<dyn TransformType4<T>>
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
sourcepub fn plan_dst5(&mut self, len: usize) -> Arc<dyn Dst5<T>>
pub fn plan_dst5(&mut self, len: usize) -> Arc<dyn Dst5<T>>
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
sourcepub fn plan_dst6(&mut self, len: usize) -> Arc<dyn Dst6And7<T>>
pub fn plan_dst6(&mut self, len: usize) -> Arc<dyn Dst6And7<T>>
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
sourcepub fn plan_dst7(&mut self, len: usize) -> Arc<dyn Dst6And7<T>>
pub fn plan_dst7(&mut self, len: usize) -> Arc<dyn Dst6And7<T>>
Returns DST 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
sourcepub fn plan_dst8(&mut self, len: usize) -> Arc<dyn Dst8<T>>
pub fn plan_dst8(&mut self, len: usize) -> Arc<dyn Dst8<T>>
Returns a DST 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
sourcepub fn plan_mdct<F>(&mut self, len: usize, window_fn: F) -> Arc<dyn Mdct<T>>where
F: FnOnce(usize) -> Vec<T>,
pub fn plan_mdct<F>(&mut self, len: usize, window_fn: F) -> Arc<dyn Mdct<T>>where
F: FnOnce(usize) -> Vec<T>,
Returns a MDCT instance which processes inputs of size len * 2
and produces outputs of size len
.
window_fn
is a function that takes a size
and returns a Vec
containing size
window values.
See the window_fn
module for provided window functions.
If this is called multiple times, it will attempt to re-use internal data between instances