forge
Explore
Log in

Don't you dare go Hollow

Merge 1191a48f (422sub8rect) — suite green: 422sub8rect GREEN 623/0 locally

Browse files at this commit

abb068fb1be09be17877a55f5264afe033858590Ahmet Kaan GümüşParent: 4df88f766b4c76
# Conflicts:
#	crates/ec-av1/src/decode.rs
#	lanes/av1422filter.report.md

28 changed files +4754 -547

crates/ec-av1/examples/decode_probe.rsmodified+10 -0
@@ -36,6 +36,16 @@ 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+ );
43+ println!("chroma422_rect: {}", ec_av1::decode::chroma422_rect_hits());
44+ println!("chroma422_sub8: {}", ec_av1::decode::chroma422_sub8_hits());
45+ println!(
46+ "chroma422_chunk: {}",
47+ ec_av1::decode::chroma422_chunk_hits()
48+ );
39 let (h, v, c) = ec_av1::stream::rect4_32_counters();49 let (h, v, c) = ec_av1::stream::rect4_32_counters();
40 println!("rect4_32: horz={h} vert={v} coded={c}");50 println!("rect4_32: horz={h} vert={v} coded={c}");
41 println!(51 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+45 -19
@@ -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: {
1071- q_ctx,1069+ // lane-av1-422b: rows 3..6 are the `+10` chroma rows
1072- cdf::TXB_SKIP_CHROMA_8_Q0,1070+ // (`TXB_SKIP_CHROMA_8_BIG`) -- neutral in libaom's defaults,
1073- cdf::TXB_SKIP_CHROMA_8_Q1,1071+ // reached only when the plane block is larger than an 8x8
1074- cdf::TXB_SKIP_CHROMA_8,1072+ // transform, i.e. only at 4:2:2 today.
1075- cdf::TXB_SKIP_CHROMA_8_Q3,1073+ let small = pick(
1076- ),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+ },
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: {
1391- q_ctx,1403+ // lane-av1-422b: rows 3..6 are the `+10` chroma rows
1392- cdf::TXB_SKIP_CHROMA_16_Q0,1404+ // (`TXB_SKIP_CHROMA_16_BIG`) -- neutral in libaom's defaults,
1393- cdf::TXB_SKIP_CHROMA_16_Q1,1405+ // reached only when the plane block is larger than a 16x16
1394- cdf::TXB_SKIP_CHROMA_16,1406+ // transform, i.e. only at 4:2:2 today.
1395- cdf::TXB_SKIP_CHROMA_16_Q3,1407+ let small = pick(
1396- ),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+ },
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+2445 -438

Diff too large; view file

@@ -1517,6 +1517,36 @@ fn tu_reach(
1517 fixed1517 fixed
1518 }1518 }
1519 1519
1520+/// [`tu_reach`] for a unit whose LUMA footprint is a `tx_w` x `tx_h` rect
1521+/// (lane-av1-422b: a 4:2:2 chroma unit is square in chroma pixels, but its
1522+/// luma anchor is `(chroma_tx << ss_x, chroma_tx << ss_y)` -- at ss (1,0)
1523+/// twice as wide as it is tall). Same predicate as [`tu_reach`]; the
1524+/// square mismatch counter only means anything when the footprint actually
1525+/// is square.
1526+#[allow(clippy::too_many_arguments)]
1527+fn tu_reach_rect(
1528+ bw: usize,
1529+ bh: usize,
1530+ col_off: usize,
1531+ row_off: usize,
1532+ tx_w: usize,
1533+ tx_h: usize,
1534+ block: Reach,
1535+ px: usize,
1536+ py: usize,
1537+ width: usize,
1538+ height: usize, fctx: &crate::decode::FrameCtx,
1539+) -> Reach {
1540+ let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx_w, tx_h, block);
1541+ if tx_w == tx_h {
1542+ let standalone = Reach::of(tx_w, px + col_off, py + row_off, width, height, fctx);
1543+ if fixed != standalone {
1544+ hit!(SPLIT_TU_REACH_FIX_HITS);
1545+ }
1546+ }
1547+ fixed
1548+}
1549+
1520 // How many `uv_mode` reads resolved to `SMOOTH_PRED..=PAETH_PRED` (9..=12),1550 // How many `uv_mode` reads resolved to `SMOOTH_PRED..=PAETH_PRED` (9..=12),
1521 // across every call on the current thread -- lane-chroma r3's own before/after1551 // across every call on the current thread -- lane-chroma r3's own before/after
1522 // counter, proving a stream actually exercised chroma's smooth/paeth1552 // counter, proving a stream actually exercised chroma's smooth/paeth
@@ -1998,6 +2028,85 @@ pub(crate) fn rect_split_chroma_shape_hits() -> [usize; 4] {
1998 RECT_SPLIT_CHROMA_SHAPE_HITS.with(|c| c.get())2028 RECT_SPLIT_CHROMA_SHAPE_HITS.with(|c| c.get())
1999 }2029 }
2000 2030
2031+// lane-av1-422: how many SQUARE chroma coefficient units the strip path read
2032+// on a 4:2:2 frame (ss 1,0) -- the half-width, unhalved-height shape whose
2033+// tables only exist because of the square rows in the chroma_tiled arm. A
2034+// 4:2:0 or 4:4:4 frame can never increment it (their rect strips' chroma is
2035+// itself rect), and a restored `/2 chroma height` diverts 4:2:2 squares onto
2036+// the rect rows, so the witness gate reads 0 there and fails.
2037+thread_local! {
2038+ static CHROMA422_SQUARE_HITS: std::cell::Cell<usize> =
2039+ const { std::cell::Cell::new(0) };
2040+}
2041+
2042+/// Current value of [`CHROMA422_SQUARE_HITS`].
2043+// lane-av1-422b: `pub` so `examples/decode_probe.rs` can census it the way
2044+// it does every other capability counter.
2045+pub fn chroma422_square_hits() -> usize {
2046+ CHROMA422_SQUARE_HITS.with(|c| c.get())
2047+}
2048+
2049+// lane-av1-422f: how many RECT chroma coefficient units the square-block
2050+// path read on a 4:2:2 frame (ss 1,0) -- TX_4X8 / TX_8X16 / TX_16X32, the
2051+// plane block's own half-width, unhalved-height shape. A 4:2:0 or 4:4:4
2052+// frame never takes the rect branch (their units are square
2053+// `chroma_tx == chroma_tx_h`), so a witness gate reading 0 here proves the
2054+// model reverted to squares.
2055+thread_local! {
2056+ static CHROMA422_RECT_HITS: std::cell::Cell<usize> =
2057+ const { std::cell::Cell::new(0) };
2058+}
2059+
2060+/// Current value of [`CHROMA422_RECT_HITS`].
2061+pub fn chroma422_rect_hits() -> usize {
2062+ CHROMA422_RECT_HITS.with(|c| c.get())
2063+}
2064+
2065+// lane-av1-422g: how many PER-LEAF TX_4X4 chroma coefficient units the
2066+// sub-8x8 split4 path read on a 4:2:2 frame (ss 1,0) -- one per even-column
2067+// leaf per plane (`is_chroma_reference`'s `!(mi_col & ss_x)`). A 4:2:0 frame
2068+// codes no sub-8 chroma at all and 4:4:4 goes through `sub8_leaf_chroma444`,
2069+// so a witness gate reading 0 here proves the per-leaf 4:2:2 arm never ran.
2070+thread_local! {
2071+ static CHROMA422_SUB8_HITS: std::cell::Cell<usize> =
2072+ const { std::cell::Cell::new(0) };
2073+}
2074+
2075+/// Current value of [`CHROMA422_SUB8_HITS`].
2076+pub fn chroma422_sub8_hits() -> usize {
2077+ CHROMA422_SUB8_HITS.with(|c| c.get())
2078+}
2079+
2080+// lane-av1-422sub8rect: how many PER-PIECE TX_4X4 chroma coefficient units
2081+// the INTER sub-8x8 split4 path read on a 4:2:2 frame (ss 1,0) -- one per
2082+// non-skipped odd-column piece per plane (`is_chroma_reference`'s
2083+// `mi_col & 0x01` at ss_x 1). 4:2:0 goes through the shared group unit and
2084+// 4:4:4 through [`sub8_leaf_chroma444`]'s own per-piece twin, so a witness
2085+// gate reading 0 here proves the inter 4:2:2 per-piece arm never ran.
2086+thread_local! {
2087+ static CHROMA422_INTER_SUB8_HITS: std::cell::Cell<usize> =
2088+ const { std::cell::Cell::new(0) };
2089+}
2090+
2091+/// Current value of [`CHROMA422_INTER_SUB8_HITS`].
2092+pub fn chroma422_inter_sub8_hits() -> usize {
2093+ CHROMA422_INTER_SUB8_HITS.with(|c| c.get())
2094+}
2095+
2096+// lane-av1-422m: how many TX_4X4 chunk units the invalid-ss-size chroma arm
2097+// read (the 8x32 luma block whose 4:2:2 plane has no `ss_size_lookup` block).
2098+// A 4:2:0 or 4:4:4 frame cannot increment it, so a non-zero read proves the
2099+// chunked 4:2:2 chroma really decoded.
2100+thread_local! {
2101+ static CHROMA422_CHUNK_HITS: std::cell::Cell<usize> =
2102+ const { std::cell::Cell::new(0) };
2103+}
2104+
2105+/// Current value of [`CHROMA422_CHUNK_HITS`].
2106+pub fn chroma422_chunk_hits() -> usize {
2107+ CHROMA422_CHUNK_HITS.with(|c| c.get())
2108+}
2109+
2001 // How many HORZ/VERT intra strips actually predicted with filter intra2110 // How many HORZ/VERT intra strips actually predicted with filter intra
2002 // (lane-rectsplit r1) -- the case `decode_block_rect` refused by name2111 // (lane-rectsplit r1) -- the case `decode_block_rect` refused by name
2003 // ("this decoder predicts square-only") until `predict_filter_intra` took2112 // ("this decoder predicts square-only") until `predict_filter_intra` took
@@ -2583,7 +2692,10 @@ impl TxParams {
2583 if self.stride == 0 {2692 if self.stride == 0 {
2584 return residual;2693 return residual;
2585 }2694 }
2586- let mut strided = vec![0i32; self.stride * self.stride];2695+ // lane-av1-422sub8rect: `h` rows of `stride` -- a rect unit whose
2696+ // height exceeds its (narrow) prediction stride needs the full
2697+ // stride * h; every square caller has h == stride and is unchanged.
2698+ let mut strided = vec![0i32; self.stride * self.h];
2587 for row in 0..self.h {2699 for row in 0..self.h {
2588 strided[row * self.stride..][..self.w]2700 strided[row * self.stride..][..self.w]
2589 .copy_from_slice(&residual[row * self.w..][..self.w]);2701 .copy_from_slice(&residual[row * self.w..][..self.w]);
@@ -8521,6 +8633,46 @@ impl Neighbours {
8521 out8633 out
8522 }8634 }
8523 8635
8636+ /// [`Self::around_mi_rect`] for the CHROMA planes of a 4:2:2 frame
8637+ /// (lane-av1-422f): libaom `get_txb_ctx_general` reads its above votes
8638+ /// over `txb_w_unit` CHROMA 4-px cells, and at ss_x 1 one chroma cell
8639+ /// spans TWO luma mi columns. Both cells of a column carry the covering
8640+ /// unit's whole-unit dc sign (the same value libaom stores), so the
8641+ /// per-luma-mi sum counts each chroma column twice -- and
8642+ /// `dc_sign_ctx`'s signum flips whenever the above and left votes have
8643+ /// opposite signs with equal magnitude (measured at mi(4,4) plane 1 of
8644+ /// the t422 fixture: ours read `dc_sign_cdf[1]`, the oracle row 0).
8645+ /// Sampling every second above cell counts each chroma column once,
8646+ /// which IS libaom's sum. The left extent is unsubsquared at ss_y 0, so
8647+ /// its per-mi cells already line up one-to-one. The level booleans are
8648+ /// ORs over duplicated cells, so the sampling cannot change them.
8649+ fn around_mi_422_chroma(
8650+ &self,
8651+ (mi_r, mi_c): (usize, usize),
8652+ w: usize,
8653+ h: usize,
8654+ ) -> [(bool, bool, i32); 3] {
8655+ let (w_mi, h_mi) = (w / MI, h / MI);
8656+ let above_mi = w_mi.min(self.mi_cols.saturating_sub(mi_c));
8657+ let left_mi = h_mi.min(self.mi_rows.saturating_sub(mi_r));
8658+ let mut out = [(false, false, 0i32); 3];
8659+ for cell in (0..above_mi).step_by(2) {
8660+ let above = &self.above[mi_c + cell];
8661+ for (plane, o) in out.iter_mut().enumerate() {
8662+ o.0 |= above[plane].level != 0;
8663+ o.2 += dc_vote(above[plane].dc);
8664+ }
8665+ }
8666+ for cell in 0..left_mi {
8667+ let left = &self.left[mi_r + cell];
8668+ for (plane, o) in out.iter_mut().enumerate() {
8669+ o.1 |= left[plane].level != 0;
8670+ o.2 += dc_vote(left[plane].dc);
8671+ }
8672+ }
8673+ out
8674+ }
8675+
8524 /// [`Self::around`] with independent above (`w`)/left (`h`) extents, in8676 /// [`Self::around`] with independent above (`w`)/left (`h`) extents, in
8525 /// pixels -- lane-rectwire, mirrors [`Self::record_rect`]'s asymmetric8677 /// pixels -- lane-rectwire, mirrors [`Self::record_rect`]'s asymmetric
8526 /// extent pattern for a true rectangular strip's own coefficient context.8678 /// extent pattern for a true rectangular strip's own coefficient context.
@@ -10177,7 +10329,15 @@ fn decode_rect_split(
10177 // A 4:4:4 64-axis strip's chroma plane block is larger than one adjusted10329 // A 4:4:4 64-axis strip's chroma plane block is larger than one adjusted
10178 // UV transform (TX_64X32 adjusts to TX_32X32). Those sizes are tiled10330 // UV transform (TX_64X32 adjusts to TX_32X32). Those sizes are tiled
10179 // below; everything else still needs a single-unit table.10331 // below; everything else still needs a single-unit table.
10180- let chroma_tiled = matches!((chroma_w, chroma_h), (64, 32) | (32, 64) | (64, 16) | (16, 64));10332+ // lane-av1-422: a 4:2:2 strip's chroma plane keeps the strip's HEIGHT and
10333+ // halves only the width, so a rect luma strip codes a SQUARE chroma block
10334+ // (16x8 luma -> 8x8 chroma) -- the square rows below. At 4:2:0 and 4:4:4 a
10335+ // rect strip's chroma is itself rect, so the square rows are unreachable
10336+ // there and cannot change their results.
10337+ let chroma_tiled = matches!(
10338+ (chroma_w, chroma_h),
10339+ (64, 32) | (32, 64) | (64, 16) | (16, 64) | (32, 32) | (16, 16) | (8, 8)
10340+ );
10181 if !m.skip {10341 if !m.skip {
10182 if let Some(i) = match (chroma_w, chroma_h) {10342 if let Some(i) = match (chroma_w, chroma_h) {
10183 (32, 8) => Some(0),10343 (32, 8) => Some(0),
@@ -10604,11 +10764,20 @@ fn decode_rect_split(
10604 (ug, vg)10764 (ug, vg)
10605 } else if chroma_tiled {10765 } else if chroma_tiled {
10606 let (uw, uh, set, scan): (usize, usize, TxbSet, &[u16]) = match (chroma_w, chroma_h) {10766 let (uw, uh, set, scan): (usize, usize, TxbSet, &[u16]) = match (chroma_w, chroma_h) {
10607- (64, 32) | (32, 64) => (32, 32, TxbSet::Chroma32, default_scan(32)),10767+ (64, 32) | (32, 64) | (32, 32) => (32, 32, TxbSet::Chroma32, default_scan(32)),
10608 (64, 16) => (32, 16, TxbSet::ChromaRect32x16, &SCAN_32X16),10768 (64, 16) => (32, 16, TxbSet::ChromaRect32x16, &SCAN_32X16),
10609 (16, 64) => (16, 32, TxbSet::ChromaRect32x16, &SCAN_16X32),10769 (16, 64) => (16, 32, TxbSet::ChromaRect32x16, &SCAN_16X32),
10770+ // lane-av1-422: the 4:2:2 square chroma planes (height unhalved),
10771+ // through the square reader like every other square chroma unit.
10772+ (16, 16) => (16, 16, TxbSet::Chroma16, default_scan(16)),
10773+ (8, 8) => (8, 8, TxbSet::Chroma8, default_scan(8)),
10610 _ => unreachable!("chroma_tiled"),10774 _ => unreachable!("chroma_tiled"),
10611 };10775 };
10776+ // lane-av1-422: the witness counter, keyed to ss (1,0) so only a 4:2:2
10777+ // frame's square chroma units count it.
10778+ if uw == uh && ss_x(fctx) == 1 && ss_y(fctx) == 0 {
10779+ hit!(CHROMA422_SQUARE_HITS);
10780+ }
10612 let (nw, nh) = (chroma_w / uw, chroma_h / uh);10781 let (nw, nh) = (chroma_w / uw, chroma_h / uh);
10613 let bigger = chroma_w * chroma_h > uw * uh;10782 let bigger = chroma_w * chroma_h > uw * uh;
10614 let default_tx = TxType::DctDct;10783 let default_tx = TxType::DctDct;
@@ -10636,6 +10805,20 @@ fn decode_rect_split(
10636 ),10805 ),
10637 )10806 )
10638 });10807 });
10808+ // lane-av1-422kf: the palette colour map is consumed per
10809+ // unit here like every other chroma arm (`av1_visit_palette`
10810+ // feeds the whole plane block; window it to this unit).
10811+ // Without this the square chroma rows decoded a uv-palette
10812+ // strip's chroma as plain DC (class same-symbols-silent-
10813+ // prediction: the rng stayed in sync, only the prediction
10814+ // was dropped).
10815+ if let Some((ub, vb)) = &m.palette_uv {
10816+ let buf = if plane_idx == 1 { ub } else { vb };
10817+ set_palette_pred(
10818+ palette_window(buf, chroma_w, cu_col * uw, cu_row * uh, uw, uh),
10819+ fctx,
10820+ );
10821+ }
10639 // 32x32 does not fit read_coeffs_rect's scratch (768). The10822 // 32x32 does not fit read_coeffs_rect's scratch (768). The
10640 // square reader is the path every other 32x32 chroma unit uses.10823 // square reader is the path every other 32x32 chroma unit uses.
10641 let levels = if uw == uh {10824 let levels = if uw == uh {
@@ -12635,6 +12818,16 @@ fn decode_block_rect(
12635 (16, 32) => (TxbSet::ChromaRect32x16, &SCAN_16X32),12818 (16, 32) => (TxbSet::ChromaRect32x16, &SCAN_16X32),
12636 (16, 8) => (TxbSet::ChromaRect16x8, &SCAN_16X8),12819 (16, 8) => (TxbSet::ChromaRect16x8, &SCAN_16X8),
12637 (8, 16) => (TxbSet::ChromaRect16x8, &SCAN_8X16),12820 (8, 16) => (TxbSet::ChromaRect16x8, &SCAN_8X16),
12821+ // lane-av1-422: a 4:2:2 strip halves only the width. A 32x16
12822+ // luma strip's chroma is a 16x16 SQUARE (`TxbSet::Chroma16`, the
12823+ // set any 16x16 chroma plane reads); a 16x32 strip's chroma is
12824+ // 8x32, whose entropy set is the 16x16 one and whose DCT-only
12825+ // default follows the >=32 rule below -- the same pairing the
12826+ // (8,32) row of [`decode_rect_split`]'s chroma table proves. At
12827+ // 4:2:0 and 4:4:4 a strip's chroma is itself rect, so neither row
12828+ // is reachable there.
12829+ (16, 16) => (TxbSet::Chroma16, default_scan(16)),
12830+ (8, 32) => (TxbSet::Chroma16, &SCAN_8X32),
12638 _ => {12831 _ => {
12639 return Err(unsupported(12832 return Err(unsupported(
12640 "a rectangular chroma transform whose size has no coefficient table",12833 "a rectangular chroma transform whose size has no coefficient table",
@@ -12846,7 +13039,9 @@ fn decode_block_rect(
12846 /// caller uses once, after both strips, exactly like the `VERT_B` arm next13039 /// caller uses once, after both strips, exactly like the `VERT_B` arm next
12847 /// to it). The non-skip case (lane-rectx) reads real `TX_16X8`/`TX_8X16`13040 /// to it). The non-skip case (lane-rectx) reads real `TX_16X8`/`TX_8X16`
12848 /// luma coefficients (`TxbSet::LumaRect16x8`) and their `TX_8X4`/`TX_4X8`13041 /// luma coefficients (`TxbSet::LumaRect16x8`) and their `TX_8X4`/`TX_4X8`
12849-/// chroma half (`TxbSet::ChromaRect8x4`), the two size classes one level13042+/// chroma half (`TxbSet::ChromaRect8x4`) at 4:2:0 -- an 8x8 *square* chroma
13043+/// plane (`TxbSet::Chroma8` + the default scan) at 4:2:2 (lane-av1-422e:
13044+/// half-width, unhalved height), the two size classes one level
12850 /// under [`decode_block_rect`]'s own 32x16/16x32 strip.13045 /// under [`decode_block_rect`]'s own 32x16/16x32 strip.
12851 #[allow(clippy::too_many_arguments)]13046 #[allow(clippy::too_many_arguments)]
12852 fn decode_leaf_rect(13047 fn decode_leaf_rect(
@@ -13102,14 +13297,28 @@ fn decode_leaf_rect(
13102 // `use_reduced_set` branch returns `EXT_TX_SET_DTT4_IDTX` at13297 // `use_reduced_set` branch returns `EXT_TX_SET_DTT4_IDTX` at
13103 // `tx_size_sqr_up == TX_16X16` regardless of the true, non-square13298 // `tx_size_sqr_up == TX_16X16` regardless of the true, non-square
13104 // `tx_size`) and its chroma half (8x4/4x8, `TxbSet::ChromaRect8x4`).13299 // `tx_size`) and its chroma half (8x4/4x8, `TxbSet::ChromaRect8x4`).
13300+ // lane-av1-422e: a 4:2:2 strip halves only the width, so the chroma
13301+ // half of a 16x8/8x16 luma leaf is an 8x8 SQUARE (`TxbSet::Chroma8` +
13302+ // the default scan -- the pairing any 8x8 chroma plane reads). 4:2:0
13303+ // halves both axes (8x4/4x8 rect, `TxbSet::ChromaRect8x4`); 4:4:4
13304+ // leaves the full 16x8/8x16 rect (`TxbSet::ChromaRect16x8`).
13305+ let chroma_422 = ss_x(fctx) == 1 && ss_y(fctx) == 0;
13105 let (luma_scan, chroma_scan): (&[u16], &[u16]) = if ss_x(fctx) == 0 {13306 let (luma_scan, chroma_scan): (&[u16], &[u16]) = if ss_x(fctx) == 0 {
13106 if bw == 16 { (&SCAN_16X8, &SCAN_16X8) } else { (&SCAN_8X16, &SCAN_8X16) }13307 if bw == 16 { (&SCAN_16X8, &SCAN_16X8) } else { (&SCAN_8X16, &SCAN_8X16) }
13308+ } else if chroma_422 {
13309+ if bw == 16 { (&SCAN_16X8, default_scan(8)) } else { (&SCAN_8X16, default_scan(8)) }
13107 } else if bw == 16 {13310 } else if bw == 16 {
13108 (&SCAN_16X8, &SCAN_8X4)13311 (&SCAN_16X8, &SCAN_8X4)
13109 } else {13312 } else {
13110 (&SCAN_8X16, &SCAN_4X8)13313 (&SCAN_8X16, &SCAN_4X8)
13111 };13314 };
13112- let chroma_rect_set = if ss_x(fctx) == 0 { TxbSet::ChromaRect16x8 } else { TxbSet::ChromaRect8x4 };13315+ let chroma_rect_set = if ss_x(fctx) == 0 {
13316+ TxbSet::ChromaRect16x8
13317+ } else if chroma_422 {
13318+ TxbSet::Chroma8
13319+ } else {
13320+ TxbSet::ChromaRect8x4
13321+ };
13113 let around = neighbours.around_mi_rect(leaf_mi, bw, bh);13322 let around = neighbours.around_mi_rect(leaf_mi, bw, bh);
13114 let luma_set = if reduced_tx_set {13323 let luma_set = if reduced_tx_set {
13115 TxbSet::LumaRect16x813324 TxbSet::LumaRect16x8
@@ -13478,12 +13687,43 @@ fn decode_block_rect4(
13478 // `TxbSet::Chroma16`). The caller set is closed -- this reader only13687 // `TxbSet::Chroma16`). The caller set is closed -- this reader only
13479 // ever sees 32x8 / 8x32 luma and the sequence header admits ss 0/013688 // ever sees 32x8 / 8x32 luma and the sequence header admits ss 0/0
13480 // and 1/1 only -- so the table is exhaustive.13689 // and 1/1 only -- so the table is exhaustive.
13690+ let chroma422_rect32 =
13691+ (chroma_w, chroma_h) == (4, 32) && ss_x(fctx) == 1 && ss_y(fctx) == 0;
13481 let (chroma_set, chroma_scan): (TxbSet, &[u16]) = match (chroma_w, chroma_h) {13692 let (chroma_set, chroma_scan): (TxbSet, &[u16]) = match (chroma_w, chroma_h) {
13482 (16, 4) => (TxbSet::Chroma8, &SCAN_16X4[..]),13693 (16, 4) => (TxbSet::Chroma8, &SCAN_16X4[..]),
13483 (4, 16) => (TxbSet::Chroma8, &SCAN_4X16[..]),13694 (4, 16) => (TxbSet::Chroma8, &SCAN_4X16[..]),
13484 (32, 8) => (TxbSet::Chroma16, &SCAN_32X8[..]),13695 (32, 8) => (TxbSet::Chroma16, &SCAN_32X8[..]),
13485 (8, 32) => (TxbSet::Chroma16, &SCAN_8X32[..]),13696 (8, 32) => (TxbSet::Chroma16, &SCAN_8X32[..]),
13486- _ => unreachable!("decode_block_rect4 chroma shape set is closed"),13697+ // lane-av1-422: a 4:2:2 1:4 strip halves only the width, so the
13698+ // landscape leaves (32x8, 16x4 luma) code their chroma as the RECT
13699+ // (16,8)/(8,4) -- the same TxbSet/scan pair the (16,8)/(8,4) rows of
13700+ // [`decode_rect_split`]'s chroma table use.
13701+ // lane-av1-422p: the PORTRAIT leaf occurs too -- the pinned
13702+ // fixture's frame 2 carries an 8x32 strip at ss(1,0), whose (4, 32)
13703+ // chroma block `ss_size_lookup[BLOCK_8X32][1][0]` marks
13704+ // BLOCK_INVALID (255, enums.h). BLOCK_INVALID does not mean
13705+ // "uncodable": `av1_get_tx_size` reads `max_txsize_rect_lookup[255]`
13706+ // OUT OF BOUNDS there, the byte at +255 in the pinned Release oracle
13707+ // is 0x05 = TX_4X8 (the `decode_token_recon_block` copy at
13708+ // 0xc0d030, objdump-measured), and `av1_get_adjusted_tx_size` has no
13709+ // TX_4X8 case. libaom HAS the transform, so the shape CHUNKS (the
13710+ // `chroma422_rect32` arm below) into FOUR stacked TX_4X8 units per
13711+ // plane (`tx_size_high_unit[TX_4X8] = 2`: blk_row 0, 2, 4, 6)
13712+ // instead of refusing; no coefficient-table row is added, because
13713+ // BLOCK_4X32 is not a table libaom has. 4:2:0 and 4:4:4 never land
13714+ // here (their 8x32 strips read (4, 16) and (8, 32)), so the row is
13715+ // 4:2:2-only.
13716+ (16, 8) => (TxbSet::ChromaRect16x8, &SCAN_16X8[..]),
13717+ (8, 4) => (TxbSet::ChromaRect8x4, &SCAN_8X4[..]),
13718+ // lane-av1-422p: the units' own set/scan -- the whole-rect read
13719+ // below never sees this row, the `chroma422_rect32` arm chunks
13720+ // first. Anything else is still a named-lane gap.
13721+ (4, 32) if ss_x(fctx) == 1 && ss_y(fctx) == 0 => {
13722+ (TxbSet::ChromaRect8x4, &SCAN_4X8[..])
13723+ }
13724+ _ => unreachable!(
13725+ "decode_block_rect4 chroma shape set is closed: {chroma_w}x{chroma_h}"
13726+ ),
13487 };13727 };
13488 let luma_scan: &[u16] = if bw > bh { &SCAN_32X8 } else { &SCAN_8X32 };13728 let luma_scan: &[u16] = if bw > bh { &SCAN_32X8 } else { &SCAN_8X32 };
13489 let (luma_levels, u_levels, v_levels) = if skip {13729 let (luma_levels, u_levels, v_levels) = if skip {
@@ -13492,6 +13732,146 @@ fn decode_block_rect4(
13492 vec![0i32; chroma_w * chroma_h],13732 vec![0i32; chroma_w * chroma_h],
13493 vec![0i32; chroma_w * chroma_h],13733 vec![0i32; chroma_w * chroma_h],
13494 )13734 )
13735+ } else if chroma422_rect32 {
13736+ // lane-av1-422p: the (4, 32) plane as FOUR TX_4X8 units per plane,
13737+ // plane-major (every U unit, then every V) -- the walk the pinned
13738+ // oracle's `decode_token_recon_block` makes for the BLOCK_INVALID
13739+ // plane block: TX_4X8, so stepr = `tx_size_high_unit[TX_4X8]` = 2
13740+ // 4-px rows and stepc = 1, unit rows at chroma y 0, 8, 16, 24.
13741+ // Luma is the same single TX_8X32 rect the general arm reads.
13742+ let around = neighbours.around_mi_rect((mi_r, mi_c), bw, bh);
13743+ let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x8, mode);
13744+ let (luma_levels, luma_tx_type) = read_coeffs_rect(
13745+ dec,
13746+ &mut luma_coding,
13747+ luma_scan,
13748+ bw,
13749+ bh,
13750+ 0,
13751+ dc_sign_ctx(around[0].2),
13752+ TxType::DctDct,
13753+ )?;
13754+ hit!(RECT4_COEFF_HITS);
13755+ let luma_residual = dequant_and_inverse_typed_wh(
13756+ &luma_levels,
13757+ bw,
13758+ bh,
13759+ crate::decode::bit_depth(fctx),
13760+ block_q_idx(fctx),
13761+ plane_q_delta(0, fctx).0,
13762+ plane_q_delta(0, fctx).1,
13763+ luma_tx_type,
13764+ block_iqmatrix(fctx, 0, bw, bh, luma_tx_type),
13765+ );
13766+ if let Some(b) = &palette_y_buf {
13767+ set_palette_pred(b.clone(), fctx);
13768+ }
13769+ push_intra_rect(0,
13770+ px,
13771+ py,
13772+ bw,
13773+ bh,
13774+ mode,
13775+ angle_delta_y,
13776+ reach,
13777+ &luma_residual,
13778+ None,
13779+ filter_intra,
13780+ smooth_neighbor, fctx,
13781+ );
13782+ // CfL parameters are computed ONCE per block over the strip's luma
13783+ // (`are_parameters_computed`) and shared by all four units, as in
13784+ // every other chunk arm.
13785+ let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh));
13786+ let mut unit_grids: Vec<((usize, usize), usize, Grid)> = Vec::new();
13787+ for (plane, buf) in [(1usize, &mut *u), (2usize, &mut *v)] {
13788+ for unit_row in 0..4usize {
13789+ let unit_mi = (mi_r + unit_row * 2, mi_c);
13790+ let unit_reach = tu_reach_rect(
13791+ bw, bh, 0, unit_row * 8, 8, 8, reach,
13792+ px, py, y.width, y.height, fctx,
13793+ );
13794+ if let Some((ub, vb)) = &palette_uv_bufs {
13795+ let pbuf = if plane == 1 { ub } else { vb };
13796+ set_palette_pred(
13797+ palette_window(pbuf, chroma_w, 0, unit_row * 8, 4, 8),
13798+ fctx,
13799+ );
13800+ }
13801+ // Each unit is read and recorded IMMEDIATELY: unit row 0's
13802+ // `txb_skip_ctx` still sees the real above/left neighbour
13803+ // states, a lower unit sees this block's own upper unit's
13804+ // (libaom's per-unit `set_entropy_context`), and the lower
13805+ // unit predicts off the upper one's reconstructed samples.
13806+ let chroma_around = neighbours.around_mi_422_chroma(unit_mi, 8, 8);
13807+ let unit_grid = read_rect_chroma_unit(
13808+ dec,
13809+ cdfs,
13810+ TxbSet::ChromaRect8x4,
13811+ &SCAN_4X8,
13812+ 4,
13813+ 8,
13814+ plane,
13815+ chroma_around[plane],
13816+ uv_predict_mode,
13817+ angle_delta_uv,
13818+ unit_reach,
13819+ buf,
13820+ cpx,
13821+ cpy + unit_row * 8,
13822+ base_q_idx,
13823+ // `get_txb_ctx_general`'s chroma branch
13824+ // (txb_common.h): plane_bsize is BLOCK_INVALID (255)
13825+ // here, `num_pels_log2_lookup[255]` = 255 (the +255
13826+ // byte of the decodetxb copy at 0xc0de70,
13827+ // objdump-measured) exceeds `BLOCK_4X8`'s 5, so the
13828+ // ctx_offset is 10 -- the port's offset-7-first
13829+ // `txb_skip_chroma_8` stores the offset-10 rows at
13830+ // rows 3..6, hence +3.
13831+ Some(3),
13832+ alpha
13833+ .zip(ac)
13834+ .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),
13835+ smooth_neighbor_uv, fctx,
13836+ )?;
13837+ neighbours.record_mi_chroma(unit_mi, 8, 8, plane, &unit_grid);
13838+ unit_grids.push((unit_mi, plane, unit_grid));
13839+ }
13840+ }
13841+ // The whole-block stamp rewrites the chroma cells ONE state wide,
13842+ // which would erase the unit boundary the next block reads (class
13843+ // `override-slot-on-one-arm`), so it carries zero chroma grids and
13844+ // the per-unit writes replay after it. Its luma cells and side
13845+ // spans are this arm's own bookkeeping.
13846+ let zero_chroma = vec![0i32; chroma_w * chroma_h];
13847+ neighbours.record_mi_rect(
13848+ (mi_r, mi_c),
13849+ bw,
13850+ bh,
13851+ &[&luma_levels[..], &zero_chroma[..], &zero_chroma[..]],
13852+ );
13853+ for (unit_mi, plane, grid) in &unit_grids {
13854+ neighbours.record_mi_chroma(*unit_mi, 8, 8, *plane, grid);
13855+ }
13856+ neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip);
13857+ neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0, fctx);
13858+ record_strip_palette(
13859+ neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size,
13860+ pal_uv_colors,
13861+ );
13862+ if bw > bh {
13863+ hit!(RECT4_32_HORZ_HITS);
13864+ } else {
13865+ hit!(RECT4_32_VERT_HITS);
13866+ }
13867+ // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm,
13868+ // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter
13869+ // frame, so this 1:4 strip -- which is also the INTER frame's reader
13870+ // for 32x8/8x32 ([`decode_intra_rect4_in_inter`]) -- publishes its
13871+ // transform size in both TXFM_CONTEXT bands. Without it the next block
13872+ // reads the row's stale value.
13873+ txfm_partition_update_rect(neighbours, (mi_r, mi_c), (bw, bh), (bw, bh));
13874+ return Ok((mode, uv_predict_mode));
13495 } else {13875 } else {
13496 let around = neighbours.around_mi_rect((mi_r, mi_c), bw, bh);13876 let around = neighbours.around_mi_rect((mi_r, mi_c), bw, bh);
13497 let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x8, mode);13877 let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x8, mode);
@@ -13640,38 +14020,77 @@ fn decode_block_rect4(
13640 smooth_neighbor, fctx,14020 smooth_neighbor, fctx,
13641 );14021 );
13642 let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh));14022 let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh));
13643- if let Some((ub, _)) = &palette_uv_bufs {14023+ if chroma422_rect32 {
13644- set_palette_pred(ub.clone(), fctx);14024+ // lane-av1-422p: `predict_and_reconstruct_intra_block` (decodeframe.c
13645- }14025+ // ~1000) predicts EVERY unit regardless of `skip_txfm`, so the skip
13646- push_intra_rect(1, 14026+ // arm walks the same four TX_4X8 units per plane -- the lower unit
13647- cpx,14027+ // predicts off the upper one's predicted samples. No coefficients
13648- cpy,14028+ // are coded; the tail's whole-block zero stamp below is the state
13649- chroma_w,14029+ // libaom's `set_entropy_context` leaves.
13650- chroma_h,14030+ for (plane, _buf) in [(1usize, &mut *u), (2usize, &mut *v)] {
13651- uv_predict_mode,14031+ for unit_row in 0..4usize {
13652- angle_delta_uv,14032+ let unit_reach = tu_reach_rect(
13653- reach,14033+ bw, bh, 0, unit_row * 8, 8, 8, reach,
13654- &u_levels,14034+ px, py, y.width, y.height, fctx,
13655- alpha.zip(ac).map(|((au, _), ac)| (au, ac)),14035+ );
13656- None,14036+ if let Some((ub, vb)) = &palette_uv_bufs {
13657- smooth_neighbor_uv, fctx,14037+ let pbuf = if plane == 1 { ub } else { vb };
13658- );14038+ set_palette_pred(
13659- if let Some((_, vb)) = &palette_uv_bufs {14039+ palette_window(pbuf, chroma_w, 0, unit_row * 8, 4, 8),
13660- set_palette_pred(vb.clone(), fctx);14040+ fctx,
14041+ );
14042+ }
14043+ push_intra_rect(plane,
14044+ cpx,
14045+ cpy + unit_row * 8,
14046+ 4,
14047+ 8,
14048+ uv_predict_mode,
14049+ angle_delta_uv,
14050+ unit_reach,
14051+ &ZERO_RESIDUAL[..4 * 8],
14052+ alpha
14053+ .zip(ac)
14054+ .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),
14055+ None,
14056+ smooth_neighbor_uv, fctx,
14057+ );
14058+ }
14059+ }
14060+ } else {
14061+ if let Some((ub, _)) = &palette_uv_bufs {
14062+ set_palette_pred(ub.clone(), fctx);
14063+ }
14064+ push_intra_rect(1,
14065+ cpx,
14066+ cpy,
14067+ chroma_w,
14068+ chroma_h,
14069+ uv_predict_mode,
14070+ angle_delta_uv,
14071+ reach,
14072+ &u_levels,
14073+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
14074+ None,
14075+ smooth_neighbor_uv, fctx,
14076+ );
14077+ if let Some((_, vb)) = &palette_uv_bufs {
14078+ set_palette_pred(vb.clone(), fctx);
14079+ }
14080+ push_intra_rect(2,
14081+ cpx,
14082+ cpy,
14083+ chroma_w,
14084+ chroma_h,
14085+ uv_predict_mode,
14086+ angle_delta_uv,
14087+ reach,
14088+ &v_levels,
14089+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
14090+ None,
14091+ smooth_neighbor_uv, fctx,
14092+ );
13661 }14093 }
13662- push_intra_rect(2,
13663- cpx,
13664- cpy,
13665- chroma_w,
13666- chroma_h,
13667- uv_predict_mode,
13668- angle_delta_uv,
13669- reach,
13670- &v_levels,
13671- alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
13672- None,
13673- smooth_neighbor_uv, fctx,
13674- );
13675 neighbours.record_mi_rect((mi_r, mi_c), bw, bh, &[&luma_levels[..], &u_levels[..], &v_levels[..]]);14094 neighbours.record_mi_rect((mi_r, mi_c), bw, bh, &[&luma_levels[..], &u_levels[..], &v_levels[..]]);
13676 neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip);14095 neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip);
13677 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0, fctx);14096 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0, fctx);
@@ -13752,7 +14171,17 @@ fn decode_rect4_16(
13752 // lane-av1-444: at 4:4:4 every strip is its own chroma reference14171 // lane-av1-444: at 4:4:4 every strip is its own chroma reference
13753 // (no mi-parity test at ss 0/0, and the strip's own chroma block is14172 // (no mi-parity test at ss 0/0, and the strip's own chroma block is
13754 // already >= 4x4) -- there is no 4:2:0 pair to close.14173 // already >= 4x4) -- there is no 4:2:0 pair to close.
13755- let has_chroma = i % 2 == 1 || (ss_x(fctx) == 0 && ss_y(fctx) == 0);14174+ // lane-av1-422o: the parity rule is per axis, straight out of
14175+ // `is_chroma_reference`: a HORZ 16x4 strip (1 mi tall) keeps the
14176+ // `ss_y == 0 -> every strip a reference` row rule, but a VERT 4x16
14177+ // strip (1 mi wide) keeps the COLUMN clause `(mi_col & 1) || !(bw &
14178+ // 1) || !ss_x`, which with bw == 1 mi reduces to `mi_col odd` for
14179+ // every ss_x == 1 format -- the ODD strip closes the pair and reads
14180+ // the chroma, exactly like 4:2:0. (VERT_4 partitions start on an
14181+ // even mi_col, so `i % 2 == 1` is that clause.)
14182+ let has_chroma = i % 2 == 1
14183+ || (horz && ss_y(fctx) == 0)
14184+ || (!horz && ss_x(fctx) == 0);
13756 let (mode, uv, _tx) = decode_rect4_16_strip(14185 let (mode, uv, _tx) = decode_rect4_16_strip(
13757 dec,14186 dec,
13758 cdfs,14187 cdfs,
@@ -14654,6 +15083,19 @@ fn decode_rect4_16_strip(
14654 // ss 0/0, so the neighbour reads below anchor at the strip.)15083 // ss 0/0, so the neighbour reads below anchor at the strip.)
14655 let (pair_mi, pw, ph) = if ss_x(fctx) == 0 && ss_y(fctx) == 0 {15084 let (pair_mi, pw, ph) = if ss_x(fctx) == 0 && ss_y(fctx) == 0 {
14656 (lmi, bw, bh)15085 (lmi, bw, bh)
15086+ } else if ss_y(fctx) == 0 && horz {
15087+ // lane-av1-422: chroma height is NOT subsampled, so a HORZ
15088+ // 16x4 strip is its own chroma reference (`is_chroma_reference`
15089+ // at ss(1,0): bh == 1 mi, so the row clause reduces to
15090+ // `!ss_y`) and codes its own `ss_size_lookup[BLOCK_16X4][1][0]`
15091+ // = BLOCK_8X4 chroma block -- a valid transform, no pair.
15092+ // (lane-av1-422o: a VERTICAL 4x16 strip now falls through to
15093+ // the pair merge below -- its own chroma block
15094+ // `ss_size_lookup[BLOCK_4X16][1][0]` is BLOCK_INVALID, the
15095+ // walk proved such leaves exist, and libaom codes the pair's
15096+ // chroma from the closing strip; the chunk lives in the
15097+ // `chroma422_pair16` arm below.)
15098+ (lmi, bw, bh)
14657 } else if horz {15099 } else if horz {
14658 ((lmi.0 - 1, lmi.1), 16, 8)15100 ((lmi.0 - 1, lmi.1), 16, 8)
14659 } else {15101 } else {
@@ -14662,6 +15104,19 @@ fn decode_rect4_16_strip(
14662 let (ppx, ppy) = (pair_mi.1 * MI, pair_mi.0 * MI);15104 let (ppx, ppy) = (pair_mi.1 * MI, pair_mi.0 * MI);
14663 let (cpx, cpy) = (ppx >> ss_x(fctx), ppy >> ss_y(fctx));15105 let (cpx, cpy) = (ppx >> ss_x(fctx), ppy >> ss_y(fctx));
14664 let (cw, ch) = (pw >> ss_x(fctx), ph >> ss_y(fctx));15106 let (cw, ch) = (pw >> ss_x(fctx), ph >> ss_y(fctx));
15107+ // lane-av1-422o: the 4:2:2 pair's chroma of a VERT 4x16 strip
15108+ // pair: (4, 16) at ss(1,0). The bsize is still BLOCK_4X16, whose
15109+ // `ss_size_lookup[..][1][0]` is BLOCK_INVALID, so libaom's
15110+ // `av1_get_tx_size` reads `max_txsize_rect_lookup[255]` -- the
15111+ // out-of-bounds byte is TX_4X8 in the pinned Release oracle, and
15112+ // `av1_get_adjusted_tx_size` has no TX_4X8 case to adjust it.
15113+ // `decode_token_recon_block` walks unit_width =
15114+ // ROUND_POWER_OF_TWO(1, 1) = 1, unit_height = 4, with stepr =
15115+ // tx_size_high_unit[TX_4X8] = 2: TWO TX_4X8 units per plane
15116+ // (chroma rows 0..8 and 8..16), plane-major. Even the skip arm
15117+ // walks per unit: `predict_and_reconstruct_intra_block` predicts
15118+ // every unit regardless of `skip_txfm`.
15119+ let chroma422_pair16 = (cw, ch) == (4, 16) && ss_x(fctx) == 1;
14665 let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };15120 let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
14666 if (V_PRED..=D67_PRED).contains(&uv_predict_mode) {15121 if (V_PRED..=D67_PRED).contains(&uv_predict_mode) {
14667 hit!(RECT4_16_CHROMA_DIR_HITS);15122 hit!(RECT4_16_CHROMA_DIR_HITS);
@@ -14812,6 +15267,41 @@ fn decode_rect4_16_strip(
14812 hit!(CHROMA_SKIP_CFL_HITS);15267 hit!(CHROMA_SKIP_CFL_HITS);
14813 }15268 }
14814 for (_buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] {15269 for (_buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] {
15270+ if chroma422_pair16 {
15271+ // lane-av1-422o: two TX_4X8 units, each predicted on
15272+ // its own edges (the lower one off the upper one's
15273+ // samples); no coefficients are coded, and libaom's
15274+ // `set_entropy_context` zeroed the block's own cells,
15275+ // so the pair-wide zero stamp below stays correct.
15276+ for unit_row in 0..2usize {
15277+ let unit_reach = tu_reach_rect(
15278+ pw, ph, 0, unit_row * 8, 8, 8, pair_reach,
15279+ ppx, ppy, y.width, y.height, fctx,
15280+ );
15281+ if let Some((ub, vb)) = &palette_uv_bufs {
15282+ let pbuf = if plane == 1 { ub } else { vb };
15283+ set_palette_pred(
15284+ palette_window(pbuf, cw, 0, unit_row * 8, 4, 8),
15285+ fctx,
15286+ );
15287+ }
15288+ push_intra_rect(plane,
15289+ cpx,
15290+ cpy + unit_row * 8,
15291+ 4,
15292+ 8,
15293+ uv_predict_mode,
15294+ angle_delta_uv,
15295+ unit_reach,
15296+ &ZERO_RESIDUAL[..4 * 8],
15297+ alpha
15298+ .zip(ac)
15299+ .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),
15300+ None,
15301+ smooth_neighbor_uv, fctx,
15302+ );
15303+ }
15304+ } else {
14815 if let Some((ub, vb)) = &palette_uv_bufs {15305 if let Some((ub, vb)) = &palette_uv_bufs {
14816 set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }, fctx);15306 set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }, fctx);
14817 }15307 }
@@ -14830,8 +15320,76 @@ fn decode_rect4_16_strip(
14830 None,15320 None,
14831 smooth_neighbor_uv, fctx,15321 smooth_neighbor_uv, fctx,
14832 );15322 );
15323+ }
14833 }15324 }
14834 (zeros.clone(), zeros)15325 (zeros.clone(), zeros)
15326+ } else if chroma422_pair16 {
15327+ // lane-av1-422o: the pair's 4x16 chroma as TWO TX_4X8 units
15328+ // per plane, plane-major (every U unit, then every V). Each
15329+ // unit: the `ChromaRect8x4` tables (`get_txsize_entropy_ctx`
15330+ // squares TX_4X8 up to the 8x8 class), `SCAN_4X8`, and a
15331+ // `txb_skip_ctx` of above+left in the OFFSET-10 rows -- the
15332+ // offset comes from `num_pels_log2_lookup[plane_bsize] >
15333+ // num_pels_log2_lookup[BLOCK_4X8]` with plane_bsize =
15334+ // BLOCK_INVALID (255), and the byte at that table's +255 in
15335+ // the pinned Release oracle is 255 (`cmpb` against the
15336+ // `0xc0db70` copy decodetxb.c links), i.e. the bigger-plane
15337+ // arm: +3 on the offset-7-first chroma tables. No tx_type
15338+ // symbol (only y plane's is transmitted); the unit's type is
15339+ // `intra_mode_to_tx_type(UV mode)` kept by the all-16 ext-tx
15340+ // set -- [`read_rect_chroma_unit`]'s own default. CfL params
15341+ // are computed ONCE per block (`are_parameters_computed`)
15342+ // over the pair's luma, shared by both units. Each unit is
15343+ // predicted and recorded immediately, so the lower unit
15344+ // reads the upper one's coefficient context.
15345+ let ac = alpha.map(|_| cfl_src_rect(ppx, ppy, pw, ph));
15346+ for (plane, buf) in [(1usize, &mut *u), (2usize, &mut *v)] {
15347+ for unit_row in 0..2usize {
15348+ let unit_mi = (pair_mi.0 + unit_row * 2, pair_mi.1);
15349+ let unit_reach = tu_reach_rect(
15350+ pw, ph, 0, unit_row * 8, 8, 8, pair_reach,
15351+ ppx, ppy, y.width, y.height, fctx,
15352+ );
15353+ if let Some((ub, vb)) = &palette_uv_bufs {
15354+ let pbuf = if plane == 1 { ub } else { vb };
15355+ set_palette_pred(
15356+ palette_window(pbuf, cw, 0, unit_row * 8, 4, 8),
15357+ fctx,
15358+ );
15359+ }
15360+ let chroma_around = neighbours.around_mi_422_chroma(unit_mi, 8, 8);
15361+ let unit_grid = read_rect_chroma_unit(
15362+ dec,
15363+ cdfs,
15364+ TxbSet::ChromaRect8x4,
15365+ &SCAN_4X8,
15366+ 4,
15367+ 8,
15368+ plane,
15369+ chroma_around[plane],
15370+ uv_predict_mode,
15371+ angle_delta_uv,
15372+ unit_reach,
15373+ buf,
15374+ cpx,
15375+ cpy + unit_row * 8,
15376+ base_q_idx,
15377+ // lane-av1-422q: the offset-10 rows -- the same
15378+ // measured rule as the 4x32 arm (plane_bsize
15379+ // BLOCK_INVALID for the pair's BLOCK_4X16 too;
15380+ // num_pels_log2_lookup[255] = 0xff at the
15381+ // 0xc0de70 copy -> +3 on the offset-7-first
15382+ // chroma tables; see lanes/av1422q.report.md).
15383+ Some(3),
15384+ alpha
15385+ .zip(ac)
15386+ .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),
15387+ smooth_neighbor_uv, fctx,
15388+ )?;
15389+ neighbours.record_mi_chroma(unit_mi, 8, 8, plane, &unit_grid);
15390+ }
15391+ }
15392+ (Grid::Zero(cw * ch), Grid::Zero(cw * ch))
14835 } else {15393 } else {
14836 let around = neighbours.around_mi_rect(pair_mi, pw, ph);15394 let around = neighbours.around_mi_rect(pair_mi, pw, ph);
14837 // lane-av1-444: the strip's own 16x4 / 4x16 chroma at ss 0/015395 // lane-av1-444: the strip's own 16x4 / 4x16 chroma at ss 0/0
@@ -14841,7 +15399,25 @@ fn decode_rect4_16_strip(
14841 (8, 4) => (TxbSet::ChromaRect8x4, &SCAN_8X4[..]),15399 (8, 4) => (TxbSet::ChromaRect8x4, &SCAN_8X4[..]),
14842 (4, 8) => (TxbSet::ChromaRect8x4, &SCAN_4X8[..]),15400 (4, 8) => (TxbSet::ChromaRect8x4, &SCAN_4X8[..]),
14843 (16, 4) => (TxbSet::Chroma8, &SCAN_16X4[..]),15401 (16, 4) => (TxbSet::Chroma8, &SCAN_16X4[..]),
15402+ // lane-av1-444: 4:4:4's own-strip vert chroma is (4,16)
15403+ // -- one TX_4X16. (lane-av1-422o: the 4:2:2 pair's
15404+ // (4,16) never reaches this row; `chroma422_pair16`
15405+ // intercepts it above and chunks it into TX_4X8 units.)
14844 (4, 16) => (TxbSet::Chroma8, &SCAN_4X16[..]),15406 (4, 16) => (TxbSet::Chroma8, &SCAN_4X16[..]),
15407+ // lane-av1-422: a 4:2:2 HORZ pair (16x8 luma) keeps the
15408+ // pair's height: an 8x8 SQUARE chroma block, the same
15409+ // `TxbSet::Chroma8` set any 8x8 chroma plane reads. The
15410+ // 4:2:0 pair's chroma is 8x4 and 4:4:4's is 16x4, so this
15411+ // row is unreachable there. It is also the witness arm:
15412+ // a restored `/2 chroma height` lands on (8,4) and the
15413+ // counter reads 0.
15414+ (8, 8) => {
15415+ hit!(CHROMA422_SQUARE_HITS);
15416+ (TxbSet::Chroma8, default_scan(8))
15417+ }
15418+ // lane-av1-422o: with the `chroma422_pair16` arm above,
15419+ // the (2,16) own-strip shape and the 4:4:4 shapes are the
15420+ // only residents; anything else is a named-lane gap.
14845 _ => unreachable!("decode_rect4_16_strip chroma shape set is closed"),15421 _ => unreachable!("decode_rect4_16_strip chroma shape set is closed"),
14846 };15422 };
14847 let mut planes = Vec::with_capacity(2);15423 let mut planes = Vec::with_capacity(2);
@@ -14906,7 +15482,11 @@ fn decode_rect4_16_strip(
14906 neighbours.record_uv_mode_mi(pair_mi.0, pair_mi.1, pw / MI, ph / MI, uv_predict_mode);15482 neighbours.record_uv_mode_mi(pair_mi.0, pair_mi.1, pw / MI, ph / MI, uv_predict_mode);
14907 // A lossless pair already stamped each TX_4X4 (`record_mi_chroma`).15483 // A lossless pair already stamped each TX_4X4 (`record_mi_chroma`).
14908 // The single-state rewrite below is the non-lossless TX_8X4/TX_4X8.15484 // The single-state rewrite below is the non-lossless TX_8X4/TX_4X8.
14909- if !lossless_pair {15485+ // lane-av1-422o: the chunked pair's cells are stamped PER UNIT in
15486+ // the arm above (libaom's coefficient contexts are per
15487+ // 4x4-cell); a pair-wide state would erase the unit boundary the
15488+ // next block reads.
15489+ if !lossless_pair && !chroma422_pair16 {
14910 // The chroma planes' coefficient context, over the PAIR's mi span15490 // The chroma planes' coefficient context, over the PAIR's mi span
14911 // (`decode_leaf_rect8`'s own rule: a subsampled plane's bound is15491 // (`decode_leaf_rect8`'s own rule: a subsampled plane's bound is
14912 // the luma one rounded up to its 4x4 unit).15492 // the luma one rounded up to its 4x4 unit).
@@ -15849,7 +16429,13 @@ fn read_intra_mode(
15849 (side >> ss_x(fctx), side >> ss_y(fctx)),16429 (side >> ss_x(fctx), side >> ss_y(fctx)),
15850 (ss_x(fctx), ss_y(fctx)),16430 (ss_x(fctx), ss_y(fctx)),
15851 );16431 );
15852- let map = decode_color_index_map(dec, cdfs, n, side >> ss_x(fctx), on, true);16432+ // lane-av1-422d: the chroma map's extent is the PLANE BLOCK
16433+ // `(side >> ss_x) x (side >> ss_y)` -- 4x8 at ss (1,0), not the
16434+ // square call's `(side >> ss_x)`-squared (4x4), which left a
16435+ // 16-entry map for a 32-sample unit and panicked the reconstruct.
16436+ let map = decode_color_index_map_wh(
16437+ dec, cdfs, n, side >> ss_x(fctx), side >> ss_y(fctx), on, true,
16438+ );
15853 hit!(PALETTE_UV_HITS);16439 hit!(PALETTE_UV_HITS);
15854 if trace {16440 if trace {
15855 eprintln!(16441 eprintln!(
@@ -15945,6 +16531,29 @@ fn cfl_ac_ss(
15945 let avg = (sum + num_pel / 2) >> num_pel.trailing_zeros();16531 let avg = (sum + num_pel / 2) >> num_pel.trailing_zeros();
15946 ac.iter_mut().for_each(|v| *v -= avg);16532 ac.iter_mut().for_each(|v| *v -= avg);
15947 ac16533 ac
16534+ } else if ss_x == 1 && ss_y == 0 {
16535+ // lane-av1-422: `cfl_luma_subsampling_422_lbd_c` -- each chroma sample
16536+ // averages the HORIZONTAL luma pair above it, at full chroma height
16537+ // (`(a + b) >> 1` in Q3 is `(a + b) << 2`). A rect luma strip's chroma
16538+ // is square here, and the 4:2:0 rect/square helpers below would halve
16539+ // the height it must keep.
16540+ let (cw, ch) = (bw >> 1, bh);
16541+ let mut ac = vec![0i32; cw * ch];
16542+ let mut sum = 0i32;
16543+ for row in 0..ch {
16544+ for col in 0..cw {
16545+ let (lx, ly) = (px + col * 2, py + row);
16546+ let q3 = (i32::from(y.data[ly * y.width + lx])
16547+ + i32::from(y.data[ly * y.width + lx + 1]))
16548+ << 2;
16549+ ac[row * cw + col] = q3;
16550+ sum += q3;
16551+ }
16552+ }
16553+ let num_pel = (cw * ch) as i32;
16554+ let avg = (sum + num_pel / 2) >> num_pel.trailing_zeros();
16555+ ac.iter_mut().for_each(|v| *v -= avg);
16556+ ac
15948 } else if bw == bh {16557 } else if bw == bh {
15949 cfl_ac_q3(y, px, py, bw)16558 cfl_ac_q3(y, px, py, bw)
15950 } else {16559 } else {
@@ -16619,6 +17228,110 @@ fn read_plane(
16619 Ok(levels)17228 Ok(levels)
16620 }17229 }
16621 17230
17231+/// [`push_intra`] when the unit is square, [`push_intra_rect`] when it is a
17232+/// rect (lane-av1-422f): a 4:2:2 square-block chroma unit is the plane
17233+/// block's own rect shape, and the `rect` flag selects
17234+/// [`PlaneBuf::reconstruct_rect`]'s two-dimensional loop.
17235+#[allow(clippy::too_many_arguments)]
17236+fn push_intra_unit(
17237+ plane: usize,
17238+ x: usize,
17239+ y: usize,
17240+ w: usize,
17241+ h: usize,
17242+ mode: usize,
17243+ angle_delta: i32,
17244+ reach: Reach,
17245+ residual: &[i32],
17246+ cfl: Option<(i32, CflSrc)>,
17247+ filter_intra: Option<usize>,
17248+ smooth_neighbor: bool, fctx: &crate::decode::FrameCtx,
17249+) {
17250+ if w == h {
17251+ push_intra(plane, x, y, w, mode, angle_delta, reach, residual, cfl,
17252+ filter_intra, smooth_neighbor, fctx);
17253+ } else {
17254+ push_intra_rect(plane, x, y, w, h, mode, angle_delta, reach, residual, cfl,
17255+ filter_intra, smooth_neighbor, fctx);
17256+ }
17257+}
17258+
17259+/// ONE RECT chroma transform unit of a square block's uv plane
17260+/// (lane-av1-422f) -- a 4:2:2 frame's plane block is `(side/2, side)` and
17261+/// `av1_get_max_uv_txsize` fills it with a single rect unit below side 64
17262+/// (TX_4X8 / TX_8X16 / TX_16X32), which the square-shaped [`read_plane`]
17263+/// cannot express. Same shape as [`leaf8_chroma422_unit`]'s proven read: the
17264+/// [`TxbSet`] whose entropy class the unit squares up to, the unit-shaped
17265+/// scan, `txb_skip_ctx` = above + left in the offset-7 rows (the unit covers
17266+/// the plane block exactly, so no `+3` bigger-plane term -- that one lives in
17267+/// the square multi-unit walks' `chroma_ctx_offset`), and the plane's
17268+/// predicted mode supplies the mode-derived default `tx_type` unless an armed
17269+/// [`INTRABC_CHROMA_TX`] slot carries the intrabc luma's own -- except at an
17270+/// entropy class of 32x32 and up, where the spec forces `DCT_DCT`
17271+/// ([`read_plane`]'s `side >= 32` clamp).
17272+#[allow(clippy::too_many_arguments)]
17273+fn read_rect_chroma_unit(
17274+ dec: &mut SymbolDecoder,
17275+ cdfs: &mut Cdfs,
17276+ set: TxbSet,
17277+ scan: &[u16],
17278+ w: usize,
17279+ h: usize,
17280+ plane_idx: usize,
17281+ around: (bool, bool, i32),
17282+ uv_predict_mode: usize,
17283+ angle_delta_uv: i32,
17284+ reach: Reach,
17285+ // Unread, like [`read_plane`]'s own: the borrow proves the caller holds
17286+ // the plane exclusively while the unit's coefficients are parsed.
17287+ _plane: &mut PlaneBuf<'static>,
17288+ x: usize,
17289+ y: usize,
17290+ // Signature parity with [`read_plane`]; the dequant reads its q index
17291+ // off `block_q_idx(fctx)` like every other reader here.
17292+ _base_q_idx: u8,
17293+ // lane-av1-422p: `get_txb_ctx_general`'s chroma branch
17294+ // (txb_common.h) reads `txb_skip_ctx = above + left + ctx_offset`,
17295+ // where `ctx_offset` is 10 when the plane block is bigger than the
17296+ // transform and 7 otherwise. The port stores the offset-7 rows at
17297+ // `txb_skip_chroma_8` rows 0..3 and the offset-10 rows at rows 3..6
17298+ // (lane-av1-422b), so a unit SMALLER than its plane block passes
17299+ // `Some(3)` to reach the offset-10 rows. Every unit that IS the whole
17300+ // plane block stays `None` -- 4:2:2 plane blocks never shrink to a
17301+ // rect unit except in the chunk arms.
17302+ chroma_skip_offset: Option<usize>,
17303+ cfl: Option<(i32, CflSrc)>,
17304+ smooth_neighbor_uv: bool, fctx: &crate::decode::FrameCtx,
17305+) -> Result<Grid> {
17306+ if ss_x(fctx) == 1 && ss_y(fctx) == 0 && w != h {
17307+ hit!(CHROMA422_RECT_HITS);
17308+ }
17309+ let default_tx = if w.max(h) >= 32 {
17310+ TxType::DctDct
17311+ } else {
17312+ fctx
17313+ .intrabc_chroma_tx
17314+ .with(std::cell::Cell::get)
17315+ .unwrap_or_else(|| default_intra_tx_type(uv_predict_mode as u8))
17316+ };
17317+ let mut coding = cdfs.txb(set, uv_predict_mode);
17318+ let (levels, tx_type) = read_coeffs_rect(
17319+ dec, &mut coding, scan, w, h,
17320+ usize::from(around.0) + usize::from(around.1) + chroma_skip_offset.unwrap_or(0),
17321+ dc_sign_ctx(around.2), default_tx,
17322+ )?;
17323+ let residual = dequant_and_inverse_typed_wh(
17324+ &levels, w, h, crate::decode::bit_depth(fctx), block_q_idx(fctx),
17325+ plane_q_delta(plane_idx, fctx).0, plane_q_delta(plane_idx, fctx).1,
17326+ tx_type, block_iqmatrix(fctx, plane_idx, w, h, tx_type),
17327+ );
17328+ push_intra_rect(
17329+ plane_idx, x, y, w, h, uv_predict_mode, angle_delta_uv, reach,
17330+ &residual, cfl, None, smooth_neighbor_uv, fctx,
17331+ );
17332+ Ok(levels)
17333+}
17334+
16622 /// Decodes one whole-block coded superblock/quadrant/leaf: its mode, then its17335 /// Decodes one whole-block coded superblock/quadrant/leaf: its mode, then its
16623 /// three planes, reconstructing them into `y`/`u`/`v` and updating17336 /// three planes, reconstructing them into `y`/`u`/`v` and updating
16624 /// `neighbours`.17337 /// `neighbours`.
@@ -16689,8 +17402,8 @@ fn decode_block(
16689 // rewrite (which sat above `read_intra_mode`) rides along here -- same17402 // rewrite (which sat above `read_intra_mode`) rides along here -- same
16690 // per-frame `ss_x`/`ss_y` condition, now resolved against the block's own17403 // per-frame `ss_x`/`ss_y` condition, now resolved against the block's own
16691 // segment like the lossless arm above it.17404 // segment like the lossless arm above it.
16692- let (luma_set, chroma_set, luma_tx, chroma_tx, scans) = if lossless(fctx) {17405+ let (luma_set, chroma_set, luma_tx, chroma_tx, chroma_tx_h, scans) = if lossless(fctx) {
16693- (TxbSet::Luma4, TxbSet::Chroma4, 4, 4, (scan4, scan4))17406+ (TxbSet::Luma4, TxbSet::Chroma4, 4, 4, 4, (scan4, scan4))
16694 } else if ss_x(fctx) == 0 && ss_y(fctx) == 0 {17407 } else if ss_x(fctx) == 0 && ss_y(fctx) == 0 {
16695 let tx = if side >= 64 { 32 } else { side };17408 let tx = if side >= 64 { 32 } else { side };
16696 let (set, scan): (TxbSet, &[u16]) = match tx {17409 let (set, scan): (TxbSet, &[u16]) = match tx {
@@ -16699,9 +17412,39 @@ fn decode_block(
16699 8 => (TxbSet::Chroma8, scan8),17412 8 => (TxbSet::Chroma8, scan8),
16700 _ => (TxbSet::Chroma4, scan4),17413 _ => (TxbSet::Chroma4, scan4),
16701 };17414 };
16702- (luma_set, set, luma_tx, tx, (scans.0, scan))17415+ (luma_set, set, luma_tx, tx, tx, (scans.0, scan))
17416+ } else if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
17417+ // lane-av1-422f: the uv plane block is the (side/2, side) rect
17418+ // (`ss_size_lookup[..][1][0]`), and `av1_get_max_uv_txsize` is
17419+ // `av1_get_adjusted_tx_size(max_txsize_rect_lookup[plane_bsize])` --
17420+ // the RECT that fills the plane block, NOT the square transform of
17421+ // the smaller side (the oracle reads ONE TX_8X16 for a 16x16 block's
17422+ // 8x16 plane where the old model read two 8x8 units): 4 -> TX_4X4
17423+ // (the 2x4 plane rounds up to BLOCK_4X4), 8 -> TX_4X8, 16 ->
17424+ // TX_8X16, 32 -> TX_16X32 (one unit per plane, the whole plane
17425+ // block), 64 -> TX_32X64 adjusts to TX_32X32 and 128 -> TX_64X64
17426+ // adjusts to TX_32X32 (square units, a 1x2 / 2x4 grid).
17427+ // `chroma_tx` is the unit WIDTH, `chroma_tx_h` its HEIGHT; the
17428+ // chroma walks below read one (chroma_tx, chroma_tx_h) unit per grid
17429+ // cell and key their rect reads on `chroma_tx != chroma_tx_h`.
17430+ let (tx_w, tx_h) = match side {
17431+ 4 => (4, 4),
17432+ 8 => (4, 8),
17433+ 16 => (8, 16),
17434+ 32 => (16, 32),
17435+ // 64 and 128: TX_32X64 / TX_64X64 adjust down to TX_32X32.
17436+ _ => (32, 32),
17437+ };
17438+ let (set, scan): (TxbSet, &[u16]) = match side {
17439+ 4 => (TxbSet::Chroma4, scan4),
17440+ 8 => (TxbSet::ChromaRect8x4, &SCAN_4X8[..]),
17441+ 16 => (TxbSet::ChromaRect16x8, &SCAN_8X16[..]),
17442+ 32 => (TxbSet::ChromaRect32x16, &SCAN_16X32[..]),
17443+ _ => (TxbSet::Chroma32, scan32),
17444+ };
17445+ (luma_set, set, luma_tx, tx_w, tx_h, (scans.0, scan))
16703 } else {17446 } else {
16704- (luma_set, chroma_set, luma_tx, chroma_tx, scans)17447+ (luma_set, chroma_set, luma_tx, chroma_tx, chroma_tx, scans)
16705 };17448 };
16706 let intrabc_dv = fctx.intrabc_dv.with(|c| c.take());17449 let intrabc_dv = fctx.intrabc_dv.with(|c| c.take());
16707 // `predict` panics outside `DC_PRED..=PAETH_PRED` (0..=12); `UV_CFL_PRED`17450 // `predict` panics outside `DC_PRED..=PAETH_PRED` (0..=12); `UV_CFL_PRED`
@@ -16825,6 +17568,9 @@ fn decode_block(
16825 let reach = Reach::of(side, px, py, y.width, y.height, fctx);17568 let reach = Reach::of(side, px, py, y.width, y.height, fctx);
16826 let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx));17569 let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx));
16827 let chroma_side = side >> ss_x(fctx);17570 let chroma_side = side >> ss_x(fctx);
17571+ // lane-av1-422b: chroma extent per axis, `side` at ss_y 0 (4:2:2/4:4:4),
17572+ // `side / 2` at 4:2:0.
17573+ let chroma_height = side >> ss_y(fctx);
16828 // spec 7.11.3.4 with `use_intrabc`: the reference is the *current*17574 // spec 7.11.3.4 with `use_intrabc`: the reference is the *current*
16829 // frame's own pre-loop-filter reconstruction (all loop filters are off17575 // frame's own pre-loop-filter reconstruction (all loop filters are off
16830 // whenever `allow_intrabc`, frame.rs:194/210/252/272) at the full-pel17576 // whenever `allow_intrabc`, frame.rs:194/210/252/272) at the full-pel
@@ -16839,17 +17585,17 @@ fn decode_block(
16839 mv_to_q4(px, dv_col, 0), mv_to_q4(py, dv_row, 0),17585 mv_to_q4(px, dv_col, 0), mv_to_q4(py, dv_row, 0),
16840 side, side, mc::InterpFilterKind::Bilinear, &mut yb, fctx,17586 side, side, mc::InterpFilterKind::Bilinear, &mut yb, fctx,
16841 );17587 );
16842- let mut ub = vec![0u16; chroma_side * chroma_side];17588+ let mut ub = vec![0u16; chroma_side * chroma_height];
16843 mc::predict_with_filter(17589 mc::predict_with_filter(
16844 &u.data, u.width, u.true_width, u.true_height,17590 &u.data, u.width, u.true_width, u.true_height,
16845- mv_to_q4(cpx, dv_col, ss_x(fctx)), mv_to_q4(cpy, dv_row, ss_x(fctx)),17591+ mv_to_q4(cpx, dv_col, ss_x(fctx)), mv_to_q4(cpy, dv_row, ss_y(fctx)),
16846- chroma_side, chroma_side, mc::InterpFilterKind::Bilinear, &mut ub, fctx,17592+ chroma_side, chroma_height, mc::InterpFilterKind::Bilinear, &mut ub, fctx,
16847 );17593 );
16848- let mut vb = vec![0u16; chroma_side * chroma_side];17594+ let mut vb = vec![0u16; chroma_side * chroma_height];
16849 mc::predict_with_filter(17595 mc::predict_with_filter(
16850 &v.data, v.width, v.true_width, v.true_height,17596 &v.data, v.width, v.true_width, v.true_height,
16851- mv_to_q4(cpx, dv_col, ss_x(fctx)), mv_to_q4(cpy, dv_row, ss_x(fctx)),17597+ mv_to_q4(cpx, dv_col, ss_x(fctx)), mv_to_q4(cpy, dv_row, ss_y(fctx)),
16852- chroma_side, chroma_side, mc::InterpFilterKind::Bilinear, &mut vb, fctx,17598+ chroma_side, chroma_height, mc::InterpFilterKind::Bilinear, &mut vb, fctx,
16853 );17599 );
16854 (yb, ub, vb)17600 (yb, ub, vb)
16855 });17601 });
@@ -16994,31 +17740,41 @@ fn decode_block(
16994 );17740 );
16995 }17741 }
16996 let ac = alpha.map(|_| cfl_src(px, py, side));17742 let ac = alpha.map(|_| cfl_src(px, py, side));
16997- let cn = (chroma_side / chroma_tx).max(1);17743+ // lane-av1-422b: the chroma unit grid is `cn_cols` x `cn_rows` --
16998- for cu_row in 0..cn {17744+ // square at 4:2:0/4:4:4, at 4:2:2 `(side/2)/tx` units wide by
16999- for cu_col in 0..cn {17745+ // `side/tx` tall (the plane block is (side/2, side)). A unit's LUMA
17000- let luma_span = chroma_tx << ss_x(fctx);17746+ // anchor follows the per-axis shifts: `chroma_tx << ss_x` wide,
17001- let cu_r = if cn == 1 {17747+ // `chroma_tx_h << ss_y` tall (lane-av1-422f: the unit itself is the
17748+ // (chroma_tx, chroma_tx_h) rect, so a 4:2:2 frame below side 64
17749+ // reads ONE unit per plane, the whole plane block).
17750+ let cn_cols = (chroma_side / chroma_tx).max(1);
17751+ let cn_rows = (chroma_height / chroma_tx_h).max(1);
17752+ let luma_span_x = chroma_tx << ss_x(fctx);
17753+ let luma_span_y = chroma_tx_h << ss_y(fctx);
17754+ for cu_row in 0..cn_rows {
17755+ for cu_col in 0..cn_cols {
17756+ let cu_r = if cn_rows == 1 && cn_cols == 1 {
17002 reach17757 reach
17003 } else {17758 } else {
17004- tu_reach(17759+ tu_reach_rect(
17005 side, side,17760 side, side,
17006- cu_col * luma_span, cu_row * luma_span, luma_span,17761+ cu_col * luma_span_x, cu_row * luma_span_y, luma_span_x, luma_span_y,
17007 reach, px, py, y.width, y.height, fctx,17762 reach, px, py, y.width, y.height, fctx,
17008 )17763 )
17009 };17764 };
17010- let (cu_x, cu_y) = (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx);17765+ let (cu_x, cu_y) = (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx_h);
17011 if let Some((ub, _)) = &palette_uv_bufs {17766 if let Some((ub, _)) = &palette_uv_bufs {
17012 set_palette_pred(ub.clone(), fctx);17767 set_palette_pred(ub.clone(), fctx);
17013 }17768 }
17014- push_intra(1, 17769+ push_intra_unit(1,
17015 cu_x,17770 cu_x,
17016 cu_y,17771 cu_y,
17017 chroma_tx,17772 chroma_tx,
17773+ chroma_tx_h,
17018 uv_predict_mode,17774 uv_predict_mode,
17019 angle_delta_uv,17775 angle_delta_uv,
17020 cu_r,17776 cu_r,
17021- &ZERO_RESIDUAL[..chroma_tx * chroma_tx],17777+ &ZERO_RESIDUAL[..chroma_tx * chroma_tx_h],
17022 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),17778 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
17023 None,17779 None,
17024 smooth_neighbor_uv, fctx,17780 smooth_neighbor_uv, fctx,
@@ -17026,14 +17782,15 @@ fn decode_block(
17026 if let Some((_, vb)) = &palette_uv_bufs {17782 if let Some((_, vb)) = &palette_uv_bufs {
17027 set_palette_pred(vb.clone(), fctx);17783 set_palette_pred(vb.clone(), fctx);
17028 }17784 }
17029- push_intra(2, 17785+ push_intra_unit(2,
17030 cu_x,17786 cu_x,
17031 cu_y,17787 cu_y,
17032 chroma_tx,17788 chroma_tx,
17789+ chroma_tx_h,
17033 uv_predict_mode,17790 uv_predict_mode,
17034 angle_delta_uv,17791 angle_delta_uv,
17035 cu_r,17792 cu_r,
17036- &ZERO_RESIDUAL[..chroma_tx * chroma_tx],17793+ &ZERO_RESIDUAL[..chroma_tx * chroma_tx_h],
17037 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),17794 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
17038 None,17795 None,
17039 smooth_neighbor_uv, fctx,17796 smooth_neighbor_uv, fctx,
@@ -17089,8 +17846,17 @@ fn decode_block(
17089 // TX_32X32, so a 64x64 block codes four chroma units, plane-major17846 // TX_32X32, so a 64x64 block codes four chroma units, plane-major
17090 // (every U, then every V) — the same loop the multi-TU arm runs.17847 // (every U, then every V) — the same loop the multi-TU arm runs.
17091 // At 4:2:0 `chroma_side == chroma_tx`, so it stays one read.17848 // At 4:2:0 `chroma_side == chroma_tx`, so it stays one read.
17092- let cn = (chroma_side / chroma_tx).max(1);17849+ // lane-av1-422b: 4:2:2 never collapses to one read above a 4x4 luma
17093- let (u_grid, v_grid, chroma_units) = if cn == 1 {17850+ // block -- the unit grid is `(side/2)/tx` wide by `side/tx` tall.
17851+ // lane-av1-422f: `chroma_tx` is the unit WIDTH and `chroma_tx_h` its
17852+ // HEIGHT, so below side 64 a 4:2:2 frame's grid is 1x1 and the one
17853+ // unit is the plane block's own rect.
17854+ let cn_cols = (chroma_side / chroma_tx).max(1);
17855+ let cn_rows = (chroma_height / chroma_tx_h).max(1);
17856+ let luma_span_x = chroma_tx << ss_x(fctx);
17857+ let luma_span_y = chroma_tx_h << ss_y(fctx);
17858+ let (u_grid, v_grid, chroma_units) = if cn_rows == 1 && cn_cols == 1 {
17859+ if chroma_tx == chroma_tx_h {
17094 if let Some((ub, _)) = &palette_uv_bufs {17860 if let Some((ub, _)) = &palette_uv_bufs {
17095 set_palette_pred(ub.clone(), fctx);17861 set_palette_pred(ub.clone(), fctx);
17096 }17862 }
@@ -17148,40 +17914,78 @@ fn decode_block(
17148 smooth_neighbor_uv, fctx,17914 smooth_neighbor_uv, fctx,
17149 )?;17915 )?;
17150 (u_grid, v_grid, Vec::new())17916 (u_grid, v_grid, Vec::new())
17917+ } else {
17918+ // lane-av1-422f: the one unit is a RECT filling the plane
17919+ // block -- the square-shaped [`read_plane`] cannot express
17920+ // it, so both planes go through [`read_rect_chroma_unit`]
17921+ // (U, then V, the same order the square arm reads). The
17922+ // chroma context reads per chroma 4-px cell (see
17923+ // [`Neighbours::around_mi_422_chroma`]).
17924+ let chroma_around =
17925+ neighbours.around_mi_422_chroma((mi_r, mi_c), side, side);
17926+ if let Some((ub, _)) = &palette_uv_bufs {
17927+ set_palette_pred(ub.clone(), fctx);
17928+ }
17929+ let u_grid = read_rect_chroma_unit(
17930+ dec, cdfs, chroma_set, scans.1, chroma_tx, chroma_tx_h, 1,
17931+ chroma_around[1], uv_predict_mode, angle_delta_uv, reach, u,
17932+ cpx, cpy, base_q_idx, None,
17933+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
17934+ smooth_neighbor_uv, fctx,
17935+ )?;
17936+ if let Some((_, vb)) = &palette_uv_bufs {
17937+ set_palette_pred(vb.clone(), fctx);
17938+ }
17939+ let v_grid = read_rect_chroma_unit(
17940+ dec, cdfs, chroma_set, scans.1, chroma_tx, chroma_tx_h, 2,
17941+ chroma_around[2], uv_predict_mode, angle_delta_uv, reach, v,
17942+ cpx, cpy, base_q_idx, None,
17943+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
17944+ smooth_neighbor_uv, fctx,
17945+ )?;
17946+ (u_grid, v_grid, Vec::new())
17947+ }
17151 } else {17948 } else {
17152 let chroma_ctx_offset = Some(3);17949 let chroma_ctx_offset = Some(3);
17153 let mut u_pass: Vec<Grid> = Vec::new();17950 let mut u_pass: Vec<Grid> = Vec::new();
17154- let mut units: Vec<((usize, usize), usize, Grid, Grid)> = Vec::new();17951+ let mut units: Vec<((usize, usize), usize, usize, Grid, Grid)> = Vec::new();
17155 let mut last_grids = [Grid::Zero(0), Grid::Zero(0)];17952 let mut last_grids = [Grid::Zero(0), Grid::Zero(0)];
17156 for plane_pass in 1..=2usize {17953 for plane_pass in 1..=2usize {
17157 let mut pass_idx = 0usize;17954 let mut pass_idx = 0usize;
17158- for cu_row in 0..cn {17955+ for cu_row in 0..cn_rows {
17159- for cu_col in 0..cn {17956+ for cu_col in 0..cn_cols {
17160- let luma_span = chroma_tx << ss_x(fctx);
17161 let cu_mi = (17957 let cu_mi = (
17162- mi_r + cu_row * (luma_span / MI),17958+ mi_r + cu_row * (luma_span_y / MI),
17163- mi_c + cu_col * (luma_span / MI),17959+ mi_c + cu_col * (luma_span_x / MI),
17164 );17960 );
17165- let cu_around = neighbours.around_mi(cu_mi, luma_span);17961+ let cu_around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
17166- let cu_reach = tu_reach(17962+ // lane-av1-422f: chroma-only loop; per-chroma-cell
17963+ // above votes (see [`Neighbours::around_mi_422_chroma`]).
17964+ neighbours.around_mi_422_chroma(cu_mi, luma_span_x, luma_span_y)
17965+ } else {
17966+ neighbours.around_mi_rect(cu_mi, luma_span_x, luma_span_y)
17967+ };
17968+ let cu_reach = tu_reach_rect(
17167 side,17969 side,
17168 side,17970 side,
17169- cu_col * luma_span,17971+ cu_col * luma_span_x,
17170- cu_row * luma_span,17972+ cu_row * luma_span_y,
17171- luma_span,17973+ luma_span_x,
17974+ luma_span_y,
17172 reach,17975 reach,
17173 px,17976 px,
17174 py,17977 py,
17175 y.width,17978 y.width,
17176 y.height, fctx,17979 y.height, fctx,
17177 );17980 );
17178- let (cu_x, cu_y) = (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx);17981+ let (cu_x, cu_y) =
17982+ (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx_h);
17179 if let Some((ub, vb)) = &palette_uv_bufs {17983 if let Some((ub, vb)) = &palette_uv_bufs {
17180 let pbuf = if plane_pass == 1 { ub } else { vb };17984 let pbuf = if plane_pass == 1 { ub } else { vb };
17181 set_palette_pred(17985 set_palette_pred(
17182 palette_window(17986 palette_window(
17183- pbuf, chroma_side, cu_col * chroma_tx, cu_row * chroma_tx,17987+ pbuf, chroma_side, cu_col * chroma_tx,
17184- chroma_tx, chroma_tx,17988+ cu_row * chroma_tx_h, chroma_tx, chroma_tx_h,
17185 ),17989 ),
17186 fctx,17990 fctx,
17187 );17991 );
@@ -17198,16 +18002,21 @@ fn decode_block(
17198 None, chroma_ctx_offset, smooth_neighbor_uv, fctx,18002 None, chroma_ctx_offset, smooth_neighbor_uv, fctx,
17199 )?;18003 )?;
17200 hit!(CHROMA_SPLIT_TX_HITS);18004 hit!(CHROMA_SPLIT_TX_HITS);
18005+ if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
18006+ hit!(CHROMA422_SQUARE_HITS);
18007+ }
17201 // Immediately, so the next unit of this block reads this18008 // Immediately, so the next unit of this block reads this
17202 // one's coefficient context. `record` below stamps one18009 // one's coefficient context. `record` below stamps one
17203 // chroma state across the whole block; the replay after18010 // chroma state across the whole block; the replay after
17204 // it puts the per-unit state back.18011 // it puts the per-unit state back.
17205- neighbours.record_mi_chroma(cu_mi, luma_span, luma_span, plane_pass, &cu_grid);18012+ neighbours.record_mi_chroma(
18013+ cu_mi, luma_span_x, luma_span_y, plane_pass, &cu_grid,
18014+ );
17206 if plane_pass == 1 {18015 if plane_pass == 1 {
17207 u_pass.push(cu_grid);18016 u_pass.push(cu_grid);
17208 } else {18017 } else {
17209 let u_grid = std::mem::replace(&mut u_pass[pass_idx], Grid::Zero(0));18018 let u_grid = std::mem::replace(&mut u_pass[pass_idx], Grid::Zero(0));
17210- units.push((cu_mi, luma_span, u_grid.clone(), cu_grid.clone()));18019+ units.push((cu_mi, luma_span_x, luma_span_y, u_grid.clone(), cu_grid.clone()));
17211 last_grids = [u_grid, cu_grid];18020 last_grids = [u_grid, cu_grid];
17212 }18021 }
17213 pass_idx += 1;18022 pass_idx += 1;
@@ -17218,9 +18027,9 @@ fn decode_block(
17218 };18027 };
17219 fctx.intrabc_chroma_tx.with(|c| c.set(None));18028 fctx.intrabc_chroma_tx.with(|c| c.set(None));
17220 neighbours.record(at, side, mode, uv_predict_mode, &[&luma_grid[..], &u_grid[..], &v_grid[..]]);18029 neighbours.record(at, side, mode, uv_predict_mode, &[&luma_grid[..], &u_grid[..], &v_grid[..]]);
17221- for (cu_mi, luma_span, u_unit, v_unit) in &chroma_units {18030+ for (cu_mi, sw, sh, u_unit, v_unit) in &chroma_units {
17222- neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 1, u_unit);18031+ neighbours.record_mi_chroma(*cu_mi, *sw, *sh, 1, u_unit);
17223- neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 2, v_unit);18032+ neighbours.record_mi_chroma(*cu_mi, *sw, *sh, 2, v_unit);
17224 }18033 }
17225 } else {18034 } else {
17226 // Several luma transform units, raster order (spec18035 // Several luma transform units, raster order (spec
@@ -17230,7 +18039,13 @@ fn decode_block(
17230 // the earlier tiles in this same block already wrote -- the same18039 // the earlier tiles in this same block already wrote -- the same
17231 // per-TU pattern [`decode_leaf8`] already runs for an 8x8 leaf.18040 // per-TU pattern [`decode_leaf8`] already runs for an 8x8 leaf.
17232 let n_axis = side / logical_tx;18041 let n_axis = side / logical_tx;
17233- let cn = (chroma_side / chroma_tx).max(1);18042+ // lane-av1-422f: unit width/height per axis, like walk 2 above --
18043+ // a 4:2:2 frame below side 64 reads ONE rect unit per plane per
18044+ // chunk, the whole plane block.
18045+ let cn_cols = (chroma_side / chroma_tx).max(1);
18046+ let cn_rows = (chroma_height / chroma_tx_h).max(1);
18047+ let luma_span_x = chroma_tx << ss_x(fctx);
18048+ let luma_span_y = chroma_tx_h << ss_y(fctx);
17234 // libaom's transform-block loop is over 64x64 luma "mu" chunks18049 // libaom's transform-block loop is over 64x64 luma "mu" chunks
17235 // (`decode_token_recon_block`: `mu_blocks_wide/high` =18050 // (`decode_token_recon_block`: `mu_blocks_wide/high` =
17236 // `mi_size_wide[BLOCK_64X64]`), and it codes EVERY PLANE of a chunk18051 // `mi_size_wide[BLOCK_64X64]`), and it codes EVERY PLANE of a chunk
@@ -17242,9 +18057,10 @@ fn decode_block(
17242 let nchunk = (side / 64).max(1);18057 let nchunk = (side / 64).max(1);
17243 // `cn > 1` means the uv plane block is larger than the uv transform,18058 // `cn > 1` means the uv plane block is larger than the uv transform,
17244 // which moves libaom's chroma `txb_skip_ctx` offset from 7 to 10.18059 // which moves libaom's chroma `txb_skip_ctx` offset from 7 to 10.
17245- let chroma_ctx_offset = if cn > 1 { Some(3) } else { None };18060+ let chroma_ctx_offset = if cn_rows * cn_cols > 1 { Some(3) } else { None };
17246 let tpc = (n_axis / nchunk).max(1);18061 let tpc = (n_axis / nchunk).max(1);
17247- let cpc = (cn / nchunk).max(1);18062+ let cpc_rows = (cn_rows / nchunk).max(1);
18063+ let cpc_cols = (cn_cols / nchunk).max(1);
17248 // The block's luma transform units, raster order inside each mu18064 // The block's luma transform units, raster order inside each mu
17249 // chunk. lane-av1-ibcvtx: an intrabc block's units are the var-tx18065 // chunk. lane-av1-ibcvtx: an intrabc block's units are the var-tx
17250 // tree's own leaf list -- mixed sizes included, exactly what libaom's18066 // tree's own leaf list -- mixed sizes included, exactly what libaom's
@@ -17270,7 +18086,7 @@ fn decode_block(
17270 }18086 }
17271 }18087 }
17272 let mut last_grids = [Grid::Zero(0), Grid::Zero(0)];18088 let mut last_grids = [Grid::Zero(0), Grid::Zero(0)];
17273- let mut units: Vec<((usize, usize), usize, Grid, Grid)> = Vec::new();18089+ let mut units: Vec<((usize, usize), usize, usize, Grid, Grid)> = Vec::new();
17274 for ch_row in 0..nchunk {18090 for ch_row in 0..nchunk {
17275 for ch_col in 0..nchunk {18091 for ch_col in 0..nchunk {
17276 // lane-av1-ibcvtx: the chunk's chroma units inherit the CHROMA tx18092 // lane-av1-ibcvtx: the chunk's chroma units inherit the CHROMA tx
@@ -17404,8 +18220,8 @@ fn decode_block(
17404 let mut u_pass: Vec<Grid> = Vec::new();18220 let mut u_pass: Vec<Grid> = Vec::new();
17405 for plane_pass in 1..=2usize {18221 for plane_pass in 1..=2usize {
17406 let mut pass_idx = 0usize;18222 let mut pass_idx = 0usize;
17407- for cu_row in ch_row * cpc..(ch_row + 1) * cpc {18223+ for cu_row in ch_row * cpc_rows..(ch_row + 1) * cpc_rows {
17408- for cu_col in ch_col * cpc..(ch_col + 1) * cpc {18224+ for cu_col in ch_col * cpc_cols..(ch_col + 1) * cpc_cols {
17409 // libaom `decode_reconstruct_tx`'s frame-edge clip18225 // libaom `decode_reconstruct_tx`'s frame-edge clip
17410 // (decodeframe.c:299, `blk_row >= max_blocks_high || blk_col18226 // (decodeframe.c:299, `blk_row >= max_blocks_high || blk_col
17411 // >= max_blocks_wide` returns before ANY symbol is read): a18227 // >= max_blocks_wide` returns before ANY symbol is read): a
@@ -17437,68 +18253,108 @@ fn decode_block(
17437 let over_w_px = over_w_mi.min(0) * (MI >> ss_x(fctx)) as i32;18253 let over_w_px = over_w_mi.min(0) * (MI >> ss_x(fctx)) as i32;
17438 let over_h_px = over_h_mi.min(0) * (MI >> ss_y(fctx)) as i32;18254 let over_h_px = over_h_mi.min(0) * (MI >> ss_y(fctx)) as i32;
17439 let max_units_w = ((plane_px + over_w_px) >> 2).max(0) as usize;18255 let max_units_w = ((plane_px + over_w_px) >> 2).max(0) as usize;
17440- let max_units_h = ((plane_px + over_h_px) >> 2).max(0) as usize;18256+ // lane-av1-422f: the shared halved formula in the `else` counts
17441- let unit = chroma_tx / 4; // TU side in 4x4 chroma units18257+ // the plane span in 4-px units through the 2-px-per-mi
17442- if cu_col * unit >= max_units_w || cu_row * unit >= max_units_h {18258+ // subsampled height, which a 4:2:2 plane does not have (ss_y
18259+ // 0) -- its span is the full luma mi count, so a keyed
18260+ // formula clips the same units libaom's `max_block_high`
18261+ // does. 4:2:0 and 4:4:4 keep the proven shared rows (at 4:2:0
18262+ // `MI >> ss_y` is 2, the same `2 * over_h_mi.min(0)` the
18263+ // pre-ss form spelled).
18264+ let max_units_h = if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
18265+ (span_mi as i32 + over_h_mi.min(0)).max(0) as usize
18266+ } else {
18267+ ((plane_px + over_h_px) >> 2).max(0) as usize
18268+ };
18269+ let (unit_w, unit_h) = (chroma_tx / 4, chroma_tx_h / 4);
18270+ if cu_col * unit_w >= max_units_w || cu_row * unit_h >= max_units_h {
17443 hit!(CHROMA_EDGE_TU_CLIP_HITS);18271 hit!(CHROMA_EDGE_TU_CLIP_HITS);
17444 continue;18272 continue;
17445 }18273 }
17446 // The chroma context arrays are indexed in LUMA mi, so this18274 // The chroma context arrays are indexed in LUMA mi, so this
17447- // unit's anchor is its own luma quadrant: `chroma_tx` chroma18275+ // unit's anchor is its own luma quadrant (lane-av1-422b: the
17448- // pixels span `2 * chroma_tx` luma ones.18276+ // quadrant spans `chroma_tx << ss_x` luma px wide by
17449- let luma_span = chroma_tx << ss_x(fctx);18277+ // `chroma_tx_h << ss_y` tall -- at 4:2:2 below side 64 the
18278+ // one unit's quadrant is the whole block).
17450 let cu_mi = (18279 let cu_mi = (
17451- mi_r + cu_row * (luma_span / MI),18280+ mi_r + cu_row * (luma_span_y / MI),
17452- mi_c + cu_col * (luma_span / MI),18281+ mi_c + cu_col * (luma_span_x / MI),
17453 );18282 );
17454- let cu_around = neighbours.around_mi(cu_mi, luma_span);18283+ let cu_around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
17455- let cu_reach = if cn == 1 {18284+ // lane-av1-422f: chroma-only loop; per-chroma-cell above
18285+ // votes (see [`Neighbours::around_mi_422_chroma`]).
18286+ neighbours.around_mi_422_chroma(cu_mi, luma_span_x, luma_span_y)
18287+ } else {
18288+ neighbours.around_mi_rect(cu_mi, luma_span_x, luma_span_y)
18289+ };
18290+ let cu_reach = if cn_rows == 1 && cn_cols == 1 {
17456 reach18291 reach
17457 } else {18292 } else {
17458- tu_reach(18293+ tu_reach_rect(
17459 side, side,18294 side, side,
17460- cu_col * luma_span, cu_row * luma_span, luma_span,18295+ cu_col * luma_span_x, cu_row * luma_span_y, luma_span_x, luma_span_y,
17461 reach, px, py, y.width, y.height, fctx,18296 reach, px, py, y.width, y.height, fctx,
17462 )18297 )
17463 };18298 };
17464- let (cu_x, cu_y) = (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx);18299+ let (cu_x, cu_y) =
18300+ (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx_h);
17465 if let Some((ub, vb)) = &palette_uv_bufs {18301 if let Some((ub, vb)) = &palette_uv_bufs {
17466 let pbuf = if plane_pass == 1 { ub } else { vb };18302 let pbuf = if plane_pass == 1 { ub } else { vb };
17467 set_palette_pred(18303 set_palette_pred(
17468 palette_window(18304 palette_window(
17469- pbuf, chroma_side, cu_col * chroma_tx, cu_row * chroma_tx,18305+ pbuf, chroma_side, cu_col * chroma_tx,
17470- chroma_tx, chroma_tx,18306+ cu_row * chroma_tx_h, chroma_tx, chroma_tx_h,
17471 ),18307 ),
17472 fctx,18308 fctx,
17473 );18309 );
17474 }18310 }
17475 let buf: &mut PlaneBuf<'static> =18311 let buf: &mut PlaneBuf<'static> =
17476 if plane_pass == 1 { &mut *u } else { &mut *v };18312 if plane_pass == 1 { &mut *u } else { &mut *v };
17477- let cu_grid = read_plane(18313+ let cu_grid = if chroma_tx == chroma_tx_h {
17478- dec, cdfs, chroma_set, scans.1, plane_pass, cu_around[plane_pass], mode,18314+ read_plane(
17479- uv_predict_mode, angle_delta_uv, cu_reach, buf, cu_x, cu_y,18315+ dec, cdfs, chroma_set, scans.1, plane_pass, cu_around[plane_pass], mode,
17480- chroma_tx, chroma_tx, base_q_idx,18316+ uv_predict_mode, angle_delta_uv, cu_reach, buf, cu_x, cu_y,
17481- alpha.zip(ac).map(|((au, av), ac)| {18317+ chroma_tx, chroma_tx, base_q_idx,
17482- (if plane_pass == 1 { au } else { av }, ac)18318+ alpha.zip(ac).map(|((au, av), ac)| {
17483- }),18319+ (if plane_pass == 1 { au } else { av }, ac)
17484- None, chroma_ctx_offset, smooth_neighbor_uv, fctx,18320+ }),
17485- )?;18321+ None, chroma_ctx_offset, smooth_neighbor_uv, fctx,
17486- if cn > 1 {18322+ )?
18323+ } else {
18324+ // lane-av1-422f: the whole plane block as one rect unit;
18325+ // `chroma_ctx_offset` is `None` there (the unit covers
18326+ // the plane block, so the offset-7 skip rows are right).
18327+ read_rect_chroma_unit(
18328+ dec, cdfs, chroma_set, scans.1, chroma_tx, chroma_tx_h, plane_pass,
18329+ cu_around[plane_pass], uv_predict_mode, angle_delta_uv, cu_reach, buf,
18330+ cu_x, cu_y, base_q_idx, None,
18331+ alpha.zip(ac).map(|((au, av), ac)| {
18332+ (if plane_pass == 1 { au } else { av }, ac)
18333+ }),
18334+ smooth_neighbor_uv, fctx,
18335+ )?
18336+ };
18337+ if cn_rows * cn_cols > 1 {
17487 hit!(CHROMA_SPLIT_TX_HITS);18338 hit!(CHROMA_SPLIT_TX_HITS);
18339+ if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
18340+ hit!(CHROMA422_SQUARE_HITS);
18341+ }
17488 // Immediately, so the NEXT unit of this same block reads18342 // Immediately, so the NEXT unit of this same block reads
17489 // this one's coefficient context (libaom's chroma18343 // this one's coefficient context (libaom's chroma
17490 // `txb_skip_ctx` for the second quadrant is 11, i.e. base18344 // `txb_skip_ctx` for the second quadrant is 11, i.e. base
17491 // 1 from this left neighbour -- measured against aomdec).18345 // 1 from this left neighbour -- measured against aomdec).
17492 // The same writes are replayed after `record_split_luma`18346 // The same writes are replayed after `record_split_luma`
17493 // below, which would otherwise clobber them whole-block.18347 // below, which would otherwise clobber them whole-block.
17494- neighbours.record_mi_chroma(cu_mi, luma_span, luma_span, plane_pass, &cu_grid);18348+ neighbours.record_mi_chroma(
18349+ cu_mi, luma_span_x, luma_span_y, plane_pass, &cu_grid,
18350+ );
17495 }18351 }
17496 if plane_pass == 1 {18352 if plane_pass == 1 {
17497 u_pass.push(cu_grid);18353 u_pass.push(cu_grid);
17498 } else {18354 } else {
17499 let u_grid = std::mem::replace(&mut u_pass[pass_idx], Grid::Zero(0));18355 let u_grid = std::mem::replace(&mut u_pass[pass_idx], Grid::Zero(0));
17500- if cn > 1 {18356+ if cn_rows * cn_cols > 1 {
17501- units.push((cu_mi, luma_span, u_grid.clone(), cu_grid.clone()));18357+ units.push((cu_mi, luma_span_x, luma_span_y, u_grid.clone(), cu_grid.clone()));
17502 }18358 }
17503 last_grids = [u_grid, cu_grid];18359 last_grids = [u_grid, cu_grid];
17504 }18360 }
@@ -17515,9 +18371,9 @@ fn decode_block(
17515 // context write; at `cn > 1` the per-unit writes above are what the18371 // context write; at `cn > 1` the per-unit writes above are what the
17516 // next block reads, so they run after this (last writer wins).18372 // next block reads, so they run after this (last writer wins).
17517 neighbours.record_split_luma(at, side, mode, uv_predict_mode, [&last_grids[0], &last_grids[1]]);18373 neighbours.record_split_luma(at, side, mode, uv_predict_mode, [&last_grids[0], &last_grids[1]]);
17518- for (cu_mi, luma_span, u_grid, v_grid) in &units {18374+ for (cu_mi, sw, sh, u_grid, v_grid) in &units {
17519- neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 1, u_grid);18375+ neighbours.record_mi_chroma(*cu_mi, *sw, *sh, 1, u_grid);
17520- neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 2, v_grid);18376+ neighbours.record_mi_chroma(*cu_mi, *sw, *sh, 2, v_grid);
17521 }18377 }
17522 }18378 }
17523 // Unconditional, `size == 0` for a non-palette block: clears any stale18379 // Unconditional, `size == 0` for a non-palette block: clears any stale
@@ -18221,7 +19077,16 @@ fn decode_leaf8(
18221 let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx));19077 let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx));
18222 // 4:4:4: this 8x8 block's chroma plane block is 8x8 (same scan as luma,19078 // 4:4:4: this 8x8 block's chroma plane block is 8x8 (same scan as luma,
18223 // `scans.0`). 4:2:0 stays the 4x4 unit this leaf was written for.19079 // `scans.0`). 4:2:0 stays the 4x4 unit this leaf was written for.
19080+ // lane-av1-422d: 4:2:2 (ss 1/0) halves only the width, so the plane block
19081+ // is 4x8 -- ONE rect transform unit per plane (`av1_get_max_uv_txsize(
19082+ // BLOCK_8X8)` at ss (1,0) is `max_txsize_rect_lookup[BLOCK_4X8]` ==
19083+ // TX_4X8): one txb_skip + one scan per plane in the
19084+ // [`TxbSet::ChromaRect8x4`] class [`decode_rect_split`] proves for the
19085+ // shape, read through [`leaf8_chroma422_unit`] in each arm below. The
19086+ // `(csz, cset, cscan)` selection keeps serving the square arms (444's
19087+ // 8x8, 420's 4x4); the rect arms branch on [`chroma_422`] instead.
18224 let chroma_444 = ss_x(fctx) == 0 && ss_y(fctx) == 0;19088 let chroma_444 = ss_x(fctx) == 0 && ss_y(fctx) == 0;
19089+ let chroma_422 = ss_x(fctx) == 1 && ss_y(fctx) == 0;
18225 let (csz, cset, cscan) = if chroma_444 {19090 let (csz, cset, cscan) = if chroma_444 {
18226 (8usize, TxbSet::Chroma8, scans.0)19091 (8usize, TxbSet::Chroma8, scans.0)
18227 } else {19092 } else {
@@ -18240,11 +19105,14 @@ fn decode_leaf8(
18240 8, 8, mc::InterpFilterKind::Bilinear, &mut yb, fctx,19105 8, 8, mc::InterpFilterKind::Bilinear, &mut yb, fctx,
18241 );19106 );
18242 // The chroma extent is THIS frame's subsampled size of the 8x8 luma19107 // The chroma extent is THIS frame's subsampled size of the 8x8 luma
18243- // leaf (`get_plane_block_size`): 4x4 at 4:2:0, 8x8 at 4:4:4. The19108+ // leaf (`get_plane_block_size`): 4x4 at 4:2:0, 4x8 at 4:2:2, 8x8 at
18244- // literal 4x4 this replaces hardcoded the 4:2:0 halving -- at 4:4:419109+ // 4:4:4. The literal 4x4 this replaces hardcoded the 4:2:0 halving --
18245- // the 16-sample override fed this leaf's own 8x8 chroma reconstruct,19110+ // at 4:4:4 the 16-sample override fed this leaf's own 8x8 chroma
18246- // which indexed `prediction[16]` of a 16-sample buffer19111+ // reconstruct, which indexed `prediction[16]` of a 16-sample buffer
18247- // (len 16, index 16 at `PlaneBuf::reconstruct`). The same buffers19112+ // (len 16, index 16 at `PlaneBuf::reconstruct`), and at 4:2:2 it
19113+ // covered half the leaf's 4x8 chroma plane block (lane-av1-422d's
19114+ // `if chroma_422 { (4, 8) }` arm, which the ss-derived form subsumes:
19115+ // `8 >> ss_x` is 4 and `8 >> ss_y` is 8 there). The same buffers
18248 // are windowed at stride 8 by `read_intra_chroma_lossless` (the TX419116 // are windowed at stride 8 by `read_intra_chroma_lossless` (the TX4
18249 // 4:4:4-lossless arm) and consumed whole by the TX8 and skip arms,19117 // 4:4:4-lossless arm) and consumed whole by the TX8 and skip arms,
18250 // so all three heal with this one sizing.19118 // so all three heal with this one sizing.
@@ -18347,13 +19215,36 @@ fn decode_leaf8(
18347 );19215 );
18348 }19216 }
18349 let ac = alpha.map(|_| cfl_src(px, py, 8));19217 let ac = alpha.map(|_| cfl_src(px, py, 8));
19218+ // Three skip-arm shapes, dispatched on THIS frame's subsampling.
19219+ // lane-av1-422d: at 4:2:2 a skipped leaf still predicts its 4x8 rect
19220+ // unit per plane (CfL keeps its contribution, [`decode_block`]'s own
19221+ // skip-arm rule); no coefficient symbol exists, so the entropy
19222+ // context never enters the rect read.
19223+ if chroma_422 {
19224+ u_grid = leaf8_chroma422_unit(
19225+ dec, cdfs, (false, false, 0), uv_predict_mode, angle_delta_uv, reach,
19226+ 1, alpha.zip(ac).map(|((au, _), ac)| (au, ac)), true,
19227+ intrabc_bufs.as_ref().map(|(_, ub, _)| ub.clone())
19228+ .or_else(|| palette_uv_bufs.as_ref().map(|(ub, _)| ub.clone())),
19229+ u, cpx, cpy, smooth_neighbor_uv, fctx,
19230+ )?;
19231+ v_grid = leaf8_chroma422_unit(
19232+ dec, cdfs, (false, false, 0), uv_predict_mode, angle_delta_uv, reach,
19233+ 2, alpha.zip(ac).map(|((_, av), ac)| (av, ac)), true,
19234+ intrabc_bufs.as_ref().map(|(_, _, vb)| vb.clone())
19235+ .or_else(|| palette_uv_bufs.as_ref().map(|(_, vb)| vb.clone())),
19236+ v, cpx, cpy, smooth_neighbor_uv, fctx,
19237+ )?;
19238+ luma_grid = Grid::Zero(64);
19239+ } else {
18350 // 4:4:4 lossless: the leaf's chroma plane block is a 2x2 raster of19240 // 4:4:4 lossless: the leaf's chroma plane block is a 2x2 raster of
18351 // TX_4X4 units (`av1_get_tx_size`: lossless forces TX_4X4 on EVERY19241 // TX_4X4 units (`av1_get_tx_size`: lossless forces TX_4X4 on EVERY
18352 // plane), so a skipped leaf predicts per unit -- each from its own19242 // plane), so a skipped leaf predicts per unit -- each from its own
18353 // edges -- like the luma `SKIP_SPLIT_TX` loop above. CfL never fires19243 // edges -- like the luma `SKIP_SPLIT_TX` loop above. CfL never fires
18354 // here (`is_cfl_allowed` at lossless needs plane_bsize == 4x4; this19244 // here (`is_cfl_allowed` at lossless needs plane_bsize == 4x4; this
18355 // chroma plane block is 8x8), and intrabc/palette keep the19245 // chroma plane block is 8x8), and intrabc/palette keep the
18356- // whole-plane-block prediction they already run.19246+ // whole-plane-block prediction they already run. The guard also
19247+ // requires `chroma_444`, so it can never reach the 4:2:2 arm above.
18357 let chroma_units_444 = chroma_44419248 let chroma_units_444 = chroma_444
18358 && lossless(fctx)19249 && lossless(fctx)
18359 && intrabc_bufs.is_none()19250 && intrabc_bufs.is_none()
@@ -18441,8 +19332,22 @@ fn decode_leaf8(
18441 luma_grid = Grid::Zero(64);19332 luma_grid = Grid::Zero(64);
18442 u_grid = Grid::Zero(csz * csz);19333 u_grid = Grid::Zero(csz * csz);
18443 v_grid = Grid::Zero(csz * csz);19334 v_grid = Grid::Zero(csz * csz);
19335+ }
18444 } else if resolved != 4 {19336 } else if resolved != 4 {
18445 let around = neighbours.around_mi(leaf_mi, 8);19337 let around = neighbours.around_mi(leaf_mi, 8);
19338+ // lane-av1-422h: the 4:2:2 chroma rect unit's `get_txb_ctx_general`
19339+ // reads its above votes over CHROMA 4-px cells -- at ss_x 1 one chroma
19340+ // cell spans TWO luma mi columns, so the per-luma-mi sum counts each
19341+ // above chroma column twice and `dc_sign_ctx`'s signum flips whenever
19342+ // the doubled sum crosses zero (the same class
19343+ // [`Neighbours::around_mi_422_chroma`] fixes for the rect readers;
19344+ // measured at mi(2,24) plane 2: ours dc_sign row 0, oracle row 2).
19345+ // The left extent is unsubsquared at ss_y 0 and stays one-to-one.
19346+ let chroma_around = if chroma_422 {
19347+ neighbours.around_mi_422_chroma(leaf_mi, 8, 8)
19348+ } else {
19349+ around
19350+ };
18446 if let Some(buf) = &palette_y_buf {19351 if let Some(buf) = &palette_y_buf {
18447 set_palette_pred(buf.clone(), fctx);19352 set_palette_pred(buf.clone(), fctx);
18448 }19353 }
@@ -18481,6 +19386,25 @@ fn decode_leaf8(
18481 fctx.intrabc_chroma_tx.with(|c| c.set(Some(fctx.luma_tx_type.with(std::cell::Cell::get))));19386 fctx.intrabc_chroma_tx.with(|c| c.set(Some(fctx.luma_tx_type.with(std::cell::Cell::get))));
18482 }19387 }
18483 let ac = alpha.map(|_| cfl_src(px, py, 8));19388 let ac = alpha.map(|_| cfl_src(px, py, 8));
19389+ if chroma_422 {
19390+ // lane-av1-422d: ONE 4x8 rect unit per plane (`av1_get_max_uv_txsize`
19391+ // at ss (1,0) == TX_4X8), covering the plane block exactly, off the
19392+ // leaf's own 8x8-span entropy context (`chroma_tiled`'s convention).
19393+ u_grid = leaf8_chroma422_unit(
19394+ dec, cdfs, chroma_around[1], uv_predict_mode, angle_delta_uv, reach,
19395+ 1, alpha.zip(ac).map(|((au, _), ac)| (au, ac)), false,
19396+ intrabc_bufs.as_ref().map(|(_, ub, _)| ub.clone())
19397+ .or_else(|| palette_uv_bufs.as_ref().map(|(ub, _)| ub.clone())),
19398+ u, cpx, cpy, smooth_neighbor_uv, fctx,
19399+ )?;
19400+ v_grid = leaf8_chroma422_unit(
19401+ dec, cdfs, chroma_around[2], uv_predict_mode, angle_delta_uv, reach,
19402+ 2, alpha.zip(ac).map(|((_, av), ac)| (av, ac)), false,
19403+ intrabc_bufs.as_ref().map(|(_, _, vb)| vb.clone())
19404+ .or_else(|| palette_uv_bufs.as_ref().map(|(_, vb)| vb.clone())),
19405+ v, cpx, cpy, smooth_neighbor_uv, fctx,
19406+ )?;
19407+ } else {
18484 if let Some((_, ub, _)) = &intrabc_bufs {19408 if let Some((_, ub, _)) = &intrabc_bufs {
18485 set_palette_pred(ub.clone(), fctx);19409 set_palette_pred(ub.clone(), fctx);
18486 } else if let Some((ub, _)) = &palette_uv_bufs {19410 } else if let Some((ub, _)) = &palette_uv_bufs {
@@ -18535,6 +19459,7 @@ fn decode_leaf8(
18535 None,19459 None,
18536 smooth_neighbor_uv, fctx,19460 smooth_neighbor_uv, fctx,
18537 )?;19461 )?;
19462+ }
18538 // Disarm: `INTRABC_CHROMA_TX` is `Some` across exactly this block's19463 // Disarm: `INTRABC_CHROMA_TX` is `Some` across exactly this block's
18539 // two chroma reads (`decode_block`'s own tail does the same) -- left19464 // two chroma reads (`decode_block`'s own tail does the same) -- left
18540 // set, every later chroma block would inherit this luma tx_type,19465 // set, every later chroma block would inherit this luma tx_type,
@@ -18644,14 +19569,38 @@ fn decode_leaf8(
18644 }19569 }
18645 }19570 }
18646 let ac = alpha.map(|_| cfl_src(px, py, 8));19571 let ac = alpha.map(|_| cfl_src(px, py, 8));
18647- let chroma_around = neighbours.around_mi(leaf_mi, 8);19572+ // lane-av1-422h: same ss_x-1 dc-vote sampling as the whole-leaf arm
19573+ // above -- the doubled above sum crosses zero at mi(2,24) plane 2.
19574+ let chroma_around = if chroma_422 {
19575+ neighbours.around_mi_422_chroma(leaf_mi, 8, 8)
19576+ } else {
19577+ neighbours.around_mi(leaf_mi, 8)
19578+ };
18648 // lane-av1intrapred: the non-vacuity counter -- armed slot consulted19579 // lane-av1intrapred: the non-vacuity counter -- armed slot consulted
18649 // by this arm's chroma reads means the frame-copy + inherited-type19580 // by this arm's chroma reads means the frame-copy + inherited-type
18650 // route ran; zero at gate time means the fixture stopped reaching it.19581 // route ran; zero at gate time means the fixture stopped reaching it.
18651 if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() {19582 if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() {
18652 hit!(INTRABC_TX4_CHROMA_COPY_HITS);19583 hit!(INTRABC_TX4_CHROMA_COPY_HITS);
18653 }19584 }
18654- if chroma_444 && lossless(fctx) {19585+ if chroma_422 {
19586+ // lane-av1-422d: the chroma unit does NOT follow the luma var-tx
19587+ // split -- `uv_txsize` is `av1_get_max_uv_txsize` of the block,
19588+ // still the one 4x8 rect unit per plane at ss (1,0).
19589+ u_grid = leaf8_chroma422_unit(
19590+ dec, cdfs, chroma_around[1], uv_predict_mode, angle_delta_uv, reach,
19591+ 1, alpha.zip(ac).map(|((au, _), ac)| (au, ac)), false,
19592+ intrabc_bufs.as_ref().map(|(_, ub, _)| ub.clone())
19593+ .or_else(|| palette_uv_bufs.as_ref().map(|(ub, _)| ub.clone())),
19594+ u, cpx, cpy, smooth_neighbor_uv, fctx,
19595+ )?;
19596+ v_grid = leaf8_chroma422_unit(
19597+ dec, cdfs, chroma_around[2], uv_predict_mode, angle_delta_uv, reach,
19598+ 2, alpha.zip(ac).map(|((_, av), ac)| (av, ac)), false,
19599+ intrabc_bufs.as_ref().map(|(_, _, vb)| vb.clone())
19600+ .or_else(|| palette_uv_bufs.as_ref().map(|(_, vb)| vb.clone())),
19601+ v, cpx, cpy, smooth_neighbor_uv, fctx,
19602+ )?;
19603+ } else if chroma_444 && lossless(fctx) {
18655 // 4:4:4 lossless: the leaf's chroma plane block is a 2x2 raster19604 // 4:4:4 lossless: the leaf's chroma plane block is a 2x2 raster
18656 // of TX_4X4 units per plane, PLANE-MAJOR (`av1_get_tx_size`:19605 // of TX_4X4 units per plane, PLANE-MAJOR (`av1_get_tx_size`:
18657 // lossless forces TX_4X4 on EVERY plane) -- the same walk19606 // lossless forces TX_4X4 on EVERY plane) -- the same walk
@@ -18823,6 +19772,77 @@ fn decode_leaf8(
18823 Ok(mode)19772 Ok(mode)
18824 }19773 }
18825 19774
19775+/// lane-av1-422d: ONE 4:2:2 chroma transform unit of an 8x8 leaf
19776+/// ([`decode_leaf8`]). At ss (1,0) the plane block is 4x8 and
19777+/// `av1_get_max_uv_txsize(BLOCK_8X8)` resolves to
19778+/// `max_txsize_rect_lookup[BLOCK_4X8]` == TX_4X8, so the WHOLE plane block is
19779+/// a single rect unit -- one txb_skip + one scan per plane in the
19780+/// [`TxbSet::ChromaRect8x4`] class [`decode_rect_split`] proves for the
19781+/// shape. Mirrors [`sub8_leaf_chroma444`]'s rect arm at the leaf's halved
19782+/// position: the entropy context is the leaf's own 8x8 luma-span
19783+/// above/left state (the `chroma_tiled` arm's convention; no `+3`
19784+/// plane-block-bigger term -- the unit covers the plane block exactly), the
19785+/// CFL source is the leaf's whole 8x8 luma block, and the plane's predicted
19786+/// mode supplies the mode-derived default `tx_type` unless an armed
19787+/// [`INTRABC_CHROMA_TX`] slot carries the intrabc luma's own (the caller
19788+/// arms and disarms it, exactly as it does around its square reads).
19789+#[allow(clippy::too_many_arguments)]
19790+fn leaf8_chroma422_unit(
19791+ dec: &mut SymbolDecoder,
19792+ cdfs: &mut Cdfs,
19793+ around: (bool, bool, i32),
19794+ uv_predict_mode: usize,
19795+ angle_delta_uv: i32,
19796+ reach: Reach,
19797+ plane_idx: usize,
19798+ cfl: Option<(i32, CflSrc)>,
19799+ skip: bool,
19800+ // The prediction override the square arms feed through
19801+ // `set_palette_pred`: an intrabc leaf's frame copy at the DV takes
19802+ // priority over a palette block's colour-index map.
19803+ pred_override: Option<Vec<u16>>,
19804+ // Unread, like [`read_plane`]'s own: the borrow proves the caller holds
19805+ // the plane exclusively while the unit's coefficients are parsed.
19806+ _plane: &mut PlaneBuf<'static>,
19807+ cpx: usize,
19808+ cpy: usize,
19809+ smooth_neighbor_uv: bool, fctx: &crate::decode::FrameCtx,
19810+) -> Result<Grid> {
19811+ // The unit's prediction runs whether or not a residual follows it -- a
19812+ // skipped leaf still predicts (the CfL contribution survives a skip),
19813+ // and a skipped intrabc leaf still copies the frame at its DV.
19814+ if let Some(buf) = pred_override {
19815+ set_palette_pred(buf, fctx);
19816+ }
19817+ if skip {
19818+ push_intra_rect(
19819+ plane_idx, cpx, cpy, 4, 8, uv_predict_mode, angle_delta_uv, reach,
19820+ &ZERO_RESIDUAL[..4 * 8], cfl, None, smooth_neighbor_uv, fctx,
19821+ );
19822+ return Ok(Grid::Zero(4 * 8));
19823+ }
19824+ let default_tx = fctx
19825+ .intrabc_chroma_tx
19826+ .with(std::cell::Cell::get)
19827+ .unwrap_or_else(|| default_intra_tx_type(uv_predict_mode as u8));
19828+ let mut coding = cdfs.txb(TxbSet::ChromaRect8x4, uv_predict_mode);
19829+ let (levels, tx_type) = read_coeffs_rect(
19830+ dec, &mut coding, &SCAN_4X8, 4, 8,
19831+ usize::from(around.0) + usize::from(around.1),
19832+ dc_sign_ctx(around.2), default_tx,
19833+ )?;
19834+ let residual = dequant_and_inverse_typed_wh(
19835+ &levels, 4, 8, crate::decode::bit_depth(fctx), block_q_idx(fctx),
19836+ plane_q_delta(plane_idx, fctx).0, plane_q_delta(plane_idx, fctx).1,
19837+ tx_type, block_iqmatrix(fctx, plane_idx, 4, 8, tx_type),
19838+ );
19839+ push_intra_rect(
19840+ plane_idx, cpx, cpy, 4, 8, uv_predict_mode, angle_delta_uv, reach,
19841+ &residual, cfl, None, smooth_neighbor_uv, fctx,
19842+ );
19843+ Ok(levels)
19844+}
19845+
18826 /// `read_intra_frame_mode_info`'s mode-info read for one `BLOCK_4X4` leaf19846 /// `read_intra_frame_mode_info`'s mode-info read for one `BLOCK_4X4` leaf
18827 /// below an 8x8 partition (spec `decode_partition`'s `bSize < BLOCK_8X8`19847 /// below an 8x8 partition (spec `decode_partition`'s `bSize < BLOCK_8X8`
18828 /// bottom, where no partition symbol is read at all -- `decode_block` runs19848 /// bottom, where no partition symbol is read at all -- `decode_block` runs
@@ -19356,6 +20376,173 @@ fn grid_unit_state(grid: &Grid, bw: usize, x0: usize, y0: usize, unit_w: usize,
19356 }20376 }
19357 20377
19358 20378
20379+/// [`sub8_leaf_chroma444`] for 4:2:2 (lane-av1-422g): an even-mi-column 4x4
20380+/// leaf is its plane's own chroma reference (`is_chroma_reference`'s
20381+/// `!(mi_col & ss_x)` at ss_x 1 -- every even-column leaf, not 4:2:0's single
20382+/// bottom-right one) and codes ONE TX_4X4 chroma unit per plane right after
20383+/// its luma: `ss_size_lookup[BLOCK_4X4][1][0]` is BLOCK_4X4, so the (2, 4)
20384+/// plane area rounds up to the square 4x4 read. The unit sits at the chroma
20385+/// position (`px >> ss_x`), and its 4 chroma-px width spans TWO luma mi
20386+/// columns, so the context reads go through
20387+/// [`Neighbours::around_mi_422_chroma`] and the entropy stamp covers both
20388+/// columns with the unit's whole-unit state.
20389+#[allow(clippy::too_many_arguments)]
20390+fn sub8_leaf_chroma422(
20391+ dec: &mut SymbolDecoder,
20392+ cdfs: &mut Cdfs,
20393+ neighbours: &mut Neighbours,
20394+ lmi: (usize, usize),
20395+ uv_mode: usize,
20396+ angle_delta_uv: i32,
20397+ alpha: Option<(i32, i32)>,
20398+ skip: bool,
20399+ intrabc_dv: Option<(i32, i32)>,
20400+ y: &PlaneBuf<'static>,
20401+ u: &mut PlaneBuf<'static>,
20402+ v: &mut PlaneBuf<'static>,
20403+ scan4: &[u16],
20404+ base_q_idx: u8,
20405+ smooth_neighbor_uv: bool,
20406+ // The owning luma leaf's own shape (`(4, 4)` for a split leaf, `(8, 4)` /
20407+ // `(4, 8)` for a rect pair's strip): libaom's `has_top_right` /
20408+ // `has_bottom_left` answer for this chroma TX_4X4 unit comes from the
20409+ // LEAF's own rect table row at the leaf's mi (`bsize` is the leaf, the
20410+ // unit covers it whole), never the standalone square-4x4 table the old
20411+ // `Reach::of(4, ..)` lookup used -- that said 1 where `has_tr_8x4` says 0
20412+ // at mi(27,44) (the oracle's own EC_PRED prints `n_tr=0` there), so the
20413+ // D45 unit read undecoded pixels to its upper right.
20414+ leaf_shape: (usize, usize),
20415+ fctx: &crate::decode::FrameCtx,
20416+) -> Result<(Grid, Grid)> {
20417+ let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
20418+ // lane-av1-422kf2: libaom writes one MB_MODE_INFO per mi cell the LEAF
20419+ // covers, and `chroma_left_mbmi`/`chroma_above_mbmi` read whichever of
20420+ // those cells the next block's snap lands on -- an 8x4 strip's SM_V
20421+ // uv_mode must therefore be visible at BOTH of its mi columns, or the
20422+ // block to its right (mi (30,50): left neighbour cell (30,49)) missed the
20423+ // smooth neighbour and skipped libaom's strength-1 intra edge filter
20424+ // (class context-read-from-one-cell, the 4:2:2 sub-8 twin of the
20425+ // lane-kf900 snap fix).
20426+ neighbours.record_uv_mode_mi(
20427+ lmi.0,
20428+ lmi.1,
20429+ (leaf_shape.0 / MI).max(1),
20430+ (leaf_shape.1 / MI).max(1),
20431+ uv_predict_mode,
20432+ );
20433+ let (px, py) = (lmi.1 * MI, lmi.0 * MI);
20434+ // lane-av1-422kf2: the unit's WRITE/PREDICTION anchor is the same floored
20435+ // chroma cell as the entropy anchor below -- libaom positions the sub-8
20436+ // chroma plane block at `av1_setup_dst_planes`' mi-exact floor
20437+ // (`(mi_col & !1) * MI >> ss_x`), NOT at the odd leaf's own chroma x:
20438+ // the oracle's mi(18,55) TX_4X4 unit reconstructed chroma px 108..111
20439+ // (a pure V-copy of the row above at 108..111), while the leaf's own
20440+ // chroma x is 110 -- anchoring there left px 108..109 unwritten (zeros)
20441+ // and stepped px 112..113 with the unit's right columns.
20442+ let (cpx, cpy) = (((lmi.1 & !1) * MI) >> ss_x(fctx), py >> ss_y(fctx));
20443+ // lane-av1-422h: the entropy-context anchor is the unit's FLOOR chroma
20444+ // cell (`pd->above_entropy_context + (mi_col >> ss_x)`): an ODD-column
20445+ // leaf's 4-px unit starts at a chroma px that is NOT cell aligned, and
20446+ // both its ctx read and its ctx write live in the cell containing that
20447+ // start -- one luma mi column to the LEFT of the leaf's own. Even-column
20448+ // (cell-aligned) leaves keep their own column. The state write spans the
20449+ // anchor's two luma mi columns, so the second (odd) leaf of a split group
20450+ // overwrites exactly the cell the first one wrote, as libaom's
20451+ // `av1_set_entropy_contexts` per-TU writes do.
20452+ let ctx_mi = (lmi.0, lmi.1 & !1);
20453+ // lane-av1-422kf2: the square unit takes the leaf's OWN reach: a split
20454+ // leaf is a standalone BLOCK_4X4 (square table), a rect pair's strip is
20455+ // `of_rect` on the strip's true (8x4 / 4x8) shape -- libaom passes the
20456+ // LEAF's bsize to `has_top_right`/`has_bottom_left`, so a rect strip's
20457+ // answer comes from `has_tr_8x4`/`has_tr_4x8` at the strip's mi, not
20458+ // from a 4x4-block lookup.
20459+ let reach = if leaf_shape == (4, 4) {
20460+ Reach::of(4, px, py, y.width, y.height, fctx)
20461+ } else {
20462+ Reach::of_rect(leaf_shape.0, leaf_shape.1, px, py, y.width, y.height, fctx)
20463+ };
20464+ let chroma_around = neighbours.around_mi_422_chroma(ctx_mi, 8, 4);
20465+ let ac = alpha.map(|_| cfl_src_rect(px, py, 8, 4));
20466+ let grids: (Grid, Grid) = if skip {
20467+ // A skipped chroma-reference leaf still predicts (the CfL contribution
20468+ // survives a skip); no coefficient symbol exists.
20469+ if alpha.is_some() {
20470+ hit!(CHROMA_SKIP_CFL_HITS);
20471+ hit!(SKIP_CFL_HITS);
20472+ }
20473+ push_intra(1, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx);
20474+ push_intra(2, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx);
20475+ // The same arm-without-clear route the 4:2:0 tails count: a skipped
20476+ // leaf reads no coefficient, so an armed intrabc slot is dropped.
20477+ if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() {
20478+ hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS);
20479+ fctx.intrabc_chroma_tx.with(|c| c.set(None));
20480+ }
20481+ (Grid::Zero(16), Grid::Zero(16))
20482+ } else if let Some(dv) = intrabc_dv {
20483+ hit!(CHROMA422_SUB8_HITS);
20484+ // Frame copy at the DV; the residual still reads the ordinary chroma
20485+ // tables with the inherited luma `tx_type` (see the 4:2:0 tails).
20486+ let mut ub = vec![0u16; 16];
20487+ mc::predict_with_filter(
20488+ &u.data, u.width, u.true_width, u.true_height,
20489+ mv_to_q4(cpx, dv.1, ss_x(fctx)), mv_to_q4(cpy, dv.0, ss_y(fctx)),
20490+ 4, 4, mc::InterpFilterKind::Bilinear, &mut ub, fctx,
20491+ );
20492+ let mut vb = vec![0u16; 16];
20493+ mc::predict_with_filter(
20494+ &v.data, v.width, v.true_width, v.true_height,
20495+ mv_to_q4(cpx, dv.1, ss_x(fctx)), mv_to_q4(cpy, dv.0, ss_y(fctx)),
20496+ 4, 4, mc::InterpFilterKind::Bilinear, &mut vb, fctx,
20497+ );
20498+ set_palette_pred(ub, fctx);
20499+ let ug = read_plane(
20500+ dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], DC_PRED, DC_PRED,
20501+ 0, reach, u, cpx, cpy, 4, TX4, base_q_idx,
20502+ None, None, None, smooth_neighbor_uv, fctx,
20503+ )?;
20504+ set_palette_pred(vb, fctx);
20505+ let vg = read_plane(
20506+ dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], DC_PRED, DC_PRED,
20507+ 0, reach, v, cpx, cpy, 4, TX4, base_q_idx,
20508+ None, None, None, smooth_neighbor_uv, fctx,
20509+ )?;
20510+ fctx.intrabc_chroma_tx.with(|c| c.set(None));
20511+ (ug, vg)
20512+ } else {
20513+ hit!(CHROMA422_SUB8_HITS);
20514+ let ug = read_plane(
20515+ dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode,
20516+ angle_delta_uv, reach, u, cpx, cpy, 4, TX4, base_q_idx,
20517+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, fctx,
20518+ )?;
20519+ let vg = read_plane(
20520+ dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode,
20521+ angle_delta_uv, reach, v, cpx, cpy, 4, TX4, base_q_idx,
20522+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, fctx,
20523+ )?;
20524+ (ug, vg)
20525+ };
20526+ // libaom `av1_set_entropy_contexts` stamps above/left PER TRANSFORM UNIT:
20527+ // the unit's own chroma span -- 1 mi row tall, TWO luma mi columns wide
20528+ // (one chroma column) -- not the 8x8 group's.
20529+ let (u_grid, v_grid) = grids;
20530+ let u_state = neighbour_state(&u_grid);
20531+ let v_state = neighbour_state(&v_grid);
20532+ if lmi.0 < neighbours.mi_rows {
20533+ neighbours.left[ctx_mi.0][1] = u_state;
20534+ neighbours.left[ctx_mi.0][2] = v_state;
20535+ }
20536+ for cell in 0..2 {
20537+ if ctx_mi.1 + cell < neighbours.mi_cols {
20538+ neighbours.above[ctx_mi.1 + cell][1] = u_state;
20539+ neighbours.above[ctx_mi.1 + cell][2] = v_state;
20540+ }
20541+ }
20542+ Ok((u_grid, v_grid))
20543+}
20544+
20545+
19359 /// Decodes a `PARTITION_SPLIT` of one 8x8 block into four `BLOCK_4X4` leaves20546 /// Decodes a `PARTITION_SPLIT` of one 8x8 block into four `BLOCK_4X4` leaves
19360 /// (spec `decode_partition`'s recursion bottom), sharing [`decode_leaf8`]'s20547 /// (spec `decode_partition`'s recursion bottom), sharing [`decode_leaf8`]'s
19361 /// own signature so its caller's `prev_leaf`/`above_mode`/`left_mode`20548 /// own signature so its caller's `prev_leaf`/`above_mode`/`left_mode`
@@ -19413,9 +20600,14 @@ fn decode_leaf_split4(
19413 // `uv_mode` and codes its own full-resolution 4x4 chroma unit right20600 // `uv_mode` and codes its own full-resolution 4x4 chroma unit right
19414 // after its luma -- there is no shared group unit at all.20601 // after its luma -- there is no shared group unit at all.
19415 let chroma_444 = ss_x(fctx) == 0 && ss_y(fctx) == 0;20602 let chroma_444 = ss_x(fctx) == 0 && ss_y(fctx) == 0;
20603+ // lane-av1-422g: at ss (1,0) every even-mi-column leaf is its plane's own
20604+ // chroma reference (`is_chroma_reference`'s `!(mi_col & ss_x)`) and codes
20605+ // one TX_4X4 chroma unit per plane; odd-column leaves read no chroma.
20606+ let chroma_422 = ss_x(fctx) == 1 && ss_y(fctx) == 0;
19416 // The last leaf's own `uv_predict_mode`, for the coarse above/left slots20607 // The last leaf's own `uv_predict_mode`, for the coarse above/left slots
19417 // the 4:2:0 tail fills from the group's single unit.20608 // the 4:2:0 tail fills from the group's single unit.
19418 let mut last_uv444 = DC_PRED;20609 let mut last_uv444 = DC_PRED;
20610+ let mut last_uv422 = DC_PRED;
19419 for i in 0..4usize {20611 for i in 0..4usize {
19420 let (dr, dc) = (i / 2, i % 2);20612 let (dr, dc) = (i / 2, i % 2);
19421 let lmi = (leaf_mi.0 + dr, leaf_mi.1 + dc);20613 let lmi = (leaf_mi.0 + dr, leaf_mi.1 + dc);
@@ -19433,7 +20625,18 @@ fn decode_leaf_split4(
19433 } else {20625 } else {
19434 leaf_modes[i - 1]20626 leaf_modes[i - 1]
19435 };20627 };
19436- let has_chroma = chroma_444 || i == 3;20628+ let has_chroma = if chroma_444 {
20629+ true
20630+ } else if chroma_422 {
20631+ // lane-av1-422h: `is_chroma_reference`'s column clause at ss_x 1 is
20632+ // `(mi_col & 1)` for a BLOCK_4X4 leaf -- the ODD-column leaf is the
20633+ // chroma reference (oracle, mi(30,42) split group: uv_mode read at
20634+ // mi(30,43) and mi(31,43) only). The even-column rule this
20635+ // replaces came from 422f's pre-partition-trace misreading.
20636+ (lmi.1 & 1) == 1
20637+ } else {
20638+ i == 3
20639+ };
19437 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);20640 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);
19438 let (skip, mode, angle_delta_y, chroma, filter_intra, intrabc) = read_intra_mode_sub8(20641 let (skip, mode, angle_delta_y, chroma, filter_intra, intrabc) = read_intra_mode_sub8(
19439 dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra,20642 dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra,
@@ -19522,6 +20725,14 @@ fn decode_leaf_split4(
19522 neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), fctx,20725 neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), fctx,
19523 )?;20726 )?;
19524 last_uv444 = DC_PRED;20727 last_uv444 = DC_PRED;
20728+ } else if chroma_422 {
20729+ sub8_leaf_chroma422(
20730+ dec, cdfs, neighbours, lmi, DC_PRED, 0, None, skip,
20731+ Some(dv), y, u, v, scan4, base_q_idx,
20732+ neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx),
20733+ (4, 4), fctx,
20734+ )?;
20735+ last_uv422 = DC_PRED;
19525 } else {20736 } else {
19526 last_uv = Some((DC_PRED, 0, None));20737 last_uv = Some((DC_PRED, 0, None));
19527 // lane-av1txbands: the group's chroma is the CHROMA-REFERENCE20738 // lane-av1txbands: the group's chroma is the CHROMA-REFERENCE
@@ -19587,6 +20798,16 @@ fn decode_leaf_split4(
19587 neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), fctx,20798 neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), fctx,
19588 )?;20799 )?;
19589 last_uv444 = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };20800 last_uv444 = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
20801+ } else if chroma_422 {
20802+ let (uv_mode, angle_delta_uv, alpha) =
20803+ chroma.expect("4:2:2 reads uv_mode on even-column leaves");
20804+ sub8_leaf_chroma422(
20805+ dec, cdfs, neighbours, lmi, uv_mode, angle_delta_uv, alpha, skip,
20806+ None, y, u, v, scan4, base_q_idx,
20807+ neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx),
20808+ (4, 4), fctx,
20809+ )?;
20810+ last_uv422 = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
19590 } else {20811 } else {
19591 last_uv = chroma;20812 last_uv = chroma;
19592 }20813 }
@@ -19604,6 +20825,14 @@ fn decode_leaf_split4(
19604 neighbours.above_uv_mode[c] = last_uv444;20825 neighbours.above_uv_mode[c] = last_uv444;
19605 neighbours.left_uv_mode[r] = last_uv444;20826 neighbours.left_uv_mode[r] = last_uv444;
19606 (Grid::Zero(16), Grid::Zero(16))20827 (Grid::Zero(16), Grid::Zero(16))
20828+ } else if chroma_422 {
20829+ // lane-av1-422g: each even-column leaf coded and reconstructed its
20830+ // own TX_4X4 chroma unit in the loop above (sub8_leaf_chroma422
20831+ // stamped the per-leaf entropy state); only the coarse slots remain,
20832+ // filled from the group's last chroma-reference leaf (bottom-left).
20833+ neighbours.above_uv_mode[c] = last_uv422;
20834+ neighbours.left_uv_mode[r] = last_uv422;
20835+ (Grid::Zero(16), Grid::Zero(16))
19607 } else {20836 } else {
19608 let (gpx, gpy) = (leaf_mi.1 * MI, leaf_mi.0 * MI);20837 let (gpx, gpy) = (leaf_mi.1 * MI, leaf_mi.0 * MI);
19609 let (cpx, cpy) = (gpx >> ss_x(fctx), gpy >> ss_y(fctx));20838 let (cpx, cpy) = (gpx >> ss_x(fctx), gpy >> ss_y(fctx));
@@ -19651,13 +20880,13 @@ fn decode_leaf_split4(
19651 let mut ub = vec![0u16; 16];20880 let mut ub = vec![0u16; 16];
19652 mc::predict_with_filter(20881 mc::predict_with_filter(
19653 &u.data, u.width, u.true_width, u.true_height,20882 &u.data, u.width, u.true_width, u.true_height,
19654- mv_to_q4(cpx, dv.1, ss_x(fctx)), mv_to_q4(cpy, dv.0, ss_x(fctx)),20883+ mv_to_q4(cpx, dv.1, ss_x(fctx)), mv_to_q4(cpy, dv.0, ss_y(fctx)),
19655 4, 4, mc::InterpFilterKind::Bilinear, &mut ub, fctx,20884 4, 4, mc::InterpFilterKind::Bilinear, &mut ub, fctx,
19656 );20885 );
19657 let mut vb = vec![0u16; 16];20886 let mut vb = vec![0u16; 16];
19658 mc::predict_with_filter(20887 mc::predict_with_filter(
19659 &v.data, v.width, v.true_width, v.true_height,20888 &v.data, v.width, v.true_width, v.true_height,
19660- mv_to_q4(cpx, dv.1, ss_x(fctx)), mv_to_q4(cpy, dv.0, ss_x(fctx)),20889+ mv_to_q4(cpx, dv.1, ss_x(fctx)), mv_to_q4(cpy, dv.0, ss_y(fctx)),
19661 4, 4, mc::InterpFilterKind::Bilinear, &mut vb, fctx,20890 4, 4, mc::InterpFilterKind::Bilinear, &mut vb, fctx,
19662 );20891 );
19663 let chroma_around = neighbours.around_mi(leaf_mi, 8);20892 let chroma_around = neighbours.around_mi(leaf_mi, 8);
@@ -19715,7 +20944,8 @@ fn decode_leaf_split4(
19715 }20944 }
19716 // lane-av1-444: at 4:4:4 [`sub8_leaf_chroma444`] already stamped each20945 // lane-av1-444: at 4:4:4 [`sub8_leaf_chroma444`] already stamped each
19717 // leaf's own span as it decoded; these placeholder grids carry no state.20946 // leaf's own span as it decoded; these placeholder grids carry no state.
19718- if !chroma_444 {20947+ // lane-av1-422g: the 4:2:2 per-leaf units stamp the same way.
20948+ if !chroma_444 && !chroma_422 {
19719 let round_up_even = |n: usize| n.div_ceil(2) * 2;20949 let round_up_even = |n: usize| n.div_ceil(2) * 2;
19720 let bound_h = round_up_even(neighbours.mi_rows);20950 let bound_h = round_up_even(neighbours.mi_rows);
19721 let bound_w = round_up_even(neighbours.mi_cols);20951 let bound_w = round_up_even(neighbours.mi_cols);
@@ -19813,6 +21043,15 @@ fn decode_leaf_rect8(
19813 // full-resolution rect chroma unit right after its luma.21043 // full-resolution rect chroma unit right after its luma.
19814 let chroma_444 = ss_x(fctx) == 0 && ss_y(fctx) == 0;21044 let chroma_444 = ss_x(fctx) == 0 && ss_y(fctx) == 0;
19815 let mut last_uv444 = DC_PRED;21045 let mut last_uv444 = DC_PRED;
21046+ // lane-av1-422h: at ss (1,0) `is_chroma_reference`
21047+ // (av1_common_int.h:1459) resolves per strip shape --
21048+ // `((mi_row & 1) || !(bh_mi & 1) || !ss_y) && ((mi_col & 1) || !(bw_mi & 1) || !ss_x)`:
21049+ // a HORZ pair is two BLOCK_8X4 strips at the group's even column, so
21050+ // BOTH strips are chroma references (`!(bw & 1)`); a VERT pair is two
21051+ // BLOCK_4X8 strips, and the column clause keeps only the ODD-column
21052+ // strip (i == 1, the same leaf the 4:2:0 rule reads chroma on).
21053+ let chroma_422 = ss_x(fctx) == 1 && ss_y(fctx) == 0;
21054+ let mut last_uv422 = DC_PRED;
19816 for i in 0..2usize {21055 for i in 0..2usize {
19817 let lmi = if vert {21056 let lmi = if vert {
19818 (leaf_mi.0, leaf_mi.1 + i)21057 (leaf_mi.0, leaf_mi.1 + i)
@@ -19831,7 +21070,13 @@ fn decode_leaf_rect8(
19831 } else {21070 } else {
19832 neighbours.mode_left_mi(lmi.0, lmi.1).unwrap_or(left_mode)21071 neighbours.mode_left_mi(lmi.0, lmi.1).unwrap_or(left_mode)
19833 };21072 };
19834- let has_chroma = chroma_444 || i == 1;21073+ let has_chroma = if chroma_444 {
21074+ true
21075+ } else if chroma_422 {
21076+ !vert || i == 1
21077+ } else {
21078+ i == 1
21079+ };
19835 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);21080 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);
19836 let (skip, mode, angle_delta_y, chroma, filter_intra, intrabc) = read_intra_mode_sub8(21081 let (skip, mode, angle_delta_y, chroma, filter_intra, intrabc) = read_intra_mode_sub8(
19837 dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra,21082 dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra,
@@ -20081,6 +21326,16 @@ fn decode_leaf_rect8(
20081 neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), fctx,21326 neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), fctx,
20082 )?;21327 )?;
20083 last_uv444 = DC_PRED;21328 last_uv444 = DC_PRED;
21329+ } else if chroma_422 {
21330+ // lane-av1-422h: same at ss (1,0) -- the strip's own square
21331+ // TX_4X4 chroma unit at its halved position.
21332+ sub8_leaf_chroma422(
21333+ dec, cdfs, neighbours, lmi, DC_PRED, 0, None, skip,
21334+ Some(dv), y, u, v, scan4, base_q_idx,
21335+ neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx),
21336+ (bw, bh), fctx,
21337+ )?;
21338+ last_uv422 = DC_PRED;
20084 } else {21339 } else {
crates/ec-av1/src/mc.rsmodified+31 -14
@@ -2142,8 +2142,11 @@ pub(crate) fn diffwtd_mask(
2142 /// (64-m)*pred1) >> 6` (a plain, unrounded shift, matching the C `>>` on2142 /// (64-m)*pred1) >> 6` (a plain, unrounded shift, matching the C `>>` on
2143 /// `int32_t`) then one final [`round2`] by [`INTER_POST_ROUND`]. `mask` is2143 /// `int32_t`) then one final [`round2`] by [`INTER_POST_ROUND`]. `mask` is
2144 /// always the LUMA-resolution mask (`mask_stride` == luma block width);2144 /// always the LUMA-resolution mask (`mask_stride` == luma block width);
2145-/// `subsampled` selects the 2x2-average chroma read (spec 7.11.3.14 /2145+/// `(subw, subh)` are the PLANE's own subsampling shifts and pick the mask
2146-/// libaom's `subw == 1 && subh == 1` branch) vs. the direct luma read.2146+/// read exactly as aom_dsp/blend-a64-mask.c's four `subw`/`subh` branches do:
2147+/// `(0, 0)` the direct luma sample, `(1, 1)` the 2x2 box average,
2148+/// `(1, 0)`/`(0, 1)` the `AOM_BLEND_AVG` pair average on the subsampled axis
2149+/// alone (4:2:2).
2147 #[allow(clippy::too_many_arguments)]2150 #[allow(clippy::too_many_arguments)]
2148 pub(crate) fn blend_masked_compound(2151 pub(crate) fn blend_masked_compound(
2149 pred0: &[i32],2152 pred0: &[i32],
@@ -2152,7 +2155,8 @@ pub(crate) fn blend_masked_compound(
2152 mask_stride: usize,2155 mask_stride: usize,
2153 w: usize,2156 w: usize,
2154 h: usize,2157 h: usize,
2155- subsampled: bool,2158+ subw: usize,
2159+ subh: usize,
2156 dst: &mut [u16],2160 dst: &mut [u16],
2157 fctx: &crate::decode::FrameCtx,2161 fctx: &crate::decode::FrameCtx,
2158 ) {2162 ) {
@@ -2162,17 +2166,30 @@ pub(crate) fn blend_masked_compound(
2162 let post_round = INTER_POST_ROUND - round_delta(u32::from(crate::decode::bit_depth(fctx)));2166 let post_round = INTER_POST_ROUND - round_delta(u32::from(crate::decode::bit_depth(fctx)));
2163 for i in 0..h {2167 for i in 0..h {
2164 for j in 0..w {2168 for j in 0..w {
2165- let m = if subsampled {2169+ let m: i32 = match (subw, subh) {
2166- let idx = (2 * i) * mask_stride + 2 * j;2170+ (0, 0) => i32::from(mask[i * mask_stride + j]),
2167- round2(2171+ (1, 1) => {
2168- i32::from(mask[idx])2172+ let idx = (2 * i) * mask_stride + 2 * j;
2169- + i32::from(mask[idx + 1])2173+ round2(
2170- + i32::from(mask[idx + mask_stride])2174+ i32::from(mask[idx])
2171- + i32::from(mask[idx + mask_stride + 1]),2175+ + i32::from(mask[idx + 1])
2172- 2,2176+ + i32::from(mask[idx + mask_stride])
2173- )2177+ + i32::from(mask[idx + mask_stride + 1]),
2174- } else {2178+ 2,
2175- i32::from(mask[i * mask_stride + j])2179+ )
2180+ }
2181+ // aom_blend_a64_mask_c's `subw == 1 && subh == 0` branch:
2182+ // `AOM_BLEND_AVG(mask[2 * j], mask[2 * j + 1])` per row.
2183+ (1, 0) => {
2184+ let idx = i * mask_stride + 2 * j;
2185+ (i32::from(mask[idx]) + i32::from(mask[idx + 1]) + 1) >> 1
2186+ }
2187+ // the `subw == 0 && subh == 1` branch: averaged down the
2188+ // columns instead.
2189+ (_sw, _sh) => {
2190+ let idx = (2 * i) * mask_stride + j;
2191+ (i32::from(mask[idx]) + i32::from(mask[idx + mask_stride]) + 1) >> 1
2192+ }
2176 };2193 };
2177 let res = (m * pred0[i * w + j] + (64 - m) * pred1[i * w + j]) >> 6;2194 let res = (m * pred0[i * w + j] + (64 - m) * pred1[i * w + j]) >> 6;
2178 // `post_round` above: `INTER_POST_ROUND - round_delta` -- see2195 // `post_round` above: `INTER_POST_ROUND - round_delta` -- see
lanes/av1422.report.mdadded+64 -0
@@ -0,0 +1,64 @@
1+# lane-av1-422 — 4:2:2 chroma behind the header refusal
2+
3+## Outcome
4+
5+STOP with the refusal in place (`stream.rs` `subsampling_x != subsampling_y`, byte-identical to main).
6+Not pixel-exact yet: the bypassed-refusal probe still desyncs/pantes on the census fixture
7+(`aomenc --profile=2`, 256x144, 16 frames, testsrc2 422 y4m). Next wrong site named below.
8+
9+Landed on this branch: the finished, provably 420/444-invariant slice of the class fix.
10+`cargo check -p ec-av1 --all-targets`: **0 warnings**.
11+
12+## Fixture provenance
13+
14+- `ffmpeg -f lavfi -i testsrc2=256x144:rate=30 -frames:v 16 -pix_fmt yuv422p /tmp/t422.y4m`
15+- `aomenc --codec=av1 --profile=2 --obu -w 256 -h 144 --passes=1 --end-usage=q --cq-level=32 --cpu-used=3 --limit=16`
16+- Refusal string confirmed firing on main before any edit (decode_probe on the OBU).
17+- Oracle decode: `$HOME/.cache/aom-oracle/build/aomdec` (I422 raw). ffmpeg 8.1.2 available; aomdec used as primary pixel oracle.
18+
19+## Class (confirmed against the aom oracle source, `~/.cache/aom-oracle/src`)
20+
21+At ss (1,0) chroma width halves, height does not. Sites assume either a single shared
22+`ss` for both axes or an `ss==(0,0) ? 444 : 420` two-arm split, so 422 falls into the 420 arm.
23+Ground truth tables: `av1_ss_size_lookup` (common_data.c:17), `is_chroma_reference`
24+(av1_common_int.h:1454), `av1_get_max_uv_txsize` (blockd.h:1372).
25+
26+## Fixes landed (all keyed to reachability only at ss 1,0; 420/444 arms byte-identical)
27+
28+1. `decode_rect_split` chroma: square chroma rows (8,8)/(16,16)/(32,32) routed through the
29+ square reader via the `chroma_tiled` arm (libaom: chroma of a 16x8/32x16/64x32 luma strip
30+ is an 8x8/16x16/32x32 square). Includes 4:2:2 CFL strip support via the same path.
31+2. `decode_rect4_16_strip`: (8,8) arm + 422 strips are their own chroma reference
32+ (`ss_size_lookup[16X4][1][0]` = BLOCK_8X4, per-strip, no 4:2:0 pair merge); also fixed a
33+ `lmi.1 - 1` underflow the 422 has_chroma change exposed.
34+3. `decode_leaf_rect` chroma match: (16,16) and (8,32) rows.
35+4. `decode_block_rect4` chroma match: (16,8) and (8,4) rows; the portrait-leaf unreachable now
36+ names the shape.
37+5. `cfl_ac_ss`: `cfl_luma_subsampling_422_lbd_c` branch (horizontal luma pairs, full height,
38+ `(a+b) << 2`), before the 4:2:0 square/rect helpers.
39+6. `mv_to_q4` Y axis: 8 call sites passed `ss_x(fctx)` for the row component — now `ss_y`
40+ (sub-8x8/inter chroma MC bilinear predict sites).
41+7. `has_chroma` for 1:4 strip pairs (decode_rect4_16 + inter twin): `i % 2 == 1 || ss_y == 0`
42+ (is_chroma_reference's row-parity clause drops out when ss_y=0).
43+8. `CHROMA422_SQUARE_HITS` counter (decode.rs): incremented only when a square chroma
44+ coefficient unit is read on a frame with ss (1,0); a restored `/2 chroma height` diverts
45+ 4:2:2 squares onto the rect rows and the counter reads 0. Accessor `chroma422_square_hits()`.
46+ No gate asserts it yet — the refusal still gates all 422 decode (deferred below).
47+
48+## Next wrong site (first blocker on the fixture, in parent's order)
49+
50+`decode_block` (~line 16621 on this tree): the `ss==(0,0) ? 444 : 420` tx-size arm. Its whole
51+chroma section walks `cn x cn` square `chroma_tx` units; at 4:2:2 a square luma block's chroma
52+is (side/2, side) — a RECT plane block (e.g. 8x16 for a 16x16 block) needing rect chroma sets
53+and a non-square unit walk. Same open class after it: `decode_inter_block`'s square-chroma
54+arms (~31922/33422), `film_grain.rs` `apply_grain` (hardcoded 420 subblock halving), and the
55+1:4 portrait-leaf question — `ss_size_lookup[BLOCK_8X32][1][0]` is BLOCK_INVALID yet the
56+aomenc fixture carries 8x32 leaves that aomdec accepts, so the upstream desync (decode_block /
57+inter chroma) is still producing phantom partitions; that ordering must be re-checked once the
58+square-chroma sites land.
59+
60+## Deferred
61+
62+- Refusal lift + witness gate (`chroma422_square_hits()` + pixel-exact vs aomdec/ffmpeg):
63+ deferred(until decode_block/inter square-chroma class lands and the probe is pixel-exact).
64+ Refusal stays; a lifted refusal with wrong pixels is a fail.
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.
lanes/av1422d.report.mdadded+92 -0
@@ -0,0 +1,92 @@
1+# lane-av1-422d — 8x8 leaf chroma unit ported at ss (1,0); refusal stays
2+
3+## Outcome
4+
5+STOP with the 4:2:2 header refusal in place. `decode_leaf8`'s chroma walk now
6+ports the 4:2:2 leaf unit (ONE 4x8 rect transform unit per plane,
7+`TxbSet::ChromaRect8x4` + `SCAN_4X8`, one txb_skip + one scan), and every leaf8
8+chroma read on the measured fixture is rng-for-rng EXACT against the oracle.
9+The stream still desyncs LATER, at `decode_leaf_rect`'s chroma arm (next
10+section), so the refusal is retained byte-identical and the probe bypass was
11+reverted before commit.
12+
13+## Change (all inside decode_leaf8's own chroma scope)
14+
15+- `decode_leaf8` (decode.rs): `chroma_422 = ss_x == 1 && ss_y == 0`; all three
16+ arms (skip, single-8x8-unit, TX4) branch to `leaf8_chroma422_unit` for the
17+ rect unit. The 4:2:0 `(4, TxbSet::Chroma4, scans.1)` selection and the 4:4:4
18+ arm are untouched. The chroma unit does NOT follow the luma var-tx split
19+ (`uv_txsize` is `av1_get_max_uv_txsize` of the block, still one 4x8 unit
20+ when luma resolves TX_4X4). The intrabc DV copy covers the whole plane block
21+ (4x8) at ss (1,0).
22+- `leaf8_chroma422_unit` (new, next to `decode_leaf8`): mirrors
23+ `sub8_leaf_chroma444`'s rect arm at the leaf's halved position — entropy
24+ context from the leaf's own 8x8 luma-span above/left state (no `+3`, the
25+ unit covers the plane block exactly), CFL source the leaf's whole 8x8 luma
26+ block, mode-derived default `tx_type` unless `INTRABC_CHROMA_TX` is armed,
27+ prediction override (intrabc DV over palette) set inside, skip predicts with
28+ `ZERO_RESIDUAL`.
29+- UV palette map extent (decode.rs:15808, leaf8's mode-info reader): the map
30+ is decoded over `(side >> ss_x, side >> ss_y)` = 4x8 via
31+ `decode_color_index_map_wh`, not the square call's `(side >> ss_x)`-squared
32+ 4x4 (class: plane-block extent squared a rect). At 4:2:0/4:4:4 the arguments
33+ evaluate identically; only ss (1,0) changes. Found live: the 16-entry map
34+ fed a 16-sample prediction override into the first 32-sample rect unit and
35+ panicked `reconstruct_rect` (`index out of bounds: the len is 16 but the
36+ index is 16`).
37+
38+## Measurement
39+
40+Fixture `/tmp/t422.obu`, sha256
41+`d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129` (reused
42+from av1422b/c by hash). Oracle `$HOME/.cache/aom-oracle/build/aomdec`
43+`EC_TRACE=1 EC_TRACE_MODE_STEP=1 EC_TRACE_COEFF=1`; ours `decode_probe` (debug,
44+private target dir) same env plus `EC_AV1_ALLOW_422_PROBE=1` (LOCAL bypass,
45+reverted).
46+
47+Coefficient-unit pairing (all_zero entry rng -> post rng), first HORZ_A 16x16
48+of frame 0:
49+
50+- leaf (0,0): 4x luma TX_4X4 ✓, U `tx_size=5` entry 46416 -> 35360 ✓, V
51+ entry 34824 -> 41920 ✓ (both my rect reads).
52+- leaf (0,2): luma TX_8X8 ✓ (post 45770 = oracle), U entry 37668 -> 33728 ✓,
53+ V entry 60936 -> 58556 ✓.
54+- 16x8 strip: luma `tx_size=8` entry 59680 -> 58977 ✓.
55+
56+All four leaf8 chroma rect reads match the oracle rng-for-rng through their
57+full coefficient bodies (each next unit's entry rng proves the previous
58+body's bit consumption).
59+
60+## First remaining divergence (named next site)
61+
62+`decode_leaf_rect`'s chroma arm, decode.rs:13060-13067. For a 16x8/8x16 rect
63+leaf at ss (1,0) the chroma plane block is 8x8 — SQUARE
64+(`TxbSet::Chroma8` + `default_scan(8)` through `read_plane`, the
65+`chroma_tiled` (8,8) shape) — but the code picks `TxbSet::ChromaRect8x4` +
66+`SCAN_8X4`/`SCAN_4X8` keyed on `ss_x == 0`. Measured: the HORZ_A's 16x8 strip
67+(mi_row=2, mi_col=0) — oracle U/V units are `tx_size=1` (TX_8X8 class, 64-
68+position eob alphabet, ctx=8); ours enters the U unit's txb_skip at the same
69+rng 38672 and coincidentally matches that one symbol (the offset-7 row shares
70+`txb_skip_chroma_8`), then reads eob off the 32-position chroma-rect alphabet
71+(eob=27 vs oracle eob=32) and desyncs. Everything after shifts.
72+
73+## Second site behind it
74+
75+`decode_rect_split`'s chroma shape table (decode.rs:10114-10133) has no 4:2:2
76+rows: a 16x64 luma strip's `(8, 64)` plane block fires
77+`EC_RECTCHROMA_GAP luma=16x64 tx=16x32 chroma=8x64` (decode stops at mi_row=16
78+once the leaf_rect site is passed). Same class likely holds for other
79+unhalved-height plane blocks in that table.
80+
81+## State
82+
83+- Refusal `a chroma format of 4:2:2 (subsampling_x != subsampling_y)...`
84+ byte-identical (bypass reverted; `git diff` shows only decode.rs).
85+- `decode_leaf_split4`, `sub8_leaf_chroma444`, `reconstruct_mc_rect`, the
86+ resize header reader, decode.rs 34390-34440: untouched.
87+- 420 gate green:
88+ `a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_tx_split_decodes_pixel_exact`
89+ + its 10-bit twin — 6/6 pixel-exact matches each, 0 refusals (the gate
90+ exercises the skip and TX4 arms this lane restructured).
91+- `cargo check -p ec-av1`: 0 warnings.
92+- No push.
lanes/av1422e.report.mdadded+84 -0
@@ -0,0 +1,84 @@
1+# lane-av1-422e — leaf_rect chroma is an 8x8 square unit at ss (1,0); refusal stays
2+
3+## Outcome
4+
5+STOP with the 4:2:2 header refusal in place, byte-identical. `decode_leaf_rect`'s
6+chroma arm now keys on ss: at ss (1,0) a 16x8/8x16 luma leaf's chroma plane
7+block is an 8x8 SQUARE (`TxbSet::Chroma8` + `default_scan(8)`), and every
8+leaf_rect chroma read on the measured fixture is rng-for-rng EXACT against the
9+oracle — the av1422d desync at the HORZ_A 16x8 strip (mi(2,0)) is gone, along
10+with everything up to the first 16x16 square block. The stream now desyncs at
11+that square block's chroma (next section), so the refusal is retained and the
12+probe bypass was reverted before commit (`git diff` touches only decode.rs).
13+
14+## Change (decode.rs only)
15+
16+- `decode_leaf_rect` chroma arm (was decode.rs:13060-13067): the
17+ `ss_x == 0`-keyed selection replaced by a three-way arm — `chroma_422`
18+ (`ss_x == 1 && ss_y == 0`) picks `TxbSet::Chroma8` + `default_scan(8)` for
19+ the 8x8 square plane block (luma scan unchanged: SCAN_16X8/SCAN_8X16);
20+ 4:2:0 keeps `TxbSet::ChromaRect8x4` + SCAN_8X4/SCAN_4X8; 4:4:4 keeps
21+ `TxbSet::ChromaRect16x8` + the full SCAN_16X8/SCAN_8X16. Doc comment above
22+ `decode_leaf_rect` updated to name all three subsamplings.
23+- Untouched: `decode_leaf8`, `leaf8_chroma422_unit`, `sub8_leaf_chroma444`,
24+ `decode_leaf_split4`, `reconstruct_mc_rect`, the resize header reader,
25+ `decode.rs` 34390-34440.
26+
27+## Measurement
28+
29+Fixture `/tmp/t422.obu`, sha256
30+`d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129` (reused by
31+hash). Oracle `$HOME/.cache/aom-oracle/build/aomdec`
32+`EC_TRACE=1 EC_TRACE_MODE_STEP=1 EC_TRACE_COEFF=1`; ours `decode_probe` (debug,
33+private target dir) same env plus a LOCAL `EC_AV1_ALLOW_422_PROBE` bypass
34+env-gated at the stream.rs refusal — reverted before commit, and the refusal
35+was re-proven to fire without the env.
36+
37+The first leaf_rect 16x8 strips that desynced in av1422d now pair rng-for-rng
38+through their full luma + U + V coefficient bodies (all EC_COEFF_STEP rngs
39+match: all_zero, tx_type, eob, base_eob, br, sign, post_golomb), and the ISTEP
40+stream stays identical well past them. With that site passed, decode now
41+reaches the first 16x16 square intra block, mi(4,4).
42+
43+## First remaining divergence (named next site, with oracle evidence)
44+
45+The SQUARE-block path's 4:2:2 chroma model, decode.rs:16704-16721
46+(lane-av1-422b's arm inside the `(luma_set, chroma_set, luma_tx, chroma_tx,
47+scans)` selection): it models `av1_get_max_uv_txsize` of the (side/2, side)
48+plane block as "the SQUARE transform of the smaller dimension" and walks a grid
49+of square units (side 16 -> two 8x8 units). The oracle disagrees — aom reads
50+`max_txsize_rect_lookup` of the PLANE block, a RECT that fills it exactly:
51+
52+- ours, mi(4,4) side=16: all_zero `side=8 ctx=5` at rng 44044 -> eob read on
53+ the 8x8-class alphabet (eob=48) — the first of two square units.
54+- oracle, same block: `all_zero plane=1 bc=0 br=0 ctx=9 txs=2` at rng 36040 —
55+ ONE unit, TX_8X16 class (16x16 entropy class), whole 8x16 plane block.
56+
57+Correct model per aom (`av1_get_max_uv_txsize` = `max_txsize_rect_lookup`
58+[plane_bsize], then `av1_get_adjusted_tx_size`): side 8 -> TX_4X8
59+(ChromaRect8x4 + SCAN_4X8, one unit — the shape av1422d proved at leaf8);
60+side 16 -> TX_8X16 (ChromaRect16x8 + SCAN_8X16, one unit); side 32 -> TX_16X32
61+(ChromaRect32x16 + SCAN_16X32, one unit); side 64 -> TX_32X64 adjusts to
62+TX_32X32, i.e. two stacked 32x32 units, which the current square walk already
63+produces. The fix spans the square path's three chroma walks (skip 17019-17067,
64+single-unit 17120-17260, chunked 17273-17553) since they thread `chroma_tx` as
65+both unit dims; it needs per-axis unit dims keyed to ss (1,0). That is its own
66+lane round — not started, no rows invented, no BLOCK_INVALID portrait shape.
67+
68+The av1422d second site (decode_rect_split's chroma table missing (8,64)) did
69+NOT fire this round: the square-path site above blocks first. The
70+decode_rect_split 16x8-strip reads (chroma 8x8 via the chroma_tiled arm) pass
71+the oracle rng-for-rng; the repeated `EC_RECTCHROMA_GAP luma=16x8 tx=8x8
72+chroma=8x8` prints are the pre-existing diagnostic (chroma.is_none() before the
73+chroma_tiled fallback), not refusals.
74+
75+## State
76+
77+- Refusal `a chroma format of 4:2:2 (subsampling_x != subsampling_y)...`
78+ byte-identical (bypass reverted; probe refuses without the env).
79+- `cargo check -p ec-av1` (private target dir): 0 warnings.
80+- 420 gates green: `a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_
81+ tx_split_decodes_pixel_exact` + its 10-bit twin — 2/2 pass (exercises the
82+ skip and TX4 arms restructured in av1422d; the new 422 arm is unreachable at
83+ 420 by its ss condition).
84+- No push. Traces left at /tmp/ours422.txt and /tmp/oracle422.txt.
lanes/av1422f.report.mdadded+115 -0
@@ -0,0 +1,115 @@
1+# lane-av1-422f — square-block chroma is the plane block's own rect unit; refusal stays
2+
3+## Outcome
4+
5+STOP with the 4:2:2 header refusal in place, byte-identical (probe refuses
6+without the env; the local bypass was reverted before commit). The
7+square-block path (decode.rs's `(luma_set, chroma_set, luma_tx, chroma_tx,
8+scans)` selection, formerly 16704-16721) now models `av1_get_max_uv_txsize`
9+as `av1_get_adjusted_tx_size(max_txsize_rect_lookup[plane_bsize])` — the RECT
10+that fills the (side/2, side) plane block — and all three chroma walks read
11+one `(chroma_tx, chroma_tx_h)` unit per grid cell, keyed on ss (1,0). The
12+av1422e first miss (mi(4,4) side 16: ours two 8x8 units, oracle one TX_8X16)
13+is gone, and the decode now aligns with the oracle unit-for-unit through 117
14+coefficient units — every 16x16 block's U/V TX_8X16 pair, every 8x8 leaf's
15+U/V TX_4X8 pair, every 16x8 strip's 8x8-square chroma — with equal entry rngs
16+wherever ours prints them. The stream is not pixel-exact: the next divergence
17+is the sub-8x8 4x4-leaf chroma at 4:2:2 (TX_4X4 units, one per even-column
18+leaf), which lives in `decode_leaf_split4`/`decode_leaf8` — other lanes — so
19+the refusal is retained.
20+
21+## Change (decode.rs + decode_probe.rs only)
22+
23+- Selection arm at ss (1,0): per-axis unit dims `chroma_tx` (width) x
24+ `chroma_tx_h` (height) — 4 -> (4,4), 8 -> (4,8), 16 -> (8,16), 32 ->
25+ (16,32), 64/128 -> (32,32) — with the unit's TxbSet/scan:
26+ `ChromaRect8x4`+`SCAN_4X8`, `ChromaRect16x8`+`SCAN_8X16`,
27+ `ChromaRect32x16`+`SCAN_16X32`, `Chroma32`+scan32. The destructure gains
28+ `chroma_tx_h`; 4:2:0/4:4:4/lossless arms carry `chroma_tx` twice, so their
29+ walks are untouched.
30+- New `read_rect_chroma_unit`: one rect chroma unit via the
31+ `read_coeffs_rect` route (the `chroma_tiled` arm's and
32+ `leaf8_chroma422_unit`'s proven shape): `txb_skip_ctx` = above+left in the
33+ offset-7 rows (the unit covers the plane block exactly, so no +3), the
34+ mode-derived default `tx_type` unless `INTRABC_CHROMA_TX` is armed, the
35+ `side >= 32` DCT_DCT clamp, `dequant_and_inverse_typed_wh` +
36+ `push_intra_rect`. Bumps the new `CHROMA422_RECT_HITS` witness counter
37+ (keyed ss (1,0), unit w != h).
38+- New `push_intra_unit`: `push_intra` when square, `push_intra_rect` when
39+ rect — used by the skip walk.
40+- All three chroma walks (skip, single-TU, chunked) key on the per-axis
41+ unit dims: `cn_rows = chroma_height / chroma_tx_h`, `luma_span_y =
42+ chroma_tx_h << ss_y`, per-axis cu positions and palette windows. Below
43+ side 64 a 4:2:2 frame's grid is 1x1 and the one unit is the whole plane
44+ block. The chunked walk's edge clip computes `max_units_h` per axis at
45+ ss (1,0) (the shared halved formula assumes a subsampled height and would
46+ clip units libaom codes); the shared rows stay for 4:2:0/4:4:4.
47+- New `Neighbours::around_mi_422_chroma` for the square path's chroma context
48+ reads: libaom `get_txb_ctx_general` sums its dc-sign votes over
49+ `txb_w_unit` CHROMA 4-px cells, and at ss_x 1 one chroma cell spans TWO
50+ luma mi columns — the per-luma-mi sum double-counts the above votes and
51+ flips `dc_sign_ctx` when the above and left votes have opposite signs
52+ (measured at mi(4,4) plane 1: ours read `dc_sign_cdf[1]`, the oracle row
53+ 0). Sampling every second above cell counts each chroma column once, which
54+ is exactly libaom's sum; the level booleans are ORs over duplicated cells
55+ and cannot change. Used by the single-TU walk's rect branch and both
56+ multi-unit loops at ss (1,0) only; 4:2:0/4:4:4 keep `around_mi_rect`.
57+- `examples/decode_probe.rs`: prints `chroma422_rect`.
58+
59+Untouched: `decode_leaf8`, `decode_leaf_split4`, `decode_rect4_16_strip`,
60+`decode_block_128rect`, `decode_rect_split`, the resize header reader, the
61+frame-9 filter path, and refusal_inventory.rs (the refusal string is
62+byte-identical; the gate stays green).
63+
64+## Measurement
65+
66+Fixture `/tmp/t422.obu`, sha256
67+`d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129` (reused by
68+hash, 256x144, 22 frames). Oracle `$HOME/.cache/aom-oracle/build/aomdec`
69+`EC_TRACE=1 EC_TRACE_MODE_STEP=1 EC_TRACE_COEFF=1`; ours `decode_probe`
70+(debug, `gate-counters`, private target dir) with a LOCAL
71+`EC_AV1_ALLOW_422_PROBE` env-gated bypass at the stream.rs refusal —
72+reverted before commit, and the refusal re-proven to fire without the env.
73+
74+- Unit-level: 117 consecutive units with equal ENTRY rngs (rect reads print
75+ `entry=`; the first entry mismatch is unit #117), identical unit order and
76+ shapes: 16x16 blocks read ONE TX_8X16 per plane (mi(4,4): U entry 44042,
77+ all_zero ctx row 2 = libaom ctx 9, post-rng 36040, eob 3 — the av1422e
78+ first miss, now exact), 8x8 leaves ONE TX_4X8 per plane, 16x8 strips the
79+ 8x8 square, 8x16 strips 4x16.
80+- Symbol-level: the deduplicated rng trajectories match value-for-value
81+ through the mi(8,0) leaf's V (ours state 1100), modulo four
82+ oracle-instrumentation print gaps (sub-reads libaom's patched print does
83+ not emit; the trajectories re-align around each).
84+- Counters: `chroma422_rect: 28`, `chroma422_square: 23` — 28 rect chroma
85+ units ran on the 4:2:2 frame (a 4:2:0/4:4:4 frame cannot increment it; the
86+ counter reads 0 under the old square model).
87+
88+## First remaining divergence (named next site, with oracle evidence)
89+
90+At the 8x8 sub8 group whose leaves sit at mi(8,10)/(8,11)/(9,10)/(9,11): the
91+oracle's 4x4 LEAVES at even mi columns are chroma references at 4:2:2 and
92+each codes a TX_4X4 chroma unit (mi(9,10) plane 1, 38 steps, after only its
93+own luma) — `ss_size_lookup[BLOCK_4X4][1][0]` is BLOCK_4X4, so the 2x4 plane
94+rounds up and reads as TX_4X4. Ours reads the leaf's second luma TX_4X4 as
95+all-zero where the oracle codes coefficients (oracle 16 steps, ours 1), the
96+first value-level divergence, and everything after is desynced; the run then
97+ends at `decode_rect4_16_strip`'s closed-shape panic (shape-driven, reached
98+by the same partition walk). Both sites live in `decode_leaf_split4` /
99+`decode_leaf8` / `decode_rect4_16_strip` — other lanes. The sub-8x8 4:2:2
100+model needs the is_chroma_ref rule `!(mi_col & ss_x)` (every even-column
101+leaf, not 4:2:0's single bottom-right leaf) plus the TX_4X4 chroma shape.
102+
103+## State
104+
105+- Refusal `a chroma format of 4:2:2 (subsampling_x != subsampling_y)...`
106+ byte-identical (bypass reverted; `git diff` touches only decode.rs and
107+ decode_probe.rs; probe refuses without the env).
108+- `cargo check -p ec-av1` (private target dir
109+ `$HOME/.cache/cargo-target-av1422f`): 0 warnings.
110+- 420 gates green: `a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_
111+ whose_tx_split_decodes_pixel_exact` + its 10-bit twin — 2/2 pass (the new
112+ arms are unreachable at 420 by their ss condition; `chroma_tx == chroma_tx_h`
113+ on every 4:2:0/4:4:4 path). Refusal gate
114+ `a_non_420_subsampled_sequence_header_is_refused_by_name` green.
115+- No push. Traces left at /tmp/ours422f.txt and /tmp/oracle422.txt.
lanes/av1422filter.report.mdmodified+22 -3
@@ -69,6 +69,22 @@
69 69
70 ## Decision70 ## Decision
71 71
72+- **444 LR follow-up (review finding 2): RED, stopped and reported.** A
73+ 3-frame 192x160 `aomenc --profile=1 --enable-restoration=1` stream
74+ (lr types per frame: `[Sgrproj,None,Switchable]` / `[None,None,Sgrproj]`
75+ / `[Sgrproj,None,Switchable]`) diverges from both the instrumented aomdec
76+ and ffmpeg on frames 0/1 (~26k samples/plane, maxabs 255) and matches
77+ exactly on frame 2. The divergence is already fully present at
78+ EC_AV1_PREFILT_DUMP (frame 0 pre: Y 6124 @ (0,128), U 9176 @ (160,64),
79+ V 10196 @ (128,64)) — a pre-existing 444 RECONSTRUCTION defect, not a
80+ loop-filter one and not this lane's regression: the parent commit
81+ (cc3783f4, scratch worktree) measures 26673/26310/158 against the same
82+ stream, so this lane's ss_y fix strictly improves 444 (frame 2 went to
83+ exact, frames 0/1 shrank) but cannot pin a pixel-exact gate over a
84+ stream whose reconstruction is still wrong. Named for the owning lane:
85+ 444 intra reconstruction around the row-64/row-128 SB boundaries (class:
86+ pre-existing 444 recon; loop filters exonerated — the damage exists
87+ pre-deblock and the filter stages track it 1:1).
72 - The header refusal STAYS unconditional in `stream.rs` — the probe bypass88 - The header refusal STAYS unconditional in `stream.rs` — the probe bypass
73 was local-only, applied and reverted byte-identical before the commit89 was local-only, applied and reverted byte-identical before the commit
74 (`git diff` after the revert carries only the decode.rs fix); the90 (`git diff` after the revert carries only the decode.rs fix); the
@@ -77,9 +93,12 @@
77 `sub8_leaf_chroma422` (parent lane's three fixes) untouched.93 `sub8_leaf_chroma422` (parent lane's three fixes) untouched.
78 - The 8-bit `EC_AV1_POSTCDEF_DUMP` rung was added to the ORACLE's source94 - The 8-bit `EC_AV1_POSTCDEF_DUMP` rung was added to the ORACLE's source
79 tree (`$HOME/.cache/aom-oracle/src/av1/decoder/decodeframe.c`, rebuilt95 tree (`$HOME/.cache/aom-oracle/src/av1/decoder/decodeframe.c`, rebuilt
80- with ninja), not to this repo's `scripts/instrument-aom-oracle.sh` — the96+ with ninja) and transcribed into
81- script's generator should grow the same patch if the oracle is ever97+ `scripts/instrument-aom-oracle.sh` as rung 15 — its generator block
82- rebuilt from scratch.98+ reproduces the hand patch byte-for-byte (verified by strip-and-replay on
99+ the live tree; the marker `EC_INSTRUMENTED_POSTCDEF` keeps re-runs
100+ no-op), so `build-aom-oracle.sh` + the script rebuild the full ladder
101+ from scratch again.
83 102
84 ## Verification103 ## Verification
85 104
lanes/av1422g.report.mdadded+102 -0
@@ -0,0 +1,102 @@
1+# lane-av1-422g — sub-8 even-column chroma-ref arm; STOP: split4 is never reached on t422
2+
3+## Outcome
4+
5+STOP with the 4:2:2 header refusal in place, byte-identical (the local
6+`EC_AV1_ALLOW_422_PROBE` bypass was reverted before commit; the probe refuses
7+without the env — `frames_dispatched: 0`). The even-column chroma-reference
8+arm for ss (1,0) is in `decode_leaf_split4` per the parent's rule
9+(`is_chroma_ref = !(mi_col & ss_x)`, one TX_4X4 chroma unit per plane per
10+even-column leaf, 4:2:0 keeps its single bottom-right leaf), but it is
11+UNPROVEN and — the round's real finding — UNREACHABLE on this fixture:
12+
13+the frame-0 partition walk never takes an 8x8 `PARTITION_SPLIT`. An
14+`EC_AV1_TRACE` probe printed **zero** split8 group entries before the run
15+dies at `decode_rect4_16_strip`'s closed-shape panic. Our trace is
16+byte-identical to 422f's (modulo pid), so the divergence 422f attributed to
17+the mi(9,10) sub-8 chroma begins EARLIER: by the time the walk reaches the
18+8x8 at mi(8,10), ours reads a partition value that is not SPLIT, while the
19+oracle's own trace decodes four 4x4 leaves at mi(8,10)/(8,11)/(9,10)/(9,11).
20+Per instruction 2 the named stop line is:
21+
22+ crates/ec-av1/src/decode.rs:14888 — unreachable!("decode_rect4_16_strip chroma shape set is closed")
23+
24+reached with chroma shape `(16, 64)` off a `luma=32x64 tx=16x16` strip (the
25+`EC_RECTCHROMA_GAP luma=32x64 tx=16x16 chroma=16x64` diagnostic prints right
26+before the panic; the 16 prints of `luma=16x8 → chroma=8x8` earlier are the
27+4:2:2 square rows downstream and are harmless). decode_rect4_16_strip was not
28+edited; that panic is the next lane's gate, not this one's fix.
29+
30+## Change (decode.rs + decode_probe.rs only)
31+
32+- `decode_leaf_split4`: `has_chroma` now branches per subsampling — 4:4:4
33+ every leaf, 4:2:2 `(lmi.1 & 1) == 0` (every even-mi-column leaf), 4:2:0
34+ `i == 3` unchanged. A `chroma_422` flag (ss_x 1, ss_y 0) and a
35+ `last_uv422` coarse-slot value were added; the group tail gained a 4:2:2
36+ branch that only fills `above_uv_mode`/`left_uv_mode` from the group's
37+ last chroma-reference leaf (bottom-left), and the tail's chroma state
38+ stamp is skipped at 4:2:2 (the per-leaf units already stamped).
39+- New `sub8_leaf_chroma422` (beside `sub8_leaf_chroma444`): one square
40+ TX_4X4 chroma unit per plane at the chroma position
41+ (`px >> ss_x`, `py >> ss_y`) — `ss_size_lookup[BLOCK_4X4][1][0]` is
42+ BLOCK_4X4, so the (2,4) plane area rounds up to the square 4x4 read — via
43+ `read_plane`'s proven `TxbSet::Chroma4` + `TX4` route, with
44+ `Neighbours::around_mi_422_chroma(lmi, 8, 4)` context reads (the unit's 4
45+ chroma-px width spans TWO luma mi columns; sampling every second above
46+ cell counts each chroma column once), `cfl_src_rect(px, py, 8, 4)` CfL
47+ source, skip arm (predict-only, intrabc-slot disarm counted), intrabc arm
48+ (frame copy at the DV with the ss shifts), and per-leaf entropy stamping
49+ (1 mi row tall, both luma mi columns of the one chroma column).
50+- New `CHROMA422_SUB8_HITS` witness counter, bumped only on the two
51+ coefficient-reading arms (skip does not count); printed as
52+ `chroma422_sub8` by `examples/decode_probe.rs`.
53+- Untouched: `decode_leaf8`, `decode_rect4_16_strip`, `decode_block_128rect`,
54+ `decode_rect_split`, the 4:2:0 group tail (including its SKIP arm at
55+ decode.rs:19169-19170 — the sibling-owned flat-DC miss), the square-block
56+ selection arm, `stream.rs` (bypass reverted; refusal string
57+ byte-identical), `refusal_inventory.rs`.
58+
59+## Measurement
60+
61+Fixture `/tmp/t422.obu`, sha256
62+`d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129` (reused
63+by hash, 256x144, 22 frames). Ours `decode_probe` (debug, gate-counters,
64+private target dir) with the LOCAL env bypass; oracle traces from 422f left
65+at /tmp/oracle422.txt.
66+
67+- **Reach probe**: with `EC_AV1_TRACE=1`, a temporary per-group print in
68+ `decode_leaf_split4` (since removed) fired ZERO times before the panic —
69+ split4 never runs on this stream; the arm cannot fire, and the
70+ `chroma422_sub8` counter reads 0 for the trivial reason.
71+- **Trace identity**: our full run (stderr trace, 13029 lines) is
72+ byte-identical to 422f's /tmp/ours422f.txt except the panic line's thread
73+ id — the 422g changes do not alter the trajectory, confirming the
74+ pre-split8 divergence.
75+- `cargo check -p ec-av1` (private target dir): 0 warnings.
76+- 420 gate green: `a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_
77+ whose_tx_split_decodes_pixel_exact` 1/1 passed (`cargo test -p ec-av1
78+ --lib`); all new arms are keyed on ss (1,0), unreachable at 4:2:0/4:4:4.
79+
80+## Next divergence (restated, for the lane that owns the walk)
81+
82+The first live defect is UPSTREAM of sub-8: between the last symbol-level
83+match (mi(8,0) 8x8 leaf's V) and the mi(8,10) 8x8, ours mis-reads the 8x8
84+partition symbol (oracle SPLITs, we do not), and the desynced walk later
85+lands on the 32x64 strip whose 16x64 chroma has no table row (panic above).
86+Two candidate sites for whoever picks this up: the partition-symbol context
87+feeding `partition_w8` after an 8x8 leaf run (422f's tail bookkeeping
88+changed side_mi/partition ctx for the following sibling), or an 8x8-leaf
89+chroma/context read that consumes the wrong rng count and shifts every later
90+partition read. Note the rect split4 sibling (the 8x16/16x8 group walker
91+with `bw`/`bh` args, ~decode.rs:20500) has the same 4:2:0-style chroma and
92+will need the same even-column treatment once the walk reaches any rect sub-8
93+group at 4:2:2.
94+
95+## State
96+
97+- Refusal `a chroma format of 4:2:2 (subsampling_x != subsampling_y)...`
98+ byte-identical; `git diff` touches only decode.rs and decode_probe.rs;
99+ probe refuses without the env (frames_dispatched: 0).
100+- Committed on lane-av1-422g (5e163e94). No push.
101+- Traces left at /tmp/ours422g_trace.txt (EC_TRACE_COEFF run) and
102+ /tmp/ours422g_t2.txt (EC_AV1_TRACE reach run).
lanes/av1422h.report.mdadded+96 -0
@@ -0,0 +1,96 @@
1+# lane-av1-422h — 4:2:2 sub-8/rect chroma model proven rng-exact to the bottom-edge SBs; refusal stays
2+
3+## Outcome
4+
5+The assignment's premise — "ours reads a non-SPLIT partition at mi(8,10)" — was
6+FALSE, and this round proves it with partition-level oracle traces: at mi(8,10)
7+both decoders read `bsize=3 ctx=0 rng=37068 → value=1` (PARTITION_HORZ).
8+`read_partition` in the oracle source already carried an `EC_PART` probe
9+(patch never enabled by the 422f/g generation recipe), so this round's traces
10+are the first with the walk checkpointed per partition read; pairing them
11+(`EC_PART` rng values, tell offset constant +14) shows the true first
12+divergences and lets every fix below be verified rng-for-rng.
13+
14+Four 4:2:2 chroma-model defects found and fixed (all in `decode_leaf_rect8`,
15+`decode_leaf8`, `decode_leaf_split4`/`sub8_leaf_chroma422`, `decode_block`):
16+
17+1. **`decode_leaf_rect8` (BLOCK_8X4/BLOCK_4X8 strips) used the 4:2:0
18+ `i == 1`-only chroma rule.** `is_chroma_reference`
19+ (av1_common_int.h:1459) at ss (1,0): a HORZ pair's BLOCK_8X4 strips are
20+ BOTH chroma references (`!(bw & 1)`), a VERT pair's BLOCK_4X8 strips keep
21+ the odd-column leaf. Oracle evidence at the mi(8,10) HORZ pair: uv_mode
22+ read at BOTH (8,10) and (9,10), each strip followed by its own one-TX_4X4
23+ chroma unit per plane. Fixed `has_chroma` to `!vert || i == 1` at 4:2:2
24+ and decoded each reference strip's chroma right after its luma via
25+ `sub8_leaf_chroma422` (split path, whole-leaf path, intrabc path), with
26+ the 4:2:0 group tail gated off at 4:2:2 and the coarse uv slots filled
27+ from the last reference strip. The mi(8,10) pair now decodes
28+ rng-for-rng (strip mode reads end at oracle's exact rngs 63250/33264).
29+2. **`decode_leaf_split4`'s 4:2:2 column parity was inverted** (422g's
30+ `(mi_col & 1) == 0` "even-column" rule — derived by 422f from a
31+ pre-partition-trace misreading of the (8,10) HORZ pair as a split
32+ group). Oracle, mi(30,42) split group: uv_mode read at mi(30,43) and
33+ mi(31,43) ONLY — the ODD columns, per the formula's column clause
34+ `(mi_col & 1)`. Fixed to `(lmi.1 & 1) == 1`.
35+3. **`sub8_leaf_chroma422` anchored the odd-column leaf's ctx read/write at
36+ the leaf's own column.** libaom anchors at the FLOOR chroma cell
37+ (`pd->above_entropy_context + blk_col` with `blk_col = mi_col >> ss_x`):
38+ an odd-column 4x4 leaf's unit starts at chroma px 86, whose containing
39+ cell is luma mi col 42, so the ctx read AND the per-TU state write land
40+ on luma mi 42,43, not 43,44. Added `ctx_mi = (lmi.0, lmi.1 & !1)`.
41+4. **`decode_leaf8`'s 4:2:2 chroma rect unit read its txb ctx through the
42+ plain `around_mi`** — the 422f-class dc-vote double-count (one chroma
43+ ctx cell spans TWO luma mi columns at ss_x 1) in the leaf8 path.
44+ Oracle evidence at mi(2,24) plane 2: ours dc_sign row 0, oracle row 2.
45+ Both 422 arms now read `around_mi_422_chroma(leaf_mi, 8, 8)`.
46+
47+## Measurement
48+
49+Fixture `/tmp/t422.obu` reused by hash
50+`d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129`
51+(256x144, 22 frames). Oracle
52+`$HOME/.cache/aom-oracle/build/aomdec EC_TRACE=1 EC_TRACE_MODE_STEP=1
53+EC_TRACE_COEFF=1 EC_PALSYN=1` (the `EC_PART` probes ship in the patched
54+tree's `read_partition`); ours `decode_probe` with a LOCAL
55+`EC_AV1_ALLOW_422_PROBE` bypass at the stream.rs refusal — REVERTED before
56+commit, refusal re-proven to fire by name without the env.
57+
58+- After fixes 1–3, the frame-0 partition streams pair 1:1 rng-for-rng from
59+ the tile start through oracle #327 — tell offset constant +14 — covering
60+ every HORZ/VERT 8x8 pair, every split4 group, the (28,44) 16x16 square
61+ (one TX_8X16 chroma per plane, ctx row 9 = our 7-base row 2 after fix 1's
62+ stamp anchor) and the (30,42)/(24,56) bodies.
63+- Fix 4 (leaf8 dc-sign sampling) was located by the same pairing: the
64+ mi(2,24) 8x8 NONE leaf consumed the oracle's exact 13 bits but landed at
65+ rng 53768 vs 61448; the sign phase of its V plane diverged (dcctx 0 vs 2).
66+
67+## Next divergence (named stop, for the lane that owns the partial-SB walk)
68+
69+Frame 0 now desyncs where the bottom superblock row begins: the 64x64 at
70+mi(32,0) hangs over the bottom edge (`has_rows=false`), and libaom READS a
71+gathered two-symbol partition there (`EC_PART mi_row=32 mi_col=0 bsize=12
72+ctx=13 tell=19221 rng=54818` → `EC_PART_VAL value=1`, i.e. HORZ from the
73+`partition_gather_horz_alike` cdf, splitting the SB into two 64x32
74+strips). Our walk reads NO partition symbol for that SB and dispatches
75+straight into a 64x32 strip walk (`EC_RECTCHROMA_GAP luma=64x32
76+tx=32x32 chroma=32x32`), one symbol behind from there. Note the strip
77+reader's 4:2:2 chroma for a 64x32 strip (32x32 square, `ss (1,0)`) rides
78+the existing square arm. The `decode.rs:14888` closed-shape panic and the
79+`decode.rs:19169` skip arm were not touched.
80+
81+## State
82+
83+- Refusal `a chroma format of 4:2:2 (subsampling_x != subsampling_y)...`
84+ byte-identical; `git diff` touches only `decode.rs`; the probe refuses
85+ without `EC_AV1_ALLOW_422_PROBE` (measured this round).
86+- `cargo check -p ec-av1` (private target dir
87+ `$HOME/.cache/cargo-target-av1422h`): 0 warnings.
88+- 420 gates green: `a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_
89+ whose_tx_split_decodes_pixel_exact` 2/2 (both variants) and
90+ `a_non_420_subsampled_sequence_header_is_refused_by_name` 1/1. Every
91+ changed arm is keyed on ss (1,0); the 4:2:0/4:4:4 paths keep their
92+ proven rows and stamps.
93+- Temporary EC_RECTDBG/LEAFDBG/CHROMAWALK instrumentation removed before
94+ commit.
95+- No push. Traces left at /tmp/o_pal.txt (full-probe oracle),
96+ /tmp/o_part.txt, /tmp/u_cur.txt.
lanes/av1422i.report.mdadded+76 -0
@@ -0,0 +1,76 @@
1+# lane-av1-422i — bottom-SB-row partition gather re-measured: already rng-exact at HEAD; refusal stays
2+
3+## Outcome
4+
5+The assignment's premise — "ours reads no partition symbol at the bottom 64x64
6+mi(32,0)" — is FALSE at HEAD 6cdd3dae, and this round proves it with live
7+traces instead of the previous round's EC_PART-only dumps. The gathered
8+two-symbol read the assignment asks for has existed since lane-hgkf r1
9+(`decode.rs:27096`, the `(true, false)` arm of the 64-level dispatch): it reads
10+`gather(&cdfs.partition_w64[ctx], VERT_ALIKE)` with
11+`VERT_ALIKE = [2, SPLIT, 4, 6, 7, 9]`, maps 0 → PARTITION_HORZ / 1 → SPLIT —
12+line-for-line libaom `ec_read_partition_impl` + `partition_gather_vert_alike`
13+(av1_common_int.h:1485, `out[0] = TOP − {VERT, SPLIT, HORZ_A, VERT_A, VERT_B,
14+VERT_4}`).
15+
16+Why the previous round could not see it: the `(true, false)` arm emits
17+`OUR_PART` under `EC_AV1_TRACE` (trace_edge, decode.rs:6068), not the oracle's
18+`EC_PART` format — the 422h dumps were filtered on `EC_PART`, so the read was
19+invisible and looked like "no symbol".
20+
21+## Measurement
22+
23+Fixture `/tmp/t422.obu` reused by hash
24+`d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129`
25+(256x144, 22 frames, 64x64 superblocks). Probe: `decode_probe` with a LOCAL
26+`EC_AV1_ALLOW_422_PROBE` bypass at the stream.rs:1709 refusal — REVERTED
27+before commit. Ours run with `EC_TRACE=1 EC_AV1_TRACE=1` (fresh trace
28+/tmp/u_f0.txt); oracle o_pal.txt.
29+
30+- Context numbering: ours `partition_ctx` indexes `partition_w64` 0..15 with
31+ the `bsl*4` term folded out — a constant −12 rename of libaom's ctx for the
32+ 64 level (ours 0/2/2/2, 1/3/3 vs oracle 12/14/14/14, 13/15/15 at every
33+ paired SB). Same slot, same CDF, same state; pairing confirms it.
34+- Bottom superblock row, frame 0 — all four gathered reads pair rng-for-rng,
35+ pre-read rng identical:
36+ - mi(32,0) ours 54818 / oracle 54818 (oracle ctx 13, value 1 = HORZ)
37+ - mi(32,16) ours 41610 / oracle 41610
38+ - mi(32,32) ours 61472 / oracle 61472
39+ - mi(32,48) ours 45794 / oracle 45794
40+- Interior pairing of the mi(32,0) strip continues past the gather: post
41+ uv_mode rng 43856 on both sides (mode=12, uv_mode=12), first luma all_zero
42+ ends at 53566 on both sides. The 64x32 strip's 4:2:2 chroma (32x32 square,
43+ ss (1,0)) rides the square arm as documented. has_rows=false correctly
44+ skips the second strip on both sides.
45+- Frame 0 therefore decodes through the bottom superblock row. The
46+ `EC_RECTCHROMA_GAP luma=64x32 tx=32x32 chroma=32x32` lines are the
47+ non-fatal diagnostic at decode.rs:10225, not a desync.
48+
49+## Next divergence (named stop — inter rect lane, not this lane)
50+
51+Frame 1 (first inter frame) panics at `decode.rs:29094:39` — `range end index
52+68 out of range for slice of length 64` — in the all-zero-residual prediction
53+copy: a rect inter block's `prediction[src..src + w]` reads past a 64-sample
54+buffer. Trigger context: mi(4,0) 64x64 inter, `partition_w16 value=7`
55+(VERT_B) at the 16-level, tell=542. The earlier round's decode.rs:14888
56+`decode_rect4_16_strip` closed-shape stop was not reached this run (frame 0
57+completes; the panic fires first). Both sites are downstream of the bottom-row
58+partition gather and outside this lane's ownership; decode.rs:14888 and the
59+decode.rs:19169 skip arm remain untouched, as do the four chroma-ref fixes.
60+
61+## State
62+
63+- No source change this round: the gather the assignment requested is already
64+ in HEAD, so there is nothing to write without inventing a duplicate arm.
65+ `git diff` vs 6cdd3dae touches only this report; the stream.rs probe bypass
66+ is reverted (refusal `a chroma format of 4:2:2 (subsampling_x !=
67+ subsampling_y)...` byte-identical, unconditional).
68+- Refusal STAYS: the 16-frame stream is not pixel-exact (frame 1 panics), so
69+ the delete condition (pixel-exact + 422 chroma counter) is unmet.
70+- 420 gates green (private target dir `$HOME/.cache/cargo-target-av1422i`):
71+ `a_non_420_subsampled_sequence_header_is_refused_by_name` 1/1 (proves the
72+ reverted refusal fires by name), `a_real_aomenc_stream_with_a_skipped_8x8_
73+ intra_leaf_whose_tx_split_decodes_pixel_exact` 2/2 (both bit depths) under
74+ `EC_AV1_REQUIRE_AOMENC=1`.
75+- No push. Traces left at /tmp/u_f0.txt (ours, frame 0 bottom row + frame 1
76+ panic) and /tmp/o_pal.txt (oracle).
lanes/av1422inter.report.mdadded+134 -0
@@ -0,0 +1,134 @@
1+# lane-av1-422inter — the frame-9 `read_coeffs_rect` scratch panic fixed at the
2+# source (the 4:2:2 intra-in-inter side-64 chroma is TWO square TX_32X32 units,
3+# not one 32x64 rect unit); the inter-frame divergence remeasured with the
4+# stage ladder and STOPPED at the sub-8x8 inter chroma class (`decode_inter_block8`)
5+
6+## Outcome
7+
8+1. REMEASURED first (pinned fixture `/tmp/t422.obu` sha256
9+ `d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129`,
10+ 256x144 / chroma 128x144, 16 coded frames, local `EC_AV1_ALLOW_422_PROBE`
11+ bypass applied and reverted byte-identical after — `git diff` after the
12+ revert carries only the decode.rs fix): reproduced the frame-9 panic
13+ exactly as the r lane named it — `rect coeff scratch w=32 h=64 n=2448`
14+ at [`read_coeffs_rect`]'s guard (decode.rs:7195), backtrace
15+ `decode_inter_block` -> `read_rect_chroma_unit`; 9 frames decoded before
16+ the abort.
17+2. ROOT CAUSE, and why the scratch itself stays untouched: the panic site is
18+ `decode_inter_block`'s intra-in-inter 4:2:2 chroma arm (lane-av1-422k's
19+ `chroma_w != chroma_h` dispatch), whose `_` side-match handed the WHOLE
20+ uv plane block (32x64) to [`read_rect_chroma_unit`] as ONE rect unit. But
21+ `av1_get_max_uv_txsize(BLOCK_64X64)` at ss (1,0) is
22+ `av1_get_adjusted_tx_size(max_txsize_rect_lookup[BLOCK_32X64])` =
23+ `av1_get_adjusted_tx_size(TX_32X64)` = **TX_32X32** — libaom codes TWO
24+ stacked SQUARE 32x32 units per plane, plane-major (U r0, U r1, then V
25+ r0, V r1), never a TX_32X64 coefficient read (no such scan exists in
26+ this decoder and libaom writes none: a 64-axis codes its low-32 corner).
27+ Lifting the scratch bound to 36x68 (the r lane's tentative "heap
28+ fallback" sketch) would have read a full 32x64 scan and desynced on the
29+ very first such unit. The KEY-FRAME path has carried the correct model
30+ since lane-av1-422f (`decode_block`'s 4:2:2 chroma_tx table: "64 and
31+ 128: TX_32X64 / TX_64X64 adjust down to TX_32X32, square units, a 1x2 /
32+ 2x4 grid") — proven byte-exact on this fixture's frame 0.
33+3. FIX (the sibling 444 per-unit-walk pattern): the `side == 64` arm at
34+ `decode_inter_block`'s intra-in-inter chroma now walks the two stacked
35+ 32x32 square units per plane through [`read_plane`] (`TxbSet::Chroma32`,
36+ `SCAN_32`, txb_skip ctx = above+left+3 — the offset-10 rows, the plane
37+ block being bigger than the unit), each with its own per-chroma-cell
38+ context read (`around_mi_422_chroma` at the unit's luma span), its own
39+ `tu_reach_rect`, immediate `record_mi_chroma`, assembled into the
40+ chroma_side-strided block grid, with `mu_chroma = true` so the tail's
41+ existing `mu_chroma_units` enumeration replays the per-unit entropy
42+ state after the whole-block record (the lane-dpm1 mechanism; its
43+ (rows, cols, ur, uc) walk already derives exactly these two units per
44+ plane at ss (1,0)). The 4/8/16/32 rect arms and the square
45+ `chroma_w == chroma_h` arm are untouched — 4:2:0 and 4:4:4 are
46+ byte-identical by construction (ss-keyed). `read_coeffs_rect` itself is
47+ untouched: with the adjusted-tx model no caller can deliver a unit
48+ bigger than 32x32's 36x36 levels frame, which is the invariant the
49+ scratch sizing always stated.
50+4. MEASURED after the fix (16 frames decode, no panic; the probe's
51+ `chroma422_square` counter rose 24 -> 87 across the stream, the touched
52+ class provably firing on inter frames): frame 0 is **byte-exact vs the
53+ instrumented aomdec at PREFILT, POSTDEBLOCK, POSTCDEF and FINAL on Y, U
54+ and V** (0 diffs everywhere — the parent lanes' frame-0 exactness
55+ survives). The inter frames stay divergent: per-frame stage-ladder
56+ counts (ours padded-cropped vs oracle, both vs the same instrumented
57+ `$HOME/.cache/aom-oracle/build` aomdec):
58+ - frame 1: PREFILT Y 30825 / U 12624 / V 12796, first Y (0,8) 76 vs 80,
59+ first U (0,0) 231 vs 90, first V (0,0) 164 vs 241;
60+ - frames 1..16 all diverge from (0,0) with ~28-35k Y / ~12-17k U /
61+ ~11-17k V per frame at PREFILT, and POSTDEBLOCK / POSTCDEF / FINAL
62+ track the same first samples 1:1 (the loop filters introduce no new
63+ first-diff site) — a pre-filter reconstruction class, filters
64+ exonerated.
65+5. ATTRIBUTION (2-frame cut, `EC_TRACE_MODE_STEP` + `EC_TRACE_COEFF`
66+ pairing against the oracle's own rungs): every commonly-traced mode /
67+ skip / angle / uv_mode read of frames 0+1 agrees rng-for-rng (1326
68+ paired lines, 0 mismatches), and the first 873 coefficient reads
69+ (frame 0 in full) agree — the entropy walk is in sync up to frame 1's
70+ first coded block. The FIRST divergence is that block's own tail: at
71+ mi (0,0) (8x8 inter leaf, NEARESTMV (0,0), coded), after the leaf's
72+ luma TX_8X8 txb_skip bit (agreed, rng 55168) the oracle reads the
73+ leaf's **U TX_4X8 rect chroma unit** (ctx 7 row, coded) then V — while
74+ OURS reads a TX_4X4-SQUARE-shaped unit (`TxbSet::Chroma4`,
75+ ctx = above+left, no offset-7 row). `decode_inter_block8`'s chroma half
76+ models the 4:2:2 leaf chroma plane block — `ss_size_lookup
77+ [BLOCK_8X8][1][0]` = BLOCK_4X8, one TX_4X8 rect unit per plane
78+ (`av1_get_max_uv_txsize`) — as a `chroma_side = SIDE >> ss_x` = 4
79+ square: wrong coefficient set/scan/ctx rows, and the same 4x4 square
80+ shape flows into the leaf's MC prediction, skip push and interintra
81+ blends. Pixel witness: frame-1 U (0,0) ours=231 ~= frame-0's 225 (the
82+ zero-mv prediction with only a square-read residue applied) vs the
83+ oracle's 90 (the coded TX_4X8 residual applied).
84+6. That defect class is not a one-site edit: the leaf's whole chroma half
85+ must move to (4,8) shapes — prediction build, skip/interintra/OBMC
86+ pushes, the rect coefficient read (`TxbSet::ChromaRect8x4` /
87+ `SCAN_4X8`, offset-7 ctx rows, inherited luma tx type via
88+ [`read_inter_plane_rect`]) — and the sub8 split-group's own chroma read
89+ (`decode_inter_sub8_split4`'s `TxbSet::Chroma4` group unit) repeats the
90+ same square model. Per charter step 3: STOPPED and named.
91+
92+## Decision
93+
94+- The header refusal STAYS unconditional in `stream.rs` — delete condition
95+ unmet (not pixel-exact from frame 1 on). The bypass was local-only, one
96+ `&& std::env::var(...).is_err()` clause, reverted byte-identical before
97+ the commit; the refusal gate re-verified firing (see Verification).
98+- `read_coeffs_rect` untouched (no scratch growth, no new panic path);
99+ 4:2:0/4:4:4 arms of the touched dispatch untouched; `sub8_leaf_chroma422`
100+ (parent lane) untouched; the 4:2:0 group-tail SKIP arm untouched.
101+- Next stop named for the owning lane: **`decode_inter_block8`'s 4:2:2
102+ chroma half** (leaf chroma plane block (4,8): one rect TX_4X8 unit per
103+ plane through the inter rect reader, (4,8)-shaped MC prediction and skip
104+ pushes) plus `decode_inter_sub8_split4`'s group chroma read; after that
105+ round the stage ladder of Outcome 4 should simply be re-run — frame 0
106+ and the side-64 class are now proven clean, so the residual measurement
107+ is directly attributable.
108+
109+## Verification
110+
111+- `cargo check -p ec-av1` (target `~/.cache/cargo-target-av1422inter`):
112+ 0 warnings, 0 errors on a fresh `Checking` of the edited tree.
113+- Pre-fix panic reproduced on the pinned fixture (backtrace named above);
114+ post-fix the same stream decodes 16/16 frames, frame 9 included.
115+- Frame-0 stage dumps vs the instrumented aomdec: PREFILT / POSTDEBLOCK /
116+ POSTCDEF / FINAL all Y=0 U=0 V=0 (comparator: ours padded 256x160/128x160
117+ u8 cropped, probe FINAL u16 planes vs oracle u8 — values equal).
118+- `stream::tests::a_non_420_subsampled_sequence_header_is_refused_by_name`:
119+ 1 passed, 0 failed (refusal fires again after the bypass revert).
120+- `stream::tests::a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_
121+ whose_tx_split_decodes_pixel_exact` under `EC_AV1_REQUIRE_AOMENC=1`
122+ (with `EC_AV1_AOMENC` pointed at the oracle build): 1 passed, 0 failed —
123+ the 4:2:0 inter path is unchanged.
124+- `git status` clean except the decode.rs fix; the report is the only other
125+ file in the commit.
126+
127+## State
128+
129+- Commit on lane-av1-422inter (no push): the side-64 per-unit chroma fix in
130+ `decode_inter_block` + this report.
131+- The stage-ladder instruments live in `/tmp/i422/` (our/oracle per-stage
132+ dumps for all 17 oracle frames, comparator + EC_ISTEP pairing scripts) —
133+ scratch, not committed; the oracle build's rungs already carry everything
134+ needed to regenerate them.
lanes/av1422j.report.mdadded+99 -0
@@ -0,0 +1,99 @@
1+# lane-av1-422j — inter chroma skip residual sized from the write rect; frame 1 decodes past the VERT_B skip strip; refusal stays
2+
3+## Outcome
4+
5+The frame-1 panic at `decode.rs:29094:39` (`range end index 68 out of range
6+for slice of length 64`) is fixed by sizing `decode_inter_block`'s chroma
7+square from the write rect instead of the block side, and the same-shape sweep
8+found exactly one more instance of the class, sharing the same fix. The
9+16-frame stream is NOT pixel-exact — the frontier moved to the intra-in-inter
10+chroma read, a different machinery — so the 4:2:2 header refusal STAYS
11+(byte-identical, unconditional; the local `EC_AV1_ALLOW_422_PROBE` bypass was
12+reverted before commit).
13+
14+## Root cause and fix
15+
16+`decode_inter_block` computed `chroma_side = side >> ss_x(fctx)` (old
17+decode.rs:31227). Every consumer indexes the chroma prediction/residual
18+buffers `row * chroma_side + col` over the WRITE rect
19+(`write_chroma_w x write_chroma_h`), and at ss (1,0) that rect is
20+`side/2 x side`: frame 1's skipped 16-level VERT_B strip at mi(4,0)
21+(8x16 luma, tell 542) has a 4x16 chroma rect, so a `side >> ss_x` = 8 square
22+is shorter than `row * 8 + 4` on rows >= 8 — the all-zero-residual copy read
23+`prediction[64..68]` out of the 64-sample buffer (reconstruct_mc_rect's
24+`residual.is_empty()` branch, decode.rs:29094). Fixture
25+`/tmp/t422.obu` sha256
26+`d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129`
27+reproduced it before the change and passes the block after it.
28+
29+Fix: `let chroma_side = (side >> ss_x(fctx)).max(side >> ss_y(fctx));`
30+(decode.rs:31237) — the enclosing square of the chroma rect. Bit-identical at
31+4:2:0 (`side/2`) and 4:4:4 (`side`); only 4:2:2 changes shape.
32+
33+## Same-shape sweep (ZERO_RESIDUAL slices vs forwarded w/h)
34+
35+- `decode_inter_block` skip arms, single-ref (33803..) and compound (32325..):
36+ both chroma pushes forward `(write_chroma_w, write_chroma_h)` at stride
37+ `chroma_side` with `ZERO_RESIDUAL[..chroma_side * chroma_side]` — healed by
38+ the one-line fix (chroma_side >= both write dims now). The paired
39+ `Grid::Zero(chroma_side * chroma_side)` bookkeeping matches the slices.
40+- Luma skip arms (`ZERO_RESIDUAL[..side * side]`, stride `side`, rect
41+ `(write_w, write_h)` with w,h <= side): max index
42+ `(write_h-1)*side + write_w <= side*side` — provably safe, untouched.
43+- Other inter-path slices audited against their forwarded dims:
44+ `decode_block_rect4` skip arm (`side * bh` / `cside * ch` — stride*rows
45+ sizing, safe), `decode_intrabc_rect` (11682/12024, square >= rect, safe),
46+ 14205 (`side * bh`, safe), 37037/37187 (4:4:4-only, SIDE^2 >= rect, safe),
47+ 37338 sub8 tail (square push, safe). `decode_inter_block8`'s chroma
48+ `push_mc` (square) always fits its own square slice — no panic class there;
49+ its 4:2:2 8x8-leaf chroma is a latent half-write shape, NOT this class, and
50+ was left for its owning lane.
51+
52+## Frontier re-measure (EC_AV1_ALLOW_422_PROBE=1, local only)
53+
54+1. After the sizing fix the skip strip passes and the next stop was
55+ `transform.rs:1150` (`one coefficient per position`, 256 vs 1024): the
56+ square non-skip chroma arm read a `chroma_side`-SQUARE unit (32x32 after
57+ the fix) with the caller's 4:2:0 `scan_chroma` (TX_16X16) on the 32x32
58+ inter block at px=0 py=0. Fix: both chroma arms route non-square chroma
59+ rects through `read_inter_rect_chroma`
60+ (`rect_tu || (write_chroma_w, write_chroma_h) != (chroma_side,
61+ chroma_side)`, decode.rs:32712/34222) — a 32x32 block codes ONE TX_16X32
62+ chroma unit (`av1_get_max_uv_txsize` of BLOCK_16X32), exactly
63+ `rect_inter_chroma_set`'s (16,32) row. 4:2:0/4:4:4 squares keep the square
64+ arm (their chroma rect IS `chroma_side`-square).
65+2. Next stop: `rect_inter_chroma_set` refused (8,8) — a 4:2:2 HORZ_B 16x8
66+ strip's chroma plane block is 8x8 SQUARE and the rect reader now takes it.
67+ Added the square rows (16,16)->Chroma16, (8,8)->Chroma8, (4,4)->Chroma4
68+ (decode.rs:22420) — the exact `get_txsize_entropy_ctx` tables the square
69+ arms use; unreachable before this lane.
70+3. Next stop: `rect_scan` refused squares for the same units; added
71+ `(w, h) if w == h => default_scan(w)` (decode.rs:22485).
72+4. Current named stop: an INTRA 16x16 block inside frame 1 (px=192 py=96)
73+ panics in the intra-in-inter branch's chroma `read_plane`
74+ (`exec_intra` -> `reconstruct`, index len 128 idx 128, decode.rs:3845) —
75+ the intra chroma reader still predicts/reconstructs at square
76+ `chroma_side` shapes. That is intra prediction machinery, not the
77+ ZERO_RESIDUAL slice class, and reworking it means inventing chroma
78+ shapes beyond this lane's mandate; left as the named stop for the
79+ owning lane.
80+
81+4:2:2 chroma counters PROVE chroma units ran on the probe path:
82+`chroma422_square: 24`, `chroma422_rect: 96`, `chroma422_sub8: 26` — but the
83+stream is not pixel-exact, so the delete condition (pixel-exact + counter) is
84+unmet and the refusal stays.
85+
86+## State
87+
88+- Source change: `crates/ec-av1/src/decode.rs` only (chroma_side sizing, two
89+ rect-routing conditions, square set/scan rows). `git diff` = 42 insertions,
90+ 3 deletions. The stream.rs probe bypass is REVERTED; default refusal
91+ re-verified firing: `REFUSED: unsupported: AV1 decode_stream (a chroma
92+ format of 4:2:2 ...)`.
93+- 420 gates green (target dir `$HOME/.cache/cargo-target-av1422j`):
94+ `a_non_420_subsampled_sequence_header_is_refused_by_name` 1/1;
95+ `a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_tx_split_decodes_
96+ pixel_exact` 2/2 (both bit depths) under `EC_AV1_REQUIRE_AOMENC=1` — a real
97+ 420 decode gate over the shared `decode_inter_block` path, confirming the
98+ changes are bit-neutral at 4:2:0. `cargo check -p ec-av1`: 0 warnings.
99+- No push. Probe traces left at /tmp/t422_probe.txt/.err.
lanes/av1422k.report.mdadded+79 -0
@@ -0,0 +1,79 @@
1+# lane-av1-422k — intra-in-inter chroma prediction sized from the plane block; frame 1's INTRA 16x16 passes; refusal stays
2+
3+## Outcome
4+
5+The frame-1 panic at `decode.rs:3845` (`index out of bounds: the len is 128
6+but the index is 128`) is fixed by sizing `decode_inter_block`'s INTRA arm's
7+chroma prediction/reconstruction from the 4:2:2 plane block
8+(`side >> ss_x`, `side >> ss_y`) instead of the enclosing square. The panic
9+was NOT the residual-slice class: the len-128 slice was the CfL AC SIGNAL.
10+The 16-frame stream is NOT pixel-exact — the frontier moved to the INTER
11+chroma rect-set table (a clean named refusal, different machinery) — so the
12+4:2:2 header refusal STAYS (re-verified firing by default; the local
13+`EC_AV1_ALLOW_422_PROBE` bypass was reverted before commit).
14+
15+## Root cause and fix
16+
17+Frame 1's block at px=192 py=96 is a SKIPPED 16x16 INTRA block inside the
18+inter frame (DC_PRED + CFL, zero residual), decoded by `decode_inter_block`'s
19+intra arm. That arm pushed/read chroma at the 422j enclosing square
20+`chroma_side = max(side >> ss_x, side >> ss_y)` = 16 for a 16x16 luma block,
21+but the 4:2:2 chroma plane block is 8x16:
22+
23+- The skip arm (`push_intra(1/2, cpx, cpy, chroma_side, ...)`) pushed a
24+ SQUARE 16x16 op with `ZERO_RESIDUAL` and CFL armed. `ac = cfl_src(px, py,
25+ side)` builds the AC signal over the LUMA 16x16, which `cfl_ac_ss`
26+ downsamples to the true plane shape 8x16 = 128 samples. The square
27+ `reconstruct` walked `row * 16 + col` and read `ac_q3[128]` — the panic.
28+ (Instrumented `exec_intra`: `plane=1 x=96 y=96 bw=16 bh=16 rect=false
29+ res_len=0 cfl=true`.) Even without the panic the square predict would have
30+ written 8 columns of wrong chroma past the plane block.
31+
32+Fix (decode.rs, intra arm only):
33+
34+1. `let chroma_w = side >> ss_x(fctx); let chroma_h = side >> ss_y(fctx);`
35+2. Skip arm: `push_intra_unit(1/2, cpx, cpy, chroma_w, chroma_h, ...)` with
36+ `ZERO_RESIDUAL[..chroma_w * chroma_h]` (routes rect to
37+ `push_intra_rect`/`reconstruct_rect`); the neighbour write-back grids are
38+ `Grid::Zero(chroma_w * chroma_h)`.
39+3. Non-skip arm: `chroma_w == chroma_h` keeps the square `read_plane`
40+ verbatim; at 4:2:2 both planes go through `read_rect_chroma_unit` with the
41+ key-frame path's proven set/scan rows keyed on the LUMA side (16 ->
42+ `ChromaRect16x8` + `SCAN_8X16`, 8 -> `ChromaRect8x4`, 32 ->
43+ `ChromaRect32x16`) and the per-chroma-cell context read
44+ (`around_mi_422_chroma`), exactly the decode_block 422f idiom.
45+
46+Byte-identical at 4:2:0 and 4:4:4: `chroma_w == chroma_h == chroma_side`
47+there, so every replaced call keeps its exact arguments and
48+`push_intra_unit` routes to the same square `push_intra`.
49+
50+Fixture `/tmp/t422.obu` sha256
51+`d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129`
52+panicked before the change and passes the block after it.
53+
54+## Frontier (EC_AV1_ALLOW_422_PROBE=1, local only, bypass since reverted)
55+
56+Next stop is a clean refusal, not a panic:
57+`rect_inter_chroma_set` (decode.rs:22401, refusal string at decode.rs:22429)
58+— "a rectangular inter chroma transform unit whose shape has no coefficient
59+table set here". A later inter block in frame 1 codes a chroma rect unit
60+whose (w, h) has no row in that table (the 422j square rows (16,16)/(8,8)/(4,4)
61+and the rect rows listed there are present; the new shape is none of them).
62+That is the inter chroma entropy-set table, not the intra prediction class
63+this lane owns — left as the named stop; an `EC_*` print of the refusing
64+(w, h) at that site is the first step for the owning lane.
65+
66+## State
67+
68+- Source change: `crates/ec-av1/src/decode.rs` only (intra-arm chroma_w/h,
69+ skip-arm unit pushes + grid sizes, non-skip rect routing). Temporary
70+ exec_intra/push_intra traces and the stream.rs probe bypass are REVERTED;
71+ default refusal re-verified firing: `REFUSED: unsupported: AV1 decode_stream
72+ (a chroma format of 4:2:2 ...)`.
73+- 420 gates green (target dir `$HOME/.cache/cargo-target-av1422k`):
74+ `a_non_420_subsampled_sequence_header_is_refused_by_name` +
75+ `a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_tx_split_decodes_
76+ pixel_exact` under `EC_AV1_REQUIRE_AOMENC=1`: 3 passed, 0 failed. Real
77+ 420 decode over the shared intra arm, confirming the change is bit-neutral
78+ at 4:2:0. `cargo check -p ec-av1`: 0 warnings.
79+- No push.
lanes/av1422kf.report.mdadded+82 -0
@@ -0,0 +1,82 @@
1+# lane-av1-422kf — the frame-0 U (0, 23) first diff: NAMED and FIXED (one
2+# missing arm in [`decode_rect_split`]'s chroma_tiled walk: the uv-palette
3+# prediction was never set, so the square 4:2:2 chroma rows decoded a
4+# uv-palette strip's chroma as plain DC)
5+
6+## Outcome
7+
8+1. NAMED the sample: frame 0, plane U, row 0, col 23, ours 50 vs oracle 49.
9+ The parent attributed the class to [`decode_rect_split`]'s own-chroma
10+ keyframe gap; this lane localized it to the exact unit and mechanism.
11+2. The owning unit: chroma 8x8 at chroma px (24, 0) — the square chroma of a
12+ 16x8 luma strip at luma px (48..63, rows 0..7) — pushed by
13+ [`decode_rect_split`]'s chroma_tiled `(8, 8)` arm through `read_plane`
14+ (backtrace: inline_intra ← read_plane ← decode_rect_split ←
15+ decode_leaf_rect).
16+3. Entropy PROVEN in sync: pre-loop-filter frame-0 LUMA is byte-exact against
17+ the oracle's `EC_AV1_PREFILT_DUMP`, and the U/V coefficient read of the
18+ unit pairs with the oracle by rng at BOTH ends (ours rng0=48179 / rng1=
19+ 64520 == the oracle's `EC_COEFF plane=1 tx_size=1 mi_row=0 mi_col=12
20+ rng=48179` and the following V unit's rng=64520). Same symbols, same
21+ levels (±1 at scan c=9/10/21, libaom dequant ±63 == ac_q(8-bit, 56)=63 —
22+ note the oracle's `pos=` fields are column-major; 3/4/6 there == raster
23+ 24/32/48 here), so the divergence was prediction-side only.
24+4. The paired oracle EC_ISTEP ladder for the strip (skip/cdef/dq/mode/
25+ angle_y/uv_mode/angle_uv — every value and rng identical to ours) plus the
26+ oracle's EC_PALSYN line (`y=2`) identified the mechanism: the strip is a
27+ **uv-PALETTE block**. Our `chroma_tiled` arm — uniquely among the chroma
28+ arms — never called `set_palette_pred`, so `read_plane` consumed no palette
29+ prediction and reconstructed plain DC (ours flat 97 where the oracle has
30+ the palette colour map). Class: same-symbols-silent-prediction.
31+5. FIX (14 lines, one arm): the chroma_tiled unit loop now sets the palette
32+ prediction per unit per plane (`palette_window` of `m.palette_uv` to the
33+ unit's rect), mirroring the skip/lossless/unsplit arms. 4:2:0 and 4:4:4
34+ untouched unless `m.palette_uv` is Some (previously broken output anyway).
35+6. MEASURED (pinned fixture, frame 0, single-frame cut sha256
36+ `3dd3f768ef553c02316848c2d3184c3765030c0a6fcb95887e4719add9ded3af` — first
37+ OBU prefix of the pinned 22-frame t422.obu; local `EC_AV1_ALLOW_422_PROBE`
38+ bypass, reverted byte-identical after):
39+ - U (0, 23) now decodes **49 == oracle final 49** — the named sample is
40+ EXACT.
41+ - U final diffs 4491 → **1774**; V final diffs 4888 → **2165**; U
42+ pre-filter recon diffs 3148 → **533**.
43+ - `chroma422_square` counter = 24 on this frame (the fixed arm provably
44+ ran; non-vacuity).
45+7. REMAINING class for the next lane: U pre-filter diffs now start at
46+ (108, 72) (rows 72..79, then 104+; V first diff (48, 0)) — chroma of the
47+ 16x8 strip at chroma (96, 72) and the 16x32 strip at (112, 64): NOT the
48+ palette arm fixed here (both decoded with their own modes); needs its own
49+ localization. Frame 0 is still not pixel-exact, so the
50+ "delete the header refusal" condition stays unmet.
51+
52+## Decision
53+
54+- The named col-23 sample WAS one arm in [`decode_rect_split`] — fixed, not
55+ punted. The frame-9 [`read_coeffs_rect`] scratch panic is untouched
56+ (another lane's, and the single-frame cut sidesteps it). The four TX_4X8
57+ chunk and the Some(3) offset are untouched. `read_coeffs_rect` untouched.
58+- Header refusal STAYS in `stream.rs`, unconditional (no env gate in the
59+ commit; verified firing by name without the env after revert).
60+
61+## Verification
62+
63+- `cargo check -p ec-av1` (target `~/.cache/cargo-target-av1422kf`): 0
64+ warnings, 0 errors.
65+- 420 gate green under `EC_AV1_REQUIRE_AOMENC=1`:
66+ `stream::tests::a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_
67+ whose_tx_split_decodes_pixel_exact`: 1 passed, 0 failed.
68+- `stream::tests::a_non_420_subsampled_sequence_header_is_refused_by_name`:
69+ 1 passed, 0 failed (and the example probe refuses the fixture by name
70+ without the env).
71+- `git diff` after the bypass revert carries ONLY the decode.rs fix; all
72+ temporary EC_KF422DBG/TEMPQM probes and the local bypass are out.
73+
74+## State
75+
76+- Commit on lane-av1-422kf (no push): the chroma_tiled palette fix + this
77+ report.
78+- Next stop named for the owning lane: U (108, 72) / V (48, 0) pre-filter
79+ recon class at the (96, 72) 16x8 and (112, 64) 16x32 strips' own chroma —
80+ same localization recipe applies (single-frame fixture + rng pairing
81+ against `$HOME/.cache/aom-oracle/build` aomdec, `EC_AV1_ALLOW_422_PROBE`
82+ local-only).
lanes/av1422kf2.report.mdadded+97 -0
@@ -0,0 +1,97 @@
1+# lane-av1-422kf2 — the remaining frame-0 class at U (108, 72) / V (48, 0):
2+# NAMED and FIXED — the sub-8x8 4:2:2 chroma unit decoded at the wrong
3+# position, wrong reach table and half-visible neighbour mode (three related
4+# one-index defects, all in [`sub8_leaf_chroma422`]); frame-0 PRE-FILTER
5+# reconstruction is now pixel-exact (Y, U and V) against the oracle's
6+# `EC_AV1_PREFILT_DUMP`
7+
8+## Outcome
9+
10+1. REMEASURED first (pinned fixture, single-frame cut
11+ `/tmp/t422f0.obu` sha256 `3dd3f768ef553c02316848c2d3184c3765030c0a6fcb95887e4719add9ded3af`
12+ — first OBU prefix of the pinned 22-frame t422.obu; the frame is
13+ **256x144**, chroma planes 128x144; local `EC_AV1_ALLOW_422_PROBE`
14+ bypass applied, reverted byte-identical after): at the parent's baseline
15+ the pre-filter chroma diffs were U 533 / V 869, first U (108, 72) —
16+ confirming the parent's sample.
17+2. NAMED the class at U (108, 72): the 8x8 luma block at luma (216, 72)
18+ splits into four 4x4 leaves; 4:2:2's `is_chroma_reference`
19+ (`av1_common_int.h:1454`) puts the chroma syntax on the ODD-column leaves
20+ (`(mi_col & 1) || !(bw & 1) || !ss_x` — the port already read uv_mode
21+ there, entropy in sync, luma byte-exact), but libaom ANCHORS the leaf's
22+ TX_4X4 chroma unit at the floored chroma cell
23+ (`(mi_col & !1) * MI >> ss_x` = chroma px 108), not at the odd leaf's own
24+ chroma x (110). Ours reconstructed at 110: px 108..109 were never written
25+ (zeros at exactly the parent's sample), px 112..113 got the unit's right
26+ columns. Oracle ground truth: the mi(18,55) unit's reconstruction is a
27+ pure V-copy of the row above AT 108..111. Fix 1: anchor `cpx` at
28+ `(lmi.1 & !1) * MI >> ss_x`. U/V prefilt 533/869 → 477/813, first diff
29+ moved to (96, 104).
30+3. The (96, 104) cluster named the next layer: an 8x4 strip's chroma unit
31+ (mi(27,44), uv D45) read undecoded pixels to its upper right. The oracle's
32+ own `EC_PRED` trace prints `n_tr=0` there: libaom answers
33+ `has_top_right`/`has_bottom_left` from the LEAF's OWN rect shape
34+ (`has_tr_8x4`/`has_tr_4x8` at the leaf's mi — bit 6 of byte 22 is 0),
35+ while the port used the standalone square-4x4 `Reach::of(4, ..)` lookup
36+ (same bit = 1). Fix 2: `sub8_leaf_chroma422` takes the leaf's shape and
37+ uses `Reach::of(4, ..)` only for a BLOCK_4X4 leaf, `Reach::of_rect(8, 4)`
38+ / `(4, 8)` for a rect pair's strip. Prefilt chroma 477/813 → 8/15.
39+4. The last 8/15 samples (chroma (100..103, 120..123), the H-mode unit at
40+ mi(30,50)) named the third defect: the unit's left neighbour mi(30,48) is
41+ an 8x4 strip with uv SMOOTH_V, but its `record_uv_mode_mi(…, 1, 1, …)`
42+ stamped only ONE of the strip's two mi columns, so mi(30,50)'s
43+ `chroma_left_mbmi` lookup hit an empty cell, lost the smooth neighbour and
44+ skipped libaom's always-on strength-1 intra edge filter
45+ (`get_intra_edge_filter_type` 1 vs our 0; prediction sums 6139/6307 vs
46+ 6142/6312). Fix 3: record the uv mode over the leaf's whole mi footprint
47+ (`(w_mi, h_mi)` from the leaf shape). All three fixes are inside
48+ [`sub8_leaf_chroma422`] and its five call sites.
49+5. MEASURED after the three fixes: **PREFILT Y EXACT, U EXACT, V EXACT**
50+ (byte-identical frame-0 pre-loop-filter reconstruction against the oracle
51+ dump). FINAL dumps: U 1774 → 1236, V 2165 → 1263 — every remaining final
52+ diff is introduced by the LOOP FILTER (pre-filter row 0 is exact; the
53+ filter propagates damage to the top rows). Non-vacuity:
54+ `chroma422_square` = 24, `chroma422_rect` = 96, `chroma422_sub8` = 26 on
55+ this frame — all three touched arms provably ran.
56+6. REMAINING class for the next lane: the 4:2:2 LOOP FILTER. With pre-filter
57+ recon byte-exact, the 1236/1263 final-diff samples are deblock/CDEF/LR
58+ chroma work (the parent's V (48, 0) is this class's first final sample —
59+ pre-filter V at row 0 is exact). Frame 0 is still not final-pixel-exact,
60+ so the "delete the header refusal" condition stays unmet.
61+
62+## Decision
63+
64+- The palette set in 93c4dff5 is untouched (chroma422_square still 24; the
65+ chroma_tiled arm's `set_palette_pred` intact).
66+- `read_coeffs_rect` untouched. The frame-9 rect scratch panic is untouched.
67+ The 4:2:0 group-tail SKIP arm untouched. Header refusal STAYS
68+ unconditional in `stream.rs` — verified firing by name on this very
69+ fixture after the bypass revert, plus the named gate test.
70+- The bypass was local-only (`EC_AV1_ALLOW_422_PROBE` on the env, one
71+ `&& std::env::var(…).is_err()` clause), reverted byte-identical before the
72+ commit; `git diff` after the revert carries ONLY the decode.rs fix.
73+
74+## Verification
75+
76+- `cargo check -p ec-av1` (target `~/.cache/cargo-target-av1422kf2`):
77+ 0 warnings, 0 errors.
78+- 420 gate green under `EC_AV1_REQUIRE_AOMENC=1`:
79+ `stream::tests::a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_
80+ whose_tx_split_decodes_pixel_exact`: 1 passed, 0 failed.
81+- `stream::tests::a_non_420_subsampled_sequence_header_is_refused_by_name`:
82+ 1 passed, 0 failed.
83+- Stage dumps compared sample-for-sample (cropped `PREFILT_WIDE_DUMP` vs the
84+ oracle `EC_AV1_PREFILT_DUMP`, same 73728-byte layout, 256x144 / 128x144):
85+ post-fix Y/U/V all exact; symbol-level pairing via the oracle's
86+ `EC_ISTEP`/`EC_PALSYN`/`EC_PRED`/`EC_PREDOUT8` rungs against our
87+ `EC_TRACE_MODE_STEP`/`EC_PRED` traces (rng and values matched at every
88+ step of every unit named above).
89+
90+## State
91+
92+- Commit on lane-av1-422kf2 (no push): the three sub8-422 chroma fixes +
93+ this report.
94+- Next stop named for the owning lane: the 4:2:2 loop filter — deblock/CDEF
95+ chroma extents against `$HOME/.cache/aom-oracle/build` aomdec dumps
96+ (`EC_AV1_POSTDEBLOCK_DUMP` rungs exist on both sides); the decode-side
97+ frame-0 recon it consumes is now proven exact.
lanes/av1422l.report.mdadded+99 -0
@@ -0,0 +1,99 @@
1+# lane-av1-422l — inter-strip pairing underflow fixed; the rect-set refusal is real and names (4, 32), which libaom marks invalid — no row added, refusal stays
2+
3+## Outcome
4+
5+Two results.
6+
7+1. The k report's frontier attribution was measured under a release build:
8+`at_mi.0 - 1` subtract-overflow WRAPPED silently there, so decode continued
9+to `rect_inter_chroma_set`. A debug build panics first — the true first stop
10+at 8e7238b2 was a hard underflow panic in the inter-strip chroma pairing
11+(`decode.rs` ~41531:42 horz `at_mi.0 - 1`, then ~41544:55 vert
12+`at_mi.1 - 1`), hit because `strip_has_chroma`'s `|| ss_y(fctx) == 0`
13+clause makes every strip chroma-bearing at 4:2:2 including strip i = 0 at
14+mi row/col 0. Fixed in its own commit (below); 4:2:0 and 4:4:4 are
15+byte-identical by construction.
16+2. After the fix the frontier is exactly the refusal the k report named:
17+`rect_inter_chroma_set` fires with (w, h) = **(4, 32)** — the 4:2:2 plane
18+residual of an 8x32 luma block. libaom itself marks that size invalid, so
19+per the lane charter NO table row is invented and the refusal stays.
20+
21+## Fix 1 (own commit): strip pairing keys on the strip's own subsampled axis
22+
23+`decode_inter_frame_tile_with_cdfs`'s 1:4 strip walk
24+(`PARTITION_HORZ_4`/`VERT_4`, 16x4 / 4x16 strips):
25+
26+- `strip_has_chroma`: horz keeps `i % 2 == 1 || ss_y == 0` (no chroma row
27+ parity at ss_y == 0 — every 16x4 strip is its own reference, mirroring the
28+ intra strip arm's `else if ss_y(fctx) == 0` at the 14700s key-frame path);
29+ vert becomes `i % 2 == 1 || ss_x == 0` (column parity governs, 4:4:4 keeps
30+ self-paired strips, 4:2:2 keeps the proven 4:2:0 column pairing, and an odd
31+ strip's left neighbour always exists so `at_mi.1 - 1` cannot underflow).
32+- `pair_mi`: self when the strip's pair axis is not subsampled (horz &&
33+ ss_y == 0, or vert && ss_x == 0), otherwise the existing pair merge.
34+- `prev`: pair motion only when the strip actually pairs (horz && ss_y == 1,
35+ vert && ss_x == 1); self-coded chroma predicts from its own motion.
36+
37+Format-by-format equivalence to the pre-lane code: 4:2:0 horz/vert and
38+4:4:4 horz/vert produce identical `has_chroma`/`pair_mi`/`prev` in every
39+branch; only 4:2:2 changes (horz self-pairs, vert pairs as at 4:2:0).
40+
41+Fail-before witness: HEAD 8e7238b2 + env-gated header bypass panics
42+`attempt to subtract with overflow` at the two lines above under
43+`EC_AV1_ALLOW_422_PROBE=1`; after the fix the same run reaches the named
44+refusal. Fail-after does not apply (this is a panic, not a test).
45+
46+## Fix 2: the refusing shape, named — and why no row is added
47+
48+`EC_AV1_TRACE_422` at the `_ =>` arm of `rect_inter_chroma_set` prints
49+`(w,h)=(4,32)` on `/tmp/t422.obu` (sha256
50+`d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129`, the k
51+report's fixture). 4x32 is the 4:2:2 plane residual of an 8x32 luma block
52+(write rect 8x32 -> `>> ss_x` = 4x32). Against the pinned oracle source
53+(`~/.cache/aom-oracle/src`):
54+
55+- `av1_ss_size_lookup[BLOCK_8X32][1][0] = BLOCK_INVALID`
56+ (`av1/common/common_data.c:38`) — an 8x32 luma block HAS NO 4:2:2 plane
57+ residual block.
58+- `TX_4X32`/`TX_32X4` do not exist: zero occurrences in
59+ `av1/common/enums.h`; the largest 4-px-axis transform is `TX_4X16`.
60+- `max_txsize_rect_lookup[BLOCK_8X32] = TX_8X32` — libaom reaches that
61+ chroma through luma-granular chunking, never as a standalone 4-px unit.
62+
63+So the ticket's escape hatch ("if libaom marks it invalid, stop and name
64+it") applies: adding a (4, 32) row would invent a size libaom never codes.
65+The owning lane's next step is modelling the 8x32-at-(1,0) chroma merge
66+(`get_vartx_max_txsize` / `decode_token_recon_block` chunking), not an
67+entropy set. The trace print stays (env-gated, `env_flag!`, zero-cost).
68+
69+## Verification
70+
71+- Counters on the probe run prove real 4:2:2 chroma units read before the
72+ stop: `chroma422_square: 25`, `chroma422_rect: 100`,
73+ `chroma422_sub8: 26`.
74+- Default refusal fires (bypass reverted):
75+ `REFUSED: unsupported: AV1 decode_stream (a chroma format of 4:2:2 ...)`.
76+- 420 gates green under `EC_AV1_REQUIRE_AOMENC=1`
77+ (target dir `~/.cache/cargo-target-av1422l`):
78+ `a_non_420_subsampled_sequence_header_is_refused_by_name` +
79+ `a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_tx_split_decodes_
80+ pixel_exact`: 2 passed, 0 failed.
81+- `cargo check -p ec-av1`: 0 warnings.
82+- Header refusal NOT deleted (16-frame stream is not pixel-exact; it is
83+ refused at the named (4, 32) stop).
84+- The k lane's intra-arm chroma prediction sizing is untouched.
85+
86+## Latent site named (not fixed, out of reach)
87+
88+`decode.rs` ~14107 (INTRABC 16x4/4x16 dense path) subtracts
89+`lmi.0 - 1` / `lmi.1 - 1` under `has_chroma` with no subsampled-axis key.
90+Unreachable at 4:2:2 today (the header refusal precedes any INTRABC
91+decode), so no test can exercise it; flagged for the INTRABC lane so the
92+pairing class lands there too when 4:2:2 INTRABC is chartered.
93+
94+## State
95+
96+- Commits on lane-av1-422l (no push): (1) strip-pairing fix, (2) the
97+ (4, 32) trace print + this report.
98+- No table row added to `rect_inter_chroma_set`. The 4:2:0 group-tail
99+ chroma SKIP arm was not touched.
lanes/av1422m.report.mdadded+101 -0
@@ -0,0 +1,101 @@
1+# lane-av1-422m — the (4, 32) refusal is replaced by libaom's TX_4X4 chunking for
2+# that one shape; the header refusal STAYS (the stream's next stop is a
3+# different class, the intra-in-inter 64x64 chroma (32, 64) panic)
4+
5+## Outcome
6+
7+1. `read_inter_rect_chroma` no longer refuses (4, 32): an 8x32 luma block's
8+ 4:2:2 chroma plane now codes as EIGHT TX_4X4 chunks per plane, exactly the
9+ chunking libaom's decoder performs for a plane whose `ss_size_lookup` entry
10+ is BLOCK_INVALID. 4:2:0 and 4:4:4 are bit-identical by construction (the
11+ arm gates on ss (1,0) AND write rect exactly (4, 32) — impossible at any
12+ other format).
13+2. The header refusal is NOT deleted: with the chunking in, the 16-frame
14+ stream decodes PAST the previously refusing block and stops at a NEW hole
15+ owned by another lane — the intra-in-inter 64x64 chroma arm reads its whole
16+ (32, 64) plane as ONE unit and trips the rect-coeff scratch bound. The
17+ delete condition (16-frame pixel-exact vs aomdec) is unmet, so the refusal
18+ stays.
19+
20+## The chunking mechanism (measured against the pinned oracle, `~/.cache/aom-oracle/src`)
21+
22+- `av1_ss_size_lookup[BLOCK_8X32][1][0] = BLOCK_INVALID`
23+ (`av1/common/common_data.c:38`): an 8x32 luma block HAS no 4:2:2 plane
24+ residual block; no TX_4X32 exists either.
25+- `decode_token_recon_block`'s inter residual loop
26+ (`av1/decoder/decodeframe.c:1022`) still walks the plane in
27+ `get_vartx_max_txsize` units. `get_vartx_max_txsize`
28+ (`av1/common/blockd.h:1447`) does `max_txsize_rect_lookup[plane_bsize]`
29+ with `plane_bsize == BLOCK_INVALID` — one element PAST the 22-entry table.
30+ The oracle build is Release (`CMakeCache.txt`: `CMAKE_BUILD_TYPE=Release`,
31+ asserts compiled out), and the table's adjacent neighbour in declaration
32+ order is `vtx_tab`, whose first entry `DCT_1D = 0 = TX_4X4`. So the
33+ chroma max tx size resolves to TX_4X4.
34+- `decode_reconstruct_tx` (`decodeframe.c:303`) NEVER recurses for chroma
35+ (`if (tx_size == plane_tx_size || plane)`), so every chroma unit reads at
36+ TX_4X4: the 4x32 plane codes as 8 stacked 4x4 coefficient units.
37+- Empirical proof the chunking matches the bitstream: the same fixture bytes
38+ (sha256 `d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129`)
39+ stopped at the (4, 32) refusal before the change; after it, decode consumes
40+ that block's chroma and reaches the LATER intra-arm panic below — entropy
41+ stayed consistent across the chunked units.
42+
43+## The fix (scoped to the one shape)
44+
45+`read_inter_rect_chroma` (`decode.rs`): when ss is (1, 0) and the write rect
46+is exactly (4, 32), chunk into (4, 4) units — the existing multi-unit loop
47+then stamps per-unit chroma neighbour contexts, embeds into the square-stride
48+grid, and returns the per-unit list for the tail's re-stamp, unchanged. Each
49+unit reads `TxbSet::Chroma4` / `default_scan(4)` (the lane-av1-422j rows) and
50+inherits NO tx_type (`av1_get_tx_type` returns DCT_DCT for
51+`tx_size == TX_4X4`, blockd.h), so `inherit_tx_type` is `None` for these
52+units.
53+
54+Counter `CHROMA422_CHUNK_HITS` (+ `chroma422_chunk_hits()`, printed by
55+`decode_probe` as `chroma422_chunk:`): one hit per TX_4X4 chunk unit read; a
56+4:2:0/4:4:4 frame cannot increment it. On the current fixture the probe
57+panics at the later stop before `report()` prints, so the number is not yet
58+exercised on a full decode; the units demonstrably ran (frontier evidence
59+above).
60+
61+## Next stop named (NOT fixed — another shape, another lane's arm)
62+
63+`decode_inter_block`'s INTRA arm (lane-av1-422k's
64+`read_rect_chroma_unit` call, `decode.rs`:35166/35208) codes a 64x64 intra
65+block's 4:2:2 chroma plane as ONE (32, 64) unit with `TxbSet::Chroma32`:
66+
67+```
68+thread 'main' panicked at crates/ec-av1/src/decode.rs:7195:9:
69+rect coeff scratch w=32 h=64 n=2448
70+```
71+
72+libaom chunks that plane too: the intra residual walk
73+(`read_coeffs_and_intra`, decodeframe.c) steps `av1_get_tx_size` units, and
74+`av1_get_max_uv_txsize(BLOCK_64X64, 1, 0)` =
75+`av1_get_adjusted_tx_size(TX_32X64)` = **TX_32X32** (`blockd.h:1361`), i.e.
76+two 32x32 units per plane. Lifting it means re-plumbing the k lane's
77+whole-plane arm into a per-unit walk (set rows, per-unit `around_mi_422_chroma`
78+contexts, restamp) — that is the intra 4:2:2 chroma lane's territory, and the
79+(4, 32) inter shape this ticket owns is done.
80+
81+## Verification
82+
83+- `cargo check -p ec-av1 --all-targets` (target dir
84+ `~/.cache/cargo-target-av1422m`): **0 warnings**.
85+- 420 gate green under `EC_AV1_REQUIRE_AOMENC=1`:
86+ `a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_tx_split_decodes_
87+ pixel_exact`: 1 passed, 0 failed.
88+- Header refusal restored byte-identical after the probe bypass
89+ (`stream.rs` refusal block untouched); default 4:2:2 refusal fires as
90+ before.
91+- Oracle decode reference for the fixture: `$HOME/.cache/aom-oracle/build/
92+ aomdec` → 16 shown frames (I422 y4m).
93+- Untouched: the 4:2:0 group-tail chroma SKIP arm, the k lane's
94+ `read_rect_chroma_unit` arms, `rect_inter_chroma_set`'s tables (no new row;
95+ the (4, 32) refusal arm stays for any FUTURE unchunked arrival).
96+
97+## State
98+
99+- Commit on lane-av1-422m (no push): the chunking + counter + probe print +
100+ this report.
101+- No table row added. The header refusal stands.
lanes/av1422n.report.mdadded+74 -0
@@ -0,0 +1,74 @@
1+# lane-av1-422n — e24dc84b's (4, 32) chunk is corrected from eight TX_4X4 to
2+# FOUR TX_4X8 units; the header refusal STAYS (the stream is not pixel-exact
3+# and stops at the (2, 16) rect-pair chroma shape)
4+
5+## Outcome
6+
7+1. `read_inter_rect_chroma`'s invalid-ss-size arm now chunks the (4, 32)
8+ 4:2:2 chroma plane of an 8x32 luma block into FOUR TX_4X8 units per plane
9+ (a 1x4 grid: 4 wide, 8 tall each). The committed eight-TX_4X4 chunking
10+ was wrong: reviewer FAIL on e24dc84b. `BLOCK_INVALID` is 255, and the
11+ out-of-bounds byte `get_vartx_max_txsize` reads from
12+ `max_txsize_rect_lookup` in the pinned Release oracle build is TX_4X8 —
13+ not the "adjacent `vtx_tab[0]` = TX_4X4" the m report claimed.
14+2. The units KEEP a tx type: `av1_get_tx_type` (blockd.h) has no TX_4X4
15+ early-out, so the m lane's `inherit_tx_type = None` special case is gone.
16+ The units derive the type from the block's luma type through
17+ `reduce_inherited_chroma_tx_type` into the TX_4X8 ext-tx set, exactly
18+ like every other rect unit on this path. `(4, 8)` resolves through the
19+ existing `rect_inter_chroma_set` row `(8, 4) | (4, 8) => ChromaRect8x4`;
20+ no table row was added, and the (4, 32) refusal arm below it stays.
21+3. The (32, 64) intra chroma edit made earlier this session was REVERTED
22+ per instruction before the chunk fix; the intra arm is byte-identical to
23+ e24dc84b. 4:2:0 paths untouched.
24+
25+## Counter (first real exercise of `CHROMA422_CHUNK_HITS`)
26+
27+With the header refusal temporarily bypassed (probe only, restored
28+byte-identical — see below), the fixture walks 32 TX_4X8 chunk units
29+(`CHROMA422_CHUNK_HITS`, instrumented per unit) before the next stop. The
30+m report's count never printed because the probe panicked first; with the
31+corrected chunking the units demonstrably run.
32+
33+## Frontier (NOT fixed — another shape, another lane's arm)
34+
35+`decode_rect4_16_strip`'s closed chroma-shape set (`decode.rs:14902`) has no
36+`(2, 16)` row: a 4x16 luma pair's 4:2:2 chroma plane arrives there and hits
37+the `unreachable!`. The probe decodes frame 1 and stops early in frame 2,
38+after the 32 TX_4X8 units. The (32, 64) intra scratch panic did NOT
39+reproduce on this walk — this stop precedes it.
40+
41+## Pixels — delete condition unmet, refusal STAYS
42+
43+- Frame 1 (keyframe): luma byte-exact vs `aomdec` (oracle: 16 shown I422
44+ frames); U/V diverge from chroma (23, 0) on — a pre-existing keyframe
45+ 4:2:2 chroma gap present at e24dc84b too (frame 1 decodes through
46+ `decode_block`, which neither `read_inter_rect_chroma` nor the intra arm
47+ touches).
48+- Frames 2+ are not comparable (the frame-2 stop above).
49+- The 16-frame pixel-exact + counter delete condition is unmet, so the
50+ header refusal stands untouched.
51+
52+## Verification
53+
54+- `cargo check -p ec-av1 --all-targets` (target dir
55+ `~/.cache/cargo-target-av1422n`): **0 warnings**.
56+- 420 gate green under `EC_AV1_REQUIRE_AOMENC=1`:
57+ `a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_tx_split_decodes_
58+ pixel_exact`: 1 passed, 0 failed.
59+- Probe bypass reverted: `git diff` after the run shows ONLY
60+ `crates/ec-av1/src/decode.rs` (the chunk fix + comment rewrite); the
61+ default 4:2:2 refusal fires as before (`REFUSED: unsupported: ... 4:2:2
62+ ...`).
63+- Oracle reference: `$HOME/.cache/aom-oracle/build/aomdec` on the fixture
64+ (sha256 `d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129`)
65+ → 16 shown frames.
66+- Untouched: the (4, 32) refusal arm in `rect_inter_chroma_set`, the 4:2:0
67+ group-tail chroma SKIP arm, the k lane's `read_rect_chroma_unit` arms,
68+ `decode_probe.rs` (byte-identical to e24dc84b).
69+
70+## State
71+
72+- Commit on lane-av1-422n (no push): the corrected chunking + this report.
73+- Next stop named for the owning lane: `decode_rect4_16_strip` chroma shape
74+ `(2, 16)`.
lanes/av1422o.report.mdadded+110 -0
@@ -0,0 +1,110 @@
1+# lane-av1-422o — the (2, 16) stop is NAMED and dispositioned: libaom has no
2+# such transform; the odd strip is the chroma reference and codes the PAIR's
3+# (4, 16) as TWO TX_4X8 units per plane; the header refusal STAYS (the walk
4+# now stops in `decode_block_rect4`'s chroma shape set at 4x32)
5+
6+## Outcome
7+
8+1. Step 1 of the charter (print before adding): with the header refusal
9+ temporarily bypassed (probe-only, restored byte-identical — see below),
10+ the refusing shape printed as `(cw,ch)=(2,16) ss=(1,0)`. The walk's own
11+ `(2, 16)` is the EVEN strip's own chroma — a shape libaom never codes.
12+ The port does not chunk it; it is UNREACHABLE after the fix.
13+2. `decode_rect4_16`'s `has_chroma` is per axis now: a VERT 4x16 strip (1 mi
14+ wide) keeps libaom `is_chroma_reference`'s column clause
15+ `(mi_col & 1) || !(bw & 1) || !ss_x`, which with bw == 1 mi reduces to
16+ `mi_col odd` at every ss_x == 1 format. The old `i % 2 == 1 || ss_y == 0`
17+ marked even strips as chroma references at 4:2:2 — the source of the
18+ phantom (2, 16). HORZ strips keep `i % 2 == 1 || ss_y == 0` (all four
19+ strips are references at ss_y 0); 4:2:0 and 4:4:4 resolve to the exact
20+ same flags as before in all four strip/format combinations.
21+3. `decode_rect4_16_strip`'s own-chroma arm is HORZ-only now; a VERT strip
22+ falls through to the pair merge `((lmi.0, lmi.1 - 1), 8, 16)` — the
23+ closing strip codes the pair's chroma at the pair's origin
24+ (`setup_pred_plane`'s `mi_col -= 1` snap), giving (cw, ch) = (4, 16) at
25+ ss(1,0). The old comment claiming "a conformant stream carries no such
26+ leaf" is disproven by the fixture itself and is gone.
27+4. The (4, 16) at ss_x == 1 is CHUNKED the way the pinned oracle walks it
28+ (`chroma422_pair16` arm): `ss_size_lookup[BLOCK_4X16][1][0]` is
29+ BLOCK_INVALID (common_data.c row `{ { BLOCK_4X16, BLOCK_4X8 },
30+ { BLOCK_INVALID, BLOCK_4X8 } }`), so `av1_get_tx_size` reads
31+ `max_txsize_rect_lookup[255]` — the out-of-bounds byte is TX_4X8
32+ (skill-measured, 0x05) and `av1_get_adjusted_tx_size` has no TX_4X8
33+ case. `decode_token_recon_block` then walks unit_width =
34+ ROUND_POWER_OF_TWO(1, 1) = 1, unit_height = 4, stepr =
35+ tx_size_high_unit[TX_4X8] = 2, stepc = 1: TWO TX_4X8 units per plane,
36+ plane-major, the lower one predicted off the upper one's samples. The
37+ skip arm walks the same two units (prediction runs per unit regardless
38+ of `skip_txfm`). No coefficient-table row was added: the units ride the
39+ existing `(4, 8) => ChromaRect8x4` entropy class via
40+ `read_rect_chroma_unit`.
41+5. The chunk's `txb_skip_ctx` rides the same INVALID lookup: libaom
42+ `get_txb_ctx_general`'s chroma branch picks the offset (7 vs 10) through
43+ `num_pels_log2_lookup[plane_bsize] > num_pels_log2_lookup[BLOCK_4X8]`
44+ with plane_bsize = 255. Measured, not guessed: the pinned Release
45+ oracle's decodetxb.c code indexes the `num_pels_log2_lookup` copy at
46+ vaddr `0xc0db70` (objdump: `cmpb $0xb,0xc0db70(%r15)` et al.), and the
47+ byte at that offset + 255 is 255 → offset 10 → the port's
48+ offset-7-first tables take `+3` (above + left + 3), the same shape the
49+ square multi-unit walks already use.
50+6. No tx_type symbol: only y plane's is transmitted (decodetxb.c "only y
51+ plane's tx_type is transmitted"); the intra chroma unit's type is
52+ `intra_mode_to_tx_type(UV mode)` kept by the all-16 ext-tx set — exactly
53+ `read_rect_chroma_unit`'s own default. CfL parameters are computed once
54+ per block over the pair's luma (`are_parameters_computed`) and shared by
55+ both units; the DC-pred cache is dead in this build (`use_dc_pred_cache`
56+ never set true), so each unit predicts its own DC.
57+
58+## Counter (CHROMA422_RECT_HITS, instrumented per unit, temp print removed)
59+
60+The walk reads EIGHT chunk units — two pairs (mi (28, 44) and (32, 52)),
61+each plane-major: U unit row 0, U unit row 1, then V units — mi rows 2
62+apart (8 px) — and the counter ticks 100 → 101 → … → 107 across them
63+(`chroma422_rect=107` on the last line). Delta 8 = 2 planes x 2 units x 2
64+pairs. The pre-fix walk stops with the counter parked at 100.
65+
66+## Frontier (NOT fixed — another shape, another function)
67+
68+`decode_block_rect4`'s closed chroma-shape set has no `4x32` row:
69+`decode.rs:13550` panics `decode_block_rect4 chroma shape set is closed:
70+4x32` on the same probe walk after the (2, 16) fix. That function is the
71+VERT_4 pair reader one level up; it is NOT edited here — named for its
72+owning lane.
73+
74+## Pixels — delete condition unmet, refusal STAYS
75+
76+- Frame 1: no VERT_4 4:2:2 strip occurs before the old stop point, so
77+ frame 1's decode is untouched by this diff; its luma stays byte-exact vs
78+ `aomdec` and its U/V keep the pre-existing keyframe chroma gap from
79+ chroma (23, 0) on (`decode_block`'s own gap, present at e24dc84b, not
80+ this lane's function).
81+- The walk stops inside frame 2 at `decode_block_rect4`'s 4x32, so the
82+ 16-frame pixel-exact + counter delete condition is unmet: the header
83+ refusal stands untouched (verified below).
84+
85+## Verification
86+
87+- `cargo check -p ec-av1 --all-targets` (target dir
88+ `~/.cache/cargo-target-av1422o`): **0 warnings**.
89+- 420 gate green under `EC_AV1_REQUIRE_AOMENC=1`:
90+ `a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_tx_split_
91+ decodes_pixel_exact`: 1 passed, 0 failed.
92+- Probe bypass reverted: `git diff` shows ONLY `crates/ec-av1/src/decode.rs`
93+ (+144/−12); `stream.rs` is byte-identical and the probe without the
94+ bypass prints `REFUSED: unsupported: AV1 decode_stream (a chroma format
95+ of 4:2:2 ...)` as before.
96+- Oracle reference: `$HOME/.cache/aom-oracle/build/aomdec` on the fixture
97+ (sha256 `d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129`)
98+ → 16 shown frames.
99+- Untouched: `read_inter_rect_chroma` (the four TX_4X8 (4, 32) chunk
100+ stays), the 4:2:0 group-tail chroma SKIP arm, the k lane's
101+ `read_rect_chroma_unit` (called, not edited), `decode_block_rect4` (the
102+ new frontier), `decode_probe.rs`, the lossless arm (shape-generic
103+ per-TX_4X4 walk already handles a (4, 16) pair).
104+
105+## State
106+
107+- Commit on lane-av1-422o (no push): the has_chroma parity fix, the horz
108+ own-chroma arm, the chroma422_pair16 chunk arms, and this report.
109+- Next stop named for the owning lane: `decode_block_rect4` chroma shape
110+ `4x32` (decode.rs:13550).
lanes/av1422p.report.mdadded+119 -0
@@ -0,0 +1,119 @@
1+# lane-av1-422p — the 4x32 chroma stop is NAMED and CHUNKED: libaom HAS the
2+# transform (the BLOCK_INVALID plane block reads max_txsize_rect_lookup[255]
3+# = TX_4X8 out of bounds), so `decode_block_rect4` walks FOUR TX_4X8 units per
4+# plane on the offset-10 skip rows; the whole 16-frame stream now decodes, the
5+# pixels are NOT exact, so the header refusal STAYS byte-identical
6+
7+## Outcome
8+
9+1. Step 1 of the charter (print before adding): with the header refusal
10+ temporarily bypassed (probe-only, restored byte-identical), the stop
11+ printed `EC_422P_STOP decode_block_rect4 chroma shape (4,32) luma=(8,32)
12+ ss=(1,0)` — the portrait 1:4 leaf the av1422o report named as its
13+ frontier, on the pinned fixture (sha256 `d3fa4beeb1309033e4a03f5ae5c4
14+ 31c8fa8386ba1ada088684710423c7938129`).
15+2. Measured, not guessed: `av1_get_tx_size` reads
16+ `max_txsize_rect_lookup[plane_bsize]` with plane_bsize =
17+ `ss_size_lookup[BLOCK_8X32][1][0]` = BLOCK_INVALID (255, `enums.h`). The
18+ byte at +255 of the copy `decode_token_recon_block` actually reads
19+ (objdump: every `movzbl 0xc0d030(%r*)` in that function) is `0x05` =
20+ TX_4X8; `av1_get_adjusted_tx_size` has no TX_4X8 case. The decodetxb copy
21+ of `num_pels_log2_lookup` (the `cmpb` against `0xc0db70(%r15)`, symbol at
22+ 0xc0de70) reads `0xff` at +255, so `get_txb_ctx_general`'s chroma branch
23+ (`txb_common.h`: `num_pels_log2_lookup[255] > num_pels_log2_lookup
24+ [BLOCK_4X8]`) takes the offset-10 arm. Both bytes re-measured on the
25+ pinned Release oracle this session.
26+3. The chunk (libaom `decode_token_recon_block` semantics: stepr =
27+ `tx_size_high_unit[TX_4X8]` = 2 4-px rows, stepc = 1, unit_width/height
28+ ROUND_POWER_OF_TWO down to (1, 4)): FOUR stacked TX_4X8 units per plane
29+ (chroma rows 0, 8, 16, 24), plane-major, riding the existing
30+ `(4, 8) => ChromaRect8x4` entropy class via [`read_rect_chroma_unit`] —
31+ no coefficient-table row added (BLOCK_4X32 is not a table libaom has).
32+ Each unit is read and recorded immediately: unit row 0's txb_skip_ctx
33+ sees the real neighbour states, lower units see the block's own upper
34+ unit's, and each unit predicts off the upper one's samples. The skip arm
35+ walks the same units (`predict_and_reconstruct_intra_block` predicts
36+ every unit regardless of `skip_txfm`). CfL parameters are computed once
37+ per block over the strip's 8x32 luma and shared by all units. Luma is
38+ the same single TX_8X32 rect the general arm reads.
39+4. The chunk units' `txb_skip_ctx` is `above + left + 10`
40+ (`get_txb_ctx_general`): the port's offset-7-first `txb_skip_chroma_8`
41+ stores the offset-10 rows at rows 3..6 (lane-av1-422b), so
42+ [`read_rect_chroma_unit`] gained a `chroma_skip_offset: Option<usize>`
43+ parameter (mirroring [`read_plane`]'s `chroma_ctx_offset`) and this arm
44+ passes `Some(3)`. Every existing caller passes `None` =
45+ behavior-identical (their rect unit IS the whole plane block, offset-7
46+ rows); the whole-rect read never sees the new `(4, 32)` match row.
47+5. 4:2:0 and 4:4:4 are on their existing paths: the chunk is gated on
48+ `(chroma_w, chroma_h) == (4, 32)` at ss(1,0), which only an 8x32 luma
49+ strip at 4:2:2 produces (4:2:0 reads (4, 16), 4:4:4 reads (8, 32)); the
50+ stale "portrait leaves are unreachable / a conformant stream cannot
51+ carry that leaf size" comment is disproven by the fixture and replaced.
52+
53+## Counter (probe, bypass env; temp print removed)
54+
55+- `rect4_32: vert=1 coded=1` — exactly one 8x32 rect4 strip in the stream,
56+ the block that used to stop.
57+- Eight unit reads at mi=(24,52), plane-major (U rows 0..3, V rows 0..3),
58+ the temp trace printing skip_ctx 3/4/5 — i.e. the offset-10 rows
59+ (base 0..2 + 3) — and varying unit-to-unit as the block's own upper
60+ units enter the context.
61+- `chroma422_rect: 172` total rect 422 chroma units across the 16 decoded
62+ frames (CHROMA422_RECT_HITS, ticked inside [`read_rect_chroma_unit`]).
63+- Pre-fix walk: panics at the stop before any report; post-fix probe prints
64+ `OK: 16 frames decoded, 256x144`.
65+
66+## Pixels — delete condition UNMET, refusal STAYS
67+
68+- Frame 0 (keyframe): luma byte-EXACT vs `aomdec --rawvideo`; U/V carry
69+ 4491/4888 sample diffs from offset ~23 — the PRE-EXISTING keyframe chroma
70+ gap in [`decode_rect_split`] (the live `EC_RECTCHROMA_GAP luma=16x8
71+ tx=8x8 chroma=8x8` diagnostics, ×21 plus one 64x32; present at e24dc84b
72+ per the av1422o report, not this lane's function).
73+- Frames 1..15 diverge widely (luma included), consistent with an entropy
74+ divergence somewhere in the inter walk — this is the first time the
75+ stream decodes past the old stop, so there is no earlier full-stream
76+ baseline to diff against.
77+- Frontier (NOT fixed — larger than this one shape; named per charter):
78+ 1. **`decode_rect4_16_strip`'s `chroma422_pair16` chunk passes no chroma
79+ skip offset** — it reads the offset-7 rows (txb_skip rows 0..3) where
80+ the same measured rule (plane_bsize BLOCK_INVALID for the pair's
81+ BLOCK_4X16 too) demands offset 10, i.e. `Some(3)`. That function is
82+ the protected av1422o lane fix, so this lane only plumbed `None`
83+ through the new parameter (behavior-identical) and names the defect
84+ for its owning lane. It runs in frame 2 before the 4x32, making it
85+ the prime suspect for the inter-frame divergence.
86+ 2. [`decode_rect_split`]'s own-chroma gap (the EC_RECTCHROMA_GAP class
87+ above).
88+ 3. Our dump carries out-of-range u16 samples on frames 1 (2 samples) and
89+ 14 (6 samples) — an unclipped-output class, unattributed.
90+- The header refusal stands untouched: `git diff` shows ONLY
91+ `crates/ec-av1/src/decode.rs` (+255/−40); `stream.rs` is byte-identical
92+ and the probe without the bypass prints `REFUSED: unsupported: AV1
93+ decode_stream (a chroma format of 4:2:2 ...)` as before.
94+
95+## Verification
96+
97+- `cargo check -p ec-av1 --all-targets` (target dir
98+ `~/.cache/cargo-target-av1422p`): **0 warnings, 0 errors**.
99+- 420 gate green under `EC_AV1_REQUIRE_AOMENC=1`:
100+ `stream::tests::a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_
101+ whose_tx_split_decodes_pixel_exact`: 1 passed, 0 failed ("6 pixel-exact
102+ matches, 0 named refusals").
103+- Oracle reference: `$HOME/.cache/aom-oracle/build/aomdec` on the fixture →
104+ 16 frames raw 4:2:2, per-frame per-plane diffed against `dump_yuv`.
105+- Untouched: `decode_rect4_16_strip` (mechanical `None` arg only, no
106+ behavioral edit), `read_inter_rect_chroma` (the four TX_4X8 (4, 32) inter
107+ chunk stays), the 4:2:0 group-tail chroma SKIP arm, `decode_probe.rs`,
108+ the lossless arm (depth != 0 || lossless returns before the chroma
109+ table), the landscape (16,8)/(8,4) arms, and every existing
110+ [`read_rect_chroma_unit`] caller's decode behavior.
111+
112+## State
113+
114+- Commit on lane-av1-422p (no push): the chroma_skip_offset parameter, the
115+ 4x32 chunk arms (skip and non-skip), the corrected portrait-leaf comment,
116+ and this report.
117+- Next stop named for the owning lane: the `chroma422_pair16` offset-10
118+ skip rows in `decode_rect4_16_strip`, then the inter-frame walk's first
119+ divergence against the oracle.
lanes/av1422q.report.mdadded+42 -0
@@ -0,0 +1,42 @@
1+# lane-av1-422q — the av1422p frontier's prime suspect APPLIED: the
2+# `chroma422_pair16` chunk passes `Some(3)` (the offset-10 skip rows), the
3+# 4x32 arm and every other caller untouched, the header refusal STAYS
4+
5+## Outcome
6+
7+1. The one-argument change, nothing else: `decode_rect4_16_strip`'s
8+ `chroma422_pair16` arm now passes `Some(3)` to [`read_rect_chroma_unit`]'s
9+ `chroma_skip_offset` (was `None`). Same measured rule as the 4x32 arm:
10+ the pair's plane_bsize is `ss_size_lookup[BLOCK_4X16][1][0]` =
11+ BLOCK_INVALID too, and the decodetxb copy of `num_pels_log2_lookup` reads
12+ `0xff` at +255 (0xc0de70), so libaom's `get_txb_ctx_general` takes the
13+ offset-10 arm; the port's offset-7-first `txb_skip_chroma_8` holds those
14+ rows at 3..6. The stale lane-av1-422p `None` comment (which claimed the
15+ offset-10 question was still open) is replaced by the measured rule.
16+2. Untouched, byte-identical: the 4x32 arm's existing `Some(3)`, every other
17+ [`read_rect_chroma_unit`] caller (`None`), the 4:2:0 group-tail chroma
18+ SKIP arm, `decode_probe.rs`, `stream.rs`, and the 4:2:2 header refusal
19+ (the charter's delete condition — 16-frame pixel-exact + a 422-unit
20+ counter — was not claimed this session, so nothing was deleted).
21+
22+## Verification
23+
24+- `git diff`: ONLY `crates/ec-av1/src/decode.rs` — one argument
25+ (`None` -> `Some(3)`) plus its comment (+7/−5 lines).
26+- `cargo check -p ec-av1` (target dir `~/.cache/cargo-target-av1422q`):
27+ **0 warnings, 0 errors**.
28+- 420 gate green under `EC_AV1_REQUIRE_AOMENC=1`:
29+ `stream::tests::a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_
30+ whose_tx_split_decodes_pixel_exact`: 1 passed, 0 failed.
31+- Not exercised this session (honest gaps): the 16-frame 4:2:2 stream was
32+ NOT re-decoded and no pixel comparison was run — this lane's scope was the
33+ single argument; whether the offset-10 rows fix the inter-frame
34+ divergence is the next lane's diff.
35+
36+## State
37+
38+- Commit on lane-av1-422q (no push): the `Some(3)` argument, the corrected
39+ comment, and this report.
40+- Next stop named for the owning lane: re-run the 16-frame probe/bypass with
41+ counters and diff frames 1..15 against the aomdec oracle — the av1422p
42+ report named this arm the prime suspect for the inter-frame divergence.
lanes/av1422r.report.mdadded+76 -0
@@ -0,0 +1,76 @@
1+# lane-av1-422r — REMEASURE after the q `Some(3)`: the first remaining diff is
2+# STILL frame 0 plane U (0, 23) ours=50 vs oracle=49 — first of the 4491-sample
3+# `decode_rect_split` own-chroma keyframe gap, NOT one wrong index — the
4+# inter-frame divergence PERSISTS (frames 1..8 differ from (0,0)), and the walk
5+# now PANICS at frame 9 in [`read_coeffs_rect`] (rect coeff scratch 36×36 <
6+# the 4:2:2 TX_32X64 chroma unit's 36×68). Stopped and named per charter.
7+
8+## Outcome
9+
10+1. Remeasured the pinned fixture (sha256 `d3fa4beeb1309033e4a03f5ae5c431c8fa
11+ 8386ba1ada088684710423c7938129`) at 03be6bad against
12+ `$HOME/.cache/aom-oracle/build/aomdec --rawvideo` (16 frames, i422), probe
13+ dump `EC_PROBE_OUT16`, local `EC_AV1_ALLOW_422_PROBE` bypass, reverted
14+ byte-identical after (`git status` clean before the report commit). Do not
15+ trust the p-report diff numbers blindly: re-derived per-frame per-plane
16+ first diffs from the raw dumps this session.
17+2. **The first remaining diff: frame 0, plane U, row 0, col 23, ours=50,
18+ oracle=49.** Frame 0 luma is byte-exact; frame 0 carries 4491 U + 4888 V
19+ diffs — the counts are byte-IDENTICAL to the pre-fix p-report measurement,
20+ as expected: frame 0 is the keyframe and the pair16/4x32 arms never run
21+ there. The class is [`decode_rect_split`]'s own-chroma gap (the live
22+ `EC_RECTCHROMA_GAP luma=16x8 tx=8x8 chroma=8x8` diagnostics). 4491 samples
23+ is not one wrong index → charter step 3: STOP and name the function:
24+ **`decode_rect_split`** (own-chroma reconstruction at ss(1,0)).
25+3. **The offset suspect is refuted for the inter-frame divergence**: frames
26+ 1..8 diverge from sample (0,0) in all three planes (frame 1: Y (0,0)
27+ ours=78 oracle=80, U (0,0) 230 vs 87, V (0,0) 165 vs 245; plane totals
28+ over 9 frames Y=258976, U=125891, V=124050). The q lane's `Some(3)` did
29+ not sync the inter walk. Note the U/V frame-1 offsets are consistent with
30+ MC inheritance of the already-wrong frame-0 chroma; the Y divergence
31+ (frame 0 Y exact) is a separate inter-path question that cannot be
32+ localized while chroma inherits the frame-0 gap.
33+4. **New hard stop, frame 9**: `read_coeffs_rect` panics
34+ `rect coeff scratch w=32 h=64 n=2448` (decode.rs:7129, panic at :7195).
35+ The scratch bound `n <= 36*36` covers ≤32×32 units; a 64×64 luma block at
36+ ss(1,0) has plane_bsize `ss_size_lookup[BLOCK_64X64][1][0]` = BLOCK_32X64
37+ (NOT invalid — unlike the p/q chunks), `max_txsize_rect_lookup` reads
38+ TX_32X64, and (32+4)×(64+4) = 2448 exceeds the bound. Frames 9..15 are
39+ unmeasurable until this is lifted. This shape never fired pre-fix because
40+ the unsynced walk never reached it.
41+5. 4 u16 samples out of 8-bit range across frames 0..8 (the p report's
42+ unclipped-output class, still unattributed; was 2+6 over 16 frames).
43+
44+## Decision
45+
46+- First diff is a 4491-sample class → no one-index fix exists; stopped per
47+ charter. Functions named: [`decode_rect_split`] (owns the first diff) and
48+ [`read_coeffs_rect`] (scratch capacity, blocks frames 9+).
49+- Header refusal STAYS: delete condition unmet (not pixel-exact — frame 0
50+ alone carries 9379 chroma diffs; no full-stream proof possible with the
51+ frame-9 panic). `stream.rs` untouched; the bypass was local-only and is
52+ not in the commit.
53+
54+## Verification
55+
56+- Ours: 9 complete frames dumped before the panic (147456 B/frame u16);
57+ oracle: 16 frames i422. Stride-checked comparison (u16 elements vs bytes —
58+ the first compare script had a byte/element stride bug; frame 0's numbers
59+ were unaffected and frames 1..8 were re-derived at the correct stride).
60+- `cargo check -p ec-av1` (target `~/.cache/cargo-target-av1422r`): 0
61+ warnings, 0 errors.
62+- 420 gate green under `EC_AV1_REQUIRE_AOMENC=1`:
63+ `stream::tests::a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_
64+ whose_tx_split_decodes_pixel_exact`: 1 passed, 0 failed.
65+- `git status` clean after bypass revert; this commit carries ONLY this
66+ report.
67+
68+## State
69+
70+- Commit on lane-av1-422r (no push): this report, nothing else.
71+- Next stop named for the owning lane: lift [`read_coeffs_rect`]'s scratch
72+ bound for TX_32X64 (36×68 levels — likely a heap fallback like
73+ [`read_coeffs`]'s, or a 68-row stack tier), re-run the 16-frame remeasure,
74+ THEN take the frame 1 luma (0,0) inter divergence with frame-0 chroma
75+ inheritance accounted for; [`decode_rect_split`]'s own-chroma gap remains
76+ the owner of the literal first diff.
lanes/av1422sub8rect.report.mdadded+185 -0
@@ -0,0 +1,185 @@
1+# lane-av1-422sub8rect — the sub-8x8 inter 4:2:2 chroma ported to its real
2+# shapes (`decode_inter_block8`'s whole chroma half to the BLOCK_4X8 rect;
3+# `decode_inter_sub8_split4`'s group unit replaced by the per-piece
4+# odd-column chroma-reference model the oracle traces actually code); frame
5+# 0 stays byte-exact at all four stages, the 4:2:0/4:4:4 identity holds by
6+# ss-keying, and the inter-frame divergence is REMEASURED (reduced ~15% on
7+# frames 1..10, exactness NOT claimed -- other 4:2:2 classes remain)
8+
9+## Outcome
10+
11+1. ROOT-CAUSE CONFIRMATION FIRST (pinned fixture `/tmp/t422.obu` sha256
12+ `d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129`,
13+ parent-lane instruments in `/tmp/i422/`, local `EC_AV1_ALLOW_422_PROBE`
14+ bypass applied and reverted byte-identical after — `git diff` carries
15+ only decode.rs/mc.rs/encode.rs changes): the oracle's frame-1 first
16+ block (`AOMMB mi=(0,0) ... skip=0`) reads luma TX_8X8 then
17+ `plane=1 tx_size=5 mi_row=0 mi_col=0 rng=55168` — tx_size 5 IS TX_4X8,
18+ confirming the charter: the 8x8 inter leaf's chroma plane block is
19+ BLOCK_4X8, one TX_4X8 rect unit per plane (`ss_size_lookup[BLOCK_8X8][1][0]`),
20+ while ours read a TX_4X4 square.
21+2. SPLIT4 MODEL CORRECTED AGAINST THE ORACLE, NOT THE CHARTER'S GUESS: the
22+ parent report assumed the split4 group codes ONE rect group unit; the
23+ traces prove otherwise. At ss (1,0) `is_chroma_reference` for a BLOCK_4X4
24+ piece is `(mi_col & 0x01)` — ODD columns only (av1_common_int.h:1459) —
25+ and every non-skipped odd-column piece codes its OWN U then V TX_4X4
26+ square unit right after its luma, anchored at the FLOORED chroma cell
27+ (`(mi_col & !1) * MI >> ss_x`, the lane-av1-422kf2 rule) with
28+ `around_mi_422_chroma`-style per-chroma-cell ctx (measured ctx 8 =
29+ above+left+7 at frame 1's mi(12,3)):
30+ - frame 0 key-frame groups (18,54) and (30,42): U+V read on BOTH
31+ odd-column leaves ((18,55)+(19,55), (30,43)+(31,43));
32+ - frame 1 inter group at mi(12,2): U+V on leaf (12,3) ALONE — its
33+ bottom-right twin was skipped, so it codes nothing.
34+ The 4:2:0 shared group unit simply never exists at 4:2:2.
35+3. PORT (all keyed on ss, 4:2:0/4:4:4 byte-identical by construction):
36+ - `decode_inter_block8` chroma half to per-axis shapes: `chroma_w/chroma_h`,
37+ `(TxbSet::ChromaRect8x4, SCAN_4X8)` at 4:2:2; inter coefficient reads
38+ through `read_inter_plane_rect` (offset-7 ctx — the unit IS the plane
39+ block — inherited luma tx type) with `around_mi_422_chroma`; MC
40+ prediction (single-ref, scaled, warp, compound-intermediate), the
41+ wedge-masked blend, interintra blend, OBMC pushes and skip pushes all
42+ (4, 8)-shaped; the intra-in-inter arm reads the key-frame arm's own
43+ rect reader (`read_rect_chroma_unit`, ctx offset None, CfL carried);
44+ palette UV map dims per axis.
45+ - `decode_inter_sub8_split4`: per-piece arm added after each inter
46+ piece's luma (odd column, ss 1,0): prediction as
47+ `build_inter_predictors_sub8x8` — left 2x4 half from the LEFT piece's
48+ own ref/mv/filters, right 2x4 half from this piece's; a mixed group
49+ (left piece intra/off-frame, `is_sub8x8_inter` false) predicts the
50+ whole 4x4 from this piece; skip pieces still predict but record zeros.
51+ Coefficients via square `TxbSet::Chroma4` reads at the floored anchor,
52+ per-unit `record_mi_chroma` (8x4 luma span). Intra pieces gate
53+ `has_chroma` on the piece's own column parity and route through
54+ [`sub8_leaf_chroma422`]; even-column intra pieces publish DC to the
55+ uv-mode map. The 4:2:0 group tail (build, read, band stamps, DC map
56+ stamp) is gated OFF at 4:2:2.
57+ - Shared helpers made ss-exact (4:2:0/4:4:4 reduce to the old behaviour):
58+ `blend_masked_compound`'s `subsampled: bool` → per-axis `(subw, subh)`
59+ mirroring aom_dsp/blend-a64-mask.c's four branches; `interintra_blend`'s
60+ wedge mask read likewise; `obmc_plan`/`obmc_run` take the plane ss —
61+ chroma extents are the luma rules `>> ss` (`av1_skip_u4x4_pred_in_obmc`
62+ keyed on the plane block, above-pass skip and left-pass blend extents),
63+ `TxParams::strided` sized `stride * h` (identical when h == stride, as
64+ every pre-existing caller has). The encoder's `obmc_plan` call passes
65+ the fctx ss.
66+ - STOP-NOTE (owning parent-lane surface, named not fixed):
67+ `decode_inter_block`'s 4:2:2 chroma is still the square-cut model; its
68+ chroma masked-blend keeps the pre-port direct mask read there (guarded
69+ by `ss_x == ss_y`), because its `chroma_side`-square buffers cannot be
70+ indexed by the subsampled-axis walks. Known-divergent, unchanged
71+ behaviour, named for the owning lane.
72+4. MEASURED after the port (17-frame probe run under the reverted bypass;
73+ comparator: ours padded 256x160/128x160 u8 cropped vs the instrumented
74+ `$HOME/.cache/aom-oracle/build` aomdec; NOTE the probe prints REFUSED and
75+ still exits 0 -- the committed tree stops at frame 11 with the
76+ pre-existing "HORZ/VERT strip ... no rect coefficient tables" frontier
77+ refusal, exactly like the reworked tree):
78+ - frame 0: **byte-exact at PREFILT, POSTCDEF (and FINAL by the u16
79+ comparator) on Y, U and V — 0 diffs everywhere**, so the rect read,
80+ the split4 per-piece model and every shared-helper change are exact on
81+ everything frame 0 exercises (including the split groups (18,54),
82+ (30,42) that motivated the per-piece model).
83+ - inter frames 1..10 decode and were measured: PREFILT diffs dropped
84+ ~15% vs the parent lane's ladder (e.g. frame 1: 30825/12624/12796 →
85+ 22248/11733/11974; frame 8: 35014/11020/12043 → 32855/11020/12043;
86+ per-frame values in `/tmp/i422/sub8rect/`). **Frame exactness is NOT
87+ claimed** — frames 1..10 remain divergent: the named sub-8 sites are
88+ fixed, but the stream carries further 4:2:2 classes the decoder still
89+ square-cuts or gaps (probe trace: `EC_RECTCHROMA_GAP luma=16x8
90+ tx=16x8 chroma=8x8`, `luma=8x32 ... chroma=4x32`, i.e. `decode_inter_block`'s
91+ own 4:2:2 chroma half), so the entropy walk desyncs again after the
92+ first uncoded-for block.
93+ - frames 11..16 were not reached by the probe's frame accounting this
94+ round (11 dumped frames, decode exits 0 — the dump-index vs
95+ show-existing accounting needs the parent-lane harness's
96+ 1-frame-per-OBU walk); the ladder for 1..16 is the owning lane's
97+ re-measurement once the next class lands.
98+5. Deferred items: (a) frames 11..16 ladder entries — unblock: rerun the
99+ parent-lane per-OBU cut harness (`/tmp/i422/cut_frames.py`) after the
100+ next class; (b) `decode_inter_sub8_rect2`'s 4:2:2 has_chroma gating (its
101+ inter strips pass `i == 1` where BLOCK_4X8 needs odd-column parity) —
102+ not one of this charter's named sites, unmeasured on the fixture so far.
103+
104+## Decision
105+
106+- The header refusal STAYS unconditional in `stream.rs`; the bypass was
107+ local-only, applied and reverted byte-identical (0 occurrences left;
108+ `stream::tests` green after the revert).
109+- 4:2:0/4:4:4 untouched by construction (ss-keyed arms); the 4:2:0
110+ group-tail SKIP arm untouched; `read_coeffs_rect` untouched.
111+
112+## Review rework (r2, post-review findings 1-3)
113+
114+The review correctly rejected two byte-identity claims and one
115+justification:
116+
117+1. **444 OBMC behaviour now UNCHANGED from the parent.** The first commit
118+ made `obmc_plan`/`obmc_run` ss-exact (`av1_skip_u4x4_pred_in_obmc`
119+ keyed on the plane block; chroma extents `>> ss`), which is what
120+ reconinter.c does -- but it CHANGES 4:4:4 behaviour (the above-pass
121+ chroma skip flips to run on square plane blocks, the blend extents
122+ double) and is NOT byte-identical, with no 444 OBMC gate covering it.
123+ Measured before reworking: fixture `/tmp/obmc444/obmc444.obu` sha256
124+ `4b5c0a473c7ca5bd460e76bb5d7fde541dc996bec45f60bfcc393eb2f11731ef`
125+ (10-frame 128x96 4:4:4 aomenc `--enable-obmc=1 --profile=1`, 2 rect
126+ OBMC leaves firing per the probe census), decoded parent (4e8c6073)
127+ vs tip vs instrumented aomdec: parent and tip read IDENTICAL symbols
128+ and differ in exactly ONE V sample (f1, (82,80)): oracle 110 ==
129+ parent, tip 111. Attribution by single-change revert builds: reverting
130+ `TxParams::strided` alone (varB) reproduces tip exactly; reverting the
131+ OBMC ss semantics alone (varA) reproduces the parent exactly -- so the
132+ whole parent<->tip delta is the OBMC change, and on this fixture the
133+ conformant variant is one sample FARTHER from aomdec, never closer.
134+ Per the review protocol ("if worse, rework") the OBMC ss semantics are
135+ REVERTED to the parent's 4:2:0-shaped corner-cut (luma-keyed
136+ `skip_chroma_above`, half chroma blend extents); the 444-conformant
137+ port stays deferred to the owning 444 lane, which can measure it on
138+ OBMC-heavy 444 content once that lane's reconstruction class is exact
139+ enough to gate on. `encode.rs` carries no change any more (the ss
140+ argument is gone with the parameter).
141+2. **`TxParams::strided` justification corrected.** The commit text
142+ claimed "every pre-existing caller has h == stride" -- wrong:
143+ `read_inter_plane_rect` callers pass rect units with `h < stride`
144+ (e.g. an 8x4 unit in an 8x8-strided plane buffer), and for those the
145+ scratch shrinks from `stride*stride` to `stride*h`. Output identity
146+ holds because the copy loop only ever writes `h` rows of `w <= stride`
147+ and every consumer reads the residual through the same dense bounds --
148+ verified empirically (the 4:2:0 pixel-exact witness, 4:4:4 frame
149+ equality with the parent on the obmc444 fixture, and the varB
150+ revert experiment), not by the removed claim. The `stride * h` sizing
151+ itself STAYS: the 4:2:2 leaf's TX_4X8 unit (stride 4, h 8) panics on
152+ the old square sizing.
153+3. The t422 measurement note above also corrects the probe's exit-status
154+ reading (REFUSED still exits 0; both the committed and reworked trees
155+ stop at frame 11 on the pre-existing strip-chroma frontier refusal).
156+
157+Everything else in Outcome 3 (the leaf8 rect port, the split4 per-piece
158+model, the ss-keyed masked/interintra blends) is untouched by the rework;
159+frame 0 re-verified byte-exact at PREFILT/POSTCDEF after it, and both
160+gates re-run green post-revert.
161+
162+## Verification
163+
164+- `cargo check -p ec-av1` (target `~/.cache/cargo-target-av1422sub8rect`):
165+ 0 warnings, 0 errors.
166+- `stream::tests::a_non_420_subsampled_sequence_header_is_refused_by_name`:
167+ 1 passed — the refusal fires after the bypass revert.
168+- `stream::tests::a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_
169+ whose_tx_split_decodes_pixel_exact` under `EC_AV1_REQUIRE_AOMENC=1`
170+ (oracle aomenc): 1 passed — the 4:2:0 inter path, including the
171+ shared-helper ss-ifications, stays pixel-exact.
172+- Frame-0 stage dumps vs the instrumented aomdec: PREFILT/POSTCDEF
173+ Y=U=V=0 (POSTDEB comparator run this round used the wrong dump-env name;
174+ the post-deblock state is bracketed by the two exact stages).
175+- Hit counter added: `CHROMA422_INTER_SUB8_HITS` (per-piece inter 4:2:2
176+ chroma units) — reads non-zero on the fixture's frames 1+, so the new arm
177+ provably fires.
178+
179+## State
180+
181+- Commit on lane-av1-422sub8rect (no push): the sub-8 rect port +
182+ `TxParams::strided` sizing fix + shared ss-exact helpers + this report.
183+- Probe instruments regenerated under `/tmp/i422/sub8rect/` (scratch, not
184+ committed); the oracle build's rungs already cover everything needed to
185+ re-measure after the next class.
scripts/instrument-aom-oracle.shmodified+70 -0
@@ -40,6 +40,13 @@
40 # its superres margin (lane-superres r5: hand-tracing the arithmetic40 # its superres margin (lane-superres r5: hand-tracing the arithmetic
41 # could only prove our own self-consistency, not correctness against41 # could only prove our own self-consistency, not correctness against
42 # libaom).42 # libaom).
43+# EC_AV1_POSTCDEF_DUMP=<prefix> -> <prefix>.f<N> per frame, same shape as
44+# the POSTDEBLOCK rung (full ALIGNED-buffer rows), written right after
45+# the CDEF pass and before superres/LR -- splits a final-output
46+# mismatch into "already in CDEF" vs "introduced by loop restoration"
47+# without the 16-bit-only DUMP16 rungs (lane-av1422filter: on the
48+# pinned 4:2:2 keyframe this named the 251/259-sample CDEF chroma
49+# defect whose first samples were the ticket's first final samples).
43 # EC_TRACE_MODE_STEP=1 -> per-symbol range ladder inside50 # EC_TRACE_MODE_STEP=1 -> per-symbol range ladder inside
44 # ec_read_intra_frame_mode_info_impl (rung 5's renamed body):51 # ec_read_intra_frame_mode_info_impl (rung 5's renamed body):
45 # "EC_ISTEP mi_row=.. mi_col=.. name=skip val=.. rng=.." after52 # "EC_ISTEP mi_row=.. mi_col=.. name=skip val=.. rng=.." after
@@ -832,3 +839,66 @@ s = s.replace(anchor, anchor + dump, 1)
832 open(path, "w").write(s)839 open(path, "w").write(s)
833 print("decodemv rung 14 (per-entry EC_STACK) instrumented")840 print("decodemv rung 14 (per-entry EC_STACK) instrumented")
834 PYST841 PYST
842+
843+# --- rung 15: post-CDEF, pre-superres 8-bit row dump (lane-av1422filter) ---
844+# The 8-bit mirror of rung 6 one stage later: written right after the CDEF
845+# pass (the `if (do_cdef) {...}` block) and before superres/LR, so a final
846+# chroma/luma mismatch splits into "already in CDEF" vs "introduced by
847+# loop restoration". The *_DUMP16 family covers this stage only in 16-bit
848+# builds (its 8-bit run SEGFAULTS); this rung is the 8-bit one. lane-
849+# av1422filter added it to the live oracle tree by hand first, then it was
850+# transcribed here (class: instrument that lives only in a build tree).
851+python3 - "$F" <<'PYC'
852+import sys
853+path = sys.argv[1]
854+s = open(path).read()
855+if "EC_INSTRUMENTED_POSTCDEF" in s:
856+ print("postcdef dump already instrumented (no-op)")
857+ sys.exit(0)
858+
859+anchor = """ if (do_cdef) {
860+ if (pbi->num_workers > 1) {
861+ av1_cdef_frame_mt(cm, &pbi->dcb.xd, pbi->cdef_worker,
862+ pbi->tile_workers, &pbi->cdef_sync,
863+ pbi->num_workers, av1_cdef_init_fb_row_mt,
864+ do_extend_border_mt);
865+ } else {
866+ av1_cdef_frame(&pbi->common.cur_frame->buf, cm, &pbi->dcb.xd,
867+ av1_cdef_init_fb_row);
868+ }
869+ }
870+"""
871+dump = """
872+ /* EC_INSTRUMENTED_POSTCDEF (8-bit twin of the POSTDEBLOCK rung:
873+ * full aligned buffer, post-CDEF pre-superres/LR) */
874+ {
875+ const char *ec_dump = getenv("EC_AV1_POSTCDEF_DUMP");
876+ if (ec_dump) {
877+ static int ec_postcdef_idx = 0;
878+ char ec_path[1024];
879+ snprintf(ec_path, sizeof(ec_path), "%s.f%d", ec_dump,
880+ ec_postcdef_idx++);
881+ FILE *ec_f = fopen(ec_path, "wb");
882+ if (ec_f) {
883+ const YV12_BUFFER_CONFIG *ec_b = &cm->cur_frame->buf;
884+ for (int ec_r = 0; ec_r < ec_b->y_height; ++ec_r)
885+ fwrite(ec_b->y_buffer + ec_r * ec_b->y_stride, 1, ec_b->y_width,
886+ ec_f);
887+ if (num_planes > 1) {
888+ for (int ec_r = 0; ec_r < ec_b->uv_height; ++ec_r)
889+ fwrite(ec_b->u_buffer + ec_r * ec_b->uv_stride, 1,
890+ ec_b->uv_width, ec_f);
891+ for (int ec_r = 0; ec_r < ec_b->uv_height; ++ec_r)
892+ fwrite(ec_b->v_buffer + ec_r * ec_b->uv_stride, 1,
893+ ec_b->uv_width, ec_f);
894+ }
895+ fclose(ec_f);
896+ }
897+ }
898+ }
899+"""
900+assert anchor in s, "do_cdef block anchor moved"
901+s = s.replace(anchor, anchor + dump, 1)
902+open(path, "w").write(s)
903+print("postcdef dump instrumented")
904+PYC