forge
Explore
Log in

Don't you dare go Hollow

Merge lane-av1mixllconj: the var-tx tree is gated on per-segment lossless as a CONJUNCT, not an else-if

Browse files at this commit

e3cfa333bc8ce7f4468fcc7dcccd627c70041297Ahmet Kaan GümüşParent: fe71116d827f72
The mixed-lossless class (a supported 4:2:0 8-bit cell reachable from one aomenc line) is fixed. The charter's
suspicion -- that our per-segment lossless answer disagreed with libaom's xd->lossless[segment_id] -- is
REFUTED: the derivation is libaom's term for term (av1_get_qindex + the five deltas, evaluated after
segmentation resolves), and behaviourally the parse is bit-identical to the oracle for 179378 reads on the
640x480 cell, where any wrong flag at any var-tx gate would have changed the READ COUNT and forked the ladder.
The defect was the branch POSITION: libaom puts !xd->lossless[segment_id] IN the var-tx condition
(decodeframe.c:1237), we had it one branch late in an `else if`. Two sites: decode.rs:27213 (intrabc 4x8/8x4
rect leaf) and :48332 (sub-8 4x8/8x4 inter leaf).

Evidence: the pinned 256x128 witness is 6/6 decode-order byte-exact with the paired EC_SYMR ladder
bit-identical over the WHOLE stream (96997/96997 reads, zero divergence -- not merely up to the old fork); the
4:4:4 arm goes red-on-f1..f8 -> 9/9 exact; 352x288 is REFUSED -> 7/7 exact; 176x144 REFUSED -> decodes (its
residual fork at read 25792 is a different site, closed by the sibling clip merged next); the 107-fixture
corpus moves exactly ONE fixture RED -> EXACT with zero EXACT->RED, no new refusal and no frame-count change;
mutation proof reds the gate at the same 33724 bytes as the hand measurement; scoped suite 375 passed / 0
failed / 7 ignored.

ONE REGRESSION CONTROL IS NOT MET AND ITS PREMISE WAS FALSE, reported rather than papered over: 640x480 still
refuses after 4 of 6 decode-order frames. It is not "a working cell made to refuse" -- at base it decodes 6/6
dumps while EVERY inter frame is 70-92% wrong (f1..f5 differ by 352066/414286/313795/399471/422078 of 460800),
independently reproduced by the sibling lane on its own tree. So the fix replaces silent ~80%-wrong pixels with
a loud refusal, and the residual is a THIRD defect, handed over with its site named: mi=(80,110), an 8x4 intra
leaf with use_filter_intra in an inter frame, we read tx_size_cat0[2] where libaom reads [1] (a missing
TXFM_CONTEXT band write above mi column 110); forcing ctx=1 there makes the cell bit-identical over all 457907
reads, and that forcing is deliberately NOT shipped because a forced context is a symptom mask.
crates/ec-av1/fixtures/420_mixll_altref_256x128_5f.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+31 -2
@@ -27201,7 +27201,16 @@ fn decode_leaf_rect8(
27201 // libaom's `set_txfm_ctxs` runs at `parse_decode_block`'s tail, so27201 // libaom's `set_txfm_ctxs` runs at `parse_decode_block`'s tail, so
27202 // a unit's own `txb_skip_ctx` read must see the PRE-block bands.27202 // a unit's own `txb_skip_ctx` read must see the PRE-block bands.
27203 let mut publish = Some((bw, bh));27203 let mut publish = Some((bw, bh));
27204- if tx_select && !skip {27204+ // lane-av1mixllfork: libaom `parse_decode_block` (decodeframe.c:1237)
27205+ // gates the var-tx tree on `!xd->lossless[mbmi->segment_id]` as a
27206+ // CONJUNCT of the tx_mode-select condition, not as the `else` arm --
27207+ // `read_tx_size` (`decodeframe.c:1208`) answers TX_4X4 on the same
27208+ // flag. A frame whose segments disagree (per-segment mixed
27209+ // lossless: `--cq-level=0` with AQ) therefore reads NO tree symbol
27210+ // on its lossless blocks. Ordering the test the other way round
27211+ // reads a `tx_size_cat1` symbol the oracle never reads and forks
27212+ // the very next block's `txb_skip`.
27213+ if tx_select && !skip && !lossless(fctx) {
27205 // `max_block_wide`/`max_block_high`: the frame's own mi grid,27214 // `max_block_wide`/`max_block_high`: the frame's own mi grid,
27206 // so a leaf hanging over the right/bottom edge reads no split27215 // so a leaf hanging over the right/bottom edge reads no split
27207 // symbol for the units outside it (as in `decode_block`).27216 // symbol for the units outside it (as in `decode_block`).
@@ -34662,6 +34671,14 @@ thread_local! {
34662 /// is 256 per inter frame (8 unclipped luma rows x 32 columns), and 0 on a34671 /// is 256 per inter frame (8 unclipped luma rows x 32 columns), and 0 on a
34663 /// frame that fits.34672 /// frame that fits.
34664 pub(crate) static LOSSLESS_EDGE_CLIP_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };34673 pub(crate) static LOSSLESS_EDGE_CLIP_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
34674+ /// lane-av1mixllfork: sub-8 (4x8 / 8x4) inter leaves whose var-tx tree
34675+ /// was SUPPRESSED because their own segment is lossless -- libaom's
34676+ /// `parse_decode_block` carries `!xd->lossless[mbmi->segment_id]` as a
34677+ /// conjunct of the tree condition (`decodeframe.c:1237`), so a mixed-
34678+ /// lossless frame codes no `tx_size_cat1` symbol there. Zero on any frame
34679+ /// whose sub-8 leaves all sit in lossy segments, so a gate cannot look
34680+ /// armed by merely decoding.
34681+ pub(crate) static SUB8_LOSSLESS_NO_VARTX: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
34665 }34682 }
34666 34683
34667 /// [`MU_CHUNK_WALKS`], for a gate's own before/after delta.34684 /// [`MU_CHUNK_WALKS`], for a gate's own before/after delta.
@@ -34694,6 +34711,12 @@ pub(crate) fn lossless_edge_clipped() -> usize {
34694 pub(crate) fn lossless_edge_clip_units() -> usize {34711 pub(crate) fn lossless_edge_clip_units() -> usize {
34695 LOSSLESS_EDGE_CLIP_UNITS.with(std::cell::Cell::get)34712 LOSSLESS_EDGE_CLIP_UNITS.with(std::cell::Cell::get)
34696 }34713 }
34714+/// [`SUB8_LOSSLESS_NO_VARTX`] -- sub-8 inter leaves on a lossless segment that
34715+/// read no var-tx symbol, for a gate's own before/after delta.
34716+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
34717+pub(crate) fn sub8_lossless_no_vartx() -> usize {
34718+ SUB8_LOSSLESS_NO_VARTX.with(std::cell::Cell::get)
34719+}
34697 34720
34698 /// [`CHROMA_SPLIT_TX_HITS`], for a gate's own before/after delta.34721 /// [`CHROMA_SPLIT_TX_HITS`], for a gate's own before/after delta.
34699 #[allow(dead_code)] // read only from the `#[cfg(test)]` gates34722 #[allow(dead_code)] // read only from the `#[cfg(test)]` gates
@@ -48300,7 +48323,12 @@ fn decode_inter_sub8_rect2(
48300 // skipped one codes nothing and records its BLOCK size in both txfm48323 // skipped one codes nothing and records its BLOCK size in both txfm
48301 // contexts (`set_txfm_ctxs`' `skip_inter` arm).48324 // contexts (`set_txfm_ctxs`' `skip_inter` arm).
48302 let mut leaves: Vec<(usize, usize, usize, usize)> = Vec::new();48325 let mut leaves: Vec<(usize, usize, usize, usize)> = Vec::new();
48303- if fctx.tx_select_inter.with(std::cell::Cell::get) && !skip {48326+ // lane-av1mixllfork: the same libaom ordering fix as the intrabc rect
48327+ // leaf's (`parse_decode_block`, decodeframe.c:1237): the per-segment
48328+ // `lossless` flag is a CONJUNCT of the var-tx condition, not its
48329+ // `else` arm, so a lossless SEGMENT of a mixed-lossless inter frame
48330+ // reads no `tx_size_cat1` symbol here and codes TX_4X4 per plane.
48331+ if fctx.tx_select_inter.with(std::cell::Cell::get) && !skip && !lossless(fctx) {
48304 let max_w_mi = w_mi.min((mi_cols as usize).saturating_sub(cmi));48332 let max_w_mi = w_mi.min((mi_cols as usize).saturating_sub(cmi));
48305 let max_h_mi = h_mi.min((mi_rows as usize).saturating_sub(rmi));48333 let max_h_mi = h_mi.min((mi_rows as usize).saturating_sub(rmi));
48306 read_var_tx_size(48334 read_var_tx_size(
@@ -48317,6 +48345,7 @@ fn decode_inter_sub8_rect2(
48317 &mut leaves,48345 &mut leaves,
48318 );48346 );
48319 } else if lossless(fctx) && !skip {48347 } else if lossless(fctx) && !skip {
48348+ hit!(SUB8_LOSSLESS_NO_VARTX);
48320 // lane-lossless2: `read_block_tx_size` returns TX_4X4 before it48349 // lane-lossless2: `read_block_tx_size` returns TX_4X4 before it
48321 // ever looks at `max_txsize_rect_lookup`, so an 8x4/4x8 leaf is48350 // ever looks at `max_txsize_rect_lookup`, so an 8x4/4x8 leaf is
48322 // TWO 4x4 units, not one rect one.48351 // TWO 4x4 units, not one rect one.
crates/ec-av1/src/stream.rsmodified+87 -0
@@ -9293,6 +9293,93 @@ pub(crate) mod tests {
9293 {shown} shown frame(s) exact per plane, mid-cell chroma publications {mid:?}"9293 {shown} shown frame(s) exact per plane, mid-cell chroma publications {mid:?}"
9294 );9294 );
9295 }9295 }
9296+
9297+ /// lane-av1mixllfork: per-segment MIXED LOSSLESS + an alt-ref structure.
9298+ /// The first fork was entropy read **30889** of f1 (paired `EC_SYMR`:
9299+ /// identical `pre[0..1]`, `n`, `s` on both sides, `post_rng` 42076 vs
9300+ /// 54010), and the pre-fix `cdf0` at that read was 22401 vs the oracle's
9301+ /// 15299 -- **not** the usual `32768 - x` ICDF mirror, i.e. two different
9302+ /// reads, not one wrong CDF row.
9303+ ///
9304+ /// What each side read there: libaom `decodetxb.c:158`, the luma `txb_skip`
9305+ /// of a TX_4X4 unit at `mi=(6,1)` `bc=0 br=0`; ours an untagged `n=2`
9306+ /// symbol that a `set_symr_cdf` sweep over all six MV-stack copies
9307+ /// (`ii16/newmv16/…/refmvB`, `inter8` phase inherited) ruled out as every
9308+ /// inter mode-info read, leaving the one read that block makes *between*
9309+ /// its `refmv` and its coefficients: the var-tx tree's `tx_size_cat1`.
9310+ /// libaom's own reason it reads nothing: `parse_decode_block`
9311+ /// (`decodeframe.c:1237`) carries `!xd->lossless[mbmi->segment_id]` as a
9312+ /// **conjunct** of the tx-mode-select condition, and `read_tx_size`
9313+ /// (`:1208`) answers TX_4X4 on the same flag. This tree tested
9314+ /// `tx_select && !skip` and put `lossless(fctx) && !skip` in the `else if`
9315+ /// arm instead, so on a lossless SEGMENT of a mixed-lossless frame it read
9316+ /// a `tx_size_cat1` symbol libaom never reads, and the very next block's
9317+ /// `txb_skip` forked. `SUB8_LOSSLESS_NO_VARTX` counts the leaves that
9318+ /// newly take the lossless arm, so this gate cannot pass vacuously on a
9319+ /// stream whose sub-8 leaves all sit in lossy segments.
9320+ ///
9321+ /// The trigger really is the CONJUNCTION: `--cq-level=0` with AQ makes
9322+ /// *some* segments lossless and others not (`--cq-level=20`, `--cq-level=32`,
9323+ /// `--lossless=1` and `--aq-mode=0` are all byte-exact on this recipe), and
9324+ /// `--auto-alt-ref=0` makes it exact at 5, 6, 8 and 12 frames. After the
9325+ /// fix the whole-stream `EC_SYMR` ladder is bit-identical: **96997 reads,
9326+ /// 96997 paired, zero divergence** -- not just up to the fork.
9327+ ///
9328+ /// Recipe (ffmpeg 8.1.3 `testsrc2`, shared oracle `aomenc`, 18525 bytes):
9329+ /// ```text
9330+ /// ffmpeg -f lavfi -i testsrc2=size=256x128:rate=25 -frames:v 5 \
9331+ /// -pix_fmt yuv420p src5b.y4m
9332+ /// aomenc --codec=av1 --obu -o c_mix5.obu --passes=1 --cpu-used=4 \
9333+ /// --limit=5 --end-usage=q --cq-level=0 --aq-mode=1 src5b.y4m
9334+ /// ```
9335+ /// sha256 `3e06b5641e6a0f5a3f4ac8f114d4ee48c88638429e9eaafe6b4483e24f1dbc3a`.
9336+ /// The tree pins fixture identity by fnv1a64; a `const SHA256` compared
9337+ /// against itself would be the tautology lane-av1422anom exists to kill.
9338+ #[test]
9339+ fn a_420_mixed_lossless_alt_ref_sub8_vartx_witness_is_byte_exact_in_decode_order() {
9340+ const NAME: &str =
9341+ "a_420_mixed_lossless_alt_ref_sub8_vartx_witness_is_byte_exact_in_decode_order";
9342+ let _gate_lock = lock_gate_counters();
9343+ const FILE: &str = "420_mixll_altref_256x128_5f.obu";
9344+ const BYTES: usize = 18525;
9345+ const FNV1A64: u64 = 16348502764482216576;
9346+ let path = crate_pin(FILE);
9347+ let data = std::fs::read(&path)
9348+ .unwrap_or_else(|e| panic!("{NAME}: the committed pin {FILE} is missing ({e})"));
9349+ assert_eq!(data.len(), BYTES, "{NAME}: {FILE} size drifted");
9350+ assert_eq!(fnv1a64(&data), FNV1A64, "{NAME}: {FILE} bytes drifted");
9351+ let before = crate::decode::sub8_lossless_no_vartx();
9352+ let (decoded, hidden) = decode_all_frames_vs_oracle(&data, NAME);
9353+ let suppressed = crate::decode::sub8_lossless_no_vartx() - before;
9354+ assert_eq!(
9355+ decoded, 6,
9356+ "{NAME}: the oracle decoded {decoded} frames in DECODE order; the 5-frame \
9357+ altref recipe codes 5 source frames plus a hidden alt-ref picture"
9358+ );
9359+ assert_eq!(
9360+ hidden, 1,
9361+ "{NAME}: {decoded} decode-order dumps against {decoded} - {hidden} shown outputs \
9362+ means the gate saw the hidden picture no shown-frame compare can reach"
9363+ );
9364+ assert!(
9365+ suppressed > 0,
9366+ "{NAME}: no sub-8 (4x8/8x4) inter leaf on a LOSSLESS segment read no var-tx \
9367+ symbol ({suppressed} of them did), so this witness does not exercise the \
9368+ ordering at all (class gate-blind-to-feature) -- re-encode per the recipe above"
9369+ );
9370+ let (wy, wu, wv, shown, exact) =
9371+ count_rawvideo_diffs(&data, NAME, None).expect("the two sides must be byte-comparable");
9372+ assert_eq!(
9373+ (wy, wu, wv, exact),
9374+ (0, 0, 0, shown),
9375+ "{NAME}: shown-frame per-plane diff vs `aomdec --rawvideo`"
9376+ );
9377+ eprintln!(
9378+ "{NAME}: {decoded} decode-order frame(s) byte-exact ({hidden} hidden), \
9379+ {shown} shown frame(s) exact per plane, {suppressed} sub-8 leaf/leaves on a \
9380+ lossless segment read no var-tx symbol"
9381+ );
9382+ }
9296 /// lane-av1444rect r2 — the SAME class as the gate above, second9383 /// lane-av1444rect r2 — the SAME class as the gate above, second
9297 /// instance: `decode_rect4_16_intrabc` applied the 4:2:0 pair geometry at9384 /// instance: `decode_rect4_16_intrabc` applied the 4:2:0 pair geometry at
9298 /// ss (0,0), where `is_chroma_reference` makes an intra-BC 1:4 strip its9385 /// ss (0,0), where `is_chroma_reference` makes an intra-BC 1:4 strip its
lanes/av1mixllconj.report.mdadded+441 -0
@@ -0,0 +1,441 @@
1+# lane-av1mixllconj — the per-segment `lossless` answer ALREADY agrees with libaom; the var-tx **conjunct** lands, and the 640x480 "regression" is a SECOND, independent defect on a cell that was never correct
2+
3+Base `main` = `6bb66a4a`. Worktree `/home/user/.cache/wt/av1mixllconj`, target dir
4+`$HOME/.cache/cargo-target-av1mixllconj`, `EC_NOMEMGUARD=1`. Oracle
5+`~/.cache/aom-oracle/build/{aomdec,aomenc}` (shared, untouched; not rebuilt, not
6+re-instrumented). ffmpeg 8.1.3.
7+
8+**This lane lands the two-line conjunct** (cherry-picked candidate `658d37fa`,
9+re-derived and re-proved here) **plus its fixture, route counter and gate.** One
10+regression control from the charter is NOT met as literally written — the
11+640x480 cell refuses instead of decoding — and §4 shows, with measurements, that
12+the control's premise is false (the cell is 70–92 % wrong at base) and that the
13+refusal is caused by a **different defect class**, localised to one read and
14+reproduced to a one-line override.
15+
16+---
17+
18+## 0. Verdict
19+
20+| | |
21+|---|---|
22+| The charter's live question — "make our per-segment `lossless` answer agree with libaom's `xd->lossless[segment_id]`" | **the answer is: it already agrees.** The derivation is line-for-line libaom's, and 179 378 bit-identical entropy reads on the 640x480 cell prove no var-tx gate ever consulted a wrong flag. There is nothing to fix in the derivation. |
23+| 256x128 pin (`--limit=5`) | **6/6 decode-order byte-exact**; paired `EC_SYMR` **96 997 / 96 997 bit-identical over the WHOLE stream** (§3.1) |
24+| 4:4:4 arm (`--profile=1`, 8 frames) | **9/9 exact**, red on f1..f8 before |
25+| 176x144 / 352x288 (refuse at base) | 352x288 → **7/7 exact**; 176x144 → decodes 7/7 (still red from the already-handed-off `mi=(32,32)` defect, which `lane-av1offtile`'s clip then closes — §7b) |
26+| 640x480 — **CONTROL NOT MET** | refuses at frame 3 instead of decoding. Base decodes it **70–92 % wrong on every frame** (§4.1). Refusal cause = a second defect, named and one-line-reproduced in §4.3. |
27+| Corpus sweep, 107 committed fixtures | **exactly one status change: `420_mixll_altref_256x128_5f` RED → EXACT.** Zero EXACT→RED, zero new REFUSED, zero FRAMECOUNT change (§5) |
28+| Composition with `714fb55b` (`lane-av1offtile`) | cherry-picked for measurement and reverted; the two clips close **every** cell of this recipe at 256x128 / 176x144 / 352x288 / 4:4:4 and leave the 640x480 residual byte-for-byte unchanged (§7b) |
29+| Class sweep | all 10 `else if lossless(fctx)` sites and all 9 `read_var_tx_size` gates re-derived against libaom's own `if`: **exactly the 2 fixed sites were in the class, no third site** (§6) |
30+| Fixture / gate / counter | committed; gate mutation-proven red-before (§3.2) |
31+
32+## 1. Reproduction
33+
34+Every cell below is `testsrc2` at 25 fps, `ffmpeg -f lavfi -i
35+testsrc2=size=<S>:rate=25 -frames:v <N> -pix_fmt yuv420p`, then
36+
37+```text
38+aomenc --codec=av1 --obu -o <cell>.obu --passes=1 --cpu-used=4 --limit=<N> \
39+ --end-usage=q --cq-level=0 --aq-mode=1 src<S>.y4m # 4:2:0
40+ ... --profile=1 ... src444.y4m # 4:4:4
41+```
42+
43+| cell | bytes | sha256 (prefix) |
44+|---|---:|---|
45+| `m5_256x128.obu` (the pin) | 18 525 | `3e06b5641e6a0f5a` |
46+| `m_256x128.obu` | 22 336 | — |
47+| `m_176x144.obu` | 20 069 | `02b15d0d5b08aa5a` |
48+| `m_320x240.obu` / `m5_320x240.obu` | 38 686 / 28 716 | `37fbe7cb…` / `40d613fd…` |
49+| `m_352x288.obu` | 46 490 | `e43c74b8d847e701` |
50+| `m5_640x480.obu` | 87 537 | `3d505fd2e0bbb7ca` |
51+| `m_640x480.obu` | 115 615 | `c82ba4d793d378cc` |
52+| `m444_8.obu` (4:4:4, 8 frames) | 79 051 | — |
53+
54+The three byte counts and shas the inherited reports name all reproduce on the
55+first try.
56+
57+## 2. The charter's premise, tested and answered
58+
59+The charter says: *"our per-segment lossless answer disagrees with libaom's
60+`xd->lossless[segment_id]` on that stream … the table is built from a
61+qindex/delta predicate that does not account for what segmentation ACTUALLY
62+resolves to."*
63+
64+**It does not disagree. Two independent measurements:**
65+
66+**(a) The derivation is libaom's, term for term.** libaom
67+`decodeframe.c:5210-5217`:
68+
69+```c
70+for (int i = 0; i < MAX_SEGMENTS; ++i) {
71+ const int qindex = av1_get_qindex(&cm->seg, i, quant_params->base_qindex);
72+ xd->lossless[i] = qindex == 0 && quant_params->y_dc_delta_q == 0 &&
73+ quant_params->u_dc_delta_q == 0 && quant_params->u_ac_delta_q == 0 &&
74+ quant_params->v_dc_delta_q == 0 && quant_params->v_ac_delta_q == 0;
75+ xd->qindex[i] = qindex;
76+}
77+```
78+
79+`av1_get_qindex` (`quant_common.c:222`) is
80+`segfeature_active(SEG_LVL_ALT_Q) ? clamp(base_qindex + data, 0, MAXQ) :
81+base_qindex`. Ours (`ec-av1-syntax/src/frame.rs:658-666` and `1022-1033`) is the
82+same predicate, the same clamp, the same five deltas — and it is evaluated
83+**after** `read_quantization_params` / `read_segmentation_params` /
84+`read_delta_q_params` / `read_delta_lf_params`, i.e. after segmentation has
85+resolved, which is the one thing the charter suspected. The suspicion is
86+**REFUTED**.
87+
88+The table this lane prints per frame (env-gated, reverted; the 640x480 cell, all
89+five frames identical) shows the mixed structure the class needs:
90+
91+```text
92+EC_MIXLL_FRAME base_q=0 deltas=(0,0,0,0,0) qindex=[0,0,0,0,1,1,1,1]
93+ lossless=[true,true,true,true,false,false,false,false] # frames 0-1
94+EC_MIXLL_FRAME base_q=0 deltas=(0,0,0,0,0) qindex=[0,0,0,0,0,0,0,0]
95+ lossless=[true,true,true,true,true,true,true,true] # frames 2-4
96+```
97+
98+**(b) A wrong flag could not have stayed hidden.** On `m5_640x480` the parse is
99+**bit-identical to the oracle for 179 378 entropy reads** with the fix in. At
100+every var-tx gate a wrong `lossless` answer changes the NUMBER of reads (the tree
101+walk appears or vanishes), so a wrong flag at any gate inside that range would
102+have forked the ladder. It did not. **No tree-gate on this stream ever
103+consulted a wrong flag.**
104+
105+So the charter's "fix the DERIVATION" lever is empty, and the remaining question
106+is the one §4 answers.
107+
108+## 3. The landed change, and its proof
109+
110+```diff
111+@@ decode.rs:27213 (intrabc 4x8 / 8x4 rect leaf, read_var_tx_size)
112+- if tx_select && !skip {
113++ if tx_select && !skip && !lossless(fctx) {
114+@@ decode.rs:48332 (sub-8 4x8/8x4 inter leaf, read_var_tx_size)
115+- if fctx.tx_select_inter.with(std::cell::Cell::get) && !skip {
116++ if fctx.tx_select_inter.with(std::cell::Cell::get) && !skip && !lossless(fctx) {
117+```
118+
119+libaom's own condition (`decodeframe.c:1237`) carries
120+`!xd->lossless[mbmi->segment_id]` **inside** the tree condition and
121+`read_tx_size` (`:1203`) answers `TX_4X4` on the same flag before reading
122+anything. `lossless(fctx)` is already per-segment
123+(`lossless_per_seg[cur_segment_id]`, `decode.rs:453-456`), so the flag was right
124+and one branch too late.
125+
126+### 3.1 Whole-stream ladder, not just "up to the fork"
127+
128+`EC_SYMR=1` on both sides of the pin, comparing the convention-free fields
129+(`pre[0]`, `pre[1]`, `n`, `s`, `post_rng`; `pre[2]` carries a per-site constant
130+offset and `cdf0` the ICDF mirror, so neither is the signal):
131+
132+```text
133+ours=96997 (unparsed 0) oracle=96997 (unparsed 0)
134+bit-identical over all 96997 paired reads
135+```
136+
137+### 3.2 Gate, counter, mutation proof
138+
139+* fixture `crates/ec-av1/fixtures/420_mixll_altref_256x128_5f.obu`, 18 525 B,
140+ pinned by **fnv1a64** `16348502764482216576` (not a `const SHA256` compared
141+ against itself);
142+* route counter `SUB8_LOSSLESS_NO_VARTX`, incremented on the **decision** — the
143+ `else if lossless(fctx) && !skip` arm, i.e. it can only be non-zero when the
144+ conjunct actually suppressed a tree that the pre-fix tree would have walked
145+ (`decode.rs:48349`). A stream whose sub-8 leaves all sit in lossy segments
146+ leaves it at zero, so the gate cannot look armed by merely decoding;
147+* gate `a_420_mixed_lossless_alt_ref_sub8_vartx_witness_is_byte_exact_in_decode_order`
148+ asserts 6 decode-order dumps with **1 hidden**, the counter delta `> 0`, and the
149+ shown-frame per-plane diff against `aomdec --rawvideo`.
150+
151+Mutation proof — the fix surgically reverted from the working tree, the gate
152+re-run — is in §8.
153+
154+## 4. The 640x480 control: what actually breaks, and why it is not this class
155+
156+### 4.1 The control's premise is false — the cell is wrong at base
157+
158+Decode-order dumps vs the oracle's `EC_AV1_FINAL_DUMP`, 460 800 B per frame:
159+
160+| cell | at base `6bb66a4a` | with the fix |
161+|---|---|---|
162+| `m5_640x480` (87 537 B) | **6/6 dumps, f1..f5 red by 352 066 / 414 286 / 313 795 / 399 471 / 422 078** | 4/6 dumps, then `REFUSED: unsupported: AV1 tile (a Golomb tail longer than this decoder reads)` |
163+| `m_640x480` (115 615 B) | 7/7 dumps, f1..f6 red by 162 045 … 439 643 | 5/7 dumps, then the same refusal |
164+
165+So the base tree does not "decode 640x480" — it emits between 8 % and 30 % of
166+each frame's bytes correctly and says nothing. The prior lane recorded the same
167+gap (`lanes/av1mixllfork.report.md` §7: *"Whether the 640x480 base decode is red
168+or exact — I measured that it decodes, not that it is correct"*). It is red.
169+The fix converts a **silent** near-garbage decode into a **loud** refusal, which
170+is the direction the project's honesty invariant asks for
171+(`skill://edith-refusal-inventory-gates`).
172+
173+### 4.2 The fix moves the fork 40 892 reads forward — it is not the blocker
174+
175+Paired `EC_SYMR`, first divergence over the whole stream:
176+
177+| tree | first divergence | our read count | oracle |
178+|---|---:|---:|---:|
179+| base `6bb66a4a` | **138 586** | 860 431 | 457 696 |
180+| with the fix | **179 378** | 521 856 | 457 696 |
181+
182+The base fork at 138 586 is the *same* signature as the pin's read 30 889 — the
183+oracle goes `decodemv.c:191` (`ref_mv`) → `decodetxb.c:158` (`txb_skip`) with no
184+`tx_size` symbol in between, and we read one — i.e. **the 640x480 cell has the
185+same lossless defect, and the fix fixes 40 892 reads' worth of it.** The
186+remaining fork is elsewhere.
187+
188+### 4.3 The remaining fork is a `tx_size_context` read — a different class
189+
190+At read 179 378 both sides are at the **same block, `mi=(80,110)`** (the oracle's
191+own `EC_TXCTXB` rung names it; its `EC_SYMR` `mi=` label is stale there, and
192+`site=decodeframe.c:1186` is **not** the var-tx split read — the built binary's
193+line numbering is 17 lines behind the current `decodeframe.c`, and 1186 there is
194+`read_selected_tx_size`'s `tx_size_cdf` read, which a paired
195+`EC_SYMR=1 EC_VARTX=1` run proves: the var-tx rung fires only 15 times in the
196+whole stream and at none of these bit positions).
197+
198+| side | above band | left band | above | left | **ctx** |
199+|---|---|---|---|---|---:|
200+| libaom (`EC_TXCTXB mi=80,110 bsize=2 maxw=8 maxh=4 hasup=1 hasleft=1`) | 4 | 8 | 0 | 1 | **1** |
201+| ours (`EC_TXCTX mi=80,110 own=8x4`) | **16** | 8 | 1 | 1 | **2** |
202+
203+The read is `tx_size_cat0[ctx]` at `decode.rs:47264`, a 4:2:0 **8x4 intra leaf
204+with `use_filter_intra` inside an inter frame** — a *sub-8 intra-rect leaf*, not
205+an inter leaf, so neither fixed site is involved.
206+
207+**One-line reproduction.** Forcing `ctx = 1` at that single site (an env-gated
208+override, reverted) makes the whole 640x480 cell **bit-identical to the oracle**:
209+
210+```text
211+natural ctx=2 : ours=521856 reads, first divergence 179378
212+forced ctx=1 : ours=457907 reads, oracle=457907, bit-identical over all 457907
213+forced ctx=0 : 286327 reads forced ctx=2 : 521856
214+forced ctx=3 : 179378 reads forced ctx=4 : 179378
215+```
216+
217+**The band itself is wrong, not the context formula.** Replaying every
218+`EC_TXUPD` band write up to read 179 378, the last write to mi column 110 is a
219+**skipped** 16-px-wide inter block at `mi=(36,108)` (`skip_inter=true`,
220+`w_mi=4 → bw=16`) at read 157 577; nothing writes column 110 between then and
221+the read. libaom reads 4 there, so libaom has a band write in rows 37..79 that
222+this tree does not make — class `context-band-not-published`, the same class
223+`decode.rs:27595`'s comment already names. **Not this lane's hunks, and not
224+fixable from a one-line context change: a forced `ctx` is a symptom mask, not a
225+fix.**
226+
227+## 5. Corpus sweep — 107 committed fixtures, before and after
228+
229+Every `crates/ec-av1/fixtures/*.obu`, decode-order dumps vs the oracle
230+(`EC_AV1_DECODE_ORDER_DUMP` / `EC_AV1_FINAL_DUMP`):
231+
232+| | base `6bb66a4a` | with the fix |
233+|---|---:|---:|
234+| EXACT | 64 | **65** |
235+| RED (decodes, some frame differs) | 34 | **33** |
236+| FRAMECOUNT mismatch | 9 | 9 |
237+| REFUSED | 0 | 0 |
238+
239+Per-fixture diff: **one row changes.**
240+
241+```text
242+420_mixll_altref_256x128_5f RED (f1..f5) -> EXACT
243+```
244+
245+No fixture goes EXACT → RED, none gains a refusal, none changes its frame count.
246+The change is a strict improvement over the committed corpus.
247+
248+## 6. Class sweep — *a per-segment flag consulted as a branch alternative
249+instead of a conjunct of the condition it gates*
250+
251+Every `lossless(fctx)` consult in `decode.rs` re-derived against libaom's own
252+`if` (74 sites). The class needs a **symbol read** whose guard tests the flag as
253+a branch *alternative*; chroma unit-grid selection is a different concern.
254+
255+| site | shape | verdict |
256+|---|---|---|
257+| `12835` | `else if lossless` — chroma unit grid | not this class |
258+| **`18229`/`18231`** | `if skip \|\| (!lossless && !tx_select) {None} else if lossless {4x4 grid} else {tree}` | **correct** — lossless is the FIRST discriminator, which is what libaom's `!xd->lossless` in the tree condition plus `read_tx_size`'s early return imply |
259+| `22032`, `23937` | `… && !lossless(fctx)` in the tree condition | conjunct — correct |
260+| `24642`, `24716`, `25762`, `42459`, `44261`, `48632` | `else if lossless` — chroma unit grid (4:2:2 / 4:4:4 / 4:2:0 rect chroma) | not this class |
261+| **`27213`/`27236`** | intrabc 4x8/8x4 rect leaf | **WAS this class — fixed** |
262+| `27572` | `tx_select && !lossless` | conjunct — correct |
263+| `29267` (`read_tx_size`), `29790` (`read_block_tx_size`), `30315` (`read_block_tx_size_rect`) | `if lossless { return / 4x4 }` before the tree | early return — correct |
264+| `14087`, `15549`, `16188`, `16754`, `18765`, `19742`, `47264` | `tx_select && !lossless` | conjunct — correct |
265+| **`48332`/`48348`** | sub-8 4x8/8x4 inter leaf | **WAS this class — fixed** |
266+| `476`, `485`, `12234`, `14617`, `15098`, `15307`, `15320`, `18342`, `18421`, `18422`, `19108`, `21576`, `21625`, `21664`, `21940`, `23393`, `24147`, `24203`, `24598`, `24850`, `25546`, `25549`, `27374`, `27412`, `29790`, `30315`, `30733`, `30744`, `30815`, `30887`, `37885`, `37894`, `37935`, `42230`, `44043`, `45027`, `45316`, `45769`, `45771`, `47739`, `50236`, `51195`, `51830` | value/units/recon selection, `depth != 0 \|\| lossless`, early returns | not this class |
267+
268+**Exactly 2 sites were in the class; both are fixed; there is no third.** The
269+recursive `read_var_tx_size` calls (29750, 29854, 30381, 30449) sit inside the
270+three functions that carry the lossless early return, verified by reading each
271+function's first lines.
272+
273+## 7. The rest of the class's stream sweep
274+
275+All `testsrc2`, `--passes=1 --cpu-used=4 --end-usage=q --cq-level=0 --aq-mode=1`,
276+decode-order dumps vs the oracle. "red" = the byte count of each differing frame
277+(49 152 for 256x128, 115 200 for 176x144/320x240, 230 400 for 352x288,
278+460 800 for 640x480).
279+
280+| cell | at base | with the fix |
281+|---|---|---|
282+| `m5_256x128` (pin, 5 f) | 6 dumps, red f1..f5: 33 724 / 34 251 / 44 500 / 36 688 / 37 462 | **6/6 EXACT** |
283+| `m_256x128` (6 f) | 7 dumps, red f1..f6: 36 045 … 43 147 | 7 dumps, red f1..f6: 6 051 / 4 115 / 2 962 / 26 566 / 41 876 / 14 749 |
284+| `m_176x144` | **REFUSED** (1 dump) | 7 dumps, red f1..f6: 811 / 949 / 630 / 969 / 811 / 24 105 |
285+| `m_320x240` | 7 dumps, red f1..f6: 67 194 … 97 946 | 7 dumps, **red f6 only: 19 398** |
286+| `m5_320x240` | 6 dumps, red f1..f5: 85 821 … 99 314 | 6 dumps, red f1..f5: 15 031 / 16 006 / 21 930 / 65 405 / 90 077 |
287+| `m_352x288` | **REFUSED** (3 dumps) | **7/7 EXACT** |
288+| `m5_640x480` | 6 dumps, red f1..f5: 313 795 … 422 078 | 4 dumps then REFUSED (§4) |
289+| `m_640x480` | 7 dumps, red f1..f6: 162 045 … 439 643 | 5 dumps then REFUSED (§4) |
290+| `m444_8` (4:4:4, 8 f) | 9 dumps, red f1..f8: 79 886 … 92 108 | **9/9 EXACT** |
291+
292+The 6-frame 256x128 and the 320x240 residuals are **not** claimed closed: they
293+are separate defects this change shrinks but does not remove.
294+
295+The 176x144 residual is the `mi=(32,32)` extra-geometry fork already handed to
296+`lane-av1golomb320`, and this lane re-measured it rather than citing it: paired
297+`EC_SYMR` on `m_176x144` gives a first divergence at read **25792 both with and
298+without the conjunct**, and the fix still moves our read count from **41 381 to
299+105 219** against the oracle's **106 607** — i.e. it closes 63 838 reads of
300+divergence and leaves 1 388 of that other defect. The two sites are independent,
301+which is the same conclusion `lanes/av1golomb320.report.md` §4 reached.
302+
303+## 7b. Composition with `lane-av1offtile` (`e87a8a27`, was `714fb55b`) — measured, then reverted
304+
305+`714fb55b` (later amended to `e87a8a27`) bounds the lossless rect strip's chroma walk by the chroma PLANE and
306+closes the `mi=(32,32)` 40-extra-reads fork this lane inherited as 176x144's
307+residual. Cherry-picked onto this tip for the measurement only (reverted; the branch
308+carries no trace of it). Their tip is now `e87a8a27`, which differs from the
309+`714fb55b` I measured in `lanes/av1offtile.report.md` ONLY -- `git diff 714fb55b
310+e87a8a27 -- crates/` is empty -- so these numbers stand without re-taking
311+them:
312+
313+| cell | my clip alone | both clips |
314+|---|---|---|
315+| `m5_256x128` (pin) | 6/6 exact | **6/6 exact** |
316+| `m_176x144` | 7 dumps, red f1..f6 | **7/7 exact** |
317+| `m_352x288` | 7/7 exact | **7/7 exact** |
318+| `m444_8` (4:4:4) | 9/9 exact | **9/9 exact** |
319+| `m5_640x480` | 4/6 dumps then REFUSED, red 64 181 / 98 673 / 63 442 | **identical — the clip changes nothing** |
320+| `m_640x480` | 5/7 dumps then REFUSED, red 53 685 / 75 891 / 34 386 / 112 145 | identical |
321+
322+So the two clips compose without overlap and together close every cell of this
323+recipe at 256x128, 176x144, 352x288 and 4:4:4. The 640x480 residual is
324+untouched by the composition — the three red byte counts are the same to the
325+byte — which is the third defect of §4.3, not a chroma-walk defect.
326+
327+**`lane-av1offtile` originally reported that `mix_640x480_5/6` "still decode with
328+both applied". That does not reproduce on this tip + their clip** (measured
329+above); it reproduces on base + their clip, i.e. without the var-tx conjunct.
330+They re-measured, retracted it verbatim with the re-measurement under it, and
331+amended to `e87a8a27` (2026-09-30). They also independently re-measured the
332+"red at base" point on their own tree and got my numbers exactly
333+(f1 352066, f2 414286, f3 313795, f4 399471 of 460800).
334+
335+## 8. Mutation proof
336+
337+The fix surgically reverted from the working tree (the two
338+` && !lossless(fctx)` suffixes removed from lines 27213 and 48332), the gate
339+re-run:
340+
341+```text
342+running 1 test
343+
344+thread 'stream::tests::a_420_mixed_lossless_alt_ref_sub8_vartx_witness_is_byte_exact_in_decode_order'
345+panicked at crates/ec-av1/src/stream.rs:10935:17:
346+a_420_mixed_lossless_alt_ref_sub8_vartx_witness_is_byte_exact_in_decode_order:
347+decode-order frame 1 of 6 (5 shown, 1 hidden) differs from the oracle at byte 33
348+(ours 82 vs 81), 33724 bytes differ
349+test stream::tests::a_420_mixed_lossless_alt_ref_sub8_vartx_witness_... ... FAILED
350+
351+test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 803 filtered out
352+```
353+
354+**33 724 -- the same number as the hand-measured red in section 1 / section 7.**
355+Restored, the same gate is green and prints its non-vacuity evidence:
356+
357+```text
358+a_420_mixed_lossless_alt_ref_sub8_vartx_witness_is_byte_exact_in_decode_order:
359+6 decode-order frame(s) byte-exact (1 hidden), 5 shown frame(s) exact per plane,
360+40 sub-8 leaf/leaves on a lossless segment read no var-tx symbol
361+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 803 filtered out
362+```
363+
364+
365+## 9. Scoped test command and output
366+
367+```text
368+CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1mixllconj EC_NOMEMGUARD=1 \
369+ cargo test -p ec-av1 --lib -- 420 444 422 lossless stream \
370+ --skip bitrate_target_lands_within_5_percent_over_48_frames
371+```
372+
373+```text
374+test result: ok. 375 passed; 0 failed; 7 ignored; 0 measured; 422 filtered out;
375+ finished in 1770.01s
376+```
377+
378+**375 / 0 / 7 / 422.** `lanes/av1mixllfork.report.md` §8 records
379+`373 / 0 / 7 / 422` for the same scope on its (older) base; the two extra
380+passes are this lane's new gate plus the `4:4:4` chroma palette gate that landed
381+on `main` after that report, so the numbers are comparable and the run is a
382+real-delta result, not a no-delta confirmation.
383+
384+**The scope limit this run cannot cover, restated because it is load-bearing:**
385+it contains **no 640x480-class cell**. The corpus sweep in §5 covers the
386+committed fixtures and the cell sweep in §7 covers the generated ones, so the
387+§4 refusal is caught by neither the suite nor the corpus -- it needs its own
388+generated cell, exactly as the prior lane warned.
389+
390+## 10. What is NOT measured
391+
392+* **The 640x480 cell does not decode with this fix in.** §4 names the blocker
393+ (a missing `TXFM_CONTEXT` band write above `mi=(80,110)`, class
394+ `context-band-not-published`) and reproduces its effect in one line, but the
395+ band write itself is not identified to a call site — the replay only shows
396+ that libaom has a write in rows 37..79 at mi column 110 and this tree has
397+ none. That is the next lane's job, and it is NOT this lane's hunks.
398+* **10/12-bit arm of the class sweep: not synthesized.** This ffmpeg cannot emit
399+ a >8-bit y4m and a hand-built 16-bit-LE one is rejected by the shared
400+ `aomenc` (`Loss of framing in Y4M input data`). The committed HBD corpus is
401+ covered by the §5 regression; that is a regression, not a sweep of this class
402+ at HBD.
403+* The class is content-dependent: everything above is `testsrc2` at five sizes.
404+ The 106 committed fixtures that do not come from this recipe are the
405+ regression evidence (§5), not a sweep of the class.
406+* The forced-`ctx` override in §4.3 is a **symptom mask used as a proof**, not a
407+ candidate fix; it is not in the tree.
408+
409+## 11. Fix-now | deferred(<unblock>) | accepted
410+
411+* **fix-now** — the two-line conjunct, its fixture, its route counter and its
412+ gate. Landed in this commit.
413+* **deferred(unblock: identify the `TXFM_CONTEXT` band write libaom makes above
414+ `mi=(80,110)` on a 640x480 mixed-lossless cell, rows 37..79, mi column 110 —
415+ the last write this tree makes is a skipped 16-px inter block at `mi=(36,108)`
416+ publishing 16 where libaom has 4)** — that is the whole 640x480 cell, and the
417+ one regression control this lane does not meet. Owner: whoever holds
418+ `context-band-not-published`; §4.3 hands it a one-line reproduction.
419+* **deferred(identification of the residual reds on the 6-frame 256x128,
420+ 320x240 and 176x144 arms)** — the 176x144 one is `lane-av1golomb320`'s
421+ `mi=(32,32)` fork; the other two are unnamed and this lane does not claim
422+ them.
423+* **deferred(a >8-bit y4m source, or a hand-built one the shared `aomenc`
424+ accepts)** — the HBD arm of the class sweep, §10.
425+* **accepted** — the `EC_MIXLL` per-frame table print, the `EC_SITETAG` /
426+ `EC_TXCTX_SITE` / `EC_TXUPD` diagnostics and the `set_symr_cdf` tags are all
427+ **reverted**; the tree carries no probe bypass and no env-gated trace. The
428+ permanent artefacts are this report and the measurements in it. The shared
429+ oracle was never rebuilt or edited: the one oracle rung this lane needed
430+ (`EC_TXCTXB`) already existed.
431+
432+## 12. Hunk scope
433+
434+* Authored here: this report, and nothing else. The `decode.rs` lines are the
435+ cherry-picked candidate `658d37fa`'s (`27213`, `48332`, plus the
436+ `SUB8_LOSSLESS_NO_VARTX` counter at `48349`); the fixture and the gate are
437+ that commit's too, re-measured on this base.
438+* No line outside those hunks was touched; `git status` in the primary checkout
439+ is clean.
440+* Every diagnostic added during this lane was reverted before the commit
441+ (`git status --porcelain` empty apart from this report).