forge
Explore
Log in

Don't you dare go Hollow

ec-av1: lane-av1-422b r1 -- decode_block 4:2:2 rect chroma unit walk behind the header refusal

Browse files at this commit

3439011dfcd17ecca6bdf2cd694d1a1649104dafAhmet Kaan GümüşParent: 14d0a2f
- decode_block tx-size arm: 4:2:2 branch keyed to ss (1,0) -- uv plane block
  (side/2, side), max uv tx = square tx of the smaller dim capped at TX_32X32;
  unit grid is (side/2)/tx wide by side/tx tall
- all three chroma walks (skip / single-TU / multi-TU mu-chunk) generalized
  to cn_cols x cn_rows with per-axis luma anchors (around_mi_rect,
  tu_reach_rect, record_mi_chroma w/h, rect units tuples)
- intrabc chroma prediction buffers sized chroma_side x chroma_height
- Chroma8/Chroma16 txb_skip widened to six rows (+10 chroma rows, neutral
  per token_cdfs.h; mirrors the existing Chroma4/Chroma32 BIG assembly) --
  fixes the txb_skip[3] index panic a 4:2:2 plane-bigger-than-transform read
  took
- chroma422_square_hits() pub + printed by decode_probe; EC_PART/EC_PART_VAL
  traces (EC_TRACE-gated) at the 64/32/16/8 partition reads, format-matched
  to the instrumented aomdec oracle
- header refusal untouched and still committed; bypass used for measurement
  only and reverted before commit; stop + next site in lanes/av1422b.report.md
crates/ec-av1/examples/decode_probe.rsmodified+4 -0
@@ -36,6 +36,10 @@ fn main() {
3636 }
3737 let (sc, dp) = ec_av1::decode::reelc_chroma_counters();
3838 println!("reelc_chroma: skip_cfl={sc} dir_1to4_pairs={dp}");
39+ println!(
40+ "chroma422_square: {}",
41+ ec_av1::decode::chroma422_square_hits()
42+ );
3943 let (h, v, c) = ec_av1::stream::rect4_32_counters();
4044 println!("rect4_32: horz={h} vert={v} coded={c}");
4145 println!(
crates/ec-av1/src/cdf.rsmodified+115 -73
@@ -290,21 +290,16 @@ pub const EOB_PT_512_LUMA_Q3: [u16; 11] = [
290290 /// coded positions -- what a true 16x8/8x16 rectangular transform has
291291 /// (`txsize_log2_minus4` = 3), distinct from [`EOB_PT_256_CHROMA`]'s
292292 /// 256-position group a *square* 16x16 reads.
293-pub const EOB_PT_128_CHROMA: [u16; 9] = [
294- 13627, 16246, 20173, 24429, 27948, 30415, 31863, 32768, 0,
295-];
293+pub const EOB_PT_128_CHROMA: [u16; 9] = [13627, 16246, 20173, 24429, 27948, 30415, 31863, 32768, 0];
296294 /// [`EOB_PT_128_CHROMA`], q-context 0.
297-pub const EOB_PT_128_CHROMA_Q0: [u16; 9] = [
298- 5245, 7456, 12880, 15852, 20033, 23932, 27608, 32768, 0,
299-];
295+pub const EOB_PT_128_CHROMA_Q0: [u16; 9] =
296+ [5245, 7456, 12880, 15852, 20033, 23932, 27608, 32768, 0];
300297 /// [`EOB_PT_128_CHROMA`], q-context 1.
301-pub const EOB_PT_128_CHROMA_Q1: [u16; 9] = [
302- 8045, 11200, 15497, 19595, 23948, 27408, 30938, 32768, 0,
303-];
298+pub const EOB_PT_128_CHROMA_Q1: [u16; 9] =
299+ [8045, 11200, 15497, 19595, 23948, 27408, 30938, 32768, 0];
304300 /// [`EOB_PT_128_CHROMA`], q-context 3.
305-pub const EOB_PT_128_CHROMA_Q3: [u16; 9] = [
306- 24313, 26062, 28385, 30107, 31217, 31898, 32345, 32768, 0,
307-];
301+pub const EOB_PT_128_CHROMA_Q3: [u16; 9] =
302+ [24313, 26062, 28385, 30107, 31217, 31898, 32345, 32768, 0];
308303
309304 /// `av1_default_eob_multi128_cdfs[2][0][0]` (`token_cdfs.h:830-849`,
310305 /// lane-rectx): the end-of-block group of a LUMA transform with 128 coded
@@ -313,21 +308,13 @@ pub const EOB_PT_128_CHROMA_Q3: [u16; 9] = [
313308 /// 32x16/16x32), distinct from [`EOB_PT_256_LUMA`]'s 256-position group a
314309 /// *square* 16x16 reads. Read straight from the plane-0 half of the same
315310 /// `token_cdfs.h` table [`EOB_PT_128_CHROMA`] reads its plane-1 half from.
316-pub const EOB_PT_128_LUMA: [u16; 9] = [
317- 1366, 1738, 2527, 5016, 9355, 15797, 24643, 32768, 0,
318-];
311+pub const EOB_PT_128_LUMA: [u16; 9] = [1366, 1738, 2527, 5016, 9355, 15797, 24643, 32768, 0];
319312 /// [`EOB_PT_128_LUMA`], q-context 0.
320-pub const EOB_PT_128_LUMA_Q0: [u16; 9] = [
321- 219, 482, 1140, 2091, 3680, 6028, 12586, 32768, 0,
322-];
313+pub const EOB_PT_128_LUMA_Q0: [u16; 9] = [219, 482, 1140, 2091, 3680, 6028, 12586, 32768, 0];
323314 /// [`EOB_PT_128_LUMA`], q-context 1.
324-pub const EOB_PT_128_LUMA_Q1: [u16; 9] = [
325- 685, 933, 1488, 2714, 4766, 8562, 19254, 32768, 0,
326-];
315+pub const EOB_PT_128_LUMA_Q1: [u16; 9] = [685, 933, 1488, 2714, 4766, 8562, 19254, 32768, 0];
327316 /// [`EOB_PT_128_LUMA`], q-context 3.
328-pub const EOB_PT_128_LUMA_Q3: [u16; 9] = [
329- 3472, 4885, 7489, 12481, 18517, 24536, 29635, 32768, 0,
330-];
317+pub const EOB_PT_128_LUMA_Q3: [u16; 9] = [3472, 4885, 7489, 12481, 18517, 24536, 29635, 32768, 0];
331318
332319 /// `av1_default_eob_multi32_cdfs[2][1][0]` (`token_cdfs.h:792-808`,
333320 /// lane-rectx): the end-of-block group of a CHROMA transform with 32 coded
@@ -1824,20 +1811,20 @@ pub const WEDGE_IDX: [[u16; 17]; 22] = [
18241811 29629, 32768, 0,
18251812 ],
18261813 [
1827- 2779, 3738, 4683, 7213, 7775, 8017, 8655, 14357, 17939, 21332, 24520, 27470, 29456,
1828- 30529, 31656, 32768, 0,
1814+ 2779, 3738, 4683, 7213, 7775, 8017, 8655, 14357, 17939, 21332, 24520, 27470, 29456, 30529,
1815+ 31656, 32768, 0,
18291816 ],
18301817 [
18311818 1684, 3625, 5675, 7108, 9302, 11274, 14429, 17144, 19163, 20961, 22884, 24471, 26719,
18321819 28714, 30877, 32768, 0,
18331820 ],
18341821 [
1835- 1142, 3491, 6277, 7314, 8089, 8355, 9023, 13624, 15369, 16730, 18114, 19313, 22521,
1836- 26012, 29550, 32768, 0,
1822+ 1142, 3491, 6277, 7314, 8089, 8355, 9023, 13624, 15369, 16730, 18114, 19313, 22521, 26012,
1823+ 29550, 32768, 0,
18371824 ],
18381825 [
1839- 2742, 4195, 5727, 8035, 8980, 9336, 10146, 14124, 17270, 20533, 23434, 25972, 27944,
1840- 29570, 31416, 32768, 0,
1826+ 2742, 4195, 5727, 8035, 8980, 9336, 10146, 14124, 17270, 20533, 23434, 25972, 27944, 29570,
1827+ 31416, 32768, 0,
18411828 ],
18421829 [
18431830 1727, 3948, 6101, 7796, 9841, 12344, 15766, 18944, 20638, 22038, 23963, 25311, 26988,
@@ -1880,8 +1867,8 @@ pub const WEDGE_IDX: [[u16; 17]; 22] = [
18801867 30911, 32768, 0,
18811868 ],
18821869 [
1883- 1135, 1322, 1493, 2635, 2696, 2737, 2770, 21016, 22935, 25057, 27251, 29173, 30089,
1884- 30960, 31933, 32768, 0,
1870+ 1135, 1322, 1493, 2635, 2696, 2737, 2770, 21016, 22935, 25057, 27251, 29173, 30089, 30960,
1871+ 31933, 32768, 0,
18851872 ],
18861873 [
18871874 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528, 24576, 26624,
@@ -3179,6 +3166,19 @@ pub const TXB_SKIP_CHROMA_8_Q3: [[u16; 3]; 3] =
31793166 /// TXB_SKIP_CHROMA_16, q-context 3: the same table as [`TXB_SKIP_CHROMA_16`], for `base_q_idx` 121..=255.
31803167 pub const TXB_SKIP_CHROMA_16_Q3: [[u16; 3]; 3] =
31813168 [[3440, 32768, 0], [13117, 32768, 0], [22702, 32768, 0]];
3169+
3170+/// `av1_default_txb_skip_cdfs[q][TX_8X8][10..13]` (token_cdfs.h): the chroma
3171+/// `+10` rows of an 8x8 transform. libaom leaves every q-context at the
3172+/// neutral 16384 -- its own encoder never codes an 8x8 chroma transform under
3173+/// a larger plane block (4:2:0/4:4:4 always match plane to transform at this
3174+/// size) -- but `get_txb_ctx`'s `+10` arm reaches them the moment a 4:2:2
3175+/// frame's 16x16 luma block reads its plane's 8x16 half as two TX_8X8 units
3176+/// (lane-av1-422b; aomdec seeds and adapts the same neutral rows).
3177+pub const TXB_SKIP_CHROMA_8_BIG: [[u16; 3]; 3] = [[16384, 32768, 0]; 3];
3178+/// `av1_default_txb_skip_cdfs[q][TX_16X16][10..13]` (token_cdfs.h): the same
3179+/// neutral `+10` rows at 16x16 (libaom encoder-unreachable, 4:2:2-reachable
3180+/// through a 32x32 luma block's 16x32 plane -- lane-av1-422b).
3181+pub const TXB_SKIP_CHROMA_16_BIG: [[u16; 3]; 3] = [[16384, 32768, 0]; 3];
31823182 /// TXB_SKIP_CHROMA_32, q-context 3: the same table as [`TXB_SKIP_CHROMA_32`], for `base_q_idx` 121..=255.
31833183 pub const TXB_SKIP_CHROMA_32_Q3: [[u16; 3]; 3] =
31843184 [[4656, 32768, 0], [16074, 32768, 0], [24704, 32768, 0]];
@@ -3188,13 +3188,17 @@ pub const TXB_SKIP_CHROMA_32_Q3: [[u16; 3]; 3] =
31883188 /// LARGER than the transform (`get_txb_ctx`), which in AV1 happens only for a
31893189 /// 128x128 block's four TX_32X32 chroma units -- the offset-7 rows above are
31903190 /// every other case (lane-sb128b r3).
3191-pub const TXB_SKIP_CHROMA_32_BIG_Q0: [[u16; 3]; 3] = [[146, 32768, 0], [5132, 32768, 0], [31657, 32768, 0]];
3191+pub const TXB_SKIP_CHROMA_32_BIG_Q0: [[u16; 3]; 3] =
3192+ [[146, 32768, 0], [5132, 32768, 0], [31657, 32768, 0]];
31923193 /// Default CDF table `TXB_SKIP_CHROMA_32_BIG_Q1` (AV1 spec 9.4 initial probabilities).
3193-pub const TXB_SKIP_CHROMA_32_BIG_Q1: [[u16; 3]; 3] = [[641, 32768, 0], [22265, 32768, 0], [31452, 32768, 0]];
3194+pub const TXB_SKIP_CHROMA_32_BIG_Q1: [[u16; 3]; 3] =
3195+ [[641, 32768, 0], [22265, 32768, 0], [31452, 32768, 0]];
31943196 /// Default CDF table `TXB_SKIP_CHROMA_32_BIG` (AV1 spec 9.4 initial probabilities).
3195-pub const TXB_SKIP_CHROMA_32_BIG: [[u16; 3]; 3] = [[3082, 32768, 0], [20982, 32768, 0], [29443, 32768, 0]];
3197+pub const TXB_SKIP_CHROMA_32_BIG: [[u16; 3]; 3] =
3198+ [[3082, 32768, 0], [20982, 32768, 0], [29443, 32768, 0]];
31963199 /// Default CDF table `TXB_SKIP_CHROMA_32_BIG_Q3` (AV1 spec 9.4 initial probabilities).
3197-pub const TXB_SKIP_CHROMA_32_BIG_Q3: [[u16; 3]; 3] = [[1806, 32768, 0], [14645, 32768, 0], [25336, 32768, 0]];
3200+pub const TXB_SKIP_CHROMA_32_BIG_Q3: [[u16; 3]; 3] =
3201+ [[1806, 32768, 0], [14645, 32768, 0], [25336, 32768, 0]];
31983202 /// EOB_EXTRA_LUMA_16, q-context 3: the same table as [`EOB_EXTRA_LUMA_16`], for `base_q_idx` 121..=255.
31993203 pub const EOB_EXTRA_LUMA_16_Q3: [[u16; 3]; 9] = [
32003204 [19941, 32768, 0],
@@ -5374,27 +5378,28 @@ pub const EOB_PT_256_LUMA_CLASS1_Q3: [u16; 10] =
53745378 [2453, 4474, 6307, 8777, 16474, 22975, 29000, 31547, 32768, 0];
53755379
53765380 /// Default CDF table `EOB_PT_256_CHROMA_CLASS1_Q0` (AV1 spec 9.4 initial probabilities).
5377-pub const EOB_PT_256_CHROMA_CLASS1_Q0: [u16; 10] =
5378- [2203, 4130, 7435, 10739, 20652, 23681, 25609, 27261, 32768, 0];
5381+pub const EOB_PT_256_CHROMA_CLASS1_Q0: [u16; 10] = [
5382+ 2203, 4130, 7435, 10739, 20652, 23681, 25609, 27261, 32768, 0,
5383+];
53795384 /// Default CDF table `EOB_PT_256_CHROMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).
5380-pub const EOB_PT_256_CHROMA_CLASS1_Q1: [u16; 10] =
5381- [1674, 3252, 5734, 10159, 22397, 23802, 24821, 30940, 32768, 0];
5385+pub const EOB_PT_256_CHROMA_CLASS1_Q1: [u16; 10] = [
5386+ 1674, 3252, 5734, 10159, 22397, 23802, 24821, 30940, 32768, 0,
5387+];
53825388 /// Default CDF table `EOB_PT_256_CHROMA_CLASS1` (AV1 spec 9.4 initial probabilities).
5383-pub const EOB_PT_256_CHROMA_CLASS1: [u16; 10] =
5384- [6571, 9610, 15516, 21826, 29092, 30829, 31842, 32708, 32768, 0];
5389+pub const EOB_PT_256_CHROMA_CLASS1: [u16; 10] = [
5390+ 6571, 9610, 15516, 21826, 29092, 30829, 31842, 32708, 32768, 0,
5391+];
53855392 /// Default CDF table `EOB_PT_256_CHROMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).
5386-pub const EOB_PT_256_CHROMA_CLASS1_Q3: [u16; 10] =
5387- [9998, 17661, 25178, 28097, 31308, 32038, 32403, 32695, 32768, 0];
5393+pub const EOB_PT_256_CHROMA_CLASS1_Q3: [u16; 10] = [
5394+ 9998, 17661, 25178, 28097, 31308, 32038, 32403, 32695, 32768, 0,
5395+];
53885396
53895397 /// Default CDF table `EOB_PT_64_CHROMA_CLASS1_Q0` (AV1 spec 9.4 initial probabilities).
5390-pub const EOB_PT_64_CHROMA_CLASS1_Q0: [u16; 8] =
5391- [1563, 2700, 4876, 10911, 14706, 22480, 32768, 0];
5398+pub const EOB_PT_64_CHROMA_CLASS1_Q0: [u16; 8] = [1563, 2700, 4876, 10911, 14706, 22480, 32768, 0];
53925399 /// Default CDF table `EOB_PT_64_CHROMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).
5393-pub const EOB_PT_64_CHROMA_CLASS1_Q1: [u16; 8] =
5394- [1923, 3127, 5867, 9703, 14277, 27100, 32768, 0];
5400+pub const EOB_PT_64_CHROMA_CLASS1_Q1: [u16; 8] = [1923, 3127, 5867, 9703, 14277, 27100, 32768, 0];
53955401 /// Default CDF table `EOB_PT_64_CHROMA_CLASS1` (AV1 spec 9.4 initial probabilities).
5396-pub const EOB_PT_64_CHROMA_CLASS1: [u16; 8] =
5397- [4034, 6290, 10235, 14982, 21214, 28491, 32768, 0];
5402+pub const EOB_PT_64_CHROMA_CLASS1: [u16; 8] = [4034, 6290, 10235, 14982, 21214, 28491, 32768, 0];
53985403 /// Default CDF table `EOB_PT_64_CHROMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).
53995404 pub const EOB_PT_64_CHROMA_CLASS1_Q3: [u16; 8] =
54005405 [8726, 12378, 19409, 26450, 30038, 32462, 32768, 0];
@@ -5411,13 +5416,15 @@ pub const EOB_PT_16_CHROMA_CLASS1_Q3: [u16; 6] = [7297, 10767, 19273, 28194, 327
54115416 /// `EOB_PT_128_LUMA`'s class-1 sibling (`av1_default_eob_multi128_cdfs[q][0][1]`),
54125417 /// read by a 16x8/8x16 luma transform whose inherited `tx_type` is 1D
54135418 /// (`TxbSet::LumaRect16x8`) -- machine-extracted, scripts/extract-eob-class1.py.
5414-pub const EOB_PT_128_LUMA_CLASS1_Q0: [u16; 9] = [371, 699, 1254, 4830, 9479, 12562, 17497, 32768, 0];
5419+pub const EOB_PT_128_LUMA_CLASS1_Q0: [u16; 9] =
5420+ [371, 699, 1254, 4830, 9479, 12562, 17497, 32768, 0];
54155421 /// Default CDF table `EOB_PT_128_LUMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).
54165422 pub const EOB_PT_128_LUMA_CLASS1_Q1: [u16; 9] = [217, 352, 618, 2303, 5261, 9969, 17472, 32768, 0];
54175423 /// Default CDF table `EOB_PT_128_LUMA_CLASS1` (AV1 spec 9.4 initial probabilities).
54185424 pub const EOB_PT_128_LUMA_CLASS1: [u16; 9] = [354, 558, 944, 2760, 7287, 14037, 21779, 32768, 0];
54195425 /// Default CDF table `EOB_PT_128_LUMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).
5420-pub const EOB_PT_128_LUMA_CLASS1_Q3: [u16; 9] = [886, 1731, 3271, 8469, 15569, 22126, 28383, 32768, 0];
5426+pub const EOB_PT_128_LUMA_CLASS1_Q3: [u16; 9] =
5427+ [886, 1731, 3271, 8469, 15569, 22126, 28383, 32768, 0];
54215428
54225429 /// `EOB_PT_32_CHROMA`'s class-1 sibling (`av1_default_eob_multi32_cdfs[q][1][1]`),
54235430 /// read by an 8x4/4x8 chroma transform under a 1D luma `tx_type`
@@ -5431,47 +5438,82 @@ pub const EOB_PT_32_CHROMA_CLASS1: [u16; 7] = [3542, 5502, 10415, 16760, 25644,
54315438 pub const EOB_PT_32_CHROMA_CLASS1_Q3: [u16; 7] = [7699, 10897, 20891, 26926, 31628, 32768, 0];
54325439
54335440 /// `EOB_PT_128_CHROMA`'s class-1 sibling (`av1_default_eob_multi128_cdfs[q][1][1]`).
5434-pub const EOB_PT_128_CHROMA_CLASS1_Q0: [u16; 9] = [2054, 3472, 5869, 14232, 18242, 20590, 26752, 32768, 0];
5441+pub const EOB_PT_128_CHROMA_CLASS1_Q0: [u16; 9] =
5442+ [2054, 3472, 5869, 14232, 18242, 20590, 26752, 32768, 0];
54355443 /// Default CDF table `EOB_PT_128_CHROMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).
5436-pub const EOB_PT_128_CHROMA_CLASS1_Q1: [u16; 9] = [2310, 4160, 7471, 14997, 17931, 20768, 30240, 32768, 0];
5444+pub const EOB_PT_128_CHROMA_CLASS1_Q1: [u16; 9] =
5445+ [2310, 4160, 7471, 14997, 17931, 20768, 30240, 32768, 0];
54375446 /// Default CDF table `EOB_PT_128_CHROMA_CLASS1` (AV1 spec 9.4 initial probabilities).
5438-pub const EOB_PT_128_CHROMA_CLASS1: [u16; 9] = [6275, 9889, 14769, 23164, 27988, 30493, 32272, 32768, 0];
5447+pub const EOB_PT_128_CHROMA_CLASS1: [u16; 9] =
5448+ [6275, 9889, 14769, 23164, 27988, 30493, 32272, 32768, 0];
54395449 /// Default CDF table `EOB_PT_128_CHROMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).
5440-pub const EOB_PT_128_CHROMA_CLASS1_Q3: [u16; 9] = [9165, 13282, 21150, 30286, 31894, 32571, 32712, 32768, 0];
5450+pub const EOB_PT_128_CHROMA_CLASS1_Q3: [u16; 9] =
5451+ [9165, 13282, 21150, 30286, 31894, 32571, 32712, 32768, 0];
54415452
54425453 /// `EOB_PT_512_LUMA`'s class-1 sibling (`av1_default_eob_multi512_cdfs[q][0][1]`).
5443-pub const EOB_PT_512_LUMA_CLASS1_Q0: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0];
5454+pub const EOB_PT_512_LUMA_CLASS1_Q0: [u16; 11] = [
5455+ 3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0,
5456+];
54445457 /// Default CDF table `EOB_PT_512_LUMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).
5445-pub const EOB_PT_512_LUMA_CLASS1_Q1: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0];
5458+pub const EOB_PT_512_LUMA_CLASS1_Q1: [u16; 11] = [
5459+ 3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0,
5460+];
54465461 /// Default CDF table `EOB_PT_512_LUMA_CLASS1` (AV1 spec 9.4 initial probabilities).
5447-pub const EOB_PT_512_LUMA_CLASS1: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0];
5462+pub const EOB_PT_512_LUMA_CLASS1: [u16; 11] = [
5463+ 3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0,
5464+];
54485465 /// Default CDF table `EOB_PT_512_LUMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).
5449-pub const EOB_PT_512_LUMA_CLASS1_Q3: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0];
5466+pub const EOB_PT_512_LUMA_CLASS1_Q3: [u16; 11] = [
5467+ 3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0,
5468+];
54505469
54515470 /// `EOB_PT_512_CHROMA`'s class-1 sibling (`av1_default_eob_multi512_cdfs[q][1][1]`).
5452-pub const EOB_PT_512_CHROMA_CLASS1_Q0: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0];
5471+pub const EOB_PT_512_CHROMA_CLASS1_Q0: [u16; 11] = [
5472+ 3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0,
5473+];
54535474 /// Default CDF table `EOB_PT_512_CHROMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).
5454-pub const EOB_PT_512_CHROMA_CLASS1_Q1: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0];
5475+pub const EOB_PT_512_CHROMA_CLASS1_Q1: [u16; 11] = [
5476+ 3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0,
5477+];
54555478 /// Default CDF table `EOB_PT_512_CHROMA_CLASS1` (AV1 spec 9.4 initial probabilities).
5456-pub const EOB_PT_512_CHROMA_CLASS1: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0];
5479+pub const EOB_PT_512_CHROMA_CLASS1: [u16; 11] = [
5480+ 3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0,
5481+];
54575482 /// Default CDF table `EOB_PT_512_CHROMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).
5458-pub const EOB_PT_512_CHROMA_CLASS1_Q3: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0];
5483+pub const EOB_PT_512_CHROMA_CLASS1_Q3: [u16; 11] = [
5484+ 3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0,
5485+];
54595486
54605487 /// `EOB_PT_1024_LUMA`'s class-1 sibling (`av1_default_eob_multi1024_cdfs[q][0][1]`).
5461-pub const EOB_PT_1024_LUMA_CLASS1_Q0: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0];
5488+pub const EOB_PT_1024_LUMA_CLASS1_Q0: [u16; 12] = [
5489+ 2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0,
5490+];
54625491 /// Default CDF table `EOB_PT_1024_LUMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).
5463-pub const EOB_PT_1024_LUMA_CLASS1_Q1: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0];
5492+pub const EOB_PT_1024_LUMA_CLASS1_Q1: [u16; 12] = [
5493+ 2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0,
5494+];
54645495 /// Default CDF table `EOB_PT_1024_LUMA_CLASS1` (AV1 spec 9.4 initial probabilities).
5465-pub const EOB_PT_1024_LUMA_CLASS1: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0];
5496+pub const EOB_PT_1024_LUMA_CLASS1: [u16; 12] = [
5497+ 2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0,
5498+];
54665499 /// Default CDF table `EOB_PT_1024_LUMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).
5467-pub const EOB_PT_1024_LUMA_CLASS1_Q3: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0];
5500+pub const EOB_PT_1024_LUMA_CLASS1_Q3: [u16; 12] = [
5501+ 2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0,
5502+];
54685503
54695504 /// `EOB_PT_1024_CHROMA`'s class-1 sibling (`av1_default_eob_multi1024_cdfs[q][1][1]`).
5470-pub const EOB_PT_1024_CHROMA_CLASS1_Q0: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0];
5505+pub const EOB_PT_1024_CHROMA_CLASS1_Q0: [u16; 12] = [
5506+ 2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0,
5507+];
54715508 /// Default CDF table `EOB_PT_1024_CHROMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).
5472-pub const EOB_PT_1024_CHROMA_CLASS1_Q1: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0];
5509+pub const EOB_PT_1024_CHROMA_CLASS1_Q1: [u16; 12] = [
5510+ 2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0,
5511+];
54735512 /// Default CDF table `EOB_PT_1024_CHROMA_CLASS1` (AV1 spec 9.4 initial probabilities).
5474-pub const EOB_PT_1024_CHROMA_CLASS1: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0];
5513+pub const EOB_PT_1024_CHROMA_CLASS1: [u16; 12] = [
5514+ 2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0,
5515+];
54755516 /// Default CDF table `EOB_PT_1024_CHROMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).
5476-pub const EOB_PT_1024_CHROMA_CLASS1_Q3: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0];
5477-
5517+pub const EOB_PT_1024_CHROMA_CLASS1_Q3: [u16; 12] = [
5518+ 2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0,
5519+];
crates/ec-av1/src/cdf_state.rsmodified+45 -19
@@ -400,7 +400,7 @@ pub(crate) struct Cdfs {
400400 /// The same, for a 4x4 luma transform (lane-av1tx4).
401401 pub txb_skip_luma_4: [[u16; 3]; 7],
402402 /// The all-zero flag of an 8x8 chroma transform.
403- pub txb_skip_chroma_8: [[u16; 3]; 3],
403+ pub txb_skip_chroma_8: [[u16; 3]; 6],
404404 /// The all-zero flag of a 4x4 chroma transform.
405405 /// lane-lossless: SIX rows, like [`Self::txb_skip_chroma_32`] -- the last
406406 /// three are `get_txb_ctx`'s `+10` rows (chroma plane block bigger than
@@ -500,7 +500,7 @@ pub(crate) struct Cdfs {
500500 /// The same, for a 64x64 luma transform.
501501 pub txb_skip_luma_64: [[u16; 3]; 7],
502502 /// The all-zero flag of a 16x16 chroma transform.
503- pub txb_skip_chroma_16: [[u16; 3]; 3],
503+ pub txb_skip_chroma_16: [[u16; 3]; 6],
504504 /// The all-zero flag of a 32x32 chroma transform.
505505 /// SIX contexts, not three: rows 0..3 are libaom's `txb_skip_ctx` 7..9
506506 /// (chroma transform == its plane block) and rows 3..6 its 10..12 (plane
@@ -828,9 +828,7 @@ fn reset3<const N: usize, const M: usize, const K: usize>(a: &mut [[[u16; N]; M]
828828 /// [`reset3`] for a table whose ALPHABET grows with its first index: the
829829 /// palette colour-index CDFs are `[u16; 9]` rows read as `[..=n]` with
830830 /// `n = idx + 2`, so their symbol counter sits at index `n`, not `N - 1`.
831-fn reset_var_alphabet<const N: usize, const M: usize, const K: usize>(
832- a: &mut [[[u16; N]; M]; K],
833-) {
831+fn reset_var_alphabet<const N: usize, const M: usize, const K: usize>(a: &mut [[[u16; N]; M]; K]) {
834832 for (idx, rows) in a.iter_mut().enumerate() {
835833 for row in rows.iter_mut() {
836834 row[idx + 2] = 0;
@@ -1067,13 +1065,27 @@ impl Cdfs {
10671065 cdf::TXB_SKIP_LUMA_4_CTX,
10681066 cdf::TXB_SKIP_LUMA_4_Q3_CTX,
10691067 ),
1070- txb_skip_chroma_8: pick(
1071- q_ctx,
1072- cdf::TXB_SKIP_CHROMA_8_Q0,
1073- cdf::TXB_SKIP_CHROMA_8_Q1,
1074- cdf::TXB_SKIP_CHROMA_8,
1075- cdf::TXB_SKIP_CHROMA_8_Q3,
1076- ),
1068+ txb_skip_chroma_8: {
1069+ // lane-av1-422b: rows 3..6 are the `+10` chroma rows
1070+ // (`TXB_SKIP_CHROMA_8_BIG`) -- neutral in libaom's defaults,
1071+ // reached only when the plane block is larger than an 8x8
1072+ // transform, i.e. only at 4:2:2 today.
1073+ let small = pick(
1074+ q_ctx,
1075+ cdf::TXB_SKIP_CHROMA_8_Q0,
1076+ cdf::TXB_SKIP_CHROMA_8_Q1,
1077+ cdf::TXB_SKIP_CHROMA_8,
1078+ cdf::TXB_SKIP_CHROMA_8_Q3,
1079+ );
1080+ [
1081+ small[0],
1082+ small[1],
1083+ small[2],
1084+ cdf::TXB_SKIP_CHROMA_8_BIG[0],
1085+ cdf::TXB_SKIP_CHROMA_8_BIG[1],
1086+ cdf::TXB_SKIP_CHROMA_8_BIG[2],
1087+ ]
1088+ },
10771089 txb_skip_chroma_4: {
10781090 let small = pick(
10791091 q_ctx,
@@ -1387,13 +1399,27 @@ impl Cdfs {
13871399 cdf::TXB_SKIP_LUMA_64_CTX,
13881400 cdf::TXB_SKIP_LUMA_64_Q3_CTX,
13891401 ),
1390- txb_skip_chroma_16: pick(
1391- q_ctx,
1392- cdf::TXB_SKIP_CHROMA_16_Q0,
1393- cdf::TXB_SKIP_CHROMA_16_Q1,
1394- cdf::TXB_SKIP_CHROMA_16,
1395- cdf::TXB_SKIP_CHROMA_16_Q3,
1396- ),
1402+ txb_skip_chroma_16: {
1403+ // lane-av1-422b: rows 3..6 are the `+10` chroma rows
1404+ // (`TXB_SKIP_CHROMA_16_BIG`) -- neutral in libaom's defaults,
1405+ // reached only when the plane block is larger than a 16x16
1406+ // transform, i.e. only at 4:2:2 today.
1407+ let small = pick(
1408+ q_ctx,
1409+ cdf::TXB_SKIP_CHROMA_16_Q0,
1410+ cdf::TXB_SKIP_CHROMA_16_Q1,
1411+ cdf::TXB_SKIP_CHROMA_16,
1412+ cdf::TXB_SKIP_CHROMA_16_Q3,
1413+ );
1414+ [
1415+ small[0],
1416+ small[1],
1417+ small[2],
1418+ cdf::TXB_SKIP_CHROMA_16_BIG[0],
1419+ cdf::TXB_SKIP_CHROMA_16_BIG[1],
1420+ cdf::TXB_SKIP_CHROMA_16_BIG[2],
1421+ ]
1422+ },
13971423 txb_skip_chroma_32: {
13981424 let small = pick(
13991425 q_ctx,
crates/ec-av1/src/decode.rsmodified+157 -53
@@ -1509,6 +1509,36 @@ fn tu_reach(
15091509 fixed
15101510 }
15111511
1512+/// [`tu_reach`] for a unit whose LUMA footprint is a `tx_w` x `tx_h` rect
1513+/// (lane-av1-422b: a 4:2:2 chroma unit is square in chroma pixels, but its
1514+/// luma anchor is `(chroma_tx << ss_x, chroma_tx << ss_y)` -- at ss (1,0)
1515+/// twice as wide as it is tall). Same predicate as [`tu_reach`]; the
1516+/// square mismatch counter only means anything when the footprint actually
1517+/// is square.
1518+#[allow(clippy::too_many_arguments)]
1519+fn tu_reach_rect(
1520+ bw: usize,
1521+ bh: usize,
1522+ col_off: usize,
1523+ row_off: usize,
1524+ tx_w: usize,
1525+ tx_h: usize,
1526+ block: Reach,
1527+ px: usize,
1528+ py: usize,
1529+ width: usize,
1530+ height: usize, fctx: &crate::decode::FrameCtx,
1531+) -> Reach {
1532+ let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx_w, tx_h, block);
1533+ if tx_w == tx_h {
1534+ let standalone = Reach::of(tx_w, px + col_off, py + row_off, width, height, fctx);
1535+ if fixed != standalone {
1536+ hit!(SPLIT_TU_REACH_FIX_HITS);
1537+ }
1538+ }
1539+ fixed
1540+}
1541+
15121542 // How many `uv_mode` reads resolved to `SMOOTH_PRED..=PAETH_PRED` (9..=12),
15131543 // across every call on the current thread -- lane-chroma r3's own before/after
15141544 // counter, proving a stream actually exercised chroma's smooth/paeth
@@ -2002,8 +2032,9 @@ thread_local! {
20022032 }
20032033
20042034 /// Current value of [`CHROMA422_SQUARE_HITS`].
2005-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
2006-pub(crate) fn chroma422_square_hits() -> usize {
2035+// lane-av1-422b: `pub` so `examples/decode_probe.rs` can census it the way
2036+// it does every other capability counter.
2037+pub fn chroma422_square_hits() -> usize {
20072038 CHROMA422_SQUARE_HITS.with(|c| c.get())
20082039 }
20092040
@@ -16648,6 +16679,24 @@ fn decode_block(
1664816679 _ => (TxbSet::Chroma4, scan4),
1664916680 };
1665016681 (luma_set, set, luma_tx, tx, (scans.0, scan))
16682+ } else if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
16683+ // lane-av1-422b: the uv plane block is (side/2, side)
16684+ // (`ss_size_lookup[..][1][0]`), so `av1_get_max_uv_txsize` is the
16685+ // SQUARE transform of the smaller dimension, capped at TX_32X32
16686+ // (`av1_get_adjusted_tx_size` only ever shrinks): 4 -> TX_4X4 (the
16687+ // 2x4 plane rounds up to BLOCK_4X4), 8 -> TX_4X4 (BLOCK_4X8),
16688+ // 16 -> TX_8X8 (BLOCK_8X16), 32 -> TX_16X16, 64 -> TX_32X32
16689+ // (BLOCK_32X64), 128 -> TX_32X32 (BLOCK_64X128 adjusts TX_64X64
16690+ // down). The units stay square; the UNIT GRID is (side/2)/tx wide
16691+ // by side/tx tall -- never square above a 4x4 luma block.
16692+ let tx = if side >= 64 { 32 } else { (side / 2).max(4) };
16693+ let (set, scan): (TxbSet, &[u16]) = match tx {
16694+ 32 => (TxbSet::Chroma32, scan32),
16695+ 16 => (TxbSet::Chroma16, scan16),
16696+ 8 => (TxbSet::Chroma8, scan8),
16697+ _ => (TxbSet::Chroma4, scan4),
16698+ };
16699+ (luma_set, set, luma_tx, tx, (scans.0, scan))
1665116700 } else {
1665216701 (luma_set, chroma_set, luma_tx, chroma_tx, scans)
1665316702 };
@@ -16773,6 +16822,9 @@ fn decode_block(
1677316822 let reach = Reach::of(side, px, py, y.width, y.height, fctx);
1677416823 let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx));
1677516824 let chroma_side = side >> ss_x(fctx);
16825+ // lane-av1-422b: chroma extent per axis, `side` at ss_y 0 (4:2:2/4:4:4),
16826+ // `side / 2` at 4:2:0.
16827+ let chroma_height = side >> ss_y(fctx);
1677616828 // spec 7.11.3.4 with `use_intrabc`: the reference is the *current*
1677716829 // frame's own pre-loop-filter reconstruction (all loop filters are off
1677816830 // whenever `allow_intrabc`, frame.rs:194/210/252/272) at the full-pel
@@ -16787,17 +16839,17 @@ fn decode_block(
1678716839 mv_to_q4(px, dv_col, 0), mv_to_q4(py, dv_row, 0),
1678816840 side, side, mc::InterpFilterKind::Bilinear, &mut yb, fctx,
1678916841 );
16790- let mut ub = vec![0u16; chroma_side * chroma_side];
16842+ let mut ub = vec![0u16; chroma_side * chroma_height];
1679116843 mc::predict_with_filter(
1679216844 &u.data, u.width, u.true_width, u.true_height,
1679316845 mv_to_q4(cpx, dv_col, ss_x(fctx)), mv_to_q4(cpy, dv_row, ss_y(fctx)),
16794- chroma_side, chroma_side, mc::InterpFilterKind::Bilinear, &mut ub, fctx,
16846+ chroma_side, chroma_height, mc::InterpFilterKind::Bilinear, &mut ub, fctx,
1679516847 );
16796- let mut vb = vec![0u16; chroma_side * chroma_side];
16848+ let mut vb = vec![0u16; chroma_side * chroma_height];
1679716849 mc::predict_with_filter(
1679816850 &v.data, v.width, v.true_width, v.true_height,
1679916851 mv_to_q4(cpx, dv_col, ss_x(fctx)), mv_to_q4(cpy, dv_row, ss_y(fctx)),
16800- chroma_side, chroma_side, mc::InterpFilterKind::Bilinear, &mut vb, fctx,
16852+ chroma_side, chroma_height, mc::InterpFilterKind::Bilinear, &mut vb, fctx,
1680116853 );
1680216854 (yb, ub, vb)
1680316855 });
@@ -16942,16 +16994,23 @@ fn decode_block(
1694216994 );
1694316995 }
1694416996 let ac = alpha.map(|_| cfl_src(px, py, side));
16945- let cn = (chroma_side / chroma_tx).max(1);
16946- for cu_row in 0..cn {
16947- for cu_col in 0..cn {
16948- let luma_span = chroma_tx << ss_x(fctx);
16949- let cu_r = if cn == 1 {
16997+ // lane-av1-422b: the chroma unit grid is `cn_cols` x `cn_rows` --
16998+ // square at 4:2:0/4:4:4, at 4:2:2 `(side/2)/tx` units wide by
16999+ // `side/tx` tall (the plane block is (side/2, side)). A unit's LUMA
17000+ // anchor follows the per-axis shifts: `chroma_tx << ss_x` wide,
17001+ // `chroma_tx << ss_y` tall.
17002+ let cn_cols = (chroma_side / chroma_tx).max(1);
17003+ let cn_rows = (chroma_height / chroma_tx).max(1);
17004+ let luma_span_x = chroma_tx << ss_x(fctx);
17005+ let luma_span_y = chroma_tx << ss_y(fctx);
17006+ for cu_row in 0..cn_rows {
17007+ for cu_col in 0..cn_cols {
17008+ let cu_r = if cn_rows == 1 && cn_cols == 1 {
1695017009 reach
1695117010 } else {
16952- tu_reach(
17011+ tu_reach_rect(
1695317012 side, side,
16954- cu_col * luma_span, cu_row * luma_span, luma_span,
17013+ cu_col * luma_span_x, cu_row * luma_span_y, luma_span_x, luma_span_y,
1695517014 reach, px, py, y.width, y.height, fctx,
1695617015 )
1695717016 };
@@ -17037,8 +17096,13 @@ fn decode_block(
1703717096 // TX_32X32, so a 64x64 block codes four chroma units, plane-major
1703817097 // (every U, then every V) — the same loop the multi-TU arm runs.
1703917098 // At 4:2:0 `chroma_side == chroma_tx`, so it stays one read.
17040- let cn = (chroma_side / chroma_tx).max(1);
17041- let (u_grid, v_grid, chroma_units) = if cn == 1 {
17099+ // lane-av1-422b: 4:2:2 never collapses to one read above a 4x4 luma
17100+ // block -- the unit grid is `(side/2)/tx` wide by `side/tx` tall.
17101+ let cn_cols = (chroma_side / chroma_tx).max(1);
17102+ let cn_rows = (chroma_height / chroma_tx).max(1);
17103+ let luma_span_x = chroma_tx << ss_x(fctx);
17104+ let luma_span_y = chroma_tx << ss_y(fctx);
17105+ let (u_grid, v_grid, chroma_units) = if cn_rows == 1 && cn_cols == 1 {
1704217106 if let Some((ub, _)) = &palette_uv_bufs {
1704317107 set_palette_pred(ub.clone(), fctx);
1704417108 }
@@ -17099,24 +17163,25 @@ fn decode_block(
1709917163 } else {
1710017164 let chroma_ctx_offset = Some(3);
1710117165 let mut u_pass: Vec<Grid> = Vec::new();
17102- let mut units: Vec<((usize, usize), usize, Grid, Grid)> = Vec::new();
17166+ let mut units: Vec<((usize, usize), usize, usize, Grid, Grid)> = Vec::new();
1710317167 let mut last_grids = [Grid::Zero(0), Grid::Zero(0)];
1710417168 for plane_pass in 1..=2usize {
1710517169 let mut pass_idx = 0usize;
17106- for cu_row in 0..cn {
17107- for cu_col in 0..cn {
17108- let luma_span = chroma_tx << ss_x(fctx);
17170+ for cu_row in 0..cn_rows {
17171+ for cu_col in 0..cn_cols {
1710917172 let cu_mi = (
17110- mi_r + cu_row * (luma_span / MI),
17111- mi_c + cu_col * (luma_span / MI),
17173+ mi_r + cu_row * (luma_span_y / MI),
17174+ mi_c + cu_col * (luma_span_x / MI),
1711217175 );
17113- let cu_around = neighbours.around_mi(cu_mi, luma_span);
17114- let cu_reach = tu_reach(
17176+ let cu_around =
17177+ neighbours.around_mi_rect(cu_mi, luma_span_x, luma_span_y);
17178+ let cu_reach = tu_reach_rect(
1711517179 side,
1711617180 side,
17117- cu_col * luma_span,
17118- cu_row * luma_span,
17119- luma_span,
17181+ cu_col * luma_span_x,
17182+ cu_row * luma_span_y,
17183+ luma_span_x,
17184+ luma_span_y,
1712017185 reach,
1712117186 px,
1712217187 py,
@@ -17146,16 +17211,21 @@ fn decode_block(
1714617211 None, chroma_ctx_offset, smooth_neighbor_uv, fctx,
1714717212 )?;
1714817213 hit!(CHROMA_SPLIT_TX_HITS);
17214+ if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
17215+ hit!(CHROMA422_SQUARE_HITS);
17216+ }
1714917217 // Immediately, so the next unit of this block reads this
1715017218 // one's coefficient context. `record` below stamps one
1715117219 // chroma state across the whole block; the replay after
1715217220 // it puts the per-unit state back.
17153- neighbours.record_mi_chroma(cu_mi, luma_span, luma_span, plane_pass, &cu_grid);
17221+ neighbours.record_mi_chroma(
17222+ cu_mi, luma_span_x, luma_span_y, plane_pass, &cu_grid,
17223+ );
1715417224 if plane_pass == 1 {
1715517225 u_pass.push(cu_grid);
1715617226 } else {
1715717227 let u_grid = std::mem::replace(&mut u_pass[pass_idx], Grid::Zero(0));
17158- units.push((cu_mi, luma_span, u_grid.clone(), cu_grid.clone()));
17228+ units.push((cu_mi, luma_span_x, luma_span_y, u_grid.clone(), cu_grid.clone()));
1715917229 last_grids = [u_grid, cu_grid];
1716017230 }
1716117231 pass_idx += 1;
@@ -17166,9 +17236,9 @@ fn decode_block(
1716617236 };
1716717237 fctx.intrabc_chroma_tx.with(|c| c.set(None));
1716817238 neighbours.record(at, side, mode, uv_predict_mode, &[&luma_grid[..], &u_grid[..], &v_grid[..]]);
17169- for (cu_mi, luma_span, u_unit, v_unit) in &chroma_units {
17170- neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 1, u_unit);
17171- neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 2, v_unit);
17239+ for (cu_mi, sw, sh, u_unit, v_unit) in &chroma_units {
17240+ neighbours.record_mi_chroma(*cu_mi, *sw, *sh, 1, u_unit);
17241+ neighbours.record_mi_chroma(*cu_mi, *sw, *sh, 2, v_unit);
1717217242 }
1717317243 } else {
1717417244 // Several luma transform units, raster order (spec
@@ -17178,7 +17248,10 @@ fn decode_block(
1717817248 // the earlier tiles in this same block already wrote -- the same
1717917249 // per-TU pattern [`decode_leaf8`] already runs for an 8x8 leaf.
1718017250 let n_axis = side / logical_tx;
17181- let cn = (chroma_side / chroma_tx).max(1);
17251+ let cn_cols = (chroma_side / chroma_tx).max(1);
17252+ let cn_rows = (chroma_height / chroma_tx).max(1);
17253+ let luma_span_x = chroma_tx << ss_x(fctx);
17254+ let luma_span_y = chroma_tx << ss_y(fctx);
1718217255 // libaom's transform-block loop is over 64x64 luma "mu" chunks
1718317256 // (`decode_token_recon_block`: `mu_blocks_wide/high` =
1718417257 // `mi_size_wide[BLOCK_64X64]`), and it codes EVERY PLANE of a chunk
@@ -17190,9 +17263,10 @@ fn decode_block(
1719017263 let nchunk = (side / 64).max(1);
1719117264 // `cn > 1` means the uv plane block is larger than the uv transform,
1719217265 // which moves libaom's chroma `txb_skip_ctx` offset from 7 to 10.
17193- let chroma_ctx_offset = if cn > 1 { Some(3) } else { None };
17266+ let chroma_ctx_offset = if cn_rows * cn_cols > 1 { Some(3) } else { None };
1719417267 let tpc = (n_axis / nchunk).max(1);
17195- let cpc = (cn / nchunk).max(1);
17268+ let cpc_rows = (cn_rows / nchunk).max(1);
17269+ let cpc_cols = (cn_cols / nchunk).max(1);
1719617270 // The block's luma transform units, raster order inside each mu
1719717271 // chunk. lane-av1-ibcvtx: an intrabc block's units are the var-tx
1719817272 // tree's own leaf list -- mixed sizes included, exactly what libaom's
@@ -17218,7 +17292,7 @@ fn decode_block(
1721817292 }
1721917293 }
1722017294 let mut last_grids = [Grid::Zero(0), Grid::Zero(0)];
17221- let mut units: Vec<((usize, usize), usize, Grid, Grid)> = Vec::new();
17295+ let mut units: Vec<((usize, usize), usize, usize, Grid, Grid)> = Vec::new();
1722217296 for ch_row in 0..nchunk {
1722317297 for ch_col in 0..nchunk {
1722417298 // lane-av1-ibcvtx: the chunk's chroma units inherit the CHROMA tx
@@ -17352,8 +17426,8 @@ fn decode_block(
1735217426 let mut u_pass: Vec<Grid> = Vec::new();
1735317427 for plane_pass in 1..=2usize {
1735417428 let mut pass_idx = 0usize;
17355- for cu_row in ch_row * cpc..(ch_row + 1) * cpc {
17356- for cu_col in ch_col * cpc..(ch_col + 1) * cpc {
17429+ for cu_row in ch_row * cpc_rows..(ch_row + 1) * cpc_rows {
17430+ for cu_col in ch_col * cpc_cols..(ch_col + 1) * cpc_cols {
1735717431 // libaom `decode_reconstruct_tx`'s frame-edge clip
1735817432 // (decodeframe.c:299, `blk_row >= max_blocks_high || blk_col
1735917433 // >= max_blocks_wide` returns before ANY symbol is read): a
@@ -17384,20 +17458,21 @@ fn decode_block(
1738417458 continue;
1738517459 }
1738617460 // The chroma context arrays are indexed in LUMA mi, so this
17387- // unit's anchor is its own luma quadrant: `chroma_tx` chroma
17388- // pixels span `2 * chroma_tx` luma ones.
17389- let luma_span = chroma_tx << ss_x(fctx);
17461+ // unit's anchor is its own luma quadrant (lane-av1-422b: the
17462+ // quadrant spans `chroma_tx << ss_x` luma px wide by
17463+ // `chroma_tx << ss_y` tall -- at 4:2:2 a rect twice as wide
17464+ // as it is tall).
1739017465 let cu_mi = (
17391- mi_r + cu_row * (luma_span / MI),
17392- mi_c + cu_col * (luma_span / MI),
17466+ mi_r + cu_row * (luma_span_y / MI),
17467+ mi_c + cu_col * (luma_span_x / MI),
1739317468 );
17394- let cu_around = neighbours.around_mi(cu_mi, luma_span);
17395- let cu_reach = if cn == 1 {
17469+ let cu_around = neighbours.around_mi_rect(cu_mi, luma_span_x, luma_span_y);
17470+ let cu_reach = if cn_rows == 1 && cn_cols == 1 {
1739617471 reach
1739717472 } else {
17398- tu_reach(
17473+ tu_reach_rect(
1739917474 side, side,
17400- cu_col * luma_span, cu_row * luma_span, luma_span,
17475+ cu_col * luma_span_x, cu_row * luma_span_y, luma_span_x, luma_span_y,
1740117476 reach, px, py, y.width, y.height, fctx,
1740217477 )
1740317478 };
@@ -17423,22 +17498,27 @@ fn decode_block(
1742317498 }),
1742417499 None, chroma_ctx_offset, smooth_neighbor_uv, fctx,
1742517500 )?;
17426- if cn > 1 {
17501+ if cn_rows * cn_cols > 1 {
1742717502 hit!(CHROMA_SPLIT_TX_HITS);
17503+ if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
17504+ hit!(CHROMA422_SQUARE_HITS);
17505+ }
1742817506 // Immediately, so the NEXT unit of this same block reads
1742917507 // this one's coefficient context (libaom's chroma
1743017508 // `txb_skip_ctx` for the second quadrant is 11, i.e. base
1743117509 // 1 from this left neighbour -- measured against aomdec).
1743217510 // The same writes are replayed after `record_split_luma`
1743317511 // below, which would otherwise clobber them whole-block.
17434- neighbours.record_mi_chroma(cu_mi, luma_span, luma_span, plane_pass, &cu_grid);
17512+ neighbours.record_mi_chroma(
17513+ cu_mi, luma_span_x, luma_span_y, plane_pass, &cu_grid,
17514+ );
1743517515 }
1743617516 if plane_pass == 1 {
1743717517 u_pass.push(cu_grid);
1743817518 } else {
1743917519 let u_grid = std::mem::replace(&mut u_pass[pass_idx], Grid::Zero(0));
17440- if cn > 1 {
17441- units.push((cu_mi, luma_span, u_grid.clone(), cu_grid.clone()));
17520+ if cn_rows * cn_cols > 1 {
17521+ units.push((cu_mi, luma_span_x, luma_span_y, u_grid.clone(), cu_grid.clone()));
1744217522 }
1744317523 last_grids = [u_grid, cu_grid];
1744417524 }
@@ -17455,9 +17535,9 @@ fn decode_block(
1745517535 // context write; at `cn > 1` the per-unit writes above are what the
1745617536 // next block reads, so they run after this (last writer wins).
1745717537 neighbours.record_split_luma(at, side, mode, uv_predict_mode, [&last_grids[0], &last_grids[1]]);
17458- for (cu_mi, luma_span, u_grid, v_grid) in &units {
17459- neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 1, u_grid);
17460- neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 2, v_grid);
17538+ for (cu_mi, sw, sh, u_grid, v_grid) in &units {
17539+ neighbours.record_mi_chroma(*cu_mi, *sw, *sh, 1, u_grid);
17540+ neighbours.record_mi_chroma(*cu_mi, *sw, *sh, 2, v_grid);
1746117541 }
1746217542 }
1746317543 // Unconditional, `size == 0` for a non-palette block: clears any stale
@@ -26319,7 +26399,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
2631926399 // mirroring [`crate::tile::sb_coeff_key_frame_tile`]'s own
2632026400 // three-way write exactly.
2632126401 let part = if has_cols && has_rows {
26402+ if crate::envflags::env_flag!("EC_TRACE") {
26403+ eprintln!("EC_PART mi_row={} mi_col={} bsize=12 ctx={} tell={} rng={}", sb_r * SB_MI, sb_c * SB_MI, ctx, dec.debug_bitpos(), dec.debug_state().0);
26404+ }
2632226405 let p = dec.symbol(&mut cdfs.partition_w64[ctx]);
26406+ if crate::envflags::env_flag!("EC_TRACE") {
26407+ eprintln!("EC_PART_VAL mi_row={} mi_col={} bsize=12 value={}", sb_r * SB_MI, sb_c * SB_MI, p);
26408+ }
2632326409 if crate::envflags::env_flag!("EC_AV1_TRACE") {
2632426410 eprintln!("TRACE partition_w64 ctx={ctx} value={p}");
2632526411 }
@@ -26395,7 +26481,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
2639526481 has_half(r32 * BLOCK_MI, BLOCK_MI, mi_rows),
2639626482 );
2639726483 let part32 = if has_cols32 && has_rows32 {
26484+ if crate::envflags::env_flag!("EC_TRACE") {
26485+ eprintln!("EC_PART mi_row={} mi_col={} bsize=9 ctx={} tell={} rng={}", r32 * BLOCK_MI, c32 * BLOCK_MI, ctx32, dec.debug_bitpos(), dec.debug_state().0);
26486+ }
2639826487 let p = dec.symbol(&mut cdfs.partition_w32[ctx32]);
26488+ if crate::envflags::env_flag!("EC_TRACE") {
26489+ eprintln!("EC_PART_VAL mi_row={} mi_col={} bsize=9 value={}", r32 * BLOCK_MI, c32 * BLOCK_MI, p);
26490+ }
2639926491 if crate::envflags::env_flag!("EC_AV1_TRACE") {
2640026492 let (rng, _) = dec.debug_state();
2640126493 eprintln!(
@@ -26481,7 +26573,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
2648126573 let at16 = (sr, sc);
2648226574 let ctx16 = neighbours.partition_ctx(at16, SUB);
2648326575 if has_cols16 && has_rows16 {
26576+ if crate::envflags::env_flag!("EC_TRACE") {
26577+ eprintln!("EC_PART mi_row={} mi_col={} bsize=6 ctx={} tell={} rng={}", at16.0, at16.1, ctx16, dec.debug_bitpos(), dec.debug_state().0);
26578+ }
2648426579 let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]);
26580+ if crate::envflags::env_flag!("EC_TRACE") {
26581+ eprintln!("EC_PART_VAL mi_row={} mi_col={} bsize=6 value={}", at16.0, at16.1, part16);
26582+ }
2648526583 if crate::envflags::env_flag!("EC_AV1_TRACE") {
2648626584 eprintln!(
2648726585 "TRACE partition_w16 mi=({},{}) ctx={ctx16} value={part16}",
@@ -26805,8 +26903,14 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
2680526903 }
2680626904 }
2680726905 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);
26906+ if crate::envflags::env_flag!("EC_TRACE") {
26907+ eprintln!("EC_PART mi_row={} mi_col={} bsize=3 ctx={} tell={} rng={}", leaf_mi.0, leaf_mi.1, leaf_ctx, dec.debug_bitpos(), dec.debug_state().0);
26908+ }
2680826909 let part8 =
2680926910 dec.symbol(&mut cdfs.partition_w8[leaf_ctx]);
26911+ if crate::envflags::env_flag!("EC_TRACE") {
26912+ eprintln!("EC_PART_VAL mi_row={} mi_col={} bsize=3 value={}", leaf_mi.0, leaf_mi.1, part8);
26913+ }
2681026914 if crate::envflags::env_flag!("EC_AV1_TRACE") {
2681126915 eprintln!(
2681226916 "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8}"
lanes/av1422b.report.mdadded+90 -0
@@ -0,0 +1,90 @@
1+# lane-av1-422b — decode_block square-chroma walk (4:2:2, refusal still up)
2+
3+## Outcome
4+
5+STOP with the refusal in place (`stream.rs` `subsampling_x != subsampling_y`,
6+byte-identical to main — restored before the commit; no bypass committed).
7+Not pixel-exact yet: the bypassed-refusal probe desyncs INSIDE the first
8+16x16 `PARTITION_HORZ_A` of frame 0, before `decode_block`'s own chroma walk
9+is ever reached. Next wrong site named below.
10+
11+## Landed (all keyed to reachability only at ss (1,0); 420/444 arms unchanged)
12+
13+1. `decode_block` tx-size arm: new 4:2:2 branch — the uv plane block is
14+ `(side/2, side)` (`ss_size_lookup[..][1][0]`), so
15+ `av1_get_max_uv_txsize` is the SQUARE transform of the smaller dimension
16+ capped at TX_32X32: 4→TX_4X4 (2x4 rounds to BLOCK_4X4), 8→TX_4X4,
17+ 16→TX_8X8, 32→TX_16X16, 64→TX_32X32, 128→TX_32X32 (BLOCK_64X128 adjusts
18+ TX_64X64 down). Units stay square; the unit GRID is `(side/2)/tx` wide by
19+ `side/tx` tall — never square above a 4x4 luma block.
20+2. All three chroma walks in `decode_block` (skip arm, single-luma-TU arm,
21+ multi-TU mu-chunk arm) generalized from square `cn x cn` to
22+ `cn_cols x cn_rows`; each unit's luma anchor split per axis
23+ (`chroma_tx << ss_x` wide, `chroma_tx << ss_y` tall): `around_mi_rect`,
24+ `tu_reach_rect` (new helper; keeps the square mismatch counter semantics),
25+ `record_mi_chroma(cu_mi, span_x, span_y, ...)`, units tuples widened to
26+ carry both spans.
27+3. intrabc chroma prediction buffers sized `chroma_side x chroma_height`.
28+4. `TxbSet::Chroma8`/`Chroma16` `txb_skip` tables widened to six rows:
29+ rows 3..6 are `av1_default_txb_skip_cdfs[q][TX_8X8/16X16][10..13]`
30+ (`get_txb_ctx`'s `+10` rows; neutral 16384 in libaom — its encoder never
31+ reaches them at 4:2:0/4:4:4, a 4:2:2 plane block larger than an 8x8/16x16
32+ transform does). Mirrors the existing `TXB_SKIP_CHROMA_4_BIG`/
33+ `CHROMA_32_BIG` assembly. Unused rows are never adapted, so 420/444 CDF
34+ adaptation is unchanged.
35+5. `chroma422_square_hits()` made `pub` and printed by `examples/decode_probe.rs`
36+ (like every other capability counter) for the witness gate later.
37+6. `EC_PART`/`EC_PART_VAL` traces behind `EC_TRACE` at the 64/32/16/8-level
38+ partition symbol reads, byte-format-matched to the oracle aomdec's own
39+ trace (same instrumented-oracle pairing the file already uses elsewhere).
40+
41+## Measurement (local bypass, NOT committed)
42+
43+Fixture: `ffmpeg testsrc2 256x144 yuv422p` → `aomenc --profile=2 --obu
44+-w 256 -h 144 --passes=1 --end-usage=q --cq-level=32 --cpu-used=3 --limit=16`
45+(sha256 d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129);
46+oracle `aomdec --rawvideo` (I422).
47+
48+- With the refusal bypassed, `decode_block`'s new arm runs and the pre-existing
49+ `txb_skip[3]` panic is gone (the widening in 4 fixes it).
50+- Desync localization via `EC_TRACE=1` partition pairing: every partition
51+ symbol pairs rng-for-rng with the oracle through the 64→32 split and the
52+ FIRST 16x16 (`(0,0)` value 4 = HORZ_A, rng 57096→45060→49312 identical).
53+ The oracle's NEXT 16-level read is `(0,4)` at tell 1079; ours is the second
54+ quadrant at tell 700 — the divergence is inside HORZ_A's own pieces:
55+ the two 8x8 leaves (`decode_leaf8`, whose chroma at 4:2:2 is 4x8 = two TX_4X4
56+ units per plane) and/or the 16x8 bottom strip (`decode_rect_split`'s
57+ `chroma_tiled` (8,8) arm — its `EC_RECTCHROMA_GAP luma=16x8 tx=8x8
58+ chroma=8x8` diagnostic fires right before the panic point).
59+
60+## The 8x32/32x64 leaf note, resolved against the oracle source
61+
62+`av1_ss_size_lookup[..][1][0]` (common_data.c:17): 16X4→8X4 VALID, 32X8→16X8
63+VALID, 64X16→32X16 VALID, but 4X16, 8X32, 16X64 (the TALL 1:4 shapes) are
64+BLOCK_INVALID at 4:2:2. libaom's ENCODER disables exactly those:
65+`partition_search.c` (`part4_search_allowed`) requires
66+`get_plane_block_size(subsize, ss_x, ss_y) != BLOCK_INVALID` before a HORZ_4/
67+VERT_4 may be coded. So aomenc never writes tall 1:4 leaves at 4:2:2 — the
68+4x16 leaf our decoder tripped on (`EC_RECTCHROMA_GAP` then the closed-shape
69+unreachable in `decode_rect4_16_strip`) is a phantom partition produced by the
70+upstream desync above, not a missing portrait block size. Nothing invented;
71+the shape guard stays closed.
72+
73+## Next wrong site
74+
75+`decode_rect_split`'s `chroma_tiled` square-chroma arm for 16x8 strips and
76+`decode_leaf8`'s 4x8 chroma (first HORZ_A pieces) — re-check those against
77+the oracle's `EC_COEFF` pairing before re-touching `decode_block`'s walk.
78+
79+## Gates
80+
81+- `a_real_aomenc_128x128_none_inter_blocks_coded_chroma_per_mu_chunk_decodes_
82+ pixel_exact` (420): PASS.
83+- `a_non_420_subsampled_sequence_header_is_refused_by_name` (422 refusal +
84+ 420 control): PASS.
85+- 444 check: `aomenc --profile=1` testsrc2 256x144 through `decode_probe`
86+ byte-compares IDENTICALLY at clean 5674d2c5 and with this diff (first diff
87+ at char 50689 on both — pre-existing branch behavior against this quick
88+ oracle recipe, not touched by this slice; the merged-main 444 gate
89+ c3c67f17 is not on this branch yet).
90+- `cargo check -p ec-av1 --all-targets`: 0 warnings.