Skip to main content

Crate rusty_flac

Crate rusty_flac 

Source
Expand description

§rusty_flac — pure-Rust FLAC codec

A self-contained FLAC encoder + decoder: no FFI, no required dependencies.

  • Encoder: feed planar or interleaved i32 samples (8/16/24-bit, up to 8 channels), get a complete spec-valid FLAC stream with STREAMINFO MD5.
  • Decoder: streaming per-frame decode of a FLAC stream to planar i32, with CRC verification; decode is the whole-stream convenience.

Lossless is the invariant: decode(encode(x)) == x exactly, and every stream interoperates with libFLAC/ffmpeg in both directions.

§no_std

The crate is no_std + alloc with default-features = false plus the libm feature (pure-Rust math for the window design, LPC quantisation and the Rice estimate). The std feature adds per-thread scratch reuse, runtime AVX2 detection and the RUSTY_FLAC_TIMING stage print; the output bytes do not depend on it — only on whether libm is in use.

Structs§

Decoder
Streaming FLAC decoder over a complete in-memory stream.
EncodeStats
Wiring-audit counters: every decision path in the encoder counts what it chose, so a corpus run can prove no path is silently dead and no fallback is silently hot. Cheap (a few increments per subframe).
Encoder
A pure-Rust FLAC encoder. Feed planar or interleaved i32 samples at the configured bit depth, then Encoder::finish returns the complete stream.
FrameDecoder
Decodes FLAC frames handed over one at a time — e.g. the packets a demuxer cuts — given the stream’s STREAMINFO. It owns its per-channel scratch, so one FrameDecoder serves a whole stream without re-allocating, and nothing needs the fLaC header in front of a frame. Same checks as Decoder: header CRC-8, frame CRC-16, channel count.
StreamInfo
Parsed STREAMINFO.

Enums§

DecodeError
EncodeError
Encoder configuration / stream errors.

Traits§

Sample
Output sample types for Decoder::next_frame_interleaved: i32 (native width), f32 (normalised) and i16 (streams of at most 16 bits). Sealed: the conversions belong to this crate.

Functions§

decode
Decode a complete FLAC stream to (StreamInfo, planar samples).