diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 0020aa6f..7e7d73f5 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -44628,4 +44628,496 @@ pub(crate) mod tests { } assert!(seen, "{name}: no sequence header parsed"); } + + /// lane-av1tilemeasure: the per-frame facts a tiling / superres / odd-size + /// cell's OWN claim needs, read off the parsed stream. + /// + /// Every gate below asserts its cell through this, never through the + /// aomenc flag that was supposed to produce it. `lanes/av1formatsweep. + /// report.md` trap 2 is exactly that failure: `--tile-rows=1` below 256px + /// high at `--sb-size=128` leaves the stream byte-identical, so a gate + /// that trusted the flag would report an untiled decode as a tile-row + /// decode (and the sweep's own 10/12-bit "tile rows" numbers were that). + #[derive(Debug, Clone, Copy)] + struct FrameFacts { + tile_cols: u32, + tile_rows: u32, + use_superres: bool, + coded_w: u32, + coded_h: u32, + upscaled_w: u32, + mi_cols: u32, + mi_rows: u32, + } + + fn frame_facts(stream: &[u8], name: &str) -> Vec { + let mut parser = Av1Parser::new(); + let mut pos = 0usize; + let mut out: Vec = Vec::new(); + while pos < stream.len() { + let obu = parser + .parse_obu(&stream[pos..]) + .unwrap_or_else(|e| panic!("{name}: aomenc OBU does not parse: {e:?}")); + if obu.total_size == 0 { + break; + } + pos += obu.total_size; + if let ObuKind::FrameHeader(h) | ObuKind::Frame(h, _) = obu.kind { + out.push(FrameFacts { + tile_cols: h.tile_info.cols, + tile_rows: h.tile_info.rows, + use_superres: h.use_superres, + coded_w: h.frame_width, + coded_h: h.frame_height, + upscaled_w: h.upscaled_width, + mi_cols: h.mi_cols, + mi_rows: h.mi_rows, + }); + } + } + assert!( + !out.is_empty(), + "{name}: the stream carries no frame header" + ); + out + } + + /// lane-av1tilemeasure: 12-BIT 4:2:0 with tile ROWS genuinely enabled, and + /// with a 2x2 tile grid. `gate_coverage.rs` records that the multi-tile + /// 2D grid is covered "at both bit depths" -- meaning 8 and 10; 12 was the + /// gap, and the sweep's 12-bit "tile rows" cell (t420_12_row) never + /// encoded an untiled control, so nobody could say which stream it had + /// measured. + /// + /// Recipe (per arm): `mandelbrot 256x256` + `-vf gblur=sigma=6` + /// yuv420p12le 6 frames (the 12-bit screen-tools refusal fires on a sharp + /// source -- H6), `aomenc --codec=av1 --passes=1 --end-usage=q + /// --cq-level=20 --cpu-used=2 --enable-palette=0 --enable-intrabc=0 + /// --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=6 + /// --input-bit-depth=12 --bit-depth=12 --obu -o - -` plus `--tile-rows=1` + /// (arm 1) or `--tile-columns=1 --tile-rows=1` (arm 2). + /// + /// NON-VACUITY, in the order a reader should check it: + /// 1. the sequence header is `ss (1,1)` at 12 bits + /// (`odd_dim_header_mi_grid`); + /// 2. EVERY frame header's parsed `tile_info` is 1x2 / 2x2 -- the trap-2 + /// guard: an untiled stream fails here before a pixel is read; + /// 3. `decode::tile_hits()` advances by at least one hit per tile per + /// frame, so tile 1 (and the second ROW) really decoded rather than the + /// first tile being decoded twice; + /// 4. every decoded plane is 256*256 samples -- a truncated or + /// quarter-extent decode fails the shape assert; + /// 5. `decode_all_frames_vs_oracle` asserts the decode-order frame COUNT + /// and each frame's byte LENGTH against the instrumented `aomdec` + /// before any sample is compared (a prefix compare is not a compare -- + /// the same report's trap 1). + #[test] + fn a_real_aomenc_12bit_stream_with_two_tile_rows_and_a_two_by_two_tile_grid_decodes_pixel_exact() + { + const NAME: &str = "a_real_aomenc_12bit_stream_with_two_tile_rows_and_a_two_by_two_tile_grid_decodes_pixel_exact"; + let _gate_lock = lock_gate_counters(); + if !have_ffmpeg() || !have_aomenc() { + eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); + return; + } + let arms: [(&str, &[&str], u32, u32); 2] = [ + ("two tile rows", &["--tile-rows=1"], 1, 2), + ( + "a 2x2 tile grid", + &["--tile-columns=1", "--tile-rows=1"], + 2, + 2, + ), + ]; + for (label, tiles, want_cols, want_rows) in arms { + let mut extra = vec![ + "--cq-level=20", + "--cpu-used=2", + "--enable-palette=0", + "--enable-intrabc=0", + ]; + extra.extend_from_slice(tiles); + let stream = chroma_format_stream(256, 256, "yuv420p12le", 12, 6, &extra, 1); + odd_dim_header_mi_grid(&stream, NAME, 12); + let facts = frame_facts(&stream, NAME); + assert_eq!( + facts.len(), + 6, + "{NAME} ({label}): expected six frame headers, parsed {}", + facts.len() + ); + for (i, f) in facts.iter().enumerate() { + assert_eq!( + (f.tile_cols, f.tile_rows), + (want_cols, want_rows), + "{NAME} ({label}): decode-order frame {i} parses tile_info {}x{}, not \ + {want_cols}x{want_rows} -- the aomenc tile flag was a NO-OP at this \ + geometry, so this arm would be measuring an untiled stream", + f.tile_cols, + f.tile_rows + ); + } + let before_tiles = crate::decode::tile_hits(); + let frames = decode_stream(&stream) + .unwrap_or_else(|e| panic!("{NAME} ({label}): refused the stream: {e}")); + let tile_hits = crate::decode::tile_hits() - before_tiles; + assert!( + tile_hits >= facts.len() * (want_cols * want_rows) as usize, + "{NAME} ({label}): tile_hits advanced by {tile_hits} over {} frames of a \ + {}x{} grid -- not every tile decoded", + facts.len(), + want_cols, + want_rows + ); + for (i, f) in frames.iter().enumerate() { + assert_eq!( + f.y.len(), + 256 * 256, + "{NAME} ({label}): frame {i} luma plane is {} samples, not 256x256", + f.y.len() + ); + } + let (frames_decoded, _hidden) = decode_all_frames_vs_oracle(&stream, NAME); + assert!( + frames_decoded >= 6, + "{NAME} ({label}): {frames_decoded} decode-order frames" + ); + eprintln!( + "{NAME} ({label}): {frames_decoded} frames byte-exact vs aomdec, tiles \ + {want_cols}x{want_rows} confirmed on every frame header, tile_hits {tile_hits}" + ); + } + } + + /// lane-av1tilemeasure: 4:4:4 SUPERRES at 8, 10 and 12 bits. The sweep's + /// superres row was `--superres-mode=1` alone, and measured that recipe + /// at 4:4:4 8 bits: this lane re-encoded it and read `use_superres` on + /// every frame header -- ZERO frames carried it, so that cell never + /// exercised the upscaler at all (the same "an aomenc flag is not + /// evidence" trap as tile rows, one axis over). libaom only signals + /// `use_superres` when a DENOMINATOR is given, so the arms here spell + /// `--superres-denominator=12 --superres-kf-denominator=12` and the + /// header says `use_superres=1` on all four frames. + /// + /// Recipe: `testsrc2 128x128` yuv444p10le (12-bit: the gblur'd + /// `mandelbrot`, H6) 4 frames, `aomenc --codec=av1 --passes=1 + /// --end-usage=q --cq-level=20 --cpu-used=2 --enable-palette=0 + /// --enable-intrabc=0 --superres-mode=1 --superres-denominator=12 + /// --superres-kf-denominator=12 --threads=1 --row-mt=0 --lag-in-frames=0 + /// --kf-max-dist=100 --limit=4 --input-bit-depth=N --bit-depth=N --obu + /// -o - -`. Coded width comes out 85px, upscaled to 128. + /// + /// NON-VACUITY: `ss (0,0)` at the claimed depth; EVERY frame header has + /// `use_superres` with a coded width strictly below the upscaled one (a + /// stream without it fails here, not at the pixel compare); + /// `superres::superres_hits()` advances once per frame (the upscaler + /// really ran); every decoded plane is the UPSCALED 128x128 -- a decoder + /// that forgot the upsample would hand back 85x128 and fail the shape + /// assert, and at `ss (0,0)` the chroma planes must be full resolution + /// too; then the length-asserting `aomdec` compare. + #[test] + fn a_real_aomenc_444_superres_stream_at_8_10_and_12_bit_decodes_pixel_exact() { + const NAME: &str = + "a_real_aomenc_444_superres_stream_at_8_10_and_12_bit_decodes_pixel_exact"; + let _gate_lock = lock_gate_counters(); + if !have_ffmpeg() || !have_aomenc() { + eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); + return; + } + for (depth, pix_fmt, smooth) in [ + (8usize, "yuv444p", 0u8), + (10, "yuv444p10le", 0), + (12, "yuv444p12le", 1), + ] { + let stream = chroma_format_stream( + 128, + 128, + pix_fmt, + depth, + 4, + &[ + "--cq-level=20", + "--cpu-used=2", + "--enable-palette=0", + "--enable-intrabc=0", + "--superres-mode=1", + "--superres-denominator=12", + "--superres-kf-denominator=12", + ], + smooth, + ); + assert_444_header(&stream, NAME, depth); + let facts = frame_facts(&stream, NAME); + for (i, f) in facts.iter().enumerate() { + assert!( + f.use_superres, + "{NAME} ({depth}-bit): decode-order frame {i} has use_superres=0 -- the \ + superres cell would be measuring an ordinary 4:4:4 stream" + ); + assert!( + f.coded_w < f.upscaled_w, + "{NAME} ({depth}-bit): frame {i} codes {}px and upscaled_width says {}px", + f.coded_w, + f.upscaled_w + ); + assert_eq!(f.upscaled_w, 128, "{NAME} ({depth}-bit): upscaled width"); + } + let before_sr = crate::superres::superres_hits(); + let frames = decode_stream(&stream) + .unwrap_or_else(|e| panic!("{NAME} ({depth}-bit): refused the stream: {e}")); + let superres_hits = crate::superres::superres_hits() - before_sr; + assert!( + superres_hits >= facts.len(), + "{NAME} ({depth}-bit): superres_hits advanced by {superres_hits} over {} \ + frames -- the upscaler never ran", + facts.len() + ); + for (i, f) in frames.iter().enumerate() { + assert_eq!( + f.y.len(), + 128 * 128, + "{NAME} ({depth}-bit): frame {i} luma is {} samples -- a superres decode \ + must hand back the UPSCALED 128x128, not the 85px coded width", + f.y.len() + ); + assert_eq!( + f.u.len(), + 128 * 128, + "{NAME} ({depth}-bit): frame {i} chroma is {} samples -- at 4:4:4 the chroma \ + plane is full resolution at the upscaled size", + f.u.len() + ); + } + let (frames_decoded, _hidden) = decode_all_frames_vs_oracle(&stream, NAME); + assert!( + frames_decoded >= 4, + "{NAME} ({depth}-bit): {frames_decoded} decode-order frames" + ); + eprintln!( + "{NAME} ({depth}-bit): {frames_decoded} frames byte-exact vs aomdec, \ + use_superres on every frame, superres_hits {superres_hits}" + ); + } + } + + /// lane-av1tilemeasure: 4:4:4 at PARTIAL and ODD coded dimensions, + /// 8/10/12 bits -- and a correction to what the sweep's "odd dims" cell + /// was measuring. + /// + /// **The sweep's odd-dimension 4:4:4 cells were not odd.** 66x66, + /// 130x122 and 194x130 are even in BOTH axes; what they are is "not a + /// multiple of 8", the same class as the 4:2:0 row the sweep measured as + /// "even, not a multiple of 8". This gate's own assert said so out loud + /// on its first run: `the 66x66 arm is even in BOTH axes`. The genuinely + /// odd arms are the two 12-bit ones, and they are producible only at 12 + /// bits: at 8 and 10 bits aomenc rounds a 4:4:4 odd size DOWN to even + /// (`67x67` -> coded 66x66, `131x131` -> coded 130x130, both measured), + /// the same rounding the sweep proved for 4:2:0. 12-bit (seq_profile 2) + /// keeps 67x67 and 65x67 odd, and both decode byte-exact. + /// + /// The sweep's 130x122 DIVERGENT verdict is also corrected here: this + /// lane re-encoded the identical stream (the bytes reproduce the + /// sweep's sha256 `c87ac65b…`) and it is byte-exact against `aomdec`. + /// That published verdict came from the prefix compare the same report + /// documents as its trap 1. + /// + /// Recipe per arm: `testsrc2 WxH` yuv444p[10le|12le] 4 frames (12-bit: + /// the gblur'd `mandelbrot`, H6), `aomenc --codec=av1 --passes=1 + /// --end-usage=q --cq-level=20 --cpu-used=2 --enable-palette=0 + /// --enable-intrabc=0 --threads=1 --row-mt=0 --lag-in-frames=0 + /// --kf-max-dist=100 --limit=4 --obu -o - -` (plus `--input-bit-depth` / + /// `--bit-depth` above 8). + /// + /// NON-VACUITY: `ss (0,0)` at the claimed depth; the arm is not a + /// multiple of 8 in some axis, and the `odd` flag says whether an axis is + /// odd, so an arm cannot quietly become the cell next door; EVERY frame + /// header's coded width and height are exactly the claimed sizes -- a + ///omenc rounding would make the arm measure a different geometry and fails + /// here rather than at the pixel compare; the mode-info grid is PARTIAL + /// (`mi_cols*8 > width` or `mi_rows*8 > height`), the partial-plane walk + /// the cell exists for; every decoded plane is exactly `width*height` (at + /// `ss (0,0)` the chroma planes are full resolution, so a 4:2:0 extent or + /// a truncated decode fails the shape assert); then the + /// length-asserting `aomdec` compare. + #[test] + fn a_real_aomenc_444_partial_and_odd_coded_dimension_streams_decode_pixel_exact() { + const NAME: &str = + "a_real_aomenc_444_partial_and_odd_coded_dimension_streams_decode_pixel_exact"; + let _gate_lock = lock_gate_counters(); + if !have_ffmpeg() || !have_aomenc() { + eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); + return; + } + // (width, height, bit depth, smooth source, an axis is odd) + let arms: [(usize, usize, usize, u8, bool); 10] = [ + (66, 66, 8, 0, false), + (98, 66, 8, 0, false), + (130, 122, 8, 0, false), + (66, 66, 10, 0, false), + (194, 130, 10, 0, false), + (130, 122, 10, 0, false), + (66, 66, 12, 1, false), + (130, 122, 12, 1, false), + (67, 67, 12, 1, true), + (65, 67, 12, 1, true), + ]; + for (w, h, depth, smooth, odd) in arms { + assert!( + w % 8 != 0 || h % 8 != 0, + "{NAME}: the {w}x{h} arm is a multiple of 8 -- it is not a partial-size cell" + ); + assert_eq!( + w % 2 == 1 || h % 2 == 1, + odd, + "{NAME}: the {w}x{h} arm's `odd` flag is wrong" + ); + let pix_fmt = match depth { + 8 => "yuv444p", + 10 => "yuv444p10le", + _ => "yuv444p12le", + }; + let stream = chroma_format_stream( + w, + h, + pix_fmt, + depth, + 4, + &[ + "--cq-level=20", + "--cpu-used=2", + "--enable-palette=0", + "--enable-intrabc=0", + ], + smooth, + ); + assert_444_header(&stream, NAME, depth); + let facts = frame_facts(&stream, NAME); + for (i, f) in facts.iter().enumerate() { + assert_eq!( + (f.coded_w as usize, f.coded_h as usize), + (w, h), + "{NAME} ({w}x{h} {depth}-bit): decode-order frame {i} codes {}x{} -- the arm \ + is not measuring the geometry it names", + f.coded_w, + f.coded_h + ); + assert!( + f.mi_cols as usize * 8 > w || f.mi_rows as usize * 8 > h, + "{NAME} ({w}x{h} {depth}-bit): frame {i} has a {}x{} mode-info grid, which \ + covers the frame exactly -- the partial-plane walk never runs", + f.mi_cols, + f.mi_rows + ); + } + let frames = decode_stream(&stream) + .unwrap_or_else(|e| panic!("{NAME} ({w}x{h} {depth}-bit): refused: {e}")); + for (i, f) in frames.iter().enumerate() { + assert_eq!( + f.y.len(), + w * h, + "{NAME} ({w}x{h} {depth}-bit): frame {i} luma is {} samples", + f.y.len() + ); + assert_eq!( + f.u.len(), + w * h, + "{NAME} ({w}x{h} {depth}-bit): frame {i} chroma is {} samples -- at 4:4:4 \ + the chroma plane is full resolution even at an odd coded size", + f.u.len() + ); + } + let (frames_decoded, _hidden) = decode_all_frames_vs_oracle(&stream, NAME); + assert!( + frames_decoded >= 4, + "{NAME} ({w}x{h} {depth}-bit): {frames_decoded} decode-order frames" + ); + eprintln!( + "{NAME}: {w}x{h} {depth}-bit codes exactly as named (odd axis: {odd}), \ + {frames_decoded} frames byte-exact vs aomdec" + ); + } + } + + /// lane-av1tilemeasure: the H3 CONTROL -- 4:4:4 LOSSLESS 8-bit with NO + /// tiles -- beside its two-tile-column sibling at the same geometry. The + /// sweep's H3 named a 90-chroma-sample divergence on a lossless 4:4:4 + /// tile-column stream; the control it never encoded is the untiled stream + /// at the same size, and without it "tiles cause it" and "4:4:4 lossless + /// chroma causes it" are the same sentence. Measured here: BOTH arms are + /// byte-exact against the oracle at 256x128, so at THIS geometry the + /// defect does not reproduce with or without tiles; the first 4:4:4 + /// lossless fork measured in this lane is at 192x192 (34 chroma samples, + /// first U(90,25)), where the tiled and untiled streams diverge at the + /// very same sample -- see `lanes/av1tilemeasure.report.md`. + /// + /// Recipe per arm: `testsrc2 256x128` yuv444p 6 frames, `aomenc + /// --codec=av1 --lossless=1 --passes=1 --end-usage=q --threads=1 + /// --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=6 + /// --enable-palette=0 --enable-intrabc=0 --obu -o - -`, plus + /// `--tile-columns=1` on the sibling. + /// + /// NON-VACUITY: `ss (0,0)` at 8 bits; every frame header's parsed + /// `tile_info` is 1x1 for the control and 2x1 for the sibling (so the + /// control cannot silently become a tiled stream, which is the whole + /// point of the arm); `decode::rect_split_lossless_chroma444_hits()` + /// advances, i.e. a lossless strip really walked its chroma as 4:4:4 4x4 + /// units; then the length-asserting `aomdec` compare. + #[test] + fn a_lossless_444_8bit_untiled_control_and_its_two_tile_column_sibling_decode_pixel_exact() { + const NAME: &str = "a_lossless_444_8bit_untiled_control_and_its_two_tile_column_sibling_decode_pixel_exact"; + let _gate_lock = lock_gate_counters(); + if !have_ffmpeg() || !have_aomenc() { + eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); + return; + } + let arms: [(&str, &[&str], u32, u32); 2] = [ + ( + "untiled control", + &["--lossless=1", "--enable-palette=0", "--enable-intrabc=0"], + 1, + 1, + ), + ( + "two tile columns", + &[ + "--lossless=1", + "--enable-palette=0", + "--enable-intrabc=0", + "--tile-columns=1", + ], + 2, + 1, + ), + ]; + for (label, flags, want_cols, want_rows) in arms { + let stream = chroma_format_stream(256, 128, "yuv444p", 8, 6, flags, 0); + assert_444_header(&stream, NAME, 8); + let facts = frame_facts(&stream, NAME); + for (i, f) in facts.iter().enumerate() { + assert_eq!( + (f.tile_cols, f.tile_rows), + (want_cols, want_rows), + "{NAME} ({label}): decode-order frame {i} parses tile_info {}x{}, not \ + {want_cols}x{want_rows}", + f.tile_cols, + f.tile_rows + ); + } + let before_444 = crate::decode::rect_split_lossless_chroma444_hits(); + let (frames_decoded, _hidden) = decode_all_frames_vs_oracle(&stream, NAME); + assert!( + crate::decode::rect_split_lossless_chroma444_hits() > before_444, + "{NAME} ({label}) went blind: no lossless strip walked its chroma as 4:4:4 4x4 \ + units, so the cell never reached the 4:4:4 chroma path" + ); + assert!( + frames_decoded >= 6, + "{NAME} ({label}): {frames_decoded} decode-order frames" + ); + eprintln!( + "{NAME} ({label}): {frames_decoded} frames byte-exact vs aomdec, tiles \ + {want_cols}x{want_rows} confirmed on every frame header" + ); + } + } } diff --git a/lanes/av1tilemeasure.report.md b/lanes/av1tilemeasure.report.md new file mode 100644 index 00000000..c2fe1c81 --- /dev/null +++ b/lanes/av1tilemeasure.report.md @@ -0,0 +1,309 @@ +# lane-av1tilemeasure — tile-rows / superres / odd-size cells, measured + +**Tree.** `lane-av1tilemeasure` off `a21f3680`, worktree `~/.cache/wt/av1tilemeasure`. +`crates/ec-av1/src/decode.rs` is **untouched**; every verdict below is HEAD's decoder. + +**Method.** Every cell was encoded live against the durable oracle +(`~/.cache/aom-oracle/build/aomenc`), its OBUs were **parsed** and the frame +headers' `tile_info` / `use_superres` / coded size read off the parse (never off +the aomenc flag), and the stream was decoded against the instrumented +`~/.cache/aom-oracle/build/aomdec` through the same +`decode_all_frames_vs_oracle` path the committed gates use: it asserts the +decode-order frame COUNT and each frame's byte LENGTH before a single sample is +compared. Control arms first: 4:2:0 12-bit untiled and the two existing 4:4:4 +committed recipes both come out byte-exact, so the harness is sound. + +--- + +## 0. Trap 3 (this lane's own): a SHARED `CARGO_TARGET_DIR` silently measures another lane's decoder + +The first two sweeps of this lane were run with the house +`CARGO_TARGET_DIR=$HOME/.cache/cargo-target`, which at that moment was being +written by at least one other lane building `ec-av1` from its own worktree. The +example binary linked **that** lane's in-flight `ec-av1` rlib, and the numbers +were not merely noisy — they were a different decoder: + +| cell | shared target dir | lane-private target dir | +|---|---|---| +| 4:4:4 lossless 8-bit 2x2 tiles, 256x256 | DIVERGENT f1, 11913 samples, first Y(216,128) | **EXACT 6/6** | +| 4:4:4 lossless 8-bit 1 tile row, 128x256 | DIVERGENT f1, 8055 samples, first Y(108,128) | **EXACT 6/6** | +| 4:2:0 lossless 8-bit 2x2 tiles, 256x256 | DIVERGENT f1, 5545 samples, first Y(64,0) | **EXACT 6/6** | +| 4:2:0 lossless 8-bit 1 tile row, 256x256 | DIVERGENT f1, 39763 samples, first Y(128,0) | **EXACT 6/6** | +| 4:2:0 lossless 8-bit 128x256 untiled | DIVERGENT f1, 25334 samples, first Y(86,0) | **EXACT 6/6** | +| 4:4:4 lossless 10-bit 1 tile row, 128x256 | refused by name ("Golomb tail") | DIVERGENT f0, 74 samples, first U(82,188) | +| 4:4:4 lossless 10-bit 1 tile row, 256x256 | 1208 then 1083 samples (two binaries) | 1374 samples, one number | + +A second symptom of the same collision, and the one that could have shipped a +false green: `cargo test -p ec-av1 --lib -- --exact ` reported +`0 passed; 717 filtered out` **three times in a row** while the source file +contained the gate — cargo was running the other lane's test binary. It also +rebuilt "successfully" (`Compiling ec-av1`) without my tests in it. + +**Rule this lane proposes:** any lane that measures *or gates* `ec-av1` while +other lanes are live must use a LANE-PRIVATE `CARGO_TARGET_DIR` +(`$HOME/.cache/cargo-target-`). The shared directory is fine for +`cargo check` on a path that no sibling is building, and useless as evidence. +Every number in this report was re-taken in +`$HOME/.cache/cargo-target-av1tilemeasure` and is stable across repeated runs +(three runs of the same cell, identical counts and identical first-fork values). + +--- + +## 1. The `t420_12_row` correction (published verdict: "may be measuring the same stream") + +**It was not measuring the same stream, and the flag was not a no-op at that +geometry.** The sweep's caveat assumed 128px superblocks; profile-0 4:2:0 +defaults to `--sb-size=64`, so a 256x128 frame is a 4x2 SB grid and +`--tile-rows=1` really does split it. Encoded at the sweep's own flag set +(`--profile=0 --cq-level=20 --cpu-used=2 --enable-palette=0 --enable-intrabc=0 +--threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=6`, source +`mandelbrot=size=256x128:rate=25` + `-vf gblur=sigma=6` yuv420p12le), all three +arms parse as three different grids and are three different streams: + +| arm | parsed `tile_info` (all 6 frames) | bytes | sha256 | verdict vs aomdec | +|---|---|---|---|---| +| `t420_12_notile` (the control the sweep never encoded) | 1x1 | 1675 | `6cd14c13356a5d8e` | **EXACT 6/6** | +| `t420_12_col` (`--tile-columns=1`) | 2x1 | 1747 | `0069fa4b1a9f63bd` | **EXACT 6/6** | +| `t420_12_row` (`--tile-rows=1`) | **1x2** | 1785 | `85050393a76cafae` | **EXACT 6/6** | + +Two independent ways to see the published cells were distinct streams: the +sweep's own table already lists different sha256 and different byte counts for +`t420_12_col` (`c983a91c`, 8713 B) and `t420_12_row` (`0bf14e1e`, 8760 B) — a +no-op flag would have produced identical bytes, which is exactly what the +sweep's own trap-2 table shows happening at `--sb-size=128`. So **the cell did +carry two tile rows, and the EXACT verdict stands on its own stream.** + +Trap 2 is nevertheless real and now has its own reproduction, in the same +report's own words: at `--sb-size=128`, `--tile-rows=1` at 256x128 leaves the +stream byte-identical (`a628e835b8ca1002` for both arms, parsed 1x1 both times). +The flag is a no-op exactly when the frame is one SB row tall. + +**Caveat on the published byte counts.** The sweep's 8713/8760-byte streams are +not reproducible from the recipe text in the report (a re-encode of that exact +flag set gives 1675/1747/1785 bytes). Dropping the `gblur` smoothing — the one +degree of freedom the report leaves open — gives 10830/11139/11147 bytes, and +all three of THOSE hit this decoder's named 12-bit screen-content-tools refusal +(`allow_screen_content_tools=1`). The published byte counts are therefore from a +third variant; the structural answer above does not depend on reproducing them. + +--- + +## 2. Cells measured, with the recipe and the parsed geometry + +Every row: parse asserted before pixels, decode compared against `aomdec` in +decode order with equal frame count and equal byte length asserted first. +Common aomenc tail: `--codec=av1 --passes=1 --end-usage=q --threads=1 --row-mt=0 +--lag-in-frames=0 --kf-max-dist=100 --obu -o - -` (+ `--input-bit-depth=N +--bit-depth=N` above 8). Sources: `testsrc2=WxH:rate=25` unless marked +*smooth* = `mandelbrot=WxH:rate=25` + `-vf gblur=sigma=6` (mandatory at 12 bits, +H6: a sharp 12-bit source sets `allow_screen_content_tools` and the refusal +fires before anything else). + +### 2.1 Tile ROWS genuinely enabled (the cell trap 2 left open) + +| cell | recipe flags | parsed grid | bytes / sha256 | verdict | +|---|---|---|---|---| +| 4:2:0 12-bit 1x2 rows, 256x256 | `--cq-level=20 --cpu-used=2 --enable-palette=0 --enable-intrabc=0 --tile-rows=1`, *smooth*, 6f | 1x2 | 3725 / `40448841c229d18c` | **EXACT 6/6** | +| 4:2:0 12-bit 2x2 grid, 256x256 | same + `--tile-columns=1` | 2x2 | 3886 / `90fff0c014e954c4` | **EXACT 6/6** | +| 4:2:0 10-bit 1x2 rows, 256x256 | same, yuv420p10le | 1x2 | 16509 / `3f2041bb56f4b6c0` | **EXACT 6/6** | +| 4:2:0 8-bit 1x2 rows, 256x256 | same, yuv420p | 1x2 | 15705 / `7726da064e677fb7` | **EXACT 6/6** | +| 4:4:4 lossless 8-bit 1x2 rows, 256x256 | `--lossless=1 --sb-size=128 --tile-rows=1` + tools off | 1x2 | 111159 / `043e31cc555b5946` | DIVERGENT — §3 | +| 4:4:4 lossless 10-bit 1x2 rows, 256x256 | same, yuv444p10le | 1x2 | 189317 / `562ea414b515f715` | DIVERGENT — §3 | +| 4:4:4 lossless 12-bit 1x2 rows, 256x256 | same, yuv444p12le, *smooth* | 1x2 | 414712 / `63d3b7a9c80dc60b` | DIVERGENT — §3 | +| 4:4:4 lossless 10-bit 1x2 rows, 128x256, sb64 | `--lossless=1 --tile-rows=1` + tools off | 1x2 | 126594 / `491982ec18cc45b9` | DIVERGENT — §3 | +| 4:4:4 lossless 8-bit 2x2 grid, 256x256 | `--lossless=1 --sb-size=128 --tile-columns=1 --tile-rows=1` | 2x2 | 111264 / `d517d33ef232770b` | **EXACT 6/6** | +| 4:4:4 lossless 8-bit 1x2 rows, 128x256, sb128 | `--lossless=1 --sb-size=128 --tile-rows=1` | 1x2 | 68908 / `74c85b982ff75ff5` | **EXACT 6/6** | + +`gate_coverage.rs` says the multi-tile 2D grid is covered "at both bit depths" +— meaning 8 and 10. **12-bit was the hole**, and it is now a gate. + +### 2.2 4:4:4 superres, and the trap on the same axis as trap 2 + +`--superres-mode=1` alone does **not** make libaom signal superres: re-encoding +the sweep's own superres recipe (`--superres-mode=1 --cq-level=20 +--cpu-used=2`, 256x128) and parsing every frame header gives `use_superres` on +**0 of 6 frames**, at 8, 10 and 12 bits. A denominator is required. With +`--superres-denominator=12 --superres-kf-denominator=12` every frame header +carries `use_superres=1` and the coded width drops (128x128 display -> 85x128 +coded), i.e. the flag finally did something: + +| cell | recipe | parsed | verdict | +|---|---|---|---| +| 4:4:4 superres 8-bit, 128x128, 4f | `--cq-level=20 --cpu-used=2 --enable-palette=0 --enable-intrabc=0 --superres-mode=1 --superres-denominator=12 --superres-kf-denominator=12` | 85x128 coded, use_superres 4/4 | **EXACT 4/4** | +| 4:4:4 superres 10-bit, same | yuv444p10le | 85x128, 4/4 | **EXACT 4/4** | +| 4:4:4 superres 12-bit, same | yuv444p12le, *smooth* | 85x128, 4/4 | **EXACT 4/4** | +| 4:2:0 superres 12-bit, 128x128, 2f | same, yuv420p12le, *smooth* | 85x128, 2/2 | **EXACT 2/2** | +| 4:4:4 superres 10-bit, 256x256, 4f | same at 256x256 | 171x256, 4/4 | **EXACT 4/4** | +| 4:4:4 superres 12-bit, 256x256, 4f | same at 256x256 | 171x256, 4/4 | **EXACT 4/4** | + +The sweep's published 4:4:4 superres verdicts (`sr444` DIVERGENT from f2; +`sr444_12`/`sr420_12` EXACT) are all `--superres-mode=1`-only recipes, i.e. +streams with `use_superres = 0` on every frame: whatever they measured, it was +not superres. With superres genuinely on, all three depths are exact. + +### 2.3 4:4:4 partial and odd coded dimensions + +The sweep's "odd coded dims" cells (66x66, 130x122, 194x130) are **even in both +axes** — what they are is "not a multiple of 8". This gate said so out loud on +its first run: `the 66x66 arm is even in BOTH axes`. A genuinely odd 4:4:4 +coded size is producible **only at 12 bits** (seq_profile 2): at 8 and 10 bits +aomenc rounds the size down to even — `67x67` -> coded 66x66 (byte-identical to +the 66x66 arm, sha `973eddf4aa6b0bf1`) and `131x131` -> coded 130x130. + +| cell | coded size (parsed) | bytes / sha256 | verdict | +|---|---|---|---| +| 4:4:4 66x66 8-bit | 66x66 (even, not mult. of 8) | 5938 / `973eddf4aa6b0bf1` | **EXACT 4/4** | +| 4:4:4 98x66 8-bit | 98x66 | 6431 / `fc0e13060d1b7ca7` | **EXACT 4/4** | +| 4:4:4 130x122 8-bit | 130x122 | 9513 / `897791f360e3f3fb` | **EXACT 4/4** | +| 4:4:4 66x66 10-bit | 66x66 | 6006 / `995e6d45ca3e6983` | **EXACT 4/4** | +| 4:4:4 194x130 10-bit | 194x130 | 15751 / `cdb16f6a47306bbc` | **EXACT 4/4** | +| 4:4:4 130x122 10-bit | 130x122 | 10237 / `d34448dd0d44e4e9` | **EXACT 4/4** | +| 4:4:4 66x66 12-bit | 66x66 | 791 / `d266e4281c00eb4f` | **EXACT 4/4** | +| 4:4:4 130x122 12-bit | 130x122 | 1994 / `039d0a5aaabbe230` | **EXACT 4/4** | +| 4:4:4 **67x67 12-bit (odd)** | 67x67 | 844 / `da5d680389656d97` | **EXACT 4/4** | +| 4:4:4 **65x67 12-bit (odd)** | 65x67 | 791 / `471e4458babf7fa2` | **EXACT 4/4** | + +Recipe per arm: `testsrc2=WxH:rate=25` yuv444p[10le|12le] (12-bit: *smooth*), +4 frames, `--cq-level=20 --cpu-used=2 --enable-palette=0 --enable-intrabc=0`. + +**Correction to a published verdict.** The sweep records 4:4:4 `130x122` as +DIVERGENT from f3 (11521 samples, first f3 s2208 = Y(128,16)). This lane +re-encoded the sweep's own recipe (no `--enable-palette/intrabc`), reproduced its +stream byte-for-byte (8945 bytes, sha `c87ac65b77579afd`) and it is **byte-exact +4/4** against `aomdec` under a length-asserting compare. That published verdict +is the prefix compare the same report documents as its trap 1. + +### 2.4 The H3 control: 4:4:4 lossless 8-bit WITHOUT tiles + +| arm | parsed grid | bytes / sha256 | verdict | +|---|---|---|---| +| 256x128 untiled (the control the sweep never encoded) | 1x1 | 76468 / `c2cc3bd54d9127a4` | **EXACT 6/6** | +| 256x128 `--tile-columns=1` | 2x1 | 77905 / `1349984ef364c618` | **EXACT 6/6** | +| 256x128 untiled, screen tools left at their default | 1x1 | 74076 / `6c49502811b1a5d8` | **EXACT 6/6** | +| 256x128 `--tile-columns=1`, tools defaulted | 2x1 | 75446 / `65e94e91c56178d2` | **EXACT 6/6** | +| 256x256 untiled | 1x1 | 109215 / `4563a01f17786000` | DIVERGENT — §3 | +| 192x192 untiled | 1x1 | 82918 / `82c3b0a6db9dba2a` | **EXACT 6/6** | +| 192x192 1 tile row | 1x2 | 83105 / `359983962a2c06c3` | **EXACT 6/6** | + +**H3 does not reproduce.** On both flag variants at 256x128, the lossless 4:4:4 +tile-column stream decodes byte-exact 6/6 — no 90-chroma-sample fork, and the +untiled control is exact too. Whatever produced H3's numbers, this recipe is not +it, so H3's "tiles cause it" has no reproduction on this tree and the control +that was missing now exists as a gate. + +--- + +## 3. Divergences (measured, NOT fixed — each is a charter, not this lane's work) + +All of them are the same class: **4:4:4 LOSSLESS, key frame, chroma only, ±1, +luma exactly zero wrong**, at 256x256 or 128x256. Not one of them is +tile-specific. + +| cell | untiled control at the same geometry | tiled arm | first fork (decode order) | +|---|---|---|---| +| 4:4:4 lossless 8-bit 256x256 | DIVERGENT f0, 49 samples | 1 tile row: DIVERGENT f0, 33 samples / 2 tile cols: DIVERGENT f0, 14 samples | control `U(201,200)` ours 160 ref 159; 1x2 `U(199,201)` ours 165 ref 164; 2x1 `U(191,178)` ours 171 ref 172 | +| 4:4:4 lossless 10-bit 256x256 | DIVERGENT f0, 7695 samples, first `U(163,36)` ours 209 ref 129 | 1 tile row: DIVERGENT f0, 1374 samples, **first `U(163,36)` — the same sample** | 10-bit | +| 4:4:4 lossless 12-bit 256x256 | DIVERGENT f0, 17336 samples, first `U(154,32)` ours 84 ref 85 | 1 tile row: DIVERGENT f0, 25152 samples, **first `U(154,32)` — the same sample** | 12-bit | +| 4:4:4 lossless 10-bit 128x256 (sb64) | (not encoded) | 1 tile row: DIVERGENT f0, 74 samples, first `U(82,188)` ours 182 ref 165 | 10-bit, sb64 | + +**Attribution, stated as a measurement and not a theory.** At 10 and 12 bits the +tiled and untiled streams fork at the *same* first sample, so the tile row is +not the cause and the cell does not add a class; the fork belongs to the +4:4:4-lossless chroma defect the sweep already tracks as H3 / §6.1 and handed +to Agent24-2. **H4 ("4:4:4 lossless + 2 tile ROWS: hard divergence", "the whole +plane comes out flat from frame 3") is refuted on two counts:** its recipe was +256x128 with `--tile-rows=1`, which trap 2 shows is a no-op at that geometry +(so it was an untiled stream), and the genuine tile-row stream here diverges by +tens of samples in the key frame, not by 70-85% of the plane from frame 3. At +8 bits the tiled forks land at three nearby-but-different samples inside the +same bottom-right region, all ±1, all frame 0 — the same family, and a +discriminator run is owed before anyone claims one defect. + +The `256x128` control being exact while `256x256` diverges at all three depths +is the sharpest thing this lane measured about the class: it needs a frame that +is 256 rows tall **and** 256 wide, tiled or not. + +--- + +## 4. Gates added (all in `crates/ec-av1/src/stream.rs`) + +| gate | arms | what it pins | +|---|---|---| +| `a_real_aomenc_12bit_stream_with_two_tile_rows_and_a_two_by_two_tile_grid_decodes_pixel_exact` | 4:2:0 12-bit 1x2 rows; 4:2:0 12-bit 2x2 grid | the 12-bit multi-tile hole `gate_coverage.rs` left open | +| `a_real_aomenc_444_superres_stream_at_8_10_and_12_bit_decodes_pixel_exact` | 4:4:4 8/10/12-bit, `use_superres` on every frame | 4:4:4 superres at all three depths, the first with superres actually signalled | +| `a_real_aomenc_444_partial_and_odd_coded_dimension_streams_decode_pixel_exact` | 8 arms: 66x66, 98x66, 130x122 (8-bit), 66x66, 194x130, 130x122 (10-bit), 66x66, 130x122, **67x67, 65x67** (12-bit) | 4:4:4 partial-size at 8/10/12 and the first genuinely ODD 4:4:4 coded sizes | +| `a_lossless_444_8bit_untiled_control_and_its_two_tile_column_sibling_decode_pixel_exact` | 256x128 untiled + 256x128 2 tile columns | the H3 control the sweep never encoded, beside the tile-column sibling it was missing | + +Shared helper added: `frame_facts` (+ `FrameFacts`), which reads +`tile_cols/tile_rows/use_superres/coded_w/coded_h/upscaled_w/mi_cols/mi_rows` +off every frame header of a parsed stream. + +**Non-vacuity.** Each gate asserts, before any pixel: the sequence header's +`ss` and bit depth; the PARSED per-frame `tile_info` equal to the grid the arm +claims (or `use_superres` with `coded_w < upscaled_w` for the superres arms, or +the exact coded size and a partial mode-info grid for the size arms); a +per-path counter (`decode::tile_hits()` >= frames x tiles, +`superres::superres_hits()` >= frames, `decode::rect_split_lossless_chroma444_hits()` +strictly up); the decoded plane extents (256x256, the UPSCALED 128x128, or +exactly `w*h` at `ss (0,0)`), which a truncated or quarter-extent decode fails; +and then `decode_all_frames_vs_oracle`, which asserts equal frame counts and +equal per-frame byte lengths before comparing samples. + +**Red-before proofs (all reverted, all reproduced):** + +1. tile grid — drop `--tile-rows=1` from the 1x2 arm: RED, + `decode-order frame 0 parses tile_info 1x1, not 1x2 -- the aomenc tile flag + was a NO-OP at this geometry`. That is trap 2 caught by the gate. +2. superres — drop both denominators: RED, `decode-order frame 0 has + use_superres=0 -- the superres cell would be measuring an ordinary 4:4:4 + stream`. +3. coded size — expect `(w+1, h)` instead of `(w, h)` on the 66x66 arm: RED, + `left: (66, 66) right: (67, 66)`. +4. arm shape — the first run of the size gate, with an "odd in at least one + axis" assert written before the arm list was checked, went RED on its own + first arm (`the 66x66 arm is even in BOTH axes`). That is where the + "odd dims were not odd" correction came from. + +**`gate_coverage.rs`.** No entry is closed by these gates and none is deleted: +they spell no `--enable-=1` (the multi-tile and superres tools carry no +`NEVER_EXERCISED` entry — TILING is deliberately outside that derivation, and +superres is already positively covered through the `--superres-mode` alias by +the three existing superres gates), and they add no new `--enable-*` flag name, +so no new hole can open. `gate_coverage`'s three tests are green on this tree. +Entries 17/18/19 of the census were not touched. + +--- + +## 5. Dispositions (cells that cannot be produced, with the tooling path) + +1. **4:4:4 at 8/10 bits with a genuinely ODD coded dimension** — not producible + by recipe. The tooling path that refuses it is aomenc's own frame-size + rounding: `67x67` yuv444p encodes to a stream whose frame header says + `frame_width = 66`, and the bytes are identical to the 66x66 arm + (`973eddf4aa6b0bf1`); `131x131` -> 130x130. At 12 bits (seq_profile 2) the + rounding does not happen and 67x67/65x67 stay odd, which is why the odd arms + are 12-bit. Closing the 8/10-bit odd cell needs a hand-built frame header, + the same conclusion the sweep reached for 4:2:0 odd luma dimensions. +2. **12-bit 4:2:0 from a sharp source** — refused by name before any pixel: + `allow_screen_content_tools=1` trips the 12-bit screen-tools refusal even + with `--enable-palette=0 --enable-intrabc=0` (measured on the no-gblur + variants, 10830/11139/11147 bytes). Every 12-bit arm in this report + therefore carries the smoothed source. +3. **4:4:4 lossless 10-bit with tile rows at 128x256 on the default 64px SB** — + measured, DIVERGENT (§3), not refused: 74 samples, first `U(82,188)`. +4. **4:4:0 (`ss 0,1`)** — carried forward unmeasured from the sweep's §6.4: the + y4m muxer has no `yuv440p` and aomenc has no 4:4:0 input path. Not + re-derived here. +5. **The sweep's exact published byte counts** for the 12-bit 4:2:0 cells + (8713/8760 B) are not reproducible from its recipe text (§1). Disposition: + recorded, not chased; the structural question is answered without them. + +## 6. Handed on + +- **Agent24-2 / the 4:4:4 lossless chroma class** gains the sharpest discriminator + this lane produced: exact at 128x128, 192x192 and 256x128, divergent at + 256x256 at 8, 10 and 12 bits, untiled, key frame, chroma only, +-1 — and the + tile-row stream forks at the *same* first sample as the untiled control at 10 + and 12 bits. H4 (the tile-rows divergence) should be closed as refuted. +- **The shared `CARGO_TARGET_DIR`** is a measurement hazard for every lane that + measures or gates `ec-av1` while siblings build it (§0). Worth a house rule.