ec-av1: lane-av1-422inter -- the frame-9 read_coeffs_rect scratch panic fixed at the source: the 4:2:2 intra-in-inter side-64 chroma walks TWO stacked square TX_32X32 units per plane (av1_get_max_uv_txsize adjusts TX_32X64 down to TX_32X32, the key-frame path's own model) instead of one whole-plane-block 32x64 rect unit whose 36x68 levels frame the scratch never had; the reader's sizing guard and every other arm untouched, 4:2:0/4:4:4 byte-identical; frame 0 of the pinned t422 fixture stays byte-exact at PREFILT/POSTDEBLOCK/POSTCDEF/FINAL and all 16 frames now decode; the inter divergence is remeasured with the stage ladder (diverges from (0,0) at PREFILT from frame 1, filters track 1:1) and attributed by EC_ISTEP/EC_COEFF pairing to the first coded block's chroma tail: decode_inter_block8 models the 4:2:2 leaf chroma plane block (4x8, one TX_4X8 rect unit per plane) as a 4x4 square, which desyncs the entropy walk at frame 1 mi(0,0) -- a whole-chroma-half shape class (prediction, skip pushes, coefficient read, plus the sub8 split-group's Chroma4 read), not a one-site edit, so the lane stops with that site named
Browse files at this commit08f3d51e1f70a5f4900854358904629e1786672aParent: 69cef8e2 changed files +271 -0
- crates/ec-av1/src/decode.rs +137 -0
- lanes/av1422inter.report.md +134 -0
crates/ec-av1/src/decode.rsmodified+137 -0
| @@ -35616,6 +35616,83 @@ fn decode_inter_block( | |||
| 35616 | None, | 35616 | None, |
| 35617 | smooth_neighbor_uv, fctx, | 35617 | smooth_neighbor_uv, fctx, |
| 35618 | )? | 35618 | )? |
| 35619 | + } else if side == 64 { | ||
| 35620 | + // lane-av1-422inter: `av1_get_max_uv_txsize(BLOCK_64X64)` at | ||
| 35621 | + // ss (1,0) adjusts `max_txsize_rect_lookup[BLOCK_32X64]` = | ||
| 35622 | + // TX_32X64 down to TX_32X32 (`av1_get_adjusted_tx_size`), so | ||
| 35623 | + // the (side/2, side) = (32, 64) plane block codes TWO stacked | ||
| 35624 | + // SQUARE TX_32X32 units per plane, plane-major -- the | ||
| 35625 | + // key-frame path's own model (`decode_block`'s 4:2:2 | ||
| 35626 | + // chroma_tx table, "64 and 128: TX_32X64 / TX_64X64 adjust | ||
| 35627 | + // down to TX_32X32", proven byte-exact on this fixture's | ||
| 35628 | + // frame 0) and the twin of this function's own side>64 | ||
| 35629 | + // mu-chunk walk above. The whole-plane-block rect read this | ||
| 35630 | + // arm replaced handed [`read_coeffs_rect`] a 36x68 levels | ||
| 35631 | + // frame it never had (the frame-9 panic) and would have read | ||
| 35632 | + // a full TX_32X64 scan libaom never codes. | ||
| 35633 | + let cu_scan = default_scan(32); | ||
| 35634 | + let (cu_w, cu_h) = (32usize, 32usize); | ||
| 35635 | + let luma_span_x = cu_w << ss_x(fctx); | ||
| 35636 | + let luma_span_y = cu_h << ss_y(fctx); | ||
| 35637 | + let mut assembled = vec![0i32; chroma_side * chroma_side]; | ||
| 35638 | + for cu_row in 0..chroma_h / cu_h { | ||
| 35639 | + let cu_mi = (at_mi.0 + cu_row * (luma_span_y / MI), at_mi.1); | ||
| 35640 | + let cu_around = | ||
| 35641 | + neighbours.around_mi_422_chroma(cu_mi, luma_span_x, luma_span_y); | ||
| 35642 | + let cu_reach = tu_reach_rect( | ||
| 35643 | + side, | ||
| 35644 | + side, | ||
| 35645 | + 0, | ||
| 35646 | + cu_row * luma_span_y, | ||
| 35647 | + luma_span_x, | ||
| 35648 | + luma_span_y, | ||
| 35649 | + reach, | ||
| 35650 | + px, | ||
| 35651 | + py, | ||
| 35652 | + y.width, | ||
| 35653 | + y.height, fctx, | ||
| 35654 | + ); | ||
| 35655 | + let cu_grid = read_plane( | ||
| 35656 | + dec, | ||
| 35657 | + cdfs, | ||
| 35658 | + TxbSet::Chroma32, | ||
| 35659 | + &cu_scan, | ||
| 35660 | + 1, | ||
| 35661 | + cu_around[1], | ||
| 35662 | + mode, | ||
| 35663 | + uv_predict_mode, | ||
| 35664 | + angle_delta_uv, | ||
| 35665 | + cu_reach, | ||
| 35666 | + u, | ||
| 35667 | + cpx, | ||
| 35668 | + cpy + cu_row * cu_h, | ||
| 35669 | + cu_w, | ||
| 35670 | + cu_w, | ||
| 35671 | + base_q_idx, | ||
| 35672 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | ||
| 35673 | + None, | ||
| 35674 | + // The uv plane block (32x64) is larger than the unit | ||
| 35675 | + // (32x32): `get_txb_ctx`'s offset-10 rows, +3 on the | ||
| 35676 | + // `txb_skip_chroma_32` table (lane-sb128b r3). | ||
| 35677 | + Some(3), | ||
| 35678 | + smooth_neighbor_uv, fctx, | ||
| 35679 | + )?; | ||
| 35680 | + hit!(CHROMA_SPLIT_TX_HITS); | ||
| 35681 | + hit!(CHROMA422_SQUARE_HITS); | ||
| 35682 | + // Immediately, so the next unit of this plane reads this | ||
| 35683 | + // one's coefficient context; the whole-block record below | ||
| 35684 | + // re-stamps the block over these and the tail's | ||
| 35685 | + // `mu_chroma_units` replay puts the per-unit state back | ||
| 35686 | + // (lane-dpm1). | ||
| 35687 | + neighbours.record_mi_chroma(cu_mi, luma_span_x, luma_span_y, 1, &cu_grid); | ||
| 35688 | + for rr in 0..cu_h { | ||
| 35689 | + let start = (cu_row * cu_h + rr) * chroma_side; | ||
| 35690 | + assembled[start..start + cu_w] | ||
| 35691 | + .copy_from_slice(&cu_grid[rr * cu_w..][..cu_w]); | ||
| 35692 | + } | ||
| 35693 | + } | ||
| 35694 | + mu_chroma = true; | ||
| 35695 | + Grid::Own(assembled) | ||
| 35619 | } else { | 35696 | } else { |
| 35620 | let (rect_set, rect_scan): (TxbSet, &[u16]) = match side { | 35697 | let (rect_set, rect_scan): (TxbSet, &[u16]) = match side { |
| 35621 | 4 => (TxbSet::Chroma4, default_scan(4)), | 35698 | 4 => (TxbSet::Chroma4, default_scan(4)), |
| @@ -35658,6 +35735,66 @@ fn decode_inter_block( | |||
| 35658 | None, | 35735 | None, |
| 35659 | smooth_neighbor_uv, fctx, | 35736 | smooth_neighbor_uv, fctx, |
| 35660 | )? | 35737 | )? |
| 35738 | + } else if side == 64 { | ||
| 35739 | + // lane-av1-422inter: plane 2 of the TX_32X32-adjusted walk | ||
| 35740 | + // above -- same two stacked square units, plane-major (every | ||
| 35741 | + // U unit, then every V unit, libaom `decode_token_recon_block`'s | ||
| 35742 | + // per-mu-chunk plane loop). | ||
| 35743 | + let cu_scan = default_scan(32); | ||
| 35744 | + let (cu_w, cu_h) = (32usize, 32usize); | ||
| 35745 | + let luma_span_x = cu_w << ss_x(fctx); | ||
| 35746 | + let luma_span_y = cu_h << ss_y(fctx); | ||
| 35747 | + let mut assembled = vec![0i32; chroma_side * chroma_side]; | ||
| 35748 | + for cu_row in 0..chroma_h / cu_h { | ||
| 35749 | + let cu_mi = (at_mi.0 + cu_row * (luma_span_y / MI), at_mi.1); | ||
| 35750 | + let cu_around = | ||
| 35751 | + neighbours.around_mi_422_chroma(cu_mi, luma_span_x, luma_span_y); | ||
| 35752 | + let cu_reach = tu_reach_rect( | ||
| 35753 | + side, | ||
| 35754 | + side, | ||
| 35755 | + 0, | ||
| 35756 | + cu_row * luma_span_y, | ||
| 35757 | + luma_span_x, | ||
| 35758 | + luma_span_y, | ||
| 35759 | + reach, | ||
| 35760 | + px, | ||
| 35761 | + py, | ||
| 35762 | + y.width, | ||
| 35763 | + y.height, fctx, | ||
| 35764 | + ); | ||
| 35765 | + let cu_grid = read_plane( | ||
| 35766 | + dec, | ||
| 35767 | + cdfs, | ||
| 35768 | + TxbSet::Chroma32, | ||
| 35769 | + &cu_scan, | ||
| 35770 | + 2, | ||
| 35771 | + cu_around[2], | ||
| 35772 | + mode, | ||
| 35773 | + uv_predict_mode, | ||
| 35774 | + angle_delta_uv, | ||
| 35775 | + cu_reach, | ||
| 35776 | + v, | ||
| 35777 | + cpx, | ||
| 35778 | + cpy + cu_row * cu_h, | ||
| 35779 | + cu_w, | ||
| 35780 | + cu_w, | ||
| 35781 | + base_q_idx, | ||
| 35782 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | ||
| 35783 | + None, | ||
| 35784 | + Some(3), | ||
| 35785 | + smooth_neighbor_uv, fctx, | ||
| 35786 | + )?; | ||
| 35787 | + hit!(CHROMA_SPLIT_TX_HITS); | ||
| 35788 | + hit!(CHROMA422_SQUARE_HITS); | ||
| 35789 | + neighbours.record_mi_chroma(cu_mi, luma_span_x, luma_span_y, 2, &cu_grid); | ||
| 35790 | + for rr in 0..cu_h { | ||
| 35791 | + let start = (cu_row * cu_h + rr) * chroma_side; | ||
| 35792 | + assembled[start..start + cu_w] | ||
| 35793 | + .copy_from_slice(&cu_grid[rr * cu_w..][..cu_w]); | ||
| 35794 | + } | ||
| 35795 | + } | ||
| 35796 | + mu_chroma = true; | ||
| 35797 | + Grid::Own(assembled) | ||
| 35661 | } else { | 35798 | } else { |
| 35662 | let (rect_set, rect_scan): (TxbSet, &[u16]) = match side { | 35799 | let (rect_set, rect_scan): (TxbSet, &[u16]) = match side { |
| 35663 | 4 => (TxbSet::Chroma4, default_scan(4)), | 35800 | 4 => (TxbSet::Chroma4, default_scan(4)), |
lanes/av1422inter.report.mdadded+134 -0
| @@ -0,0 +1,134 @@ | |||
| 1 | +# lane-av1-422inter — the frame-9 `read_coeffs_rect` scratch panic fixed at the | ||
| 2 | +# source (the 4:2:2 intra-in-inter side-64 chroma is TWO square TX_32X32 units, | ||
| 3 | +# not one 32x64 rect unit); the inter-frame divergence remeasured with the | ||
| 4 | +# stage ladder and STOPPED at the sub-8x8 inter chroma class (`decode_inter_block8`) | ||
| 5 | + | ||
| 6 | +## Outcome | ||
| 7 | + | ||
| 8 | +1. REMEASURED first (pinned fixture `/tmp/t422.obu` sha256 | ||
| 9 | + `d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129`, | ||
| 10 | + 256x144 / chroma 128x144, 16 coded frames, local `EC_AV1_ALLOW_422_PROBE` | ||
| 11 | + bypass applied and reverted byte-identical after — `git diff` after the | ||
| 12 | + revert carries only the decode.rs fix): reproduced the frame-9 panic | ||
| 13 | + exactly as the r lane named it — `rect coeff scratch w=32 h=64 n=2448` | ||
| 14 | + at [`read_coeffs_rect`]'s guard (decode.rs:7195), backtrace | ||
| 15 | + `decode_inter_block` -> `read_rect_chroma_unit`; 9 frames decoded before | ||
| 16 | + the abort. | ||
| 17 | +2. ROOT CAUSE, and why the scratch itself stays untouched: the panic site is | ||
| 18 | + `decode_inter_block`'s intra-in-inter 4:2:2 chroma arm (lane-av1-422k's | ||
| 19 | + `chroma_w != chroma_h` dispatch), whose `_` side-match handed the WHOLE | ||
| 20 | + uv plane block (32x64) to [`read_rect_chroma_unit`] as ONE rect unit. But | ||
| 21 | + `av1_get_max_uv_txsize(BLOCK_64X64)` at ss (1,0) is | ||
| 22 | + `av1_get_adjusted_tx_size(max_txsize_rect_lookup[BLOCK_32X64])` = | ||
| 23 | + `av1_get_adjusted_tx_size(TX_32X64)` = **TX_32X32** — libaom codes TWO | ||
| 24 | + stacked SQUARE 32x32 units per plane, plane-major (U r0, U r1, then V | ||
| 25 | + r0, V r1), never a TX_32X64 coefficient read (no such scan exists in | ||
| 26 | + this decoder and libaom writes none: a 64-axis codes its low-32 corner). | ||
| 27 | + Lifting the scratch bound to 36x68 (the r lane's tentative "heap | ||
| 28 | + fallback" sketch) would have read a full 32x64 scan and desynced on the | ||
| 29 | + very first such unit. The KEY-FRAME path has carried the correct model | ||
| 30 | + since lane-av1-422f (`decode_block`'s 4:2:2 chroma_tx table: "64 and | ||
| 31 | + 128: TX_32X64 / TX_64X64 adjust down to TX_32X32, square units, a 1x2 / | ||
| 32 | + 2x4 grid") — proven byte-exact on this fixture's frame 0. | ||
| 33 | +3. FIX (the sibling 444 per-unit-walk pattern): the `side == 64` arm at | ||
| 34 | + `decode_inter_block`'s intra-in-inter chroma now walks the two stacked | ||
| 35 | + 32x32 square units per plane through [`read_plane`] (`TxbSet::Chroma32`, | ||
| 36 | + `SCAN_32`, txb_skip ctx = above+left+3 — the offset-10 rows, the plane | ||
| 37 | + block being bigger than the unit), each with its own per-chroma-cell | ||
| 38 | + context read (`around_mi_422_chroma` at the unit's luma span), its own | ||
| 39 | + `tu_reach_rect`, immediate `record_mi_chroma`, assembled into the | ||
| 40 | + chroma_side-strided block grid, with `mu_chroma = true` so the tail's | ||
| 41 | + existing `mu_chroma_units` enumeration replays the per-unit entropy | ||
| 42 | + state after the whole-block record (the lane-dpm1 mechanism; its | ||
| 43 | + (rows, cols, ur, uc) walk already derives exactly these two units per | ||
| 44 | + plane at ss (1,0)). The 4/8/16/32 rect arms and the square | ||
| 45 | + `chroma_w == chroma_h` arm are untouched — 4:2:0 and 4:4:4 are | ||
| 46 | + byte-identical by construction (ss-keyed). `read_coeffs_rect` itself is | ||
| 47 | + untouched: with the adjusted-tx model no caller can deliver a unit | ||
| 48 | + bigger than 32x32's 36x36 levels frame, which is the invariant the | ||
| 49 | + scratch sizing always stated. | ||
| 50 | +4. MEASURED after the fix (16 frames decode, no panic; the probe's | ||
| 51 | + `chroma422_square` counter rose 24 -> 87 across the stream, the touched | ||
| 52 | + class provably firing on inter frames): frame 0 is **byte-exact vs the | ||
| 53 | + instrumented aomdec at PREFILT, POSTDEBLOCK, POSTCDEF and FINAL on Y, U | ||
| 54 | + and V** (0 diffs everywhere — the parent lanes' frame-0 exactness | ||
| 55 | + survives). The inter frames stay divergent: per-frame stage-ladder | ||
| 56 | + counts (ours padded-cropped vs oracle, both vs the same instrumented | ||
| 57 | + `$HOME/.cache/aom-oracle/build` aomdec): | ||
| 58 | + - frame 1: PREFILT Y 30825 / U 12624 / V 12796, first Y (0,8) 76 vs 80, | ||
| 59 | + first U (0,0) 231 vs 90, first V (0,0) 164 vs 241; | ||
| 60 | + - frames 1..16 all diverge from (0,0) with ~28-35k Y / ~12-17k U / | ||
| 61 | + ~11-17k V per frame at PREFILT, and POSTDEBLOCK / POSTCDEF / FINAL | ||
| 62 | + track the same first samples 1:1 (the loop filters introduce no new | ||
| 63 | + first-diff site) — a pre-filter reconstruction class, filters | ||
| 64 | + exonerated. | ||
| 65 | +5. ATTRIBUTION (2-frame cut, `EC_TRACE_MODE_STEP` + `EC_TRACE_COEFF` | ||
| 66 | + pairing against the oracle's own rungs): every commonly-traced mode / | ||
| 67 | + skip / angle / uv_mode read of frames 0+1 agrees rng-for-rng (1326 | ||
| 68 | + paired lines, 0 mismatches), and the first 873 coefficient reads | ||
| 69 | + (frame 0 in full) agree — the entropy walk is in sync up to frame 1's | ||
| 70 | + first coded block. The FIRST divergence is that block's own tail: at | ||
| 71 | + mi (0,0) (8x8 inter leaf, NEARESTMV (0,0), coded), after the leaf's | ||
| 72 | + luma TX_8X8 txb_skip bit (agreed, rng 55168) the oracle reads the | ||
| 73 | + leaf's **U TX_4X8 rect chroma unit** (ctx 7 row, coded) then V — while | ||
| 74 | + OURS reads a TX_4X4-SQUARE-shaped unit (`TxbSet::Chroma4`, | ||
| 75 | + ctx = above+left, no offset-7 row). `decode_inter_block8`'s chroma half | ||
| 76 | + models the 4:2:2 leaf chroma plane block — `ss_size_lookup | ||
| 77 | + [BLOCK_8X8][1][0]` = BLOCK_4X8, one TX_4X8 rect unit per plane | ||
| 78 | + (`av1_get_max_uv_txsize`) — as a `chroma_side = SIDE >> ss_x` = 4 | ||
| 79 | + square: wrong coefficient set/scan/ctx rows, and the same 4x4 square | ||
| 80 | + shape flows into the leaf's MC prediction, skip push and interintra | ||
| 81 | + blends. Pixel witness: frame-1 U (0,0) ours=231 ~= frame-0's 225 (the | ||
| 82 | + zero-mv prediction with only a square-read residue applied) vs the | ||
| 83 | + oracle's 90 (the coded TX_4X8 residual applied). | ||
| 84 | +6. That defect class is not a one-site edit: the leaf's whole chroma half | ||
| 85 | + must move to (4,8) shapes — prediction build, skip/interintra/OBMC | ||
| 86 | + pushes, the rect coefficient read (`TxbSet::ChromaRect8x4` / | ||
| 87 | + `SCAN_4X8`, offset-7 ctx rows, inherited luma tx type via | ||
| 88 | + [`read_inter_plane_rect`]) — and the sub8 split-group's own chroma read | ||
| 89 | + (`decode_inter_sub8_split4`'s `TxbSet::Chroma4` group unit) repeats the | ||
| 90 | + same square model. Per charter step 3: STOPPED and named. | ||
| 91 | + | ||
| 92 | +## Decision | ||
| 93 | + | ||
| 94 | +- The header refusal STAYS unconditional in `stream.rs` — delete condition | ||
| 95 | + unmet (not pixel-exact from frame 1 on). The bypass was local-only, one | ||
| 96 | + `&& std::env::var(...).is_err()` clause, reverted byte-identical before | ||
| 97 | + the commit; the refusal gate re-verified firing (see Verification). | ||
| 98 | +- `read_coeffs_rect` untouched (no scratch growth, no new panic path); | ||
| 99 | + 4:2:0/4:4:4 arms of the touched dispatch untouched; `sub8_leaf_chroma422` | ||
| 100 | + (parent lane) untouched; the 4:2:0 group-tail SKIP arm untouched. | ||
| 101 | +- Next stop named for the owning lane: **`decode_inter_block8`'s 4:2:2 | ||
| 102 | + chroma half** (leaf chroma plane block (4,8): one rect TX_4X8 unit per | ||
| 103 | + plane through the inter rect reader, (4,8)-shaped MC prediction and skip | ||
| 104 | + pushes) plus `decode_inter_sub8_split4`'s group chroma read; after that | ||
| 105 | + round the stage ladder of Outcome 4 should simply be re-run — frame 0 | ||
| 106 | + and the side-64 class are now proven clean, so the residual measurement | ||
| 107 | + is directly attributable. | ||
| 108 | + | ||
| 109 | +## Verification | ||
| 110 | + | ||
| 111 | +- `cargo check -p ec-av1` (target `~/.cache/cargo-target-av1422inter`): | ||
| 112 | + 0 warnings, 0 errors on a fresh `Checking` of the edited tree. | ||
| 113 | +- Pre-fix panic reproduced on the pinned fixture (backtrace named above); | ||
| 114 | + post-fix the same stream decodes 16/16 frames, frame 9 included. | ||
| 115 | +- Frame-0 stage dumps vs the instrumented aomdec: PREFILT / POSTDEBLOCK / | ||
| 116 | + POSTCDEF / FINAL all Y=0 U=0 V=0 (comparator: ours padded 256x160/128x160 | ||
| 117 | + u8 cropped, probe FINAL u16 planes vs oracle u8 — values equal). | ||
| 118 | +- `stream::tests::a_non_420_subsampled_sequence_header_is_refused_by_name`: | ||
| 119 | + 1 passed, 0 failed (refusal fires again after the bypass revert). | ||
| 120 | +- `stream::tests::a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_ | ||
| 121 | + whose_tx_split_decodes_pixel_exact` under `EC_AV1_REQUIRE_AOMENC=1` | ||
| 122 | + (with `EC_AV1_AOMENC` pointed at the oracle build): 1 passed, 0 failed — | ||
| 123 | + the 4:2:0 inter path is unchanged. | ||
| 124 | +- `git status` clean except the decode.rs fix; the report is the only other | ||
| 125 | + file in the commit. | ||
| 126 | + | ||
| 127 | +## State | ||
| 128 | + | ||
| 129 | +- Commit on lane-av1-422inter (no push): the side-64 per-unit chroma fix in | ||
| 130 | + `decode_inter_block` + this report. | ||
| 131 | +- The stage-ladder instruments live in `/tmp/i422/` (our/oracle per-stage | ||
| 132 | + dumps for all 17 oracle frames, comparator + EC_ISTEP pairing scripts) — | ||
| 133 | + scratch, not committed; the oracle build's rungs already carry everything | ||
| 134 | + needed to regenerate them. | ||