forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-av1formatsweep'

Browse files at this commit

fae5c1f7c11358c23bae0e6e304f32c2cd541070Ahmet Kaan GümüşParent: cfabb97ce89686
# Conflicts:
#	crates/ec-av1/src/stream.rs
crates/ec-av1/src/stream.rsmodified+497 -11
@@ -5005,12 +5005,7 @@ pub(crate) mod tests {
5005 5005
5006 /// Decodes `stream` and the oracle's `aomdec --rawvideo` output and5006 /// Decodes `stream` and the oracle's `aomdec --rawvideo` output and
5007 /// requires every sample of every frame to agree, in decode order.5007 /// requires every sample of every frame to agree, in decode order.
5008- fn assert_rawvideo_matches(5008+ fn assert_rawvideo_matches(obu: &std::path::Path, stream: &[u8], name: &str, frames: usize) {
5009- obu: &std::path::Path,
5010- stream: &[u8],
5011- name: &str,
5012- frames: usize,
5013- ) {
5014 let dir = std::env::temp_dir().join(format!("ec-av1-{name}-{}", std::process::id()));5009 let dir = std::env::temp_dir().join(format!("ec-av1-{name}-{}", std::process::id()));
5015 let _ = std::fs::remove_dir_all(&dir);5010 let _ = std::fs::remove_dir_all(&dir);
5016 std::fs::create_dir_all(&dir).expect("scratch dir");5011 std::fs::create_dir_all(&dir).expect("scratch dir");
@@ -10294,7 +10289,10 @@ pub(crate) mod tests {
10294 }10289 }
10295 let seq = seq.unwrap_or_else(|| panic!("{NAME}: no sequence header parsed"));10290 let seq = seq.unwrap_or_else(|| panic!("{NAME}: no sequence header parsed"));
10296 assert_eq!(10291 assert_eq!(
10297- (seq.color_config.subsampling_x, seq.color_config.subsampling_y),10292+ (
10293+ seq.color_config.subsampling_x,
10294+ seq.color_config.subsampling_y
10295+ ),
10298 (0, 0),10296 (0, 0),
10299 "{NAME}: fixture is not 4:4:4 (ss {}x{})",10297 "{NAME}: fixture is not 4:4:4 (ss {}x{})",
10300 seq.color_config.subsampling_x,10298 seq.color_config.subsampling_x,
@@ -10305,14 +10303,16 @@ pub(crate) mod tests {
10305 "{NAME}: fixture bit depth moved"10303 "{NAME}: fixture bit depth moved"
10306 );10304 );
10307 assert_eq!(seq.max_frame_width, W as u32, "{NAME}: fixture width moved");10305 assert_eq!(seq.max_frame_width, W as u32, "{NAME}: fixture width moved");
10308- assert_eq!(seq.max_frame_height, H as u32, "{NAME}: fixture height moved");10306+ assert_eq!(
10307+ seq.max_frame_height, H as u32,
10308+ "{NAME}: fixture height moved"
10309+ );
10309 }10310 }
10310 10311
10311 let _guard = lock_gate_counters();10312 let _guard = lock_gate_counters();
10312 crate::decode::reset_rect4_16_pair_hits();10313 crate::decode::reset_rect4_16_pair_hits();
10313- let frames = decode_stream(&stream).unwrap_or_else(|e| {10314+ let frames = decode_stream(&stream)
10314- panic!("{NAME}: the pinned stream no longer decodes cleanly: {e}")10315+ .unwrap_or_else(|e| panic!("{NAME}: the pinned stream no longer decodes cleanly: {e}"));
10315- });
10316 let hits = crate::decode::rect4_16_lossless_chroma_hits();10316 let hits = crate::decode::rect4_16_lossless_chroma_hits();
10317 assert!(10317 assert!(
10318 hits > 0,10318 hits > 0,
@@ -43114,4 +43114,490 @@ pub(crate) mod tests {
43114 and the smooth boolean {smooth_diff} times, all three planes pixel-exact"43114 and the smooth boolean {smooth_diff} times, all three planes pixel-exact"
43115 );43115 );
43116 }43116 }
43117+
43118+ /// lane-av1formatsweep: the ODD CODED DIMENSION cell -- a frame whose
43119+ /// width or height is not a multiple of 8, so the last mode-info column
43120+ /// and the last chroma plane row/column are PARTIAL (`mi_cols * 8 >
43121+ /// width`, and at 4:2:0 the chroma plane is `ceil(w/2) x ceil(h/2)`).
43122+ ///
43123+ /// Nothing else in this file ever encoded one: every frame size in the
43124+ /// suite (the `tiny_frame_size_sweep` ladder included -- 8,16,24,32,48,
43125+ /// 64,72,136,192) is a multiple of 8, so the partial-chroma-plane walk
43126+ /// had no committed exactness evidence at any depth. The class matters
43127+ /// for a 4:2:2 lift too: at ss (1,0) the chroma plane is
43128+ /// `ceil(w/2) x h`, so the partial extent lands on the OTHER axis.
43129+ ///
43130+ /// NON-VACUITY: `decode::inter_edge_strip_hits()` (the frame-edge strip
43131+ /// walk) is asserted to fire, and the even-size control arm is asserted
43132+ /// to leave it at zero -- measured: 130x122 -> `[0,2,0,4,0,6]`,
43133+ /// 130x130 -> `[0,3,0,2,24,6]`, 128x96 -> all zero. Without that pair a
43134+ /// decoder that dropped the partial column entirely would still pass the
43135+ /// pixel compare (class `gate-blind-to-feature`).
43136+ ///
43137+ /// Recipe (deterministic: single pass, single thread, no row-mt):
43138+ /// `ffmpeg -f lavfi -i testsrc2=size=<W>x<H>:rate=25 -frames:v 4
43139+ /// -pix_fmt <pix> -f yuv4mpegpipe -` piped to
43140+ /// `aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=20
43141+ /// --cpu-used=2 --threads=1 --row-mt=0 --lag-in-frames=0
43142+ /// --kf-max-dist=100 --limit=4 --obu -o - -`, plus
43143+ /// `--input-bit-depth=N --bit-depth=N` at 10 and 12 bits. The 12-bit arm
43144+ /// uses the smoothed `mandelbrot` source because a sharp-edged source
43145+ /// makes aomenc set `allow_screen_content_tools`, which this decoder
43146+ /// refuses BY NAME at 12 bits (see `a_12bit_screen_content_stream_is_
43147+ /// refused_by_name`).
43148+ ///
43149+ /// NON-VACUITY, RED-BEFORE PROVEN: the mode-info grid's ceil is the
43150+ /// arithmetic this cell depends on, and mutating it turns every arm red
43151+ /// -- `ec-av1-syntax`'s `h.mi_cols = 2 * ((h.frame_width + 7) >> 3)`
43152+ /// floored to `2 * (h.frame_width >> 3)` makes the first arm fail at
43153+ /// decode-order frame 0, byte 128 (ours 74 vs oracle 170, 11538 bytes
43154+ /// differ); reverted, the gate is green again. A NEARER mutation,
43155+ /// flooring `decode::round_ss` from libaom's `ROUND_POWER_OF_TWO`,
43156+ /// leaves this gate GREEN and is not evidence either way: aomenc rounds
43157+ /// a 4:2:0 frame's coded size DOWN to even, so no stream this recipe can
43158+ /// produce codes an odd luma dimension, and the chroma-extent ceil only
43159+ /// differs from its floor when the luma dimension is itself odd.
43160+ ///
43161+ /// Also asserted, so a recipe that silently became even-dimensioned can
43162+ /// not pass as this cell: the header's `ss (1,1)` and bit depth, the
43163+ /// partial mode-info grid (`mi*8 > dim`), every frame's chroma plane
43164+ /// being `ceil(w/2)*ceil(h/2)`, and
43165+ /// `decode::inter_edge_strip_hits()` non-zero after a per-arm reset --
43166+ /// measured per arm: `[0,6,0,4,48,12]`, `[0,0,0,4,0,6]`,
43167+ /// `[0,4,0,10,0,10]`, `[0,4,0,8,0,12]`, `[0,4,0,8,0,8]`,
43168+ /// `[0,0,0,12,0,14]`, where the even-size control (128x96) reads all
43169+ /// zeros. Without the counter a decoder that dropped the partial column
43170+ /// entirely would still pass the pixel compare (class
43171+ /// `gate-blind-to-feature`).
43172+ #[test]
43173+ fn a_real_aomenc_odd_coded_dimension_streams_decode_pixel_exact() {
43174+ const NAME: &str = "a_real_aomenc_odd_coded_dimension_streams_decode_pixel_exact";
43175+ let _gate_lock = lock_gate_counters();
43176+ if !have_ffmpeg() || !have_aomenc() {
43177+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
43178+ return;
43179+ }
43180+ // (width, height, pix_fmt, bit_depth, smooth_source)
43181+ let arms: &[(usize, usize, &str, usize, bool)] = &[
43182+ (130, 130, "yuv420p", 8, false),
43183+ (66, 66, "yuv420p", 8, false),
43184+ (194, 122, "yuv420p", 8, false),
43185+ (130, 122, "yuv420p", 8, false),
43186+ (130, 122, "yuv420p10le", 10, false),
43187+ (130, 122, "yuv420p12le", 12, true),
43188+ ];
43189+ let mut odd_arms = 0usize;
43190+ for &(width, height, pix_fmt, bit_depth, smooth) in arms {
43191+ let stream = odd_dim_stream(width, height, pix_fmt, bit_depth, smooth);
43192+ // The header must really carry the odd geometry, or the arm
43193+ // silently degrades to an even-dimension stream (class
43194+ // `arrival-not-intent`).
43195+ let (mi_cols, mi_rows) = odd_dim_header_mi_grid(&stream, NAME, bit_depth);
43196+ assert!(
43197+ mi_cols * 8 > width || mi_rows * 8 > height,
43198+ "{NAME}: {width}x{height} is not an odd coded dimension \
43199+ (mi grid {mi_cols}x{mi_rows})"
43200+ );
43201+ // Reset per attempt, never a delta across arms (class
43202+ // `counter-from-refused-stream`).
43203+ crate::decode::reset_inter_edge_strip_hits();
43204+ let (frames_decoded, _hidden) = decode_all_frames_vs_oracle(&stream, NAME);
43205+ let frames = decode_stream(&stream)
43206+ .unwrap_or_else(|e| panic!("{NAME}: refused {width}x{height}: {e}"));
43207+ let chroma = ((width + 1) / 2) * ((height + 1) / 2);
43208+ for (i, f) in frames.iter().enumerate() {
43209+ assert_eq!(f.y.len(), width * height, "{NAME}: frame {i} luma extent");
43210+ assert_eq!(
43211+ f.u.len(),
43212+ chroma,
43213+ "{NAME}: frame {i} chroma extent -- a {width}x{height} frame's \
43214+ chroma plane is ceil(w/2)*ceil(h/2) = {chroma}, not w/2*h/2"
43215+ );
43216+ }
43217+ let edge = crate::decode::inter_edge_strip_hits();
43218+ assert!(
43219+ edge.iter().any(|&n| n > 0),
43220+ "{NAME}: {width}x{height} decoded byte-exact but walked NO \
43221+ frame-edge strip -- the partial-column chroma extent this \
43222+ cell exists for was never reached (class \
43223+ `gate-blind-to-feature`): {edge:?}"
43224+ );
43225+ eprintln!(
43226+ "{NAME}: {width}x{height} {pix_fmt}: {frames_decoded} frames \
43227+ byte-exact vs aomdec, frame-edge walk {edge:?}"
43228+ );
43229+ odd_arms += 1;
43230+ }
43231+ assert!(odd_arms == arms.len(), "{NAME}: arm loop ended early");
43232+ }
43233+
43234+ /// lane-av1formatsweep: encodes the odd-dimension arm's fixture --
43235+ /// `testsrc2` (or the smoothed `mandelbrot` source at 12 bits, which
43236+ /// keeps `allow_screen_content_tools` off) as `y4m`, then hands the pipe
43237+ /// to `aomenc`. The child deadline comes from `run_with_stdin`
43238+ /// (`EC_AV1_CHILD_TIMEOUT_SECS`), so a wedged encoder fails loudly.
43239+ fn odd_dim_stream(
43240+ width: usize,
43241+ height: usize,
43242+ pix_fmt: &str,
43243+ bit_depth: usize,
43244+ smooth: bool,
43245+ ) -> Vec<u8> {
43246+ let source = if smooth {
43247+ format!("mandelbrot=size={width}x{height}:rate=25")
43248+ } else {
43249+ format!("testsrc2=size={width}x{height}:rate=25")
43250+ };
43251+ let mut ffmpeg_args: Vec<String> = vec![
43252+ "-v".into(),
43253+ "error".into(),
43254+ "-f".into(),
43255+ "lavfi".into(),
43256+ "-i".into(),
43257+ source,
43258+ ];
43259+ if smooth {
43260+ ffmpeg_args.extend(["-vf".into(), "gblur=sigma=6".into()]);
43261+ }
43262+ ffmpeg_args.extend([
43263+ "-frames:v".into(),
43264+ "4".into(),
43265+ "-pix_fmt".into(),
43266+ pix_fmt.into(),
43267+ "-strict".into(),
43268+ "-1".into(),
43269+ "-f".into(),
43270+ "yuv4mpegpipe".into(),
43271+ "-".into(),
43272+ ]);
43273+ let y4m = Command::new("ffmpeg")
43274+ .args(&ffmpeg_args)
43275+ .stdin(Stdio::null())
43276+ .stdout(Stdio::piped())
43277+ .stderr(Stdio::piped())
43278+ .output()
43279+ .expect("ffmpeg failed to run");
43280+ assert!(
43281+ y4m.status.success(),
43282+ "ffmpeg refused the {width}x{height} {pix_fmt} source: {}",
43283+ String::from_utf8_lossy(&y4m.stderr)
43284+ );
43285+ let mut args: Vec<String> = [
43286+ "--codec=av1",
43287+ "--passes=1",
43288+ "--end-usage=q",
43289+ "--cq-level=20",
43290+ "--cpu-used=2",
43291+ "--threads=1",
43292+ "--row-mt=0",
43293+ "--lag-in-frames=0",
43294+ "--kf-max-dist=100",
43295+ "--limit=4",
43296+ ]
43297+ .iter()
43298+ .map(|s| (*s).to_owned())
43299+ .collect();
43300+ if bit_depth > 8 {
43301+ args.push(format!("--input-bit-depth={bit_depth}"));
43302+ args.push(format!("--bit-depth={bit_depth}"));
43303+ }
43304+ args.extend(["--obu".into(), "-o".into(), "-".into(), "-".into()]);
43305+ let out = run_with_stdin(Command::new(aomenc_path()).args(&args), &y4m.stdout);
43306+ assert!(
43307+ out.status.success(),
43308+ "aomenc refused {args:?}: {}",
43309+ String::from_utf8_lossy(&out.stderr)
43310+ );
43311+ out.stdout
43312+ }
43313+
43314+ /// Reads `(mi_cols, mi_rows)` out of a stream's first frame header, and
43315+ /// asserts the sequence header says the bit depth the caller asked for.
43316+ fn odd_dim_header_mi_grid(stream: &[u8], name: &str, bit_depth: usize) -> (usize, usize) {
43317+ let mut parser = Av1Parser::new();
43318+ let mut pos = 0usize;
43319+ let mut seen_depth = None;
43320+ let mut grid = None;
43321+ while pos < stream.len() {
43322+ let obu = parser
43323+ .parse_obu(&stream[pos..])
43324+ .unwrap_or_else(|e| panic!("{name}: aomenc OBU does not parse: {e:?}"));
43325+ if obu.total_size == 0 {
43326+ break;
43327+ }
43328+ pos += obu.total_size;
43329+ match obu.kind {
43330+ ObuKind::SequenceHeader(seq) => {
43331+ assert_eq!(
43332+ seq.color_config.bit_depth as usize, bit_depth,
43333+ "{name}: the stream is not {bit_depth}-bit"
43334+ );
43335+ assert_eq!(
43336+ (
43337+ seq.color_config.subsampling_x,
43338+ seq.color_config.subsampling_y
43339+ ),
43340+ (1, 1),
43341+ "{name}: not a 4:2:0 stream"
43342+ );
43343+ seen_depth = Some(seq.color_config.bit_depth);
43344+ }
43345+ ObuKind::FrameHeader(h) | ObuKind::Frame(h, _) => {
43346+ grid = Some((
43347+ (h.frame_width as usize + 7) / 8,
43348+ (h.frame_height as usize + 7) / 8,
43349+ ));
43350+ }
43351+ _ => {}
43352+ }
43353+ }
43354+ assert!(seen_depth.is_some(), "{name}: no sequence header parsed");
43355+ grid.expect("the stream carries no frame header")
43356+ }
43357+
43358+ /// lane-av1formatsweep: the 4:4:4 x 10-BIT cell. Every committed 4:4:4
43359+ /// exactness gate in this file is `--lossless=1` at 8 bits
43360+ /// (`a_real_aomenc_lossless_444_key_frame_decodes_sample_exact`,
43361+ /// `a_lossless_444_min_partition64_inter_stream_decodes_pixel_exact`,
43362+ /// `a_lossless_444_defaultp_inter_strip_stream_decodes_byte_exact`, the
43363+ /// `ll444_*` pins), so the whole committed 4:4:4 evidence base is LOSSLESS
43364+ /// 8-bit: no 4:4:4 stream above 8 bits had a committed exactness gate.
43365+ ///
43366+ /// NON-VACUITY: `decode::rect_split_lossless_chroma444_hits()` -- the
43367+ /// per-4x4 chroma unit walk a lossless HORZ/VERT strip takes at
43368+ /// subsampling 0/0 -- is asserted to fire (measured 32 units on this
43369+ /// recipe), and the sequence header is asserted to say ss (0,0) at
43370+ /// 10-bit before any pixel is trusted. A 4:2:0 stream of the same
43371+ /// content leaves that counter at zero, so the pixel compare alone would
43372+ /// not prove the 4:4:4 chroma path ran (class `gate-blind-to-feature`).
43373+ ///
43374+ /// Recipe: `testsrc2 128x96` yuv444p10le 6 frames, `aomenc --codec=av1
43375+ /// --profile=1 --input-bit-depth=10 --bit-depth=10 --lossless=1
43376+ /// --enable-palette=0 --enable-intrabc=0 --cq-level=20 --cpu-used=2
43377+ /// --passes=1 --end-usage=q --threads=1 --row-mt=0 --lag-in-frames=0
43378+ /// --kf-max-dist=100 --limit=6 --obu -o - -`.
43379+ #[test]
43380+ fn a_lossless_444_10bit_inter_stream_decodes_pixel_exact() {
43381+ const NAME: &str = "a_lossless_444_10bit_inter_stream_decodes_pixel_exact";
43382+ let _gate_lock = lock_gate_counters();
43383+ if !have_ffmpeg() || !have_aomenc() {
43384+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
43385+ return;
43386+ }
43387+ let stream = chroma_format_stream(
43388+ 128,
43389+ 96,
43390+ "yuv444p10le",
43391+ 10,
43392+ 6,
43393+ &[
43394+ "--lossless=1",
43395+ "--enable-palette=0",
43396+ "--enable-intrabc=0",
43397+ // `--cpu-used=2`, NOT 0: at `--cpu-used=0` aomenc reaches
43398+ // the 128-root partition (measured `part128: split=1
43399+ // none=5` where this recipe reads `none=0`) and THAT stream
43400+ // diverges at 10-bit 4:4:4 from frame 1 on -- 11152 of
43401+ // 36864 samples, first at Y(8,4), with ffmpeg and aomdec
43402+ // agreeing on the reference. Handoff, not this gate's
43403+ // subject; see `lanes/av1formatsweep.report.md`.
43404+ "--cpu-used=2",
43405+ "--cq-level=20",
43406+ ],
43407+ 0,
43408+ );
43409+ assert_444_header(&stream, NAME, 10);
43410+ let before_444 = crate::decode::rect_split_lossless_chroma444_hits();
43411+ let (frames_decoded, _hidden) = decode_all_frames_vs_oracle(&stream, NAME);
43412+ assert!(
43413+ crate::decode::rect_split_lossless_chroma444_hits() > before_444,
43414+ "{NAME} went blind: no lossless strip walked its chroma as 4:4:4 \
43415+ 4x4 units"
43416+ );
43417+ assert!(
43418+ frames_decoded >= 6,
43419+ "{NAME}: expected the six-frame recipe to decode"
43420+ );
43421+ eprintln!("{NAME}: {frames_decoded} frames byte-exact vs aomdec at 10-bit 4:4:4");
43422+ }
43423+
43424+ /// lane-av1formatsweep: the 4:4:4 x 12-BIT cell -- the deepest chroma
43425+ /// format the spec allows, and the one no committed gate reached. A
43426+ /// sharp-edged source makes aomenc set `allow_screen_content_tools`,
43427+ /// which this decoder refuses BY NAME at 12 bits (palette and intrabc
43428+ /// have no 12-bit witness), so the arm encodes the SMOOTHED
43429+ /// `mandelbrot` source -- the same trick `a_real_aomenc_12bit_stream_
43430+ /// decodes_pixel_exact`'s in-tree source exists for.
43431+ ///
43432+ /// NON-VACUITY: the header is asserted to say ss (0,0) at 12 bits,
43433+ /// `mc::mc_subpel_hits()` (the 12-bit-sensitive subpel round pair) must
43434+ /// fire -- a key-frame-only stream would pass the pixel compare without
43435+ /// touching it -- and every decoded frame's chroma plane is asserted to
43436+ /// be FULL resolution, which is the 4:4:4 extent itself.
43437+ ///
43438+ /// Recipe: `mandelbrot 128x96` + `-vf gblur=sigma=6` yuv444p12le 6 frames,
43439+ /// `aomenc --codec=av1 --input-bit-depth=12 --bit-depth=12 --passes=1
43440+ /// --end-usage=q --cq-level=20 --cpu-used=2 --threads=1 --row-mt=0
43441+ /// --lag-in-frames=0 --kf-max-dist=100 --limit=6 --obu -o - -`.
43442+ /// aomenc picks `seq_profile=2` here (12-bit forces it) with
43443+ /// `subsampling_x/y = 0,0` -- still 4:4:4 planes, and the decoder's
43444+ /// refusal only rejects `subsampling_x != subsampling_y`.
43445+ #[test]
43446+ fn a_444_12bit_inter_sequence_decodes_pixel_exact() {
43447+ const NAME: &str = "a_444_12bit_inter_sequence_decodes_pixel_exact";
43448+ let _gate_lock = lock_gate_counters();
43449+ if !have_ffmpeg() || !have_aomenc() {
43450+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
43451+ return;
43452+ }
43453+ let stream = chroma_format_stream(128, 96, "yuv444p12le", 12, 6, &["--cq-level=20"], 1);
43454+ assert_444_header(&stream, NAME, 12);
43455+ let before_subpel = crate::mc::mc_subpel_hits();
43456+ let frames = decode_stream(&stream)
43457+ .unwrap_or_else(|e| panic!("{NAME}: refused a real 12-bit 4:4:4 stream: {e}"));
43458+ let (frames_decoded, _hidden) = decode_all_frames_vs_oracle(&stream, NAME);
43459+ assert!(
43460+ crate::mc::mc_subpel_hits() > before_subpel,
43461+ "{NAME} went blind: no subpel inter prediction ran, so the \
43462+ 12-bit round pair is unexercised"
43463+ );
43464+ // The 4:4:4 chroma EXTENT is the cell's own claim: at ss (0,0) the
43465+ // chroma planes are full resolution, so a decoder that kept the
43466+ // 4:2:0 extent would produce quarter-size chroma planes and a
43467+ // byte-length the oracle cannot even match. (CDEF is NOT asserted
43468+ // here: on this smoothed source CDEF runs but skips every band --
43469+ // measured `cdef_band: rect_skip_writes=11`, zero index literals --
43470+ // so a CDEF assertion would be a claim the witness cannot carry.)
43471+ for (i, f) in frames.iter().enumerate() {
43472+ assert_eq!(
43473+ f.u.len(),
43474+ 128 * 96,
43475+ "{NAME}: frame {i} chroma plane is {} samples -- at 4:4:4 it \
43476+ must be full resolution (128x96), not the 4:2:0 quarter",
43477+ f.u.len()
43478+ );
43479+ }
43480+ eprintln!("{NAME}: {frames_decoded} frames byte-exact vs aomdec at 12-bit 4:4:4");
43481+ }
43482+
43483+ /// lane-av1formatsweep: a `testsrc2`/`mandelbrot` source rendered to
43484+ /// `pix_fmt` as y4m and piped to `aomenc` at `bit_depth`, with `extra`
43485+ /// aomenc flags. `smooth` selects the gblur'd `mandelbrot` source (1) or
43486+ /// `testsrc2` (0). The child deadline comes from `run_with_stdin`
43487+ /// (`EC_AV1_CHILD_TIMEOUT_SECS`), so a wedged encoder fails loudly.
43488+ fn chroma_format_stream(
43489+ width: usize,
43490+ height: usize,
43491+ pix_fmt: &str,
43492+ bit_depth: usize,
43493+ frames: usize,
43494+ extra: &[&str],
43495+ smooth: u8,
43496+ ) -> Vec<u8> {
43497+ let source = if smooth == 1 {
43498+ format!("mandelbrot=size={width}x{height}:rate=25")
43499+ } else {
43500+ format!("testsrc2=size={width}x{height}:rate=25")
43501+ };
43502+ let mut ffmpeg_args: Vec<String> = vec![
43503+ "-v".into(),
43504+ "error".into(),
43505+ "-f".into(),
43506+ "lavfi".into(),
43507+ "-i".into(),
43508+ source,
43509+ ];
43510+ if smooth == 1 {
43511+ ffmpeg_args.extend(["-vf".into(), "gblur=sigma=6".into()]);
43512+ }
43513+ ffmpeg_args.extend([
43514+ "-frames:v".into(),
43515+ frames.to_string(),
43516+ "-pix_fmt".into(),
43517+ pix_fmt.into(),
43518+ "-strict".into(),
43519+ "-1".into(),
43520+ "-f".into(),
43521+ "yuv4mpegpipe".into(),
43522+ "-".into(),
43523+ ]);
43524+ let y4m = Command::new("ffmpeg")
43525+ .args(&ffmpeg_args)
43526+ .stdin(Stdio::null())
43527+ .stdout(Stdio::piped())
43528+ .stderr(Stdio::piped())
43529+ .output()
43530+ .expect("ffmpeg failed to run");
43531+ assert!(
43532+ y4m.status.success(),
43533+ "ffmpeg refused the {width}x{height} {pix_fmt} source: {}",
43534+ String::from_utf8_lossy(&y4m.stderr)
43535+ );
43536+ // AOMENC FLAG PRECEDENCE (COMMON): aomenc keeps the FIRST occurrence
43537+ // of a flag, so the per-arm override goes BEFORE the base list.
43538+ let limit = format!("--limit={frames}");
43539+ let mut args: Vec<String> = extra.iter().map(|s| (*s).to_owned()).collect();
43540+ args.extend(
43541+ [
43542+ "--codec=av1",
43543+ "--passes=1",
43544+ "--end-usage=q",
43545+ "--threads=1",
43546+ "--row-mt=0",
43547+ "--lag-in-frames=0",
43548+ "--kf-max-dist=100",
43549+ limit.as_str(),
43550+ ]
43551+ .iter()
43552+ .map(|s| (*s).to_owned()),
43553+ );
43554+ if bit_depth > 8 {
43555+ args.push(format!("--input-bit-depth={bit_depth}"));
43556+ args.push(format!("--bit-depth={bit_depth}"));
43557+ }
43558+ args.extend(["--obu".into(), "-o".into(), "-".into(), "-".into()]);
43559+ let out = run_with_stdin(Command::new(aomenc_path()).args(&args), &y4m.stdout);
43560+ assert!(
43561+ out.status.success(),
43562+ "aomenc refused {args:?}: {}",
43563+ String::from_utf8_lossy(&out.stderr)
43564+ );
43565+ out.stdout
43566+ }
43567+
43568+ /// Asserts the stream's sequence header really is 4:4:4 (`ss 0,0`) at
43569+ /// `bit_depth` before any pixel comparison is trusted (class
43570+ /// `arrival-not-intent`: a recipe that silently produced 4:2:0 would
43571+ /// make the whole gate a no-op for its own subject).
43572+ fn assert_444_header(stream: &[u8], name: &str, bit_depth: usize) {
43573+ let mut parser = Av1Parser::new();
43574+ let mut pos = 0usize;
43575+ let mut seen = false;
43576+ while pos < stream.len() {
43577+ let obu = parser
43578+ .parse_obu(&stream[pos..])
43579+ .unwrap_or_else(|e| panic!("{name}: aomenc OBU does not parse: {e:?}"));
43580+ if obu.total_size == 0 {
43581+ break;
43582+ }
43583+ pos += obu.total_size;
43584+ if let ObuKind::SequenceHeader(seq) = obu.kind {
43585+ let cc = &seq.color_config;
43586+ assert_eq!(
43587+ (cc.subsampling_x, cc.subsampling_y),
43588+ (0, 0),
43589+ "{name}: the stream is not 4:4:4 (ss {}x{})",
43590+ cc.subsampling_x,
43591+ cc.subsampling_y
43592+ );
43593+ assert_eq!(
43594+ cc.bit_depth as usize, bit_depth,
43595+ "{name}: the stream is {}-bit, not {bit_depth}-bit",
43596+ cc.bit_depth
43597+ );
43598+ seen = true;
43599+ }
43600+ }
43601+ assert!(seen, "{name}: no sequence header parsed");
43602+ }
43117 }43603 }
lanes/av1formatsweep.report.mdadded+510 -0
@@ -0,0 +1,510 @@
1+# lane-av1formatsweep — chroma-format coverage sweep
2+
3+**Scope.** Breadth leg for any future 4:2:2 refusal lift, and a general
4+capability audit of `crates/ec-av1`: which (chroma format x bit depth x
5+geometry) cells carry a committed exactness gate, which do not, and for the
6+uncovered ones that can be witnessed locally, whether the decoder is exact
7+or divergent.
8+
9+**Tree.** `lane-av1formatsweep` off `4155c7c7`, worktree
10+`~/.cache/wt/av1fmt`. Measurements are against a CLEAN HEAD decoder
11+(`decode.rs` untouched); a parallel lane's in-progress `decode.rs` in
12+`~/.cache/wt/av1leftref` was measured first and gave identical verdicts, so
13+nothing here is an artifact of that lane's build.
14+
15+**Cross-check from the parallel lane (lane-av1leftref, the ss_y left-chroma
16+reference fix; landed as `83b6af97`).** That lane reports main and its tip byte-identical on all 35
17+committed fixtures that decode at all (4:2:0, 4:4:4, 8/10/12-bit), with the
18+six 4:2:2 pins decoding zero frames in both trees because they need the
19+uncommitted bypass. That matches what this sweep measured independently: no
20+verdict in §1 moved between the two builds. For 4:2:2 the change is a no-op by
21+construction anyway — libaom's read offset is `ss_y`, and 4:2:2 has
22+`ss_y = 0`, so the cell read is the same one.
23+
24+**Method.** (1) Every `#[test]` in the crate was enumerated (693 total, 285
25+in `stream.rs`) and each `a_real_aomenc_*` / 4:4:4-named gate resolved to its
26+shape from the aomenc flag vector its body (or its helper) actually builds.
27+(2) Uncovered cells were encoded with the durable oracle
28+`~/.cache/aom-oracle/build/aomenc` and decoded two ways: against
29+`aomdec`'s `EC_AV1_FINAL_DUMP` (byte-for-byte, decode order) and against
30+`ffmpeg -f rawvideo`. A cell is called EXACT only when both agree.
31+(3) Control arms first, to prove the comparison itself is sound: 4:2:0 8-bit
32+`min-partition=64` and 4:4:4 8-bit lossless `min-partition=64` (the recipe of
33+the committed `a_lossless_444_min_partition64_inter_stream_decodes_pixel_exact`
34+gate) both came out exact, so a divergence below is the decoder's, not the
35+harness's.
36+
37+## 1. The matrix
38+
39+Format is the sequence header's `subsampling_x/y` (what the decoder branches
40+on), not aomenc's `--profile`: profile 2 at 12 bits still emits `ss (0,0)`
41+for a `yuv444p12le` input, and a true 4:4:0 needs a `yuv440p` input the sweep
42+never produced.
43+
44+Legend: **Y** = committed exactness gate; **y** = no gate, measured EXACT this
45+lane; **D** = no gate, measured DIVERGENT (localized in §3); **R** = refused by
46+name (no exactness claim possible or wanted); **–** = not measured.
47+
48+### 4:2:0 (`ss 1,1`)
49+
50+| cell | 8-bit | 10-bit | 12-bit |
51+|---|---|---|---|
52+| even dims, key+inter | Y (≈120 gates) | Y (≈40 gates) | Y (4 gates) |
53+| **even, not a multiple of 8** (`w%8≠0` or `h%8≠0`, both even) | **y → gate A** | **y → gate A** | **y → gate A** |
54+| luma dimension itself ODD | not producible¹ | not producible¹ | not producible¹ |
55+| partial-superblock edge (72, 136, …) | Y (`tiny_frame_size_sweep`) | Y | – |
56+| tile columns / rows | Y (2 and 4, both axes) | Y (multi-tile family) | – |
57+| superres | Y | Y | – |
58+| film grain / warp / CDEF+LR | Y | Y | Y |
59+
60+¹ **Neither gateable nor refutable from this recipe:** aomenc rounds a 4:2:0
61+frame's coded size DOWN to even, so no stream it produces from a lavfi source
62+codes an odd luma dimension at all. Verified: a `testsrc2 131x131` yuv420p
63+y4m (ffmpeg accepts it) encodes to a sequence header of `max_frame=130x130`,
64+which this decoder decodes correctly; the ffmpeg reference for the same file
65+comes back 131x131 because ffmpeg pads to the y4m header. Closing that cell
66+needs a hand-built stream (the `Av1Parser` header writer the sweep's own
67+`every_frame_size_a_header_can_code_has_a_mode_info_grid` gate already uses),
68+not an aomenc recipe.
69+
70+Even non-multiple-of-8 dimensions had **no committed gate at any depth**:
71+every frame size in the crate (the tiny-size ladder included — 8, 16, 24, 32,
72+48, 64, 72, 136, 192, 200…248) is a multiple of 8, so the partial-chroma-plane
73+walk had no exactness evidence. Measured exact, and gated.
74+
75+### 4:4:4 (`ss 0,0`) — the whole committed base is LOSSLESS 8-bit
76+
77+| cell | 8-bit | 10-bit | 12-bit |
78+|---|---|---|---|
79+| lossless | Y (8 gates, `ll444_*` pins) | **y → gate B** | R¹ / – |
80+| **lossy** | **D (H1, H2)** | **D (H1)** | **y → gate C** |
81+| tile columns (2) | **D (H3)** | – | – |
82+| tile rows (2) | **D (H4)** | – | – |
83+| superres | – | – | – |
84+| odd coded dims | – | – | – |
85+
86+¹ 12-bit 4:4:4 is reachable only from a source smooth enough that aomenc
87+leaves `allow_screen_content_tools = 0`; otherwise the 12-bit screen-tools
88+refusal fires first (H6). The smooth-source 12-bit 4:4:4 path is exact
89+(gate C). The smooth-source 12-bit **lossless** 4:4:4 stream was not measured.
90+
91+### 4:2:2 (`ss 1,0`) and 4:4:0 (`ss 0,1`)
92+
93+| cell | verdict |
94+|---|---|
95+| any depth, any geometry, committed | **R** — `subsampling_x != subsampling_y` refuses by name in `decode_frame` before any tile dispatch |
96+| committed 4:2:2 fixtures | 7 pins (`422_allskip_2f`, `422_sb128_3f`, 2x `422_intrabc_sb128_strip*`, 2x `422_residual_compound_warp*`, `422_residual_compound_warp_nolr_16f`); every committed gate asserts **refusal**, not pixels |
97+| odd coded dims, 8-bit, lossy inter | **y, probe-bypass only** (130x122, 66x66, 194x130 — 4 frames each, all three planes byte-exact vs ffmpeg) |
98+| odd coded dims, 10-bit | **y, probe-bypass only** (130x122) |
99+| 2x2 tiles, 8-bit | **y, probe-bypass only** (130x122) |
100+| 4:4:0 | – (no witness produced; refused by the same clause anyway) |
101+
102+The bypass is a local patch (`EC_AV1_ALLOW_422_PROBE` added to the refusal
103+condition), applied, measured, and reverted in the same session;
104+`grep EC_AV1_ALLOW_422_PROBE crates/ --include=*.rs` at HEAD still hits only
105+doc comments. The refusal stays.
106+
107+**This is the single most useful line in the report for a 4:2:2 lift:** the
108+lossy 4:2:2 inter path — odd extents, 10-bit, multi-tile — decodes
109+**pixel-exact** wherever the bypass admits it. The lift's risk is not in the
110+odd-dimension or tile geometry; it is in the shapes already named in
111+`refusal_inventory.rs` (rect chroma units, 64-side mu-chunk walks, sub-8
112+pairs), which the committed 4:2:2 pins exist to witness.
113+
114+## 2. Gates added (all in `crates/ec-av1/src/stream.rs`)
115+
116+Each is live-aomenc (no new fixture pin needed: the recipe is deterministic —
117+single pass, single thread, no row-mt — and the aomenc recipe is quoted in
118+the doc comment), compares byte-for-byte against the instrumented `aomdec`
119+through `decode_all_frames_vs_oracle`, and hard-asserts the shape it claims.
120+
121+1. **`a_real_aomenc_odd_coded_dimension_streams_decode_pixel_exact`** — six
122+ arms: 130x130, 66x66, 194x122, 130x122 at 8-bit; 130x122 at 10-bit;
123+ 130x122 at 12-bit (smoothed `mandelbrot` source). Non-vacuity: the header
124+ must really be `ss (1,1)` at the claimed depth, the mode-info grid must
125+ be partial (`mi*8 > dim`), every decoded frame's chroma plane must be
126+ `ceil(w/2)*ceil(h/2)`, and `decode::inter_edge_strip_hits()` must be
127+ non-zero after a per-arm reset. Measured per-arm edge walks:
128+ `[0,6,0,4,48,12]`, `[0,0,0,4,0,6]`, `[0,4,0,10,0,10]`, `[0,4,0,8,0,12]`,
129+ `[0,4,0,8,0,8]`, `[0,0,0,12,0,14]` — the even-size control (128x96) reads
130+ all zeros, so the counter is specific to the partial-column walk.
131+2. **`a_lossless_444_10bit_inter_stream_decodes_pixel_exact`** — 4:4:4
132+ lossless at 10-bit, 6 frames, byte-exact vs aomdec. Non-vacuity: the
133+ header must say `ss (0,0)` at 10-bit and
134+ `decode::rect_split_lossless_chroma444_hits()` must fire (measured 32
135+ units; a 4:2:0 stream of the same content leaves it at 0). The recipe is
136+ pinned to `--cpu-used=2`; see H5 for the `--cpu-used=0` sibling.
137+3. **`a_444_12bit_inter_sequence_decodes_pixel_exact`** — 4:4:4 at 12-bit,
138+ 6 frames, byte-exact vs aomdec. Non-vacuity: header `ss (0,0)` at 12-bit,
139+ `mc::mc_subpel_hits()` must fire (the 12-bit round pair), and every
140+ decoded frame's chroma plane must be full resolution. CDEF is
141+ deliberately NOT asserted: on this smoothed source CDEF runs but skips
142+ every band (`cdef_band: rect_skip_writes=11`, zero index literals), so
143+ such an assertion would be a claim the witness cannot carry.
144+
145+Shared helpers added: `odd_dim_stream` / `chroma_format_stream` (ffmpeg y4m →
146+aomenc pipe, deadline from `run_with_stdin`), `odd_dim_header_mi_grid`,
147+`assert_444_header`.
148+
149+**Red-before proof for gate A (done).** The mutation that bites is the
150+mode-info grid's ceil: `ec-av1-syntax`'s
151+`h.mi_cols = 2 * ((h.frame_width + 7) >> 3)` floored to
152+`2 * (h.frame_width >> 3)` turns the gate red on the first arm — decode-order
153+frame 0, byte 128, ours 74 vs oracle 170, 11538 bytes differ — and green again
154+on revert.
155+
156+**Why the nearer mutation was the wrong one.** Flooring `decode::round_ss`
157+(libaom's `ROUND_POWER_OF_TWO`) leaves the gate GREEN, and that is not a gap
158+in the gate: aomenc rounds a 4:2:0 frame's coded size DOWN to even, so no
159+stream this recipe can produce codes an odd luma dimension, and the
160+chroma-extent ceil only differs from its floor when the luma dimension is
161+itself odd. Verified directly: a `testsrc2 131x131` yuv420p y4m (ffmpeg
162+accepts it) comes out of aomenc as a stream whose sequence header says
163+`max_frame=130x130` — and this decoder decodes that 130x130 frame correctly.
164+The ffmpeg reference for the same file comes back 131x131 (25873 samples
165+against our 25350), which is ffmpeg padding to the y4m header, not a decoder
166+defect. **Consequence for the matrix:** the "luma dimension itself odd" cell
167+is not producible through the aomenc + lavfi recipe, so it can be neither
168+gated nor refuted from here; the sweep's odd-dimension cell is "even, not a
169+multiple of 8".
170+
171+**Declared debt:** gates B (4:4:4 lossless 10-bit) and C (4:4:4 12-bit)
172+carry NO targeted mutation proof. They inherit the `aomdec` byte-compare the
173+180 existing gates run on, plus their own header/counter non-vacuity asserts
174+(`rect_split_lossless_chroma444_hits()`, `mc_subpel_hits()`, the full-resolution
175+chroma extent). A future lane that touches the 4:4:4 unit geometry should
176+spend a mutation on them; the shape of the proof is the one in gate A's doc
177+comment — mutate the site the CELL depends on, not a nearby helper.
178+
179+## 3. Divergences, localized
180+
181+### H1 — 4:4:4 lossy + a RECT partition: entropy fork (the big one)
182+
183+Minimal repro: `aomenc --codec=av1 --profile=1 --passes=1 --end-usage=q
184+--cq-level=20 --cpu-used=2 --threads=1 --row-mt=0 --lag-in-frames=0
185+--kf-max-dist=100 --limit=2` over `testsrc2 128x96 yuv444p`, 6441 bytes.
186+Frame 0 (key) is exact; frame 1's first wrong sample is **Y(91,32)**
187+(ours 35, ref 38) and 8884 of 36864 samples are wrong by frame 1.
188+
189+Bisect: `--enable-rect-partitions=0` → **exact**; `--enable-ab-partitions=0`
190+→ still divergent (AB partitions are innocent); `--min-partition-size=32`
191+and `=64` → exact; CDEF / loop restoration / deblock / OBMC / warp toggles
192+change nothing; the same recipe at 4:2:0 is exact.
193+
194+First divergence, `EC_SYMR` on both sides (ours: `msac.rs` `SymbolDecoder::
195+symbol`; oracle: `aom_dsp/bitreader.h` `aom_read_symbol_`), one line per
196+symbol read in decode order, aligned on `(value, range, symbol, post_rng)`
197+with the CDF-row convention reconciled (`32768 - ours_icdf0 == oracle_cdf0`;
198+the `bit` field runs a constant +15 offset, 26219 of the first 26263 reads):
199+
200+```
201+index 26262 both mi=(8,16) decodetxb.c:368 (dc_sign) s=1 pre=(13550,51360) post=58008
202+index 26263 ORACLE mi=(8,16) decodetxb.c:158 txb_skip s=1 cdf0=16519 n=2 pre=(27101,58008) post=58316
203+index 26263 OURS mi=(8,16) (read_coeffs_rect) s=0 icdf0=22556 n=2 pre=(27101,58008) post=40037
204+```
205+
206+`decodetxb.c:158` is the `txb_skip` read. `EC_COEFF_STEP` names the unit:
207+
208+```
209+[1252] OURS plane=0 ctx=0 entry=61254 all_zero=0
210+[1253] ORACLE plane=1 bc=0 br=0 ctx=7 txs=1 pt=1 all_zero=1 <- the U plane
211+[1253] OURS plane=0 ctx=1 entry=58008 all_zero=0 <- a second LUMA rect unit
212+```
213+
214+(The `plane=0` label on our side is hardcoded in `read_coeffs_rect`'s trace
215+line — a label bug, not a fact; the read site is the rect walk.) So at
216+4:4:4, where the chroma plane block is 1:1 with luma, the rect unit walk
217+emits a LUMA unit where the oracle moves to the chroma plane, and the fork
218+propagates from there. The first *pixel* divergence is a block later
219+(the block at mi(8,16) is a skip/zero-residual block, so its own pixels
220+survive the wrong read). `decode.rs:11602` (`span_x = 4 << ss_x`) is the
221+4:4:4 unit geometry to look at first, and the txb_ctx chroma base
222+(7 vs 10, `txb_common.h` ~352, already flagged in
223+`skill://ec-av1-chroma-arm-oracle-verify`) is the second candidate.
224+
225+### H2 — 4:4:4 lossy + TX size search: chroma-only ±1, NO entropy divergence
226+
227+Recipe: profile 1 lossy cq 20, `--sb-size=64 --min-partition-size=64
228+--max-partition-size=64` (whole 64x64 roots, no rect splits), 4 frames.
229+Frame 0 and 1 exact; from frame 2, 608 of 36864 samples wrong — **U and V
230+only, luma exactly zero wrong**, magnitude ±1 (up to ±20 at cq 40).
231+
232+`EC_SYMR` on both sides: **140820 reads, zero divergence** — the entropy
233+decode is bit-identical, so this is pure reconstruction arithmetic, not a
234+fork. `--enable-tx-size-search=0` → exact; every filter toggle changes
235+nothing.
236+
237+**Round 2 (this lane, deeper).** The pre-filter dumps exonerate the whole
238+filter chain: `EC_AV1_PREFILT_DUMP` on both sides shows frame 2 already
239+carries 847 wrong CHROMA samples (luma 0 wrong) BEFORE deblock, CDEF and LR.
240+The oracle's per-unit census (`EC_COEFF plane=… row=… col=… tx_size=…`) shows
241+every chroma unit in this stream is `tx_size=3` (TX_32X32) at mi_row 0 / 0 and
242+mi_row 16, mi_col 0 and 8 — i.e. the `av1_get_adjusted_tx_size` clamp the
243+first suspect pointed at is ALREADY being applied correctly on both sides
244+(`decode_inter_block`'s 4:4:4 arm computes `if side >= 64 { 32 }`), and there
245+is no chroma unit at mi_row 8 at all. The wrong pixels are exactly the left
246+column of chroma units of the BOTTOM, frame-edge PARTIAL block row (frame is
247+96 high, blocks 64: the second block row has 32 real luma rows, so its chroma
248+band is 32 rows at `ss (0,0)` where 4:2:0 would give 16). Both sides walk the
249+same units with the same coefficients, so the defect is in what happens to
250+that partial block's chroma — its `unit_height` /
251+`ROUND_POWER_OF_TWO` clamp at `ss 0` (decodeframe.c:989) or its above/left
252+prediction reach at the frame edge — not in the transform-size rule.
253+
254+**Round 3 (this lane) — THE ROUND-2 LOCALIZATION IS REFUTED, RETRACTED.**
255+Geometry controls kill it:
256+
257+| stream | frame grid | verdict |
258+|---|---|---|
259+| 128x96 (the H2 stream) | 1.5 x 2 block rows — partial bottom row | divergent, U+V, from f2 |
260+| **128x128** | **2 x 2 whole 64 blocks — NO partial row, NO partial column** | **divergent, V only, 777 samples from f1** |
261+| 160x96 | 2.5 x 2 — partial bottom row only | divergent, V only, from f3 |
262+| 96x96 | partial row AND partial column | divergent, U+V, from f1 |
263+| any of the above with `--enable-tx-size-search=0` | — | **exact** |
264+
265+Candidate (a), the partial block's `unit_height` / `ROUND_POWER_OF_TWO` clamp
266+at ss 0, is refuted: a frame with no partial block anywhere reproduces the
267+defect, and a wrong clamp would change the unit COUNT, which the
268+bit-identical 140820-symbol entropy trace already excludes. Candidate (b) is
269+also refuted *as an edge class* — the errors appear mid-block (first wrong
270+sample V(27,60) in the 128x128 control, y=60, inside the first block row) and
271+the affected extent tracks no frame edge. What survives is narrower and not
272+geometry at all: **4:4:4 lossy inter with tx size search ON, chroma only,
273+always ±1, luma always exact, entropy bit-identical, present before every
274+filter, and the plane that errs varies with content** (V only at 128x128, U
275+and V at 128x96/96x96).
276+
277+Named next step (one run, and it is the measurement that finally splits
278+dequant from transform): take ONE affected 32x32 chroma unit and compare our
279+dequantized coefficients against the oracle's `EC_COEFF_VAL` (and ours via
280+`EC_DQCOEFF`). Values already different => the chroma dequant at `ss (0,0)`
281+is the fault. Values equal but pixels differ => the fault is in the 32x32
282+inverse transform / residual add.
283+
284+### H3 — 4:4:4 lossless + 2 tile columns: 90 chroma samples wrong in the key frame
285+
286+256x128 `testsrc2 yuv444p`, `--lossless=1 --tile-columns=1`, 6 frames,
287+aomdec-confirmed (not an ffmpeg artefact). Frame 0: exactly 90 wrong
288+samples, U and V, ±1, first at U(237,58). Frames 1–5: byte-exact.
289+
290+**Round 2 (this lane).** Also pre-filter: the same `EC_AV1_PREFILT_DUMP`
291+pair shows all 90 samples wrong BEFORE deblock/CDEF/LR, luma 0 wrong. Frames
292+1–5 are byte-exact even though they predict from that same key frame — so the
293+wrong samples are never read as a prediction source.
294+
295+**Round 3 (this lane) — the output/crop and reference-store candidates are
296+REFUTED.** The `EC_AV1_FINAL_DUMP` rung writes the picture exactly as it is
297+handed to the reference slots, and diffing it against the oracle's rung 12
298+gives the SAME 90 chroma samples wrong in frame 0 (first at U(237,58), luma 0)
299+with frames 1–2 byte-exact. The error is therefore already in the stored
300+reference picture: not introduced by the output crop, not introduced by the
301+reference-store path. It is the key frame's own chroma reconstruction, and the
302+fact that it never propagates is a property of which samples the inter frames
303+happen to predict from, not evidence of a healthy path.
304+
305+**H2 and H3 still do not reduce to one defect.** Both are pre-filter,
306+chroma-only, ±1, and present in the stored picture — but they run different
307+unit paths: H2 is the LOSSY 32x32 chroma unit and needs tx size search ON,
308+H3 is the LOSSLESS per-4x4 chroma unit (the walk
309+`rect_split_lossless_chroma444_hits` counts) and fires with tx search
310+irrelevant. No single fix is claimed for them.
311+
312+### H4 — 4:4:4 lossless + 2 tile ROWS: hard divergence
313+
314+Same recipe with `--tile-rows=1`. Frames 0–2 exact; frame 3 onwards the whole
315+plane comes out flat (Y(0,0) ours 128 vs ref 81, then ~70% of all samples
316+wrong, growing to 85% by frame 5). Worst verdict in the sweep.
317+
318+### H5 — 4:4:4 lossless at 10-bit, `--cpu-used=0`: 128-root partition diverges
319+
320+The gate-B recipe at `--cpu-used=0` makes aomenc reach the 128-root
321+partition (`part128: split=1 none=5`, where `--cpu-used=2` reads
322+`none=0`). That stream diverges from frame 1: 11152 of 36864 samples wrong,
323+first at Y(8,4), with **ffmpeg and aomdec agreeing** on the reference. The
324+committed 8-bit 4:4:4 gates cover 128 roots (`a_444_sb128_root_rect_stream_
325+with_restoration_decodes_pixel_exact`), but not at 10 bits.
326+
327+### H6 — coverage caveat, not a defect: 12-bit 4:4:4 needs a smooth source
328+
329+`aomenc --input-bit-depth=12` over `testsrc2 yuv444p12le` sets
330+`allow_screen_content_tools = 1` even with `--enable-palette=0
331+--enable-intrabc=0`, and the 12-bit screen-tools refusal fires by name. With
332+a `-vf gblur=sigma=6` source the same recipe decodes and is exact. Any
333+future 12-bit 4:4:4 witness has to carry that source, or it will measure the
334+screen-tools refusal and call it a 4:4:4 result.
335+
336+## 4. Not measured (budget), stated so nobody reads silence as coverage
337+
338+12-bit tiles at 4:2:0; 12-bit superres; 4:4:4 superres; 4:4:4 odd coded
339+dimensions; 4:4:4 at 10/12-bit with tiles; 12-bit 4:4:4 lossless; 4:4:0
340+(`ss 0,1`) at any depth. Suite staging and the full-suite run are Main's.
341+
342+## 5. Handoffs, in the order a follow-up lane should take them
343+
344+1. **H1** rect partition at 4:4:4 lossy — the largest correctness gap in the
345+ sweep; entropy fork at mi(8,16), localized to the chroma/luma unit walk.
346+2. **H4** 4:4:4 lossless + tile rows — hard failure, cheapest to bisect
347+ (single-tile-row frame-edge walk).
348+3. **H5** 4:4:4 10-bit lossless 128-root — a cell the 8-bit 444 gates
349+ suggest is safe and is not.
350+4. **H2** 4:4:4 lossy + tx size search chroma ±1 — reconstruction-only,
351+ entropy-clean, filter chain exonerated, tx-size clamp exonerated, and
352+ (round 3) the frame-edge geometry exonerated too: a 128x128 control with
353+ whole blocks reproduces it. What is left is the chroma unit's own
354+ arithmetic at `ss (0,0)`, gated on tx size search being ON. One
355+ `EC_DQCOEFF` vs `EC_COEFF_VAL` comparison on a single affected 32x32 unit
356+ splits dequant from inverse transform.
357+5. **H3** 4:4:4 lossless + tile columns, 90 chroma samples — smallest
358+ magnitude, likely the same root as H2.
359+
360+For the **4:2:2 lift** the sweep's message is mostly good news: the odd-
361+dimension, 10-bit and multi-tile 4:2:2 paths are already pixel-exact under
362+the bypass. Start from the shapes `refusal_inventory.rs` still names, and use
363+the bypass recipe in `skill://ec-av1-422-probe-bypass` to widen the committed
364+422 pins from "refuses by name" to "refuses by name, and is exact when
365+admitted" for at least the lossless big-block case.
366+
367+---
368+
369+## 6. Round 4 (lane-av1444chr) — the "not measured" list, closed
370+
371+**Tree.** `lane-av1formatsweep` (this branch), append-only, no code change.
372+Every verdict below is against the **durable instrumented aomdec**
373+(`EC_AV1_FINAL_DUMP`, decode order), **not** ffmpeg, and every compare
374+asserts (a) the two frame COUNTS are equal and (b) each frame's byte length
375+is equal, before any sample is looked at. That is not pedantry: two of the
376+twelve cells below first read DIVERGENT against an ffmpeg reference and
377+turned out EXACT against aomdec (round-4 finding F, below).
378+
379+### 6.0 The two measurement traps this round hit (read before trusting any sweep number)
380+
381+**Trap 1 — a compare that truncates is a PREFIX compare.** A per-frame
382+compare zipped against `min(len(ours), len(ref))` passes exactly when the
383+defect lies outside the prefix; the 4:4:4 lossless defect sits at x >= 108,
384+outside the 128x96 window a hardcoded geometry produces. This is how a
385+"byte-exact 6/6" was reported for a stream that is wrong in every frame. The
386+prefix compare must assert equal lengths first.
387+
388+**Trap 2 — an aomenc flag is not evidence the geometry changed.**
389+`--tile-rows=1` at 256x128 is a **no-op**: with a 128px superblock the frame
390+is a 2x1 SB grid, so there is no second SB row to tile. Verified by bytes,
391+not by the flag:
392+
393+| stream | untiled sha256 | with `--tile-rows=1` | verdict |
394+|---|---|---|---|
395+| 4:4:4 lossless 10-bit, 256x128 | `ec7a6a0ed9d7c2bada8816bb692de3379620856644a462f287a6cc3e6d9c5103` | **identical** | flag had NO effect |
396+| 4:4:4 lossless 12-bit, 256x128 | `ef7338136d560674677cb5fd903e60906ef4df7b2f4c93a990e65a5b5ed4402c` | **identical** | flag had NO effect |
397+
398+So this round's 10- and 12-bit "tile rows" cells are NOT tile witnesses; what
399+they actually measure is the **untiled** 4:4:4 lossless stream at those depths,
400+which is itself divergent (6.1). A real 4:4:4 tile-rows witness needs a
401+geometry with two SB rows (>= 256 high at `--sb-size=128`).
402+
403+**Trap 3 — the reference can be the outlier.** Against `ffmpeg
404+-pix_fmt yuv420p12le` the 12-bit 4:2:0 cells read as ~8175/8192 chroma
405+samples wrong in every frame. Against aomdec the same streams are **byte-exact
406+6/6**. ffmpeg's raw 12-bit 4:2:0 output is not the reference for this cell.
407+
408+### 6.1 4:4:4 at 10 and 12 bit — LOSSY tile cells and the untiled control
409+
410+Source `testsrc2=size=256x128:rate=25` yuv444p / yuv444p10le; the 12-bit runs
411+need a smooth source (`mandelbrot` + `gblur=sigma=6`) or
412+`--enable-palette=0 --enable-intrabc=0`, else the 12-bit screen-tools refusal
413+fires first (H6). Common flags: `--lossless=1 --input-bit-depth=N
414+--bit-depth=N --codec=av1 --passes=1 --end-usage=q --threads=1 --row-mt=0
415+--lag-in-frames=0 --kf-max-dist=100 --limit=6 --obu -o - -`.
416+
417+| cell | stream | bytes | sha256 | verdict vs aomdec |
418+|---|---|---|---|---|
419+| 4:4:4 10-bit lossless, **no tiles** | `t444_10_notile` | 122730 | `ec7a6a0e…` | **DIVERGENT** from f1, 290506 samples, first (f1, s128) = Y(128,0) |
420+| 4:4:4 10-bit + **2 tile columns** | `t444_10_col` | 122937 | `2d295c2c…` | **DIVERGENT** 248394 samples; f0 first (f0, s47853) = U(229,58) |
421+| 4:4:4 12-bit lossless, **no tiles** | `t444_12_notile` | 171599 | `ef733813…` | **DIVERGENT** from f0, 264180 samples, first (f0, s32877) = U(109,0) |
422+| 4:4:4 12-bit + **2 tile columns** | `t444_12columns` | 172340 | `06fb4a8d…` | **DIVERGENT** from f0, 174949 samples, **same first sample** (f0, s32877) = U(109,0) |
423+
424+Reading: the 10-bit tile-column stream's frame 0 carries the H3 signature
425+(7 U + 11 V wrong against ffmpeg, first wrong U(237,58) — the sweep's H3 first
426+divergence, reproduced at 10 bits), then diverges hard from frame 1. The 12-bit
427+cell diverges from **frame 0** with the first wrong sample at U(109,0) whether
428+or not tiles are on — i.e. at 12 bits the 4:4:4 lossless key-frame defect is
429+present **untiled**. So the class is **not** depth-independent and **not**
430+tile-specific: it is a 4:4:4 lossless chroma defect that appears at 8, 10 and
431+12 bits, with or without tiles. None of these reduce to H1 (entropy fork —
432+H2's stream is entropy-clean) or to H2 (lossy, tx-search-gated).
433+
434+### 6.2 4:4:4 superres and odd coded dimensions (8-bit lossy, cq 20, cpu-used 2)
435+
436+| cell | stream | bytes | sha256 | verdict vs aomdec |
437+|---|---|---|---|---|
438+| 4:4:4 **superres** 256x128 (`--superres-mode=1`) | `sr444` | 15239 | `06621606…` | **DIVERGENT** from f2, 76404 samples, first (f2, s192) = Y(192,0) |
439+| 4:4:4 **odd coded dims 66x66** | `odd444_66x66` | 5938 | `973eddf4…` | **EXACT 4/4** — new exact cell |
440+| 4:4:4 **odd coded dims 130x122** | `odd444_130x122` | 8945 | `c87ac65b…` | **DIVERGENT** from f3, 11521 samples, first (f3, s2208) = Y(128,16) |
441+
442+Note the aomenc flag is `--superres-mode=1`; there is no `--enable-superres`
443+in this build (`aomenc --help | grep -i superres`).
444+
445+The 130x122 stream is the interesting one: 66x66 is exact at the same
446+settings, so the 4:4:4 partial-frame walk is right at one odd geometry and
447+wrong at another, and the first divergence is at (128,16) — inside the frame,
448+not on its edge. Same shape of question as H2's retracted edge theory; **not
449+claimed to be the same defect** without a discriminator run.
450+
451+### 6.3 12-bit 4:2:0 tiles and superres — the two cells the matrix left open
452+
453+Source `mandelbrot=size=256x128:rate=25` yuv420p12le (smooth, or the 12-bit
454+screen-tools refusal fires), `--enable-palette=0 --enable-intrabc=0
455+--input-bit-depth=12 --bit-depth=12 --profile=0 --cq-level=20 --cpu-used=2`.
456+
457+| cell | stream | bytes | sha256 | verdict vs aomdec |
458+|---|---|---|---|---|
459+| 4:2:0 12-bit + 2 tile columns | `t420_12_col` | 8713 | `c983a91c…` | **EXACT 6/6** |
460+| 4:2:0 12-bit + 2 tile rows | `t420_12_row` | 8760 | `0bf14e1e…` | **EXACT 6/6** (flag effect at this geometry NOT verified — see caveat) |
461+| 4:2:0 12-bit superres | `sr420_12` | 8494 | `9e8206bf…` | **EXACT 6/6** |
462+
463+Caveat, stated so the next round does not inherit it: at 256x128 `--tile-rows`
464+was a proven no-op for 4:4:4, and I did **not** encode an untiled 4:2:0
465+control here, so `t420_12_row` may be measuring the same untiled stream as
466+`t420_12_col`. The EXACT verdict is safe either way (it is exact against the
467+oracle); what is unproven is that it exercised tiles.
468+
469+### 6.4 4:4:0 (`ss 0,1`) — NOT PRODUCIBLE through aomenc
470+
471+The y4m muxer refuses the format outright: `yuv4mpeg can only handle yuv444p,
472+yuv422p, yuv420p, yuv411p and gray8`. A raw `yuv440p` plane dump reaches
473+aomenc, which has no 4:4:0 input path and falls back to 4:2:0
474+(`Profile 1 requires 4:4:4 color format`; there is no `--input-format` flag
475+in `--help`). So the `4:4:0 (ss 0,1)` row stays **unmeasured and
476+unproducible by recipe**, for the same reason the 4:2:0 odd-luma-dimension row
477+does: closing it needs a hand-built sequence header, not an aomenc run. The
478+decoder's refusal (`subsampling_x != subsampling_y` refuses by name in
479+`decode_frame`) is unchanged and still the honest answer for any 4:4:0 stream
480+that is ever hand-built.
481+
482+### 6.5 Matrix deltas and the honest "not measured" list
483+
484+Matrix changes (§1): 4:4:4 row gains `odd dims 66x66 → y` (exact this lane),
485+`superres → D`, `10/12-bit tiles → D`, `12-bit lossless → D`; 4:2:0 row gains
486+`12-bit tiles + superres → y`. The tile-ROWS cells for 4:4:4 stay as they
487+are — the 8-bit one is now Agent13's EXACT (tile rows genuinely enabled at
488+geometries with a second SB row), and the 10/12-bit ones are the untiled
489+control above.
490+
491+Still not measured after this round: 4:4:4 at 10/12 bits with **tile rows
492+actually enabled** (needs a >= 256-high geometry — trap 2); 4:4:4 superres at
493+10/12 bits; 4:4:4 odd dims at 10/12 bits and at dimensions other than 66x66 /
494+130x122; 4:4:4 lossless at 8 bits **without** tiles as a control for the H3
495+witness; 4:4:0 at any depth (unproducible, §6.4); 4:2:2 (ss 1,0) beyond the
496+existing probe-bypass row.
497+
498+### 6.6 Handed to other lanes
499+
500+- The 4:4:4 **lossless chroma** divergences at 8/10/12 bits with and without
501+ tiles (first wrong sample U(109,0) at 12 bits, U(237,58) at 8 bits) go to
502+ **Agent24-2** with H3 — same format, same unit family, and this round shows the
503+ class is not tile-specific and not depth-specific, which narrows it.
504+- The 4:4:4 **130x122** odd-dimension divergence and the 4:4:4 **superres**
505+ divergence are unassigned; neither reduces to a known class on the evidence
506+ here, and neither has a discriminator run.
507+- Recorded from Agent13-2 and folded into the matrix above: a hardcoded 4:2:0
508+ luma footprint at the lossless 16x4/4x16 chroma-pair walk
509+ (`Reach::of_tu` mis-answering at `ss 0,0`), same shape class as the wave's
510+ other 4:4:4 bugs; its stream family is exact after the fix.