Document decode_probe, which 2be815f added without saying so
Browse files at this commite7ae36ef5d82257abb106310e70f81ff7144c04aParent: 177de6a- docs
- document decode_probe, which 2be815f added without saying so
1 changed file +32 -3
crates/ec-av1/examples/decode_probe.rsmodified+32 -3
| @@ -1,8 +1,37 @@ | |||
| 1 | -//! Temporary probe: decode an IVF and print what the decoder says. | 1 | +//! Where does a real stream stop? Decode one AV1 file and print the answer. |
| 2 | +//! | ||
| 3 | +//! The gates in [`ec_av1::stream`] each pin one capability against one encoder | ||
| 4 | +//! recipe. This asks the complementary question -- given a stream someone | ||
| 5 | +//! actually produced, which refusal comes first -- and it is how the refusal | ||
| 6 | +//! distribution in commit 2be815f was measured rather than reasoned about: | ||
| 7 | +//! | ||
| 8 | +//! ```text | ||
| 9 | +//! aomenc --codec=av1 --obu -o s.obu --passes=1 --cpu-used=4 --limit=4 in.y4m | ||
| 10 | +//! cargo run -p ec-av1 --example decode_probe -- s.obu | ||
| 11 | +//! ``` | ||
| 12 | +//! | ||
| 13 | +//! Note `--obu`: [`ec_av1::stream::decode_stream`] takes a raw OBU stream, and | ||
| 14 | +//! an IVF file decodes as zero frames rather than as an error. | ||
| 15 | +//! | ||
| 16 | +//! That run is also what disproved three refusal strings claiming an encoder | ||
| 17 | +//! never writes a case it demonstrably writes, so this is a first-class | ||
| 18 | +//! instrument, not a scratch file. | ||
| 2 | fn main() { | 19 | fn main() { |
| 3 | - let path = std::env::args().nth(1).expect("usage: decode_probe <file.ivf>"); | 20 | + let Some(path) = std::env::args().nth(1) else { |
| 4 | - let data = std::fs::read(&path).expect("read"); | 21 | + eprintln!("usage: decode_probe <stream.obu>"); |
| 22 | + std::process::exit(2); | ||
| 23 | + }; | ||
| 24 | + let data = match std::fs::read(&path) { | ||
| 25 | + Ok(data) => data, | ||
| 26 | + Err(e) => { | ||
| 27 | + eprintln!("{path}: {e}"); | ||
| 28 | + std::process::exit(2); | ||
| 29 | + } | ||
| 30 | + }; | ||
| 5 | match ec_av1::stream::decode_stream(&data) { | 31 | match ec_av1::stream::decode_stream(&data) { |
| 32 | + Ok(frames) if frames.is_empty() => { | ||
| 33 | + println!("OK but EMPTY: no frames -- is {path} an IVF rather than a raw OBU stream?"); | ||
| 34 | + } | ||
| 6 | Ok(frames) => println!("OK: {} frames decoded", frames.len()), | 35 | Ok(frames) => println!("OK: {} frames decoded", frames.len()), |
| 7 | Err(e) => println!("REFUSED: {e}"), | 36 | Err(e) => println!("REFUSED: {e}"), |
| 8 | } | 37 | } |