diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 27c39a23..02d45d9e 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -12801,7 +12801,9 @@ fn decode_block_rect( /// caller uses once, after both strips, exactly like the `VERT_B` arm next /// to it). The non-skip case (lane-rectx) reads real `TX_16X8`/`TX_8X16` /// luma coefficients (`TxbSet::LumaRect16x8`) and their `TX_8X4`/`TX_4X8` -/// chroma half (`TxbSet::ChromaRect8x4`), the two size classes one level +/// chroma half (`TxbSet::ChromaRect8x4`) at 4:2:0 -- an 8x8 *square* chroma +/// plane (`TxbSet::Chroma8` + the default scan) at 4:2:2 (lane-av1-422e: +/// half-width, unhalved height), the two size classes one level /// under [`decode_block_rect`]'s own 32x16/16x32 strip. #[allow(clippy::too_many_arguments)] fn decode_leaf_rect( @@ -13057,14 +13059,28 @@ fn decode_leaf_rect( // `use_reduced_set` branch returns `EXT_TX_SET_DTT4_IDTX` at // `tx_size_sqr_up == TX_16X16` regardless of the true, non-square // `tx_size`) and its chroma half (8x4/4x8, `TxbSet::ChromaRect8x4`). + // lane-av1-422e: a 4:2:2 strip halves only the width, so the chroma + // half of a 16x8/8x16 luma leaf is an 8x8 SQUARE (`TxbSet::Chroma8` + + // the default scan -- the pairing any 8x8 chroma plane reads). 4:2:0 + // halves both axes (8x4/4x8 rect, `TxbSet::ChromaRect8x4`); 4:4:4 + // leaves the full 16x8/8x16 rect (`TxbSet::ChromaRect16x8`). + let chroma_422 = ss_x(fctx) == 1 && ss_y(fctx) == 0; let (luma_scan, chroma_scan): (&[u16], &[u16]) = if ss_x(fctx) == 0 { if bw == 16 { (&SCAN_16X8, &SCAN_16X8) } else { (&SCAN_8X16, &SCAN_8X16) } + } else if chroma_422 { + if bw == 16 { (&SCAN_16X8, default_scan(8)) } else { (&SCAN_8X16, default_scan(8)) } } else if bw == 16 { (&SCAN_16X8, &SCAN_8X4) } else { (&SCAN_8X16, &SCAN_4X8) }; - let chroma_rect_set = if ss_x(fctx) == 0 { TxbSet::ChromaRect16x8 } else { TxbSet::ChromaRect8x4 }; + let chroma_rect_set = if ss_x(fctx) == 0 { + TxbSet::ChromaRect16x8 + } else if chroma_422 { + TxbSet::Chroma8 + } else { + TxbSet::ChromaRect8x4 + }; let around = neighbours.around_mi_rect(leaf_mi, bw, bh); let luma_set = if reduced_tx_set { TxbSet::LumaRect16x8 diff --git a/lanes/av1422e.report.md b/lanes/av1422e.report.md new file mode 100644 index 00000000..b1565ac7 --- /dev/null +++ b/lanes/av1422e.report.md @@ -0,0 +1,84 @@ +# lane-av1-422e — leaf_rect chroma is an 8x8 square unit at ss (1,0); refusal stays + +## Outcome + +STOP with the 4:2:2 header refusal in place, byte-identical. `decode_leaf_rect`'s +chroma arm now keys on ss: at ss (1,0) a 16x8/8x16 luma leaf's chroma plane +block is an 8x8 SQUARE (`TxbSet::Chroma8` + `default_scan(8)`), and every +leaf_rect chroma read on the measured fixture is rng-for-rng EXACT against the +oracle — the av1422d desync at the HORZ_A 16x8 strip (mi(2,0)) is gone, along +with everything up to the first 16x16 square block. The stream now desyncs at +that square block's chroma (next section), so the refusal is retained and the +probe bypass was reverted before commit (`git diff` touches only decode.rs). + +## Change (decode.rs only) + +- `decode_leaf_rect` chroma arm (was decode.rs:13060-13067): the + `ss_x == 0`-keyed selection replaced by a three-way arm — `chroma_422` + (`ss_x == 1 && ss_y == 0`) picks `TxbSet::Chroma8` + `default_scan(8)` for + the 8x8 square plane block (luma scan unchanged: SCAN_16X8/SCAN_8X16); + 4:2:0 keeps `TxbSet::ChromaRect8x4` + SCAN_8X4/SCAN_4X8; 4:4:4 keeps + `TxbSet::ChromaRect16x8` + the full SCAN_16X8/SCAN_8X16. Doc comment above + `decode_leaf_rect` updated to name all three subsamplings. +- Untouched: `decode_leaf8`, `leaf8_chroma422_unit`, `sub8_leaf_chroma444`, + `decode_leaf_split4`, `reconstruct_mc_rect`, the resize header reader, + `decode.rs` 34390-34440. + +## Measurement + +Fixture `/tmp/t422.obu`, sha256 +`d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129` (reused by +hash). Oracle `$HOME/.cache/aom-oracle/build/aomdec` +`EC_TRACE=1 EC_TRACE_MODE_STEP=1 EC_TRACE_COEFF=1`; ours `decode_probe` (debug, +private target dir) same env plus a LOCAL `EC_AV1_ALLOW_422_PROBE` bypass +env-gated at the stream.rs refusal — reverted before commit, and the refusal +was re-proven to fire without the env. + +The first leaf_rect 16x8 strips that desynced in av1422d now pair rng-for-rng +through their full luma + U + V coefficient bodies (all EC_COEFF_STEP rngs +match: all_zero, tx_type, eob, base_eob, br, sign, post_golomb), and the ISTEP +stream stays identical well past them. With that site passed, decode now +reaches the first 16x16 square intra block, mi(4,4). + +## First remaining divergence (named next site, with oracle evidence) + +The SQUARE-block path's 4:2:2 chroma model, decode.rs:16704-16721 +(lane-av1-422b's arm inside the `(luma_set, chroma_set, luma_tx, chroma_tx, +scans)` selection): it models `av1_get_max_uv_txsize` of the (side/2, side) +plane block as "the SQUARE transform of the smaller dimension" and walks a grid +of square units (side 16 -> two 8x8 units). The oracle disagrees — aom reads +`max_txsize_rect_lookup` of the PLANE block, a RECT that fills it exactly: + +- ours, mi(4,4) side=16: all_zero `side=8 ctx=5` at rng 44044 -> eob read on + the 8x8-class alphabet (eob=48) — the first of two square units. +- oracle, same block: `all_zero plane=1 bc=0 br=0 ctx=9 txs=2` at rng 36040 — + ONE unit, TX_8X16 class (16x16 entropy class), whole 8x16 plane block. + +Correct model per aom (`av1_get_max_uv_txsize` = `max_txsize_rect_lookup` +[plane_bsize], then `av1_get_adjusted_tx_size`): side 8 -> TX_4X8 +(ChromaRect8x4 + SCAN_4X8, one unit — the shape av1422d proved at leaf8); +side 16 -> TX_8X16 (ChromaRect16x8 + SCAN_8X16, one unit); side 32 -> TX_16X32 +(ChromaRect32x16 + SCAN_16X32, one unit); side 64 -> TX_32X64 adjusts to +TX_32X32, i.e. two stacked 32x32 units, which the current square walk already +produces. The fix spans the square path's three chroma walks (skip 17019-17067, +single-unit 17120-17260, chunked 17273-17553) since they thread `chroma_tx` as +both unit dims; it needs per-axis unit dims keyed to ss (1,0). That is its own +lane round — not started, no rows invented, no BLOCK_INVALID portrait shape. + +The av1422d second site (decode_rect_split's chroma table missing (8,64)) did +NOT fire this round: the square-path site above blocks first. The +decode_rect_split 16x8-strip reads (chroma 8x8 via the chroma_tiled arm) pass +the oracle rng-for-rng; the repeated `EC_RECTCHROMA_GAP luma=16x8 tx=8x8 +chroma=8x8` prints are the pre-existing diagnostic (chroma.is_none() before the +chroma_tiled fallback), not refusals. + +## State + +- Refusal `a chroma format of 4:2:2 (subsampling_x != subsampling_y)...` + byte-identical (bypass reverted; probe refuses without the env). +- `cargo check -p ec-av1` (private target dir): 0 warnings. +- 420 gates green: `a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_ + tx_split_decodes_pixel_exact` + its 10-bit twin — 2/2 pass (exercises the + skip and TX4 arms restructured in av1422d; the new 422 arm is unreachable at + 420 by its ss condition). +- No push. Traces left at /tmp/ours422.txt and /tmp/oracle422.txt.