Skip to content
QuaLix
On this page

Rust Crate API

Public symbols for the Rust crate qualix: ClipInfo, Color, Decoder, Frame, MemoryUsage, Encoder, and RateMode.

Playback-only native runtimes should disable default encoder features:

TOML
qualix = { version = "0.1.0", default-features = false }

Metadata & constants

  • SIGNATURE: [u8; 3] = *b"QLX", FORMAT_VERSION: u8, ADAPTIVE_QUANTIZATION: u8 = 255, MAX_FRAMES: u32 = 1 << 24, DEFAULT_BUDGET: usize = 160 * 1024 * 1024
  • enum Color { Srgb8 = 1, Pq10 = 2, Hlg10 = 3 }
  • struct ClipInfo (width, height, fps_num, fps_den, frames, key_interval, color, drop_bits) with frame_bytes(), validate(), and ClipInfo::read(&mut impl Read).

Decoder (qualix::decode)

  • Decoder::open(reader: R, budget: usize) -> io::Result<Self> (R: Read + Seek) — Validates header, EOF key index, and working-set budget before allocating internal reference canvas storage.
  • Decoder::open_into(reader: R, budget: usize, pixels: &'a mut [u8]) -> io::Result<Self> — Reconstructs directly into a caller-lent width × height × 4 buffer with zero extra frame copy.
  • decoder.info() -> ClipInfo and decoder.memory_usage() -> MemoryUsage (surface, key_index, block_scratch, .bytes()).
  • decoder.decode(&mut self, frame: u32) -> io::Result<Frame<'_>> — Decodes sequentially or across arbitrary keyframes, returning Frame { pixels: &[u8], dirty_rows: Range<u32> }.

Encoder (encode feature)

  • Encoder::new(writer: W, info: ClipInfo) -> io::Result<Self> (W: Write) with search builders with_raw_keys(), with_fast_search(), with_playback_search(), with_dense_search().
  • write_frame(&mut self, pixels: &[u8]), finish(self), and finish_counted(self).
  • encode_bitrate(self, input, writer, mode: RateMode, bps: u64) -> io::Result<RateReport> supporting RateMode::Vbr and RateMode::Cbr.