ec-av1: lane-av1-422e r1 -- leaf_rect chroma is an 8x8 square unit at ss (1,0), behind the header refusal
Browse files at this commit7607f60c421b1f1d0f23884854551372d9d800f5Parent: 4280e512 changed files +102 -2
- crates/ec-av1/src/decode.rs +18 -2
- lanes/av1422e.report.md +84 -0
crates/ec-av1/src/decode.rsmodified+18 -2
| @@ -12801,7 +12801,9 @@ fn decode_block_rect( | |||
| 12801 | /// caller uses once, after both strips, exactly like the `VERT_B` arm next | 12801 | /// caller uses once, after both strips, exactly like the `VERT_B` arm next |
| 12802 | /// to it). The non-skip case (lane-rectx) reads real `TX_16X8`/`TX_8X16` | 12802 | /// to it). The non-skip case (lane-rectx) reads real `TX_16X8`/`TX_8X16` |
| 12803 | /// luma coefficients (`TxbSet::LumaRect16x8`) and their `TX_8X4`/`TX_4X8` | 12803 | /// luma coefficients (`TxbSet::LumaRect16x8`) and their `TX_8X4`/`TX_4X8` |
| 12804 | -/// chroma half (`TxbSet::ChromaRect8x4`), the two size classes one level | 12804 | +/// chroma half (`TxbSet::ChromaRect8x4`) at 4:2:0 -- an 8x8 *square* chroma |
| 12805 | +/// plane (`TxbSet::Chroma8` + the default scan) at 4:2:2 (lane-av1-422e: | ||
| 12806 | +/// half-width, unhalved height), the two size classes one level | ||
| 12805 | /// under [`decode_block_rect`]'s own 32x16/16x32 strip. | 12807 | /// under [`decode_block_rect`]'s own 32x16/16x32 strip. |
| 12806 | #[allow(clippy::too_many_arguments)] | 12808 | #[allow(clippy::too_many_arguments)] |
| 12807 | fn decode_leaf_rect( | 12809 | fn decode_leaf_rect( |
| @@ -13057,14 +13059,28 @@ fn decode_leaf_rect( | |||
| 13057 | // `use_reduced_set` branch returns `EXT_TX_SET_DTT4_IDTX` at | 13059 | // `use_reduced_set` branch returns `EXT_TX_SET_DTT4_IDTX` at |
| 13058 | // `tx_size_sqr_up == TX_16X16` regardless of the true, non-square | 13060 | // `tx_size_sqr_up == TX_16X16` regardless of the true, non-square |
| 13059 | // `tx_size`) and its chroma half (8x4/4x8, `TxbSet::ChromaRect8x4`). | 13061 | // `tx_size`) and its chroma half (8x4/4x8, `TxbSet::ChromaRect8x4`). |
| 13062 | + // lane-av1-422e: a 4:2:2 strip halves only the width, so the chroma | ||
| 13063 | + // half of a 16x8/8x16 luma leaf is an 8x8 SQUARE (`TxbSet::Chroma8` + | ||
| 13064 | + // the default scan -- the pairing any 8x8 chroma plane reads). 4:2:0 | ||
| 13065 | + // halves both axes (8x4/4x8 rect, `TxbSet::ChromaRect8x4`); 4:4:4 | ||
| 13066 | + // leaves the full 16x8/8x16 rect (`TxbSet::ChromaRect16x8`). | ||
| 13067 | + let chroma_422 = ss_x(fctx) == 1 && ss_y(fctx) == 0; | ||
| 13060 | let (luma_scan, chroma_scan): (&[u16], &[u16]) = if ss_x(fctx) == 0 { | 13068 | let (luma_scan, chroma_scan): (&[u16], &[u16]) = if ss_x(fctx) == 0 { |
| 13061 | if bw == 16 { (&SCAN_16X8, &SCAN_16X8) } else { (&SCAN_8X16, &SCAN_8X16) } | 13069 | if bw == 16 { (&SCAN_16X8, &SCAN_16X8) } else { (&SCAN_8X16, &SCAN_8X16) } |
| 13070 | + } else if chroma_422 { | ||
| 13071 | + if bw == 16 { (&SCAN_16X8, default_scan(8)) } else { (&SCAN_8X16, default_scan(8)) } | ||
| 13062 | } else if bw == 16 { | 13072 | } else if bw == 16 { |
| 13063 | (&SCAN_16X8, &SCAN_8X4) | 13073 | (&SCAN_16X8, &SCAN_8X4) |
| 13064 | } else { | 13074 | } else { |
| 13065 | (&SCAN_8X16, &SCAN_4X8) | 13075 | (&SCAN_8X16, &SCAN_4X8) |
| 13066 | }; | 13076 | }; |
| 13067 | - let chroma_rect_set = if ss_x(fctx) == 0 { TxbSet::ChromaRect16x8 } else { TxbSet::ChromaRect8x4 }; | 13077 | + let chroma_rect_set = if ss_x(fctx) == 0 { |
| 13078 | + TxbSet::ChromaRect16x8 | ||
| 13079 | + } else if chroma_422 { | ||
| 13080 | + TxbSet::Chroma8 | ||
| 13081 | + } else { | ||
| 13082 | + TxbSet::ChromaRect8x4 | ||
| 13083 | + }; | ||
| 13068 | let around = neighbours.around_mi_rect(leaf_mi, bw, bh); | 13084 | let around = neighbours.around_mi_rect(leaf_mi, bw, bh); |
| 13069 | let luma_set = if reduced_tx_set { | 13085 | let luma_set = if reduced_tx_set { |
| 13070 | TxbSet::LumaRect16x8 | 13086 | TxbSet::LumaRect16x8 |
lanes/av1422e.report.mdadded+84 -0
| @@ -0,0 +1,84 @@ | |||
| 1 | +# lane-av1-422e — leaf_rect chroma is an 8x8 square unit at ss (1,0); refusal stays | ||
| 2 | + | ||
| 3 | +## Outcome | ||
| 4 | + | ||
| 5 | +STOP with the 4:2:2 header refusal in place, byte-identical. `decode_leaf_rect`'s | ||
| 6 | +chroma arm now keys on ss: at ss (1,0) a 16x8/8x16 luma leaf's chroma plane | ||
| 7 | +block is an 8x8 SQUARE (`TxbSet::Chroma8` + `default_scan(8)`), and every | ||
| 8 | +leaf_rect chroma read on the measured fixture is rng-for-rng EXACT against the | ||
| 9 | +oracle — the av1422d desync at the HORZ_A 16x8 strip (mi(2,0)) is gone, along | ||
| 10 | +with everything up to the first 16x16 square block. The stream now desyncs at | ||
| 11 | +that square block's chroma (next section), so the refusal is retained and the | ||
| 12 | +probe bypass was reverted before commit (`git diff` touches only decode.rs). | ||
| 13 | + | ||
| 14 | +## Change (decode.rs only) | ||
| 15 | + | ||
| 16 | +- `decode_leaf_rect` chroma arm (was decode.rs:13060-13067): the | ||
| 17 | + `ss_x == 0`-keyed selection replaced by a three-way arm — `chroma_422` | ||
| 18 | + (`ss_x == 1 && ss_y == 0`) picks `TxbSet::Chroma8` + `default_scan(8)` for | ||
| 19 | + the 8x8 square plane block (luma scan unchanged: SCAN_16X8/SCAN_8X16); | ||
| 20 | + 4:2:0 keeps `TxbSet::ChromaRect8x4` + SCAN_8X4/SCAN_4X8; 4:4:4 keeps | ||
| 21 | + `TxbSet::ChromaRect16x8` + the full SCAN_16X8/SCAN_8X16. Doc comment above | ||
| 22 | + `decode_leaf_rect` updated to name all three subsamplings. | ||
| 23 | +- Untouched: `decode_leaf8`, `leaf8_chroma422_unit`, `sub8_leaf_chroma444`, | ||
| 24 | + `decode_leaf_split4`, `reconstruct_mc_rect`, the resize header reader, | ||
| 25 | + `decode.rs` 34390-34440. | ||
| 26 | + | ||
| 27 | +## Measurement | ||
| 28 | + | ||
| 29 | +Fixture `/tmp/t422.obu`, sha256 | ||
| 30 | +`d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129` (reused by | ||
| 31 | +hash). Oracle `$HOME/.cache/aom-oracle/build/aomdec` | ||
| 32 | +`EC_TRACE=1 EC_TRACE_MODE_STEP=1 EC_TRACE_COEFF=1`; ours `decode_probe` (debug, | ||
| 33 | +private target dir) same env plus a LOCAL `EC_AV1_ALLOW_422_PROBE` bypass | ||
| 34 | +env-gated at the stream.rs refusal — reverted before commit, and the refusal | ||
| 35 | +was re-proven to fire without the env. | ||
| 36 | + | ||
| 37 | +The first leaf_rect 16x8 strips that desynced in av1422d now pair rng-for-rng | ||
| 38 | +through their full luma + U + V coefficient bodies (all EC_COEFF_STEP rngs | ||
| 39 | +match: all_zero, tx_type, eob, base_eob, br, sign, post_golomb), and the ISTEP | ||
| 40 | +stream stays identical well past them. With that site passed, decode now | ||
| 41 | +reaches the first 16x16 square intra block, mi(4,4). | ||
| 42 | + | ||
| 43 | +## First remaining divergence (named next site, with oracle evidence) | ||
| 44 | + | ||
| 45 | +The SQUARE-block path's 4:2:2 chroma model, decode.rs:16704-16721 | ||
| 46 | +(lane-av1-422b's arm inside the `(luma_set, chroma_set, luma_tx, chroma_tx, | ||
| 47 | +scans)` selection): it models `av1_get_max_uv_txsize` of the (side/2, side) | ||
| 48 | +plane block as "the SQUARE transform of the smaller dimension" and walks a grid | ||
| 49 | +of square units (side 16 -> two 8x8 units). The oracle disagrees — aom reads | ||
| 50 | +`max_txsize_rect_lookup` of the PLANE block, a RECT that fills it exactly: | ||
| 51 | + | ||
| 52 | +- ours, mi(4,4) side=16: all_zero `side=8 ctx=5` at rng 44044 -> eob read on | ||
| 53 | + the 8x8-class alphabet (eob=48) — the first of two square units. | ||
| 54 | +- oracle, same block: `all_zero plane=1 bc=0 br=0 ctx=9 txs=2` at rng 36040 — | ||
| 55 | + ONE unit, TX_8X16 class (16x16 entropy class), whole 8x16 plane block. | ||
| 56 | + | ||
| 57 | +Correct model per aom (`av1_get_max_uv_txsize` = `max_txsize_rect_lookup` | ||
| 58 | +[plane_bsize], then `av1_get_adjusted_tx_size`): side 8 -> TX_4X8 | ||
| 59 | +(ChromaRect8x4 + SCAN_4X8, one unit — the shape av1422d proved at leaf8); | ||
| 60 | +side 16 -> TX_8X16 (ChromaRect16x8 + SCAN_8X16, one unit); side 32 -> TX_16X32 | ||
| 61 | +(ChromaRect32x16 + SCAN_16X32, one unit); side 64 -> TX_32X64 adjusts to | ||
| 62 | +TX_32X32, i.e. two stacked 32x32 units, which the current square walk already | ||
| 63 | +produces. The fix spans the square path's three chroma walks (skip 17019-17067, | ||
| 64 | +single-unit 17120-17260, chunked 17273-17553) since they thread `chroma_tx` as | ||
| 65 | +both unit dims; it needs per-axis unit dims keyed to ss (1,0). That is its own | ||
| 66 | +lane round — not started, no rows invented, no BLOCK_INVALID portrait shape. | ||
| 67 | + | ||
| 68 | +The av1422d second site (decode_rect_split's chroma table missing (8,64)) did | ||
| 69 | +NOT fire this round: the square-path site above blocks first. The | ||
| 70 | +decode_rect_split 16x8-strip reads (chroma 8x8 via the chroma_tiled arm) pass | ||
| 71 | +the oracle rng-for-rng; the repeated `EC_RECTCHROMA_GAP luma=16x8 tx=8x8 | ||
| 72 | +chroma=8x8` prints are the pre-existing diagnostic (chroma.is_none() before the | ||
| 73 | +chroma_tiled fallback), not refusals. | ||
| 74 | + | ||
| 75 | +## State | ||
| 76 | + | ||
| 77 | +- Refusal `a chroma format of 4:2:2 (subsampling_x != subsampling_y)...` | ||
| 78 | + byte-identical (bypass reverted; probe refuses without the env). | ||
| 79 | +- `cargo check -p ec-av1` (private target dir): 0 warnings. | ||
| 80 | +- 420 gates green: `a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_ | ||
| 81 | + tx_split_decodes_pixel_exact` + its 10-bit twin — 2/2 pass (exercises the | ||
| 82 | + skip and TX4 arms restructured in av1422d; the new 422 arm is unreachable at | ||
| 83 | + 420 by its ss condition). | ||
| 84 | +- No push. Traces left at /tmp/ours422.txt and /tmp/oracle422.txt. | ||