Skip to main content

Module shipdec

Module shipdec 

Source
Expand description

Streams that carry their own decoder (TCS1).

A TCS1 container is "TCS1", a varint length, a decoder program, then an ordinary TCG3 stream. The program replaces the receiver’s built-in coding path: the rANS residual decoders (crate::irdec) and optionally the learned model’s MLP (its weights as graph constants, so the receiver needs no model registry). The receiver verifies it (tang_expr::int::IntGraph::from_bytes plus the role ABIs below), lowers it to WGSL (bounds-checked loads) and to the CPU interpreter, and caches the result by content hash. Plain TCG3 streams decode as before.

Program layout: "TCDP", version byte (1), flags byte (bit 0 static residual graph, bit 1 learned residual graph, bit 2 MLP graph, bit 3 adaptive learned residual graph), then per present section a varint length and a TIR1 graph. A missing residual section falls back to the built-in graph.

Role ABIs (anything else is rejected):

  • static residual: params u32 × 8, buffers mt, stream (u32), outputs u32, u32, i32 (see crate::irdec);
  • learned residual: params u32 × 3, i32 × 5, u32 × 2, same buffers and outputs;
  • MLP: params i32 × NFL, no buffers, outputs i32 × NO;
  • adaptive learned residual (streams with the per-lane APM layer): params u32 × 3, i32 × 5, u32 × 6, buffers mt, stream and the scratch buffer adt (136 words), outputs u32, u32, i32, u32.

Structs§

Decoder
A verified decoder program, ready for both backends.

Constants§

MAGIC
Container magic.
MAX_PROGRAM
Largest program accepted (bytes).

Functions§

builtin_program
The built-in decoder as a program: the static residual graph, the learned one (adaptive when ad, for streams with the APM layer), plus net’s MLP when given.
compile
Verify and lower a program (no cache).
compile_cached
compile through the process-wide cache (keyed by FNV-1a 64 of the program, confirmed by a full byte comparison, so a hash collision can never select another program).
fnv1a
FNV-1a 64.
open
Split a stream: (Some(decoder), inner TCG3) for TCS1, (None, bytes) otherwise.
placeholder_net
Placeholder net for a stream whose model is shipped as a graph (its weights are never used; the shipped MLP runs instead).
program_bytes
Serialize a decoder program from graphs (None sections are left to the receiver’s built-ins).
wrap
Wrap a TCG3 stream with a decoder program.

Type Aliases§

Graph
A graph with its outputs.