Merge lane-av1422lpf: the 4:2:2 lossless inter chroma panic family is SEVEN sites, all fixed
Browse files at this commit6 changed files +726 -10
- crates/ec-av1/fixtures/W_intrabc.obu +0 -0
- crates/ec-av1/fixtures/X_intrabc_tiled.obu +0 -0
- crates/ec-av1/fixtures/Y_intrabc_10b.obu +0 -0
- crates/ec-av1/src/decode.rs +134 -10
- crates/ec-av1/src/stream.rs +264 -0
- lanes/av1422lpf.report.md +328 -0
crates/ec-av1/fixtures/W_intrabc.obuadded+0 -0
Binary file changed
crates/ec-av1/fixtures/X_intrabc_tiled.obuadded+0 -0
Binary file changed
crates/ec-av1/fixtures/Y_intrabc_10b.obuadded+0 -0
Binary file changed
crates/ec-av1/src/decode.rsmodified+134 -10
| @@ -37445,7 +37445,16 @@ fn read_intra_chroma_lossless( | |||
| 37445 | } else { | 37445 | } else { |
| 37446 | &mut *v_out | 37446 | &mut *v_out |
| 37447 | }, | 37447 | }, |
| 37448 | - stride * stride, | 37448 | + // lane-av1422lpf site 7: `stride * blk_h`, the intra twin |
| 37449 | + // of site 1. `read_intra_chroma_lossless`'s own | ||
| 37450 | + // `(blk_w, blk_h)` parameter is the block's whole CHROMA | ||
| 37451 | + // PLANE BLOCK, per-axis, and the walk below addresses up | ||
| 37452 | + // to row `org_y + reg_h - 1` at `stride` -- so the | ||
| 37453 | + // requirement is `stride * blk_h` and `stride * stride` | ||
| 37454 | + // underruns by exactly the ratio the plane block's height | ||
| 37455 | + // exceeds its width. Identical number at 4:2:0 | ||
| 37456 | + // (`blk_h == stride`) and 4:4:4. | ||
| 37457 | + stride * blk_h, | ||
| 37449 | ); | 37458 | ); |
| 37450 | for row in 0..4 { | 37459 | for row in 0..4 { |
| 37451 | let start = (oy + row) * stride + ox; | 37460 | let start = (oy + row) * stride + ox; |
| @@ -37609,7 +37618,29 @@ fn read_inter_chroma_lossless( | |||
| 37609 | } else { | 37618 | } else { |
| 37610 | &mut *v_out | 37619 | &mut *v_out |
| 37611 | }, | 37620 | }, |
| 37612 | - stride * stride, | 37621 | + // lane-av1422lpf site 1: `stride * blk_h`, NOT |
| 37622 | + // `stride * stride`. The composed `u_out`/`v_out` grid is | ||
| 37623 | + // the block's whole CHROMA PLANE BLOCK read at `stride`, | ||
| 37624 | + // and libaom's plane block is PER-AXIS | ||
| 37625 | + // (`(bw >> ss_x) x (bh >> ss_y)`, decodeframe.c's | ||
| 37626 | + // `dec->uv_buffer` extent) -- square only when | ||
| 37627 | + // `ss_x == ss_y`. The walk above addresses row | ||
| 37628 | + // `org_y + reg_h - 1` at column `org_x + reg_w`, and every | ||
| 37629 | + // call site passes a region that is a sub-rect of `blk` | ||
| 37630 | + // with `org` inside `blk`, so the requirement is exactly | ||
| 37631 | + // `stride * blk_h` (the last row's end | ||
| 37632 | + // `(blk_h - 1) * stride + blk_w` fits because | ||
| 37633 | + // `blk_w <= stride` at all nine call sites). | ||
| 37634 | + // | ||
| 37635 | + // Where the plane block IS square -- 4:2:0 (`side/2` both | ||
| 37636 | + // axes) and 4:4:4 (`side` both axes) on a square block -- | ||
| 37637 | + // `blk_h == stride` and this reduces to the old | ||
| 37638 | + // `stride * stride` verbatim, so it cannot move a byte | ||
| 37639 | + // there. It is not 4:2:2-only either: a 64x128 4:2:0 block | ||
| 37640 | + // has a 32x64 chroma plane block, and `ll420_a.obu` | ||
| 37641 | + // (`range end index 1028 out of range for slice of | ||
| 37642 | + // length 1024`) panicked on the old expression. | ||
| 37643 | + stride * blk_h, | ||
| 37613 | ); | 37644 | ); |
| 37614 | for row in 0..4 { | 37645 | for row in 0..4 { |
| 37615 | let start = (oy + row) * stride + ox; | 37646 | let start = (oy + row) * stride + ox; |
| @@ -40024,10 +40055,37 @@ fn decode_inter_block( | |||
| 40024 | Some(s) if s.has_chroma => { | 40055 | Some(s) if s.has_chroma => { |
| 40025 | // 4:2:0: the PAIR's 8x4 / 4x8. 4:4:4: the strip's own 16x4 / | 40056 | // 4:2:0: the PAIR's 8x4 / 4x8. 4:4:4: the strip's own 16x4 / |
| 40026 | // 4x16 (lane-av1-444; no pair at ss 0/0). | 40057 | // 4x16 (lane-av1-444; no pair at ss 0/0). |
| 40058 | + // | ||
| 40059 | + // lane-av1422lpf site 4: the VERT arm's third shape. A | ||
| 40060 | + // `PARTITION_VERT_4` strip is 4x16 luma and pairs on COLUMNS | ||
| 40061 | + // while `ss_x == 1` (`is_chroma_reference` on `mi_col` parity, | ||
| 40062 | + // av1_common_int.h:1454), so the pair is 8x16 luma -- and 4:2:2 | ||
| 40063 | + // subsamples X ONLY (`subsampling_x = 1, subsampling_y = 0`, | ||
| 40064 | + // spec 5.5.2's `color_config`), which leaves the pair's chroma | ||
| 40065 | + // plane block at 8>>1 x 16>>0 = **4x16**, twice as tall as the | ||
| 40066 | + // 4:2:0 pair's 4x8. The old `else` handed 4:2:2 the 4:2:0 shape, | ||
| 40067 | + // halving `write_chroma_h` for the WHOLE of `decode_inter_block` | ||
| 40068 | + // at ss (1,0) -- `chroma_stride`/`chroma_buf_h` at 40017 and so | ||
| 40069 | + // every prediction buffer, every grid and every mu-chunk replay | ||
| 40070 | + // below. Measured on `W_intrabc.obu` frame 1: a 4x16 vert strip | ||
| 40071 | + // got `chroma_stride = 4`, `chroma_buf_h = 8`, a 32-sample grid, | ||
| 40072 | + // and the lossless TX_4x4 replay's last unit row read index 64 of | ||
| 40073 | + // it (`range end index 36 out of range for slice of length 32` | ||
| 40074 | + // at the composed-grid read). | ||
| 40075 | + // | ||
| 40076 | + // The HORZ arm needs no third shape at 4:2:2 and gets none: a | ||
| 40077 | + // HORZ_4 strip pairs on ROWS only while `ss_y == 1`, and 4:2:2 | ||
| 40078 | + // has `ss_y == 0`, so each 16x4 strip is its own chroma reference | ||
| 40079 | + // and its own 8x4 chroma block -- the number `(8, 4)` already | ||
| 40080 | + // returns. At 4:2:0 (`ss_x == ss_y == 1`) the pair halves on both | ||
| 40081 | + // axes and at 4:4:4 there is no pair at all, so both of those | ||
| 40082 | + // arms are untouched by this line. | ||
| 40027 | if ss_x(fctx) == 0 && ss_y(fctx) == 0 { | 40083 | if ss_x(fctx) == 0 && ss_y(fctx) == 0 { |
| 40028 | if s.horz { (16, 4) } else { (4, 16) } | 40084 | if s.horz { (16, 4) } else { (4, 16) } |
| 40029 | } else if s.horz { | 40085 | } else if s.horz { |
| 40030 | (8, 4) | 40086 | (8, 4) |
| 40087 | + } else if ss_y(fctx) == 0 { | ||
| 40088 | + (4, 16) | ||
| 40031 | } else { | 40089 | } else { |
| 40032 | (4, 8) | 40090 | (4, 8) |
| 40033 | } | 40091 | } |
| @@ -41547,7 +41605,33 @@ fn decode_inter_block( | |||
| 41547 | (cc * chunk_chroma_w, cr * chunk_chroma_h), | 41605 | (cc * chunk_chroma_w, cr * chunk_chroma_h), |
| 41548 | (chunk_chroma_w, chunk_chroma_h), | 41606 | (chunk_chroma_w, chunk_chroma_h), |
| 41549 | (write_chroma_w, write_chroma_h), | 41607 | (write_chroma_w, write_chroma_h), |
| 41550 | - chroma_side, | 41608 | + // lane-av1422lpf site 5: the stride |
| 41609 | + // the walk indexes `su`/`sv` at is the | ||
| 41610 | + // PREDICTION BUFFER's own | ||
| 41611 | + // `chroma_stride` -- the same number | ||
| 41612 | + // `su`/`sv` were built at, and the one | ||
| 41613 | + // the composed `u_units`/`v_units` | ||
| 41614 | + // grid is sized and written at (site | ||
| 41615 | + // 1's `stride * blk_h`). `chroma_side` | ||
| 41616 | + // is the ENCLOSING SQUARE | ||
| 41617 | + // (`max(side >> ss_x, side >> ss_y)`) | ||
| 41618 | + // and at 4:2:2 it is the LUMA side: a | ||
| 41619 | + // 128x128 block's chroma plane block is | ||
| 41620 | + // 64x128, so the walk addressed | ||
| 41621 | + // `oy * 128 + ox` on a 64-wide, 8192- | ||
| 41622 | + // sample buffer and the last unit row | ||
| 41623 | + // ran off the end | ||
| 41624 | + // (`offset 8192 .. 8580 of 8192`, | ||
| 41625 | + // X_intrabc_tiled frame 1, at | ||
| 41626 | + // `push_mc_rect_tx`). | ||
| 41627 | + // | ||
| 41628 | + // At 4:2:0 `chroma_stride == | ||
| 41629 | + // chroma_side == side >> 1` and at | ||
| 41630 | + // 4:4:4 both are `side`, so this | ||
| 41631 | + // argument is the same number on every | ||
| 41632 | + // shape this decoder admits except | ||
| 41633 | + // 4:2:2. | ||
| 41634 | + chroma_stride, | ||
| 41551 | mode_for_tx, | 41635 | mode_for_tx, |
| 41552 | base_q_idx, | 41636 | base_q_idx, |
| 41553 | &mut u_units, | 41637 | &mut u_units, |
| @@ -43334,7 +43418,13 @@ fn decode_inter_block( | |||
| 43334 | (cc * chunk_chroma_w, cr * chunk_chroma_h), | 43418 | (cc * chunk_chroma_w, cr * chunk_chroma_h), |
| 43335 | (chunk_chroma_w, chunk_chroma_h), | 43419 | (chunk_chroma_w, chunk_chroma_h), |
| 43336 | (write_chroma_w, write_chroma_h), | 43420 | (write_chroma_w, write_chroma_h), |
| 43337 | - chroma_side, | 43421 | + // lane-av1422lpf site 5 (the compound |
| 43422 | + // twin of the single-reference fix at | ||
| 43423 | + // 41572): the prediction buffer's own | ||
| 43424 | + // `chroma_stride`, never the enclosing | ||
| 43425 | + // square `chroma_side`. Identical | ||
| 43426 | + // number at 4:2:0 and 4:4:4. | ||
| 43427 | + chroma_stride, | ||
| 43338 | mode_for_tx, | 43428 | mode_for_tx, |
| 43339 | base_q_idx, | 43429 | base_q_idx, |
| 43340 | &mut u_units, | 43430 | &mut u_units, |
| @@ -44309,10 +44399,21 @@ fn decode_inter_block( | |||
| 44309 | (px, py), | 44399 | (px, py), |
| 44310 | (cpx, cpy), | 44400 | (cpx, cpy), |
| 44311 | side, | 44401 | side, |
| 44312 | - (chroma_side, chroma_side), | 44402 | + // lane-av1422lpf site 6 (the intra-in-inter twin of |
| 44403 | + // site 5 at 41572): the plane block's own per-axis | ||
| 44404 | + // shape and stride, never the enclosing square. | ||
| 44405 | + // `palette_uv_bufs` is the decoded colour-index map | ||
| 44406 | + // at `(write_w >> ss_x, write_h >> ss_y)` (44144), | ||
| 44407 | + // i.e. per-axis already, and the lossless walk | ||
| 44408 | + // windows it at this `stride` -- at 4:2:2 a | ||
| 44409 | + // 16-wide square stride over an 8-wide map put the | ||
| 44410 | + // third unit row at index 180 of 128 samples | ||
| 44411 | + // (`palette_window`, decode.rs:2946; measured on | ||
| 44412 | + // `Y_intrabc_10b.obu`). | ||
| 44413 | + (chroma_stride, chroma_buf_h), | ||
| 44313 | (cc * chunk_chroma_w, cr * chunk_chroma_h), | 44414 | (cc * chunk_chroma_w, cr * chunk_chroma_h), |
| 44314 | (chunk_chroma_w, chunk_chroma_h), | 44415 | (chunk_chroma_w, chunk_chroma_h), |
| 44315 | - chroma_side, | 44416 | + chroma_stride, |
| 44316 | reach, | 44417 | reach, |
| 44317 | (y.width, y.height), | 44418 | (y.width, y.height), |
| 44318 | mode, | 44419 | mode, |
| @@ -44588,10 +44689,15 @@ fn decode_inter_block( | |||
| 44588 | (px, py), | 44689 | (px, py), |
| 44589 | (cpx, cpy), | 44690 | (cpx, cpy), |
| 44590 | side, | 44691 | side, |
| 44591 | - (chroma_side, chroma_side), | 44692 | + // lane-av1422lpf site 6 (the whole-block twin of the mu |
| 44693 | + // chunk fix at 44374): the plane block's own per-axis shape | ||
| 44694 | + // and its own stride, never the enclosing square | ||
| 44695 | + // `chroma_side`. At 4:2:0 and 4:4:4 all three are the same | ||
| 44696 | + // number. | ||
| 44697 | + (chroma_stride, chroma_buf_h), | ||
| 44592 | (0, 0), | 44698 | (0, 0), |
| 44593 | - (chroma_side, chroma_side), | 44699 | + (chroma_stride, chroma_buf_h), |
| 44594 | - chroma_side, | 44700 | + chroma_stride, |
| 44595 | reach, | 44701 | reach, |
| 44596 | (y.width, y.height), | 44702 | (y.width, y.height), |
| 44597 | mode, | 44703 | mode, |
| @@ -45046,7 +45152,25 @@ fn decode_inter_block( | |||
| 45046 | for (plane, grid) in [(1usize, &u_grid), (2usize, &v_grid)] { | 45152 | for (plane, grid) in [(1usize, &u_grid), (2usize, &v_grid)] { |
| 45047 | let mut unit = Vec::with_capacity(cu * cu); | 45153 | let mut unit = Vec::with_capacity(cu * cu); |
| 45048 | for rr in 0..cu { | 45154 | for rr in 0..cu { |
| 45049 | - let start = (cr * cu + rr) * chroma_side + cc * cu; | 45155 | + // lane-av1422lpf site 2: the composed grid this |
| 45156 | + // replays is the block's CHROMA PLANE BLOCK at | ||
| 45157 | + // `chroma_stride` -- the same per-axis stride | ||
| 45158 | + // site 1 sized `u_out`/`v_out` at and the same | ||
| 45159 | + // `read_inter_chroma_lossless` wrote them at | ||
| 45160 | + // (`src.offset(..)` + `(oy + row) * stride + ox`). | ||
| 45161 | + // `chroma_side` is the ENCLOSING SQUARE | ||
| 45162 | + // (`max(side >> ss_x, side >> ss_y)`), which is | ||
| 45163 | + // the plane block's own width only when | ||
| 45164 | + // `ss_x == ss_y`: at 4:2:2 it is the full luma | ||
| 45165 | + // side, twice a strip block's plane-block width, | ||
| 45166 | + // and the last unit row ran off the end | ||
| 45167 | + // (`range end index 68 out of range for slice of | ||
| 45168 | + // length 64`, W_intrabc frame 1). | ||
| 45169 | + // | ||
| 45170 | + // At 4:2:0 (`chroma_stride == chroma_side == | ||
| 45171 | + // side >> 1`) and 4:4:4 (`side`) the two are the | ||
| 45172 | + // same number and this line is unchanged. | ||
| 45173 | + let start = (cr * cu + rr) * chroma_stride + cc * cu; | ||
| 45050 | unit.extend_from_slice(&grid[start..start + cu]); | 45174 | unit.extend_from_slice(&grid[start..start + cu]); |
| 45051 | } | 45175 | } |
| 45052 | units.push(( | 45176 | units.push(( |
crates/ec-av1/src/stream.rsmodified+264 -0
| @@ -3039,6 +3039,270 @@ pub(crate) mod tests { | |||
| 3039 | /// the refusal-by-name contract: with the header refusal standing, | 3039 | /// the refusal-by-name contract: with the header refusal standing, |
| 3040 | /// NO committed test can decode a 4:2:2 stream, because the bypass that | 3040 | /// NO committed test can decode a 4:2:2 stream, because the bypass that |
| 3041 | /// would allow it must never be committed. | 3041 | /// would allow it must never be committed. |
| 3042 | + /// lane-av1422lpf: the 4:2:2 lossless INTER chroma panic family -- SEVEN | ||
| 3043 | + /// sites, each indexing a block's chroma PLANE BLOCK with the ENCLOSING | ||
| 3044 | + /// SQUARE `max(side >> ss_x, side >> ss_y)`. | ||
| 3045 | + /// | ||
| 3046 | + /// libaom's chroma plane block is PER-AXIS, `(bw >> ss_x) x | ||
| 3047 | + /// (bh >> ss_y)` (`av1_common_int.h`'s `av1_get_plane_block_size`, the | ||
| 3048 | + /// `dec->uv_buffer` extent in decodeframe.c), and it is square only when | ||
| 3049 | + /// `ss_x == ss_y`. The enclosing square is the same number at 4:2:0 | ||
| 3050 | + /// (`side >> 1`) and 4:4:4 (`side`) on a square block, so every site | ||
| 3051 | + /// below is byte-identical there; at 4:2:2 the square is the LUMA side | ||
| 3052 | + /// and each site walked off its own buffer. | ||
| 3053 | + /// | ||
| 3054 | + /// Committed code refuses 4:2:2 at the sequence header, so -- exactly | ||
| 3055 | + /// like the witnesses above -- what this gate can assert in committed | ||
| 3056 | + /// code is the byte pin, the refusal-by-name contract, and the arm below: | ||
| 3057 | + /// that each site's PER-AXIS expression is still spelled per-axis and | ||
| 3058 | + /// the square-cut expression it replaced is gone. The decode-level | ||
| 3059 | + /// evidence is measured on the local `EC_AV1_ALLOW_422_PROBE` | ||
| 3060 | + /// patch-run-restore build and is in `lanes/av1422lpf.report.md`. | ||
| 3061 | + #[test] | ||
| 3062 | + fn the_pinned_422_lossless_inter_chroma_panics_refuse_by_name() { | ||
| 3063 | + const NAME: &str = "the_pinned_422_lossless_inter_chroma_panics_refuse_by_name"; | ||
| 3064 | + const REFUSAL: &str = "a chroma format of 4:2:2"; | ||
| 3065 | + for (file, bytes, fp) in [ | ||
| 3066 | + ("W_intrabc.obu", 130_320usize, 0xb6d5c4653a32567a_u64), | ||
| 3067 | + ("X_intrabc_tiled.obu", 131_696, 0xb6e04621d2116ef7), | ||
| 3068 | + ("Y_intrabc_10b.obu", 202_281, 0x2ecf03435a14dbf), | ||
| 3069 | + ] { | ||
| 3070 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | ||
| 3071 | + .join("fixtures") | ||
| 3072 | + .join(file); | ||
| 3073 | + let data = std::fs::read(&path).unwrap_or_else(|e| { | ||
| 3074 | + panic!("{NAME}: pinned witness {file} is missing ({e}) -- the gate cannot run") | ||
| 3075 | + }); | ||
| 3076 | + assert_eq!(data.len(), bytes, "{NAME}: {file} size drifted"); | ||
| 3077 | + assert_eq!(fnv1a64(&data), fp, "{NAME}: {file} bytes drifted"); | ||
| 3078 | + let err = decode_stream(&data).unwrap_err().to_string(); | ||
| 3079 | + assert!( | ||
| 3080 | + err.contains(REFUSAL), | ||
| 3081 | + "{NAME}: {file} must refuse by name, got: {err}" | ||
| 3082 | + ); | ||
| 3083 | + } | ||
| 3084 | + } | ||
| 3085 | + | ||
| 3086 | + /// lane-av1422lpf: the SOURCE-SCAN arm of the witness gate above -- one | ||
| 3087 | + /// assertion per site, so a mutation at any single site reds exactly that | ||
| 3088 | + /// site and leaves the other six alone. | ||
| 3089 | + /// | ||
| 3090 | + /// Every assertion has a NEGATIVE twin (`forbidden`) and a POSITIVE twin | ||
| 3091 | + /// (`required`), so neither an unreverted site nor a matcher that has | ||
| 3092 | + /// stopped matching can pass: the forbidden string is absent AND the | ||
| 3093 | + /// required string is present in the same function body. The `required` | ||
| 3094 | + /// half is what makes this gate non-vacuous in the | ||
| 3095 | + /// `dead-matcher-positive-control` sense -- a scan that matched nothing | ||
| 3096 | + /// would fail it rather than pass silently. | ||
| 3097 | + /// | ||
| 3098 | + /// `strip_code` is the same comment-stripping the arms above use: the | ||
| 3099 | + /// fixes quote their own old expression to say what it was, and a prose | ||
| 3100 | + /// mention must neither read as a reintroduction nor mask one. | ||
| 3101 | + #[test] | ||
| 3102 | + fn the_422_lossless_inter_chroma_walk_sites_stay_per_axis() { | ||
| 3103 | + const NAME: &str = "the_422_lossless_inter_chroma_walk_sites_stay_per_axis"; | ||
| 3104 | + let src = include_str!("decode.rs"); | ||
| 3105 | + let strip_code = |body: &str| -> String { | ||
| 3106 | + body.lines() | ||
| 3107 | + .map(|l| l.split_once("//").map_or(l, |(c, _)| c)) | ||
| 3108 | + .collect::<Vec<_>>() | ||
| 3109 | + .join("\n") | ||
| 3110 | + }; | ||
| 3111 | + // A SECOND form with the same comment stripping but every run of | ||
| 3112 | + // whitespace collapsed to one space, so a matcher can span an argument | ||
| 3113 | + // list that a line-anchored fix's own comment sits inside. Without it | ||
| 3114 | + // the site-5 and site-6 matchers are DEAD: the mutation that reverts | ||
| 3115 | + // them still passes, because the literal being searched for never | ||
| 3116 | + // matched even when the fix was in place. Measured, not assumed -- | ||
| 3117 | + // `verifier-dead-matcher-positive-control`. | ||
| 3118 | + let flatten = |body: &str| -> String { | ||
| 3119 | + strip_code(body) | ||
| 3120 | + .split_whitespace() | ||
| 3121 | + .collect::<Vec<_>>() | ||
| 3122 | + .join(" ") | ||
| 3123 | + }; | ||
| 3124 | + let body_of = |fn_name: &str| -> String { | ||
| 3125 | + let after = src | ||
| 3126 | + .split_once(&format!("\nfn {fn_name}(")) | ||
| 3127 | + .unwrap_or_else(|| panic!("{NAME}: `{fn_name}` must exist in decode.rs")); | ||
| 3128 | + let end = after.1.find("\nfn ").unwrap_or(after.1.len()); | ||
| 3129 | + strip_code(&after.1[..end]) | ||
| 3130 | + }; | ||
| 3131 | + let flat_of = |fn_name: &str| -> String { | ||
| 3132 | + let after = src | ||
| 3133 | + .split_once(&format!("\nfn {fn_name}(")) | ||
| 3134 | + .unwrap_or_else(|| panic!("{NAME}: `{fn_name}` must exist in decode.rs")); | ||
| 3135 | + let end = after.1.find("\nfn ").unwrap_or(after.1.len()); | ||
| 3136 | + flatten(&after.1[..end]) | ||
| 3137 | + }; | ||
| 3138 | + // (label, enclosing fn, forbidden square-cut spelling, required | ||
| 3139 | + // per-axis spelling, required count in that fn) | ||
| 3140 | + let sites: [(&str, &str, &str, &str, usize); 4] = [ | ||
| 3141 | + ( | ||
| 3142 | + "site 1 -- read_inter_chroma_lossless's composed-grid extent", | ||
| 3143 | + "read_inter_chroma_lossless", | ||
| 3144 | + "stride * stride,\n );", | ||
| 3145 | + "stride * blk_h,", | ||
| 3146 | + 1, | ||
| 3147 | + ), | ||
| 3148 | + ( | ||
| 3149 | + "site 7 -- read_intra_chroma_lossless's composed-grid extent", | ||
| 3150 | + "read_intra_chroma_lossless", | ||
| 3151 | + "stride * stride,\n );", | ||
| 3152 | + "stride * blk_h,", | ||
| 3153 | + 1, | ||
| 3154 | + ), | ||
| 3155 | + ( | ||
| 3156 | + "site 4 -- the strip chroma rect's VERT arm at ss (1,0)", | ||
| 3157 | + "decode_inter_block", | ||
| 3158 | + "} else if s.horz {\n (8, 4)\n } else {\n (4, 8)\n }", | ||
| 3159 | + "} else if ss_y(fctx) == 0 {\n (4, 16)\n } else {\n (4, 8)\n }", | ||
| 3160 | + 1, | ||
| 3161 | + ), | ||
| 3162 | + ( | ||
| 3163 | + "site 5 -- the mu-chunk lossless walk's prediction stride", | ||
| 3164 | + "decode_inter_block", | ||
| 3165 | + "(write_chroma_w, write_chroma_h), chroma_side, mode_for_tx,", | ||
| 3166 | + "(write_chroma_w, write_chroma_h), chroma_stride, mode_for_tx,", | ||
| 3167 | + 2, | ||
| 3168 | + ), | ||
| 3169 | + ]; | ||
| 3170 | + for (label, fn_name, forbidden, required, count) in sites { | ||
| 3171 | + // The last table row is written in the flattened form (it spans a | ||
| 3172 | + // comment the fix itself wrote); the others are line-anchored. | ||
| 3173 | + let flattened = required.contains(" mode_for_tx,"); | ||
| 3174 | + let body = if flattened { | ||
| 3175 | + flat_of(fn_name) | ||
| 3176 | + } else { | ||
| 3177 | + body_of(fn_name) | ||
| 3178 | + }; | ||
| 3179 | + assert_eq!( | ||
| 3180 | + body.matches(forbidden).count(), | ||
| 3181 | + 0, | ||
| 3182 | + "{NAME}: {label} is BACK -- the square-cut expression \ | ||
| 3183 | + `{forbidden}` is what this gate exists for" | ||
| 3184 | + ); | ||
| 3185 | + assert!( | ||
| 3186 | + body.matches(required).count() >= count, | ||
| 3187 | + "{NAME}: {label}: the per-axis expression `{required}` must appear \ | ||
| 3188 | + at least {count} time(s) in `{fn_name}` -- found {}", | ||
| 3189 | + body.matches(required).count() | ||
| 3190 | + ); | ||
| 3191 | + } | ||
| 3192 | + // Sites 2, 5 and 6 are the `chroma_side`-vs-`chroma_stride` and | ||
| 3193 | + // `chroma_side`-vs-`chroma_buf_h` argument choices, which are | ||
| 3194 | + // single-token differences on otherwise identical lines. Counting the | ||
| 3195 | + // remaining `chroma_side` uses per arm is the only way to see them, so | ||
| 3196 | + // they get their own exact-count assertions instead of a substring. | ||
| 3197 | + let dib = body_of("decode_inter_block"); | ||
| 3198 | + // Site 2: the lossless TX_4x4 unit replay indexes the composed grid. | ||
| 3199 | + assert_eq!( | ||
| 3200 | + dib.matches("let start = (cr * cu + rr) * chroma_stride + cc * cu;") | ||
| 3201 | + .count(), | ||
| 3202 | + 1, | ||
| 3203 | + "{NAME}: site 2 -- the lossless TX_4x4 replay must index the \ | ||
| 3204 | + composed plane grid at `chroma_stride` (the plane block's own \ | ||
| 3205 | + width), not `chroma_side`" | ||
| 3206 | + ); | ||
| 3207 | + assert_eq!( | ||
| 3208 | + dib.matches("let start = (cr * cu + rr) * chroma_side + cc * cu;") | ||
| 3209 | + .count(), | ||
| 3210 | + 0, | ||
| 3211 | + "{NAME}: site 2 is BACK -- the lossless TX_4x4 replay indexes the \ | ||
| 3212 | + composed grid at the enclosing square again" | ||
| 3213 | + ); | ||
| 3214 | + // Sites 5 and 6. The two mu-chunk walks (the single-reference and the | ||
| 3215 | + // compound twin) take the block's `(write_chroma_w, write_chroma_h)` | ||
| 3216 | + // and the stride SEPARATELY; the two intra-in-inter walks take both | ||
| 3217 | + // the block shape and the region as `(chroma_stride, chroma_buf_h)`. | ||
| 3218 | + // Every one of the four must be per-axis; the pre-fix spelling was | ||
| 3219 | + // the enclosing square `chroma_side` for the stride, and | ||
| 3220 | + // `(chroma_side, chroma_side)` for the intra block shape. | ||
| 3221 | + let dibf = flat_of("decode_inter_block"); | ||
| 3222 | + assert_eq!( | ||
| 3223 | + dibf.matches("(chroma_stride, chroma_buf_h),").count(), | ||
| 3224 | + 3, | ||
| 3225 | + "{NAME}: site 6 -- the two intra-in-inter walks pass the plane block \ | ||
| 3226 | + as `(chroma_stride, chroma_buf_h)` at all THREE argument positions \ | ||
| 3227 | + it occupies -- the mu-chunk walk's blk shape, and the whole-block walk's blk shape and region -- found {}", | ||
| 3228 | + dibf.matches("(chroma_stride, chroma_buf_h),").count() | ||
| 3229 | + ); | ||
| 3230 | + assert_eq!( | ||
| 3231 | + dibf.matches("(chroma_side, chroma_side),").count(), | ||
| 3232 | + 0, | ||
| 3233 | + "{NAME}: site 6 is BACK -- an intra-in-inter walk still hands the \ | ||
| 3234 | + plane block the enclosing square `chroma_side`" | ||
| 3235 | + ); | ||
| 3236 | + // The geometry the scan cannot see, derived from the same `>> ss` | ||
| 3237 | + // forms the fixes use, so the scan and the fix cannot disagree about | ||
| 3238 | + // what per-axis means at each chroma format. A 16x16 luma block: | ||
| 3239 | + // (side >> ss_x, side >> ss_y) is the plane block and | ||
| 3240 | + // max(side >> ss_x, side >> ss_y) is the enclosing square. | ||
| 3241 | + let plane_block = |side: usize, ss_x: u32, ss_y: u32| (side >> ss_x, side >> ss_y); | ||
| 3242 | + let enclosing = |side: usize, ss_x: u32, ss_y: u32| { | ||
| 3243 | + ( | ||
| 3244 | + (side >> ss_x).max(side >> ss_y), | ||
| 3245 | + (side >> ss_x).max(side >> ss_y), | ||
| 3246 | + ) | ||
| 3247 | + }; | ||
| 3248 | + for (label, side, ss_x, ss_y, block, square) in [ | ||
| 3249 | + ("4:2:0", 16usize, 1u32, 1u32, (8, 8), (8, 8)), | ||
| 3250 | + ("4:2:2", 16, 1, 0, (8, 16), (16, 16)), | ||
| 3251 | + ("4:4:4", 16, 0, 0, (16, 16), (16, 16)), | ||
| 3252 | + ] { | ||
| 3253 | + assert_eq!( | ||
| 3254 | + plane_block(side, ss_x, ss_y), | ||
| 3255 | + block, | ||
| 3256 | + "{NAME}: the {label} chroma plane block of a {side}x{side} luma block" | ||
| 3257 | + ); | ||
| 3258 | + assert_eq!( | ||
| 3259 | + enclosing(side, ss_x, ss_y), | ||
| 3260 | + square, | ||
| 3261 | + "{NAME}: the {label} enclosing chroma square of a {side}x{side} \ | ||
| 3262 | + luma block" | ||
| 3263 | + ); | ||
| 3264 | + } | ||
| 3265 | + // The load-bearing claim of "unchanged at 4:2:0 and 4:4:4": the two | ||
| 3266 | + // are the same number exactly when `ss_x == ss_y`, and DIFFERENT at | ||
| 3267 | + // 4:2:2 -- which is what makes every site above inert there and | ||
| 3268 | + // active at 4:2:2. If this ever held at 4:2:2 the fixes would be | ||
| 3269 | + // untested rather than inert. | ||
| 3270 | + assert_eq!(plane_block(16, 1, 1), enclosing(16, 1, 1)); | ||
| 3271 | + assert_eq!(plane_block(16, 0, 0), enclosing(16, 0, 0)); | ||
| 3272 | + assert_ne!( | ||
| 3273 | + plane_block(16, 1, 0), | ||
| 3274 | + enclosing(16, 1, 0), | ||
| 3275 | + "{NAME}: 4:2:2 must NOT be square -- if the plane block equalled \ | ||
| 3276 | + the enclosing square at ss (1,0), none of these sites could ever \ | ||
| 3277 | + be wrong and the gates above would be measuring nothing" | ||
| 3278 | + ); | ||
| 3279 | + // Site 4's own geometry: a PARTITION_VERT_4 strip is 4x16 luma and | ||
| 3280 | + // pairs on COLUMNS while `ss_x == 1`, so the pair is 8x16 and its | ||
| 3281 | + // plane block is (8 >> ss_x, 16 >> ss_y). | ||
| 3282 | + for (label, ss_x, _ss_y, want) in [ | ||
| 3283 | + ("4:2:0", 1u32, 1u32, (4usize, 8usize)), | ||
| 3284 | + ("4:2:2", 1, 0, (4, 16)), | ||
| 3285 | + ("4:4:4", 0, 0, (8, 16)), | ||
| 3286 | + ] { | ||
| 3287 | + assert_eq!( | ||
| 3288 | + plane_block(8, ss_x, 0).0, | ||
| 3289 | + want.0, | ||
| 3290 | + "{NAME}: site 4 -- the {label} VERT strip pair's chroma width" | ||
| 3291 | + ); | ||
| 3292 | + } | ||
| 3293 | + // ...and the HORZ arm of the same match needs NO third shape at | ||
| 3294 | + // 4:2:2: a HORZ_4 strip pairs on ROWS only while `ss_y == 1`, and | ||
| 3295 | + // 4:2:2 has `ss_y == 0`, so each 16x4 strip is its own chroma | ||
| 3296 | + // reference and its own (8 >> ss_x, 4 >> 0) plane block -- which is | ||
| 3297 | + // the (8, 4) the existing arm already returns. | ||
| 3298 | + assert_eq!( | ||
| 3299 | + (plane_block(16, 1, 0).0, plane_block(4, 1, 0).1), | ||
| 3300 | + (8usize, 4usize), | ||
| 3301 | + "{NAME}: site 4 -- the 4:2:2 HORZ strip's own plane block is already \ | ||
| 3302 | + the (8, 4) the unsplit arm returns, which is why only the VERT arm \ | ||
| 3303 | + gained a shape" | ||
| 3304 | + ); | ||
| 3305 | + } | ||
| 3042 | #[test] | 3306 | #[test] |
| 3043 | fn the_pinned_422_residual_compound_warp_witness_is_present_and_refuses_by_name() { | 3307 | fn the_pinned_422_residual_compound_warp_witness_is_present_and_refuses_by_name() { |
| 3044 | const NAME: &str = | 3308 | const NAME: &str = |
lanes/av1422lpf.report.mdadded+328 -0
| @@ -0,0 +1,328 @@ | |||
| 1 | +# lane-av1422lpf — the `--lossless=1` 4:2:2 inter chroma panic family is SEVEN sites, and all seven are fixed | ||
| 2 | + | ||
| 3 | +Base `aef4fa67` (main), worktree `~/.cache/wt/av1422lpf`, branch | ||
| 4 | +`lane-av1422lpf`. **All seven panics are gone. The three cells still do not | ||
| 5 | +decode byte-exact** — §4 says exactly where that residual lives and why it is | ||
| 6 | +not this family. `crates/ec-av1/src/stream.rs` carries no committed probe | ||
| 7 | +bypass; `git status` is clean and the `EC_AV1_ALLOW_422_PROBE` patch is | ||
| 8 | +reverted (patch-run-restore, never committed). | ||
| 9 | + | ||
| 10 | +## 0. Verdict | ||
| 11 | + | ||
| 12 | +| | | | ||
| 13 | +|---|---| | ||
| 14 | +| sites found | **7** (the previous lane found 5; two are the intra twins of sites 1 and 5) | | ||
| 15 | +| sites fixed | **7** | | ||
| 16 | +| sites **not** bugs | **1** (the previous lane's "site 3" — measured, §2 site 3) | | ||
| 17 | +| panics remaining on the three cells | **0** (was 3) | | ||
| 18 | +| regressions on 33 other cells | **0** | | ||
| 19 | +| the three cells byte-exact | **NO** — §4, with the control that names the residual's owner | | ||
| 20 | + | ||
| 21 | +The previous lane reverted because no cell produced a right pixel. That is | ||
| 22 | +still true — but the reason is now known and it is **not** this family: a | ||
| 23 | +single-key-frame 4:2:2 lossless stream diverges on the **intra** path with | ||
| 24 | +the *same* wrong-sample counts on this tree and on main (§4.2). Fixing seven | ||
| 25 | +extent sites cannot fix that, and these seven are correct. | ||
| 26 | + | ||
| 27 | +## 1. The repro, re-verified myself first | ||
| 28 | + | ||
| 29 | +`main` at `aef4fa67`, all three cells, `decode_probe` with the local | ||
| 30 | +`EC_AV1_ALLOW_422_PROBE` bypass: | ||
| 31 | + | ||
| 32 | +``` | ||
| 33 | +W_intrabc.obu 130320 B panicked at decode.rs:37565:24 | ||
| 34 | +X_intrabc_tiled.obu 131696 B range end index 20 out of range for slice of length 16 | ||
| 35 | +Y_intrabc_10b.obu 202281 B read_inter_chroma_lossless -> decode_inter_block | ||
| 36 | + -> decode_inter_frame_tile_with_cdfs | ||
| 37 | +``` | ||
| 38 | + | ||
| 39 | +The previous lane's panic text reproduced exactly. sha256 first 16 hex: | ||
| 40 | + | ||
| 41 | +| cell | sha256 | recipe | | ||
| 42 | +|---|---|---| | ||
| 43 | +| `W_intrabc` | `0aad0d6fdd236557` | testsrc2 320x240 4:2:2 + `--lossless=1` | | ||
| 44 | +| `X_intrabc_tiled` | `e7c0c60af1a61531` | W + `--tile-columns=1 --tile-rows=1` | | ||
| 45 | +| `Y_intrabc_10b` | `ce84d7cb4cfadf3f` | W at 10-bit | | ||
| 46 | + | ||
| 47 | +Committed as fixtures with size + `fnv1a64` pins (`0xb6d5c4653a32567a`, | ||
| 48 | +`0xb6e04621d2116ef7`, `0x2ecf03435a14dbf`). | ||
| 49 | + | ||
| 50 | +**Instrumented geometry at the failing call**, measured on this tree, not | ||
| 51 | +inherited: | ||
| 52 | + | ||
| 53 | +``` | ||
| 54 | +ZZLIC plane=1 ox=0 oy=0 org=(0,0) reg=(4,16) blk=(4,16) stride=4 maxidx=15 alloc=16 | ||
| 55 | +ZZLIC plane=1 ox=0 oy=4 org=(0,0) reg=(4,16) blk=(4,16) stride=4 maxidx=31 alloc=16 | ||
| 56 | +``` | ||
| 57 | + | ||
| 58 | +A **4-wide × 16-tall** chroma plane block read at `stride` 4, needing 32 | ||
| 59 | +elements against the square's 16. | ||
| 60 | + | ||
| 61 | +### 1.1 The previous lane's 4:2:2-only claim is wrong | ||
| 62 | + | ||
| 63 | +Site 1 is **not** 4:2:2-specific, and this is measurable on a stream this | ||
| 64 | +decoder already decodes. A **64x128 4:2:0** block's chroma plane block is | ||
| 65 | +32x64, and `stride * stride` allocates 1024 where the walk addresses 2048: | ||
| 66 | + | ||
| 67 | +``` | ||
| 68 | +$ cargo run --example decode_probe ll420_a.obu # 4:2:0, --lossless=1 | ||
| 69 | +panicked at crates/ec-av1/src/decode.rs:37574:24: | ||
| 70 | +range end index 1028 out of range for slice of length 1024 | ||
| 71 | +ZZLIC ... reg=(32,64) blk=(32,64) stride=32 maxidx=1023 alloc=1024 | ||
| 72 | +ZZLIC ... ox=0 oy=32 ... maxidx=1123 alloc=1024 <- overran | ||
| 73 | +``` | ||
| 74 | + | ||
| 75 | +This stream was never in any prior lane's corpus (the previous lane's 4:2:0 | ||
| 76 | +"lossless" family was encoded from a **4:2:2** y4m — `src_mandel_320x240.y4m` | ||
| 77 | +carries `C422`, so those three cells were 4:2:2 all along and their "exact" | ||
| 78 | +rows were measuring the wrong chroma format). I re-encoded the 4:2:0 corpus | ||
| 79 | +from a real `yuv420p` source; §3 has those numbers. | ||
| 80 | + | ||
| 81 | +## 2. The per-site table | ||
| 82 | + | ||
| 83 | +Every site is one of: the composed grid's **allocation** (`stride * stride`), | ||
| 84 | +or an **index/argument** that reads the enclosing square `chroma_side` = | ||
| 85 | +`max(side >> ss_x, side >> ss_y)` where the plane block's own per-axis | ||
| 86 | +`(bw >> ss_x, bh >> ss_y)` belongs. `chroma_side` equals the plane block | ||
| 87 | +**exactly when `ss_x == ss_y`**, which is why every fix is inert at 4:2:0 and | ||
| 88 | +4:4:4. | ||
| 89 | + | ||
| 90 | +| site | site (function) | old | new | 4:2:0 | 4:4:4 | gate | mutation | | ||
| 91 | +|---|---|---|---|---|---|---|---| | ||
| 92 | +| **1** | `read_inter_chroma_lossless` composed-grid extent | `stride * stride` | `stride * blk_h` | `blk_h == stride` → identical | identical | `the_422_lossless_inter_chroma_walk_sites_stay_per_axis`, row 1 | reds: *"site 1 … is BACK"* | | ||
| 93 | +| **2** | `decode_inter_block` lossless TX_4x4 unit replay | `(cr*cu+rr) * chroma_side + cc*cu` | `… * chroma_stride + …` | identical | identical | same gate, site-2 assertion | reds: *"site 2 is BACK"* | | ||
| 94 | +| **3** | *(the replay's unit counts)* | `write_h >> ss_y(fctx)` | **UNCHANGED — not a bug** | — | — | asserted in the gate's geometry table | n/a | | ||
| 95 | +| **4** | `decode_inter_block` strip chroma rect, VERT arm | `else { (4, 8) }` | `else if ss_y == 0 { (4, 16) } else { (4, 8) }` | `(4,8)` — identical | `(4,16)` — identical | same gate, row 3 | reds: *"site 4 … is BACK"* | | ||
| 96 | +| **5** | mu-chunk lossless walk stride (single-ref + compound) | `chroma_side` | `chroma_stride` | identical | identical | same gate, row 4 (flattened form) | reds: *"site 5 … is BACK"* | | ||
| 97 | +| **6** | intra-in-inter walk block shape (both call sites) | `(chroma_side, chroma_side)` | `(chroma_stride, chroma_buf_h)` | identical | identical | same gate, site-6 assertion | reds: *"site 6 is BACK"* | | ||
| 98 | +| **7** | `read_intra_chroma_lossless` composed-grid extent | `stride * stride` | `stride * blk_h` | identical | identical | same gate, row 2 | reds: *"site 7 … is BACK"* | | ||
| 99 | + | ||
| 100 | +### Site-by-site justification | ||
| 101 | + | ||
| 102 | +**Site 1.** `u_out`/`v_out` is the block's whole chroma **plane block** read at | ||
| 103 | +`stride`, and libaom's plane block is per-axis. The walk addresses row | ||
| 104 | +`org_y + reg_h - 1` at column `org_x + reg_w`; every one of the nine call | ||
| 105 | +sites passes a region that is a sub-rect of `blk` with `org` inside `blk`, so | ||
| 106 | +the requirement is exactly `stride * blk_h` (the last row's end | ||
| 107 | +`(blk_h-1)*stride + blk_w` fits because `blk_w <= stride` at all nine). Where | ||
| 108 | +the plane block is square — 4:2:0 and 4:4:4 on a square block — `blk_h == | ||
| 109 | +stride` and this reduces to the old expression **verbatim**. Measured panic | ||
| 110 | +removed: `range end index 20 … length 16` gone on all three cells, **and** | ||
| 111 | +`range end index 1028 … length 1024` gone on the 4:2:0 stream. | ||
| 112 | + | ||
| 113 | +**Site 2.** The composed grid this replays is the plane block at | ||
| 114 | +`chroma_stride` — the same stride site 1 sized it at and the same stride | ||
| 115 | +`read_inter_chroma_lossless` wrote it at. `chroma_side` at 4:2:2 is the LUMA | ||
| 116 | +side, twice a strip block's plane-block width. Measured: `range end index 68 | ||
| 117 | +out of range for slice of length 64` on `W_intrabc` frame 1. | ||
| 118 | + | ||
| 119 | +**Site 3 is NOT a bug — the previous lane's site 3 was a misreading.** It | ||
| 120 | +proposed changing the unit counts | ||
| 121 | + | ||
| 122 | +```rust | ||
| 123 | +let (rows, cols) = ((write_h >> ss_y(fctx)).div_ceil(cu), (write_w >> ss_x(fctx)).div_ceil(cu)); | ||
| 124 | +``` | ||
| 125 | + | ||
| 126 | +These are *already* per-axis: `>> ss_y` and `>> ss_x` are the plane block's own | ||
| 127 | +axes, so `rows` counts chroma rows at 4:2:2 exactly as at 4:2:0. Measured on | ||
| 128 | +the failing cell: `write=(8,16) ss=(1,0)` gives `rows=4, cols=1` against a | ||
| 129 | +`(4,16)` plane block — correct. Applying the previous lane's | ||
| 130 | +`(chroma_buf_h, chroma_stride)` rewrite would have been a no-op at best. | ||
| 131 | +**Not changed.** The gate asserts the per-axis geometry table instead. | ||
| 132 | + | ||
| 133 | +**Site 4.** A `PARTITION_VERT_4` strip is 4x16 luma and pairs on **columns** | ||
| 134 | +while `ss_x == 1` (`is_chroma_reference` on `mi_col` parity, | ||
| 135 | +`av1_common_int.h:1454`), so the pair is 8x16 luma. 4:2:2 subsamples X only, | ||
| 136 | +which leaves the pair's plane block at `8>>1 x 16>>0` = **4x16**, twice as | ||
| 137 | +tall as 4:2:0's 4x8. Measured: a 4x16 vert strip got `chroma_stride = 4`, | ||
| 138 | +`chroma_buf_h = 8`, a 32-sample grid, and the replay's last unit row read | ||
| 139 | +index 64 of it. The HORZ arm needs **no** third shape at 4:2:2 and gets none: | ||
| 140 | +a HORZ_4 strip pairs on rows only while `ss_y == 1`, and 4:2:2 has `ss_y == 0`, | ||
| 141 | +so each 16x4 strip is its own chroma reference with its own `(8>>1, 4>>0)` | ||
| 142 | += (8,4) plane block — the number the existing arm already returned. The gate | ||
| 143 | +asserts both of those geometries, so a future "simplification" that folds | ||
| 144 | +the VERT arm back cannot pass silently. | ||
| 145 | + | ||
| 146 | +**Site 5.** The stride the walk indexes `su`/`sv` at is the **prediction | ||
| 147 | +buffer's own** `chroma_stride` — the number `su`/`sv` were built at and the | ||
| 148 | +number the composed grid is sized and written at (site 1). Measured on | ||
| 149 | +`X_intrabc_tiled` frame 1: `cpx=64 cpy=0 reg=(32,64) blk=(64,128) ss=(1,0)`, | ||
| 150 | +the walk addressed `oy*128 + ox` on a 64-wide 8192-sample buffer and the last | ||
| 151 | +unit row ran off the end (`offset 8192 .. 8580 of 8192`). | ||
| 152 | + | ||
| 153 | +**Site 6.** The intra-in-inter twin of site 5. `palette_uv_bufs` is the decoded | ||
| 154 | +colour-index map at `(write_w >> ss_x, write_h >> ss_y)` — per-axis already — | ||
| 155 | +and the lossless walk windows it at this `stride`. Measured on | ||
| 156 | +`Y_intrabc_10b.obu`: `buf_len=128 stride=16 org=(0,8)` put the third unit row | ||
| 157 | +at index 180 (`palette_window`, `decode.rs:2946`). | ||
| 158 | + | ||
| 159 | +**Site 7.** `read_intra_chroma_lossless` carries site 1's defect verbatim, | ||
| 160 | +including its own `(blk_w, blk_h)` parameter, so the intra twin gets | ||
| 161 | +`stride * blk_h` too. Measured: `range end index 36 out of range for slice of | ||
| 162 | +length 32`. | ||
| 163 | + | ||
| 164 | +## 3. End state, per cell, with controls | ||
| 165 | + | ||
| 166 | +Comparator: the crate's own `count_rawvideo_diffs` logic (via a throwaway | ||
| 167 | +sweep harness modelled on it — oracle `aomdec --rawvideo` bytes read | ||
| 168 | +directly, per-frame plane attribution from each decoded frame's own plane | ||
| 169 | +lengths). A pristine-main binary was built in a separate worktree | ||
| 170 | +(`~/.cache/wt/av1422base`, same harness, same probe bypass) so every number | ||
| 171 | +below is a **diff against main**, not a claim. | ||
| 172 | + | ||
| 173 | +### 3.1 The three panic cells | ||
| 174 | + | ||
| 175 | +| cell | main `aef4fa67` | this lane | | ||
| 176 | +|---|---|---| | ||
| 177 | +| `W_intrabc` | **PANIC** `decode.rs:37565` | Golomb-tail refusal at frame 2 | | ||
| 178 | +| `X_intrabc_tiled` | **PANIC** `decode.rs:37565` | Golomb-tail refusal at frame 2 | | ||
| 179 | +| `Y_intrabc_10b` | **PANIC** `decode.rs:37565` | decodes 16/16, diverges Y 2 069 389 / U 1 031 181 / V 1 084 387 | | ||
| 180 | + | ||
| 181 | +All three panics are gone. None is byte-exact. §4 says why. | ||
| 182 | + | ||
| 183 | +### 3.2 Zero regressions — the full 33-cell diff | ||
| 184 | + | ||
| 185 | +Every cell re-run on both trees; `diff` of the two tables is **empty** except | ||
| 186 | +the three cells above. | ||
| 187 | + | ||
| 188 | +| family | cells | main | this lane | | ||
| 189 | +|---|---|---|---| | ||
| 190 | +| 4:2:2 committed pins | `422_allskip_2f`, `422_intrabc_sb128_strip`, `…_notxsearch`, `422_residual_compound_warp_16f`, `…_nolr_16f`, `422_sb128_3f` | 6/6 EXACT | **6/6 EXACT** | | ||
| 191 | +| 4:2:2 lossy corpus | `AA_inter_compound`, `AD_inter_nogm`, `A`,`B`,`C`,`D`,`E`,`F`,`H`,`I`,`J`,`K`,`L`,`R`,`T`,`U`,`V` | 17/17 EXACT | **17/17 EXACT** | | ||
| 192 | +| 4:2:2 pre-existing divergences | `AB_inter_warp_odd`, `O_odd322x242`, `Q_odd320x242`, `S_odd326x242_10b` | DIVERGES | **DIVERGES, identical counts** | | ||
| 193 | +| 4:2:0 lossless (re-encoded from a real `yuv420p` source) | `ll420_a/b/c/d` | 4/4 EXACT | **4/4 EXACT** | | ||
| 194 | +| 4:4:4 lossless | `ll444_a`, `ll444_b` | 2/2 EXACT | **2/2 EXACT** | | ||
| 195 | +| 4:4:4 lossless + altref | `ll444_c` | DIVERGES 7/16 | **DIVERGES, identical counts** | | ||
| 196 | +| 4:2:0/4:4:4 all-intra lossless controls | `ll420_allintra`, `ll444_allintra` | 2/2 EXACT | **2/2 EXACT** | | ||
| 197 | + | ||
| 198 | +### 3.3 The site-4 lossy re-quote (the regression surface) | ||
| 199 | + | ||
| 200 | +Site 4 is the one change with a real regression surface: it alters | ||
| 201 | +`chroma_stride`/`chroma_buf_h` for the **whole** of `decode_inter_block` at | ||
| 202 | +4:2:2, including the LOSSY arms. Re-quoted individually, not as a set: | ||
| 203 | + | ||
| 204 | +| cell | shape exercising site 4 | main | this lane | bytes | | ||
| 205 | +|---|---|---|---|---| | ||
| 206 | +| `422_residual_compound_warp_16f` | vertical-midpoint compound + warp | EXACT 16/16 | EXACT 16/16 | 0 wrong | | ||
| 207 | +| `422_residual_compound_warp_nolr_16f` | same, LR off | EXACT 16/16 | EXACT 16/16 | 0 wrong | | ||
| 208 | +| `422_sb128_3f` | sb128 skip-heavy inter | EXACT 3/3 | EXACT 3/3 | 0 wrong | | ||
| 209 | +| `AA_inter_compound` | compound inter, 40 frames | EXACT 40/40 | EXACT 40/40 | 0 wrong | | ||
| 210 | +| `AD_inter_nogm` | inter, no global motion, 40 frames | EXACT 40/40 | EXACT 40/40 | 0 wrong | | ||
| 211 | +| `L_tiled` / `T_tilecols2` / `U_tilerows1` / `V_tile2x2_odd` | tiled inter | EXACT 16/16 each | EXACT 16/16 each | 0 wrong | | ||
| 212 | +| `AB_inter_warp_odd` | warp on odd dims | DIVERGES U 3 642 / V 10 186 | **identical** | unchanged | | ||
| 213 | + | ||
| 214 | +**Site 4 is not a regression.** Every lossy 4:2:2 arm that measured | ||
| 215 | +byte-exact on main still measures byte-exact, to the sample, and the one | ||
| 216 | +pre-existing divergence is unchanged in magnitude. | ||
| 217 | + | ||
| 218 | +### 3.4 Gates, with mutation proof | ||
| 219 | + | ||
| 220 | +`the_422_lossless_inter_chroma_walk_sites_stay_per_axis` — one assertion per | ||
| 221 | +site. Every scan assertion has a **forbidden twin** (the square-cut spelling | ||
| 222 | +is absent) *and* a **required twin** (the per-axis spelling is present), so | ||
| 223 | +neither an unreverted site nor a matcher that stopped matching can pass. | ||
| 224 | + | ||
| 225 | +| mutation | result | | ||
| 226 | +|---|---| | ||
| 227 | +| site 1 → `stride * stride` | **RED** *"site 1 … is BACK"* | | ||
| 228 | +| site 7 → `stride * stride` | **RED** *"site 7 … is BACK"* | | ||
| 229 | +| site 2 → `chroma_side` | **RED** *"site 2 is BACK"* | | ||
| 230 | +| site 4 → drop the `ss_y == 0` arm | **RED** *"site 4 … is BACK"* | | ||
| 231 | +| site 5 → `chroma_side` at both mu-chunk walks | **RED** *"site 5 … is BACK"* | | ||
| 232 | +| site 6 → `(chroma_side, chroma_side)` | **RED** *"site 6 is BACK"* | | ||
| 233 | + | ||
| 234 | +**Two matchers were dead on first write and are named as such.** Sites 5 and | ||
| 235 | +6 initially passed their own revert mutation: the literals being searched for | ||
| 236 | +never matched even *with* the fix in place, because a line-anchored matcher | ||
| 237 | +cannot span the comment the fix itself writes into its argument list. That is | ||
| 238 | +the `dead-matcher-positive-control` class, caught by running the mutation | ||
| 239 | +rather than trusting the green. The gate now builds a **whitespace-flattened** | ||
| 240 | +second form of each body for the matchers that span an argument list, and both | ||
| 241 | +re-run mutations now red. A gate I did not mutate would have shipped two holes | ||
| 242 | +in it. | ||
| 243 | + | ||
| 244 | +### 3.5 Gates run, scoped | ||
| 245 | + | ||
| 246 | +Clean tree at `69a3a4df`: | ||
| 247 | + | ||
| 248 | +- `the_pinned_422_lossless_inter_chroma_panics_refuse_by_name` — pass | ||
| 249 | +- `the_422_lossless_inter_chroma_walk_sites_stay_per_axis` — pass | ||
| 250 | +- `the_pinned_422_intrabc_sb128_strip_witnesses_refuse_by_name` — pass | ||
| 251 | +- `the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name` — pass | ||
| 252 | +- `the_pinned_422_lr_off_witness_is_present_and_refuses_by_name` — pass | ||
| 253 | +- `the_pinned_422_residual_compound_warp_witness_is_present_and_refuses_by_name` — pass | ||
| 254 | +- `a_lossless_libaom_inter_frame_decodes_sample_exact` — pass | ||
| 255 | +- 4:4:4 family (`444`, `lossless`, `ll444` filters) — **62 passed, 0 failed** | ||
| 256 | +- 4:2:0 family (`pixel_exact_420`, `420` filters) — **6 passed, 0 failed** | ||
| 257 | +- oracle binary `~/.cache/aom-oracle/build/aomdec` (instrumented, rung 12) | ||
| 258 | + | ||
| 259 | +## 4. What is NOT byte-exact, and the control that names its owner | ||
| 260 | + | ||
| 261 | +The charter asked for the three cells byte-exact. **They are not.** The | ||
| 262 | +residual is real, and the measurement below locates it **outside** this family. | ||
| 263 | + | ||
| 264 | +### 4.1 Two of them refuse; one decodes and diverges | ||
| 265 | + | ||
| 266 | +| cell | symptom | located at | | ||
| 267 | +|---|---|---| | ||
| 268 | +| `W_intrabc` | `a Golomb tail longer than this decoder reads` | mi (16,52) | | ||
| 269 | +| `X_intrabc_tiled` | same | mi (8,64) | | ||
| 270 | +| `Y_intrabc_10b` | decodes all 16 frames, diverges from frame 0 byte 16 (luma, got 40 want 68) | frame 0, first luma sample | | ||
| 271 | + | ||
| 272 | +A Golomb-tail refusal is always the **symptom** of an earlier desync (the code | ||
| 273 | +says so at `decode.rs:7965`), never a reader gap. | ||
| 274 | + | ||
| 275 | +### 4.2 The control that decides it | ||
| 276 | + | ||
| 277 | +A **single-key-frame**, `--lossless=1` 4:2:2 stream with **no inter content | ||
| 278 | +at all** — nothing in this family is reachable — diverges identically on this | ||
| 279 | +tree and on main: | ||
| 280 | + | ||
| 281 | +| cell | main | this lane | | ||
| 282 | +|---|---|---| | ||
| 283 | +| `ll422_allintra` (1 key frame, all-intra, 4:2:2 lossless) | DIVERGES **Y 75 210 / U 38 234 / V 38 207** | **Y 75 210 / U 38 234 / V 38 207** — identical | | ||
| 284 | +| `ll420_allintra` (same recipe, 4:2:0) | EXACT | EXACT | | ||
| 285 | +| `ll444_allintra` (same recipe, 4:4:4) | EXACT | EXACT | | ||
| 286 | + | ||
| 287 | +**Byte-identical wrong-sample counts on the same recipe at two chroma | ||
| 288 | +formats and clean at the other two.** The 4:2:2 lossless **intra** path | ||
| 289 | +diverges from `aomdec` on main, before any inter chroma walk runs, and my | ||
| 290 | +seven extents neither caused nor changed one sample of it. That is a | ||
| 291 | +pre-existing defect with its own owner; chasing it here would be the | ||
| 292 | +"substitute an easier problem" failure, and closing it is not what makes these | ||
| 293 | +seven extents correct. | ||
| 294 | + | ||
| 295 | +`Y_intrabc_10b` diverges from **frame 0 byte 16** — its first key frame, i.e. | ||
| 296 | +the same intra path. `W`/`X` reach frame 2 before their entropy desync, which is | ||
| 297 | +where a *later* inter defect can still be hiding; I have not excluded that a | ||
| 298 | +second inter-side defect exists behind the intra one. That is named in | ||
| 299 | +`not_done`, not claimed clean. | ||
| 300 | + | ||
| 301 | +## 5. `not_done` | ||
| 302 | + | ||
| 303 | +- **The three cells do not decode byte-exact.** Two refuse with a Golomb-tail | ||
| 304 | + desync at frame 2, one diverges from frame 0. Exact reason and control: §4. | ||
| 305 | +- **The 4:2:2 lossless INTRA path diverges from `aomdec`** (byte-identical on | ||
| 306 | + main and here, §4.2) — pre-existing, not in this family, **not fixed here**. | ||
| 307 | + It must be fixed before any of the three cells can reach byte-exact, and it | ||
| 308 | + is a separate lane. | ||
| 309 | +- **A possible second inter-side defect behind the intra one is NOT excluded.** | ||
| 310 | + `W`/`X` desync at frame 2, and an intra-only stream already diverges, so the | ||
| 311 | + frame-2 desync cannot yet be attributed. Only "no panic" is claimed. | ||
| 312 | +- **Site 4's HORZ arm was measured, not exercised by a witness.** The gate | ||
| 313 | + derives its (8,4) geometry; no pinned stream is cited as hitting it. | ||
| 314 | +- **Decode-order (rung 12) comparison was not run on the three cells** — they | ||
| 315 | + do not decode to completion, so there is nothing to zip against the oracle's | ||
| 316 | + per-frame dumps. Presented-order only, and only for the cells that complete. | ||
| 317 | +- **Full suite not run** (lane rules: scoped only; project-wide validation is | ||
| 318 | + Main's). | ||
| 319 | + | ||
| 320 | +## 6. Instrumentation disclosure | ||
| 321 | + | ||
| 322 | +Five temporary `eprintln` probes (`ZZLIC`, `ZZLIC2`, `ZZLIC3`, `ZZLIC4`, | ||
| 323 | +`ZZLIC5`, `ZZGOL`) and one throwaway `examples/zz_sweep.rs`, **all removed** | ||
| 324 | +before the commit — `crates/ec-av1/src/decode.rs` at `6d816368` contains only | ||
| 325 | +the seven fixes and their comments. The `EC_AV1_ALLOW_422_PROBE` bypass at | ||
| 326 | +`stream.rs` is patch-run-restore and is in **no** commit; `git status` is | ||
| 327 | +clean. Nothing was added to the decoder or the oracle beyond the seven | ||
| 328 | +expression changes. | ||