open-standards/wai/byte-exact-conformance/src/lib.rs
Transaction Science 48b41f21d3 wai: cross-architecture goldens for staged delivery
byte-exact-conformance includes the WIR1 parser, predictors and arithmetic
step and pins every stage of three corpus sets: a WIV1 GOP with per-frame
and per-GOP layers, up2 to odd sizes, and a stereo rate ladder. The last
stage of each must also be the clip hash its case states.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-02 00:45:31 -04:00

90 lines
4.4 KiB
Rust
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//! Shim crate that compiles WAI's pure-integer decode paths — the rANS entropy
//! coder and the integer fixed-point synthesis — WITHOUT the system codec
//! libraries or the ONNX runtime, so the cross-architecture byte-equality
//! matrix (`.github/workflows/wai-byte-equality.yml`) can run them on every
//! OS/arch cheaply.
//!
//! The sources are `#[path]`-included from `wai-rs` — one source of truth; this
//! crate only supplies the two tiny types those modules expect from their
//! parent (`DecodeError`, `image::DecodedImage`).
pub mod neural;
// rans.rs's integer-entropy round-trip test references `crate::int_entropy`
// (the scale-bucketing that makes a conditional codec cross-hardware exact).
// Included from wai-rs verbatim, same single-source-of-truth rule as the
// neural sources — it is itself pure-integer and self-contained.
#[path = "../../wai-rs/src/int_entropy.rs"]
pub mod int_entropy;
// The fast kernels the integer decoders dispatch to (and the policy that can
// select the scalar reference instead). Included so the cross-arch matrix checks
// the code path sinks actually run by default. Pure std, self-contained. Some of
// its helpers serve modules this crate does not compile (the attention nets), so
// their dead-code warnings are expected here and silenced at the include.
#[allow(dead_code)]
#[path = "../../wai-rs/src/int_kernels.rs"]
pub mod int_kernels;
// The merged byte-exact JPEG-AI decoder's entropy stage (crate-root, self-contained —
// no shims needed). Included so the cross-arch byte-equality matrix covers the decoder
// that `wai.image.jpegai` actually reconstructs with, not only the older `neural/` port.
#[path = "../../wai-rs/src/jpegai_mans.rs"]
pub mod jpegai_mans_exact;
// `int_video.rs` names the rANS decoder as `crate::rans` (its path in wai-rs,
// where rans is a crate-root module). Here rans is included under `neural`, so
// re-export rather than `#[path]`-include a second copy: two includes would
// compile two structurally identical but distinct types, and the whole point of
// this crate is that there is one source of truth per decode path.
pub use neural::rans;
// The deterministic integer INTER-FRAME video decoder (`wai.video.int_motion`).
// Included so the cross-arch matrix covers temporal decode, not only the
// still-image and synthesis paths. This one matters disproportionately: its
// half-pel predictor is the only place in the integer contract where a
// *rounding* decision (`(a + b + 1) >> 1` over clamped neighbours) sits inside a
// feedback loop — each P-frame predicts from the previously reconstructed
// frame, so a single divergent byte on one architecture does not stay one byte.
// It propagates through every subsequent frame.
#[path = "../../wai-rs/src/int_video.rs"]
pub mod int_video;
// The integer transform kernels (`igdn` and friends) the learned codecs use.
// Self-contained — no crate-internal dependencies of its own.
#[path = "../../wai-rs/src/int_transform.rs"]
pub mod int_transform;
// The learned integer conditional codec that decodes a NEURAL keyframe. Needed
// for `wai.video.int_hyper`, whose I-frame comes from here rather than from
// `int_video::decode` — the gap the previous commit named and left open, since
// covering it meant pulling this source in rather than adding a line.
#[path = "../../wai-rs/src/int_hyper_synth.rs"]
pub mod int_hyper_synth;
// The integer MLIC++-topology codec (`wai.neural.int_mlicpp`): channel slices ×
// checkerboard passes over int_hyper_synth's networks, int_entropy's bucketing and
// the rANS decoder, all already included here — so the matrix checks that every
// platform derives the encoder's scale bucket for every element.
#[path = "../../wai-rs/src/int_mlicpp.rs"]
pub mod int_mlicpp;
// The wire parser of the integer payloads SPEC §5 pins (WIV1, WIH1, WIA1, WIS1).
// Self-contained — std's Vec only, nothing from the crate — so the matrix parses the
// committed binary payloads with the parser a sink runs.
#[path = "../../wai-rs/src/int_payload/wire.rs"]
pub mod int_payload_wire;
// The staged-delivery residual (`WIR1`, extensions/staged-delivery.md Appendix A): its
// parser, predictors and arithmetic step. Self-contained beside the rANS coder and the
// histogram table already included here; the encoder is not used by the goldens.
#[allow(dead_code)]
pub mod staged;
mod golden;
mod int_payload_golden;
mod int_video_golden;
mod neural_keyframe_golden;
mod jpegai_golden;
mod int_mlicpp_golden;
mod staged_golden;