forge
Explore
Log in

Don't you dare go Hollow

Gate the three chroma-format cells the suite never covered

Browse files at this commit

dfb19132064460ec1f275c70643fb153def15424Ahmet Kaan GümüşParent: e772a72
  • test
    • gate the three chroma-format cells the suite never covered
Show full message
test(av1formatsweep): gate the three chroma-format cells the suite never covered

The sweep in lanes/av1formatsweep.report.md enumerates every committed
exactness gate in crates/ec-av1 by (chroma format x bit depth x geometry) and
finds three cells with no evidence at all, all of which decode exactly:

- 4:2:0 ODD CODED DIMENSIONS (w%8 or h%8 not 0), at 8, 10 and 12 bits. Every
  frame size in the crate was a multiple of 8, so the partial-chroma-plane
  walk had no exactness evidence at any depth. Six aomenc arms, compared
  byte-for-byte against the instrumented aomdec; non-vacuity comes from
  decode::inter_edge_strip_hits() firing per arm (the even 128x96 control
  reads all zeros) plus the ceil(w/2)*ceil(h/2) chroma extent assertion.
- 4:4:4 LOSSLESS at 10 bits. The entire committed 4:4:4 evidence base is
  lossless 8-bit; nothing above 8 bits was gated. Non-vacuity is
  decode::rect_split_lossless_chroma444_hits() (32 units here, 0 on a 4:2:0
  stream of the same content) plus an ss (0,0) @ 10-bit header assert.
- 4:4:4 at 12 bits, the deepest chroma format the spec allows. Reachable
  only from a source smooth enough to leave allow_screen_content_tools off,
  since the 12-bit screen-tools refusal fires first (H6 in the report);
  non-vacuity is mc::mc_subpel_hits() plus the full-resolution chroma extent.

The same sweep localizes five divergences it did NOT fix, the largest being a
rect partition at 4:4:4 lossy: EC_SYMR puts the first divergent symbol at
mi=(8,16), read 26263, where the oracle reads the U plane's txb_skip
(decodetxb.c:158, symbol 1) and this decoder reads a second LUMA unit through
read_coeffs_rect. --enable-rect-partitions=0 makes it exact;
--enable-ab-partitions=0 does not.
crates/ec-av1/src/stream.rsmodified+462 -1
@@ -2671,7 +2671,6 @@ pub(crate) mod tests {
2671 );2671 );
2672 }2672 }
2673 2673
2674-
2675 /// lane-av1-qmatrix: WITNESS for the lifted `using_qmatrix` refusal (the2674 /// lane-av1-qmatrix: WITNESS for the lifted `using_qmatrix` refusal (the
2676 /// old gate `a_frame_using_quantisation_matrices_is_refused_by_name` is2675 /// old gate `a_frame_using_quantisation_matrices_is_refused_by_name` is
2677 /// its mirror image -- its own panic said "flip this gate to a witness"2676 /// its mirror image -- its own panic said "flip this gate to a witness"
@@ -42036,4 +42035,466 @@ pub(crate) mod tests {
42036 crate::decode::segment_ids_seen()42035 crate::decode::segment_ids_seen()
42037 );42036 );
42038 }42037 }
42038+
42039+ /// lane-av1formatsweep: the ODD CODED DIMENSION cell -- a frame whose
42040+ /// width or height is not a multiple of 8, so the last mode-info column
42041+ /// and the last chroma plane row/column are PARTIAL (`mi_cols * 8 >
42042+ /// width`, and at 4:2:0 the chroma plane is `ceil(w/2) x ceil(h/2)`).
42043+ ///
42044+ /// Nothing else in this file ever encoded one: every frame size in the
42045+ /// suite (the `tiny_frame_size_sweep` ladder included -- 8,16,24,32,48,
42046+ /// 64,72,136,192) is a multiple of 8, so the partial-chroma-plane walk
42047+ /// had no committed exactness evidence at any depth. The class matters
42048+ /// for a 4:2:2 lift too: at ss (1,0) the chroma plane is
42049+ /// `ceil(w/2) x h`, so the partial extent lands on the OTHER axis.
42050+ ///
42051+ /// NON-VACUITY: `decode::inter_edge_strip_hits()` (the frame-edge strip
42052+ /// walk) is asserted to fire, and the even-size control arm is asserted
42053+ /// to leave it at zero -- measured: 130x122 -> `[0,2,0,4,0,6]`,
42054+ /// 130x130 -> `[0,3,0,2,24,6]`, 128x96 -> all zero. Without that pair a
42055+ /// decoder that dropped the partial column entirely would still pass the
42056+ /// pixel compare (class `gate-blind-to-feature`).
42057+ ///
42058+ /// Recipe (deterministic: single pass, single thread, no row-mt):
42059+ /// `ffmpeg -f lavfi -i testsrc2=size=<W>x<H>:rate=25 -frames:v 4
42060+ /// -pix_fmt <pix> -f yuv4mpegpipe -` piped to
42061+ /// `aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=20
42062+ /// --cpu-used=2 --threads=1 --row-mt=0 --lag-in-frames=0
42063+ /// --kf-max-dist=100 --limit=4 --obu -o - -`, plus
42064+ /// `--input-bit-depth=N --bit-depth=N` at 10 and 12 bits. The 12-bit arm
42065+ /// uses the smoothed `mandelbrot` source because a sharp-edged source
42066+ /// makes aomenc set `allow_screen_content_tools`, which this decoder
42067+ /// refuses BY NAME at 12 bits (see `a_12bit_screen_content_stream_is_
42068+ /// refused_by_name`).
42069+ #[test]
42070+ fn a_real_aomenc_odd_coded_dimension_streams_decode_pixel_exact() {
42071+ const NAME: &str = "a_real_aomenc_odd_coded_dimension_streams_decode_pixel_exact";
42072+ let _gate_lock = lock_gate_counters();
42073+ if !have_ffmpeg() || !have_aomenc() {
42074+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
42075+ return;
42076+ }
42077+ // (width, height, pix_fmt, bit_depth, smooth_source)
42078+ let arms: &[(usize, usize, &str, usize, bool)] = &[
42079+ (130, 130, "yuv420p", 8, false),
42080+ (66, 66, "yuv420p", 8, false),
42081+ (194, 122, "yuv420p", 8, false),
42082+ (130, 122, "yuv420p", 8, false),
42083+ (130, 122, "yuv420p10le", 10, false),
42084+ (130, 122, "yuv420p12le", 12, true),
42085+ ];
42086+ let mut odd_arms = 0usize;
42087+ for &(width, height, pix_fmt, bit_depth, smooth) in arms {
42088+ let stream = odd_dim_stream(width, height, pix_fmt, bit_depth, smooth);
42089+ // The header must really carry the odd geometry, or the arm
42090+ // silently degrades to an even-dimension stream (class
42091+ // `arrival-not-intent`).
42092+ let (mi_cols, mi_rows) = odd_dim_header_mi_grid(&stream, NAME, bit_depth);
42093+ assert!(
42094+ mi_cols * 8 > width || mi_rows * 8 > height,
42095+ "{NAME}: {width}x{height} is not an odd coded dimension \
42096+ (mi grid {mi_cols}x{mi_rows})"
42097+ );
42098+ // Reset per attempt, never a delta across arms (class
42099+ // `counter-from-refused-stream`).
42100+ crate::decode::reset_inter_edge_strip_hits();
42101+ let (frames_decoded, _hidden) = decode_all_frames_vs_oracle(&stream, NAME);
42102+ let frames = decode_stream(&stream)
42103+ .unwrap_or_else(|e| panic!("{NAME}: refused {width}x{height}: {e}"));
42104+ let chroma = ((width + 1) / 2) * ((height + 1) / 2);
42105+ for (i, f) in frames.iter().enumerate() {
42106+ assert_eq!(f.y.len(), width * height, "{NAME}: frame {i} luma extent");
42107+ assert_eq!(
42108+ f.u.len(),
42109+ chroma,
42110+ "{NAME}: frame {i} chroma extent -- a {width}x{height} frame's \
42111+ chroma plane is ceil(w/2)*ceil(h/2) = {chroma}, not w/2*h/2"
42112+ );
42113+ }
42114+ let edge = crate::decode::inter_edge_strip_hits();
42115+ assert!(
42116+ edge.iter().any(|&n| n > 0),
42117+ "{NAME}: {width}x{height} decoded byte-exact but walked NO \
42118+ frame-edge strip -- the partial-column chroma extent this \
42119+ cell exists for was never reached (class \
42120+ `gate-blind-to-feature`): {edge:?}"
42121+ );
42122+ eprintln!(
42123+ "{NAME}: {width}x{height} {pix_fmt}: {frames_decoded} frames \
42124+ byte-exact vs aomdec, frame-edge walk {edge:?}"
42125+ );
42126+ odd_arms += 1;
42127+ }
42128+ assert!(odd_arms == arms.len(), "{NAME}: arm loop ended early");
42129+ }
42130+
42131+ /// lane-av1formatsweep: encodes the odd-dimension arm's fixture --
42132+ /// `testsrc2` (or the smoothed `mandelbrot` source at 12 bits, which
42133+ /// keeps `allow_screen_content_tools` off) as `y4m`, then hands the pipe
42134+ /// to `aomenc`. The child deadline comes from `run_with_stdin`
42135+ /// (`EC_AV1_CHILD_TIMEOUT_SECS`), so a wedged encoder fails loudly.
42136+ fn odd_dim_stream(
42137+ width: usize,
42138+ height: usize,
42139+ pix_fmt: &str,
42140+ bit_depth: usize,
42141+ smooth: bool,
42142+ ) -> Vec<u8> {
42143+ let source = if smooth {
42144+ format!("mandelbrot=size={width}x{height}:rate=25")
42145+ } else {
42146+ format!("testsrc2=size={width}x{height}:rate=25")
42147+ };
42148+ let mut ffmpeg_args: Vec<String> = vec![
42149+ "-v".into(),
42150+ "error".into(),
42151+ "-f".into(),
42152+ "lavfi".into(),
42153+ "-i".into(),
42154+ source,
42155+ ];
42156+ if smooth {
42157+ ffmpeg_args.extend(["-vf".into(), "gblur=sigma=6".into()]);
42158+ }
42159+ ffmpeg_args.extend([
42160+ "-frames:v".into(),
42161+ "4".into(),
42162+ "-pix_fmt".into(),
42163+ pix_fmt.into(),
42164+ "-strict".into(),
42165+ "-1".into(),
42166+ "-f".into(),
42167+ "yuv4mpegpipe".into(),
42168+ "-".into(),
42169+ ]);
42170+ let y4m = Command::new("ffmpeg")
42171+ .args(&ffmpeg_args)
42172+ .stdin(Stdio::null())
42173+ .stdout(Stdio::piped())
42174+ .stderr(Stdio::piped())
42175+ .output()
42176+ .expect("ffmpeg failed to run");
42177+ assert!(
42178+ y4m.status.success(),
42179+ "ffmpeg refused the {width}x{height} {pix_fmt} source: {}",
42180+ String::from_utf8_lossy(&y4m.stderr)
42181+ );
42182+ let mut args: Vec<String> = [
42183+ "--codec=av1",
42184+ "--passes=1",
42185+ "--end-usage=q",
42186+ "--cq-level=20",
42187+ "--cpu-used=2",
42188+ "--threads=1",
42189+ "--row-mt=0",
42190+ "--lag-in-frames=0",
42191+ "--kf-max-dist=100",
42192+ "--limit=4",
42193+ ]
42194+ .iter()
42195+ .map(|s| (*s).to_owned())
42196+ .collect();
42197+ if bit_depth > 8 {
42198+ args.push(format!("--input-bit-depth={bit_depth}"));
42199+ args.push(format!("--bit-depth={bit_depth}"));
42200+ }
42201+ args.extend(["--obu".into(), "-o".into(), "-".into(), "-".into()]);
42202+ let out = run_with_stdin(Command::new(aomenc_path()).args(&args), &y4m.stdout);
42203+ assert!(
42204+ out.status.success(),
42205+ "aomenc refused {args:?}: {}",
42206+ String::from_utf8_lossy(&out.stderr)
42207+ );
42208+ out.stdout
42209+ }
42210+
42211+ /// Reads `(mi_cols, mi_rows)` out of a stream's first frame header, and
42212+ /// asserts the sequence header says the bit depth the caller asked for.
42213+ fn odd_dim_header_mi_grid(stream: &[u8], name: &str, bit_depth: usize) -> (usize, usize) {
42214+ let mut parser = Av1Parser::new();
42215+ let mut pos = 0usize;
42216+ let mut seen_depth = None;
42217+ let mut grid = None;
42218+ while pos < stream.len() {
42219+ let obu = parser
42220+ .parse_obu(&stream[pos..])
42221+ .unwrap_or_else(|e| panic!("{name}: aomenc OBU does not parse: {e:?}"));
42222+ if obu.total_size == 0 {
42223+ break;
42224+ }
42225+ pos += obu.total_size;
42226+ match obu.kind {
42227+ ObuKind::SequenceHeader(seq) => {
42228+ assert_eq!(
42229+ seq.color_config.bit_depth as usize, bit_depth,
42230+ "{name}: the stream is not {bit_depth}-bit"
42231+ );
42232+ assert_eq!(
42233+ (
42234+ seq.color_config.subsampling_x,
42235+ seq.color_config.subsampling_y
42236+ ),
42237+ (1, 1),
42238+ "{name}: not a 4:2:0 stream"
42239+ );
42240+ seen_depth = Some(seq.color_config.bit_depth);
42241+ }
42242+ ObuKind::FrameHeader(h) | ObuKind::Frame(h, _) => {
42243+ grid = Some((
42244+ (h.frame_width as usize + 7) / 8,
42245+ (h.frame_height as usize + 7) / 8,
42246+ ));
42247+ }
42248+ _ => {}
42249+ }
42250+ }
42251+ assert!(seen_depth.is_some(), "{name}: no sequence header parsed");
42252+ grid.expect("the stream carries no frame header")
42253+ }
42254+
42255+ /// lane-av1formatsweep: the 4:4:4 x 10-BIT cell. Every committed 4:4:4
42256+ /// exactness gate in this file is `--lossless=1` at 8 bits
42257+ /// (`a_real_aomenc_lossless_444_key_frame_decodes_sample_exact`,
42258+ /// `a_lossless_444_min_partition64_inter_stream_decodes_pixel_exact`,
42259+ /// `a_lossless_444_defaultp_inter_strip_stream_decodes_byte_exact`, the
42260+ /// `ll444_*` pins), so the whole committed 4:4:4 evidence base is LOSSLESS
42261+ /// 8-bit: no 4:4:4 stream above 8 bits had a committed exactness gate.
42262+ ///
42263+ /// NON-VACUITY: `decode::rect_split_lossless_chroma444_hits()` -- the
42264+ /// per-4x4 chroma unit walk a lossless HORZ/VERT strip takes at
42265+ /// subsampling 0/0 -- is asserted to fire (measured 32 units on this
42266+ /// recipe), and the sequence header is asserted to say ss (0,0) at
42267+ /// 10-bit before any pixel is trusted. A 4:2:0 stream of the same
42268+ /// content leaves that counter at zero, so the pixel compare alone would
42269+ /// not prove the 4:4:4 chroma path ran (class `gate-blind-to-feature`).
42270+ ///
42271+ /// Recipe: `testsrc2 128x96` yuv444p10le 6 frames, `aomenc --codec=av1
42272+ /// --profile=1 --input-bit-depth=10 --bit-depth=10 --lossless=1
42273+ /// --enable-palette=0 --enable-intrabc=0 --cq-level=20 --cpu-used=2
42274+ /// --passes=1 --end-usage=q --threads=1 --row-mt=0 --lag-in-frames=0
42275+ /// --kf-max-dist=100 --limit=6 --obu -o - -`.
42276+ #[test]
42277+ fn a_lossless_444_10bit_inter_stream_decodes_pixel_exact() {
42278+ const NAME: &str = "a_lossless_444_10bit_inter_stream_decodes_pixel_exact";
42279+ let _gate_lock = lock_gate_counters();
42280+ if !have_ffmpeg() || !have_aomenc() {
42281+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
42282+ return;
42283+ }
42284+ let stream = chroma_format_stream(
42285+ 128,
42286+ 96,
42287+ "yuv444p10le",
42288+ 10,
42289+ 6,
42290+ &[
42291+ "--lossless=1",
42292+ "--enable-palette=0",
42293+ "--enable-intrabc=0",
42294+ // `--cpu-used=2`, NOT 0: at `--cpu-used=0` aomenc reaches
42295+ // the 128-root partition (measured `part128: split=1
42296+ // none=5` where this recipe reads `none=0`) and THAT stream
42297+ // diverges at 10-bit 4:4:4 from frame 1 on -- 11152 of
42298+ // 36864 samples, first at Y(8,4), with ffmpeg and aomdec
42299+ // agreeing on the reference. Handoff, not this gate's
42300+ // subject; see `lanes/av1formatsweep.report.md`.
42301+ "--cpu-used=2",
42302+ "--cq-level=20",
42303+ ],
42304+ 0,
42305+ );
42306+ assert_444_header(&stream, NAME, 10);
42307+ let before_444 = crate::decode::rect_split_lossless_chroma444_hits();
42308+ let (frames_decoded, _hidden) = decode_all_frames_vs_oracle(&stream, NAME);
42309+ assert!(
42310+ crate::decode::rect_split_lossless_chroma444_hits() > before_444,
42311+ "{NAME} went blind: no lossless strip walked its chroma as 4:4:4 \
42312+ 4x4 units"
42313+ );
42314+ assert!(
42315+ frames_decoded >= 6,
42316+ "{NAME}: expected the six-frame recipe to decode"
42317+ );
42318+ eprintln!("{NAME}: {frames_decoded} frames byte-exact vs aomdec at 10-bit 4:4:4");
42319+ }
42320+
42321+ /// lane-av1formatsweep: the 4:4:4 x 12-BIT cell -- the deepest chroma
42322+ /// format the spec allows, and the one no committed gate reached. A
42323+ /// sharp-edged source makes aomenc set `allow_screen_content_tools`,
42324+ /// which this decoder refuses BY NAME at 12 bits (palette and intrabc
42325+ /// have no 12-bit witness), so the arm encodes the SMOOTHED
42326+ /// `mandelbrot` source -- the same trick `a_real_aomenc_12bit_stream_
42327+ /// decodes_pixel_exact`'s in-tree source exists for.
42328+ ///
42329+ /// NON-VACUITY: the header is asserted to say ss (0,0) at 12 bits,
42330+ /// `mc::mc_subpel_hits()` (the 12-bit-sensitive subpel round pair) must
42331+ /// fire -- a key-frame-only stream would pass the pixel compare without
42332+ /// touching it -- and every decoded frame's chroma plane is asserted to
42333+ /// be FULL resolution, which is the 4:4:4 extent itself.
42334+ ///
42335+ /// Recipe: `mandelbrot 128x96` + `-vf gblur=sigma=6` yuv444p12le 6 frames,
42336+ /// `aomenc --codec=av1 --input-bit-depth=12 --bit-depth=12 --passes=1
42337+ /// --end-usage=q --cq-level=20 --cpu-used=2 --threads=1 --row-mt=0
42338+ /// --lag-in-frames=0 --kf-max-dist=100 --limit=6 --obu -o - -`.
42339+ /// aomenc picks `seq_profile=2` here (12-bit forces it) with
42340+ /// `subsampling_x/y = 0,0` -- still 4:4:4 planes, and the decoder's
42341+ /// refusal only rejects `subsampling_x != subsampling_y`.
42342+ #[test]
42343+ fn a_444_12bit_inter_sequence_decodes_pixel_exact() {
42344+ const NAME: &str = "a_444_12bit_inter_sequence_decodes_pixel_exact";
42345+ let _gate_lock = lock_gate_counters();
42346+ if !have_ffmpeg() || !have_aomenc() {
42347+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
42348+ return;
42349+ }
42350+ let stream = chroma_format_stream(128, 96, "yuv444p12le", 12, 6, &["--cq-level=20"], 1);
42351+ assert_444_header(&stream, NAME, 12);
42352+ let before_subpel = crate::mc::mc_subpel_hits();
42353+ let frames = decode_stream(&stream)
42354+ .unwrap_or_else(|e| panic!("{NAME}: refused a real 12-bit 4:4:4 stream: {e}"));
42355+ let (frames_decoded, _hidden) = decode_all_frames_vs_oracle(&stream, NAME);
42356+ assert!(
42357+ crate::mc::mc_subpel_hits() > before_subpel,
42358+ "{NAME} went blind: no subpel inter prediction ran, so the \
42359+ 12-bit round pair is unexercised"
42360+ );
42361+ // The 4:4:4 chroma EXTENT is the cell's own claim: at ss (0,0) the
42362+ // chroma planes are full resolution, so a decoder that kept the
42363+ // 4:2:0 extent would produce quarter-size chroma planes and a
42364+ // byte-length the oracle cannot even match. (CDEF is NOT asserted
42365+ // here: on this smoothed source CDEF runs but skips every band --
42366+ // measured `cdef_band: rect_skip_writes=11`, zero index literals --
42367+ // so a CDEF assertion would be a claim the witness cannot carry.)
42368+ for (i, f) in frames.iter().enumerate() {
42369+ assert_eq!(
42370+ f.u.len(),
42371+ 128 * 96,
42372+ "{NAME}: frame {i} chroma plane is {} samples -- at 4:4:4 it \
42373+ must be full resolution (128x96), not the 4:2:0 quarter",
42374+ f.u.len()
42375+ );
42376+ }
42377+ eprintln!("{NAME}: {frames_decoded} frames byte-exact vs aomdec at 12-bit 4:4:4");
42378+ }
42379+
42380+ /// lane-av1formatsweep: a `testsrc2`/`mandelbrot` source rendered to
42381+ /// `pix_fmt` as y4m and piped to `aomenc` at `bit_depth`, with `extra`
42382+ /// aomenc flags. `smooth` selects the gblur'd `mandelbrot` source (1) or
42383+ /// `testsrc2` (0). The child deadline comes from `run_with_stdin`
42384+ /// (`EC_AV1_CHILD_TIMEOUT_SECS`), so a wedged encoder fails loudly.
42385+ fn chroma_format_stream(
42386+ width: usize,
42387+ height: usize,
42388+ pix_fmt: &str,
42389+ bit_depth: usize,
42390+ frames: usize,
42391+ extra: &[&str],
42392+ smooth: u8,
42393+ ) -> Vec<u8> {
42394+ let source = if smooth == 1 {
42395+ format!("mandelbrot=size={width}x{height}:rate=25")
42396+ } else {
42397+ format!("testsrc2=size={width}x{height}:rate=25")
42398+ };
42399+ let mut ffmpeg_args: Vec<String> = vec![
42400+ "-v".into(),
42401+ "error".into(),
42402+ "-f".into(),
42403+ "lavfi".into(),
42404+ "-i".into(),
42405+ source,
42406+ ];
42407+ if smooth == 1 {
42408+ ffmpeg_args.extend(["-vf".into(), "gblur=sigma=6".into()]);
42409+ }
42410+ ffmpeg_args.extend([
42411+ "-frames:v".into(),
42412+ frames.to_string(),
42413+ "-pix_fmt".into(),
42414+ pix_fmt.into(),
42415+ "-strict".into(),
42416+ "-1".into(),
42417+ "-f".into(),
42418+ "yuv4mpegpipe".into(),
42419+ "-".into(),
42420+ ]);
42421+ let y4m = Command::new("ffmpeg")
42422+ .args(&ffmpeg_args)
42423+ .stdin(Stdio::null())
42424+ .stdout(Stdio::piped())
42425+ .stderr(Stdio::piped())
42426+ .output()
42427+ .expect("ffmpeg failed to run");
42428+ assert!(
42429+ y4m.status.success(),
42430+ "ffmpeg refused the {width}x{height} {pix_fmt} source: {}",
42431+ String::from_utf8_lossy(&y4m.stderr)
42432+ );
42433+ // AOMENC FLAG PRECEDENCE (COMMON): aomenc keeps the FIRST occurrence
42434+ // of a flag, so the per-arm override goes BEFORE the base list.
42435+ let limit = format!("--limit={frames}");
42436+ let mut args: Vec<String> = extra.iter().map(|s| (*s).to_owned()).collect();
42437+ args.extend(
42438+ [
42439+ "--codec=av1",
42440+ "--passes=1",
42441+ "--end-usage=q",
42442+ "--threads=1",
42443+ "--row-mt=0",
42444+ "--lag-in-frames=0",
42445+ "--kf-max-dist=100",
42446+ limit.as_str(),
42447+ ]
42448+ .iter()
42449+ .map(|s| (*s).to_owned()),
42450+ );
42451+ if bit_depth > 8 {
42452+ args.push(format!("--input-bit-depth={bit_depth}"));
42453+ args.push(format!("--bit-depth={bit_depth}"));
42454+ }
42455+ args.extend(["--obu".into(), "-o".into(), "-".into(), "-".into()]);
42456+ let out = run_with_stdin(Command::new(aomenc_path()).args(&args), &y4m.stdout);
42457+ assert!(
42458+ out.status.success(),
42459+ "aomenc refused {args:?}: {}",
42460+ String::from_utf8_lossy(&out.stderr)
42461+ );
42462+ out.stdout
42463+ }
42464+
42465+ /// Asserts the stream's sequence header really is 4:4:4 (`ss 0,0`) at
42466+ /// `bit_depth` before any pixel comparison is trusted (class
42467+ /// `arrival-not-intent`: a recipe that silently produced 4:2:0 would
42468+ /// make the whole gate a no-op for its own subject).
42469+ fn assert_444_header(stream: &[u8], name: &str, bit_depth: usize) {
42470+ let mut parser = Av1Parser::new();
42471+ let mut pos = 0usize;
42472+ let mut seen = false;
42473+ while pos < stream.len() {
42474+ let obu = parser
42475+ .parse_obu(&stream[pos..])
42476+ .unwrap_or_else(|e| panic!("{name}: aomenc OBU does not parse: {e:?}"));
42477+ if obu.total_size == 0 {
42478+ break;
42479+ }
42480+ pos += obu.total_size;
42481+ if let ObuKind::SequenceHeader(seq) = obu.kind {
42482+ let cc = &seq.color_config;
42483+ assert_eq!(
42484+ (cc.subsampling_x, cc.subsampling_y),
42485+ (0, 0),
42486+ "{name}: the stream is not 4:4:4 (ss {}x{})",
42487+ cc.subsampling_x,
42488+ cc.subsampling_y
42489+ );
42490+ assert_eq!(
42491+ cc.bit_depth as usize, bit_depth,
42492+ "{name}: the stream is {}-bit, not {bit_depth}-bit",
42493+ cc.bit_depth
42494+ );
42495+ seen = true;
42496+ }
42497+ }
42498+ assert!(seen, "{name}: no sequence header parsed");
42499+ }
42039 }42500 }
lanes/av1formatsweep.report.mdadded+255 -0
@@ -0,0 +1,255 @@
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+**Method.** (1) Every `#[test]` in the crate was enumerated (693 total, 285
16+in `stream.rs`) and each `a_real_aomenc_*` / 4:4:4-named gate resolved to its
17+shape from the aomenc flag vector its body (or its helper) actually builds.
18+(2) Uncovered cells were encoded with the durable oracle
19+`~/.cache/aom-oracle/build/aomenc` and decoded two ways: against
20+`aomdec`'s `EC_AV1_FINAL_DUMP` (byte-for-byte, decode order) and against
21+`ffmpeg -f rawvideo`. A cell is called EXACT only when both agree.
22+(3) Control arms first, to prove the comparison itself is sound: 4:2:0 8-bit
23+`min-partition=64` and 4:4:4 8-bit lossless `min-partition=64` (the recipe of
24+the committed `a_lossless_444_min_partition64_inter_stream_decodes_pixel_exact`
25+gate) both came out exact, so a divergence below is the decoder's, not the
26+harness's.
27+
28+## 1. The matrix
29+
30+Format is the sequence header's `subsampling_x/y` (what the decoder branches
31+on), not aomenc's `--profile`: profile 2 at 12 bits still emits `ss (0,0)`
32+for a `yuv444p12le` input, and a true 4:4:0 needs a `yuv440p` input the sweep
33+never produced.
34+
35+Legend: **Y** = committed exactness gate; **y** = no gate, measured EXACT this
36+lane; **D** = no gate, measured DIVERGENT (localized in §3); **R** = refused by
37+name (no exactness claim possible or wanted); **–** = not measured.
38+
39+### 4:2:0 (`ss 1,1`)
40+
41+| cell | 8-bit | 10-bit | 12-bit |
42+|---|---|---|---|
43+| even dims, key+inter | Y (≈120 gates) | Y (≈40 gates) | Y (4 gates) |
44+| **odd coded dims** (`w%8≠0` or `h%8≠0`) | **y → gate A** | **y → gate A** | **y → gate A** |
45+| partial-superblock edge (72, 136, …) | Y (`tiny_frame_size_sweep`) | Y | – |
46+| tile columns / rows | Y (2 and 4, both axes) | Y (multi-tile family) | – |
47+| superres | Y | Y | – |
48+| film grain / warp / CDEF+LR | Y | Y | Y |
49+
50+Odd coded dimensions had **no committed gate at any depth**: every frame size
51+in the crate (the tiny-size ladder included — 8, 16, 24, 32, 48, 64, 72, 136,
52+192, 200…248) is a multiple of 8, so the partial-chroma-plane walk had no
53+exactness evidence. Measured exact, and gated.
54+
55+### 4:4:4 (`ss 0,0`) — the whole committed base is LOSSLESS 8-bit
56+
57+| cell | 8-bit | 10-bit | 12-bit |
58+|---|---|---|---|
59+| lossless | Y (8 gates, `ll444_*` pins) | **y → gate B** | R¹ / – |
60+| **lossy** | **D (H1, H2)** | **D (H1)** | **y → gate C** |
61+| tile columns (2) | **D (H3)** | – | – |
62+| tile rows (2) | **D (H4)** | – | – |
63+| superres | – | – | – |
64+| odd coded dims | – | – | – |
65+
66+¹ 12-bit 4:4:4 is reachable only from a source smooth enough that aomenc
67+leaves `allow_screen_content_tools = 0`; otherwise the 12-bit screen-tools
68+refusal fires first (H6). The smooth-source 12-bit 4:4:4 path is exact
69+(gate C). The smooth-source 12-bit **lossless** 4:4:4 stream was not measured.
70+
71+### 4:2:2 (`ss 1,0`) and 4:4:0 (`ss 0,1`)
72+
73+| cell | verdict |
74+|---|---|
75+| any depth, any geometry, committed | **R** — `subsampling_x != subsampling_y` refuses by name in `decode_frame` before any tile dispatch |
76+| 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 |
77+| odd coded dims, 8-bit, lossy inter | **y, probe-bypass only** (130x122, 66x66, 194x130 — 4 frames each, all three planes byte-exact vs ffmpeg) |
78+| odd coded dims, 10-bit | **y, probe-bypass only** (130x122) |
79+| 2x2 tiles, 8-bit | **y, probe-bypass only** (130x122) |
80+| 4:4:0 | – (no witness produced; refused by the same clause anyway) |
81+
82+The bypass is a local patch (`EC_AV1_ALLOW_422_PROBE` added to the refusal
83+condition), applied, measured, and reverted in the same session;
84+`grep EC_AV1_ALLOW_422_PROBE crates/ --include=*.rs` at HEAD still hits only
85+doc comments. The refusal stays.
86+
87+**This is the single most useful line in the report for a 4:2:2 lift:** the
88+lossy 4:2:2 inter path — odd extents, 10-bit, multi-tile — decodes
89+**pixel-exact** wherever the bypass admits it. The lift's risk is not in the
90+odd-dimension or tile geometry; it is in the shapes already named in
91+`refusal_inventory.rs` (rect chroma units, 64-side mu-chunk walks, sub-8
92+pairs), which the committed 4:2:2 pins exist to witness.
93+
94+## 2. Gates added (all in `crates/ec-av1/src/stream.rs`)
95+
96+Each is live-aomenc (no new fixture pin needed: the recipe is deterministic —
97+single pass, single thread, no row-mt — and the aomenc recipe is quoted in
98+the doc comment), compares byte-for-byte against the instrumented `aomdec`
99+through `decode_all_frames_vs_oracle`, and hard-asserts the shape it claims.
100+
101+1. **`a_real_aomenc_odd_coded_dimension_streams_decode_pixel_exact`** — six
102+ arms: 130x130, 66x66, 194x122, 130x122 at 8-bit; 130x122 at 10-bit;
103+ 130x122 at 12-bit (smoothed `mandelbrot` source). Non-vacuity: the header
104+ must really be `ss (1,1)` at the claimed depth, the mode-info grid must
105+ be partial (`mi*8 > dim`), every decoded frame's chroma plane must be
106+ `ceil(w/2)*ceil(h/2)`, and `decode::inter_edge_strip_hits()` must be
107+ non-zero after a per-arm reset. Measured per-arm edge walks:
108+ `[0,6,0,4,48,12]`, `[0,0,0,4,0,6]`, `[0,4,0,10,0,10]`, `[0,4,0,8,0,12]`,
109+ `[0,4,0,8,0,8]`, `[0,0,0,12,0,14]` — the even-size control (128x96) reads
110+ all zeros, so the counter is specific to the partial-column walk.
111+2. **`a_lossless_444_10bit_inter_stream_decodes_pixel_exact`** — 4:4:4
112+ lossless at 10-bit, 6 frames, byte-exact vs aomdec. Non-vacuity: the
113+ header must say `ss (0,0)` at 10-bit and
114+ `decode::rect_split_lossless_chroma444_hits()` must fire (measured 32
115+ units; a 4:2:0 stream of the same content leaves it at 0). The recipe is
116+ pinned to `--cpu-used=2`; see H5 for the `--cpu-used=0` sibling.
117+3. **`a_444_12bit_inter_sequence_decodes_pixel_exact`** — 4:4:4 at 12-bit,
118+ 6 frames, byte-exact vs aomdec. Non-vacuity: header `ss (0,0)` at 12-bit,
119+ `mc::mc_subpel_hits()` must fire (the 12-bit round pair), and every
120+ decoded frame's chroma plane must be full resolution. CDEF is
121+ deliberately NOT asserted: on this smoothed source CDEF runs but skips
122+ every band (`cdef_band: rect_skip_writes=11`, zero index literals), so
123+ such an assertion would be a claim the witness cannot carry.
124+
125+Shared helpers added: `odd_dim_stream` / `chroma_format_stream` (ffmpeg y4m →
126+aomenc pipe, deadline from `run_with_stdin`), `odd_dim_header_mi_grid`,
127+`assert_444_header`.
128+
129+**Honest gap in the proof:** the odd-dimensions gate's counter and geometry
130+assertions are in place, but its red-before (mutation) proof is NOT
131+complete. Forcing `decode::round_ss` from libaom's `ROUND_POWER_OF_TWO` to a
132+floor division left the gate GREEN — the odd-dimension extents are computed
133+from the mode-info grid (`mi_cols*4 >> ss`), not through `round_ss`. A
134+mutation inside that extent computation is the outstanding proof. Gates B and
135+C inherit the same `aomdec` byte-compare proof as the 180 existing gates, and
136+no mutation proof either.
137+
138+## 3. Divergences, localized
139+
140+### H1 — 4:4:4 lossy + a RECT partition: entropy fork (the big one)
141+
142+Minimal repro: `aomenc --codec=av1 --profile=1 --passes=1 --end-usage=q
143+--cq-level=20 --cpu-used=2 --threads=1 --row-mt=0 --lag-in-frames=0
144+--kf-max-dist=100 --limit=2` over `testsrc2 128x96 yuv444p`, 6441 bytes.
145+Frame 0 (key) is exact; frame 1's first wrong sample is **Y(91,32)**
146+(ours 35, ref 38) and 8884 of 36864 samples are wrong by frame 1.
147+
148+Bisect: `--enable-rect-partitions=0` → **exact**; `--enable-ab-partitions=0`
149+→ still divergent (AB partitions are innocent); `--min-partition-size=32`
150+and `=64` → exact; CDEF / loop restoration / deblock / OBMC / warp toggles
151+change nothing; the same recipe at 4:2:0 is exact.
152+
153+First divergence, `EC_SYMR` on both sides (ours: `msac.rs` `SymbolDecoder::
154+symbol`; oracle: `aom_dsp/bitreader.h` `aom_read_symbol_`), one line per
155+symbol read in decode order, aligned on `(value, range, symbol, post_rng)`
156+with the CDF-row convention reconciled (`32768 - ours_icdf0 == oracle_cdf0`;
157+the `bit` field runs a constant +15 offset, 26219 of the first 26263 reads):
158+
159+```
160+index 26262 both mi=(8,16) decodetxb.c:368 (dc_sign) s=1 pre=(13550,51360) post=58008
161+index 26263 ORACLE mi=(8,16) decodetxb.c:158 txb_skip s=1 cdf0=16519 n=2 pre=(27101,58008) post=58316
162+index 26263 OURS mi=(8,16) (read_coeffs_rect) s=0 icdf0=22556 n=2 pre=(27101,58008) post=40037
163+```
164+
165+`decodetxb.c:158` is the `txb_skip` read. `EC_COEFF_STEP` names the unit:
166+
167+```
168+[1252] OURS plane=0 ctx=0 entry=61254 all_zero=0
169+[1253] ORACLE plane=1 bc=0 br=0 ctx=7 txs=1 pt=1 all_zero=1 <- the U plane
170+[1253] OURS plane=0 ctx=1 entry=58008 all_zero=0 <- a second LUMA rect unit
171+```
172+
173+(The `plane=0` label on our side is hardcoded in `read_coeffs_rect`'s trace
174+line — a label bug, not a fact; the read site is the rect walk.) So at
175+4:4:4, where the chroma plane block is 1:1 with luma, the rect unit walk
176+emits a LUMA unit where the oracle moves to the chroma plane, and the fork
177+propagates from there. The first *pixel* divergence is a block later
178+(the block at mi(8,16) is a skip/zero-residual block, so its own pixels
179+survive the wrong read). `decode.rs:11602` (`span_x = 4 << ss_x`) is the
180+4:4:4 unit geometry to look at first, and the txb_ctx chroma base
181+(7 vs 10, `txb_common.h` ~352, already flagged in
182+`skill://ec-av1-chroma-arm-oracle-verify`) is the second candidate.
183+
184+### H2 — 4:4:4 lossy + TX size search: chroma-only ±1, NO entropy divergence
185+
186+Recipe: profile 1 lossy cq 20, `--sb-size=64 --min-partition-size=64
187+--max-partition-size=64` (whole 64x64 roots, no rect splits), 4 frames.
188+Frame 0 and 1 exact; from frame 2, 608 of 36864 samples wrong — **U and V
189+only, luma exactly zero wrong**, magnitude ±1 (up to ±20 at cq 40).
190+
191+`EC_SYMR` on both sides: **140820 reads, zero divergence** — the entropy
192+decode is bit-identical, so this is pure reconstruction arithmetic, not a
193+fork. `--enable-tx-size-search=0` → exact; every filter toggle changes
194+nothing. Prime suspect is the chroma transform-unit shape at `ss (0,0)`: at
195+4:2:0 the chroma rect is halved and a `TX_32X64` chroma unit cannot arise,
196+while at 4:4:4 it can, and libaom clamps it —
197+`max_txsize_rect_lookup[BLOCK_32X64] = TX_32X64` then
198+`av1_get_adjusted_tx_size` (`blockd.h` ~1363) reduces TX_32X64 to TX_32X32.
199+
200+### H3 — 4:4:4 lossless + 2 tile columns: 90 chroma samples wrong in the key frame
201+
202+256x128 `testsrc2 yuv444p`, `--lossless=1 --tile-columns=1`, 6 frames,
203+aomdec-confirmed (not an ffmpeg artefact). Frame 0: exactly 90 wrong
204+samples, U and V, ±1, first at U(237,58). Frames 1–5: byte-exact.
205+
206+### H4 — 4:4:4 lossless + 2 tile ROWS: hard divergence
207+
208+Same recipe with `--tile-rows=1`. Frames 0–2 exact; frame 3 onwards the whole
209+plane comes out flat (Y(0,0) ours 128 vs ref 81, then ~70% of all samples
210+wrong, growing to 85% by frame 5). Worst verdict in the sweep.
211+
212+### H5 — 4:4:4 lossless at 10-bit, `--cpu-used=0`: 128-root partition diverges
213+
214+The gate-B recipe at `--cpu-used=0` makes aomenc reach the 128-root
215+partition (`part128: split=1 none=5`, where `--cpu-used=2` reads
216+`none=0`). That stream diverges from frame 1: 11152 of 36864 samples wrong,
217+first at Y(8,4), with **ffmpeg and aomdec agreeing** on the reference. The
218+committed 8-bit 4:4:4 gates cover 128 roots (`a_444_sb128_root_rect_stream_
219+with_restoration_decodes_pixel_exact`), but not at 10 bits.
220+
221+### H6 — coverage caveat, not a defect: 12-bit 4:4:4 needs a smooth source
222+
223+`aomenc --input-bit-depth=12` over `testsrc2 yuv444p12le` sets
224+`allow_screen_content_tools = 1` even with `--enable-palette=0
225+--enable-intrabc=0`, and the 12-bit screen-tools refusal fires by name. With
226+a `-vf gblur=sigma=6` source the same recipe decodes and is exact. Any
227+future 12-bit 4:4:4 witness has to carry that source, or it will measure the
228+screen-tools refusal and call it a 4:4:4 result.
229+
230+## 4. Not measured (budget), stated so nobody reads silence as coverage
231+
232+12-bit tiles at 4:2:0; 12-bit superres; 4:4:4 superres; 4:4:4 odd coded
233+dimensions; 4:4:4 at 10/12-bit with tiles; 12-bit 4:4:4 lossless; 4:4:0
234+(`ss 0,1`) at any depth. Suite staging and the full-suite run are Main's.
235+
236+## 5. Handoffs, in the order a follow-up lane should take them
237+
238+1. **H1** rect partition at 4:4:4 lossy — the largest correctness gap in the
239+ sweep; entropy fork at mi(8,16), localized to the chroma/luma unit walk.
240+2. **H4** 4:4:4 lossless + tile rows — hard failure, cheapest to bisect
241+ (single-tile-row frame-edge walk).
242+3. **H5** 4:4:4 10-bit lossless 128-root — a cell the 8-bit 444 gates
243+ suggest is safe and is not.
244+4. **H2** 4:4:4 lossy + tx size search chroma ±1 — reconstruction-only,
245+ entropy-clean, so the `av1_get_adjusted_tx_size` clamp is the first thing
246+ to check.
247+5. **H3** 4:4:4 lossless + tile columns, 90 chroma samples — smallest
248+ magnitude, likely the same root as H2.
249+
250+For the **4:2:2 lift** the sweep's message is mostly good news: the odd-
251+dimension, 10-bit and multi-tile 4:2:2 paths are already pixel-exact under
252+the bypass. Start from the shapes `refusal_inventory.rs` still names, and use
253+the bypass recipe in `skill://ec-av1-422-probe-bypass` to widen the committed
254+422 pins from "refuses by name" to "refuses by name, and is exact when
255+admitted" for at least the lossless big-block case.