WAI is a container + capability-dispatch standard for media. It does not re-implement codecs; it dispatches to SOTA standard libraries (PNG, FLAC, zstd as the mandatory floor; AVIF, JPEG-XL, Opus, AV1, XZ as the recommended modern set) and adds an envelope that lets a neural shared-prior path coexist with the model-free floor. The capability a file requires is named, not supplied. Two paths open every conforming file: the neural condition (sink regenerates from a shared ambient prior) and the zeroth condition (registered SOTA codec menu). Apache-2.0. Adds: - wai/SPEC.md — WAI v1.0 spec (envelope, manifest, capability dispatch, registered capabilities including v1.1 multi-rendition extension) - wai/wai-rs/ — Rust reference implementation: lib + cdylib + staticlib, C FFI, 11 capability + envelope round-trip tests passing - wai/wai-web/ — wasm-bindgen wrapper for browser sinks - wai/wai-neural/ — Python tooling for neural-condition models - wai/tools/ — codec export + encode helpers (Python) - wai/corpus/CORPUS.md — third-party test corpus reacquisition guide Updates README.md to list four standards instead of three. Known consumer: CommunicationOS uses WAI for media transport over MoQT/MLS sessions. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
15 lines
741 B
Rust
15 lines
741 B
Rust
fn main() {
|
|
let h: u32 = 16; let w: u32 = 16;
|
|
let mut rgb = vec![0u8; (h*w*3) as usize];
|
|
for i in 0..h { for j in 0..w {
|
|
let p = ((i*w+j)*3) as usize;
|
|
rgb[p] = ((i+j)*8) as u8; rgb[p+1] = (i*16) as u8; rgb[p+2] = (j*16) as u8;
|
|
}}
|
|
let bytes = wai::codecs::image::jpeg_encode(&rgb, h, w, 80).unwrap();
|
|
std::fs::write("/tmp/test.jpg", &bytes).unwrap();
|
|
println!("wrote {} bytes", bytes.len());
|
|
let (rec, rh, rw) = wai::codecs::image::jpeg_decode(&bytes).unwrap();
|
|
println!("decoded {}x{}", rh, rw);
|
|
let mse: f64 = rgb.iter().zip(&rec).map(|(&a,&b)| (a as f64 - b as f64).powi(2)).sum::<f64>() / rgb.len() as f64;
|
|
println!("PSNR: {:.2} dB", 10.0 * (255.0f64.powi(2) / mse).log10());
|
|
}
|