pub struct ConvolutionalInterleaver<T> { /* private fields */ }Expand description
A convolutional (Forney) interleaver or deinterleaver of $I$ branches of unit depth $M$ (see the module): a stream processed symbol by symbol, its FIFOs holding the symbols still in flight.
Branch $j$ of the interleaver holds $M j$ cells; branch $j$ of the deinterleaver
holds $M (I - 1 - j)$ cells. Both start filled with T::default(); the commutator
starts on branch 0, so that the first symbol of a stream (the sync byte of DVB) takes
the branch without delay. Symbol $t$ leaves the interleaver $I M (t \bmod I)$ symbols
late, and the pair delays every symbol by ConvolutionalInterleaver::latency.
§Examples
use comnum_fec::interleaving::ConvolutionalInterleaver;
// the interleaver of DVB-S and DVB-T: I = 12, M = 17
let mut tx = ConvolutionalInterleaver::new(12, 17)?;
let mut rx = ConvolutionalInterleaver::deinterleaver(12, 17)?;
let data: Vec<u8> = (0..5000).map(|i| (i % 251) as u8).collect();
let y = rx.process(&tx.process(&data));
let lat = tx.latency(); // 12 · 17 · 11 = 2244 symbols
assert_eq!(&y[lat..], &data[..data.len() - lat]);Implementations§
Source§impl<T: Copy + Default> ConvolutionalInterleaver<T>
impl<T: Copy + Default> ConvolutionalInterleaver<T>
Sourcepub fn new(branches: usize, unit: usize) -> Result<Self>
pub fn new(branches: usize, unit: usize) -> Result<Self>
The interleaver of branches branches of unit depth unit ($I$, $M$).
§Errors
comnum_core::Error::Config without a branch.
Sourcepub fn deinterleaver(branches: usize, unit: usize) -> Result<Self>
pub fn deinterleaver(branches: usize, unit: usize) -> Result<Self>
The deinterleaver of ConvolutionalInterleaver::new with the same parameters.
§Errors
Sourcepub fn unit_depth(&self) -> usize
pub fn unit_depth(&self) -> usize
The unit depth $M$.
Sourcepub fn is_deinterleaver(&self) -> bool
pub fn is_deinterleaver(&self) -> bool
Whether this is the deinterleaver.
Sourcepub fn delay(&self, branch: usize) -> usize
pub fn delay(&self, branch: usize) -> usize
The delay (in symbols) of the symbols of branch branch: $I M j$ for the
interleaver, $I M (I - 1 - j)$ for the deinterleaver.
Sourcepub fn latency(&self) -> usize
pub fn latency(&self) -> usize
The delay of the interleaver and deinterleaver together, $I M (I - 1)$ symbols.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Back to the initial state: the FIFOs filled with T::default(), the commutator on
branch 0.
Sourcepub fn process_into(&mut self, x: &[T], out: &mut [T]) -> Result<()>
pub fn process_into(&mut self, x: &[T], out: &mut [T]) -> Result<()>
The symbols of x through the interleaver, into out (as many).
§Errors
comnum_core::Error::Shape if out does not have the length of x.