pub struct SilkDecoder {
pub bandwidth: SilkBandwidth,
pub frame_size: usize,
pub prev_samples: Vec<i16>,
}Expand description
SILK frame decoder scaffold.
This type parses the SILK frame header and exposes helpers for LPC
synthesis. Full entropy-coded SILK decoding is extremely complex and is
provided by the Opus implementation in crate::opus::silk. This struct
is intentionally lightweight and suitable for testing and scaffolding.
Fields§
§bandwidth: SilkBandwidthOperating bandwidth.
frame_size: usizeExpected frame size in samples.
prev_samples: Vec<i16>Previous output samples kept for LPC synthesis state (history).
Implementations§
Source§impl SilkDecoder
impl SilkDecoder
Sourcepub fn new(bandwidth: SilkBandwidth) -> Self
pub fn new(bandwidth: SilkBandwidth) -> Self
Creates a new SilkDecoder for the given bandwidth.
Sourcepub fn decode_frame(&mut self, data: &[u8]) -> Result<SilkFrame, String>
pub fn decode_frame(&mut self, data: &[u8]) -> Result<SilkFrame, String>
Parses the frame header and returns a SilkFrame with zeroed samples.
Full SILK decoding (excitation decoding, LTP, noise shaping …) is not implemented here; the goal of this method is to validate the header and set up the frame scaffold so that higher-level code can fill in the decoded samples.
Sourcepub fn apply_lpc_synthesis(
&mut self,
excitation: &[i16],
lpc: &SilkLpcCoeffs,
) -> Vec<i16>
pub fn apply_lpc_synthesis( &mut self, excitation: &[i16], lpc: &SilkLpcCoeffs, ) -> Vec<i16>
Applies the LPC synthesis filter to an excitation signal.
The synthesis filter is:
s[n] = excitation[n] + sum_{k=0}^{order-1} (lpc.coeffs[k] * s[n-k-1]) / 4096where the division by 4096 converts Q12 fixed-point coefficients back to the integer domain.
The decoder’s prev_samples buffer is used as the initial state and
is updated to the last order samples of the output on return.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SilkDecoder
impl RefUnwindSafe for SilkDecoder
impl Send for SilkDecoder
impl Sync for SilkDecoder
impl Unpin for SilkDecoder
impl UnsafeUnpin for SilkDecoder
impl UnwindSafe for SilkDecoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more