deinterleave_variable

Function deinterleave_variable 

Source
pub fn deinterleave_variable<T: Copy, Vout: AsMut<[T]>>(
    input: &[T],
    num_in_channels: NonZeroUsize,
    output: &mut [Vout],
    output_range: Range<usize>,
)
Expand description

Deinterleave the given data with a variable number of channels into the output buffers with a variable number of channels.

  • input - The interleaved input data.
  • num_in_channels - The number of interleaved channels in input.
  • output - The de-interleaved output buffer to write to.
  • out_range - The range in each channel in output to write to.

Note, if output.len() > num_in_channels.get(), then the extra output channels will be left untouched.

§Example

let input: Vec<i32> = vec![1, 2, 3, 4, 5, 6, 7, 8];
let mut output: Vec<Vec<i32>> = vec![vec![0; 4], vec![0; 4], vec![0; 4]];

deinterleave_variable(&input, NonZeroUsize::new(2).unwrap(), &mut output, 0..4);

assert_eq!(&output[0], &[1, 3, 5, 7]);
assert_eq!(&output[1], &[2, 4, 6, 8]);
assert_eq!(&output[2], &[0, 0, 0, 0]);

§Panics

Panics when any of the following are true:

  • output_range is out-of-bounds for any output channel
  • input.len() < (output_range.end - output_range.start) * num_in_channels.get()