forge
Explore
Log in

Don't you dare go Hollow

ec-av1: lane-av1-422kf2 -- the remaining frame-0 class at U (108,72)/V (48,0) named and fixed: the sub-8x8 4:2:2 chroma unit decoded at the odd leaf's own chroma x where libaom anchors at the floored cell (zeros at 108..109, the named sample), answered reach from the square-4x4 table where the leaf's own has_tr_8x4/4x8 row says n_tr=0 (oracle EC_PRED self-report at mi(27,44)), and stamped its uv_mode into one mi cell of a two-column strip so the right neighbour lost the smooth-uv edge filter (mi(30,50) ft 1 vs 0); entropy was in sync throughout, prediction-side only; frame-0 PRE-FILTER reconstruction is now byte-exact vs the oracle EC_AV1_PREFILT_DUMP (Y, U, V), chroma prefilt diffs 533/869 -> 0/0, final dumps 1774/2165 -> 1236/1263 all introduced by the 4:2:2 loop filter (named for the next lane, V (48,0) its first sample); header refusal stays unconditional and fires by name, read_coeffs_rect untouched, 4:2:0 aomenc pixel-exact gate green, cargo check 0 warnings; report lanes/av1422kf2.report.md

Browse files at this commit

2cd34bfec229f37b3a9c938a6b2f34758f49676bAhmet Kaan GümüşParent: d785309
crates/ec-av1/src/decode.rsmodified+54 -10
@@ -19919,12 +19919,43 @@ fn sub8_leaf_chroma422(
1991919919 scan4: &[u16],
1992019920 base_q_idx: u8,
1992119921 smooth_neighbor_uv: bool,
19922+ // The owning luma leaf's own shape (`(4, 4)` for a split leaf, `(8, 4)` /
19923+ // `(4, 8)` for a rect pair's strip): libaom's `has_top_right` /
19924+ // `has_bottom_left` answer for this chroma TX_4X4 unit comes from the
19925+ // LEAF's own rect table row at the leaf's mi (`bsize` is the leaf, the
19926+ // unit covers it whole), never the standalone square-4x4 table the old
19927+ // `Reach::of(4, ..)` lookup used -- that said 1 where `has_tr_8x4` says 0
19928+ // at mi(27,44) (the oracle's own EC_PRED prints `n_tr=0` there), so the
19929+ // D45 unit read undecoded pixels to its upper right.
19930+ leaf_shape: (usize, usize),
1992219931 fctx: &crate::decode::FrameCtx,
1992319932 ) -> Result<(Grid, Grid)> {
1992419933 let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
19925- neighbours.record_uv_mode_mi(lmi.0, lmi.1, 1, 1, uv_predict_mode);
19934+ // lane-av1-422kf2: libaom writes one MB_MODE_INFO per mi cell the LEAF
19935+ // covers, and `chroma_left_mbmi`/`chroma_above_mbmi` read whichever of
19936+ // those cells the next block's snap lands on -- an 8x4 strip's SM_V
19937+ // uv_mode must therefore be visible at BOTH of its mi columns, or the
19938+ // block to its right (mi (30,50): left neighbour cell (30,49)) missed the
19939+ // smooth neighbour and skipped libaom's strength-1 intra edge filter
19940+ // (class context-read-from-one-cell, the 4:2:2 sub-8 twin of the
19941+ // lane-kf900 snap fix).
19942+ neighbours.record_uv_mode_mi(
19943+ lmi.0,
19944+ lmi.1,
19945+ (leaf_shape.0 / MI).max(1),
19946+ (leaf_shape.1 / MI).max(1),
19947+ uv_predict_mode,
19948+ );
1992619949 let (px, py) = (lmi.1 * MI, lmi.0 * MI);
19927- let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx));
19950+ // lane-av1-422kf2: the unit's WRITE/PREDICTION anchor is the same floored
19951+ // chroma cell as the entropy anchor below -- libaom positions the sub-8
19952+ // chroma plane block at `av1_setup_dst_planes`' mi-exact floor
19953+ // (`(mi_col & !1) * MI >> ss_x`), NOT at the odd leaf's own chroma x:
19954+ // the oracle's mi(18,55) TX_4X4 unit reconstructed chroma px 108..111
19955+ // (a pure V-copy of the row above at 108..111), while the leaf's own
19956+ // chroma x is 110 -- anchoring there left px 108..109 unwritten (zeros)
19957+ // and stepped px 112..113 with the unit's right columns.
19958+ let (cpx, cpy) = (((lmi.1 & !1) * MI) >> ss_x(fctx), py >> ss_y(fctx));
1992819959 // lane-av1-422h: the entropy-context anchor is the unit's FLOOR chroma
1992919960 // cell (`pd->above_entropy_context + (mi_col >> ss_x)`): an ODD-column
1993019961 // leaf's 4-px unit starts at a chroma px that is NOT cell aligned, and
@@ -19935,9 +19966,17 @@ fn sub8_leaf_chroma422(
1993519966 // overwrites exactly the cell the first one wrote, as libaom's
1993619967 // `av1_set_entropy_contexts` per-TU writes do.
1993719968 let ctx_mi = (lmi.0, lmi.1 & !1);
19938- // The square unit takes the leaf's own `Reach::of` (its luma's), the way
19939- // [`decode_leaf8`]'s 422 arm passes the enclosing block's luma reach.
19940- let reach = Reach::of(4, px, py, y.width, y.height, fctx);
19969+ // lane-av1-422kf2: the square unit takes the leaf's OWN reach: a split
19970+ // leaf is a standalone BLOCK_4X4 (square table), a rect pair's strip is
19971+ // `of_rect` on the strip's true (8x4 / 4x8) shape -- libaom passes the
19972+ // LEAF's bsize to `has_top_right`/`has_bottom_left`, so a rect strip's
19973+ // answer comes from `has_tr_8x4`/`has_tr_4x8` at the strip's mi, not
19974+ // from a 4x4-block lookup.
19975+ let reach = if leaf_shape == (4, 4) {
19976+ Reach::of(4, px, py, y.width, y.height, fctx)
19977+ } else {
19978+ Reach::of_rect(leaf_shape.0, leaf_shape.1, px, py, y.width, y.height, fctx)
19979+ };
1994119980 let chroma_around = neighbours.around_mi_422_chroma(ctx_mi, 8, 4);
1994219981 let ac = alpha.map(|_| cfl_src_rect(px, py, 8, 4));
1994319982 let grids: (Grid, Grid) = if skip {
@@ -20206,7 +20245,8 @@ fn decode_leaf_split4(
2020620245 sub8_leaf_chroma422(
2020720246 dec, cdfs, neighbours, lmi, DC_PRED, 0, None, skip,
2020820247 Some(dv), y, u, v, scan4, base_q_idx,
20209- neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), fctx,
20248+ neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx),
20249+ (4, 4), fctx,
2021020250 )?;
2021120251 last_uv422 = DC_PRED;
2021220252 } else {
@@ -20280,7 +20320,8 @@ fn decode_leaf_split4(
2028020320 sub8_leaf_chroma422(
2028120321 dec, cdfs, neighbours, lmi, uv_mode, angle_delta_uv, alpha, skip,
2028220322 None, y, u, v, scan4, base_q_idx,
20283- neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), fctx,
20323+ neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx),
20324+ (4, 4), fctx,
2028420325 )?;
2028520326 last_uv422 = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
2028620327 } else {
@@ -20744,7 +20785,8 @@ fn decode_leaf_rect8(
2074420785 sub8_leaf_chroma422(
2074520786 dec, cdfs, neighbours, lmi, DC_PRED, 0, None, skip,
2074620787 Some(dv), y, u, v, scan4, base_q_idx,
20747- neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), fctx,
20788+ neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx),
20789+ (bw, bh), fctx,
2074820790 )?;
2074920791 last_uv422 = DC_PRED;
2075020792 } else {
@@ -20912,7 +20954,8 @@ fn decode_leaf_rect8(
2091220954 sub8_leaf_chroma422(
2091320955 dec, cdfs, neighbours, lmi, uv_mode, angle_delta_uv, alpha,
2091420956 skip, None, y, u, v, scan4, base_q_idx,
20915- neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), fctx,
20957+ neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx),
20958+ (bw, bh), fctx,
2091620959 )?;
2091720960 last_uv422 = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
2091820961 } else {
@@ -21015,7 +21058,8 @@ fn decode_leaf_rect8(
2101521058 sub8_leaf_chroma422(
2101621059 dec, cdfs, neighbours, lmi, uv_mode, angle_delta_uv, alpha,
2101721060 skip, None, y, u, v, scan4, base_q_idx,
21018- neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), fctx,
21061+ neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx),
21062+ (bw, bh), fctx,
2101921063 )?;
2102021064 last_uv422 = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
2102121065 } else {
lanes/av1422kf2.report.mdadded+97 -0
@@ -0,0 +1,97 @@
1+# lane-av1-422kf2 — the remaining frame-0 class at U (108, 72) / V (48, 0):
2+# NAMED and FIXED — the sub-8x8 4:2:2 chroma unit decoded at the wrong
3+# position, wrong reach table and half-visible neighbour mode (three related
4+# one-index defects, all in [`sub8_leaf_chroma422`]); frame-0 PRE-FILTER
5+# reconstruction is now pixel-exact (Y, U and V) against the oracle's
6+# `EC_AV1_PREFILT_DUMP`
7+
8+## Outcome
9+
10+1. REMEASURED first (pinned fixture, single-frame cut
11+ `/tmp/t422f0.obu` sha256 `3dd3f768ef553c02316848c2d3184c3765030c0a6fcb95887e4719add9ded3af`
12+ — first OBU prefix of the pinned 22-frame t422.obu; the frame is
13+ **256x144**, chroma planes 128x144; local `EC_AV1_ALLOW_422_PROBE`
14+ bypass applied, reverted byte-identical after): at the parent's baseline
15+ the pre-filter chroma diffs were U 533 / V 869, first U (108, 72) —
16+ confirming the parent's sample.
17+2. NAMED the class at U (108, 72): the 8x8 luma block at luma (216, 72)
18+ splits into four 4x4 leaves; 4:2:2's `is_chroma_reference`
19+ (`av1_common_int.h:1454`) puts the chroma syntax on the ODD-column leaves
20+ (`(mi_col & 1) || !(bw & 1) || !ss_x` — the port already read uv_mode
21+ there, entropy in sync, luma byte-exact), but libaom ANCHORS the leaf's
22+ TX_4X4 chroma unit at the floored chroma cell
23+ (`(mi_col & !1) * MI >> ss_x` = chroma px 108), not at the odd leaf's own
24+ chroma x (110). Ours reconstructed at 110: px 108..109 were never written
25+ (zeros at exactly the parent's sample), px 112..113 got the unit's right
26+ columns. Oracle ground truth: the mi(18,55) unit's reconstruction is a
27+ pure V-copy of the row above AT 108..111. Fix 1: anchor `cpx` at
28+ `(lmi.1 & !1) * MI >> ss_x`. U/V prefilt 533/869 → 477/813, first diff
29+ moved to (96, 104).
30+3. The (96, 104) cluster named the next layer: an 8x4 strip's chroma unit
31+ (mi(27,44), uv D45) read undecoded pixels to its upper right. The oracle's
32+ own `EC_PRED` trace prints `n_tr=0` there: libaom answers
33+ `has_top_right`/`has_bottom_left` from the LEAF's OWN rect shape
34+ (`has_tr_8x4`/`has_tr_4x8` at the leaf's mi — bit 6 of byte 22 is 0),
35+ while the port used the standalone square-4x4 `Reach::of(4, ..)` lookup
36+ (same bit = 1). Fix 2: `sub8_leaf_chroma422` takes the leaf's shape and
37+ uses `Reach::of(4, ..)` only for a BLOCK_4X4 leaf, `Reach::of_rect(8, 4)`
38+ / `(4, 8)` for a rect pair's strip. Prefilt chroma 477/813 → 8/15.
39+4. The last 8/15 samples (chroma (100..103, 120..123), the H-mode unit at
40+ mi(30,50)) named the third defect: the unit's left neighbour mi(30,48) is
41+ an 8x4 strip with uv SMOOTH_V, but its `record_uv_mode_mi(…, 1, 1, …)`
42+ stamped only ONE of the strip's two mi columns, so mi(30,50)'s
43+ `chroma_left_mbmi` lookup hit an empty cell, lost the smooth neighbour and
44+ skipped libaom's always-on strength-1 intra edge filter
45+ (`get_intra_edge_filter_type` 1 vs our 0; prediction sums 6139/6307 vs
46+ 6142/6312). Fix 3: record the uv mode over the leaf's whole mi footprint
47+ (`(w_mi, h_mi)` from the leaf shape). All three fixes are inside
48+ [`sub8_leaf_chroma422`] and its five call sites.
49+5. MEASURED after the three fixes: **PREFILT Y EXACT, U EXACT, V EXACT**
50+ (byte-identical frame-0 pre-loop-filter reconstruction against the oracle
51+ dump). FINAL dumps: U 1774 → 1236, V 2165 → 1263 — every remaining final
52+ diff is introduced by the LOOP FILTER (pre-filter row 0 is exact; the
53+ filter propagates damage to the top rows). Non-vacuity:
54+ `chroma422_square` = 24, `chroma422_rect` = 96, `chroma422_sub8` = 26 on
55+ this frame — all three touched arms provably ran.
56+6. REMAINING class for the next lane: the 4:2:2 LOOP FILTER. With pre-filter
57+ recon byte-exact, the 1236/1263 final-diff samples are deblock/CDEF/LR
58+ chroma work (the parent's V (48, 0) is this class's first final sample —
59+ pre-filter V at row 0 is exact). Frame 0 is still not final-pixel-exact,
60+ so the "delete the header refusal" condition stays unmet.
61+
62+## Decision
63+
64+- The palette set in 93c4dff5 is untouched (chroma422_square still 24; the
65+ chroma_tiled arm's `set_palette_pred` intact).
66+- `read_coeffs_rect` untouched. The frame-9 rect scratch panic is untouched.
67+ The 4:2:0 group-tail SKIP arm untouched. Header refusal STAYS
68+ unconditional in `stream.rs` — verified firing by name on this very
69+ fixture after the bypass revert, plus the named gate test.
70+- The bypass was local-only (`EC_AV1_ALLOW_422_PROBE` on the env, one
71+ `&& std::env::var(…).is_err()` clause), reverted byte-identical before the
72+ commit; `git diff` after the revert carries ONLY the decode.rs fix.
73+
74+## Verification
75+
76+- `cargo check -p ec-av1` (target `~/.cache/cargo-target-av1422kf2`):
77+ 0 warnings, 0 errors.
78+- 420 gate green under `EC_AV1_REQUIRE_AOMENC=1`:
79+ `stream::tests::a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_
80+ whose_tx_split_decodes_pixel_exact`: 1 passed, 0 failed.
81+- `stream::tests::a_non_420_subsampled_sequence_header_is_refused_by_name`:
82+ 1 passed, 0 failed.
83+- Stage dumps compared sample-for-sample (cropped `PREFILT_WIDE_DUMP` vs the
84+ oracle `EC_AV1_PREFILT_DUMP`, same 73728-byte layout, 256x144 / 128x144):
85+ post-fix Y/U/V all exact; symbol-level pairing via the oracle's
86+ `EC_ISTEP`/`EC_PALSYN`/`EC_PRED`/`EC_PREDOUT8` rungs against our
87+ `EC_TRACE_MODE_STEP`/`EC_PRED` traces (rng and values matched at every
88+ step of every unit named above).
89+
90+## State
91+
92+- Commit on lane-av1-422kf2 (no push): the three sub8-422 chroma fixes +
93+ this report.
94+- Next stop named for the owning lane: the 4:2:2 loop filter — deblock/CDEF
95+ chroma extents against `$HOME/.cache/aom-oracle/build` aomdec dumps
96+ (`EC_AV1_POSTDEBLOCK_DUMP` rungs exist on both sides); the decode-side
97+ frame-0 recon it consumes is now proven exact.