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() {
36 }36 }
37 let (sc, dp) = ec_av1::decode::reelc_chroma_counters();37 let (sc, dp) = ec_av1::decode::reelc_chroma_counters();
38 println!("reelc_chroma: skip_cfl={sc} dir_1to4_pairs={dp}");38 println!("reelc_chroma: skip_cfl={sc} dir_1to4_pairs={dp}");
39+ println!(
40+ "chroma422_square: {}",
41+ ec_av1::decode::chroma422_square_hits()
42+ );
39 let (h, v, c) = ec_av1::stream::rect4_32_counters();43 let (h, v, c) = ec_av1::stream::rect4_32_counters();
40 println!("rect4_32: horz={h} vert={v} coded={c}");44 println!("rect4_32: horz={h} vert={v} coded={c}");
41 println!(45 println!(
crates/ec-av1/src/cdf.rsmodified+115 -73
@@ -290,21 +290,16 @@ pub const EOB_PT_512_LUMA_Q3: [u16; 11] = [
290 /// coded positions -- what a true 16x8/8x16 rectangular transform has290 /// coded positions -- what a true 16x8/8x16 rectangular transform has
291 /// (`txsize_log2_minus4` = 3), distinct from [`EOB_PT_256_CHROMA`]'s291 /// (`txsize_log2_minus4` = 3), distinct from [`EOB_PT_256_CHROMA`]'s
292 /// 256-position group a *square* 16x16 reads.292 /// 256-position group a *square* 16x16 reads.
293-pub const EOB_PT_128_CHROMA: [u16; 9] = [293+pub const EOB_PT_128_CHROMA: [u16; 9] = [13627, 16246, 20173, 24429, 27948, 30415, 31863, 32768, 0];
294- 13627, 16246, 20173, 24429, 27948, 30415, 31863, 32768, 0,
295-];
296 /// [`EOB_PT_128_CHROMA`], q-context 0.294 /// [`EOB_PT_128_CHROMA`], q-context 0.
297-pub const EOB_PT_128_CHROMA_Q0: [u16; 9] = [295+pub const EOB_PT_128_CHROMA_Q0: [u16; 9] =
298- 5245, 7456, 12880, 15852, 20033, 23932, 27608, 32768, 0,296+ [5245, 7456, 12880, 15852, 20033, 23932, 27608, 32768, 0];
299-];
300 /// [`EOB_PT_128_CHROMA`], q-context 1.297 /// [`EOB_PT_128_CHROMA`], q-context 1.
301-pub const EOB_PT_128_CHROMA_Q1: [u16; 9] = [298+pub const EOB_PT_128_CHROMA_Q1: [u16; 9] =
302- 8045, 11200, 15497, 19595, 23948, 27408, 30938, 32768, 0,299+ [8045, 11200, 15497, 19595, 23948, 27408, 30938, 32768, 0];
303-];
304 /// [`EOB_PT_128_CHROMA`], q-context 3.300 /// [`EOB_PT_128_CHROMA`], q-context 3.
305-pub const EOB_PT_128_CHROMA_Q3: [u16; 9] = [301+pub const EOB_PT_128_CHROMA_Q3: [u16; 9] =
306- 24313, 26062, 28385, 30107, 31217, 31898, 32345, 32768, 0,302+ [24313, 26062, 28385, 30107, 31217, 31898, 32345, 32768, 0];
307-];
308 303
309 /// `av1_default_eob_multi128_cdfs[2][0][0]` (`token_cdfs.h:830-849`,304 /// `av1_default_eob_multi128_cdfs[2][0][0]` (`token_cdfs.h:830-849`,
310 /// lane-rectx): the end-of-block group of a LUMA transform with 128 coded305 /// 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] = [
313 /// 32x16/16x32), distinct from [`EOB_PT_256_LUMA`]'s 256-position group a308 /// 32x16/16x32), distinct from [`EOB_PT_256_LUMA`]'s 256-position group a
314 /// *square* 16x16 reads. Read straight from the plane-0 half of the same309 /// *square* 16x16 reads. Read straight from the plane-0 half of the same
315 /// `token_cdfs.h` table [`EOB_PT_128_CHROMA`] reads its plane-1 half from.310 /// `token_cdfs.h` table [`EOB_PT_128_CHROMA`] reads its plane-1 half from.
316-pub const EOB_PT_128_LUMA: [u16; 9] = [311+pub const EOB_PT_128_LUMA: [u16; 9] = [1366, 1738, 2527, 5016, 9355, 15797, 24643, 32768, 0];
317- 1366, 1738, 2527, 5016, 9355, 15797, 24643, 32768, 0,
318-];
319 /// [`EOB_PT_128_LUMA`], q-context 0.312 /// [`EOB_PT_128_LUMA`], q-context 0.
320-pub const EOB_PT_128_LUMA_Q0: [u16; 9] = [313+pub const EOB_PT_128_LUMA_Q0: [u16; 9] = [219, 482, 1140, 2091, 3680, 6028, 12586, 32768, 0];
321- 219, 482, 1140, 2091, 3680, 6028, 12586, 32768, 0,
322-];
323 /// [`EOB_PT_128_LUMA`], q-context 1.314 /// [`EOB_PT_128_LUMA`], q-context 1.
324-pub const EOB_PT_128_LUMA_Q1: [u16; 9] = [315+pub const EOB_PT_128_LUMA_Q1: [u16; 9] = [685, 933, 1488, 2714, 4766, 8562, 19254, 32768, 0];
325- 685, 933, 1488, 2714, 4766, 8562, 19254, 32768, 0,
326-];
327 /// [`EOB_PT_128_LUMA`], q-context 3.316 /// [`EOB_PT_128_LUMA`], q-context 3.
328-pub const EOB_PT_128_LUMA_Q3: [u16; 9] = [317+pub const EOB_PT_128_LUMA_Q3: [u16; 9] = [3472, 4885, 7489, 12481, 18517, 24536, 29635, 32768, 0];
329- 3472, 4885, 7489, 12481, 18517, 24536, 29635, 32768, 0,
330-];
331 318
332 /// `av1_default_eob_multi32_cdfs[2][1][0]` (`token_cdfs.h:792-808`,319 /// `av1_default_eob_multi32_cdfs[2][1][0]` (`token_cdfs.h:792-808`,
333 /// lane-rectx): the end-of-block group of a CHROMA transform with 32 coded320 /// 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] = [
1824 29629, 32768, 0,1811 29629, 32768, 0,
1825 ],1812 ],
1826 [1813 [
1827- 2779, 3738, 4683, 7213, 7775, 8017, 8655, 14357, 17939, 21332, 24520, 27470, 29456,1814+ 2779, 3738, 4683, 7213, 7775, 8017, 8655, 14357, 17939, 21332, 24520, 27470, 29456, 30529,
1828- 30529, 31656, 32768, 0,1815+ 31656, 32768, 0,
1829 ],1816 ],
1830 [1817 [
1831 1684, 3625, 5675, 7108, 9302, 11274, 14429, 17144, 19163, 20961, 22884, 24471, 26719,1818 1684, 3625, 5675, 7108, 9302, 11274, 14429, 17144, 19163, 20961, 22884, 24471, 26719,
1832 28714, 30877, 32768, 0,1819 28714, 30877, 32768, 0,
1833 ],1820 ],
1834 [1821 [
1835- 1142, 3491, 6277, 7314, 8089, 8355, 9023, 13624, 15369, 16730, 18114, 19313, 22521,1822+ 1142, 3491, 6277, 7314, 8089, 8355, 9023, 13624, 15369, 16730, 18114, 19313, 22521, 26012,
1836- 26012, 29550, 32768, 0,1823+ 29550, 32768, 0,
1837 ],1824 ],
1838 [1825 [
1839- 2742, 4195, 5727, 8035, 8980, 9336, 10146, 14124, 17270, 20533, 23434, 25972, 27944,1826+ 2742, 4195, 5727, 8035, 8980, 9336, 10146, 14124, 17270, 20533, 23434, 25972, 27944, 29570,
1840- 29570, 31416, 32768, 0,1827+ 31416, 32768, 0,
1841 ],1828 ],
1842 [1829 [
1843 1727, 3948, 6101, 7796, 9841, 12344, 15766, 18944, 20638, 22038, 23963, 25311, 26988,1830 1727, 3948, 6101, 7796, 9841, 12344, 15766, 18944, 20638, 22038, 23963, 25311, 26988,
@@ -1880,8 +1867,8 @@ pub const WEDGE_IDX: [[u16; 17]; 22] = [
1880 30911, 32768, 0,1867 30911, 32768, 0,
1881 ],1868 ],
1882 [1869 [
1883- 1135, 1322, 1493, 2635, 2696, 2737, 2770, 21016, 22935, 25057, 27251, 29173, 30089,1870+ 1135, 1322, 1493, 2635, 2696, 2737, 2770, 21016, 22935, 25057, 27251, 29173, 30089, 30960,
1884- 30960, 31933, 32768, 0,1871+ 31933, 32768, 0,
1885 ],1872 ],
1886 [1873 [
1887 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528, 24576, 26624,1874 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] =
3179 /// TXB_SKIP_CHROMA_16, q-context 3: the same table as [`TXB_SKIP_CHROMA_16`], for `base_q_idx` 121..=255.3166 /// TXB_SKIP_CHROMA_16, q-context 3: the same table as [`TXB_SKIP_CHROMA_16`], for `base_q_idx` 121..=255.
3180 pub const TXB_SKIP_CHROMA_16_Q3: [[u16; 3]; 3] =3167 pub const TXB_SKIP_CHROMA_16_Q3: [[u16; 3]; 3] =
3181 [[3440, 32768, 0], [13117, 32768, 0], [22702, 32768, 0]];3168 [[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];
3182 /// TXB_SKIP_CHROMA_32, q-context 3: the same table as [`TXB_SKIP_CHROMA_32`], for `base_q_idx` 121..=255.3182 /// TXB_SKIP_CHROMA_32, q-context 3: the same table as [`TXB_SKIP_CHROMA_32`], for `base_q_idx` 121..=255.
3183 pub const TXB_SKIP_CHROMA_32_Q3: [[u16; 3]; 3] =3183 pub const TXB_SKIP_CHROMA_32_Q3: [[u16; 3]; 3] =
3184 [[4656, 32768, 0], [16074, 32768, 0], [24704, 32768, 0]];3184 [[4656, 32768, 0], [16074, 32768, 0], [24704, 32768, 0]];
@@ -3188,13 +3188,17 @@ pub const TXB_SKIP_CHROMA_32_Q3: [[u16; 3]; 3] =
3188 /// LARGER than the transform (`get_txb_ctx`), which in AV1 happens only for a3188 /// LARGER than the transform (`get_txb_ctx`), which in AV1 happens only for a
3189 /// 128x128 block's four TX_32X32 chroma units -- the offset-7 rows above are3189 /// 128x128 block's four TX_32X32 chroma units -- the offset-7 rows above are
3190 /// every other case (lane-sb128b r3).3190 /// 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]];
3192 /// Default CDF table `TXB_SKIP_CHROMA_32_BIG_Q1` (AV1 spec 9.4 initial probabilities).3193 /// 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]];
3194 /// Default CDF table `TXB_SKIP_CHROMA_32_BIG` (AV1 spec 9.4 initial probabilities).3196 /// 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]];
3196 /// Default CDF table `TXB_SKIP_CHROMA_32_BIG_Q3` (AV1 spec 9.4 initial probabilities).3199 /// 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]];
3198 /// EOB_EXTRA_LUMA_16, q-context 3: the same table as [`EOB_EXTRA_LUMA_16`], for `base_q_idx` 121..=255.3202 /// EOB_EXTRA_LUMA_16, q-context 3: the same table as [`EOB_EXTRA_LUMA_16`], for `base_q_idx` 121..=255.
3199 pub const EOB_EXTRA_LUMA_16_Q3: [[u16; 3]; 9] = [3203 pub const EOB_EXTRA_LUMA_16_Q3: [[u16; 3]; 9] = [
3200 [19941, 32768, 0],3204 [19941, 32768, 0],
@@ -5374,27 +5378,28 @@ pub const EOB_PT_256_LUMA_CLASS1_Q3: [u16; 10] =
5374 [2453, 4474, 6307, 8777, 16474, 22975, 29000, 31547, 32768, 0];5378 [2453, 4474, 6307, 8777, 16474, 22975, 29000, 31547, 32768, 0];
5375 5379
5376 /// Default CDF table `EOB_PT_256_CHROMA_CLASS1_Q0` (AV1 spec 9.4 initial probabilities).5380 /// 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] =5381+pub const EOB_PT_256_CHROMA_CLASS1_Q0: [u16; 10] = [
5378- [2203, 4130, 7435, 10739, 20652, 23681, 25609, 27261, 32768, 0];5382+ 2203, 4130, 7435, 10739, 20652, 23681, 25609, 27261, 32768, 0,
5383+];
5379 /// Default CDF table `EOB_PT_256_CHROMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).5384 /// 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] =5385+pub const EOB_PT_256_CHROMA_CLASS1_Q1: [u16; 10] = [
5381- [1674, 3252, 5734, 10159, 22397, 23802, 24821, 30940, 32768, 0];5386+ 1674, 3252, 5734, 10159, 22397, 23802, 24821, 30940, 32768, 0,
5387+];
5382 /// Default CDF table `EOB_PT_256_CHROMA_CLASS1` (AV1 spec 9.4 initial probabilities).5388 /// Default CDF table `EOB_PT_256_CHROMA_CLASS1` (AV1 spec 9.4 initial probabilities).
5383-pub const EOB_PT_256_CHROMA_CLASS1: [u16; 10] =5389+pub const EOB_PT_256_CHROMA_CLASS1: [u16; 10] = [
5384- [6571, 9610, 15516, 21826, 29092, 30829, 31842, 32708, 32768, 0];5390+ 6571, 9610, 15516, 21826, 29092, 30829, 31842, 32708, 32768, 0,
5391+];
5385 /// Default CDF table `EOB_PT_256_CHROMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).5392 /// 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] =5393+pub const EOB_PT_256_CHROMA_CLASS1_Q3: [u16; 10] = [
5387- [9998, 17661, 25178, 28097, 31308, 32038, 32403, 32695, 32768, 0];5394+ 9998, 17661, 25178, 28097, 31308, 32038, 32403, 32695, 32768, 0,
5395+];
5388 5396
5389 /// Default CDF table `EOB_PT_64_CHROMA_CLASS1_Q0` (AV1 spec 9.4 initial probabilities).5397 /// 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] =5398+pub const EOB_PT_64_CHROMA_CLASS1_Q0: [u16; 8] = [1563, 2700, 4876, 10911, 14706, 22480, 32768, 0];
5391- [1563, 2700, 4876, 10911, 14706, 22480, 32768, 0];
5392 /// Default CDF table `EOB_PT_64_CHROMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).5399 /// 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] =5400+pub const EOB_PT_64_CHROMA_CLASS1_Q1: [u16; 8] = [1923, 3127, 5867, 9703, 14277, 27100, 32768, 0];
5394- [1923, 3127, 5867, 9703, 14277, 27100, 32768, 0];
5395 /// Default CDF table `EOB_PT_64_CHROMA_CLASS1` (AV1 spec 9.4 initial probabilities).5401 /// Default CDF table `EOB_PT_64_CHROMA_CLASS1` (AV1 spec 9.4 initial probabilities).
5396-pub const EOB_PT_64_CHROMA_CLASS1: [u16; 8] =5402+pub const EOB_PT_64_CHROMA_CLASS1: [u16; 8] = [4034, 6290, 10235, 14982, 21214, 28491, 32768, 0];
5397- [4034, 6290, 10235, 14982, 21214, 28491, 32768, 0];
5398 /// Default CDF table `EOB_PT_64_CHROMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).5403 /// Default CDF table `EOB_PT_64_CHROMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).
5399 pub const EOB_PT_64_CHROMA_CLASS1_Q3: [u16; 8] =5404 pub const EOB_PT_64_CHROMA_CLASS1_Q3: [u16; 8] =
5400 [8726, 12378, 19409, 26450, 30038, 32462, 32768, 0];5405 [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
5411 /// `EOB_PT_128_LUMA`'s class-1 sibling (`av1_default_eob_multi128_cdfs[q][0][1]`),5416 /// `EOB_PT_128_LUMA`'s class-1 sibling (`av1_default_eob_multi128_cdfs[q][0][1]`),
5412 /// read by a 16x8/8x16 luma transform whose inherited `tx_type` is 1D5417 /// read by a 16x8/8x16 luma transform whose inherited `tx_type` is 1D
5413 /// (`TxbSet::LumaRect16x8`) -- machine-extracted, scripts/extract-eob-class1.py.5418 /// (`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];
5415 /// Default CDF table `EOB_PT_128_LUMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).5421 /// Default CDF table `EOB_PT_128_LUMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).
5416 pub const EOB_PT_128_LUMA_CLASS1_Q1: [u16; 9] = [217, 352, 618, 2303, 5261, 9969, 17472, 32768, 0];5422 pub const EOB_PT_128_LUMA_CLASS1_Q1: [u16; 9] = [217, 352, 618, 2303, 5261, 9969, 17472, 32768, 0];
5417 /// Default CDF table `EOB_PT_128_LUMA_CLASS1` (AV1 spec 9.4 initial probabilities).5423 /// Default CDF table `EOB_PT_128_LUMA_CLASS1` (AV1 spec 9.4 initial probabilities).
5418 pub const EOB_PT_128_LUMA_CLASS1: [u16; 9] = [354, 558, 944, 2760, 7287, 14037, 21779, 32768, 0];5424 pub const EOB_PT_128_LUMA_CLASS1: [u16; 9] = [354, 558, 944, 2760, 7287, 14037, 21779, 32768, 0];
5419 /// Default CDF table `EOB_PT_128_LUMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).5425 /// 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];
5421 5428
5422 /// `EOB_PT_32_CHROMA`'s class-1 sibling (`av1_default_eob_multi32_cdfs[q][1][1]`),5429 /// `EOB_PT_32_CHROMA`'s class-1 sibling (`av1_default_eob_multi32_cdfs[q][1][1]`),
5423 /// read by an 8x4/4x8 chroma transform under a 1D luma `tx_type`5430 /// 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,
5431 pub const EOB_PT_32_CHROMA_CLASS1_Q3: [u16; 7] = [7699, 10897, 20891, 26926, 31628, 32768, 0];5438 pub const EOB_PT_32_CHROMA_CLASS1_Q3: [u16; 7] = [7699, 10897, 20891, 26926, 31628, 32768, 0];
5432 5439
5433 /// `EOB_PT_128_CHROMA`'s class-1 sibling (`av1_default_eob_multi128_cdfs[q][1][1]`).5440 /// `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];
5435 /// Default CDF table `EOB_PT_128_CHROMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).5443 /// 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];
5437 /// Default CDF table `EOB_PT_128_CHROMA_CLASS1` (AV1 spec 9.4 initial probabilities).5446 /// 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];
5439 /// Default CDF table `EOB_PT_128_CHROMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).5449 /// 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];
5441 5452
5442 /// `EOB_PT_512_LUMA`'s class-1 sibling (`av1_default_eob_multi512_cdfs[q][0][1]`).5453 /// `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+];
5444 /// Default CDF table `EOB_PT_512_LUMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).5457 /// 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+];
5446 /// Default CDF table `EOB_PT_512_LUMA_CLASS1` (AV1 spec 9.4 initial probabilities).5461 /// 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+];
5448 /// Default CDF table `EOB_PT_512_LUMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).5465 /// 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+];
5450 5469
5451 /// `EOB_PT_512_CHROMA`'s class-1 sibling (`av1_default_eob_multi512_cdfs[q][1][1]`).5470 /// `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+];
5453 /// Default CDF table `EOB_PT_512_CHROMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).5474 /// 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+];
5455 /// Default CDF table `EOB_PT_512_CHROMA_CLASS1` (AV1 spec 9.4 initial probabilities).5478 /// 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+];
5457 /// Default CDF table `EOB_PT_512_CHROMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).5482 /// 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+];
5459 5486
5460 /// `EOB_PT_1024_LUMA`'s class-1 sibling (`av1_default_eob_multi1024_cdfs[q][0][1]`).5487 /// `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+];
5462 /// Default CDF table `EOB_PT_1024_LUMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).5491 /// 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+];
5464 /// Default CDF table `EOB_PT_1024_LUMA_CLASS1` (AV1 spec 9.4 initial probabilities).5495 /// 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+];
5466 /// Default CDF table `EOB_PT_1024_LUMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).5499 /// 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+];
5468 5503
5469 /// `EOB_PT_1024_CHROMA`'s class-1 sibling (`av1_default_eob_multi1024_cdfs[q][1][1]`).5504 /// `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+];
5471 /// Default CDF table `EOB_PT_1024_CHROMA_CLASS1_Q1` (AV1 spec 9.4 initial probabilities).5508 /// 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+];
5473 /// Default CDF table `EOB_PT_1024_CHROMA_CLASS1` (AV1 spec 9.4 initial probabilities).5512 /// 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+];
5475 /// Default CDF table `EOB_PT_1024_CHROMA_CLASS1_Q3` (AV1 spec 9.4 initial probabilities).5516 /// 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];5517+pub const EOB_PT_1024_CHROMA_CLASS1_Q3: [u16; 12] = [
5477-5518+ 2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0,
5519+];
crates/ec-av1/src/cdf_state.rsmodified+35 -9
@@ -400,7 +400,7 @@ pub(crate) struct Cdfs {
400 /// The same, for a 4x4 luma transform (lane-av1tx4).400 /// The same, for a 4x4 luma transform (lane-av1tx4).
401 pub txb_skip_luma_4: [[u16; 3]; 7],401 pub txb_skip_luma_4: [[u16; 3]; 7],
402 /// The all-zero flag of an 8x8 chroma transform.402 /// 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],
404 /// The all-zero flag of a 4x4 chroma transform.404 /// The all-zero flag of a 4x4 chroma transform.
405 /// lane-lossless: SIX rows, like [`Self::txb_skip_chroma_32`] -- the last405 /// lane-lossless: SIX rows, like [`Self::txb_skip_chroma_32`] -- the last
406 /// three are `get_txb_ctx`'s `+10` rows (chroma plane block bigger than406 /// three are `get_txb_ctx`'s `+10` rows (chroma plane block bigger than
@@ -500,7 +500,7 @@ pub(crate) struct Cdfs {
500 /// The same, for a 64x64 luma transform.500 /// The same, for a 64x64 luma transform.
501 pub txb_skip_luma_64: [[u16; 3]; 7],501 pub txb_skip_luma_64: [[u16; 3]; 7],
502 /// The all-zero flag of a 16x16 chroma transform.502 /// 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],
504 /// The all-zero flag of a 32x32 chroma transform.504 /// The all-zero flag of a 32x32 chroma transform.
505 /// SIX contexts, not three: rows 0..3 are libaom's `txb_skip_ctx` 7..9505 /// SIX contexts, not three: rows 0..3 are libaom's `txb_skip_ctx` 7..9
506 /// (chroma transform == its plane block) and rows 3..6 its 10..12 (plane506 /// (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]
828 /// [`reset3`] for a table whose ALPHABET grows with its first index: the828 /// [`reset3`] for a table whose ALPHABET grows with its first index: the
829 /// palette colour-index CDFs are `[u16; 9]` rows read as `[..=n]` with829 /// palette colour-index CDFs are `[u16; 9]` rows read as `[..=n]` with
830 /// `n = idx + 2`, so their symbol counter sits at index `n`, not `N - 1`.830 /// `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>(831+fn reset_var_alphabet<const N: usize, const M: usize, const K: usize>(a: &mut [[[u16; N]; M]; K]) {
832- a: &mut [[[u16; N]; M]; K],
833-) {
834 for (idx, rows) in a.iter_mut().enumerate() {832 for (idx, rows) in a.iter_mut().enumerate() {
835 for row in rows.iter_mut() {833 for row in rows.iter_mut() {
836 row[idx + 2] = 0;834 row[idx + 2] = 0;
@@ -1067,13 +1065,27 @@ impl Cdfs {
1067 cdf::TXB_SKIP_LUMA_4_CTX,1065 cdf::TXB_SKIP_LUMA_4_CTX,
1068 cdf::TXB_SKIP_LUMA_4_Q3_CTX,1066 cdf::TXB_SKIP_LUMA_4_Q3_CTX,
1069 ),1067 ),
1070- txb_skip_chroma_8: pick(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(
1071 q_ctx,1074 q_ctx,
1072 cdf::TXB_SKIP_CHROMA_8_Q0,1075 cdf::TXB_SKIP_CHROMA_8_Q0,
1073 cdf::TXB_SKIP_CHROMA_8_Q1,1076 cdf::TXB_SKIP_CHROMA_8_Q1,
1074 cdf::TXB_SKIP_CHROMA_8,1077 cdf::TXB_SKIP_CHROMA_8,
1075 cdf::TXB_SKIP_CHROMA_8_Q3,1078 cdf::TXB_SKIP_CHROMA_8_Q3,
1076- ),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+ },
1077 txb_skip_chroma_4: {1089 txb_skip_chroma_4: {
1078 let small = pick(1090 let small = pick(
1079 q_ctx,1091 q_ctx,
@@ -1387,13 +1399,27 @@ impl Cdfs {
1387 cdf::TXB_SKIP_LUMA_64_CTX,1399 cdf::TXB_SKIP_LUMA_64_CTX,
1388 cdf::TXB_SKIP_LUMA_64_Q3_CTX,1400 cdf::TXB_SKIP_LUMA_64_Q3_CTX,
1389 ),1401 ),
1390- txb_skip_chroma_16: pick(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(
1391 q_ctx,1408 q_ctx,
1392 cdf::TXB_SKIP_CHROMA_16_Q0,1409 cdf::TXB_SKIP_CHROMA_16_Q0,
1393 cdf::TXB_SKIP_CHROMA_16_Q1,1410 cdf::TXB_SKIP_CHROMA_16_Q1,
1394 cdf::TXB_SKIP_CHROMA_16,1411 cdf::TXB_SKIP_CHROMA_16,
1395 cdf::TXB_SKIP_CHROMA_16_Q3,1412 cdf::TXB_SKIP_CHROMA_16_Q3,
1396- ),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+ },
1397 txb_skip_chroma_32: {1423 txb_skip_chroma_32: {
1398 let small = pick(1424 let small = pick(
1399 q_ctx,1425 q_ctx,
crates/ec-av1/src/decode.rsmodified+157 -53
@@ -1509,6 +1509,36 @@ fn tu_reach(
1509 fixed1509 fixed
1510 }1510 }
1511 1511
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+
1512 // How many `uv_mode` reads resolved to `SMOOTH_PRED..=PAETH_PRED` (9..=12),1542 // How many `uv_mode` reads resolved to `SMOOTH_PRED..=PAETH_PRED` (9..=12),
1513 // across every call on the current thread -- lane-chroma r3's own before/after1543 // across every call on the current thread -- lane-chroma r3's own before/after
1514 // counter, proving a stream actually exercised chroma's smooth/paeth1544 // counter, proving a stream actually exercised chroma's smooth/paeth
@@ -2002,8 +2032,9 @@ thread_local! {
2002 }2032 }
2003 2033
2004 /// Current value of [`CHROMA422_SQUARE_HITS`].2034 /// Current value of [`CHROMA422_SQUARE_HITS`].
2005-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates2035+// lane-av1-422b: `pub` so `examples/decode_probe.rs` can census it the way
2006-pub(crate) fn chroma422_square_hits() -> usize {2036+// it does every other capability counter.
2037+pub fn chroma422_square_hits() -> usize {
2007 CHROMA422_SQUARE_HITS.with(|c| c.get())2038 CHROMA422_SQUARE_HITS.with(|c| c.get())
2008 }2039 }
2009 2040
@@ -16648,6 +16679,24 @@ fn decode_block(
16648 _ => (TxbSet::Chroma4, scan4),16679 _ => (TxbSet::Chroma4, scan4),
16649 };16680 };
16650 (luma_set, set, luma_tx, tx, (scans.0, scan))16681 (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))
16651 } else {16700 } else {
16652 (luma_set, chroma_set, luma_tx, chroma_tx, scans)16701 (luma_set, chroma_set, luma_tx, chroma_tx, scans)
16653 };16702 };
@@ -16773,6 +16822,9 @@ fn decode_block(
16773 let reach = Reach::of(side, px, py, y.width, y.height, fctx);16822 let reach = Reach::of(side, px, py, y.width, y.height, fctx);
16774 let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx));16823 let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx));
16775 let chroma_side = side >> ss_x(fctx);16824 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);
16776 // spec 7.11.3.4 with `use_intrabc`: the reference is the *current*16828 // spec 7.11.3.4 with `use_intrabc`: the reference is the *current*
16777 // frame's own pre-loop-filter reconstruction (all loop filters are off16829 // frame's own pre-loop-filter reconstruction (all loop filters are off
16778 // whenever `allow_intrabc`, frame.rs:194/210/252/272) at the full-pel16830 // whenever `allow_intrabc`, frame.rs:194/210/252/272) at the full-pel
@@ -16787,17 +16839,17 @@ fn decode_block(
16787 mv_to_q4(px, dv_col, 0), mv_to_q4(py, dv_row, 0),16839 mv_to_q4(px, dv_col, 0), mv_to_q4(py, dv_row, 0),
16788 side, side, mc::InterpFilterKind::Bilinear, &mut yb, fctx,16840 side, side, mc::InterpFilterKind::Bilinear, &mut yb, fctx,
16789 );16841 );
16790- let mut ub = vec![0u16; chroma_side * chroma_side];16842+ let mut ub = vec![0u16; chroma_side * chroma_height];
16791 mc::predict_with_filter(16843 mc::predict_with_filter(
16792 &u.data, u.width, u.true_width, u.true_height,16844 &u.data, u.width, u.true_width, u.true_height,
16793 mv_to_q4(cpx, dv_col, ss_x(fctx)), mv_to_q4(cpy, dv_row, ss_y(fctx)),16845 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,
16795 );16847 );
16796- let mut vb = vec![0u16; chroma_side * chroma_side];16848+ let mut vb = vec![0u16; chroma_side * chroma_height];
16797 mc::predict_with_filter(16849 mc::predict_with_filter(
16798 &v.data, v.width, v.true_width, v.true_height,16850 &v.data, v.width, v.true_width, v.true_height,
16799 mv_to_q4(cpx, dv_col, ss_x(fctx)), mv_to_q4(cpy, dv_row, ss_y(fctx)),16851 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,
16801 );16853 );
16802 (yb, ub, vb)16854 (yb, ub, vb)
16803 });16855 });
@@ -16942,16 +16994,23 @@ fn decode_block(
16942 );16994 );
16943 }16995 }
16944 let ac = alpha.map(|_| cfl_src(px, py, side));16996 let ac = alpha.map(|_| cfl_src(px, py, side));
16945- let cn = (chroma_side / chroma_tx).max(1);16997+ // lane-av1-422b: the chroma unit grid is `cn_cols` x `cn_rows` --
16946- for cu_row in 0..cn {16998+ // square at 4:2:0/4:4:4, at 4:2:2 `(side/2)/tx` units wide by
16947- for cu_col in 0..cn {16999+ // `side/tx` tall (the plane block is (side/2, side)). A unit's LUMA
16948- let luma_span = chroma_tx << ss_x(fctx);17000+ // anchor follows the per-axis shifts: `chroma_tx << ss_x` wide,
16949- let cu_r = if cn == 1 {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 {
16950 reach17009 reach
16951 } else {17010 } else {
16952- tu_reach(17011+ tu_reach_rect(
16953 side, side,17012 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,
16955 reach, px, py, y.width, y.height, fctx,17014 reach, px, py, y.width, y.height, fctx,
16956 )17015 )
16957 };17016 };
@@ -17037,8 +17096,13 @@ fn decode_block(
17037 // TX_32X32, so a 64x64 block codes four chroma units, plane-major17096 // TX_32X32, so a 64x64 block codes four chroma units, plane-major
17038 // (every U, then every V) — the same loop the multi-TU arm runs.17097 // (every U, then every V) — the same loop the multi-TU arm runs.
17039 // At 4:2:0 `chroma_side == chroma_tx`, so it stays one read.17098 // At 4:2:0 `chroma_side == chroma_tx`, so it stays one read.
17040- let cn = (chroma_side / chroma_tx).max(1);17099+ // lane-av1-422b: 4:2:2 never collapses to one read above a 4x4 luma
17041- let (u_grid, v_grid, chroma_units) = if cn == 1 {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 {
17042 if let Some((ub, _)) = &palette_uv_bufs {17106 if let Some((ub, _)) = &palette_uv_bufs {
17043 set_palette_pred(ub.clone(), fctx);17107 set_palette_pred(ub.clone(), fctx);
17044 }17108 }
@@ -17099,24 +17163,25 @@ fn decode_block(
17099 } else {17163 } else {
17100 let chroma_ctx_offset = Some(3);17164 let chroma_ctx_offset = Some(3);
17101 let mut u_pass: Vec<Grid> = Vec::new();17165 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();
17103 let mut last_grids = [Grid::Zero(0), Grid::Zero(0)];17167 let mut last_grids = [Grid::Zero(0), Grid::Zero(0)];
17104 for plane_pass in 1..=2usize {17168 for plane_pass in 1..=2usize {
17105 let mut pass_idx = 0usize;17169 let mut pass_idx = 0usize;
17106- for cu_row in 0..cn {17170+ for cu_row in 0..cn_rows {
17107- for cu_col in 0..cn {17171+ for cu_col in 0..cn_cols {
17108- let luma_span = chroma_tx << ss_x(fctx);
17109 let cu_mi = (17172 let cu_mi = (
17110- mi_r + cu_row * (luma_span / MI),17173+ mi_r + cu_row * (luma_span_y / MI),
17111- mi_c + cu_col * (luma_span / MI),17174+ mi_c + cu_col * (luma_span_x / MI),
17112 );17175 );
17113- let cu_around = neighbours.around_mi(cu_mi, luma_span);17176+ let cu_around =
17114- let cu_reach = tu_reach(17177+ neighbours.around_mi_rect(cu_mi, luma_span_x, luma_span_y);
17178+ let cu_reach = tu_reach_rect(
17115 side,17179 side,
17116 side,17180 side,
17117- cu_col * luma_span,17181+ cu_col * luma_span_x,
17118- cu_row * luma_span,17182+ cu_row * luma_span_y,
17119- luma_span,17183+ luma_span_x,
17184+ luma_span_y,
17120 reach,17185 reach,
17121 px,17186 px,
17122 py,17187 py,
@@ -17146,16 +17211,21 @@ fn decode_block(
17146 None, chroma_ctx_offset, smooth_neighbor_uv, fctx,17211 None, chroma_ctx_offset, smooth_neighbor_uv, fctx,
17147 )?;17212 )?;
17148 hit!(CHROMA_SPLIT_TX_HITS);17213 hit!(CHROMA_SPLIT_TX_HITS);
17214+ if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
17215+ hit!(CHROMA422_SQUARE_HITS);
17216+ }
17149 // Immediately, so the next unit of this block reads this17217 // Immediately, so the next unit of this block reads this
17150 // one's coefficient context. `record` below stamps one17218 // one's coefficient context. `record` below stamps one
17151 // chroma state across the whole block; the replay after17219 // chroma state across the whole block; the replay after
17152 // it puts the per-unit state back.17220 // 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+ );
17154 if plane_pass == 1 {17224 if plane_pass == 1 {
17155 u_pass.push(cu_grid);17225 u_pass.push(cu_grid);
17156 } else {17226 } else {
17157 let u_grid = std::mem::replace(&mut u_pass[pass_idx], Grid::Zero(0));17227 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()));
17159 last_grids = [u_grid, cu_grid];17229 last_grids = [u_grid, cu_grid];
17160 }17230 }
17161 pass_idx += 1;17231 pass_idx += 1;
@@ -17166,9 +17236,9 @@ fn decode_block(
17166 };17236 };
17167 fctx.intrabc_chroma_tx.with(|c| c.set(None));17237 fctx.intrabc_chroma_tx.with(|c| c.set(None));
17168 neighbours.record(at, side, mode, uv_predict_mode, &[&luma_grid[..], &u_grid[..], &v_grid[..]]);17238 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 {17239+ for (cu_mi, sw, sh, u_unit, v_unit) in &chroma_units {
17170- neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 1, u_unit);17240+ neighbours.record_mi_chroma(*cu_mi, *sw, *sh, 1, u_unit);
17171- neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 2, v_unit);17241+ neighbours.record_mi_chroma(*cu_mi, *sw, *sh, 2, v_unit);
17172 }17242 }
17173 } else {17243 } else {
17174 // Several luma transform units, raster order (spec17244 // Several luma transform units, raster order (spec
@@ -17178,7 +17248,10 @@ fn decode_block(
17178 // the earlier tiles in this same block already wrote -- the same17248 // the earlier tiles in this same block already wrote -- the same
17179 // per-TU pattern [`decode_leaf8`] already runs for an 8x8 leaf.17249 // per-TU pattern [`decode_leaf8`] already runs for an 8x8 leaf.
17180 let n_axis = side / logical_tx;17250 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);
17182 // libaom's transform-block loop is over 64x64 luma "mu" chunks17255 // libaom's transform-block loop is over 64x64 luma "mu" chunks
17183 // (`decode_token_recon_block`: `mu_blocks_wide/high` =17256 // (`decode_token_recon_block`: `mu_blocks_wide/high` =
17184 // `mi_size_wide[BLOCK_64X64]`), and it codes EVERY PLANE of a chunk17257 // `mi_size_wide[BLOCK_64X64]`), and it codes EVERY PLANE of a chunk
@@ -17190,9 +17263,10 @@ fn decode_block(
17190 let nchunk = (side / 64).max(1);17263 let nchunk = (side / 64).max(1);
17191 // `cn > 1` means the uv plane block is larger than the uv transform,17264 // `cn > 1` means the uv plane block is larger than the uv transform,
17192 // which moves libaom's chroma `txb_skip_ctx` offset from 7 to 10.17265 // 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 };
17194 let tpc = (n_axis / nchunk).max(1);17267 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);
17196 // The block's luma transform units, raster order inside each mu17270 // The block's luma transform units, raster order inside each mu
17197 // chunk. lane-av1-ibcvtx: an intrabc block's units are the var-tx17271 // chunk. lane-av1-ibcvtx: an intrabc block's units are the var-tx
17198 // tree's own leaf list -- mixed sizes included, exactly what libaom's17272 // tree's own leaf list -- mixed sizes included, exactly what libaom's
@@ -17218,7 +17292,7 @@ fn decode_block(
17218 }17292 }
17219 }17293 }
17220 let mut last_grids = [Grid::Zero(0), Grid::Zero(0)];17294 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();
17222 for ch_row in 0..nchunk {17296 for ch_row in 0..nchunk {
17223 for ch_col in 0..nchunk {17297 for ch_col in 0..nchunk {
17224 // lane-av1-ibcvtx: the chunk's chroma units inherit the CHROMA tx17298 // lane-av1-ibcvtx: the chunk's chroma units inherit the CHROMA tx
@@ -17352,8 +17426,8 @@ fn decode_block(
17352 let mut u_pass: Vec<Grid> = Vec::new();17426 let mut u_pass: Vec<Grid> = Vec::new();
17353 for plane_pass in 1..=2usize {17427 for plane_pass in 1..=2usize {
17354 let mut pass_idx = 0usize;17428 let mut pass_idx = 0usize;
17355- for cu_row in ch_row * cpc..(ch_row + 1) * cpc {17429+ for cu_row in ch_row * cpc_rows..(ch_row + 1) * cpc_rows {
17356- for cu_col in ch_col * cpc..(ch_col + 1) * cpc {17430+ for cu_col in ch_col * cpc_cols..(ch_col + 1) * cpc_cols {
17357 // libaom `decode_reconstruct_tx`'s frame-edge clip17431 // libaom `decode_reconstruct_tx`'s frame-edge clip
17358 // (decodeframe.c:299, `blk_row >= max_blocks_high || blk_col17432 // (decodeframe.c:299, `blk_row >= max_blocks_high || blk_col
17359 // >= max_blocks_wide` returns before ANY symbol is read): a17433 // >= max_blocks_wide` returns before ANY symbol is read): a
@@ -17384,20 +17458,21 @@ fn decode_block(
17384 continue;17458 continue;
17385 }17459 }
17386 // The chroma context arrays are indexed in LUMA mi, so this17460 // The chroma context arrays are indexed in LUMA mi, so this
17387- // unit's anchor is its own luma quadrant: `chroma_tx` chroma17461+ // unit's anchor is its own luma quadrant (lane-av1-422b: the
17388- // pixels span `2 * chroma_tx` luma ones.17462+ // quadrant spans `chroma_tx << ss_x` luma px wide by
17389- let luma_span = chroma_tx << ss_x(fctx);17463+ // `chroma_tx << ss_y` tall -- at 4:2:2 a rect twice as wide
17464+ // as it is tall).
17390 let cu_mi = (17465 let cu_mi = (
17391- mi_r + cu_row * (luma_span / MI),17466+ mi_r + cu_row * (luma_span_y / MI),
17392- mi_c + cu_col * (luma_span / MI),17467+ mi_c + cu_col * (luma_span_x / MI),
17393 );17468 );
17394- let cu_around = neighbours.around_mi(cu_mi, luma_span);17469+ let cu_around = neighbours.around_mi_rect(cu_mi, luma_span_x, luma_span_y);
17395- let cu_reach = if cn == 1 {17470+ let cu_reach = if cn_rows == 1 && cn_cols == 1 {
17396 reach17471 reach
17397 } else {17472 } else {
17398- tu_reach(17473+ tu_reach_rect(
17399 side, side,17474 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,
17401 reach, px, py, y.width, y.height, fctx,17476 reach, px, py, y.width, y.height, fctx,
17402 )17477 )
17403 };17478 };
@@ -17423,22 +17498,27 @@ fn decode_block(
17423 }),17498 }),
17424 None, chroma_ctx_offset, smooth_neighbor_uv, fctx,17499 None, chroma_ctx_offset, smooth_neighbor_uv, fctx,
17425 )?;17500 )?;
17426- if cn > 1 {17501+ if cn_rows * cn_cols > 1 {
17427 hit!(CHROMA_SPLIT_TX_HITS);17502 hit!(CHROMA_SPLIT_TX_HITS);
17503+ if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
17504+ hit!(CHROMA422_SQUARE_HITS);
17505+ }
17428 // Immediately, so the NEXT unit of this same block reads17506 // Immediately, so the NEXT unit of this same block reads
17429 // this one's coefficient context (libaom's chroma17507 // this one's coefficient context (libaom's chroma
17430 // `txb_skip_ctx` for the second quadrant is 11, i.e. base17508 // `txb_skip_ctx` for the second quadrant is 11, i.e. base
17431 // 1 from this left neighbour -- measured against aomdec).17509 // 1 from this left neighbour -- measured against aomdec).
17432 // The same writes are replayed after `record_split_luma`17510 // The same writes are replayed after `record_split_luma`
17433 // below, which would otherwise clobber them whole-block.17511 // 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+ );
17435 }17515 }
17436 if plane_pass == 1 {17516 if plane_pass == 1 {
17437 u_pass.push(cu_grid);17517 u_pass.push(cu_grid);
17438 } else {17518 } else {
17439 let u_grid = std::mem::replace(&mut u_pass[pass_idx], Grid::Zero(0));17519 let u_grid = std::mem::replace(&mut u_pass[pass_idx], Grid::Zero(0));
17440- if cn > 1 {17520+ if cn_rows * cn_cols > 1 {
17441- units.push((cu_mi, luma_span, u_grid.clone(), cu_grid.clone()));17521+ units.push((cu_mi, luma_span_x, luma_span_y, u_grid.clone(), cu_grid.clone()));
17442 }17522 }
17443 last_grids = [u_grid, cu_grid];17523 last_grids = [u_grid, cu_grid];
17444 }17524 }
@@ -17455,9 +17535,9 @@ fn decode_block(
17455 // context write; at `cn > 1` the per-unit writes above are what the17535 // context write; at `cn > 1` the per-unit writes above are what the
17456 // next block reads, so they run after this (last writer wins).17536 // next block reads, so they run after this (last writer wins).
17457 neighbours.record_split_luma(at, side, mode, uv_predict_mode, [&last_grids[0], &last_grids[1]]);17537 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 {17538+ for (cu_mi, sw, sh, u_grid, v_grid) in &units {
17459- neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 1, u_grid);17539+ neighbours.record_mi_chroma(*cu_mi, *sw, *sh, 1, u_grid);
17460- neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 2, v_grid);17540+ neighbours.record_mi_chroma(*cu_mi, *sw, *sh, 2, v_grid);
17461 }17541 }
17462 }17542 }
17463 // Unconditional, `size == 0` for a non-palette block: clears any stale17543 // Unconditional, `size == 0` for a non-palette block: clears any stale
@@ -26319,7 +26399,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
26319 // mirroring [`crate::tile::sb_coeff_key_frame_tile`]'s own26399 // mirroring [`crate::tile::sb_coeff_key_frame_tile`]'s own
26320 // three-way write exactly.26400 // three-way write exactly.
26321 let part = if has_cols && has_rows {26401 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+ }
26322 let p = dec.symbol(&mut cdfs.partition_w64[ctx]);26405 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+ }
26323 if crate::envflags::env_flag!("EC_AV1_TRACE") {26409 if crate::envflags::env_flag!("EC_AV1_TRACE") {
26324 eprintln!("TRACE partition_w64 ctx={ctx} value={p}");26410 eprintln!("TRACE partition_w64 ctx={ctx} value={p}");
26325 }26411 }
@@ -26395,7 +26481,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
26395 has_half(r32 * BLOCK_MI, BLOCK_MI, mi_rows),26481 has_half(r32 * BLOCK_MI, BLOCK_MI, mi_rows),
26396 );26482 );
26397 let part32 = if has_cols32 && has_rows32 {26483 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+ }
26398 let p = dec.symbol(&mut cdfs.partition_w32[ctx32]);26487 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+ }
26399 if crate::envflags::env_flag!("EC_AV1_TRACE") {26491 if crate::envflags::env_flag!("EC_AV1_TRACE") {
26400 let (rng, _) = dec.debug_state();26492 let (rng, _) = dec.debug_state();
26401 eprintln!(26493 eprintln!(
@@ -26481,7 +26573,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
26481 let at16 = (sr, sc);26573 let at16 = (sr, sc);
26482 let ctx16 = neighbours.partition_ctx(at16, SUB);26574 let ctx16 = neighbours.partition_ctx(at16, SUB);
26483 if has_cols16 && has_rows16 {26575 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+ }
26484 let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]);26579 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+ }
26485 if crate::envflags::env_flag!("EC_AV1_TRACE") {26583 if crate::envflags::env_flag!("EC_AV1_TRACE") {
26486 eprintln!(26584 eprintln!(
26487 "TRACE partition_w16 mi=({},{}) ctx={ctx16} value={part16}",26585 "TRACE partition_w16 mi=({},{}) ctx={ctx16} value={part16}",
@@ -26805,8 +26903,14 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
26805 }26903 }
26806 }26904 }
26807 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);26905 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+ }
26808 let part8 =26909 let part8 =
26809 dec.symbol(&mut cdfs.partition_w8[leaf_ctx]);26910 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+ }
26810 if crate::envflags::env_flag!("EC_AV1_TRACE") {26914 if crate::envflags::env_flag!("EC_AV1_TRACE") {
26811 eprintln!(26915 eprintln!(
26812 "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8}"26916 "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.