forge
Explore
Log in

Don't you dare go Hollow

lane-av1-llkf: the 4x16/16x4 rect route records its lossless chroma units at their own ss-aware span

Browse files at this commit

97a9038bb7cb819638adc0dccf4f5ca77907e3cdAhmet Kaan GümüşParent: 16748dc
The default-partition lossless 4:4:4 key frame's first entropy divergence
(frame-0 all_zero read #452): decode_rect4_16_strip's lossless chroma
walk recorded every TX_4X4 unit with record_mi_chroma(cu_mi, 8, 8, ...)
anchored at oy/2, ox/2 -- the 4:2:0 subsampled form. At 4:4:4 a unit is
ONE mi cell, so each record smeared the unit's state over a 2x2 mi block;
a 4-wide strip's later units overwrote the NEXT COLUMN's above cell with
their own state (aom's av1_set_entropy_contexts stamps exactly
tx_size_wide_unit x tx_size_high_unit cells, one above + one left for
TX_4X4), and the following block's all_zero read the wrong txb_skip row.

Both record sites in the lossless_pair branch (skip and non-skip) are now
ss-aware: anchor (oy << ss_y) / MI, (ox << ss_x) / MI, span 4 << ss.
4:2:0 is arithmetically identical; non-lossless and intrabc arms untouched.

Entropy: all_zero rng ladders match the oracle on all reads of the whole
key frame (testsrc2 2304/2304, mandelbrot 2304/2304; fail-before #452 and
#208). testsrc2 single-key-frame decodes byte-exact vs fresh aomdec; the
sibling dodge2.obu witness stays byte-exact; a_lossless gates 7/7;
cargo check --all-targets 0 warnings.
crates/ec-av1/src/decode.rsmodified+35 -4
@@ -14641,9 +14641,16 @@ fn decode_rect4_16_strip(
14641 angle_delta_uv, cu_reach, &ZERO_RESIDUAL[..16], None, None,14641 angle_delta_uv, cu_reach, &ZERO_RESIDUAL[..16], None, None,
14642 smooth_neighbor_uv, fctx,14642 smooth_neighbor_uv, fctx,
14643 );14643 );
14644- let cu_mi = (pair_mi.0 + oy / 2, pair_mi.1 + ox / 2);14644+ let cu_mi = (
14645+ pair_mi.0 + (oy << ss_y(fctx)) / MI,
14646+ pair_mi.1 + (ox << ss_x(fctx)) / MI,
14647+ );
14645 neighbours.record_mi_chroma(14648 neighbours.record_mi_chroma(
14646- cu_mi, 8, 8, plane, &ZERO_RESIDUAL[..16],14649+ cu_mi,
14650+ 4 << ss_x(fctx),
14651+ 4 << ss_y(fctx),
14652+ plane,
14653+ &ZERO_RESIDUAL[..16],
14647 );14654 );
14648 }14655 }
14649 }14656 }
@@ -14663,7 +14670,25 @@ fn decode_rect4_16_strip(
14663 if cpx + ox >= u.true_width || cpy + oy >= u.true_height {14670 if cpx + ox >= u.true_width || cpy + oy >= u.true_height {
14664 continue;14671 continue;
14665 }14672 }
14666- let cu_mi = (pair_mi.0 + oy / 2, pair_mi.1 + ox / 2);14673+ // The unit's stamp is its own span: aom
14674+ // `av1_set_entropy_contexts` (blockd.c:29)
14675+ // memsets exactly `tx_size_wide_unit` x
14676+ // `tx_size_high_unit` cells at the unit's own
14677+ // `(aoff, loff)` -- for TX_4X4 ONE above cell
14678+ // and ONE left cell. `(oy / 2, ox / 2)` +
14679+ // `(8, 8)` is the 4:2:0 subsampled form (one
14680+ // chroma cell = 8 luma px = 2 mi cells); at
14681+ // 4:4:4 a unit is ONE mi cell, and the 2x2
14682+ // smear let a 4-wide strip's later units
14683+ // overwrite the NEXT COLUMN's above cell with
14684+ // their own state -- a column aom never sees
14685+ // this block write -- so the following block's
14686+ // `all_zero` read the wrong `txb_skip` row
14687+ // (frame-0 read #452, the llkf named gap).
14688+ let cu_mi = (
14689+ pair_mi.0 + (oy << ss_y(fctx)) / MI,
14690+ pair_mi.1 + (ox << ss_x(fctx)) / MI,
14691+ );
14667 // One luma-mi cell: the chroma entropy arrays14692 // One luma-mi cell: the chroma entropy arrays
14668 // are subsampled, and our bands replicate that14693 // are subsampled, and our bands replicate that
14669 // one entry over the unit's two cells14694 // one entry over the unit's two cells
@@ -14685,7 +14710,13 @@ fn decode_rect4_16_strip(
14685 cu_reach, buf, cpx + ox, cpy + oy, 4, 4, base_q_idx,14710 cu_reach, buf, cpx + ox, cpy + oy, 4, 4, base_q_idx,
14686 None, None, offset, smooth_neighbor_uv, fctx,14711 None, None, offset, smooth_neighbor_uv, fctx,
14687 )?;14712 )?;
14688- neighbours.record_mi_chroma(cu_mi, 8, 8, plane, &cu_grid);14713+ neighbours.record_mi_chroma(
14714+ cu_mi,
14715+ 4 << ss_x(fctx),
14716+ 4 << ss_y(fctx),
14717+ plane,
14718+ &cu_grid,
14719+ );
14689 hit!(CHROMA_SPLIT_TX_HITS);14720 hit!(CHROMA_SPLIT_TX_HITS);
14690 let dst = if plane == 1 { &mut uo } else { &mut vo };14721 let dst = if plane == 1 { &mut uo } else { &mut vo };
14691 for row in 0..4 {14722 for row in 0..4 {
lanes/av1llkf.report.mdadded+97 -0
@@ -0,0 +1,97 @@
1+# lane-av1-llkf: the default-partition lossless 4:4:4 key frame's read #452
2+
3+## Ticket
4+
5+Default-partition lossless 4:4:4 key frames entropy-diverge at frame-0
6+coefficient read #452 (mandelbrot/testsrc2, `llsub8b` item 3 / `llintra8`
7+item 2). Min-partition-64 and min-8 keys stay exact, so the defect lives in
8+the shapes only a min-4 stream produces: 4x4 leaves and their 4x16/16x4
9+neighbours.
10+
11+## Named symbol and reader (measured, t1 = testsrc2 128x96, 1 key frame,
12+`--profile=1 --lossless=1 --enable-palette=0 --enable-intrabc=0`, default
13+partition)
14+
15+- Reads 1..452 of the frame's `all_zero` (TXB_SKIP) rng sequence match the
16+ oracle exactly; read #452 (0-indexed) diverges:
17+ - aom: `EC_COEFF plane=2 row=0 col=0 mi=(8,5)` — the V plane's FIRST
18+ TX_4X4 unit of the 4x16 intra block at mi=(8,5), read off
19+ `txb_skip_cdf[0][12]` (`ctx=12` = base 2 + offset 10; above=`23`,
20+ left=`21`, both nonzero).
21+ - ours: `side=4 ctx=4` — our offset-10 row for base 1 (one band cell
22+ reads zero), a different CDF row, so the rng diverges on the same
23+ symbol. Reader: `read_plane`'s `all_zero` symbol read
24+ (decode.rs:6819, `dec.symbol(&mut coding.txb_skip[skip_ctx])`), fed by
25+ `decode_rect4_16_strip`'s lossless chroma walk.
26+- Whose band cell: block (8,4) (the 4x16 strip to the LEFT) recorded each
27+ of its TX_4X4 units with `record_mi_chroma(cu_mi, 8, 8, plane, ...)`
28+ anchored at `oy / 2, ox / 2` — the 4:2:0 subsampled form. At 4:4:4 a unit
29+ is ONE mi cell, so the `(8, 8)` span smeared every unit's state over a
30+ 2x2 mi block: the strip's later V units overwrote `above[5]` — a column
31+ a 4-px-wide block never touches in aom — with their own (zero) state,
32+ where aom keeps the 4x4 leaf (7,5)'s nonzero write
33+ (`av1_set_entropy_contexts`, blockd.c:29, stamps exactly
34+ `tx_size_wide_unit` x `tx_size_high_unit` cells = one above + one left
35+ for TX_4X4). The skipped-unit twin arm has the same defect (aom's skip
36+ path zeroes the plane block's own cells, `av1_reset_entropy_context`,
37+ blockd.c:58 — the 8x8 smear also stamped past the block).
38+
39+## Change (decode.rs, two record sites, one branch)
40+
41+`decode_rect4_16_strip`'s `lossless_pair` chroma walk (skip and non-skip
42+arms): the per-unit record is now ss-aware —
43+
44+- anchor `cu_mi = (pair_mi.0 + (oy << ss_y) / MI, pair_mi.1 + (ox << ss_x) / MI)`
45+- span `record_mi_chroma(cu_mi, 4 << ss_x, 4 << ss_y, plane, ...)`
46+
47+4:2:0 is arithmetically identical (`(oy << 1) / 4 == oy / 2` for the
48+multiple-of-4 unit origins, `4 << 1 == 8`); non-lossless arms untouched;
49+the intrabc arms untouched. `RECT4_16_LOSSLESS_CHROMA_HITS` remains the
50+route's non-vacuity counter.
51+
52+## Verification (measured, this tree @ HEAD + this change)
53+
54+- Entropy: the `all_zero` rng ladders now match the oracle on ALL reads of
55+ the whole frame — t1 (testsrc2) 2304/2304, m1 (mandelbrot) 2304/2304.
56+ Fail-before on the same bytes: t1 diverges at read #452, m1 at read #208
57+ (base-tree control, `$HOME/.cache/cargo-target-av1llkf-base`).
58+- Pixel witness: t1 decodes byte-exact vs fresh `aomdec --rawvideo`
59+ (36864 bytes). The 6-frame default-partition testsrc2 stream (`t6.obu`)
60+ reads frame 0 fully in sync (reads 1..2304 of 12582 consumed before the
61+ next, DIFFERENT divergence — see deferred (1)) and completes all 6
62+ frames with no refusal.
63+- Sibling non-regression: `/tmp/ll444/dodge2.obu` (llsub8b/llintra8's
64+ witness bytes) decodes byte-exact vs fresh aomdec in this tree.
65+- Gates: `cargo test -p ec-av1 --lib a_lossless` → 7 passed, 0 failed
66+ (both 4:2:0 lossless libaom gates, the 444 min-partition-64 inter gate,
67+ the sb128 pair, the 16x4 pair).
68+- `cargo check -p ec-av1 --all-targets` (target dir
69+ `$HOME/.cache/cargo-target-av1llkf`): 0 warnings, 0 errors.
70+- Fixtures are scratch in /tmp/llkf (regenerable recipes above);
71+ fixtures/ is gitignored, nothing committed from it.
72+
73+## Named, not chased (spoken)
74+
75+1. t6's NEXT divergence is a different site: frame 1 (INTER), luma
76+ `all_zero` at our read #2317 — same ctx row (1) and same decoded value
77+ as the oracle but different CDF contents (ours `cdf0=5892` vs aom
78+ `27244`), i.e. an adaptation-history/row-selection desync on the inter
79+ frame, not a band smear. deferred(the inter-frame lossless-444 lane),
80+ with t6.obu's recipe as a ready-made fixture.
81+2. m1 (mandelbrot) pixels: entropy exact frame-wide, chroma-only pixel
82+ diffs (U 4436 / V 9070 samples, luma 0) — the pre-existing per-unit
83+ 4:4:4 chroma PREDICTION class `llintra8` named. One concrete suspect
84+ site of that class observed while here:
85+ `decode_rect4_16_strip`'s lossless walk calls
86+ `tu_reach(pw, ph, ox * 2, oy * 2, 8, ...)` — the 4:2:0 luma-space
87+ offsets — where `read_intra_chroma_lossless` uses `ox << ss_x, oy <<
88+ ss_y` with unit size `4 << ss_x`; at 4:4:4 the doubled origin moves the
89+ unit's prediction edge window. Prediction-domain, entropy unaffected
90+ (proven by the exact coefficient reads above); owned by the same
91+ chroma-prediction lane. deferred(that lane).
92+
93+## Note on the shared oracle
94+
95+aomenc/aomdec are the shared `$HOME/.cache/aom-oracle/build`; the
96+EC_TRACE_COEFF / EC_ECDUMP rungs of the patched tree carried the pairing.
97+Every comparison is against fresh aomdec output of THE SAME bytes.