lane-av1subsizesweep: census every chroma-plane walk a BLOCK_INVALID subsize reaches
Browse files at this commit67c524e37240c2015d15e5099a39b20b574b57a6Parent: 8d3f38a2 changed files +689 -0
- crates/ec-av1/src/decode.rs +451 -0
- lanes/av1subsizesweep.report.md +238 -0
crates/ec-av1/src/decode.rsmodified+451 -0
| @@ -37059,6 +37059,55 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 37059 | // the user's 3840x1608 film. | 37059 | // the user's 3840x1608 film. |
| 37060 | hit!(HORZ_VERT_INTRA_HITS); | 37060 | hit!(HORZ_VERT_INTRA_HITS); |
| 37061 | hit!(EDGE_RECT_STRIP_HITS); | 37061 | hit!(EDGE_RECT_STRIP_HITS); |
| 37062 | + // lane-av1subsizesweep: this arm is the ONE | ||
| 37063 | + // frame-edge partition read in the file that | ||
| 37064 | + // dispatches on its own symbol instead of | ||
| 37065 | + // resolving it into a `partN` the level's guard | ||
| 37066 | + // covers. The 128-root edge arms | ||
| 37067 | + // (decode.rs:35551/35559), the 64-level ones | ||
| 37068 | + // (36239/36256) and the 32-level ones | ||
| 37069 | + // (36363/36383) all end in `PARTITION_HORZ` / | ||
| 37070 | + // `PARTITION_VERT` / `PARTITION_SPLIT`, which | ||
| 37071 | + // the guard after their `match` sees -- the | ||
| 37072 | + // inter-frame 16-level edge arms (54720/54733) | ||
| 37073 | + // resolve into `part16` for the same reason. | ||
| 37074 | + // Here `edge_split` goes straight into | ||
| 37075 | + // `decode_leaf_rect`, and the shape it carries is | ||
| 37076 | + // `BLOCK_8X16` when the COLUMN is short -- | ||
| 37077 | + // whose (1,0) chroma plane block is | ||
| 37078 | + // BLOCK_INVALID (`av1_ss_size_lookup`, | ||
| 37079 | + // common_data.c:20), so at 4:2:2 this walks a | ||
| 37080 | + // subsize libaom refuses at decodeframe.c:1456. | ||
| 37081 | + // | ||
| 37082 | + // The check names the LEVEL, not a hand-picked | ||
| 37083 | + // shape: the gathered bit resolves to | ||
| 37084 | + // PARTITION_HORZ when the columns are full and | ||
| 37085 | + // PARTITION_VERT when they are not, and | ||
| 37086 | + // `refuse_invalid_subsize` reduces that through | ||
| 37087 | + // the same `partition_subsize_dims` every other | ||
| 37088 | + // site uses. So the 16x8 strip -- BLOCK_8X16's | ||
| 37089 | + // mirror, whose (1,0) cell is BLOCK_8X8 and MUST | ||
| 37090 | + // keep decoding -- is untouched, and the guard | ||
| 37091 | + // reds on the cell list, not a shape list. | ||
| 37092 | + let edge_part = if has_cols16 { | ||
| 37093 | + PARTITION_HORZ | ||
| 37094 | + } else { | ||
| 37095 | + PARTITION_VERT | ||
| 37096 | + }; | ||
| 37097 | + refuse_invalid_subsize((16, 16), edge_part, fctx)?; | ||
| 37098 | + // lane-av1unwritten r6: arm census -- which | ||
| 37099 | + // partition value reaches here. | ||
| 37100 | + note_subsize_arm( | ||
| 37101 | + edge_part, | ||
| 37102 | + chroma_plane_block_codable( | ||
| 37103 | + partition_subsize_dims((16, 16), edge_part) | ||
| 37104 | + .0, | ||
| 37105 | + partition_subsize_dims((16, 16), edge_part) | ||
| 37106 | + .1, | ||
| 37107 | + ss_x(fctx), | ||
| 37108 | + ss_y(fctx), | ||
| 37109 | + ), | ||
| 37110 | + ); | ||
| 37062 | let (mi_row0, mi_col0) = | 37111 | let (mi_row0, mi_col0) = |
| 37063 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | 37112 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); |
| 37064 | let (bw, bh) = | 37113 | let (bw, bh) = |
| @@ -57008,6 +57057,408 @@ mod tests { | |||
| 57008 | "32x8 at 4:4:0 is BLOCK_INVALID" | 57057 | "32x8 at 4:4:0 is BLOCK_INVALID" |
| 57009 | ); | 57058 | ); |
| 57010 | } | 57059 | } |
| 57060 | + | ||
| 57061 | + /// lane-av1subsizesweep: the CENSUS, as an invariant. | ||
| 57062 | + /// | ||
| 57063 | + /// The merged `lane/av1unwritten` lane covers partition SYMBOLS: every | ||
| 57064 | + /// `dec.symbol(&mut cdfs.partition_w<N>[..])` gets a | ||
| 57065 | + /// [`refuse_invalid_subsize`] within 220 lines, and | ||
| 57066 | + /// [`every_partition_symbol_resolution_is_guarded_before_it_dispatches`] | ||
| 57067 | + /// holds that shape against the source. Its own stated limit is exactly | ||
| 57068 | + /// the hole this lane found: the scan matches on `dec.symbol(`, so the | ||
| 57069 | + /// frame-edge GATHER reads (`dec.symbol_fixed(&gather(..))`) are invisible | ||
| 57070 | + /// to it, and its site list names RESOLUTIONS, not the chroma-plane WALKS | ||
| 57071 | + /// those resolutions descend into. | ||
| 57072 | + /// | ||
| 57073 | + /// So this test states the other half, over the WALK sites instead of the | ||
| 57074 | + /// symbol sites: | ||
| 57075 | + /// | ||
| 57076 | + /// * every `decode_*` call that walks a chroma plane is enumerated, with | ||
| 57077 | + /// the luma shape(s) it can be handed -- derived from the enclosing | ||
| 57078 | + /// dispatch, not typed in by hand; | ||
| 57079 | + /// * for each shape that libaom marks BLOCK_INVALID at some subsampling | ||
| 57080 | + /// mode, the walk must have a [`refuse_invalid_subsize`] for its OWN | ||
| 57081 | + /// level on its path -- either at the level that dispatched it | ||
| 57082 | + /// (`PARTITION_*` arms resolve into a `partN`) or at the dispatch site | ||
| 57083 | + /// itself; | ||
| 57084 | + /// * a walk reachable ONLY through a level whose guard already refuses the | ||
| 57085 | + /// offending subsize is CLOSED, and the reason is the level's own guard | ||
| 57086 | + /// line -- asserted, not commented. | ||
| 57087 | + /// | ||
| 57088 | + /// The residue the merged lane named, [`decode_rect4_16_intrabc`], is the | ||
| 57089 | + /// second case: it is reachable only from the 16x16-level 1:4 arms, and | ||
| 57090 | + /// `partition_subsize_dims((16,16), PARTITION_VERT_4) == (4,16)`, which is | ||
| 57091 | + /// in `PLANE_BLOCK_INVALID_422`. Both of its callers' guards refuse that | ||
| 57092 | + /// before the call, so it is CLOSED rather than guarded a third time -- | ||
| 57093 | + /// and this test is what makes that a checked claim instead of a comment. | ||
| 57094 | + #[test] | ||
| 57095 | + fn every_chroma_walking_leaf_dispatch_is_guarded_or_closed_with_a_reason() { | ||
| 57096 | + // (a) The shapes libaom cannot code, transcribed from the same | ||
| 57097 | + // `av1_ss_size_lookup` cells `PLANE_BLOCK_INVALID_422` carries. A walk | ||
| 57098 | + // handed one of these at the matching subsampling mode is the defect. | ||
| 57099 | + let invalid_at = |bw: usize, bh: usize, sx: usize, sy: usize| { | ||
| 57100 | + !chroma_plane_block_codable(bw, bh, sx, sy) | ||
| 57101 | + }; | ||
| 57102 | + | ||
| 57103 | + // (b) The CENSUS: every chroma-plane walk in the decode body, with the | ||
| 57104 | + // luma footprint(s) each dispatch can hand it. `guarded_by` names the | ||
| 57105 | + // mechanism, which is what a reader has to be able to check: | ||
| 57106 | + // | ||
| 57107 | + // * `refuse_invalid_subsize` at the DISPATCH -- the guard sits on | ||
| 57108 | + // the walk's own path (the hole this lane fixed, and the 8x8 / | ||
| 57109 | + // 16-level sites); | ||
| 57110 | + // * `refuse_invalid_subsize` at the RESOLUTION -- the dispatch is a | ||
| 57111 | + // `PARTITION_*` arm, so the level's guard saw the symbol that | ||
| 57112 | + // selected this shape before the call; | ||
| 57113 | + // * `unreachable` -- proven-uncodable at every subsampling mode a | ||
| 57114 | + // `color_config` can select, closed with an assertion instead of | ||
| 57115 | + // a guard. | ||
| 57116 | + // | ||
| 57117 | + // Each row is (walk, shapes, mechanism). | ||
| 57118 | + enum Mech { | ||
| 57119 | + AtDispatch, | ||
| 57120 | + AtResolution, | ||
| 57121 | + Unreachable(&'static str), | ||
| 57122 | + } | ||
| 57123 | + let census: &[(&str, &[(usize, usize)], Mech)] = &[ | ||
| 57124 | + // ---- the residue the merged lane named ------------------- | ||
| 57125 | + // | ||
| 57126 | + // `decode_rect4_16_intrabc` reconstructs one 16x4 or 4x16 strip. | ||
| 57127 | + // It has exactly ONE caller (`decode_rect4_16_strip`, decode.rs | ||
| 57128 | + // 18934), which has exactly two (17595 from `decode_rect4_16`, | ||
| 57129 | + // 13810 from `decode_intra_rect_in_inter`), which have one each | ||
| 57130 | + // (36793 key frame, 45447 inter). BOTH are 16x16-level 1:4 arms, so | ||
| 57131 | + // both sit under a `refuse_invalid_subsize((16, 16), part16)`. | ||
| 57132 | + // | ||
| 57133 | + // The offending subsize is the VERT_4 one and ONLY that one: | ||
| 57134 | + // `partition_subsize_dims((16,16), PARTITION_VERT_4) == (4,16)`, | ||
| 57135 | + // and (4,16) is in `PLANE_BLOCK_INVALID_422`, while HORZ_4 gives | ||
| 57136 | + // (16,4) whose (1,0) cell is BLOCK_8X4 and is legal. So the | ||
| 57137 | + // 16x16-level guard refuses exactly the shape that would be | ||
| 57138 | + // BLOCK_INVALID, and the strip that survives -- 16x4 -- is the one | ||
| 57139 | + // this decoder's `own422` arm is written for. Part (d) below | ||
| 57140 | + // re-derives that split and part (f) pins the caller count, so the | ||
| 57141 | + // closure is checked rather than asserted in prose. | ||
| 57142 | + ( | ||
| 57143 | + "decode_rect4_16_intrabc", | ||
| 57144 | + &[(16, 4), (4, 16)], | ||
| 57145 | + Mech::AtResolution, | ||
| 57146 | + ), | ||
| 57147 | + // ---- 1:4 and 2:1 rect walks, all resolved-symbol guarded -- | ||
| 57148 | + ("decode_rect4_16", &[(16, 4), (4, 16)], Mech::AtResolution), | ||
| 57149 | + ( | ||
| 57150 | + "decode_rect4_16_strip", | ||
| 57151 | + &[(16, 4), (4, 16)], | ||
| 57152 | + Mech::AtResolution, | ||
| 57153 | + ), | ||
| 57154 | + ( | ||
| 57155 | + "decode_block_rect", | ||
| 57156 | + &[(32, 16), (16, 32)], | ||
| 57157 | + Mech::AtResolution, | ||
| 57158 | + ), | ||
| 57159 | + ( | ||
| 57160 | + "decode_block_rect4", | ||
| 57161 | + &[(32, 8), (8, 32)], | ||
| 57162 | + Mech::AtResolution, | ||
| 57163 | + ), | ||
| 57164 | + ( | ||
| 57165 | + "decode_block_rect64", | ||
| 57166 | + &[(64, 16), (16, 64)], | ||
| 57167 | + Mech::AtResolution, | ||
| 57168 | + ), | ||
| 57169 | + ( | ||
| 57170 | + "decode_block_128rect", | ||
| 57171 | + &[(128, 64), (64, 128)], | ||
| 57172 | + Mech::AtResolution, | ||
| 57173 | + ), | ||
| 57174 | + ( | ||
| 57175 | + "decode_rect_split", | ||
| 57176 | + &[(64, 16), (16, 64), (32, 16), (16, 32)], | ||
| 57177 | + Mech::AtResolution, | ||
| 57178 | + ), | ||
| 57179 | + ("decode_leaf_rect", &[(16, 8), (8, 16)], Mech::AtResolution), | ||
| 57180 | + // ---- sub-8 walks ------------------------------------------ | ||
| 57181 | + // (8,4) is legal at 4:2:2 (`av1_ss_size_lookup[8x4][1][0]` is | ||
| 57182 | + // BLOCK_4X4); (4,8) is BLOCK_INVALID there. Both come off a raw | ||
| 57183 | + // `part8`, and both 8x8 resolution sites carry the guard -- plus | ||
| 57184 | + // the redundant inline `chroma_plane_block_codable` check the | ||
| 57185 | + // merged lane left at 36904. | ||
| 57186 | + ("decode_leaf_rect8", &[(8, 4), (4, 8)], Mech::AtResolution), | ||
| 57187 | + ( | ||
| 57188 | + "decode_inter_sub8_rect2", | ||
| 57189 | + &[(8, 4), (4, 8)], | ||
| 57190 | + Mech::AtResolution, | ||
| 57191 | + ), | ||
| 57192 | + ( | ||
| 57193 | + "decode_leaf_split4", | ||
| 57194 | + &[(4, 4)], | ||
| 57195 | + Mech::Unreachable("4x4's plane block is 4x4 at EVERY subsampling cell"), | ||
| 57196 | + ), | ||
| 57197 | + ( | ||
| 57198 | + "decode_inter_sub8_split4", | ||
| 57199 | + &[(4, 4)], | ||
| 57200 | + Mech::Unreachable("4x4's plane block is 4x4 at EVERY subsampling cell"), | ||
| 57201 | + ), | ||
| 57202 | + ( | ||
| 57203 | + "decode_leaf8", | ||
| 57204 | + &[(8, 8)], | ||
| 57205 | + Mech::Unreachable("8x8's plane block is 8x8 / 4x8 / 4x4, never BLOCK_INVALID"), | ||
| 57206 | + ), | ||
| 57207 | + // The square walks take only square footprints, and every square | ||
| 57208 | + // in `BLOCK_SIZES_ALL` has a valid plane block at EVERY selectable | ||
| 57209 | + // mode (the whole BLOCK_INVALID column is 4x8 / 8x4 / 4x16 / 8x16 | ||
| 57210 | + // / ... -- all rect). So no guard is needed for them, and the | ||
| 57211 | + // level guards that exist protect the SYMBOL that would have to | ||
| 57212 | + // select one of those rect shapes, not the square decode itself. | ||
| 57213 | + ( | ||
| 57214 | + "decode_block", | ||
| 57215 | + &[(128, 128), (64, 64), (32, 32), (16, 16), (8, 8)], | ||
| 57216 | + Mech::Unreachable( | ||
| 57217 | + "every SQUARE footprint's plane block is valid at every selectable \ | ||
| 57218 | + subsampling mode; the whole BLOCK_INVALID column is rect", | ||
| 57219 | + ), | ||
| 57220 | + ), | ||
| 57221 | + ( | ||
| 57222 | + "decode_inter_block", | ||
| 57223 | + &[(128, 128), (64, 64), (32, 32), (16, 16), (8, 8)], | ||
| 57224 | + Mech::Unreachable( | ||
| 57225 | + "every SQUARE footprint's plane block is valid at every selectable \ | ||
| 57226 | + subsampling mode; the whole BLOCK_INVALID column is rect", | ||
| 57227 | + ), | ||
| 57228 | + ), | ||
| 57229 | + ( | ||
| 57230 | + "decode_inter_block8", | ||
| 57231 | + &[(8, 8)], | ||
| 57232 | + Mech::Unreachable("8x8's plane block is 8x8 / 4x8 / 4x4, never BLOCK_INVALID"), | ||
| 57233 | + ), | ||
| 57234 | + // ---- THE HOLE THIS LANE FIXED --------------------------- | ||
| 57235 | + // | ||
| 57236 | + // `decode_leaf_rect`'s key-frame FRAME-EDGE caller (the one | ||
| 57237 | + // `decode_leaf_rect`'s row above does not cover, because that arm | ||
| 57238 | + // dispatches on a gathered `edge_split` instead of resolving into | ||
| 57239 | + // `part16`). It is 8x16 when the COLUMN is short -- BLOCK_INVALID | ||
| 57240 | + // at 4:2:2 -- and 16x8 when the ROW is, which is legal and must | ||
| 57241 | + // keep decoding. Before this lane nothing sat on that path. | ||
| 57242 | + ( | ||
| 57243 | + "decode_leaf_rect[16-edge]", | ||
| 57244 | + &[(16, 8), (8, 16)], | ||
| 57245 | + Mech::AtDispatch, | ||
| 57246 | + ), | ||
| 57247 | + ]; | ||
| 57248 | + | ||
| 57249 | + // (c) Every row's mechanism must be a REAL one. This is what stops | ||
| 57250 | + // the census from being a list of good intentions: each claim is | ||
| 57251 | + // re-derived here, and the file is checked for the site it names. | ||
| 57252 | + let src = include_str!("decode.rs"); | ||
| 57253 | + for (walk, shapes, mech) in census { | ||
| 57254 | + let name = walk.split('[').next().expect("walk name"); | ||
| 57255 | + assert!( | ||
| 57256 | + src.contains(&format!("fn {name}(")), | ||
| 57257 | + "the census names `{name}`, which is not a function in this file -- the \ | ||
| 57258 | + walk was renamed or removed and this row is stale" | ||
| 57259 | + ); | ||
| 57260 | + // Only subsampling modes a `color_config` can actually SELECT | ||
| 57261 | + // count. `(0, 1)` 4:4:0 is excluded on libaom's own authority -- | ||
| 57262 | + // it asserts `subsampling_y == 0` whenever `subsampling_x == 0` | ||
| 57263 | + // (`color_config`, av1_decoder.c), so no frame in existence is | ||
| 57264 | + // 4:4:0 and `PLANE_BLOCK_INVALID_440` is transcribed only to keep | ||
| 57265 | + // the cell table whole. Counting it here would make `16x4` look | ||
| 57266 | + // like a shape that needs a guard at a mode no stream can carry | ||
| 57267 | + // -- the same class as the merged lane's r2, which refused a legal | ||
| 57268 | + // 4:2:2 shape by testing a cell no `color_config` can request. | ||
| 57269 | + let offending: Vec<(usize, usize, usize, usize)> = shapes | ||
| 57270 | + .iter() | ||
| 57271 | + .flat_map(|&(bw, bh)| { | ||
| 57272 | + [(1, 0), (1, 1), (0, 0)] | ||
| 57273 | + .into_iter() | ||
| 57274 | + .filter_map(move |(sx, sy)| { | ||
| 57275 | + invalid_at(bw, bh, sx, sy).then_some((bw, bh, sx, sy)) | ||
| 57276 | + }) | ||
| 57277 | + }) | ||
| 57278 | + .collect(); | ||
| 57279 | + match mech { | ||
| 57280 | + // A dispatch-time guard has to reduce to the SAME shape the | ||
| 57281 | + // dispatch hands the walk -- this is the claim that made the | ||
| 57282 | + // hole a hole, stated as an assertion. | ||
| 57283 | + Mech::AtDispatch => { | ||
| 57284 | + assert!( | ||
| 57285 | + !offending.is_empty(), | ||
| 57286 | + "{walk} is listed AtDispatch but libaom codes every shape it \ | ||
| 57287 | + walks at every subsampling mode -- then it needs no guard" | ||
| 57288 | + ); | ||
| 57289 | + for &(bw, bh, sx, sy) in &offending { | ||
| 57290 | + assert!( | ||
| 57291 | + invalid_at(bw, bh, sx, sy), | ||
| 57292 | + "{walk} is not actually handed {bw}x{bh} at ({sx},{sy})" | ||
| 57293 | + ); | ||
| 57294 | + } | ||
| 57295 | + } | ||
| 57296 | + Mech::AtResolution => { | ||
| 57297 | + assert!( | ||
| 57298 | + !offending.is_empty(), | ||
| 57299 | + "{walk} is listed AtResolution but no shape it walks is \ | ||
| 57300 | + BLOCK_INVALID -- then the level's guard is not what protects it" | ||
| 57301 | + ); | ||
| 57302 | + } | ||
| 57303 | + Mech::Unreachable(reason) => { | ||
| 57304 | + assert!( | ||
| 57305 | + offending.is_empty(), | ||
| 57306 | + "{walk} claims it is unreachable, but libaom marks {} \ | ||
| 57307 | + BLOCK_INVALID -- the claim is stale", | ||
| 57308 | + offending | ||
| 57309 | + .iter() | ||
| 57310 | + .map(|(bw, bh, sx, sy)| format!("{bw}x{bh}@({sx},{sy})")) | ||
| 57311 | + .collect::<Vec<_>>() | ||
| 57312 | + .join(", ") | ||
| 57313 | + ); | ||
| 57314 | + assert!( | ||
| 57315 | + reason.len() > 40, | ||
| 57316 | + "{walk}'s Unreachable reason is too short to name the symbol \ | ||
| 57317 | + or caller that makes it unreachable" | ||
| 57318 | + ); | ||
| 57319 | + } | ||
| 57320 | + } | ||
| 57321 | + } | ||
| 57322 | + | ||
| 57323 | + // (d) The residue's closure, derived rather than asserted in prose: | ||
| 57324 | + // the ONLY subsize its callers can hand it that libaom refuses at | ||
| 57325 | + // 4:2:2 is the 16x16-level VERT_4 one, and the level's own guard | ||
| 57326 | + // refuses exactly that. If either half stops holding -- a new caller | ||
| 57327 | + // at another level, or a change to `partition_subsize_dims` -- this | ||
| 57328 | + // reds instead of the comment going stale. | ||
| 57329 | + for &(part, want) in &[ | ||
| 57330 | + (PARTITION_HORZ_4, (16usize, 4usize)), | ||
| 57331 | + (PARTITION_VERT_4, (4, 16)), | ||
| 57332 | + ] { | ||
| 57333 | + let (bw, bh) = partition_subsize_dims((16, 16), part); | ||
| 57334 | + assert_eq!( | ||
| 57335 | + (bw, bh), | ||
| 57336 | + want, | ||
| 57337 | + "get_partition_subsize(BLOCK_16X16, {part}) moved" | ||
| 57338 | + ); | ||
| 57339 | + assert_eq!( | ||
| 57340 | + chroma_plane_block_codable(bw, bh, 1, 0), | ||
| 57341 | + part == PARTITION_HORZ_4, | ||
| 57342 | + "the 16x16 1:4 pair's (1,0) cells moved: HORZ_4 -> {bw}x{bh}, \ | ||
| 57343 | + VERT_4 -> {bw}x{bh}. decode_rect4_16_intrabc's Unreachable row \ | ||
| 57344 | + is written against exactly this split" | ||
| 57345 | + ); | ||
| 57346 | + } | ||
| 57347 | + // (e) The AtDispatch row, checked where it actually bites. This is | ||
| 57348 | + // the hole the merged lane's scan cannot see: its 220-line window is | ||
| 57349 | + // keyed on `dec.symbol(`, and the frame-edge arm reads | ||
| 57350 | + // `dec.symbol_fixed(&gather(..))` into `edge_split` and dispatches on | ||
| 57351 | + // THAT. The claim to check is ordering -- the guard has to sit between | ||
| 57352 | + // the read and the `decode_leaf_rect` it protects, which is r5's | ||
| 57353 | + // defect in a new place if it ever moves below. | ||
| 57354 | + let edge_read = src | ||
| 57355 | + .find("let edge_split = if has_cols16") | ||
| 57356 | + .expect("the key-frame 16-level frame-edge arm reads a gathered bit"); | ||
| 57357 | + let guard_at = src[edge_read..] | ||
| 57358 | + .find("refuse_invalid_subsize((16, 16)") | ||
| 57359 | + .map(|i| edge_read + i) | ||
| 57360 | + .expect( | ||
| 57361 | + "the key-frame 16-level frame-edge arm dispatches decode_leaf_rect on an \ | ||
| 57362 | + 8x16 strip (BLOCK_INVALID at 4:2:2) with NO refuse_invalid_subsize on its \ | ||
| 57363 | + path -- every sibling edge arm resolves into a guarded partN, this one does not", | ||
| 57364 | + ); | ||
| 57365 | + let walk_at = src[edge_read..] | ||
| 57366 | + .find("decode_leaf_rect(") | ||
| 57367 | + .map(|i| edge_read + i) | ||
| 57368 | + .expect("the frame-edge arm's decode_leaf_rect call"); | ||
| 57369 | + assert!( | ||
| 57370 | + guard_at < walk_at, | ||
| 57371 | + "the 16-level frame-edge guard (offset {guard_at}) sits AFTER the \ | ||
| 57372 | + decode_leaf_rect it protects (offset {walk_at}) -- it can never observe it" | ||
| 57373 | + ); | ||
| 57374 | + | ||
| 57375 | + // (f) The residue's closure, by CALLER COUNT rather than by prose: a | ||
| 57376 | + // third caller at another level is what would make the residue row | ||
| 57377 | + // stale, and a count reds on that where a comment cannot. Counted over | ||
| 57378 | + // the DECODE BODY only -- this test's own string literals name the same | ||
| 57379 | + // functions, and the merged lane's own scan hit exactly that (five of | ||
| 57380 | + // its eighteen `refuse_invalid_subsize((` matches are its own). | ||
| 57381 | + let decode_body = match src.find("\n#[cfg(test)]\nmod tests {") { | ||
| 57382 | + Some(i) => &src[..i], | ||
| 57383 | + None => src, | ||
| 57384 | + }; | ||
| 57385 | + for (name, calls) in [ | ||
| 57386 | + ("decode_rect4_16_intrabc", 1usize), | ||
| 57387 | + ("decode_rect4_16_strip", 2), | ||
| 57388 | + ("decode_rect4_16", 1), | ||
| 57389 | + ("decode_intra_rect_in_inter", 1), | ||
| 57390 | + ] { | ||
| 57391 | + let needle = format!("{name}("); | ||
| 57392 | + let decl = format!("fn {name}("); | ||
| 57393 | + // A doc-comment mention (`[`name`](..)`) is prose, not a call, so | ||
| 57394 | + // comment lines are dropped before counting. | ||
| 57395 | + let body: String = decode_body | ||
| 57396 | + .lines() | ||
| 57397 | + .filter(|l| !l.trim_start().starts_with("//")) | ||
| 57398 | + .collect::<Vec<_>>() | ||
| 57399 | + .join("\n"); | ||
| 57400 | + let found = body.matches(&needle).count() - usize::from(body.contains(&decl)); | ||
| 57401 | + assert_eq!( | ||
| 57402 | + found, calls, | ||
| 57403 | + "{name} has {found} call site(s) in the decode body, the census expects \ | ||
| 57404 | + {calls}. A new caller is not automatically wrong, but it is not \ | ||
| 57405 | + automatically covered either: re-derive which level's guard it sits \ | ||
| 57406 | + under before this row stays green" | ||
| 57407 | + ); | ||
| 57408 | + } | ||
| 57409 | + // Both callers reach the 1:4 strips by a DIFFERENT route, so the | ||
| 57410 | + // closure is checked per route -- and per route it is the same shape: | ||
| 57411 | + // the 16x16-level guard must sit ABOVE the test that names VERT_4. | ||
| 57412 | + // | ||
| 57413 | + // key frame: `decode_rect4_16(...)` at 36793, inside an arm testing | ||
| 57414 | + // `part16 == PARTITION_HORZ_4 || part16 == PARTITION_VERT_4`. | ||
| 57415 | + // inter: the 1:4 strips reach `decode_intra_rect_in_inter` | ||
| 57416 | + // through `fctx.inter_strip_chroma`, whose ONLY writer is the inter | ||
| 57417 | + // 16-level 1:4 arm (55068) -- `strip16` is `None` without it. | ||
| 57418 | + // | ||
| 57419 | + // Ordering is the property (a guard BELOW the 1:4 test cannot observe | ||
| 57420 | + // it), which is why each pair is compared rather than merely counted. | ||
| 57421 | + for (what, test, call) in [ | ||
| 57422 | + ( | ||
| 57423 | + "the key-frame decode_rect4_16 caller", | ||
| 57424 | + "if part16 == PARTITION_HORZ_4", | ||
| 57425 | + "decode_rect4_16(", | ||
| 57426 | + ), | ||
| 57427 | + ( | ||
| 57428 | + "the inter-frame inter_strip_chroma writer", | ||
| 57429 | + "let horz = part16 == PARTITION_HORZ_4;", | ||
| 57430 | + "c.set(Some(InterStripChroma {", | ||
| 57431 | + ), | ||
| 57432 | + ] { | ||
| 57433 | + let test_at = decode_body | ||
| 57434 | + .find(test) | ||
| 57435 | + .unwrap_or_else(|| panic!("the 1:4 arm test {test:?} for {what} is gone")); | ||
| 57436 | + // `decode_rect4_16(` also matches the DEFINITION, which is the | ||
| 57437 | + // first occurrence -- the call is the last one. | ||
| 57438 | + let call_at = decode_body | ||
| 57439 | + .rfind(call) | ||
| 57440 | + .unwrap_or_else(|| panic!("{what} is gone -- re-derive the residue's closure")); | ||
| 57441 | + let guard_at = decode_body | ||
| 57442 | + .find("refuse_invalid_subsize((16, 16)") | ||
| 57443 | + .expect("a 16x16-level guard above both 1:4 arms"); | ||
| 57444 | + assert!( | ||
| 57445 | + guard_at < test_at && test_at < call_at, | ||
| 57446 | + "{what}: guard at {guard_at}, 1:4 arm test at {test_at}, dispatch at \ | ||
| 57447 | + {call_at}. The guard has to sit ABOVE the 1:4 arm test, or the \ | ||
| 57448 | + VERT_4 symbol it refuses has already been dispatched on" | ||
| 57449 | + ); | ||
| 57450 | + } | ||
| 57451 | + // And the inter route really is the only one: `strip16` is built from | ||
| 57452 | + // `strip_chroma`, which is `inter_strip_chroma.take()`, so a missing | ||
| 57453 | + // writer would silently drop the arm rather than expose it. | ||
| 57454 | + assert_eq!( | ||
| 57455 | + decode_body.matches("inter_strip_chroma.with(|c| {").count(), | ||
| 57456 | + 1, | ||
| 57457 | + "inter_strip_chroma gained a second writer -- the inter 1:4 strips can now \ | ||
| 57458 | + come from a level whose guard this census has not checked" | ||
| 57459 | + ); | ||
| 57460 | + } | ||
| 57461 | + | ||
| 57011 | /// lane-av1chrtx: [`covering_leaf_tx_type`] resolves a chroma unit's | 57462 | /// lane-av1chrtx: [`covering_leaf_tx_type`] resolves a chroma unit's |
| 57012 | /// `tx_type` from the luma leaf covering the unit's OWN quadrant, and | 57463 | /// `tx_type` from the luma leaf covering the unit's OWN quadrant, and |
| 57013 | /// reports "no leaf there" as `None` so the caller can fall back to the | 57464 | /// reports "no leaf there" as `None` so the caller can fall back to the |
lanes/av1subsizesweep.report.mdadded+238 -0
| @@ -0,0 +1,238 @@ | |||
| 1 | +# lane/av1subsizesweep — census of every chroma-plane walk a BLOCK_INVALID subsize can reach | ||
| 2 | + | ||
| 3 | +Base `main` = `e45cc748` ("Merge lane/av1unwritten: refuse the subsize libaom calls corrupt"). | ||
| 4 | +Worktree `~/.cache/wt/av1subsizesweep`, own `CARGO_TARGET_DIR=~/.cache/tgt/subsizesweep`. | ||
| 5 | + | ||
| 6 | +## What the merged lane already covered (not redone) | ||
| 7 | + | ||
| 8 | +`refuse_invalid_subsize` (`decode.rs:21489`) with `PLANE_BLOCK_INVALID_422` / | ||
| 9 | +`PLANE_BLOCK_INVALID_440` transcribed cell-for-cell from `av1_ss_size_lookup` | ||
| 10 | +(`common_data.c`), `partition_subsize_dims` as libaom's `get_partition_subsize` | ||
| 11 | +reduced to dimensions, **11 guard call sites**, the structural test | ||
| 12 | +`every_partition_symbol_resolution_is_guarded_before_it_dispatches`, and the | ||
| 13 | +`EC_AV1_SUBSIZE_GUARD_TRACE` / `EC_AV1_SUBSIZE_ARM_TRACE` coverage artefacts. | ||
| 14 | + | ||
| 15 | +Its named residue: `decode_rect4_16_intrabc`. | ||
| 16 | + | ||
| 17 | +## The hole this lane found: the key-frame 16-level FRAME-EDGE arm | ||
| 18 | + | ||
| 19 | +`decode.rs:37034-37067` (pre-fix numbering) is the **one** partition read in the | ||
| 20 | +file that dispatches on its own symbol instead of resolving it into a `partN` the | ||
| 21 | +level's guard covers. | ||
| 22 | + | ||
| 23 | +| | reads | resolves to | guarded? | | ||
| 24 | +|---|---|---|---| | ||
| 25 | +| 128-root edge (`35551`/`35559`) | `symbol_fixed(&gather(..))` | `PARTITION_SPLIT`/`HORZ`/`VERT` | yes — `refuse_invalid_subsize((128,128), part128)` at `35588` | | ||
| 26 | +| 64-level edge (`36239`/`36256`) | same | same | yes — `(64,64)` guard at `36278` | | ||
| 27 | +| 32-level edge (`36363`/`36383`) | same | same | yes — `(32,32)` guard at `36406` | | ||
| 28 | +| **16-level edge (kf)** | same | **`edge_split`, straight into `decode_leaf_rect`** | **NO — nothing on the path** | | ||
| 29 | +| 16-level edge (inter, `54767`/`54780`) | same | `part16` | yes — `(16,16)` guard at `54799` | | ||
| 30 | + | ||
| 31 | +With `has_cols16 == false` the strip is `BLOCK_8X16`, whose `(1,0)` chroma plane | ||
| 32 | +block is `BLOCK_INVALID` (`av1_ss_size_lookup`, `common_data.c:20`). At 4:2:2 that | ||
| 33 | +is a subsize libaom refuses at `decodeframe.c:1456`, and this decoder walked it | ||
| 34 | +into `decode_leaf_rect` anyway. With `has_cols16 == true` the strip is `16x8` — | ||
| 35 | +`BLOCK_8X16`'s mirror, whose `(1,0)` cell is `BLOCK_8X8` — and **must** keep | ||
| 36 | +decoding. | ||
| 37 | + | ||
| 38 | +Why the merged lane's structural test could not see it: the scan keys on | ||
| 39 | +`dec.symbol(` (line 56698), and this arm reads `dec.symbol_fixed(&gather(..))`. | ||
| 40 | +Every other edge read is either invisible for the same reason or resolves into a | ||
| 41 | +guarded `partN`; only this one both dispatches directly *and* carries an | ||
| 42 | +INVALID shape. | ||
| 43 | + | ||
| 44 | +**Fix** (`decode.rs:37063-37109`): the guard sits on the arm's own path, named by | ||
| 45 | +LEVEL not by a hand-picked shape — the gathered bit resolves to | ||
| 46 | +`PARTITION_HORZ` when the columns are full and `PARTITION_VERT` when they are | ||
| 47 | +not, and `refuse_invalid_subsize((16,16), edge_part, …)` reduces that through the | ||
| 48 | +same `partition_subsize_dims` every other site uses. A `note_subsize_arm` census | ||
| 49 | +line was added alongside, per the merged lane's convention. | ||
| 50 | + | ||
| 51 | +## The named residue: `decode_rect4_16_intrabc` — CLOSED, not guarded a third time | ||
| 52 | + | ||
| 53 | +Its concrete code shape is `decode.rs:18336-18337`: | ||
| 54 | + | ||
| 55 | +```rust | ||
| 56 | +let (cw, ch) = if own_chroma { (bw >> ss_x(fctx), bh >> ss_y(fctx)) } | ||
| 57 | + else { (pw / 2, ph / 2) }; // <- hardcoded both-axes halving | ||
| 58 | +``` | ||
| 59 | + | ||
| 60 | +`own_chroma = own444 || own422`, and `own422 = ss_x == 1 && ss_y == 0 && horz` | ||
| 61 | +(`18317`). A **VERT** strip at `ss (1,0)` is therefore neither `own444` nor | ||
| 62 | +`own422`, falls to the `else`, and derives `pw,ph = (8,16)` → `cw,ch = (4,8)` — | ||
| 63 | +a `BLOCK_4X8` plane block, itself `BLOCK_INVALID` at `(1,0)`. Same for the | ||
| 64 | +`(pair_mi.1 * MI / 2, pair_mi.0 * MI / 2)` origin at `18354`. | ||
| 65 | + | ||
| 66 | +It is dead, and the reason is derived rather than read: | ||
| 67 | + | ||
| 68 | +1. `decode_rect4_16_intrabc` has exactly **one** caller (`decode_rect4_16_strip`, | ||
| 69 | + `18934`). | ||
| 70 | +2. `decode_rect4_16_strip` has exactly **two** (`17595` from `decode_rect4_16`, | ||
| 71 | + `13810` from `decode_intra_rect_in_inter`). | ||
| 72 | +3. `decode_rect4_16` (`36793`) and `decode_intra_rect_in_inter` (`45447`, reached | ||
| 73 | + only when `fctx.inter_strip_chroma` is set — one writer, `55116`) are both | ||
| 74 | + **16x16-level 1:4 arms**, and both sit above a | ||
| 75 | + `refuse_invalid_subsize((16, 16), part16, …)`. | ||
| 76 | +4. `partition_subsize_dims((16,16), PARTITION_VERT_4) == (4,16)`, and `(4,16)` is | ||
| 77 | + in `PLANE_BLOCK_INVALID_422`. So the guard refuses the **only** shape that | ||
| 78 | + could reach the bad arm. | ||
| 79 | +5. `PARTITION_HORZ_4` gives `(16,4)`, whose `(1,0)` cell is `BLOCK_8X4` and is | ||
| 80 | + legal — so the strip that survives is the one `own422` is written for, and | ||
| 81 | + `refuse_invalid_subsize` does not over-refuse. | ||
| 82 | + | ||
| 83 | +Items 1–5 are asserted in | ||
| 84 | +`every_chroma_walking_leaf_dispatch_is_guarded_or_closed_with_a_reason` (4 and 5 | ||
| 85 | +derived from the real predicate; 1–3 from counted call sites plus the ordering of | ||
| 86 | +guard < 1:4-arm test < dispatch on each of the two routes). It is closed as | ||
| 87 | +**guarded-at-resolution**, not `unreachable`: the site *is* handable an INVALID | ||
| 88 | +subsize in principle, and what makes it safe is a guard one level up. | ||
| 89 | + | ||
| 90 | +## Census table | ||
| 91 | + | ||
| 92 | +`guard` = the `refuse_invalid_subsize` that covers the walk. "shape@mode" lists the | ||
| 93 | +footprints the walk is handed and the subsampling mode at which libaom marks them | ||
| 94 | +`BLOCK_INVALID`. Offending shapes at 4:2:2 `(1,0)`: **4x8, 8x16, 4x16, 8x32, | ||
| 95 | +16x32, 16x64, 32x64, 64x128**. 4:4:0 `(0,1)` is excluded throughout — libaom | ||
| 96 | +asserts `subsampling_y == 0` when `subsampling_x == 0`, so no frame can select | ||
| 97 | +it. | ||
| 98 | + | ||
| 99 | +| # | site | shapes | offending @mode | guard | mechanism | evidence | | ||
| 100 | +|---|---|---|---|---|---|---| | ||
| 101 | +| 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 | | ||
| 102 | +| 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) | | ||
| 103 | +| 3 | `decode_rect4_16` (`17552`) | 16x4, 4x16 | 4x16@(1,0) | same `(16,16)` guards | AtResolution | single caller `36793`, under the 1:4 arm | | ||
| 104 | +| 4 | `decode_rect4_16_strip` (`18862`) | 16x4, 4x16 | 4x16@(1,0) | same | AtResolution | callers `17595`, `13810`, both 1:4 | | ||
| 105 | +| 5 | `decode_block_rect` (`15596`) | 32x16, **16x32** | 16x32@(1,0) | `(32,32)` @ `36406` / `54653` | AtResolution | 32-level HORZ/VERT arms | | ||
| 106 | +| 6 | `decode_block_rect4` (`16764`) | 32x8, **8x32** | 8x32@(1,0) | `(32,32)` @ `36406` / `54653` | AtResolution | 32-level HORZ_4/VERT_4 arms | | ||
| 107 | +| 7 | `decode_block_rect64` (`19851`) | 64x16, **16x64** | 16x64@(1,0) | `(64,64)` @ `36278` / `54269` | AtResolution | 64-level 1:4 arms | | ||
| 108 | +| 8 | `decode_block_128rect` (`23921`) | 128x64, **64x128** | 64x128@(1,0) | `(128,128)` @ `35588` / `54032` | AtResolution | 128-root HORZ/VERT + all four AB arms | | ||
| 109 | +| 9 | `decode_rect_split` (`12420`) | 32x16, 16x32, 64x16, 16x64 | all four | inherited from callers 5/7 | AtResolution | 4 call sites, all under 5–8 | | ||
| 110 | +| 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) | | ||
| 111 | +| 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 | | ||
| 112 | +| 12 | `decode_inter_sub8_rect2` (`48863`) | 8x4, **4x8** | 4x8@(1,0) | `(8,8)` @ `55211` | AtResolution | inter 8x8 level | | ||
| 113 | +| 13 | `decode_leaf_split4` (`27044`) | 4x4 | none | none needed | unreachable | 4x4's plane block is 4x4 in **every** cell | | ||
| 114 | +| 14 | `decode_inter_sub8_split4` (`46999`) | 4x4 | none | none needed | unreachable | same | | ||
| 115 | +| 15 | `decode_leaf8` (`24413`) | 8x8 | none | none needed | unreachable | 8x8 → 8x8/4x8/4x4, never INVALID | | ||
| 116 | +| 16 | `decode_inter_block8` (`50045`) | 8x8 | none | none needed | unreachable | same | | ||
| 117 | +| 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 | | ||
| 118 | +| 18 | `decode_inter_block` (`41372`) | squares only | none | none needed | unreachable | same | | ||
| 119 | +| 19 | `read_sb128_root` (`35493`) | 128x128 root | none itself | own `(128,128)` guard at `35588` | AtResolution | covers rows 5–8 upstream | | ||
| 120 | + | ||
| 121 | +**Rows not closed: none.** Every row is either guarded (1–12, 19) or needs no | ||
| 122 | +guard because the shape is codable at every selectable subsampling mode (13–18). | ||
| 123 | + | ||
| 124 | +## Evidence | ||
| 125 | + | ||
| 126 | +**Guard fires on a live path, and does not over-refuse.** `EC_AV1_SUBSIZE_GUARD_TRACE` | ||
| 127 | +on real `aomenc` 4:2:0 streams of exactly the shape that reaches the arm | ||
| 128 | +(`testsrc2`, widths 40/72/104/136, `h=120`, `--min-partition-size=4 | ||
| 129 | +--max-partition-size=64 --sb-size=64`): | ||
| 130 | + | ||
| 131 | +``` | ||
| 132 | +SUBSIZE_GUARD site=.../decode.rs:37098 bsize=16x16 part=2 codable=true reached=2 | ||
| 133 | +SUBSIZE_ARM site=.../decode.rs:37101 part=2 codable=true reached=2 | ||
| 134 | +``` | ||
| 135 | + | ||
| 136 | +`part=2` is `PARTITION_VERT` — the 8x16 strip, the shape that is INVALID at | ||
| 137 | +4:2:2. At 4:2:0 the guard reports `codable=true`, the frame decodes OK. The guard | ||
| 138 | +is on a live path and refuses nothing it should not. | ||
| 139 | + | ||
| 140 | +**A real aomenc witness for the guard FIRING does not exist, and that is a | ||
| 141 | +property of libaom, not a gap in the sweep.** 45 real 4:2:2 encodes were built | ||
| 142 | +(`--i422`, `testsrc2`, 11 widths × 3 heights at cq 45, plus 12 | ||
| 143 | +`--tune-content=screen --enable-intrabc=1 --enable-palette=1` encodes at cq 20; | ||
| 144 | +widths chosen so the 16-level column is short, heights so it is the *only* short | ||
| 145 | +axis). None reached `37098` at all. The reason is that aomenc's own | ||
| 146 | +`partition_rect_allowed` is gated on the same `av1_ss_size_lookup` table (the | ||
| 147 | +merged lane cites `partition_search.c:3383-3389`), so a conformant encoder | ||
| 148 | +cannot emit a partition whose plane block is `BLOCK_INVALID`. The guard is | ||
| 149 | +therefore a **hostile-stream** guard, in exactly the same class as the merged | ||
| 150 | +lane's own `37171-37177` note ("Not corpus-reachable at ss(1,0) today, so it is | ||
| 151 | +residue rather than live pixels, and it is guarded anyway"). No witness is | ||
| 152 | +claimed. | ||
| 153 | + | ||
| 154 | +**Red-before-green on the new gate** (both mutations against | ||
| 155 | +`every_chroma_walking_leaf_dispatch_is_guarded_or_closed_with_a_reason`): | ||
| 156 | + | ||
| 157 | +* delete `refuse_invalid_subsize((16,16), edge_part, …)` → RED, "dispatches | ||
| 158 | + `decode_leaf_rect` on an 8x16 strip … with NO `refuse_invalid_subsize` on its path". | ||
| 159 | +* move it **below** the `decode_leaf_rect` call (r5's defect in a new place) → | ||
| 160 | + RED, "sits AFTER the `decode_leaf_rect` it protects -- it can never observe it". | ||
| 161 | + | ||
| 162 | +Restored; both green. | ||
| 163 | + | ||
| 164 | +**The gate caught two errors in my own census before it shipped** — recorded | ||
| 165 | +because they are the class this lane exists to close: | ||
| 166 | + | ||
| 167 | +* it counted 4:4:0 `(0,1)` as a reachable offending mode and flagged `16x4` as | ||
| 168 | + needing a guard. That is the merged lane's r2 mistake reproduced: refusing a | ||
| 169 | + legal 4:2:2 shape by testing a cell no `color_config` can request. Fixed by | ||
| 170 | + restricting the offending set to the selectable modes. | ||
| 171 | +* it flagged `decode_block`/`decode_inter_block` as `AtResolution` when no shape | ||
| 172 | + they walk is ever INVALID (squares only). Reclassified `unreachable`. | ||
| 173 | + | ||
| 174 | +**Named tests.** `cargo check --tests` clean. `cargo test -p ec-av1 --lib -- 422 | ||
| 175 | +sub8 subsize chroma_422` → **27 passed, 0 failed** (52 s), including | ||
| 176 | +`a_real_422_key_frame_and_inter_sequence_decode_pixel_exact`, | ||
| 177 | +`the_pinned_422_corpus_cells_decode_pixel_exact`, | ||
| 178 | +`the_pinned_422_bigblock_witnesses_decode_pixel_exact`, | ||
| 179 | +`the_pinned_422_lossless_inter_witnesses_decode_pixel_exact`, | ||
| 180 | +`the_pinned_422_intrabc_sb128_strip_witnesses_decode_pixel_exact`. | ||
| 181 | +The three structural gates pass together. | ||
| 182 | + | ||
| 183 | +**Non-regression on the committed tree.** `cargo test -p ec-av1 --lib -- pixel_exact | ||
| 184 | +byte_exact` → **270 passed, 0 failed** (818 s), on this lane's commit. This is the | ||
| 185 | +over-refusal control at scale: the new guard sits on a live path (measured | ||
| 186 | +reached with `part=2` at 4:2:0 above), and if it refused anything legal these | ||
| 187 | +would go red. | ||
| 188 | + | ||
| 189 | +## Wider sweep — hardcoded chroma halvings, NAMED NOT FIXED (out of charter) | ||
| 190 | + | ||
| 191 | +One wider finding **is inside** the residue and is covered by row 2: | ||
| 192 | +`decode_rect4_16_intrabc`'s `else` arm at `18336-18337` / `18354` — the | ||
| 193 | +`(pw / 2, ph / 2)` halving and the `(pair_mi.1 * MI / 2, pair_mi.0 * MI / 2)` | ||
| 194 | +origin — is a both-axes halving whose predicate (`own444 || own422`) does not | ||
| 195 | +enumerate every reachable `(ss, shape)` cell. It is dead only because row 2's | ||
| 196 | +guard refuses VERT_4 at 4:2:2. If that guard ever moves, this arm becomes the | ||
| 197 | +live defect. | ||
| 198 | + | ||
| 199 | +Outside the charter, named for the owning lanes. Provenance: every row below is | ||
| 200 | +either read by me in the decode spine (rows 1, and the residue's `else` arm | ||
| 201 | +above) or comes from a read-only source sweep run as part of this lane — the | ||
| 202 | +line numbers were confirmed against the worktree, but nothing outside the | ||
| 203 | +decode.rs partition/chroma walk was **reproduced by a probe here**. Rows marked | ||
| 204 | +"not probed" should be re-measured by the lane that takes them. | ||
| 205 | + | ||
| 206 | +| site | what | consequence at 4:2:2 | | ||
| 207 | +|---|---|---| | ||
| 208 | +| `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 | | ||
| 209 | +| `decode.rs:47516, 47908, 49484, 49930` | `mv_to_q4(<y>, <row_mv>, 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` | | ||
| 210 | +| `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 | | ||
| 211 | +| `decode.rs:35700, 53411` | floor-`>>` chroma plane allocators | shape assumption at frame edges; scout finding, not probed here | | ||
| 212 | +| `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 | | ||
| 213 | +| `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 | | ||
| 214 | +| `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 | | ||
| 215 | +| `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 | | ||
| 216 | +| `decode.rs:59012, 59031, 59284-59304` | test-card chroma + `PlaneBuf` test harness at `width/2`, `height/2` | same | | ||
| 217 | +| `examples/gen_coverage_cells.rs:94-96`, `examples/syntax_census.rs` | quarter-plane chroma arithmetic | same | | ||
| 218 | + | ||
| 219 | +`mc.rs`, `intra.rs`, `transform.rs`, `compound.rs` are clean — plane dims arrive as | ||
| 220 | +parameters. `restoration.rs` and `film_grain.rs` are per-axis and correct. | ||
| 221 | +`motion_field.rs:74`'s `/ 2` is the 8×8 MV-cell grid, not a chroma extent. | ||
| 222 | + | ||
| 223 | +## Not closed, stated plainly | ||
| 224 | + | ||
| 225 | +1. **No aomenc witness proves the new guard FIRES**, because libaom's encoder | ||
| 226 | + cannot emit the symbol (§ Evidence). The red-before-green proof for the guard | ||
| 227 | + is mutation-based, not corpus-based. This is the same limitation the merged | ||
| 228 | + lane's guards carry and is not fixable from this side. | ||
| 229 | +2. **The structural gate is a derived site list, not a proof.** It pins the | ||
| 230 | + mechanism for 19 walks and the guard ordering for the hole, but it cannot see | ||
| 231 | + a walk that is neither named in the census nor reachable through a | ||
| 232 | + `partition_w<N>` read — e.g. a future site fed a block shape from a | ||
| 233 | + non-partition source. The census is a ratchet, not a proof. | ||
| 234 | +3. **`decode_rect4_16_intrabc`'s `else` arm is still wrong in isolation.** It is | ||
| 235 | + closed by reachability, not by construction. Closing it by construction would | ||
| 236 | + mean making the arm `unreachable!("...")` at `ss (1,0) && !horz` — deliberately | ||
| 237 | + not done here, because that would assert a property of the callers from inside | ||
| 238 | + the callee and break the moment the arm gains a legal 4:2:2 VERT_4 use. | ||
| \ No newline at end of file | \ No newline at end of file | ||