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, buffersmt,stream(u32), outputsu32, u32, i32(seecrate::irdec); - learned residual: params
u32 × 3, i32 × 5, u32 × 2, same buffers and outputs; - MLP: params
i32 × NFL, no buffers, outputsi32 × NO; - adaptive learned residual (streams with the per-lane APM layer):
params
u32 × 3, i32 × 5, u32 × 6, buffersmt,streamand the scratch bufferadt(136 words), outputsu32, 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), plusnet’s MLP when given. - compile
- Verify and lower a program (no cache).
- compile_
cached compilethrough 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)forTCS1,(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 (
Nonesections 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.