Skip to main content

FrameDecoder

Struct FrameDecoder 

Source
pub struct FrameDecoder { /* private fields */ }
Expand description

A stateful APE frame decoder that works on raw compressed frame bytes.

Unlike ApeDecoder which owns a reader and handles both demuxing and decoding, FrameDecoder only performs decoding. It is designed for integration with external demuxers (e.g., Symphonia) that manage I/O separately and supply compressed frame data as byte slices.

§Usage

let mut fd = FrameDecoder::new(version, channels, bits_per_sample, compression_level);
let pcm = fd.decode_frame(&frame_bytes, seek_remainder, frame_blocks)?;

Implementations§

Source§

impl FrameDecoder

Source

pub fn new( version: u16, channels: u16, bits_per_sample: u16, compression_level: u16, ) -> ApeResult<Self>

Create a new FrameDecoder with the given APE stream parameters.

  • version — APE file version (e.g., 3990). Must be >= 3950.
  • channels — Number of audio channels (1–32).
  • bits_per_sample — Bits per sample (8, 16, 24, or 32).
  • compression_level — Compression level (1000–5000).

Returns an error if the parameters are invalid (unsupported version, zero channels, or unsupported bit depth).

Source

pub fn decode_frame( &mut self, frame_data: &[u8], seek_remainder: u32, frame_blocks: usize, ) -> ApeResult<Vec<u8>>

Decode a compressed frame to raw PCM bytes.

  • frame_data — Compressed frame bytes (including alignment prefix), as returned by ApeDecoder::read_frame_data.
  • seek_remainder — Byte alignment offset for this frame, as returned by ApeDecoder::seek_remainder.
  • frame_blocks — Number of audio blocks (samples per channel) in this frame.

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.