deinterleave_unchecked

Function deinterleave_unchecked 

Source
pub unsafe fn deinterleave_unchecked<T: Copy, Vout: AsMut<[T]>, const CHANNELS: usize>(
    input: &[T],
    output: &mut [Vout],
    output_range: Range<usize>,
)
Expand description

De-interleave the given channels into the output buffer.

No bounds checking will occur.

  • input - The interleaved input channels.
  • output - The de-interleaved output channels to write to.
  • output_range - The range in each output channel to write to.

§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]];

unsafe { deinterleave_unchecked::<_, _, 2>(&input, &mut output, 0..4); }

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

// Deinterleave into a range in output:
unsafe { deinterleave_unchecked::<_, _, 2>(&input[0..4], &mut output, 2..4); }

assert_eq!(&output[0], &[1, 3, 1, 3]);
assert_eq!(&output[1], &[2, 4, 2, 4]);

§Safety

The caller must uphold that all of the following conditions are true:

  • output.len() >= CHANNELS
  • output_range is within bounds for every output channel
  • input.len() >= (output_range.end - output_range.start) * CHANNELS
  • CHANNELS > 0