//! Decode an `int_hyper` conditional bitstream from a directory and dump the //! reconstructed frame as raw RGB (HWC u8) — the byte-exact keyframe the //! `int_hyper`-keyframe video codec builds its P-frames on. //! //! cargo run --release --no-default-features --features neural_int --example int_hyper_decode_frame -- //! //! `` is an int_hyper vector dir (e.g. `/tmp/sota_int`) holding //! `int_synth_sota_model.json`, `int_hs_model.json`, `cond_entropy.json`, //! `cond_bitstream.json`. use wai::int_hyper_synth::{decode_conditional, CondBitstream, CondEntropy, IntModel}; fn main() { let a: Vec = std::env::args().collect(); if a.len() < 3 { eprintln!("usage: int_hyper_decode_frame "); std::process::exit(2); } let d = std::path::PathBuf::from(&a[1]); let jl = |n: &str| -> serde_json::Value { serde_json::from_slice(&std::fs::read(d.join(n)).expect(n)).unwrap() }; let g_s = IntModel::from_json(&jl("int_synth_sota_model.json")); let h_s = IntModel::from_json(&jl("int_hs_model.json")); let ent = CondEntropy::from_value(&jl("cond_entropy.json")); let bs = CondBitstream::from_value(&jl("cond_bitstream.json")); let (rgb, h, w) = decode_conditional(&g_s, &h_s, &ent, &bs).expect("decode_conditional"); std::fs::write(&a[2], &rgb).unwrap(); eprintln!("{h}x{w} -> {} ({} bytes)", a[2], rgb.len()); }