Skip to main content

ConvolutionalInterleaver

Struct ConvolutionalInterleaver 

Source
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>

Source

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.

Source

pub fn deinterleaver(branches: usize, unit: usize) -> Result<Self>

The deinterleaver of ConvolutionalInterleaver::new with the same parameters.

§Errors

As ConvolutionalInterleaver::new.

Source

pub fn branches(&self) -> usize

The number of branches $I$.

Source

pub fn unit_depth(&self) -> usize

The unit depth $M$.

Source

pub fn is_deinterleaver(&self) -> bool

Whether this is the deinterleaver.

Source

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.

Source

pub fn latency(&self) -> usize

The delay of the interleaver and deinterleaver together, $I M (I - 1)$ symbols.

Source

pub fn reset(&mut self)

Back to the initial state: the FIFOs filled with T::default(), the commutator on branch 0.

Source

pub fn push(&mut self, x: T) -> T

One symbol in, one symbol out.

Source

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.

Source

pub fn process(&mut self, x: &[T]) -> Vec<T>

The symbols of x through the interleaver.

Trait Implementations§

Source§

impl<T: Clone> Clone for ConvolutionalInterleaver<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for ConvolutionalInterleaver<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.