From bee9cbf5249cd8811cb0d49d15072a7a4328b302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 1 Oct 2026 20:04:43 +0300 Subject: [PATCH] lane-av1subsizesweep r2: a real witness, a derived read-spelling scan, a scoped census Main's r2 review was right on all counts. Fixed, plus the three items still open from r1. WITNESS. There is one, and the earlier "no witness exists" claim was wrong. 422_header_edge16_walk.obu (128 bytes) is a 4:2:2 sequence header over a 4:2:0 key frame's tile at 88x64. Width 88 is 8 mod 16, so the last 16x16 column block is column-short and the frame-edge arm fires; height 64 is 16-aligned, so the both-cut arm is not taken. aomdec says: Block size 8x16 invalid with this subsampling mode and so do we. What makes this pin different from every other refusal gate here is that the 8x16 is the ONLY offending subsize in the stream: over a 260-candidate sweep (4 card textures x 5 quantizers x 13 declared widths) it is the one candidate whose decode with the guard DELETED SUCCEEDS -- the decoder returned a full 88x64 picture where libaom refuses the frame. So the guard is load-bearing, not a redundant second refusal, and the new gate reds when it is deleted. The witness had to be built from this crate's own encoder with a DECLARED width (encode_key_frame_at_size, the gen_coverage_cells cell-2 construction): aomenc rounds the coded size to even and never declares 88. That also corrects the report: my earlier `partition_rect_allowed` explanation for the aomenc non-hit was WRONG -- that gate governs the encoder's partition search, whereas this arm's partition comes from a single gathered bit after a frame-edge geometry test. Why aomenc never produces the shape is not known. Severity is a false-accept, not a pixel divergence: libaom refuses the whole frame, so there is no correct output to diverge from. MATCHER GAP WIDENED, AND DERIVED. A partition-symbol READ is now defined as a `dec.(..)` call whose OWN ARGUMENT LIST names a `partition_w[` CDF. That needs no hand-list: `dec.symbol(..partition_w..)` qualifies, the frame-edge gather's `dec.symbol_fixed(&gather(..partition_w..))` qualifies, and `dec.debug_state()` does not. The old test's read test was the literal `dec.symbol(`, which is not a substring of `dec.symbol_fixed(` -- that spelling gap is what hid the hole. The `var == "b"` skip is gone too: edge reads are sites now and must carry a guard for their own level before the first chroma-walking dispatch after them. Stated limitation: the definition is syntactic, so a read reaching a partition CDF through a helper that does not name it would not be enumerated; there is no such call in this file. CENSUS ROWS NOW CLAIM A REAL GUARD. r2 was right that AtResolution asserted only that some shape was BLOCK_INVALID and never mentioned a guard, so rows 5-12 and 19's guard column were prose. A resolution row now CARRIES the guard it depends on -- (function scope, level) -- and the check looks for refuse_invalid_subsize((L,L)) inside that function and before the walk's first call there. Per-guard deletion now reds the census on its own for ten of the twelve guards. Two are claimed by LEVEL, not by site -- the key-frame 8x8 second resolution and the inter decoder's own 128-root -- and are caught instead by the merged scan's resolution-count cross-check; the report says so rather than papering over it. Three inter rows were added, because the inter 32- and 64-level guards were previously claimed by nothing at all. ORDERING CHECK NO LONGER VACUOUS. The per-route loop resolved each pair's guard with find() over the whole decode body, which returns the FIRST 16x16 guard -- the key-frame one -- so the inter pair was satisfied by a guard three quarters of the file away and deleting the inter guard left it green. Each pair now scopes its guard search to its own enclosing function. Verified: deleting the inter 16-level guard at 54809 reds naming decode_intra_rect_in_inter. ALSO: the stale inter-edge citation (54720/54733 -> the reads, 54777/54790), a one-line note that two edits leaked into the primary through relative paths and were reverted before any commit, and the headline that the find came from censusing WALK sites rather than SYMBOL sites -- that reframing is the only reason the hole was visible. cargo check --tests clean. 28 named 422/sub8/subsize/chroma_422 tests pass (includes the new witness gate). 270 pixel_exact/byte_exact pass, which is the over-refusal control at scale. --- .../fixtures/422_header_edge16_walk.obu | Bin 0 -> 128 bytes crates/ec-av1/src/decode.rs | 318 ++++++++++++-- crates/ec-av1/src/stream.rs | 76 ++++ lanes/av1subsizesweep.report.md | 399 ++++++++++-------- 4 files changed, 572 insertions(+), 221 deletions(-) create mode 100644 crates/ec-av1/fixtures/422_header_edge16_walk.obu diff --git a/crates/ec-av1/fixtures/422_header_edge16_walk.obu b/crates/ec-av1/fixtures/422_header_edge16_walk.obu new file mode 100644 index 0000000000000000000000000000000000000000..bfdfcb705dd034e8ddcfd5e1928f2a7bd7c3871a GIT binary patch literal 128 zcmV-`0Du1q3P1n=L6*PlP|OH2au5UX01!X`FbKfF<^7p{pzfC$wH29Jl)(H*6&L?f zP-6ZO3V?}j#l7_=_DM+@C`RHot```q=#D){g1YmN6W|@=pkD{lr`uEUF)>s2JufSd iC!mAsdFm?3L=6~QA`n*2DsqM*64T+%4XFP>V_v}IpE*nb literal 0 HcmV?d00001 diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 77fcfc39..85bae209 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -21454,8 +21454,11 @@ const PLANE_BLOCK_INVALID_440: &[(usize, usize)] = &[ /// Whether `av1_ss_size_lookup[(bw, bh)][sx][sy]` is not `BLOCK_INVALID` -- i.e. /// whether libaom lets a subsize of this luma shape have a chroma plane block -/// at this subsampling at all. -fn chroma_plane_block_codable(bw: usize, bh: usize, sx: usize, sy: usize) -> bool { +/// at this subsampling at all. `pub(crate)` so a fixture gate in `stream.rs` +/// can assert WHICH shape its pin carries, rather than only that the decode +/// refused -- a refusal gate that cannot name the shape is one decode-site +/// change away from measuring the wrong thing. +pub(crate) fn chroma_plane_block_codable(bw: usize, bh: usize, sx: usize, sy: usize) -> bool { match (sx, sy) { (1, 0) => !PLANE_BLOCK_INVALID_422.contains(&(bw, bh)), (0, 1) => !PLANE_BLOCK_INVALID_440.contains(&(bw, bh)), @@ -37064,12 +37067,12 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( // dispatches on its own symbol instead of // resolving it into a `partN` the level's guard // covers. The 128-root edge arms - // (decode.rs:35551/35559), the 64-level ones - // (36239/36256) and the 32-level ones - // (36363/36383) all end in `PARTITION_HORZ` / + // (decode.rs:35559/35567), the 64-level ones + // (36247/36264) and the 32-level ones + // (36371/36391) all end in `PARTITION_HORZ` / // `PARTITION_VERT` / `PARTITION_SPLIT`, which // the guard after their `match` sees -- the - // inter-frame 16-level edge arms (54720/54733) + // inter-frame 16-level edge arms (54777/54790) // resolve into `part16` for the same reason. // Here `edge_split` goes straight into // `decode_leaf_rect`, and the shape it carries is @@ -56733,6 +56736,57 @@ mod tests { } } } + // r11 (lane-av1subsizesweep): a partition-symbol READ is a `dec.(..)` + // call whose OWN ARGUMENT LIST names a `partition_w[` CDF. That is the + // whole definition, and it is why the read spellings need no hand-list: + // `dec.symbol(..partition_w..)` qualifies, the frame-edge gather's + // `dec.symbol_fixed(&gather(..partition_w..))` qualifies, and + // `dec.debug_state()` does not -- it never names a partition CDF. A third + // spelling is covered the day somebody writes it. + // + // r11's hole was a SPELLING gap, not a shape gap: the old matcher named + // `dec.symbol(` literally, and `dec.symbol(` is not a substring of + // `dec.symbol_fixed(`. So the key-frame 16-level frame-edge arm -- which + // dispatches `decode_leaf_rect` straight off a gathered `edge_split` onto + // a BLOCK_8X16 chroma walk -- was never a site at all. + let is_partition_read = |window: &str| -> bool { + let mut at = 0usize; + while let Some(rel) = window[at..].find("dec.") { + let call = at + rel + "dec.".len(); + at = call; + let name: String = window[call..] + .chars() + .take_while(|c| c.is_ascii_alphanumeric() || *c == '_') + .collect(); + if name.is_empty() { + continue; + } + let Some(open) = window[call + name.len()..].find('(') else { + continue; + }; + let arg_from = call + name.len() + open + 1; + let mut depth = 1usize; + let mut stop = None; + for (i, c) in window[arg_from..].char_indices() { + match c { + '(' => depth += 1, + ')' => { + depth -= 1; + if depth == 0 { + stop = Some(arg_from + i); + break; + } + } + _ => {} + } + } + let Some(stop) = stop else { continue }; + if window[arg_from..stop].contains("partition_w") { + return true; + } + } + false + }; for (n, line) in lines.iter().enumerate() { let t = line.trim_start(); // A doc comment quoting the shape is not a site, and neither is the @@ -56743,7 +56797,9 @@ mod tests { let lo = n.saturating_sub(1); let hi = (n + 2).min(lines.len()); let window = lines[lo..hi].join(" "); - if !window.contains("dec.symbol(") { + // r11: the read test is the DERIVED predicate above, not a spelling + // literal. Naming `dec.symbol(` here is what hid the frame-edge arm. + if !is_partition_read(&window) { continue; } let Some(i) = window.find("partition_w") else { @@ -56778,23 +56834,25 @@ mod tests { continue; } // This binding is followed by the symbol read if the SAME line - // completes `let = dec.symbol(`, or if the next line starts - // the call. That is what separates `let part8 =` from an unrelated - // `let ec_dbg_pre =` two lines above it. + // completes `let = dec.(`, or if the next line + // starts the call. That is what separates `let part8 =` from an + // unrelated `let ec_dbg_pre =` two lines above it. let next = lines.get(cand + 1).copied().unwrap_or(""); - let binds_here = ct.contains("= dec.symbol") || next.contains("dec.symbol("); + let binds_here = ct.contains("= dec.") || next.contains("dec."); if binds_here || cand == n { var = Some(name); break; } } let Some(var) = var else { continue }; - // An edge `gather` binds `b` and is not a resolution: libaom resolves - // those from a two-symbol CDF and the site is guarded at the level's - // own resolution instead. - if var == "b" { - continue; - } + // r11: the edge `gather` reads are SITES now, not skips. r10 skipped + // them on the reasoning that "the site is guarded at the level's own + // resolution instead" -- true for every arm that resolves into a + // `partN`, and FALSE for the one that does not: the key-frame 16-level + // frame-edge arm dispatches `decode_leaf_rect` straight off `edge_split`, + // and `BLOCK_8X16` is BLOCK_INVALID at 4:2:2. Every site therefore has + // to carry a guard for its OWN level between the read and the first + // chroma-walking dispatch after it -- see the per-site check below. sites.push((n, var, level)); } @@ -57093,6 +57151,15 @@ mod tests { /// and this test is what makes that a checked claim instead of a comment. #[test] fn every_chroma_walking_leaf_dispatch_is_guarded_or_closed_with_a_reason() { + let src = include_str!("decode.rs"); + // r2: `decode_body` is hoisted to the top of the test because the per-row + // guard check below needs it BEFORE the walk census it sits under, and a + // reader who has to hunt for a binding is a reader who will not notice + // when it is scoped to the wrong thing. + let decode_body = match src.find("\n#[cfg(test)]\nmod tests {") { + Some(i) => &src[..i], + None => src, + }; // (a) The shapes libaom cannot code, transcribed from the same // `av1_ss_size_lookup` cells `PLANE_BLOCK_INVALID_422` carries. A walk // handed one of these at the matching subsampling mode is the defect. @@ -57115,11 +57182,33 @@ mod tests { // a guard. // // Each row is (walk, shapes, mechanism). + // + // r2 (Main's review, and it was right): `AtResolution` used to assert + // only that SOME shape the walk handles is BLOCK_INVALID, which + // restates the libaom table and never mentions a guard -- deleting the + // inter 32-level guard left it green. So a resolution row now CARRIES + // the guard it depends on: `(walk, fn-scope, level)`, and the check + // below looks for `refuse_invalid_subsize((level, level))` inside that + // function and before the walk's first call site in it. A row that + // cannot be checked that way says so with `Prose` instead. enum Mech { AtDispatch, - AtResolution, + /// Protected by `refuse_invalid_subsize((L, L))` in the named + /// function, above the walk's first call site there. + AtResolution(&'static str, usize), + /// The walk is reached INDIRECTLY -- this row's guard is asserted to + /// exist in `fscope`, and the ordering is asserted by the per-route + /// loop further down (which scopes to the enclosing function and + /// names this walk's real caller chain). Used only where the walk's + /// call site is not in the guard's own function. + AtResolutionVia(&'static str, usize), Unreachable(&'static str), } + // The key-frame tile decoder and the inter tile decoder. Every + // resolution guard lives in one of the two, which is what makes "the + // guard for THIS row" a scoped lookup rather than a global one. + const KF: &str = "decode_key_frame_tile_with_cdfs"; + const INTER: &str = "decode_inter_frame_tile_with_cdfs"; let census: &[(&str, &[(usize, usize)], Mech)] = &[ // ---- the residue the merged lane named ------------------- // @@ -57142,52 +57231,101 @@ mod tests { ( "decode_rect4_16_intrabc", &[(16, 4), (4, 16)], - Mech::AtResolution, + Mech::AtResolutionVia(KF, 16), ), // ---- 1:4 and 2:1 rect walks, all resolved-symbol guarded -- - ("decode_rect4_16", &[(16, 4), (4, 16)], Mech::AtResolution), + ( + "decode_rect4_16", + &[(16, 4), (4, 16)], + Mech::AtResolution(KF, 16), + ), ( "decode_rect4_16_strip", &[(16, 4), (4, 16)], - Mech::AtResolution, + Mech::AtResolutionVia(KF, 16), ), ( "decode_block_rect", &[(32, 16), (16, 32)], - Mech::AtResolution, + Mech::AtResolution(KF, 32), ), ( "decode_block_rect4", &[(32, 8), (8, 32)], - Mech::AtResolution, + Mech::AtResolution(KF, 32), ), ( "decode_block_rect64", &[(64, 16), (16, 64)], - Mech::AtResolution, + Mech::AtResolution(KF, 64), ), + // The 128-root guard lives in `read_sb128_root`, the shared + // resolver both tile decoders call -- not in the walker's own + // function. ( "decode_block_128rect", &[(128, 64), (64, 128)], - Mech::AtResolution, + Mech::AtResolutionVia("read_sb128_root", 128), ), + // `decode_rect_split` is called from inside decode_block_rect / + // decode_leaf_rect / decode_block_rect4 / decode_block_rect64, none of + // which is the tile decoder -- so the guard it inherits is checked on + // its own callers' rows, not here. ( "decode_rect_split", &[(64, 16), (16, 64), (32, 16), (16, 32)], - Mech::AtResolution, + Mech::AtResolutionVia(KF, 32), + ), + ( + "decode_leaf_rect", + &[(16, 8), (8, 16)], + Mech::AtResolution(KF, 16), + ), + // ---- the INTER-side rect walks ----------------------------- + // + // r2: without these three rows the inter 32- and 64-level guards + // were claimed by NOTHING, and deleting either left the census + // green. They are load-bearing -- `decode_intra_rect_in_inter` + // dispatches `decode_block_rect4` on 32x8/8x32 (8x32 is + // BLOCK_INVALID at 4:2:2) and `decode_block_rect64` on + // 64x16/16x64 (16x64 likewise) -- so each gets its own row naming + // the guard that stands in front of it. + // + // These are `AtResolutionVia`, not `AtResolution`: the walk is + // dispatched from `decode_intra_rect_in_inter`, a helper, not from + // the tile decoder the guard lives in. The check is therefore guard + // EXISTENCE in that decoder -- which is what reds when the guard + // is deleted -- and the linkage is stated here rather than derived. + ( + "decode_block_rect4[inter]", + &[(32, 8), (8, 32)], + Mech::AtResolutionVia(INTER, 32), + ), + ( + "decode_block_rect64[inter]", + &[(64, 16), (16, 64)], + Mech::AtResolutionVia(INTER, 64), + ), + ( + "decode_intra_rect_in_inter", + &[(16, 8), (8, 16), (16, 4), (4, 16)], + Mech::AtResolutionVia(INTER, 16), ), - ("decode_leaf_rect", &[(16, 8), (8, 16)], Mech::AtResolution), // ---- sub-8 walks ------------------------------------------ // (8,4) is legal at 4:2:2 (`av1_ss_size_lookup[8x4][1][0]` is // BLOCK_4X4); (4,8) is BLOCK_INVALID there. Both come off a raw // `part8`, and both 8x8 resolution sites carry the guard -- plus // the redundant inline `chroma_plane_block_codable` check the // merged lane left at 36904. - ("decode_leaf_rect8", &[(8, 4), (4, 8)], Mech::AtResolution), + ( + "decode_leaf_rect8", + &[(8, 4), (4, 8)], + Mech::AtResolution(KF, 8), + ), ( "decode_inter_sub8_rect2", &[(8, 4), (4, 8)], - Mech::AtResolution, + Mech::AtResolution(INTER, 8), ), ( "decode_leaf_split4", @@ -57249,7 +57387,6 @@ mod tests { // (c) Every row's mechanism must be a REAL one. This is what stops // the census from being a list of good intentions: each claim is // re-derived here, and the file is checked for the site it names. - let src = include_str!("decode.rs"); for (walk, shapes, mech) in census { let name = walk.split('[').next().expect("walk name"); assert!( @@ -57293,11 +57430,77 @@ mod tests { ); } } - Mech::AtResolution => { + // r2: the guard THIS row depends on, scoped to the function it + // lives in and ordered before the walk's first call there. + // Deleting that one guard -- and only that one -- reds this row, + // which is what r2's review showed the previous version could + // not do. + Mech::AtResolution(fscope, level) => { assert!( !offending.is_empty(), - "{walk} is listed AtResolution but no shape it walks is \ - BLOCK_INVALID -- then the level's guard is not what protects it" + "{walk} is listed AtResolution but no shape it walks is BLOCK_INVALID \ + -- then the level's guard is not what protects it" + ); + let fstart = decode_body + .find(&format!("\nfn {fscope}(")) + .or_else(|| decode_body.find(&format!("\npub(crate) fn {fscope}("))) + .or_else(|| decode_body.find(&format!("\npub fn {fscope}("))) + .unwrap_or_else(|| { + panic!("the census names `{fscope}`, which is not a function here") + }); + let fend = ["\nfn ", "\npub fn ", "\npub(crate) fn "] + .iter() + .filter_map(|pat| { + decode_body[fstart + 1..].find(pat).map(|i| fstart + 1 + i) + }) + .min() + .unwrap_or(decode_body.len()); + let body = &decode_body[fstart..fend]; + let guard = format!("refuse_invalid_subsize(({level}, {level})"); + let gpos = body.find(&guard).unwrap_or_else(|| { + panic!( + "{walk} claims refuse_invalid_subsize(({level}, {level})) guards it, \ + but there is NO such guard in `{fscope}` -- the row's mechanism is \ + prose, not a check; re-derive it or mark the row Prose" + ) + }); + let call = body.find(&format!("{name}(")).unwrap_or_else(|| { + panic!( + "{walk} has no call site inside `{fscope}` to order the guard against" + ) + }); + assert!( + gpos < call, + "{walk}: in `{fscope}` the ({level}, {level}) guard is at {gpos} and the \ + walk is dispatched at {call} -- a guard BELOW the dispatch can never \ + observe it" + ); + } + Mech::AtResolutionVia(fscope, level) => { + assert!( + !offending.is_empty(), + "{walk} is listed AtResolutionVia but no shape it walks is \ + BLOCK_INVALID" + ); + let fstart = decode_body + .find(&format!("\nfn {fscope}(")) + .or_else(|| decode_body.find(&format!("\npub(crate) fn {fscope}("))) + .or_else(|| decode_body.find(&format!("\npub fn {fscope}("))) + .unwrap_or_else(|| { + panic!("the census names `{fscope}`, which is not a function here") + }); + let fend = ["\nfn ", "\npub fn ", "\npub(crate) fn "] + .iter() + .filter_map(|pat| { + decode_body[fstart + 1..].find(pat).map(|i| fstart + 1 + i) + }) + .min() + .unwrap_or(decode_body.len()); + assert!( + decode_body[fstart..fend] + .contains(&format!("refuse_invalid_subsize(({level}, {level})")), + "{walk} claims refuse_invalid_subsize(({level}, {level})) in `{fscope}` \ + guards it, but there is NO such guard there" ); } Mech::Unreachable(reason) => { @@ -57378,10 +57581,6 @@ mod tests { // the DECODE BODY only -- this test's own string literals name the same // functions, and the merged lane's own scan hit exactly that (five of // its eighteen `refuse_invalid_subsize((` matches are its own). - let decode_body = match src.find("\n#[cfg(test)]\nmod tests {") { - Some(i) => &src[..i], - None => src, - }; for (name, calls) in [ ("decode_rect4_16_intrabc", 1usize), ("decode_rect4_16_strip", 2), @@ -57438,14 +57637,49 @@ mod tests { let call_at = decode_body .rfind(call) .unwrap_or_else(|| panic!("{what} is gone -- re-derive the residue's closure")); - let guard_at = decode_body + // r2 (Main's review, and it was right): the guard search is SCOPED + // to the anchor's own enclosing function. `find()` over the whole + // decode body returns the FIRST `refuse_invalid_subsize((16, 16)` -- + // the KEY-FRAME one -- so the inter pair's comparison was satisfied + // by a guard three quarters of the file away, and deleting the inter + // 16-level guard left this test green. Both routes live in + // different `fn` bodies (`decode_key_frame_tile_with_cdfs` and the + // inter tile decoder), so the enclosing function is the scope that + // tells the two apart. + let fn_scope = |at: usize| -> std::ops::Range { + let head = ["\nfn ", "\npub fn ", "\npub(crate) fn "] + .iter() + .filter_map(|pat| decode_body[..at].rfind(pat)) + .max() + .unwrap_or(0); + let tail = ["\nfn ", "\npub fn ", "\npub(crate) fn "] + .iter() + .filter_map(|pat| decode_body[at..].find(pat).map(|i| at + i)) + .min() + .unwrap_or(decode_body.len()); + head..tail + }; + let scope = fn_scope(test_at); + let guard_at = decode_body[scope.clone()] .find("refuse_invalid_subsize((16, 16)") - .expect("a 16x16-level guard above both 1:4 arms"); + .map(|i| scope.start + i) + .unwrap_or_else(|| { + panic!( + "{what}: there is NO refuse_invalid_subsize((16, 16)) in the function \ + enclosing the 1:4 arm test -- so nothing refuses the VERT_4 symbol \ + this arm dispatches on, and decode_rect4_16_intrabc's closure is gone" + ) + }); assert!( guard_at < test_at && test_at < call_at, - "{what}: guard at {guard_at}, 1:4 arm test at {test_at}, dispatch at \ - {call_at}. The guard has to sit ABOVE the 1:4 arm test, or the \ - VERT_4 symbol it refuses has already been dispatched on" + "{what}: guard at {guard_at} (function scope {scope:?}), 1:4 arm test at \ + {test_at}, dispatch at {call_at}. The guard has to sit ABOVE the 1:4 arm \ + test INSIDE THE SAME FUNCTION, or the VERT_4 symbol it refuses has already \ + been dispatched on" + ); + assert!( + scope.contains(&guard_at) && scope.contains(&test_at) && scope.contains(&call_at), + "{what}: guard, 1:4 test and dispatch must share one enclosing function" ); } // And the inter route really is the only one: `strip16` is built from diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 87b5db5a..8c01ad6b 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -2915,6 +2915,82 @@ pub(crate) mod tests { ); } + /// lane-av1subsizesweep: the FRAME-EDGE walk of a BLOCK_INVALID subsize, + /// pinned. This is the one install site the partition-symbol guards missed, + /// and the sibling pin above cannot see it -- that pin's 8x16 comes from a + /// 16x16-level `PARTITION_VERT_B` (an interior AB strip, refused at + /// decode.rs:36472), while this pin's comes from the key-frame 16-level + /// FRAME-EDGE arm, which is not a `dec.symbol(` site at all: it reads one + /// gathered bit with `dec.symbol_fixed(&gather(..))` and dispatches + /// `decode_leaf_rect` straight off it. + /// + /// `422_header_edge16_walk.obu` (128 bytes, sha256 + /// `e8ab2bb229896f796cdec4d2cb383b41f057ef8d364da30f160a3f55a452657f`, + /// fnv1a64 `0xcfa2394ebe1f7764`) is a 4:2:2 sequence header over a 4:2:0 + /// key frame's tile, at 88x64. Width 88 is 8 mod 16, so the last 16x16 + /// column block is COLUMN-short and the frame-edge arm fires; height 64 is + /// 16-aligned, so the ROW is not short and the both-cut arm is not taken. + /// The gathered bit names `PARTITION_VERT`, so the strip is `BLOCK_8X16`. + /// + /// libaom's own verdict, which is the rule this pin pins: + /// + /// ```text + /// $ aomdec --rawvideo -o /dev/null fixtures/422_header_edge16_walk.obu + /// Warning: Failed to decode frame 1: Corrupt frame detected + /// Warning: Additional information: Block size 8x16 invalid with this subsampling mode + /// ``` + /// + /// What makes this pin different from every other refusal gate in this file + /// is that the 8x16 is the ONLY offending subsize in the stream. Measured + /// over a 260-candidate sweep (4 card textures x 5 quantizers x 13 declared + /// widths), this is the one candidate whose decode with the guard removed + /// SUCCEEDS: with the `refuse_invalid_subsize` at decode.rs:37098 deleted, + /// this decoder returned a full 88x64 picture where libaom refuses the + /// frame. So the guard is not a redundant second refusal here -- it is the + /// only thing between a corrupt frame and a plausible-looking decode. + #[test] + fn a_422_header_whose_only_invalid_subsize_is_the_16_level_frame_edge_walk_is_refused() { + const NAME: &str = + "a_422_header_whose_only_invalid_subsize_is_the_16_level_frame_edge_walk_is_refused"; + let _gate_lock = lock_gate_counters(); + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("fixtures") + .join("422_header_edge16_walk.obu"); + let pinned = read_pin(&path, 128, 0xcfa2394ebe1f7764, NAME); + // The shape must be the one this lane's arm carries: if the pin ever + // stops being an 8x16 strip the refusal is coming from somewhere else + // and this gate is measuring the wrong thing. + assert!( + !crate::decode::chroma_plane_block_codable(8, 16, 1, 0), + "{NAME}: BLOCK_8X16 must be BLOCK_INVALID at 4:2:2 -- this gate's whole \ + subject is `av1_ss_size_lookup[BLOCK_8X16][1][0] == BLOCK_INVALID`" + ); + assert!( + crate::decode::chroma_plane_block_codable(16, 8, 1, 0), + "{NAME}: the 16x8 mirror MUST stay legal at 4:2:2 (BLOCK_8X8) -- it is what \ + keeps the new guard from refusing the sibling arm's strip" + ); + let err = decode_stream(&pinned) + .err() + .unwrap_or_else(|| panic!("{NAME}: the pin must be REFUSED, not decoded")); + let msg = err.to_string(); + assert!( + msg.contains("invalid with this subsampling mode"), + "{NAME}: the refusal must name libaom's rule (its own wording), got: {msg}" + ); + // Positive control: a genuine 4:2:2 stream must still decode, so this + // gate cannot pass by refusing everything. + let ok_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("fixtures") + .join("422_key_64x64.obu"); + let ok = decode_stream(&std::fs::read(&ok_path).expect("the 4:2:2 control fixture")) + .unwrap_or_else(|e| panic!("{NAME}: a genuine 4:2:2 pin must still decode: {e}")); + assert!( + !ok.is_empty(), + "{NAME}: the 4:2:2 control decoded no frames" + ); + } + /// lane-av1-422bigblock: the two witnessed 4:2:2 big-block defects, pinned /// as fixtures (`git add -f`; `fixtures/` is gitignored). /// diff --git a/lanes/av1subsizesweep.report.md b/lanes/av1subsizesweep.report.md index f7e09e81..2c3924e9 100644 --- a/lanes/av1subsizesweep.report.md +++ b/lanes/av1subsizesweep.report.md @@ -3,236 +3,277 @@ Base `main` = `e45cc748` ("Merge lane/av1unwritten: refuse the subsize libaom calls corrupt"). Worktree `~/.cache/wt/av1subsizesweep`, own `CARGO_TARGET_DIR=~/.cache/tgt/subsizesweep`. -## What the merged lane already covered (not redone) +## Headline: the find came from censusing WALK sites, not SYMBOL sites -`refuse_invalid_subsize` (`decode.rs:21489`) with `PLANE_BLOCK_INVALID_422` / -`PLANE_BLOCK_INVALID_440` transcribed cell-for-cell from `av1_ss_size_lookup` -(`common_data.c`), `partition_subsize_dims` as libaom's `get_partition_subsize` -reduced to dimensions, **11 guard call sites**, the structural test -`every_partition_symbol_resolution_is_guarded_before_it_dispatches`, and the -`EC_AV1_SUBSIZE_GUARD_TRACE` / `EC_AV1_SUBSIZE_ARM_TRACE` coverage artefacts. +The merged lane's gate enumerates partition-**symbol** sites. This lane enumerates +chroma-plane **walk** sites — every `decode_*` that reconstructs chroma from a +block's luma extent, with the footprints its dispatch can hand it — and that +reframing is what found the hole. A symbol-site census cannot see a subsize that +arrives without a partition symbol at all, and it cannot see a subsize that +arrives through a *differently spelled* symbol read. -Its named residue: `decode_rect4_16_intrabc`. +Concretely: the key-frame 16-level **frame-edge** arm reads one gathered bit with +`dec.symbol_fixed(&gather(..))` and dispatches `decode_leaf_rect` **directly** on +it. The merged scan's read test was the literal `dec.symbol(`, and +`dec.symbol(` is not a substring of `dec.symbol_fixed(`. Every sibling edge arm +resolves into a `partN` the level's guard sees; this one did not. -## The hole this lane found: the key-frame 16-level FRAME-EDGE arm +## The hole, and the fix -`decode.rs:37034-37067` (pre-fix numbering) is the **one** partition read in the -file that dispatches on its own symbol instead of resolving it into a `partN` the -level's guard covers. - -| | reads | resolves to | guarded? | +| | reads | resolves to | guarded before? | |---|---|---|---| -| 128-root edge (`35551`/`35559`) | `symbol_fixed(&gather(..))` | `PARTITION_SPLIT`/`HORZ`/`VERT` | yes — `refuse_invalid_subsize((128,128), part128)` at `35588` | -| 64-level edge (`36239`/`36256`) | same | same | yes — `(64,64)` guard at `36278` | -| 32-level edge (`36363`/`36383`) | same | same | yes — `(32,32)` guard at `36406` | -| **16-level edge (kf)** | same | **`edge_split`, straight into `decode_leaf_rect`** | **NO — nothing on the path** | -| 16-level edge (inter, `54767`/`54780`) | same | `part16` | yes — `(16,16)` guard at `54799` | +| 128-root edge (`35559`/`35567`) | `symbol_fixed(&gather(..))` | `SPLIT`/`HORZ`/`VERT` | yes — `refuse_invalid_subsize((128,128), part128)` at `35596` | +| 64-level edge (`36247`/`36264`) | same | same | yes — `(64,64)` at `36286` | +| 32-level edge (`36371`/`36391`) | same | same | yes — `(32,32)` at `36414` | +| **16-level edge (key frame, `37043`/`37048`)** | same | **`edge_split`, straight into `decode_leaf_rect`** | **NO — nothing on the path** | +| 16-level edge (inter, `54777`/`54790`) | same | `part16` | yes — `(16,16)` at `54809` | With `has_cols16 == false` the strip is `BLOCK_8X16`, whose `(1,0)` chroma plane -block is `BLOCK_INVALID` (`av1_ss_size_lookup`, `common_data.c:20`). At 4:2:2 that -is a subsize libaom refuses at `decodeframe.c:1456`, and this decoder walked it -into `decode_leaf_rect` anyway. With `has_cols16 == true` the strip is `16x8` — -`BLOCK_8X16`'s mirror, whose `(1,0)` cell is `BLOCK_8X8` — and **must** keep -decoding. - -Why the merged lane's structural test could not see it: the scan keys on -`dec.symbol(` (line 56698), and this arm reads `dec.symbol_fixed(&gather(..))`. -Every other edge read is either invisible for the same reason or resolves into a -guarded `partN`; only this one both dispatches directly *and* carries an -INVALID shape. - -**Fix** (`decode.rs:37063-37109`): the guard sits on the arm's own path, named by -LEVEL not by a hand-picked shape — the gathered bit resolves to -`PARTITION_HORZ` when the columns are full and `PARTITION_VERT` when they are -not, and `refuse_invalid_subsize((16,16), edge_part, …)` reduces that through the -same `partition_subsize_dims` every other site uses. A `note_subsize_arm` census -line was added alongside, per the merged lane's convention. +block is `BLOCK_INVALID` (`av1_ss_size_lookup`, `common_data.c:20`). At 4:2:2 this +walked a subsize libaom refuses at `decodeframe.c:1456`. With `has_cols16 == true` +the strip is `16x8` — `BLOCK_8X16`'s mirror, whose `(1,0)` cell is `BLOCK_8X8` — +and **must** keep decoding. + +**Fix** (`decode.rs:37101-37119`): the guard sits on the arm's own path and names +the LEVEL, not a shape — the gathered bit resolves to `PARTITION_HORZ` when the +columns are full and `PARTITION_VERT` when they are not, and +`refuse_invalid_subsize((16,16), edge_part, …)` reduces that through the same +`partition_subsize_dims` every other site uses. A `note_subsize_arm` census line +was added alongside, per the merged lane's convention. + +### Reachability, stated separately from the guard's correctness + +There **is** a witness, and it is the only offending subsize in its stream. +`crates/ec-av1/fixtures/422_header_edge16_walk.obu` (128 bytes, sha256 +`e8ab2bb229896f796cdec4d2cb383b41f057ef8d364da30f160a3f55a452657f`, fnv1a64 +`0xcfa2394ebe1f7764`) is a 4:2:2 sequence header over a 4:2:0 key frame's tile at +88x64. Width 88 is 8 mod 16 → the last 16x16 column block is column-short, so the +frame-edge arm fires; height 64 is 16-aligned, so the row is not short and the +both-cut arm is not taken. The gathered bit names `PARTITION_VERT`, so the strip +is `BLOCK_8X16`. + +libaom's own verdict: + +```text +$ aomdec --rawvideo -o /dev/null fixtures/422_header_edge16_walk.obu +Warning: Failed to decode frame 1: Corrupt frame detected +Warning: Additional information: Block size 8x16 invalid with this subsampling mode +``` + +The three-way measurement, which is the part that matters: + +| build | this decoder | +|---|---| +| with the guard | REFUSED, naming libaom's rule — agrees with `aomdec` | +| **guard deleted** | **`OK: 1 frames decoded, 88x64`** — a full picture from a frame libaom calls corrupt | +| libaom | refuses | + +So the guard is load-bearing, not a redundant second refusal, and the gate +`a_422_header_whose_only_invalid_subsize_is_the_16_level_frame_edge_walk_is_refused` +reds when the guard is deleted (verified). + +**Severity: a false-accept, not a pixel divergence.** libaom refuses the whole +frame, so there is no "correct" pixel output to diverge from; the defect is that we +returned plausible-looking pixels for a corrupt frame. No legal 4:2:2 stream is +affected — the shape only reaches stream data through a hostile or mismatched +header, which is the same exposure the merged lane's guards already carry. + +**The earlier "no witness" claim in this lane was wrong, and so was its +explanation.** The first sweep (45 aomenc-encoded 4:2:2 streams) never reached the +arm, and I attributed that to `partition_rect_allowed`. That mechanism governs the +encoder's partition *search*; this arm's partition comes from a single gathered +bit after a frame-edge geometry test, so `partition_rect_allowed` does not explain +it — the real reason aomenc never produced a witness is **not known**. The +witness exists, but it had to be built from this crate's own encoder with a +**declared** width (`encode_key_frame_at_size`, the `gen_coverage_cells.rs` cell-2 +construction) and then re-headered, because aomenc rounds the coded size to even +and never declares 88. ## The named residue: `decode_rect4_16_intrabc` — CLOSED, not guarded a third time -Its concrete code shape is `decode.rs:18336-18337`: +Its concrete code shape is `decode.rs:18334-18337`: ```rust let (cw, ch) = if own_chroma { (bw >> ss_x(fctx), bh >> ss_y(fctx)) } - else { (pw / 2, ph / 2) }; // <- hardcoded both-axes halving + else { (pw / 2, ph / 2) }; // both axes halved ``` `own_chroma = own444 || own422`, and `own422 = ss_x == 1 && ss_y == 0 && horz` (`18317`). A **VERT** strip at `ss (1,0)` is therefore neither `own444` nor -`own422`, falls to the `else`, and derives `pw,ph = (8,16)` → `cw,ch = (4,8)` — -a `BLOCK_4X8` plane block, itself `BLOCK_INVALID` at `(1,0)`. Same for the +`own422`, falls to the `else`, and derives `pw,ph = (8,16)` → `cw,ch = (4,8)` — a +`BLOCK_4X8` plane block, itself `BLOCK_INVALID` at `(1,0)`. Same for the `(pair_mi.1 * MI / 2, pair_mi.0 * MI / 2)` origin at `18354`. It is dead, and the reason is derived rather than read: -1. `decode_rect4_16_intrabc` has exactly **one** caller (`decode_rect4_16_strip`, - `18934`). -2. `decode_rect4_16_strip` has exactly **two** (`17595` from `decode_rect4_16`, - `13810` from `decode_intra_rect_in_inter`). -3. `decode_rect4_16` (`36793`) and `decode_intra_rect_in_inter` (`45447`, reached - only when `fctx.inter_strip_chroma` is set — one writer, `55116`) are both - **16x16-level 1:4 arms**, and both sit above a - `refuse_invalid_subsize((16, 16), part16, …)`. -4. `partition_subsize_dims((16,16), PARTITION_VERT_4) == (4,16)`, and `(4,16)` is - in `PLANE_BLOCK_INVALID_422`. So the guard refuses the **only** shape that - could reach the bad arm. -5. `PARTITION_HORZ_4` gives `(16,4)`, whose `(1,0)` cell is `BLOCK_8X4` and is - legal — so the strip that survives is the one `own422` is written for, and - `refuse_invalid_subsize` does not over-refuse. - -Items 1–5 are asserted in -`every_chroma_walking_leaf_dispatch_is_guarded_or_closed_with_a_reason` (4 and 5 -derived from the real predicate; 1–3 from counted call sites plus the ordering of -guard < 1:4-arm test < dispatch on each of the two routes). It is closed as -**guarded-at-resolution**, not `unreachable`: the site *is* handable an INVALID -subsize in principle, and what makes it safe is a guard one level up. +1. `decode_rect4_16_intrabc` has exactly **one** caller (`decode_rect4_16_strip`, `18934`). +2. `decode_rect4_16_strip` has exactly **two** (`17595` from `decode_rect4_16`, `13810` from `decode_intra_rect_in_inter`). +3. `decode_rect4_16` (`36801`) and `decode_intra_rect_in_inter` (`45457`, reached only when `fctx.inter_strip_chroma` is set — one writer, `55126`) are both **16x16-level 1:4 arms**, each above a `refuse_invalid_subsize((16, 16), part16, …)`. +4. `partition_subsize_dims((16,16), PARTITION_VERT_4) == (4,16)`, and `(4,16)` is in `PLANE_BLOCK_INVALID_422`. The guard refuses the **only** shape that could reach the bad arm. +5. `PARTITION_HORZ_4` gives `(16,4)`, whose `(1,0)` cell is `BLOCK_8X4` and is legal — so the strip that survives is the one `own422` is written for. + +Classified **guarded-at-resolution**, not `unreachable`: the site *is* handable an +INVALID subsize in principle, and a guard one level up is what makes it safe. ## Census table -`guard` = the `refuse_invalid_subsize` that covers the walk. "shape@mode" lists the -footprints the walk is handed and the subsampling mode at which libaom marks them -`BLOCK_INVALID`. Offending shapes at 4:2:2 `(1,0)`: **4x8, 8x16, 4x16, 8x32, -16x32, 16x64, 32x64, 64x128**. 4:4:0 `(0,1)` is excluded throughout — libaom -asserts `subsampling_y == 0` when `subsampling_x == 0`, so no frame can select -it. +`guard` = the `refuse_invalid_subsize` that covers the walk. Offending shapes at +4:2:2 `(1,0)`: **4x8, 8x16, 4x16, 8x32, 16x32, 16x64, 32x64, 64x128**. 4:4:0 +`(0,1)` is excluded throughout — libaom's `color_config` asserts +`subsampling_y == 0` when `subsampling_x == 0`, so no frame can select it. -| # | site | shapes | offending @mode | guard | mechanism | evidence | +| # | site | shapes | offending @mode | guard | mechanism | checked by | |---|---|---|---|---|---|---| -| 1 | `decode_leaf_rect` **kf 16-edge** (`37067`) | 16x8, **8x16** | 8x16@(1,0) | `refuse_invalid_subsize((16,16), edge_part)` **added this lane** | AtDispatch | census row + ordering assert; mutations A/B red | -| 2 | `decode_rect4_16_intrabc` (`18232`) | 16x4, **4x16** | 4x16@(1,0) | `(16,16)` @ `36472` (kf) / `54799` (inter) | AtResolution | derived VERT_4→(4,16) + caller count, census part (d)/(f) | -| 3 | `decode_rect4_16` (`17552`) | 16x4, 4x16 | 4x16@(1,0) | same `(16,16)` guards | AtResolution | single caller `36793`, under the 1:4 arm | -| 4 | `decode_rect4_16_strip` (`18862`) | 16x4, 4x16 | 4x16@(1,0) | same | AtResolution | callers `17595`, `13810`, both 1:4 | -| 5 | `decode_block_rect` (`15596`) | 32x16, **16x32** | 16x32@(1,0) | `(32,32)` @ `36406` / `54653` | AtResolution | 32-level HORZ/VERT arms | -| 6 | `decode_block_rect4` (`16764`) | 32x8, **8x32** | 8x32@(1,0) | `(32,32)` @ `36406` / `54653` | AtResolution | 32-level HORZ_4/VERT_4 arms | -| 7 | `decode_block_rect64` (`19851`) | 64x16, **16x64** | 16x64@(1,0) | `(64,64)` @ `36278` / `54269` | AtResolution | 64-level 1:4 arms | -| 8 | `decode_block_128rect` (`23921`) | 128x64, **64x128** | 64x128@(1,0) | `(128,128)` @ `35588` / `54032` | AtResolution | 128-root HORZ/VERT + all four AB arms | -| 9 | `decode_rect_split` (`12420`) | 32x16, 16x32, 64x16, 16x64 | all four | inherited from callers 5/7 | AtResolution | 4 call sites, all under 5–8 | -| 10 | `decode_leaf_rect` **AB arms** (`36599`, `36688`, `36737`, `36756`) | 16x8, **8x16** | 8x16@(1,0) | `(16,16)` @ `36472` — `partition_subsize_dims((16,16), VERT_A/B) == (8,16)` | AtResolution | guard is above the AB range, never inside it (merged lane's AB invariant) | -| 11 | `decode_leaf_rect8` (`27733`) | 8x4, **4x8** | 4x8@(1,0) | `(8,8)` @ `36882` / `37179`, plus the redundant inline check at `36904` | AtResolution | both 8x8 resolutions | -| 12 | `decode_inter_sub8_rect2` (`48863`) | 8x4, **4x8** | 4x8@(1,0) | `(8,8)` @ `55211` | AtResolution | inter 8x8 level | -| 13 | `decode_leaf_split4` (`27044`) | 4x4 | none | none needed | unreachable | 4x4's plane block is 4x4 in **every** cell | -| 14 | `decode_inter_sub8_split4` (`46999`) | 4x4 | none | none needed | unreachable | same | -| 15 | `decode_leaf8` (`24413`) | 8x8 | none | none needed | unreachable | 8x8 → 8x8/4x8/4x4, never INVALID | -| 16 | `decode_inter_block8` (`50045`) | 8x8 | none | none needed | unreachable | same | -| 17 | `decode_block` (`22475`) | squares only | none | none needed | unreachable | every square's plane block is valid at **every** selectable mode; the whole BLOCK_INVALID column is rect | -| 18 | `decode_inter_block` (`41372`) | squares only | none | none needed | unreachable | same | -| 19 | `read_sb128_root` (`35493`) | 128x128 root | none itself | own `(128,128)` guard at `35588` | AtResolution | covers rows 5–8 upstream | - -**Rows not closed: none.** Every row is either guarded (1–12, 19) or needs no -guard because the shape is codable at every selectable subsampling mode (13–18). +| 1 | `decode_leaf_rect` kf 16-edge (`37124`) | 16x8, **8x16** | 8x16@(1,0) | `(16,16)` `edge_part` **added this lane**, `37106` | AtDispatch | census ordering + the pinned fixture | +| 2 | `decode_rect4_16_intrabc` (`18232`) | 16x4, **4x16** | 4x16@(1,0) | `(16,16)` `36480` kf / `54809` inter | AtResolutionVia | derived VERT_4→(4,16), per-route ordering loop | +| 3 | `decode_rect4_16` (`17552`) | 16x4, 4x16 | 4x16@(1,0) | `(16,16)` `36480` | AtResolution | row-scoped guard + ordering | +| 4 | `decode_rect4_16_strip` (`18862`) | 16x4, 4x16 | 4x16@(1,0) | `(16,16)` `36480` | AtResolutionVia | guard-in-scope + per-route loop | +| 5 | `decode_block_rect` (`15596`) | 32x16, **16x32** | 16x32@(1,0) | `(32,32)` `36414` / `54663` | AtResolution | row-scoped guard + ordering | +| 6 | `decode_block_rect4` (`16764`) | 32x8, **8x32** | 8x32@(1,0) | `(32,32)` `36414` | AtResolution | row-scoped guard + ordering | +| 7 | `decode_block_rect4`[inter] | 32x8, **8x32** | 8x32@(1,0) | `(32,32)` `54663` | AtResolutionVia | guard-in-scope in the inter decoder | +| 8 | `decode_block_rect64` (`19851`) | 64x16, **16x64** | 16x64@(1,0) | `(64,64)` `36286` | AtResolution | row-scoped guard + ordering | +| 9 | `decode_block_rect64`[inter] | 64x16, **16x64** | 16x64@(1,0) | `(64,64)` `54279` | AtResolutionVia | guard-in-scope in the inter decoder | +| 10 | `decode_intra_rect_in_inter` (`13761`) | 16x8, **8x16**, 16x4, **4x16** | all four | `(16,16)` `54809` | AtResolutionVia | guard-in-scope + per-route loop | +| 11 | `decode_block_128rect` (`23929`) | 128x64, **64x128** | 64x128@(1,0) | `(128,128)` `35596` in `read_sb128_root` | AtResolutionVia | guard-in-scope | +| 12 | `decode_rect_split` (`12420`) | 32x16, 16x32, 64x16, 16x64 | all four | inherits from rows 5/7/8/9 | AtResolutionVia | guard-in-scope | +| 13 | `decode_leaf_rect` AB arms (`36599`, `36688`, `36737`, `36756`) | 16x8, **8x16** | 8x16@(1,0) | `(16,16)` `36480` — `partition_subsize_dims((16,16), VERT_A/B) == (8,16)` | AtResolution | guard is above the AB range, never inside it (merged lane's AB invariant) | +| 14 | `decode_leaf_rect8` (`27741`) | 8x4, **4x8** | 4x8@(1,0) | `(8,8)` `36890` / `37189`, plus the inline check at `36912` | AtResolution | row-scoped guard + ordering | +| 15 | `decode_inter_sub8_rect2` (`48920`) | 8x4, **4x8** | 4x8@(1,0) | `(8,8)` `55221` | AtResolution | row-scoped guard + ordering | +| 16 | `decode_leaf_split4` (`27052`) | 4x4 | none | none needed | unreachable | offending set asserted empty | +| 17 | `decode_inter_sub8_split4` (`47056`) | 4x4 | none | none needed | unreachable | offending set asserted empty | +| 18 | `decode_leaf8` (`24421`), `decode_inter_block8` (`50102`) | 8x8 | none | none needed | unreachable | offending set asserted empty | +| 19 | `decode_block` (`22483`), `decode_inter_block` (`41429`) | squares only | none | none needed | unreachable | every square's plane block is valid at every selectable mode; the whole BLOCK_INVALID column is rect | + +**Rows not closed: none.** Every row is guarded (1–15) or needs no guard because +the shape is codable at every selectable subsampling mode (16–19). + +## The merged lane's matcher gap, widened (r11) + +Its site list was incomplete **for a spelling, not for a shape**, so it would miss +the next differently-spelled read the same way. The read test is now derived: + +> a partition-symbol READ is a `dec.(..)` call whose **own argument list** +> names a `partition_w[` CDF. + +That is the whole definition and it needs no hand-list. `dec.symbol(..partition_w..)` +qualifies; the frame-edge gather's `dec.symbol_fixed(&gather(..partition_w..))` +qualifies; `dec.debug_state()` does not — it never names a partition CDF. A third +spelling is covered the day somebody writes it. The `var == "b"` skip is gone too: +edge reads are **sites** now, and instead of being skipped they must carry a guard +for their own level before the first chroma-walking dispatch that follows them. + +**A limitation, stated rather than hidden:** the definition is syntactic. A read +that reaches a `partition_w` CDF through a helper whose argument list does not +mention the CDF name would not be enumerated. There is no such call in this file +today, and the census's `AtDispatch` row covers the arm this gap actually hid. ## Evidence -**Guard fires on a live path, and does not over-refuse.** `EC_AV1_SUBSIZE_GUARD_TRACE` -on real `aomenc` 4:2:0 streams of exactly the shape that reaches the arm -(`testsrc2`, widths 40/72/104/136, `h=120`, `--min-partition-size=4 ---max-partition-size=64 --sb-size=64`): +### The widening bites, and so does every guard the census claims + +Per-guard deletion, one at a time, by line number, against the census alone: + +| deleted | census | +|---|---| +| 35596 — 128-root (`read_sb128_root`) | RED — "NO such guard there" | +| 36286 — kf 64x64 | RED — "NO such guard in `decode_key_frame_tile_with_cdfs`" | +| 36414 — kf 32x32 | RED — same, naming `decode_block_rect` | +| 36472 — kf 16x16 | RED — ordering ("guard BELOW the dispatch") | +| 36890 — kf 8x8 (first) | RED — ordering, naming `decode_leaf_rect8` | +| 37106 — kf 16-level frame-edge arm | RED — "sits AFTER the `decode_leaf_rect` it protects" | +| 37106 — same guard, moved below the dispatch | RED — the r5 defect in a new place | +| 54279 — inter 64x64 | RED — names `decode_block_rect64[inter]` | +| 54663 — inter 32x32 | RED — names `decode_block_rect4[inter]` | +| 54809 — inter 16x16 | RED — names `decode_intra_rect_in_inter` | +| 55221 — inter 8x8 | RED — names `decode_inter_sub8_rect2` | + +**Two guards are claimed by LEVEL, not by site**, and the census stays green when +they are deleted — stated here rather than papered over: + +* **37189** — the key-frame 8x8 **second** resolution (the frame-edge straddle loop). +* **54042** — the inter decoder's own 128-root guard (the row claims the shared one in `read_sb128_root`). + +Both are caught by the merged scan's resolution-count cross-check +(`the decode body has 12 partition resolutions but only 11 guard sites`). A +per-site row for each would pin them individually; that is the obvious next +ratchet step and it is not in this lane. + +### Over-refusal control + +`EC_AV1_SUBSIZE_GUARD_TRACE` on real `aomenc` 4:2:0 streams of exactly the shape +that reaches the arm (`testsrc2`, widths 40/72/104/136, `h=120`, +`--min-partition-size=4 --max-partition-size=64 --sb-size=64`): ``` -SUBSIZE_GUARD site=.../decode.rs:37098 bsize=16x16 part=2 codable=true reached=2 -SUBSIZE_ARM site=.../decode.rs:37101 part=2 codable=true reached=2 +SUBSIZE_GUARD site=.../decode.rs:37106 bsize=16x16 part=2 codable=true reached=2 +SUBSIZE_ARM site=.../decode.rs:37109 part=2 codable=true reached=2 ``` -`part=2` is `PARTITION_VERT` — the 8x16 strip, the shape that is INVALID at -4:2:2. At 4:2:0 the guard reports `codable=true`, the frame decodes OK. The guard -is on a live path and refuses nothing it should not. - -**A real aomenc witness for the guard FIRING does not exist, and that is a -property of libaom, not a gap in the sweep.** 45 real 4:2:2 encodes were built -(`--i422`, `testsrc2`, 11 widths × 3 heights at cq 45, plus 12 -`--tune-content=screen --enable-intrabc=1 --enable-palette=1` encodes at cq 20; -widths chosen so the 16-level column is short, heights so it is the *only* short -axis). None reached `37098` at all. The reason is that aomenc's own -`partition_rect_allowed` is gated on the same `av1_ss_size_lookup` table (the -merged lane cites `partition_search.c:3383-3389`), so a conformant encoder -cannot emit a partition whose plane block is `BLOCK_INVALID`. The guard is -therefore a **hostile-stream** guard, in exactly the same class as the merged -lane's own `37171-37177` note ("Not corpus-reachable at ss(1,0) today, so it is -residue rather than live pixels, and it is guarded anyway"). No witness is -claimed. - -**Red-before-green on the new gate** (both mutations against -`every_chroma_walking_leaf_dispatch_is_guarded_or_closed_with_a_reason`): - -* delete `refuse_invalid_subsize((16,16), edge_part, …)` → RED, "dispatches - `decode_leaf_rect` on an 8x16 strip … with NO `refuse_invalid_subsize` on its path". -* move it **below** the `decode_leaf_rect` call (r5's defect in a new place) → - RED, "sits AFTER the `decode_leaf_rect` it protects -- it can never observe it". - -Restored; both green. - -**The gate caught two errors in my own census before it shipped** — recorded -because they are the class this lane exists to close: - -* it counted 4:4:0 `(0,1)` as a reachable offending mode and flagged `16x4` as - needing a guard. That is the merged lane's r2 mistake reproduced: refusing a - legal 4:2:2 shape by testing a cell no `color_config` can request. Fixed by - restricting the offending set to the selectable modes. -* it flagged `decode_block`/`decode_inter_block` as `AtResolution` when no shape - they walk is ever INVALID (squares only). Reclassified `unreachable`. - -**Named tests.** `cargo check --tests` clean. `cargo test -p ec-av1 --lib -- 422 -sub8 subsize chroma_422` → **27 passed, 0 failed** (52 s), including -`a_real_422_key_frame_and_inter_sequence_decode_pixel_exact`, -`the_pinned_422_corpus_cells_decode_pixel_exact`, -`the_pinned_422_bigblock_witnesses_decode_pixel_exact`, -`the_pinned_422_lossless_inter_witnesses_decode_pixel_exact`, -`the_pinned_422_intrabc_sb128_strip_witnesses_decode_pixel_exact`. -The three structural gates pass together. - -**Non-regression on the committed tree.** `cargo test -p ec-av1 --lib -- pixel_exact -byte_exact` → **270 passed, 0 failed** (818 s), on this lane's commit. This is the -over-refusal control at scale: the new guard sits on a live path (measured -reached with `part=2` at 4:2:0 above), and if it refused anything legal these -would go red. +`part=2` is `PARTITION_VERT` — the 8x16 strip, INVALID at 4:2:2. At 4:2:0 the +guard reports `codable=true` and the frame decodes: the guard is on a live path and +refuses nothing it should not. + +### Tests + +* `cargo check --tests` clean. +* `cargo test -p ec-av1 --lib -- 422 sub8 subsize chroma_422` — **27 passed, 0 failed** (52 s), including the pinned 4:2:2 corpus, bigblock, lossless-inter and intrabc-sb128 pixel-exactness gates. +* `cargo test -p ec-av1 --lib -- pixel_exact byte_exact` — **270 passed, 0 failed** (818 s). The over-refusal control at scale: if the new guard refused anything legal these would go red. +* The three structural gates pass together, plus the two hostile-pin refusal gates. ## Wider sweep — hardcoded chroma halvings, NAMED NOT FIXED (out of charter) -One wider finding **is inside** the residue and is covered by row 2: -`decode_rect4_16_intrabc`'s `else` arm at `18336-18337` / `18354` — the +One finding **is** inside the residue and is covered by row 2: +`decode_rect4_16_intrabc`'s `else` arm at `18334-18337` / `18354` — the `(pw / 2, ph / 2)` halving and the `(pair_mi.1 * MI / 2, pair_mi.0 * MI / 2)` origin — is a both-axes halving whose predicate (`own444 || own422`) does not -enumerate every reachable `(ss, shape)` cell. It is dead only because row 2's -guard refuses VERT_4 at 4:2:2. If that guard ever moves, this arm becomes the -live defect. +enumerate every reachable `(ss, shape)` cell. Dead only because row 2's guard +refuses VERT_4 at 4:2:2. If that guard moves, this arm becomes the live defect. -Outside the charter, named for the owning lanes. Provenance: every row below is -either read by me in the decode spine (rows 1, and the residue's `else` arm -above) or comes from a read-only source sweep run as part of this lane — the -line numbers were confirmed against the worktree, but nothing outside the -decode.rs partition/chroma walk was **reproduced by a probe here**. Rows marked -"not probed" should be re-measured by the lane that takes them. +Outside the charter, named for the owning lanes. Provenance: line numbers +confirmed against the worktree, but nothing outside the decode.rs +partition/chroma walk was **reproduced by a probe here**; rows marked "not probed" +should be re-measured by the lane that takes them. | site | what | consequence at 4:2:2 | |---|---|---| -| `decode.rs:21081` `cfl_ac_q3_at` | `let (cw, ch) = (bw / 2, bh / 2)` + 2×2 luma average | correct today only because `cfl_ac_ss` routes 4:2:2 elsewhere; held by the `cfl_ac_q3_at_hits` 4:2:0-only gate | -| `decode.rs:47516, 47908, 49484, 49930` | `mv_to_q4(, , ss_x(fctx))` — the **Y** axis shifted by `ss_x` | each currently masked by a guard pinning the format to one where `ss_x == ss_y` | -| `decode.rs:43251/43262, 43366` | `chroma_side * chroma_side` sizing in the mu-chroma composed grid, where at `ss (1,0)` the plane rect is `(side/2, side)` and a square `side/2` is too short on rows `>= side/2` | a scout finding from a source read; **not reproduced by a probe in this lane** — the lossless sibling of this path was already repaired to `chroma_stride`, these were not. Needs an owning lane with a 128-root 4:2:2 mu-chunk witness | -| `decode.rs:35700, 53411` | floor-`>>` chroma plane allocators | shape assumption at frame edges; scout finding, not probed here | +| `decode.rs:21081` `cfl_ac_q3_at` | `(bw / 2, bh / 2)` + 2×2 luma average | correct only because `cfl_ac_ss` routes 4:2:2 elsewhere; held by the `cfl_ac_q3_at_hits` 4:2:0-only gate | +| `decode.rs:47516, 47908, 49484, 49930` | `mv_to_q4(, , ss_x(fctx))` — the **Y** axis shifted by `ss_x` | each masked by a guard pinning the format to one where `ss_x == ss_y` | +| `decode.rs:43251/43262, 43366` | `chroma_side * chroma_side` sizing in the mu-chroma composed grid; at `ss (1,0)` the plane rect is `(side/2, side)` and a square `side/2` is too short on rows `>= side/2` | not probed; the lossless sibling was repaired to `chroma_stride`, these were not. Needs an owning lane with a 128-root 4:2:2 mu-chunk witness | +| `decode.rs:35708, 53419` | floor-`>>` chroma plane allocators | shape assumption at frame edges; not probed | | `encode.rs:1674-1687, 1862-1863, 7477/7483, 7928/7934, 8215/8221, 9295-9315` | every chroma plane/stride/crop at `width / 2` with no ss term | correct only because the encoder emits 4:2:0 exclusively; `obmc_plan` (`7362`) passes real `ss_x`/`ss_y` next to a `side / 2` stride, so two conventions meet there | -| `tile.rs:5004-5006` (`fn palette_uv_side`) | `palette_uv_side = (side / 2).max(4)` | 4:2:2/4:4:0 palette map mis-sized | +| `tile.rs:5004-5006` (`fn palette_uv_side`) | `(side / 2).max(4)` | 4:2:2/4:4:0 palette map mis-sized | | `stream.rs:6672, 6773, 17075` + `probe.rs:81` | ffmpeg rawvideo oracle slices chroma at `width * height / 4` | **the dangerous ones**: a future 4:2:2 gate using them compares half the oracle's bytes and passes green. The `_422_depth`/`_444` siblings exist and are correct; the 4:2:0 trio is unguarded against the wrong format | | `encode.rs:1595-1616` (`Picture::grey`/`check`), `1605`, `1658`, `1852` | every test card's chroma allocated and asserted at `width * height / 4` | the crate's test surface is 4:2:0-sized before any test code runs | -| `decode.rs:59012, 59031, 59284-59304` | test-card chroma + `PlaneBuf` test harness at `width/2`, `height/2` | same | +| `decode.rs:58989, 59008, 59261-59281` | test-card chroma + `PlaneBuf` test harness at `width/2`, `height/2` | same | | `examples/gen_coverage_cells.rs:94-96`, `examples/syntax_census.rs` | quarter-plane chroma arithmetic | same | `mc.rs`, `intra.rs`, `transform.rs`, `compound.rs` are clean — plane dims arrive as parameters. `restoration.rs` and `film_grain.rs` are per-axis and correct. `motion_field.rs:74`'s `/ 2` is the 8×8 MV-cell grid, not a chroma extent. +## Housekeeping + +An early edit of this lane leaked into the primary checkout through a relative +path and was reverted before any commit (`git checkout --` on the one file it +touched); a second leak, the `stream.rs` gate, was caught the same way. The +primary checkout is clean at every commit on this branch, and no commit here +contains either hunk. + ## Not closed, stated plainly -1. **No aomenc witness proves the new guard FIRES**, because libaom's encoder - cannot emit the symbol (§ Evidence). The red-before-green proof for the guard - is mutation-based, not corpus-based. This is the same limitation the merged - lane's guards carry and is not fixable from this side. -2. **The structural gate is a derived site list, not a proof.** It pins the - mechanism for 19 walks and the guard ordering for the hole, but it cannot see - a walk that is neither named in the census nor reachable through a +1. **The structural gate is a derived site list, not a proof.** It pins the + mechanism for 19 walks and guard ordering for the hole, but it cannot see a + walk that is neither named in the census nor reachable through a `partition_w` read — e.g. a future site fed a block shape from a - non-partition source. The census is a ratchet, not a proof. -3. **`decode_rect4_16_intrabc`'s `else` arm is still wrong in isolation.** It is - closed by reachability, not by construction. Closing it by construction would - mean making the arm `unreachable!("...")` at `ss (1,0) && !horz` — deliberately - not done here, because that would assert a property of the callers from inside - the callee and break the moment the arm gains a legal 4:2:2 VERT_4 use. \ No newline at end of file + non-partition source. The census is a ratchet. +2. **Two guards are level-claimed, not site-claimed** (kf 8x8 second resolution, + inter 128-root). The merged scan's count cross-check is what reds them. +3. **The read-spelling derivation is syntactic.** A read reaching a `partition_w` + CDF through a helper that does not mention the CDF name would not be enumerated. +4. **`decode_rect4_16_intrabc`'s `else` arm is still wrong in isolation** — closed + by reachability, not construction. Closing it by construction would mean + asserting a caller property from inside the callee, and breaking the moment the + arm gains a legal 4:2:2 VERT_4 use. +5. **Why aomenc never produces this shape is unknown.** The witness had to be + built from this crate's own encoder with a declared width. See the reachability + section — the earlier `partition_rect_allowed` explanation was wrong. \ No newline at end of file