The lossless refusal gets its own libaom -crf 0 gate and its inventory entry
Browse files at this commitc0c60c59abd6ecd9b8ed703bb1a643c57fdff1c4Parent: 2f8409b- test
- the lossless refusal gets its own libaom -crf 0 gate and its inventory entry
2 changed files +87 -0
crates/ec-av1/src/refusal_inventory.rsmodified+13 -0
| @@ -57,6 +57,15 @@ const REFUSALS: &[&str] = &[ | ||
| 57 | 57 | "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", |
| 58 | 58 | "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)", |
| 59 | 59 | "a bit depth of 12 (this decoder is gated at 8 and 10 only: warp/MC/wiener rounding shifts change at 12-bit and no 12-bit gate exists)", |
| 60 | + // lane-dpm1: libaom codes his screen-capture row at `-crf 5` with | |
| 61 | + // `base_q_idx == 0`, i.e. LOSSLESS -- TX_4X4 with the Walsh-Hadamard | |
| 62 | + // transform over every block (no `tx_depth` symbol at all) and | |
| 63 | + // `is_cfl_allowed` narrowed to `plane_bsize == BLOCK_4X4`, which changes | |
| 64 | + // the `uv_mode` alphabet. Nothing here consumes the header's `lossless`, | |
| 65 | + // so the first block of such a frame read `uv_mode` = UV_CFL_PRED where | |
| 66 | + // aomdec reads V_PRED. Refused by name (gate | |
| 67 | + // `a_lossless_libaom_stream_is_refused_by_name`) until the path exists. | |
| 68 | + "a lossless frame (qindex 0): the TX_4X4 Walsh-Hadamard tile syntax and the lossless CfL rule are unimplemented", | |
| 60 | 69 | "a frame OBU with no tile group", |
| 61 | 70 | "a frame naming primary_ref_frame at a reference slot with no saved CDF state", |
| 62 | 71 | "a frame with no mode-info grid", |
| @@ -275,6 +284,10 @@ const PROVEN: &[(&str, &str)] = &[ | ||
| 275 | 284 | "an inter frame with no key frame before it", |
| 276 | 285 | "an_inter_frame_opening_a_stream_is_refused_by_name", |
| 277 | 286 | ), |
| 287 | + ( | |
| 288 | + "a lossless frame (qindex 0): the TX_4X4 Walsh-Hadamard tile syntax and the lossless CfL rule are unimplemented", | |
| 289 | + "a_lossless_libaom_stream_is_refused_by_name", | |
| 290 | + ), | |
| 278 | 291 | // lane-t900 r25, enumeration: a motion_mode/obmc symbol is read only under |
| 279 | 292 | // `is_motion_variation_allowed_bsize` (min side >= 8), and each of the 17 |
| 280 | 293 | // `BLOCK_SIZES_ALL` footprints that clause admits maps to a distinct row of |
crates/ec-av1/src/stream.rsmodified+74 -0
| @@ -3985,6 +3985,80 @@ pub(crate) mod tests { | ||
| 3985 | 3985 | } |
| 3986 | 3986 | } |
| 3987 | 3987 | |
| 3988 | + /// lane-dpm1: the lossless refusal is a CLAIM, so it gets a stream that | |
| 3989 | + /// reaches it. libaom at `-crf 0` codes `base_q_idx == 0` -- the same | |
| 3990 | + /// lossless frame his screen-capture row gets at `-crf 5` -- where the tile | |
| 3991 | + /// syntax is TX_4X4 + Walsh-Hadamard and `is_cfl_allowed` narrows to | |
| 3992 | + /// `plane_bsize == BLOCK_4X4`. Before the refusal our decoder returned a | |
| 3993 | + /// picture that was wrong from luma sample 0 (measured on that row: 126 | |
| 3994 | + /// against ffmpeg's 33, the first block's `uv_mode` read off the CfL | |
| 3995 | + /// alphabet). The gate asserts the stream really is lossless and that we | |
| 3996 | + /// refuse it BY NAME rather than decode it wrong. | |
| 3997 | + #[test] | |
| 3998 | + fn a_lossless_libaom_stream_is_refused_by_name() { | |
| 3999 | + const NAME: &str = "a_lossless_libaom_stream_is_refused_by_name"; | |
| 4000 | + if !have_ffmpeg() { | |
| 4001 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 4002 | + return; | |
| 4003 | + } | |
| 4004 | + let (w, h, frames) = (256usize, 128usize, 2usize); | |
| 4005 | + let mut raw = Vec::with_capacity(frames * w * h * 3 / 2); | |
| 4006 | + for f in 0..frames { | |
| 4007 | + for row in 0..h { | |
| 4008 | + for col in 0..w { | |
| 4009 | + raw.push(((col * 7 + row * 13 + f * 31) % 251) as u8); | |
| 4010 | + } | |
| 4011 | + } | |
| 4012 | + raw.extend(std::iter::repeat_n(128u8, w * h / 2)); | |
| 4013 | + } | |
| 4014 | + // [[pid-keyed-temp-path]]: parallel test binaries must not share a name. | |
| 4015 | + let src = std::env::temp_dir().join(format!("ec-av1-lossless-{}.yuv", std::process::id())); | |
| 4016 | + std::fs::write(&src, &raw).expect("raw source"); | |
| 4017 | + let out = Command::new("ffmpeg") | |
| 4018 | + .args(["-v", "error", "-y", "-f", "rawvideo", "-pix_fmt", "yuv420p"]) | |
| 4019 | + .args(["-s", &format!("{w}x{h}"), "-r", "24", "-i"]) | |
| 4020 | + .arg(&src) | |
| 4021 | + .args(["-an", "-threads", "1", "-g", "2", "-c:v", "libaom-av1"]) | |
| 4022 | + .args(["-cpu-used", "6", "-b:v", "0", "-crf", "0", "-f", "obu", "-"]) | |
| 4023 | + .stdin(Stdio::null()) | |
| 4024 | + .stdout(Stdio::piped()) | |
| 4025 | + .stderr(Stdio::piped()) | |
| 4026 | + .output() | |
| 4027 | + .expect("ffmpeg failed to run"); | |
| 4028 | + let _ = std::fs::remove_file(&src); | |
| 4029 | + if !out.status.success() { | |
| 4030 | + eprintln!( | |
| 4031 | + "SKIP {NAME}: ffmpeg has no libaom-av1 encoder ({})", | |
| 4032 | + String::from_utf8_lossy(&out.stderr) | |
| 4033 | + ); | |
| 4034 | + return; | |
| 4035 | + } | |
| 4036 | + let stream = out.stdout; | |
| 4037 | + // Half of the gate: the stream must really carry a lossless frame | |
| 4038 | + // (class `gate-blind-to-feature`). | |
| 4039 | + let mut parser = Av1Parser::new(); | |
| 4040 | + let (mut pos, mut lossless) = (0usize, 0usize); | |
| 4041 | + while pos < stream.len() { | |
| 4042 | + let obu = parser.parse_obu(&stream[pos..]).expect("libaom OBU parses"); | |
| 4043 | + pos += obu.total_size.max(1); | |
| 4044 | + let header = match &obu.kind { | |
| 4045 | + ObuKind::FrameHeader(h) | ObuKind::Frame(h, _) => h, | |
| 4046 | + _ => continue, | |
| 4047 | + }; | |
| 4048 | + if header.lossless.iter().any(|&l| l) { | |
| 4049 | + lossless += 1; | |
| 4050 | + } | |
| 4051 | + } | |
| 4052 | + assert!(lossless > 0, "{NAME} went blind: libaom coded no lossless frame at -crf 0"); | |
| 4053 | + match decode_stream(&stream) { | |
| 4054 | + Ok(_) => panic!("{NAME}: a lossless stream decoded instead of being refused"), | |
| 4055 | + Err(e) => assert!( | |
| 4056 | + format!("{e}").contains("a lossless frame (qindex 0)"), | |
| 4057 | + "{NAME}: refused for the wrong reason: {e}" | |
| 4058 | + ), | |
| 4059 | + } | |
| 4060 | + } | |
| 4061 | + | |
| 3988 | 4062 | /// lane-dkey: the palette-neighbour-band gate. A palette-Y block's size and |
| 3989 | 4063 | /// colours used to stay standing in the mi-granular above/left bands after a |
| 3990 | 4064 | /// sub-8x8 group was decoded next to it -- the sub-8x8 readers published |