From 564bd72dcc1e081a3f5054d938daec675d488c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Sep 2026 10:19:02 +0300 Subject: [PATCH] fix(av1): the 8x8 intra leaf inside an inter frame read the REDUCED five-type tx_type set unconditionally decode_inter_block8's intra arm passed a hardcoded TxbSet::Luma8 (the reduced_tx_set==1 alphabet, EXT_TX_SET_DTT4_IDTX, five types) for the leaf's 8x8 luma transform. With reduced_tx_set==0 libaom's av1_get_ext_tx_set_type returns EXT_TX_SET_DTT4_IDTX_1DDCT for is_inter==0 at tx_size_sqr==TX_8X8 -- seven types. Same symbol value, different narrowing: the msac range diverged at the leaf's first tx_type and desynced the rest of the tile, which is what produced the 30/30 "named refusal" attempts the r1/r2 gate logs showed. Route the set through txbset_for(8, reduced_tx_set); reduced_tx_set was already a parameter of this function. Per-TU range ladder against the instrumented aomdec on the gate's own 192x128 8-bit stream goes from a first divergence at TU 3392 (frame 2, mi 2,34) to 13986/13986 identical. Gate uv_mode_in_inter8_gate: 3/3 arms (8-bit, 10-bit, two-tile) pixel-exact on attempt 0 with all three chroma classes firing; the counted predicate is tightened to require all three on the same compared attempt. --- crates/ec-av1/src/decode.rs | 10 ++++++++- crates/ec-av1/src/stream.rs | 6 +++++- lanes/uv8-r3.report.md | 42 +++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 lanes/uv8-r3.report.md diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 9b8c0de3..531e1066 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -22045,7 +22045,15 @@ fn decode_inter_block8( luma_grid = read_plane( dec, cdfs, - TxbSet::Luma8, + // lane-uv8 r3: an intra leaf inside an inter frame is + // `is_inter == 0` in `av1_get_ext_tx_set_type`, so its 8x8 + // luma reads the INTRA set -- seven-type + // `EXT_TX_SET_DTT4_IDTX_1DDCT` when `reduced_tx_set == 0`, + // five-type `EXT_TX_SET_DTT4_IDTX` when it is 1. Hardcoding + // the reduced set read the wrong ALPHABET (class + // [[wrong-alphabet-same-value]]) and desynced at the leaf's + // first `tx_type`. + txbset_for(8, reduced_tx_set), scan8, 0, around[0], diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 43c4730f..e719d3c9 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -5890,7 +5890,11 @@ mod tests { // class [[gate-skips-on-its-own-failure]]: a decode that succeeded // is ALWAYS pixel-compared; the counter only decides whether the // attempt counts as firing. - let counted = fired.0 + fired.1 + fired.2 != 0; + // lane-uv8 r3: every one of the three chroma classes this gate + // exists for (directional, smooth/paeth, CfL) must fire on the + // SAME pixel-compared attempt -- a sum-nonzero predicate would + // pass on an attempt that only ever hit DC-adjacent CfL. + let counted = fired.0 > 0 && fired.1 > 0 && fired.2 > 0; if !counted { uncounted_exact += 1; refusals.push(format!( diff --git a/lanes/uv8-r3.report.md b/lanes/uv8-r3.report.md new file mode 100644 index 00000000..d8b3fc41 --- /dev/null +++ b/lanes/uv8-r3.report.md @@ -0,0 +1,42 @@ +# lane-uv8 r3 — GREEN (root cause: wrong tx_type ALPHABET on the 8x8 intra-in-inter leaf) + +## Root cause +`decode_inter_block8`'s INTRA arm passed a hardcoded `TxbSet::Luma8` to `read_plane` for the +leaf's 8x8 luma transform. `TxbSet::Luma8` is the `reduced_tx_set == 1` set +(`EXT_TX_SET_DTT4_IDTX`, FIVE types); with `reduced_tx_set == 0` libaom's +`av1_get_ext_tx_set_type` (`av1/common/blockd.h`) returns, for `is_inter == 0` and +`tx_size_sqr == TX_8X8`, `EXT_TX_SET_DTT4_IDTX_1DDCT` — SEVEN types +(`TxbSet::Luma8Set1`). Same symbol, different alphabet: the CDF narrowing differed, so the +msac range diverged at the leaf's first `tx_type` and every following block desynced. The +desync manufactured the 30/30 "named refusals" the r1/r2 gate logs showed +(class [[refusal-from-own-desync]] + [[wrong-alphabet-same-value]]). + +Charter suspect (1) (the `fimode_to_intradir` row) was already correct: `fi_tx_row` is applied +at every luma `txb` call site including this one, and `fimode_to_intradir[0] == DC_PRED` +equals this block's `y_mode` anyway, so that row was inert here. + +## Change +- `crates/ec-av1/src/decode.rs:22057` — `TxbSet::Luma8` -> `txbset_for(8, reduced_tx_set)` + (`reduced_tx_set` was already a parameter of `decode_inter_block8`). +- `crates/ec-av1/src/stream.rs:5897` — gate `counted` predicate tightened from + "sum nonzero" to "all three uv classes fired on the same pixel-compared attempt". + +## Sweep (class: hardcoded reduced-set TxbSet) +`grep -n 'TxbSet::Luma\(4\|8\|16\|32\),' decode.rs` — the only reduced-sensitive hardcodes are +sizes 8 and 4; after this fix there are ZERO outside `txbset_for`/`txbset_for_inter`. Every +`Luma16`/`Luma32` literal is alphabet-invariant to `reduced_tx_set` (`txbset_for` maps 16 and +32 identically for both values). The rect-strip and >=16 square intra-in-inter arms already go +through `txbset_for`/`txbset_for_inter` (decode.rs:6053, 7167, 7777, 7857, 9594, 11075). + +## EVIDENCE +EVIDENCE: ~/.cache/uv8-tmp/ref.tu + ours3.tu | aomdec EC_TRACE_COEFF vs our EC_TRACE_COEFF on ~/.cache/uv8-tmp/a0.obu, per-TU (all_zero,eob) msac range ladder | before: first divergence at TU-line 3392 (ref eob rng=32776, ours 34568; the preceding tx_type read was ref rng=33532 vs ours 35240 at plane=0 tx_size=1, the mi(2,34) filter-intra leaf of decode-order frame 2) — after: 13986/13986 lines identical, whole stream, decode_probe rc=0 with no refusal +EVIDENCE: $HOME/.cache/uv8-gate-r3.log | `cargo test -p ec-av1 --lib -- --test-threads=1 --nocapture non_dc_chroma_8x8_intra_leaf` | 3 passed / 0 failed; every arm exact on attempt 0 with all three classes firing — 8bit/1tile dir 159 smooth-paeth 172 cfl 211; 10bit/1tile 112/126/120; 8bit/2tile 83/66/80; buckets counted-exact=1 uncounted-exact=0 named-refusals=0 on each + +## Residue +- deferred: the 8x8 intra-in-inter leaf whose `tx_depth` splits to four TX_4X4 units is still + refused by name (decode.rs ~21996). Unblocked by an arm with `--enable-tx-size-search=1` + plus a 4x4-TU prediction loop in this leaf path — out of this lane's charter, which fixed the + depth-0 alphabet. Its refusal string stays in refusal_inventory.rs. +- accepted: `frames` from `decode_stream` is decode order; the gate recipe has + `--lag-in-frames=0 --auto-alt-ref=0`, so decode order == display order and all 8 frames are + compared (class [[gate-blind-to-hidden-frames]] does not apply).