forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'main' into lane-mergefix

Browse files at this commit

54a60c1c06b3c3dc084e3b1440978a21b5c425ceAhmet Kaan GümüşParent: 34789da0cc84e8
# Conflicts:
#	crates/ec-av1/examples/decode_probe.rs
#	crates/ec-av1/src/cdf_state.rs
#	crates/ec-av1/src/decode.rs
#	crates/ec-av1/src/refusal_inventory.rs
#	crates/ec-av1/src/stream.rs
#	lanes/mergefix-r2.report.md

43 changed files +10718 -3963

crates/ec-av1/examples/decode_probe.rsmodified+44 -7
@@ -34,13 +34,14 @@ fn main() {
3434 let (h, v, c) = ec_av1::stream::rect4_32_counters();
3535 println!("rect4_32: horz={h} vert={v} coded={c}");
3636 println!("rect_intrabc_reads: {}", ec_av1::stream::rect_intrabc_reads());
37- let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();
38- println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");
39- let i4 = ec_av1::stream::intra_rect4_in_inter_counters();
4037 println!(
41- "intra_rect4_in_inter: 64x16={} 16x64={} 32x8={} 8x32={}",
42- i4.0, i4.1, i4.2, i4.3
38+ "rect64_corner_tu: 64x32={} 32x64={}",
39+ ec_av1::stream::rect64_corner_tu_hits(0),
40+ ec_av1::stream::rect64_corner_tu_hits(1)
4341 );
42+ println!("leaf8_intrabc_hits: {}", ec_av1::stream::leaf8_intrabc_hits());
43+ let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();
44+ println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");
4445 println!("sub8_inter_split: groups={}", ec_av1::decode::sub8_inter_split_hits());
4546 let (h84, h48) = ec_av1::decode::sub8_inter_rect_hits();
4647 println!("sub8_inter_rect: horz8x4={h84} vert4x8={h48}");
@@ -57,10 +58,14 @@ fn main() {
5758 // asserts -- printed here so a recipe sweep can see it fire without a
5859 // test-binary rebuild.
5960 println!("skip_split_tx: {}", ec_av1::decode::skip_split_tx_hits());
61+ let es = ec_av1::decode::inter_edge_strip_hits();
62+ println!(
63+ "inter_edge_strip: h64={} v64={} h32={} v32={} h16={} v16={}",
64+ es[0], es[1], es[2], es[3], es[4], es[5]
65+
66+ );
6067 let (h4, v4, pairs, sub8) = ec_av1::decode::inter16_rect4_counters();
6168 println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}");
62- let leaf = ec_av1::stream::vartx_rect_leaf_hits();
63- println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]);
6469 let leaf4 = ec_av1::stream::vartx_rect_leaf4_hits();
6570 println!("vartx_rect_leaf4: 8x4={} 4x8={}", leaf4[0], leaf4[1]);
6671 let rw = ec_av1::stream::rect_wedge_hits();
@@ -68,11 +73,43 @@ fn main() {
6873 println!(
6974 "rect_wedge(8x16,16x8,16x32,32x16,8x32,32x8): compound={rw:?} interintra={rwi:?}"
7075 );
76+ let sb = ec_av1::stream::sb128_rect_counters();
77+ println!(
78+ "sb128_rect: edge_horz={} edge_vert={} inter_128x64={} inter_64x128={}",
79+ sb.0, sb.1, sb.2, sb.3
80+ );
81+ // lane-sbab r1: the superblock-level inter AB arms.
82+ let sbab = ec_av1::decode::sb_ab_inter_hits_by_arm();
83+ println!(
84+ "inter_ab64: horz_a={} horz_b={} vert_a={} vert_b={}",
85+ sbab[0], sbab[1], sbab[2], sbab[3]
86+ );
87+ let i4 = ec_av1::stream::intra_rect4_in_inter_counters();
88+ println!(
89+ "intra_rect4_in_inter: 64x16={} 16x64={} 32x8={} 8x32={}",
90+ i4.0, i4.1, i4.2, i4.3
91+ );
92+ // lane-cdefstrip r1: 8x8 CDEF units whose skip band no coded block
93+ // wrote this frame -- non-zero means a decode arm forgot
94+ // `fill_skip_grid_rect`, and CDEF filtered a unit libaom may skip.
95+ println!(
96+ "cdef_unwritten_skip_units: {}",
97+ ec_av1::decode::cdef_unwritten_skip_units()
98+ );
99+ println!(
100+ "cdef_band: rect_skip_writes={} mixed_skip_units={}",
101+ ec_av1::decode::rect_skip_band_hits(),
102+ ec_av1::decode::cdef_mixed_skip_units()
103+ );
71104 let ir = ec_av1::stream::inter_rect_counters();
72105 println!(
73106 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",
74107 ir.0, ir.1, ir.2, ir.3, ir.4, ir.5
75108 );
109+ // lane-rectres r1: how many of those 32x8/8x32 strips coded a real
110+ // rectangular residual transform unit (a skipped one codes none).
111+ let r328 = ec_av1::stream::rect32x8_inter_tu_hits();
112+ println!("rect32x8_inter_tu: 32x8={} 8x32={}", r328[0], r328[1]);
76113 };
77114 // lane-tiles: the tiling a real stream actually uses is a decision input
78115 // (every gate in `stream.rs` picks its own `--tile-columns`), so report it
crates/ec-av1/fixtures/av1_192x128_8bit_intra64_in_inter.obuadded+0 -0

Binary file changed

crates/ec-av1/src/cdf_state.rsmodified+20 -40
@@ -118,6 +118,14 @@ pub(crate) enum TxbSet {
118118 /// block, so the encoder writes none (same reason
119119 /// [`LumaRect32x16`](TxbSet::LumaRect32x16) has none).
120120 LumaRect32x8,
121+ /// lane-rectres r1: [`LumaRect32x8`](TxbSet::LumaRect32x8)'s INTER twin --
122+ /// the 32x32-level 1:4 strip (`max_txsize_rect_lookup[BLOCK_32X8] ==
123+ /// TX_32X8`). Same coefficient tables (`get_txsize_entropy_ctx` = TX_16X16,
124+ /// `txsize_log2_minus4` = 4, 256 positions), but an inter unit DOES code a
125+ /// `tx_type`: `av1_get_ext_tx_set_type` at `tx_size_sqr_up == TX_32X32` is
126+ /// `EXT_TX_SET_DCT_IDTX` for inter regardless of `reduced_tx_set`, read at
127+ /// the `txsize_sqr_map[TX_32X8] == TX_8X8` CDF row.
128+ LumaRect32x8Inter,
121129 LumaRect32x16,
122130 /// lane-inter4 r2: [`LumaRect32x16`](TxbSet::LumaRect32x16)'s INTER twin --
123131 /// same coefficient tables (`get_txsize_entropy_ctx` reduces TX_32X16 and
@@ -259,22 +267,6 @@ pub(crate) enum TxbSet {
259267 /// TX_16X16, so `av1_get_ext_tx_set_type` returns `EXT_TX_SET_ALL16` --
260268 /// sixteen symbols, `inter_tx_type_4_set1`.
261269 LumaRect16x4Inter1,
262- /// The luma 8x4/4x8 INTER transform of a `sub_tx_size_map` SPLIT LEAF of
263- /// a 16x4/4x16 strip (lane-inter16ab r4): `sub_tx_size_map[TX_16X4] ==
264- /// TX_8X4`. Shape = [`LumaRect4x8`](TxbSet::LumaRect4x8)'s --
265- /// `get_txsize_entropy_ctx(TX_8X4)` ((`txsize_sqr_map` TX_4X4 +
266- /// `txsize_sqr_up_map` TX_8X8 + 1) >> 1) resolves to TX_8X8 so every
267- /// coefficient table is [`Luma8`](TxbSet::Luma8)'s, with the true
268- /// 32-position `eob_pt` -- but the `tx_type` table is the INTER one at
269- /// `txsize_sqr_map[TX_8X4]` = TX_4X4. `av1_get_ext_tx_set_type`
270- /// (`blockd.h:1097`) with `tx_size_sqr_up == TX_8X8` (not > TX_32X32),
271- /// inter and `use_reduced_set` returns `EXT_TX_SET_DCT_IDTX` --
272- /// `inter_tx_type_4`.
273- /// [`LumaRect8x4Inter`](TxbSet::LumaRect8x4Inter)'s `reduced_tx_set:
274- /// false` counterpart: `tx_size_sqr` is TX_4X4, so
275- /// `av1_get_ext_tx_set_type` returns `EXT_TX_SET_ALL16` --
276- /// `inter_tx_type_4_set1`.
277- LumaRect8x4Inter1,
278270 }
279271
280272 /// The tables one transform block is coded with, borrowed from the state for
@@ -1777,6 +1769,18 @@ impl Cdfs {
17771769 tx_type: None,
17781770 eob_pt_class1: Some(&mut self.eob_pt_1024_chroma_class1),
17791771 },
1772+ TxbSet::LumaRect32x8Inter => TxbTables {
1773+ side: 16,
1774+ txb_skip: &mut self.txb_skip_luma_16,
1775+ eob_pt: &mut self.eob_pt_256_luma,
1776+ eob_extra: &mut self.eob_extra_luma_16,
1777+ base: &mut self.base_luma_16,
1778+ base_eob: &mut self.base_eob_luma_16,
1779+ br: &mut self.br_luma_16,
1780+ dc_sign: &mut self.dc_sign_luma,
1781+ tx_type: Some(self.inter_tx_type_8.as_mut_slice()),
1782+ eob_pt_class1: Some(&mut self.eob_pt_256_luma_class1),
1783+ },
17801784 TxbSet::LumaRect32x8 => TxbTables {
17811785 side: 16,
17821786 txb_skip: &mut self.txb_skip_luma_16,
@@ -1957,30 +1961,6 @@ impl Cdfs {
19571961 tx_type: Some(self.inter_tx_type_4_set1.as_mut_slice()),
19581962 eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1),
19591963 },
1960- TxbSet::LumaRect8x4Inter => TxbTables {
1961- side: 8,
1962- txb_skip: &mut self.txb_skip_luma_8,
1963- eob_pt: &mut self.eob_pt_32_luma,
1964- eob_extra: &mut self.eob_extra_luma_8,
1965- base: &mut self.base_luma_8,
1966- base_eob: &mut self.base_eob_luma_8,
1967- br: &mut self.br_luma_8,
1968- dc_sign: &mut self.dc_sign_luma,
1969- tx_type: Some(self.inter_tx_type_4.as_mut_slice()),
1970- eob_pt_class1: Some(&mut self.eob_pt_32_luma_class1),
1971- },
1972- TxbSet::LumaRect8x4Inter1 => TxbTables {
1973- side: 8,
1974- txb_skip: &mut self.txb_skip_luma_8,
1975- eob_pt: &mut self.eob_pt_32_luma,
1976- eob_extra: &mut self.eob_extra_luma_8,
1977- base: &mut self.base_luma_8,
1978- base_eob: &mut self.base_eob_luma_8,
1979- br: &mut self.br_luma_8,
1980- dc_sign: &mut self.dc_sign_luma,
1981- tx_type: Some(self.inter_tx_type_4_set1.as_mut_slice()),
1982- eob_pt_class1: Some(&mut self.eob_pt_32_luma_class1),
1983- },
19841964 TxbSet::LumaRect16x8Inter => TxbTables {
19851965 side: 16,
19861966 txb_skip: &mut self.txb_skip_luma_16,
crates/ec-av1/src/decode.rsmodified+2109 -403

Diff too large; view file

@@ -181,6 +181,16 @@ thread_local! {
181181 static INTRA_IN_INTER8_UV_CFL_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
182182 }
183183
184+thread_local! {
185+ static INTRA_IN_INTER8_ANGLE_DELTA_Y_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
186+}
187+
188+/// Nonzero luma angle deltas coded by an intra 8x8 leaf inside an inter frame
189+/// (lane-leaf8tx r1) -- counted only in [`decode_inter_block8`]'s intra arm.
190+pub(crate) fn intra_in_inter8_angle_delta_y_hits() -> usize {
191+ INTRA_IN_INTER8_ANGLE_DELTA_Y_HITS.with(|c| c.get())
192+}
193+
184194 /// `(directional, smooth/paeth, CfL)` chroma modes coded by an intra 8x8 leaf
185195 /// inside an inter frame -- see [`INTRA_IN_INTER8_UV_DIR_HITS`].
186196 pub(crate) fn intra_in_inter8_uv_hits() -> (usize, usize, usize) {
@@ -1017,6 +1027,9 @@ thread_local! {
10171027 // (64x32/32x64/64x16/16x64), whose coefficients are coded as the
10181028 // truncated low-32 corner.
10191029 static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1030+ // lane-rectres r1: whole-block luma transform units of a 32x32-level 1:4
1031+ // inter strip, `[32x8, 8x32]`.
1032+ static RECT32X8_INTER_TU_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) };
10201033 // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32].
10211034 static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) };
10221035 // lane-inter16ab r4: rectangular var-tx leaves with a 4-px axis, [8x4, 4x8]
@@ -1074,6 +1087,12 @@ pub(crate) fn rect64_inter_tu_hits() -> usize {
10741087 RECT64_INTER_TU_HITS.with(|c| c.get())
10751088 }
10761089
1090+/// Current value of [`RECT32X8_INTER_TU_HITS`] (lane-rectres r1): `[32x8, 8x32]`
1091+/// whole-block luma units of a 32x32-level 1:4 inter strip.
1092+pub(crate) fn rect32x8_inter_tu_hits() -> [usize; 2] {
1093+ RECT32X8_INTER_TU_HITS.with(|c| c.get())
1094+}
1095+
10771096 /// Current value of [`VARTX_RECT_LEAF_HITS`] (lane-r14 r3): how many
10781097 /// rectangular var-tx leaf transform units were coded, `[32x16, 16x32]`.
10791098 pub(crate) fn vartx_rect_leaf_hits() -> [usize; 2] {
@@ -1192,6 +1211,64 @@ pub(crate) fn edge_rect_strip_hits() -> usize {
11921211 EDGE_RECT_STRIP_HITS.with(|c| c.get())
11931212 }
11941213
1214+// lane-interedge r1: frame-edge half strips on the INTER path, per partition
1215+// level (64/32/16) x axis (HORZ at a bottom edge, VERT at a right edge). The
1216+// index is `level_idx * 2 + axis` with `level_idx` 0=64, 1=32, 2=16 and
1217+// `axis` 0=HORZ (`!has_rows`), 1=VERT (`!has_cols`). Both of the user's films
1218+// are height mod 16 == 8, so every inter frame crosses these nodes.
1219+thread_local! {
1220+ static INTER_EDGE_STRIP_HITS: std::cell::Cell<[usize; 6]> =
1221+ const { std::cell::Cell::new([0; 6]) };
1222+}
1223+
1224+/// Bumps one bucket of [`INTER_EDGE_STRIP_HITS`].
1225+pub(crate) fn bump_inter_edge_strip(idx: usize) {
1226+ INTER_EDGE_STRIP_HITS.with(|c| {
1227+ let mut v = c.get();
1228+ v[idx] += 1;
1229+ c.set(v);
1230+ });
1231+}
1232+
1233+// lane-edgeboth r1: how many partition nodes were coded as the BOTH-AXES-CUT
1234+// forced split -- libaom `decode_partition` (decodeframe.c):
1235+// `else if (!has_rows && !has_cols) partition = PARTITION_SPLIT;`, the one
1236+// straddle case that reads NO symbol at all. Indexed by level:
1237+// 0 = 16x16, 1 = 32x32, 2 = 64x64, 3 = 128x128; intra and inter share it.
1238+thread_local! {
1239+ static EDGE_BOTH_CUT_HITS: std::cell::Cell<[usize; 4]> =
1240+ const { std::cell::Cell::new([0; 4]) };
1241+}
1242+
1243+fn bump_edge_both_cut(level: usize) {
1244+ EDGE_BOTH_CUT_HITS.with(|c| {
1245+ let mut v = c.get();
1246+ v[level] += 1;
1247+ c.set(v);
1248+ });
1249+}
1250+
1251+/// Current value of [`INTER_EDGE_STRIP_HITS`] (`[h64, v64, h32, v32, h16, v16]`).
1252+pub fn inter_edge_strip_hits() -> [usize; 6] {
1253+ INTER_EDGE_STRIP_HITS.with(|c| c.get())
1254+}
1255+
1256+/// Resets [`INTER_EDGE_STRIP_HITS`] -- a refused attempt must not carry hits
1257+/// into the next one (class `counter-from-refused-stream`).
1258+pub fn reset_inter_edge_strip_hits() {
1259+ INTER_EDGE_STRIP_HITS.with(|c| c.set([0; 6]));
1260+}
1261+
1262+/// Current value of [`EDGE_BOTH_CUT_HITS`] (`[16, 32, 64, 128]` levels).
1263+pub(crate) fn edge_both_cut_hits() -> [usize; 4] {
1264+ EDGE_BOTH_CUT_HITS.with(|c| c.get())
1265+}
1266+
1267+/// Zeroes [`EDGE_BOTH_CUT_HITS`] so a gate can measure a per-attempt delta.
1268+pub(crate) fn reset_edge_both_cut_hits() {
1269+ EDGE_BOTH_CUT_HITS.with(|c| c.set([0; 4]));
1270+}
1271+
11951272 // How many HORZ/VERT intra strips resolved a SPLIT luma transform
11961273 // (`tx_depth != 0`) and decoded it per transform unit (lane-rectsplit r1) --
11971274 // the case every rect path here refused by name before, and the first
@@ -1519,6 +1596,41 @@ pub(crate) fn palette_split_tx_hits() -> usize {
15191596 PALETTE_SPLIT_TX_HITS.with(|c| c.get())
15201597 }
15211598
1599+thread_local! {
1600+ /// lane-pal8 r1: square 8x8 LEAVES ([`decode_leaf8`]) that actually use a
1601+ /// palette (Y or UV) -- the shape every 8-bit `--tune-content=screen`
1602+ /// stream stopped on, since aomenc palettes square blocks at 8 bit and
1603+ /// `--min-partition-size=8` puts them on this leaf path.
1604+ static PALETTE_LEAF8_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1605+}
1606+
1607+/// Current value of [`PALETTE_LEAF8_HITS`].
1608+pub(crate) fn palette_leaf8_hits() -> usize {
1609+ PALETTE_LEAF8_HITS.with(|c| c.get())
1610+}
1611+
1612+/// Zeroes [`PALETTE_LEAF8_HITS`] (per-attempt gate counting).
1613+pub(crate) fn reset_palette_leaf8_hits() {
1614+ PALETTE_LEAF8_HITS.with(|c| c.set(0));
1615+}
1616+
1617+thread_local! {
1618+ /// lane-pal8 r1: NON-SKIP palette blocks on a superblock-level (64-level)
1619+ /// HORZ/VERT or 1:4 strip ([`decode_block_rect64`]) -- i.e. a palette
1620+ /// block that also carries a real, corner-cropped luma transform.
1621+ static PALETTE_SB_STRIP_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1622+}
1623+
1624+/// Current value of [`PALETTE_SB_STRIP_HITS`].
1625+pub(crate) fn palette_sb_strip_hits() -> usize {
1626+ PALETTE_SB_STRIP_HITS.with(|c| c.get())
1627+}
1628+
1629+/// Zeroes [`PALETTE_SB_STRIP_HITS`] (per-attempt gate counting).
1630+pub(crate) fn reset_palette_sb_strip_hits() {
1631+ PALETTE_SB_STRIP_HITS.with(|c| c.set(0));
1632+}
1633+
15221634 // lane-hgkf r2: SKIPPED intra blocks whose `tx_depth` split the luma transform
15231635 // and which are therefore predicted one transform unit at a time (a skipped
15241636 // block codes no coefficients, so nothing else in the stream witnesses this
@@ -1616,6 +1728,21 @@ thread_local! {
16161728 static INTRABC_DV: std::cell::Cell<Option<(i32, i32)>> = const { std::cell::Cell::new(None) };
16171729 /// How many blocks decoded `use_intrabc == 1` -- the gate's hit counter.
16181730 static INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1731+ /// The `tx_type` the last plane-0 [`read_plane`] actually coded, kept so
1732+ /// an intrabc block's chroma reads can inherit it (see
1733+ /// [`INTRABC_CHROMA_TX`]). Written on every luma read; only ever read
1734+ /// through that one arming site.
1735+ static LUMA_TX_TYPE: std::cell::Cell<TxType> = const { std::cell::Cell::new(TxType::DctDct) };
1736+ /// libaom `av1_get_tx_type` (`blockd.h:1350`): for `PLANE_TYPE_UV` it
1737+ /// branches on `is_inter_block(mbmi)` -- which `is_intrabc_block` also
1738+ /// satisfies (`blockd.h:373`) -- and takes the *colocated luma
1739+ /// transform's coded* `tx_type` (`mbmi->txk_type[...]`), never
1740+ /// `intra_mode_to_tx_type` of the chroma mode. `Some` only across an
1741+ /// intrabc block's two chroma [`read_plane`] calls; the type decides the
1742+ /// `TX_CLASS`, hence the scan order, `eob_multi_ctx` and every nz context
1743+ /// -- getting it wrong desyncs the chroma coefficients, it is not a
1744+ /// reconstruction-only detail.
1745+ static INTRABC_CHROMA_TX: std::cell::Cell<Option<TxType>> = const { std::cell::Cell::new(None) };
16191746 }
16201747
16211748 /// Whether this frame's header set `allow_intrabc` -- [`INTRABC_MI_GRID`] is
@@ -1642,6 +1769,22 @@ pub(crate) fn reset_rect_intrabc_reads() {
16421769 RECT_INTRABC_READS.with(|c| c.set(0));
16431770 }
16441771
1772+thread_local! {
1773+ /// Blocks that USED intrabc at an 8x8 LEAF (`decode_leaf8`) specifically
1774+ /// -- the shape lane-kf900 r7 fixed; [`INTRABC_HITS`] counts every shape.
1775+ static LEAF8_INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1776+}
1777+
1778+/// Current value of [`LEAF8_INTRABC_HITS`].
1779+pub(crate) fn leaf8_intrabc_hits() -> usize {
1780+ LEAF8_INTRABC_HITS.with(|c| c.get())
1781+}
1782+
1783+/// Zeroes [`LEAF8_INTRABC_HITS`] (gate tests call this before a decode).
1784+pub(crate) fn reset_leaf8_intrabc_hits() {
1785+ LEAF8_INTRABC_HITS.with(|c| c.set(0));
1786+}
1787+
16451788 /// Current value of [`INTRABC_HITS`].
16461789 pub(crate) fn intrabc_hits() -> usize {
16471790 INTRABC_HITS.with(|c| c.get())
@@ -2085,6 +2228,19 @@ thread_local! {
20852228 /// lane-sb128c r1: how many 128x128 `PARTITION_NONE` roots this INTER tile
20862229 /// path decoded as one whole block (its gate's own witness).
20872230 pub(crate) static INTER_SB128_NONE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2231+ /// 128x64 / 64x128 INTER blocks decoded at the 128 root (lane-sb128c r7).
2232+ pub(crate) static INTER_SB128_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2233+ pub(crate) static INTER_SB128_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2234+}
2235+
2236+/// Current value of [`INTER_SB128_HORZ_HITS`], for a gate's before/after delta.
2237+pub(crate) fn inter_sb128_horz_hits() -> usize {
2238+ INTER_SB128_HORZ_HITS.with(std::cell::Cell::get)
2239+}
2240+
2241+/// Current value of [`INTER_SB128_VERT_HITS`], for a gate's before/after delta.
2242+pub(crate) fn inter_sb128_vert_hits() -> usize {
2243+ INTER_SB128_VERT_HITS.with(std::cell::Cell::get)
20882244 }
20892245
20902246 /// Current value of [`INTER_SB128_NONE_HITS`], for a gate's before/after delta.
@@ -2171,6 +2327,37 @@ pub(crate) fn intra_rect_strip_in_inter_hits(class: usize) -> usize {
21712327 INTRA_RECT_IN_INTER_HITS.with(|c| c.get()[class])
21722328 }
21732329
2330+// lane-rect64port r1 (ported by hand from lane-intra64split 5ffbaf3): coded
2331+// (non-skip) 64-level HORZ/VERT intra strips whose luma transform is the
2332+// un-split TX_64X32/TX_32X64 -- the corner-cropped 32x32 coefficient read of
2333+// [`decode_rect_split`], the shape both 10-bit 3840x1608 film cuts stop on.
2334+// Split by ORIENTATION (index 0 = 64x32 wide / HORZ, 1 = 32x64 tall / VERT):
2335+// a single counter cannot tell an axis swap from a working arm
2336+// (class [[scan-weights-cross-axis]]), so the gate asserts both cells.
2337+thread_local! {
2338+ static RECT64_CORNER_TU_HITS: std::cell::Cell<[usize; 2]> =
2339+ const { std::cell::Cell::new([0; 2]) };
2340+}
2341+
2342+/// Current value of [`RECT64_CORNER_TU_HITS`] for one orientation
2343+/// (0 = 64x32, 1 = 32x64).
2344+pub(crate) fn rect64_corner_tu_hits(orient: usize) -> usize {
2345+ RECT64_CORNER_TU_HITS.with(|c| c.get()[orient])
2346+}
2347+
2348+// lane-intrasplit r1: intra HORZ/VERT strips inside an INTER frame whose luma
2349+// transform is SPLIT, bucketed by the read `tx_depth` (index 1 and 2; index 0
2350+// is never incremented) -- the gate's proof that the lifted path ran per depth.
2351+thread_local! {
2352+ static INTRA_RECT_IN_INTER_SPLIT_TX_HITS: std::cell::Cell<[usize; 3]> =
2353+ const { std::cell::Cell::new([0; 3]) };
2354+}
2355+
2356+/// Current value of [`INTRA_RECT_IN_INTER_SPLIT_TX_HITS`], indexed by tx depth.
2357+pub(crate) fn intra_rect_in_inter_split_tx_hits() -> [usize; 3] {
2358+ INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(std::cell::Cell::get)
2359+}
2360+
21742361 // lane-intra14 r1: how many intra-coded 1:4 strips decoded on the INTER
21752362 // block path, per shape -- [0] 64x16, [1] 16x64, [2] 32x8, [3] 8x32. Every
21762363 // one of them was the named refusal "an intra-coded 1:4 (or other non-2:1)
@@ -2456,6 +2643,22 @@ pub(crate) fn rect4_coeff_hits() -> usize {
24562643 RECT4_COEFF_HITS.with(|c| c.get())
24572644 }
24582645
2646+// lane-sbab r1: how many superblock-level (64x64) AB partitions fired IN AN
2647+// INTER frame, per arm, in `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`,
2648+// `_VERT_B` order (the intra-frame counterpart is `SB_AB_HITS`). Each arm is
2649+// two 32x32 inter squares plus one true 64x32/32x64 inter strip; the gate
2650+// asserts the arms it proves separately so a run whose RD only picked one
2651+// cannot pass as proof of the others.
2652+thread_local! {
2653+ static SB_AB_INTER_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) };
2654+}
2655+
2656+/// [`SB_AB_INTER_HITS`] per arm (HORZ_A, HORZ_B, VERT_A, VERT_B at 64x64 in an
2657+/// inter frame).
2658+pub fn sb_ab_inter_hits_by_arm() -> [usize; 4] {
2659+ SB_AB_INTER_HITS.with(std::cell::Cell::get)
2660+}
2661+
24592662 // lane-inter16ab r1: how many 16x16-level AB partitions fired IN AN INTER
24602663 // frame, per arm, in `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B`
24612664 // order (the intra-frame counterpart is `AB16_HITS`). Each arm is two 8x8
@@ -2927,6 +3130,26 @@ thread_local! {
29273130 // whose width or height is not a multiple of 8 is the only shape that
29283131 // produces one; the straddling-band gate arms assert it grew.
29293132 static CDEF_STRADDLE_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
3133+ // lane-cdefstrip r1: 8x8 CDEF units visited with an UNWRITTEN skip band
3134+ // (see `Neighbours::skip_written`).
3135+ static CDEF_UNWRITTEN_SKIP_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
3136+ // lane-cdefstrip r1: (d) skip RECTANGULAR blocks (every strip arm: 32x8,
3137+ // 8x32, 16x8, 32x16, 64x16, AB/1:4 pieces...) that wrote the CDEF skip
3138+ // band, and (e) 8x8 CDEF units whose four mi cells do NOT agree on skip --
3139+ // the shape libaom's `is_8x8_block_skip` (`cdef.c:29-38`) exists for: an
3140+ // 8-tall strip pair where only one half is skip must still be FILTERED.
3141+ static RECT_SKIP_BAND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
3142+ static CDEF_MIXED_SKIP_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
3143+}
3144+
3145+/// Current value of `RECT_SKIP_BAND_HITS`.
3146+pub fn rect_skip_band_hits() -> usize {
3147+ RECT_SKIP_BAND_HITS.with(|c| c.get())
3148+}
3149+
3150+/// Current value of `CDEF_MIXED_SKIP_UNITS`.
3151+pub fn cdef_mixed_skip_units() -> usize {
3152+ CDEF_MIXED_SKIP_UNITS.with(|c| c.get())
29303153 }
29313154
29323155 /// Current value of `CDEF_SKIPPED_UNITS`.
@@ -2934,6 +3157,12 @@ pub(crate) fn cdef_skipped_units() -> usize {
29343157 CDEF_SKIPPED_UNITS.with(|c| c.get())
29353158 }
29363159
3160+/// How many 8x8 CDEF units [`apply_cdef`] visited whose skip band no coded
3161+/// block wrote this frame -- a writer gap, always a defect (lane-cdefstrip r1).
3162+pub fn cdef_unwritten_skip_units() -> usize {
3163+ CDEF_UNWRITTEN_SKIP_UNITS.with(|c| c.get())
3164+}
3165+
29373166 /// Current value of `INTER8_SKIP_BAND_HITS`.
29383167 pub(crate) fn inter8_skip_band_hits() -> usize {
29393168 INTER8_SKIP_BAND_HITS.with(|c| c.get())
@@ -3706,11 +3935,17 @@ fn read_coeffs(
37063935 let (range, value) = dec.debug_state();
37073936 eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}");
37083937 }
3938+ let dbg_txbskip = if std::env::var_os("EC_TRACE_COEFF").is_some() {
3939+ coding.txb_skip[skip_ctx]
3940+ } else {
3941+ [0; 3]
3942+ };
37093943 let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1;
37103944 if std::env::var_os("EC_TRACE_COEFF").is_some() {
37113945 let (rng, _) = dec.debug_state();
37123946 eprintln!(
3713- "EC_COEFF_STEP tag=all_zero ctx={skip_ctx} all_zero={} rng={rng}",
3947+ "EC_COEFF_STEP tag=all_zero side={} ctx={skip_ctx} cdf={dbg_txbskip:?} all_zero={} rng={rng}",
3948+ coding.side,
37143949 all_zero as i32
37153950 );
37163951 }
@@ -3747,7 +3982,7 @@ fn read_coeffs(
37473982 let t = dec.symbol(tx_type_cdf);
37483983 if std::env::var_os("EC_TRACE_COEFF").is_some() {
37493984 let (rng, _) = dec.debug_state();
3750- eprintln!("EC_COEFF_STEP tag=tx_type rng={rng}");
3985+ eprintln!("EC_COEFF_STEP tag=tx_type len={len} rng={rng}");
37513986 }
37523987 if std::env::var_os("EC_AV1_EOBPT_CDF").is_some() {
37533988 let (range, value) = dec.debug_state();
@@ -3825,6 +4060,17 @@ fn read_coeffs(
38254060 let mut sent = 0;
38264061 loop {
38274062 let k = dec.symbol(&mut coding.br[ctx]) as i32;
4063+ if ec_trace_coeff {
4064+ // lane-leaf8tx r3: the `br` rung was missing from THIS
4065+ // path's trace, so the cross-decoder range ladder was
4066+ // blind to every base-range symbol and mis-reported the
4067+ // first divergence (class [[gate-blind-to-feature]]).
4068+ let (rng, _) = dec.debug_state();
4069+ let apos = col * side + row;
4070+ eprintln!(
4071+ "EC_COEFF_STEP tag=br c={scan_idx} pos={apos} ctx={ctx} k={k} rng={rng}"
4072+ );
4073+ }
38284074 if trace {
38294075 eprintln!(
38304076 "TRACE br scan_idx={scan_idx} pos={pos} row={row} col={col} ctx={ctx} value={k}"
@@ -4200,6 +4446,15 @@ struct Neighbours {
42004446 /// granularity by [`apply_cdef`] since `skip` is constant across every
42014447 /// mi cell one coded block covers.
42024448 skip_grid: Vec<bool>,
4449+ /// lane-cdefstrip r1 instrument: whether any coded block actually WROTE
4450+ /// [`Self::skip_grid`] at this mi cell during this frame. A fresh
4451+ /// `Neighbours` seeds `skip_grid` all-`false` ("not skip"), so a decode
4452+ /// arm that forgets [`Self::fill_skip_grid_rect`] silently makes
4453+ /// [`apply_cdef`] filter an 8x8 unit libaom's `is_8x8_block_skip`
4454+ /// (`cdef.c:29-38`) excludes -- exactly the lane-cdef defect, and
4455+ /// unobservable from the pixels alone. Counted by
4456+ /// [`cdef_unwritten_skip_units`].
4457+ skip_written: Vec<bool>,
42034458 /// Per-4x4-mi origin `(mi_row, mi_col)` of the coded (prediction) block
42044459 /// covering that cell -- spec 7.14.2's `isBlockEdge`/libaom `pu_edge`,
42054460 /// which re-enables the loop filter at a prediction boundary between two
@@ -4273,6 +4528,18 @@ impl Neighbours {
42734528 /// `cols`/`rows` are in [`SUB`] units; `mi_cols`/`mi_rows` are the frame's
42744529 /// true (unpadded) size in 4x4 mode-info units.
42754530 fn new(cols: usize, rows: usize, mi_cols: usize, mi_rows: usize) -> Self {
4531+ // lane-sb128c r7: a 128x64 block at the bottom frame edge records its
4532+ // neighbour state over the whole 64-row extent, past the frame's last
4533+ // mi row (mi_rows 198, block rows 192..208). libaom's own context
4534+ // buffers are superblock-aligned for exactly that reason
4535+ // (`av1_alloc_context_buffers` rounds to `MAX_MIB_SIZE`), so pad the
4536+ // side arrays to a superblock multiple and leave those cells unread --
4537+ // every availability check uses the true `mi_rows`/`mi_cols` below.
4538+ let sb_sub = (sb_mi_cur() as usize) / (SUB / MI);
4539+ let (cols, rows) = (
4540+ cols.next_multiple_of(sb_sub),
4541+ rows.next_multiple_of(sb_sub),
4542+ );
42764543 Self {
42774544 above: vec![[Neighbour::default(); 3]; cols * (SUB / MI)],
42784545 left: vec![[Neighbour::default(); 3]; rows * (SUB / MI)],
@@ -4313,6 +4580,7 @@ impl Neighbours {
43134580 mi_cols,
43144581 mi_rows,
43154582 skip_grid: vec![false; cols * (SUB / MI) * rows * (SUB / MI)],
4583+ skip_written: vec![false; cols * (SUB / MI) * rows * (SUB / MI)],
43164584 blk_org_grid: vec![[0u16; 2]; cols * (SUB / MI) * rows * (SUB / MI)],
43174585 skip_grid_cols_mi: cols * (SUB / MI),
43184586 tx_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)],
@@ -4321,14 +4589,14 @@ impl Neighbours {
43214589 uv_tx_h_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)],
43224590 ref_grid: vec![0i8; cols * (SUB / MI) * rows * (SUB / MI)],
43234591 delta_lf_grid: vec![[0i8; 4]; cols * (SUB / MI) * rows * (SUB / MI)],
4324- above_palette_size: vec![0; cols],
4325- left_palette_size: vec![0; rows],
4326- above_palette_colors: vec![[0u16; 8]; cols],
4327- left_palette_colors: vec![[0u16; 8]; rows],
4328- above_palette_uv_size: vec![0; cols],
4329- left_palette_uv_size: vec![0; rows],
4330- above_palette_uv_colors: vec![[0u16; 8]; cols],
4331- left_palette_uv_colors: vec![[0u16; 8]; rows],
4592+ above_palette_size: vec![0; cols * (SUB / MI)],
4593+ left_palette_size: vec![0; rows * (SUB / MI)],
4594+ above_palette_colors: vec![[0u16; 8]; cols * (SUB / MI)],
4595+ left_palette_colors: vec![[0u16; 8]; rows * (SUB / MI)],
4596+ above_palette_uv_size: vec![0; cols * (SUB / MI)],
4597+ left_palette_uv_size: vec![0; rows * (SUB / MI)],
4598+ above_palette_uv_colors: vec![[0u16; 8]; cols * (SUB / MI)],
4599+ left_palette_uv_colors: vec![[0u16; 8]; rows * (SUB / MI)],
43324600 tile_row0_mi: 0,
43334601 tile_col0_mi: 0,
43344602 }
@@ -4396,7 +4664,7 @@ impl Neighbours {
43964664 /// mirrors [`Self::record_rect`]'s loop shape, square-only (this lane's
43974665 /// call sites are all square blocks).
43984666 fn record_palette_y(&mut self, at: (usize, usize), side: usize, size: usize, colors: [u16; 8]) {
4399- self.record_palette_y_rect(at, side, side, size, colors);
4667+ self.record_palette_y_rect((at.0 * (SUB / MI), at.1 * (SUB / MI)), side, side, size, colors);
44004668 }
44014669
44024670 /// [`Self::record_palette_y`] with independent above (`w`)/left (`h`)
@@ -4405,29 +4673,30 @@ impl Neighbours {
44054673 /// differ.
44064674 fn record_palette_y_rect(
44074675 &mut self,
4408- at: (usize, usize),
4676+ mi: (usize, usize),
44094677 w: usize,
44104678 h: usize,
44114679 size: usize,
44124680 colors: [u16; 8],
44134681 ) {
4414- let (r, c) = at;
4415- // `.max(1)`: a below-16px span covers no whole SUB cell, so the plain
4416- // `w / SUB` loop was a NO-OP for every 16x8/8x16/8x8/4x4 leaf and the
4417- // next block read a long-dead palette out of the above/left arrays
4418- // (class [[cdf-row-held-constant]], lane-palette2 r8). libaom keeps
4419- // `palette_size` per 4px mi cell; corner-cut: our grid is 16px, so a
4420- // sub-16 leaf stamps its whole containing cell -- safe today because
4421- // every sub-16 leaf path refuses palette outright (so it can only
4422- // ever stamp `size == 0`, and its cell holds no palette sibling).
4423- // Upgrade path: widen the palette arrays to mi granularity.
4424- for cell in 0..(w / SUB).max(1) {
4425- self.above_palette_size[c + cell] = size;
4426- self.above_palette_colors[c + cell] = colors;
4682+ let (r, c) = mi;
4683+ // lane-kf900 r6: mi (4px) granularity, libaom's own -- `palette_size`
4684+ // lives per mi cell in `MB_MODE_INFO`, and `xd->left_mbmi` is the mi
4685+ // cell immediately left of the block, not its 16px [`SUB`] cell. The
4686+ // old SUB grid let a 16x8 strip pair share one slot, so the second
4687+ // strip of mi(0,8) read the FIRST strip's palette size and the colour
4688+ // cache came out one entry short (class [[context-read-from-one-cell]]).
4689+ for cell in 0..(w / MI).max(1) {
4690+ if let Some(e) = self.above_palette_size.get_mut(c + cell) {
4691+ *e = size;
4692+ self.above_palette_colors[c + cell] = colors;
4693+ }
44274694 }
4428- for cell in 0..(h / SUB).max(1) {
4429- self.left_palette_size[r + cell] = size;
4430- self.left_palette_colors[r + cell] = colors;
4695+ for cell in 0..(h / MI).max(1) {
4696+ if let Some(e) = self.left_palette_size.get_mut(r + cell) {
4697+ *e = size;
4698+ self.left_palette_colors[r + cell] = colors;
4699+ }
44314700 }
44324701 }
44334702
@@ -4445,7 +4714,7 @@ impl Neighbours {
44454714 /// palette block decoded as "no palette" and the tile desynced from
44464715 /// there (class [[cdf-row-held-constant]]).
44474716 fn palette_ctx_and_cache(&self, at: (usize, usize)) -> (usize, Vec<u16>) {
4448- self.palette_ctx_and_cache_mi(at, at.0 * (SUB / MI))
4717+ self.palette_ctx_and_cache_mi((at.0 * (SUB / MI), at.1 * (SUB / MI)))
44494718 }
44504719
44514720 /// [`Self::palette_ctx_and_cache`] with the block's REAL mi row, which a
@@ -4455,11 +4724,11 @@ impl Neighbours {
44554724 /// block's own PIXEL row), and strip 1 of a HORZ_4 sits 8 px into the
44564725 /// cell -- reading `at.0 % 4` there excludes strip 0 from the cache of
44574726 /// every strip in an SB's top cell row, which libaom does not do.
4458- fn palette_ctx_and_cache_mi(&self, at: (usize, usize), mi_r: usize) -> (usize, Vec<u16>) {
4459- let (r, c) = at;
4460- let above_ok = mi_r % 16 != 0;
4727+ fn palette_ctx_and_cache_mi(&self, mi: (usize, usize)) -> (usize, Vec<u16>) {
4728+ let (r, c) = mi;
4729+ let above_ok = r % 16 != 0;
44614730 // `xd->above_mbmi` exists for every row but the tile's own first.
4462- let above_is_palette = mi_r > self.tile_row0_mi && self.above_palette_size[c] > 0;
4731+ let above_is_palette = r > self.tile_row0_mi && self.above_palette_size[c] > 0;
44634732 let (above_n, above_colors) = if above_ok && self.above_palette_size[c] > 0 {
44644733 (self.above_palette_size[c], self.above_palette_colors[c])
44654734 } else {
@@ -4470,7 +4739,7 @@ impl Neighbours {
44704739 // (`left_available`), not the frame's -- without this guard a second
44714740 // tile column reads the previous tile's palette colours into its cache
44724741 // and its `palette_y_mode` ctx.
4473- let left_ok = c > self.tile_col0_mi / (SUB / MI);
4742+ let left_ok = c > self.tile_col0_mi;
44744743 let (left_n, left_colors) = if left_ok && self.left_palette_size[r] > 0 {
44754744 (self.left_palette_size[r], self.left_palette_colors[r])
44764745 } else {
@@ -4512,7 +4781,13 @@ impl Neighbours {
45124781 /// (U-channel) palette size/colours -- `size == 0` clears stale state the
45134782 /// same way (lane-palette2 r1).
45144783 fn record_palette_uv(&mut self, at: (usize, usize), side: usize, size: usize, colors: [u16; 8]) {
4515- self.record_palette_uv_rect(at, side, side, size, colors);
4784+ self.record_palette_uv_rect(
4785+ (at.0 * (SUB / MI), at.1 * (SUB / MI)),
4786+ side,
4787+ side,
4788+ size,
4789+ colors,
4790+ );
45164791 }
45174792
45184793 /// [`Self::record_palette_uv`] with independent above (`w`)/left (`h`)
@@ -4521,21 +4796,25 @@ impl Neighbours {
45214796 /// luma resolution regardless of which plane the recorded state is for).
45224797 fn record_palette_uv_rect(
45234798 &mut self,
4524- at: (usize, usize),
4799+ mi: (usize, usize),
45254800 w: usize,
45264801 h: usize,
45274802 size: usize,
45284803 colors: [u16; 8],
45294804 ) {
4530- let (r, c) = at;
4531- // See [`Self::record_palette_y_rect`] for the `.max(1)`.
4532- for cell in 0..(w / SUB).max(1) {
4533- self.above_palette_uv_size[c + cell] = size;
4534- self.above_palette_uv_colors[c + cell] = colors;
4805+ let (r, c) = mi;
4806+ // mi granularity, see [`Self::record_palette_y_rect`].
4807+ for cell in 0..(w / MI).max(1) {
4808+ if let Some(e) = self.above_palette_uv_size.get_mut(c + cell) {
4809+ *e = size;
4810+ self.above_palette_uv_colors[c + cell] = colors;
4811+ }
45354812 }
4536- for cell in 0..(h / SUB).max(1) {
4537- self.left_palette_uv_size[r + cell] = size;
4538- self.left_palette_uv_colors[r + cell] = colors;
4813+ for cell in 0..(h / MI).max(1) {
4814+ if let Some(e) = self.left_palette_uv_size.get_mut(r + cell) {
4815+ *e = size;
4816+ self.left_palette_uv_colors[r + cell] = colors;
4817+ }
45394818 }
45404819 }
45414820
@@ -4545,21 +4824,21 @@ impl Neighbours {
45454824 /// palette use, `read_palette_mode_info`'s `pmi->palette_size[0] > 0`),
45464825 /// so only the cache is wanted here.
45474826 fn palette_uv_cache(&self, at: (usize, usize)) -> Vec<u16> {
4548- self.palette_uv_cache_mi(at, at.0 * (SUB / MI))
4827+ self.palette_uv_cache_mi((at.0 * (SUB / MI), at.1 * (SUB / MI)))
45494828 }
45504829
45514830 /// [`Self::palette_uv_cache`] with the block's real mi row -- see
45524831 /// [`Self::palette_ctx_and_cache_mi`].
4553- fn palette_uv_cache_mi(&self, at: (usize, usize), mi_r: usize) -> Vec<u16> {
4554- let (r, c) = at;
4555- let above_ok = mi_r % 16 != 0;
4832+ fn palette_uv_cache_mi(&self, mi: (usize, usize)) -> Vec<u16> {
4833+ let (r, c) = mi;
4834+ let above_ok = r % 16 != 0;
45564835 let (above_n, above_colors) = if above_ok && self.above_palette_uv_size[c] > 0 {
45574836 (self.above_palette_uv_size[c], self.above_palette_uv_colors[c])
45584837 } else {
45594838 (0, [0u16; 8])
45604839 };
45614840 // Same tile-relative left availability as the luma cache above.
4562- let left_ok = c > self.tile_col0_mi / (SUB / MI);
4841+ let left_ok = c > self.tile_col0_mi;
45634842 let (left_n, left_colors) = if left_ok && self.left_palette_uv_size[r] > 0 {
45644843 (self.left_palette_uv_size[r], self.left_palette_uv_colors[r])
45654844 } else {
@@ -4725,12 +5004,18 @@ impl Neighbours {
47255004 /// [`Self::fill_skip_grid`] with independent row/col extents (lane-partitions r1).
47265005 fn fill_skip_grid_rect(&mut self, at_mi: (usize, usize), w_mi: usize, h_mi: usize, skip: bool) {
47275006 let (mi_r, mi_c) = at_mi;
5007+ if skip && w_mi != h_mi {
5008+ RECT_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1));
5009+ }
47285010 for rr in 0..h_mi {
47295011 for cc in 0..w_mi {
47305012 let idx = (mi_r + rr) * self.skip_grid_cols_mi + (mi_c + cc);
47315013 if let Some(cell) = self.skip_grid.get_mut(idx) {
47325014 *cell = skip;
47335015 }
5016+ if let Some(cell) = self.skip_written.get_mut(idx) {
5017+ *cell = true;
5018+ }
47345019 if let Some(org) = self.blk_org_grid.get_mut(idx) {
47355020 *org = [mi_r as u16, mi_c as u16];
47365021 }
@@ -5408,7 +5693,14 @@ impl Neighbours {
54085693 round_up_even(self.mi_cols),
54095694 ];
54105695 for cell in 0..h_mi {
5411- self.left[mi_r + cell] = std::array::from_fn(|plane| {
5696+ // lane-sb128c r7: a 128x64 at the bottom frame edge names mi rows
5697+ // past the padded side arrays (mi_rows 198, block rows 192..208);
5698+ // libaom's own arrays are superblock-sized, so those cells simply
5699+ // have no reader. Same guard the `left_side_mi` loop above uses.
5700+ let Some(left_slot) = self.left.get_mut(mi_r + cell) else {
5701+ break;
5702+ };
5703+ *left_slot = std::array::from_fn(|plane| {
54125704 if cell < h_mi.min(bound_h[plane].saturating_sub(mi_r)) {
54135705 states[plane]
54145706 } else {
@@ -5417,7 +5709,10 @@ impl Neighbours {
54175709 });
54185710 }
54195711 for cell in 0..w_mi {
5420- self.above[mi_c + cell] = std::array::from_fn(|plane| {
5712+ let Some(above_slot) = self.above.get_mut(mi_c + cell) else {
5713+ break;
5714+ };
5715+ *above_slot = std::array::from_fn(|plane| {
54215716 if cell < w_mi.min(bound_w[plane].saturating_sub(mi_c)) {
54225717 states[plane]
54235718 } else {
@@ -6078,8 +6373,6 @@ fn read_intra_mode_rect(
60786373 // the one point every rect caller routes through, so no call site can
60796374 // offer the 14-symbol CFL alphabet on a 64-axis block (class
60806375 // wrong-alphabet-same-value: same value, wrong interval, silent desync).
6081- // This funnel covers the lane-intra14 intra-1:4-in-inter callers too: they
6082- // reach their chroma through this same reader, never a private CFL read.
60836376 let cfl = if cfl && bw.max(bh) > 32 {
60846377 NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1));
60856378 false
@@ -6111,8 +6404,6 @@ fn read_intra_mode_rect(
61116404 maybe_read_delta_q(dec, cdfs, mi_r, mi_c, false, skip);
61126405 maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, false, skip);
61136406 istep!("dq", 0);
6114- skip
6115- };
61166407 // `read_intrabc_info` (spec 5.11.13, libaom `decodemv.c:892`, right after
61176408 // `skip`/`segment_id`/`cdef`/`delta_q` and before `mbmi->mode`): the
61186409 // `use_intrabc` symbol is read for EVERY intra block of an `allow_intrabc`
@@ -6134,6 +6425,8 @@ fn read_intra_mode_rect(
61346425 ));
61356426 }
61366427 }
6428+ skip
6429+ };
61376430 // libaom `read_intra_block_mode_info` (decodemv.c:1189) vs the key
61386431 // frame's `read_intra_frame_mode_info` (decodemv.c:1065 `read_intra_mode`
61396432 // off `kf_y_mode_cdf[above][left]`).
@@ -6286,40 +6579,43 @@ fn read_intra_mode_rect(
62866579 ))
62876580 }
62886581
6289-/// Stamps a 1:4 strip's palette state into the coarse above/left arrays.
6290-/// `av1_get_palette_cache` reads `xd->above_mbmi`/`xd->left_mbmi`, and inside
6291-/// a HORZ_4 (VERT_4) the next strip's ABOVE (LEFT) neighbour is this strip
6292-/// while its LEFT (ABOVE) neighbour is still the parent block's. The coarse
6293-/// [`SUB`]-cell arrays alias all four strips onto one entry, so writing BOTH
6294-/// axes after every strip would hand strip i+1 this strip's colours on the
6295-/// wrong axis too -- a wrong cache costs the same bits, so the tile stays in
6296-/// sync and only the pixels are wrong (class [[cdf-row-held-constant]]).
6297-/// Only the split axis is written until the closing strip, which stamps both
6298-/// for whatever follows the parent block.
6582+/// Stamps a 1:4 strip's palette state into the mi-granular above/left arrays,
6583+/// at the strip's REAL mi position. `av1_get_palette_cache` reads
6584+/// `xd->above_mbmi`/`xd->left_mbmi`, i.e. the mi cell above/left of the
6585+/// block, so each strip owns its own rows and columns and no aliasing rule
6586+/// is needed (lane-kf900 r6).
62996587 #[allow(clippy::too_many_arguments)]
63006588 fn record_strip_palette(
63016589 n: &mut Neighbours,
6302- at: (usize, usize),
6590+ mi: (usize, usize),
63036591 bw: usize,
63046592 bh: usize,
63056593 y_size: usize,
63066594 y_colors: [u16; 8],
63076595 uv_size: usize,
63086596 uv_colors: [u16; 8],
6309- last: bool,
63106597 ) {
6311- let (r, c) = at;
6312- let horz = bw > bh;
6313- if horz || last {
6314- for cell in 0..(bw / SUB).max(1) {
6315- n.above_palette_size[c + cell] = y_size;
6316- n.above_palette_colors[c + cell] = y_colors;
6317- n.above_palette_uv_size[c + cell] = uv_size;
6318- n.above_palette_uv_colors[c + cell] = uv_colors;
6598+ let (r, c) = mi;
6599+ // lane-kf900 r6: the palette side bands are mi-granular now, so a strip
6600+ // writes its OWN span on BOTH axes -- the old `last` split-axis rule only
6601+ // existed because the 16px [`SUB`] cell held one slot for all the strips
6602+ // of a HORZ_4/VERT_4 and leaf 0 zeroing the other axis threw away the
6603+ // real neighbour leaf 1 reads.
6604+ {
6605+ for cell in 0..(bw / MI).max(1) {
6606+ if let Some(e) = n.above_palette_size.get_mut(c + cell) {
6607+ *e = y_size;
6608+ n.above_palette_colors[c + cell] = y_colors;
6609+ n.above_palette_uv_size[c + cell] = uv_size;
6610+ n.above_palette_uv_colors[c + cell] = uv_colors;
6611+ }
63196612 }
63206613 }
6321- if !horz || last {
6322- for cell in 0..(bh / SUB).max(1) {
6614+ {
6615+ for cell in 0..(bh / MI).max(1) {
6616+ if n.left_palette_size.get(r + cell).is_none() {
6617+ break;
6618+ }
63236619 n.left_palette_size[r + cell] = y_size;
63246620 n.left_palette_colors[r + cell] = y_colors;
63256621 n.left_palette_uv_size[r + cell] = uv_size;
@@ -6339,6 +6635,12 @@ fn tx_size_context_rect(
63396635 own_w: usize,
63406636 own_h: usize,
63416637 ) -> usize {
6638+ // `get_tx_size_context` compares against `max_txsize_rect_lookup[bsize]`,
6639+ // not the block's own side: no transform is wider or taller than 64, so a
6640+ // block with a 128 side resolves against 64 (the square path already caps
6641+ // this way, lane-sb128b r1). Without the cap the 64x128 half of a 128-root
6642+ // VERT reads the tx-depth symbol off row 0 where libaom uses row 1.
6643+ let (own_w, own_h) = (own_w.min(64), own_h.min(64));
63426644 let above = mi_r > n.tile_row0_mi && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_w;
63436645 let left = mi_c > n.tile_col0_mi && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_h;
63446646 if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {
@@ -6542,6 +6844,21 @@ fn decode_rect_split(
65426844 )),
65436845 (32, 16) => Some((TxbSet::LumaRect32x16, &SCAN_32X16[..])),
65446846 (16, 32) => Some((TxbSet::LumaRect32x16, &SCAN_16X32[..])),
6847+ // lane-rect64port r1: the un-split TX_64X32/TX_32X64 of a 64-level
6848+ // strip, read through the `luma_64corner` arm below instead of a rect
6849+ // table -- a 64-length axis codes only its low 32 coefficients
6850+ // (`av1_get_max_eob` / the zero-out of `av1_get_adjusted_tx_size`), so
6851+ // the coded unit is the 32x32 corner [`decode_block_rect64`]'s own
6852+ // depth-0 arm already reads on the key-frame path.
6853+ //
6854+ // NO WITNESS YET (r1, measured): on both 10-bit 3840x1608 film cuts
6855+ // this arm fires (16x 64x32 + 2x 32x64 / 2x 32x64) but the SAME frame
6856+ // then stops at "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs
6857+ // rectangular residual coding", so no frame containing it ever
6858+ // finishes and no pixel comparison is possible. A refusal is lifted
6859+ // only with a gate (COMMON charter), so the arm stays behind
6860+ // `EC_RECT64_SPLIT=1` and the refusal below is still the default.
6861+ (64, 32) | (32, 64) if std::env::var_os("EC_RECT64_SPLIT").is_some() => None,
65456862 _ => {
65466863 return Err(unsupported(format!(
65476864 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma \
@@ -6549,6 +6866,8 @@ fn decode_rect_split(
65496866 )))
65506867 }
65516868 };
6869+ // The `None` above that is NOT the square arm.
6870+ let luma_64corner = tx_w != tx_h;
65526871 // lane-rectsplitx r1, MEASURED: the SQUARE-unit walk below is pixel-exact
65536872 // on a real stream (the pinned 16x8 filter-intra fixture decodes its whole
65546873 // frame exactly, two sub-16 split strips in it), but the RECT-unit arm --
@@ -6618,6 +6937,64 @@ fn decode_rect_split(
66186937 m.smooth_neighbor,
66196938 );
66206939 neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &zero_tu);
6940+ } else if luma_64corner && luma_rect.is_none() {
6941+ // The un-split 64-level luma transform: `read_coeffs` on the
6942+ // 32x32 CDF set [`TxbSet::Luma64`] with `default_scan(TX32)`
6943+ // and the real rect shape passed through for
6944+ // `av1_nz_map_ctx_offset` -- byte for byte
6945+ // [`decode_block_rect64`]'s depth-0 read, which the key-frame
6946+ // 64-level strip gate already proves. `tx_type` is not coded
6947+ // (`av1_get_ext_tx_set_type` resolves EXT_TX_SET_DCTONLY once
6948+ // the square-up size is TX_64X64), and this unit covers its
6949+ // whole block, so `get_txb_ctx` gives txb_skip ctx 0 flat.
6950+ if std::env::var_os("EC_RECT64TU").is_some() {
6951+ eprintln!("EC_RECT64TU mi={tu_mi:?} tx={tx_w}x{tx_h} mode={}", m.mode);
6952+ }
6953+ RECT64_CORNER_TU_HITS.with(|c| {
6954+ let mut v = c.get();
6955+ v[usize::from(tx_h > tx_w)] += 1;
6956+ c.set(v);
6957+ });
6958+ let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0];
6959+ let mut coding = cdfs.txb(TxbSet::Luma64, fi_tx_row(m.mode, m.filter_intra));
6960+ let (corner, tu_tx_type) = read_coeffs(
6961+ dec,
6962+ &mut coding,
6963+ &default_scan(TX32),
6964+ 0,
6965+ dc_sign_ctx(tu_around.2),
6966+ TxType::DctDct,
6967+ Some((tx_w, tx_h)),
6968+ )?;
6969+ let (cw, ch) = (tx_w.min(TX32), tx_h.min(TX32));
6970+ let mut tu_grid = vec![0i32; tx_w * tx_h];
6971+ for row in 0..ch {
6972+ tu_grid[row * tx_w..][..cw].copy_from_slice(&corner[row * cw..][..cw]);
6973+ }
6974+ let residual = dequant_and_inverse_typed_wh(
6975+ &tu_grid,
6976+ tx_w,
6977+ tx_h,
6978+ crate::decode::bit_depth(),
6979+ block_q_idx(),
6980+ plane_q_delta(0).0,
6981+ plane_q_delta(0).1,
6982+ tu_tx_type,
6983+ );
6984+ y.reconstruct_rect(
6985+ tu_px,
6986+ tu_py,
6987+ tx_w,
6988+ tx_h,
6989+ m.mode,
6990+ m.angle_delta_y,
6991+ tu_reach,
6992+ &residual,
6993+ None,
6994+ m.filter_intra,
6995+ m.smooth_neighbor,
6996+ );
6997+ neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid);
66216998 } else if let Some((rect_set, rect_scan)) = luma_rect {
66226999 // The rect-unit twin of the square arm below: same contexts,
66237000 // same order, through the rect coefficient reader. The
@@ -7028,7 +7405,9 @@ fn decode_intra_rect_in_inter(
70287405 }
70297406 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c);
70307407 let depth = if TX_SELECT_INTER.with(std::cell::Cell::get) {
7031- let ctx = tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh);
7408+ // The INTER frame's own `TXFM_CONTEXT` bands, not the key frame's
7409+ // deblock-grid approximation -- [`tx_size_context_txfm_rect`].
7410+ let ctx = tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw.min(64), bh.min(64));
70327411 match tx_cat {
70337412 1 => dec.symbol(&mut cdfs.tx_size_cat1[ctx]),
70347413 2 => dec.symbol(&mut cdfs.tx_size_cat2[ctx]),
@@ -7039,17 +7418,32 @@ fn decode_intra_rect_in_inter(
70397418 };
70407419 if depth != 0 {
70417420 TX_DEPTH_HITS.with(|h| h.set(h.get() + 1));
7042- // merge b51719f+lane-intrarect (class merge-cross-product-defect):
7043- // main's 10-bit `split_transform_intra_block` gate reaches this arm
7044- // with a nonzero tx depth, and the split rect-TU walk mis-decodes it
7045- // (2340 luma samples off at seed 51; refusing here restores that gate
7046- // while the depth-0 strip the lane proved keeps decoding). The lane's
7047- // own gate never exercised a split strip.
7048- return Err(unsupported(
7049- "a split (nonzero tx_depth) transform on an intra HORZ/VERT strip in an inter frame",
7050- ));
7421+ // lane-intrasplit r1: a split intra strip in an inter frame walks the
7422+ // key frame's own per-TU path ([`decode_rect_split`] below); what was
7423+ // wrong when this refusal was written was the depth SYMBOL, not the walk.
7424+ INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(|h| {
7425+ let mut v = h.get();
7426+ v[depth.min(2)] += 1;
7427+ h.set(v);
7428+ });
7429+ }
7430+ // lane-intrasplit r3: print EVERY intra strip with its depth, not only the
7431+ // split ones -- a `depth=0`-only stream is a witness gap in the SOURCE, and
7432+ // the two are indistinguishable when the diagnostic fires on splits alone.
7433+ if std::env::var_os("EC_SPLITSTRIP").is_some() {
7434+ eprintln!("EC_SPLITSTRIP mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} depth={depth}");
70517435 }
70527436 let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth);
7437+ // lane-inter16ab r8: libaom runs `set_txfm_ctxs(tx_size, n4_w, n4_h,
7438+ // skip && is_inter, xd)` (decodeframe.c `decode_block`) for EVERY block
7439+ // of an inter frame, intra ones included -- with the skip term 0 it
7440+ // memsets `above_txfm_context` to `tx_size_wide` over the block's width
7441+ // and `left_txfm_context` to `tx_size_high` over its height. This strip
7442+ // wrote neither, so the next block's var-tx `txfm_partition` context read
7443+ // a stale band: on a 192x128 8-bit stream the 16x8 intra strip at
7444+ // mi(14,0) left 8 where libaom has 16, giving ctx 13 instead of 12 at
7445+ // mi(16,0) and desyncing the tile at that symbol.
7446+ txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh));
70537447 let modes = RectStripModes {
70547448 skip,
70557449 mode,
@@ -7081,6 +7475,22 @@ fn decode_intra_rect_in_inter(
70817475 base_q_idx,
70827476 REDUCED_TX_SET_INTER.with(std::cell::Cell::get),
70837477 )?;
7478+ // `set_txfm_ctxs` (libaom `decodeframe.c:1078`, at the end of
7479+ // `decode_token_recon_block`): an INTRA block records its TRANSFORM size in
7480+ // both `TXFM_CONTEXT` bands -- the above row over the block's width, the
7481+ // left column over its height. This arm wrote neither before lane-intrasplit
7482+ // r1, so every later block in the frame read a stale `tx_size`/`txfm_split`
7483+ // context across the strip's footprint.
7484+ for i in 0..bw / MI {
7485+ if let Some(cell) = neighbours.above_txfm.get_mut(mi_c + i) {
7486+ *cell = tx_w as u8;
7487+ }
7488+ }
7489+ for i in 0..bh / MI {
7490+ if let Some(cell) = neighbours.left_txfm.get_mut(mi_r + i) {
7491+ *cell = tx_h as u8;
7492+ }
7493+ }
70847494 let class = match bw.max(bh) {
70857495 64 => 0,
70867496 32 => 1,
@@ -7241,10 +7651,10 @@ fn decode_block_rect(
72417651 // wrong VALUE -- same bit count, so the entropy stream stayed in sync
72427652 // and only those pixels were wrong (lane-palette2 r10).
72437653 let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
7244- neighbours.record_palette_y_rect(at, bw, bh, py_size, py_colors);
7654+ neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, py_size, py_colors);
72457655 let (puv_size, puv_colors) =
72467656 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
7247- neighbours.record_palette_uv_rect(at, bw, bh, puv_size, puv_colors);
7657+ neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors);
72487658 RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1));
72497659 return Ok(());
72507660 }
@@ -7509,10 +7919,10 @@ fn decode_block_rect(
75097919 }
75107920 }
75117921 let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
7512- neighbours.record_palette_y_rect(at, bw, bh, py_size, py_colors);
7922+ neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, py_size, py_colors);
75137923 let (puv_size, puv_colors) =
75147924 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
7515- neighbours.record_palette_uv_rect(at, bw, bh, puv_size, puv_colors);
7925+ neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors);
75167926 neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip);
75177927 neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0);
75187928 RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1));
@@ -7598,12 +8008,13 @@ fn decode_leaf_rect(
75988008 // a palette narrows the wrong interval and desyncs the tile even when the
75998009 // decoded bit is the same. The cell is the 16px-SUB cell containing the
76008010 // leaf (the palette neighbour arrays have no finer granularity).
7601- let pal_at = (leaf_mi.0 / (SUB / MI), leaf_mi.1 / (SUB / MI));
7602- // lane-kf900 r4: the leaf's REAL mi row -- the second leaf of a 16x8 pair
7603- // sits 8 px into the cell, so the cache's superblock-top-row exclusion
7604- // must not be read off the cell (see [`Neighbours::palette_ctx_and_cache_mi`]).
7605- let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at, leaf_mi.0);
7606- let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at, leaf_mi.0);
8011+ // lane-kf900 r6: the leaf's REAL mi position -- the second leaf of a 16x8
8012+ // pair sits 8 px into the 16px cell, and both the cache's superblock-top-row
8013+ // exclusion and the neighbour palette lookup itself are mi-granular
8014+ // (see [`Neighbours::palette_ctx_and_cache_mi`]).
8015+ let pal_at = leaf_mi;
8016+ let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at);
8017+ let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at);
76078018 let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) =
76088019 read_intra_mode_rect(
76098020 dec,
@@ -7641,12 +8052,6 @@ fn decode_leaf_rect(
76418052 palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
76428053 let (pal_uv_size, pal_uv_colors) =
76438054 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
7644- // The closing leaf of the pair -- see [`record_strip_palette`].
7645- let pal_last = if bw > bh {
7646- leaf_mi.0 % 4 == 2
7647- } else {
7648- leaf_mi.1 % 4 == 2
7649- };
76508055 if std::env::var_os("EC_AV1_RECTX_TRACE").is_some() {
76518056 eprintln!(" skip={skip} mode={mode} angle_delta_y={angle_delta_y} uv_mode={uv_mode}");
76528057 }
@@ -7729,7 +8134,6 @@ fn decode_leaf_rect(
77298134 )?;
77308135 record_strip_palette(
77318136 neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,
7732- pal_last,
77338137 );
77348138 return Ok(mode);
77358139 }
@@ -7853,7 +8257,6 @@ fn decode_leaf_rect(
78538257 // real left neighbour leaf 1 reads (lane-kf900 r4).
78548258 record_strip_palette(
78558259 neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,
7856- pal_last,
78578260 );
78588261 // A rect leaf spans mi_w x mi_h, so its mode reaches several columns and
78598262 // rows -- record the whole span, not one cell.
@@ -7923,9 +8326,9 @@ fn decode_block_rect4(
79238326 // `palette_colors_y` cache hit off an EMPTY cache -- right symbol count,
79248327 // wrong interval, so a screen-content tile desynced at the first strip
79258328 // whose neighbour used a palette (class [[cdf-row-held-constant]]).
7926- let pal_at = (mi_r / (SUB / MI), mi_c / (SUB / MI));
7927- let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at, mi_r);
7928- let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at, mi_r);
8329+ let pal_at = (mi_r, mi_c);
8330+ let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at);
8331+ let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at);
79298332 let (
79308333 skip,
79318334 mode,
@@ -7969,10 +8372,6 @@ fn decode_block_rect4(
79698372 p.map.iter().map(|&i| p.v_colors[i as usize]).collect(),
79708373 )
79718374 });
7972- // `last`: strip 3 of the parent 32x32's HORZ_4 (VERT_4), the only one
7973- // whose colours a block outside the parent sees -- see
7974- // [`record_strip_palette`].
7975- let pal_last = if bw > bh { mi_r % 8 == 6 } else { mi_c % 8 == 6 };
79768375 let (pal_y_size, pal_y_colors) =
79778376 palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
79788377 let (pal_uv_size, pal_uv_colors) =
@@ -8060,7 +8459,7 @@ fn decode_block_rect4(
80608459 )?;
80618460 record_strip_palette(
80628461 neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size,
8063- pal_uv_colors, pal_last,
8462+ pal_uv_colors,
80648463 );
80658464 if bw > bh {
80668465 RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));
@@ -8213,7 +8612,7 @@ fn decode_block_rect4(
82138612 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0);
82148613 record_strip_palette(
82158614 neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size,
8216- pal_uv_colors, pal_last,
8615+ pal_uv_colors,
82178616 );
82188617 if bw > bh {
82198618 RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));
@@ -8276,7 +8675,6 @@ fn decode_block_rect4(
82768675 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0);
82778676 record_strip_palette(
82788677 neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,
8279- pal_last,
82808678 );
82818679 if bw > bh {
82828680 RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));
@@ -8360,9 +8758,8 @@ fn decode_rect4_16(
83608758 // lane-kf900 r4: the strip's real palette ctx + colour cache (see
83618759 // [`decode_block_rect4`]); `None`/`&[]` here read `palette_y_mode`
83628760 // off CDF row 0 and every cache hit off an empty cache.
8363- let (palette_ctx, palette_cache) =
8364- neighbours.palette_ctx_and_cache_mi(at16, lmi.0);
8365- let palette_uv_cache = neighbours.palette_uv_cache_mi(at16, lmi.0);
8761+ let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(lmi);
8762+ let palette_uv_cache = neighbours.palette_uv_cache_mi(lmi);
83668763 let (
83678764 skip,
83688765 mode,
@@ -8771,8 +9168,7 @@ fn decode_rect4_16(
87719168 let (pal_uv_size, pal_uv_colors) =
87729169 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
87739170 record_strip_palette(
8774- neighbours, at16, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,
8775- i == 3,
9171+ neighbours, lmi, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,
87769172 );
87779173 last_mode = mode;
87789174 prev = Some((lmi, mode));
@@ -8860,6 +9256,14 @@ fn decode_block_rect64(
88609256 // needs the plain, uncropped rect reader [`decode_block_rect`] already
88619257 // has, not this one's truncation. `skip` (no residual at all) is
88629258 // still supported below (lane-palette2 r4).
9259+ //
9260+ // lane-pal8 r1 MEASURED the lift and it is NOT free: dropping this
9261+ // refusal decodes `testsrc2` 128x128 10-bit cq55 `--enable-palette=1
9262+ // --min-partition-size=8 --tile-columns=1` with a whole-frame pixel
9263+ // mismatch (the arm the gate below counts). Something in this shape's
9264+ // palette prediction or its corner-cropped residual is wrong, and the
9265+ // refusal stays until that is found -- it is counted, never skipped.
9266+ PALETTE_SB_STRIP_HITS.with(|c| c.set(c.get() + 1));
88639267 return Err(unsupported(
88649268 "a palette block with a real transform on a superblock-level HORZ/VERT \
88659269 strip (corner-cropped luma coefficients not ported for palette)",
@@ -8967,10 +9371,10 @@ fn decode_block_rect64(
89679371 // split-tx superblock strip would otherwise leave the above/left
89689372 // palette arrays holding a dead block's colours.
89699373 let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
8970- neighbours.record_palette_y_rect(at, bw, bh, py_size, py_colors);
9374+ neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, py_size, py_colors);
89719375 let (puv_size, puv_colors) =
89729376 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
8973- neighbours.record_palette_uv_rect(at, bw, bh, puv_size, puv_colors);
9377+ neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors);
89749378 RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1));
89759379 return Ok(());
89769380 }
@@ -9282,10 +9686,10 @@ fn decode_block_rect64(
92829686 RECT_COEFF_HITS.with(|c| c.set(c.get() + 1));
92839687 }
92849688 let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
9285- neighbours.record_palette_y_rect(at, bw, bh, py_size, py_colors);
9689+ neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, py_size, py_colors);
92869690 let (puv_size, puv_colors) =
92879691 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
9288- neighbours.record_palette_uv_rect(at, bw, bh, puv_size, puv_colors);
9692+ neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors);
92899693 neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip);
92909694 neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0);
92919695 SB_RECT_HITS.with(|c| c.set(c.get() + 1));
@@ -9728,6 +10132,15 @@ fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 {
972810132 /// lane-hgkf r2: 16-bit cropped stage dump, the high-bitdepth twin of
972910133 /// [`dump_stage`] (whose `as u8` truncation hides |delta| <= 2 defects) --
973010134 /// matches aomdec's own `ec_dump16` rung byte for byte (crop dims, u16 LE).
10135+/// lane-mc64 r1: the decode-order index the stage dumps below key their file
10136+/// name on. `PREFILT_PICTURE_IDX` is bumped once per frame just BEFORE the
10137+/// deblock/CDEF stages run, so the frame being dumped here is `idx - 1` --
10138+/// without this every frame overwrote `.f0` and a per-frame bisection silently
10139+/// compared the LAST decoded frame (ledger, class stale-output-faked-measurement).
10140+fn stage_dump_idx() -> usize {
10141+ PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst).saturating_sub(1)
10142+}
10143+
973110144 fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) {
973210145 use std::io::Write;
973310146 // lane-sbrect10 r2 / lane-cdef r1 (one shared helper): index the dump by
@@ -9979,7 +10392,16 @@ impl PlaneBuf {
997910392 );
998010393 }
998110394 for row in 0..bh {
10395+ // Same bottom/right frame-edge clip as [`Self::reconstruct`]'s
10396+ // (lane-sb128c r8) -- a 64x128 block at the right edge of a frame
10397+ // whose padded width is not superblock aligned hangs past it.
10398+ if y + row >= self.height {
10399+ break;
10400+ }
998210401 for col in 0..bw {
10402+ if x + col >= self.width {
10403+ break;
10404+ }
998310405 let idx = row * bw + col;
998410406 let mut base = i32::from(prediction[idx]);
998510407 if let Some((alpha_q3, ac_q3)) = cfl {
@@ -10072,7 +10494,21 @@ impl PlaneBuf {
1007210494 );
1007310495 }
1007410496 for row in 0..side {
10497+ // lane-sb128c r8: libaom's frame buffer is superblock
10498+ // aligned; ours is padded to 32 (`block_grid`), so a 64x64
10499+ // transform unit of a 128x64 block at the BOTTOM frame edge
10500+ // can hang past the last padded row (1920x792: a unit at
10501+ // y=768 wants 832 rows of an 800-row buffer, which panicked
10502+ // the film's key frames). Those samples are outside the
10503+ // frame: never output, and no block below ever references
10504+ // them.
10505+ if y + row >= self.height {
10506+ break;
10507+ }
1007510508 for col in 0..side {
10509+ if x + col >= self.width {
10510+ break;
10511+ }
1007610512 let idx = row * side + col;
1007710513 let mut base = i32::from(prediction[idx]);
1007810514 if let Some((alpha_q3, ac_q3)) = cfl {
@@ -10152,6 +10588,13 @@ fn read_plane(
1015210588 // narrows there — only `Chroma32` and up do).
1015310589 let default_tx_type = if plane_idx == 0 || side >= 32 {
1015410590 TxType::DctDct
10591+ } else if let Some(inherited) = INTRABC_CHROMA_TX.with(std::cell::Cell::get) {
10592+ // See [`INTRABC_CHROMA_TX`]: an intrabc block is an inter block for
10593+ // `av1_get_tx_type`, so chroma inherits luma's coded type (the
10594+ // `side >= 32` arm above is already libaom's `EXT_TX_SET_DCTONLY`
10595+ // clamp at `tx_size_sqr_up >= TX_32X32`, matching
10596+ // [`read_inter_plane`]'s own `side < 32` guard).
10597+ inherited
1015510598 } else {
1015610599 default_intra_tx_type(predict_mode as u8)
1015710600 };
@@ -10165,6 +10608,9 @@ fn read_plane(
1016510608 None,
1016610609 )?;
1016710610 note_chroma_class1(plane_idx, tx_type);
10611+ if plane_idx == 0 {
10612+ LUMA_TX_TYPE.with(|c| c.set(tx_type));
10613+ }
1016810614 // A 64x64 luma block's transform covers the whole 64x64 area, but only its
1016910615 // top-left 32x32 of frequencies are coded (spec 5.11.40); the rest of the
1017010616 // dequantized grid stays zero, which `inverse_transform_2d`'s own `< 32`
@@ -10565,6 +11011,12 @@ fn decode_block(
1056511011 smooth_neighbor,
1056611012 )?;
1056711013 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
11014+ // Armed for exactly this block's two chroma reads (see
11015+ // [`INTRABC_CHROMA_TX`]); the luma call above just set
11016+ // [`LUMA_TX_TYPE`] to the type it coded.
11017+ if intrabc_dv.is_some() {
11018+ INTRABC_CHROMA_TX.with(|c| c.set(Some(LUMA_TX_TYPE.with(std::cell::Cell::get))));
11019+ }
1056811020 if let Some((ub, _)) = &palette_uv_bufs {
1056911021 set_palette_pred(ub.clone());
1057011022 }
@@ -10621,6 +11073,7 @@ fn decode_block(
1062111073 None,
1062211074 smooth_neighbor_uv,
1062311075 )?;
11076+ INTRABC_CHROMA_TX.with(|c| c.set(None));
1062411077 neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]);
1062511078 } else {
1062611079 // Several luma transform units, raster order (spec
@@ -10833,88 +11286,389 @@ fn decode_block(
1083311286 Ok(())
1083411287 }
1083511288
10836-/// Decodes one 8x8 leaf of a straddling 16x16 block (lane-av1-rect), mirroring
10837-/// [`crate::tile::write_leaf8`]: its intra-mode context comes from the
10838-/// *enclosing* 16x16 slot's `above_mode`/`left_mode` (`outer_at`, [`SUB`]-grid),
10839-/// overridden on whichever axis `prev_leaf` sits along -- the previous leaf's
10840-/// just-decoded mode, not the enclosing slot's stale one, is the true
10841-/// neighbour there. `leaf_mi` is this leaf's own position in 4x4 mode-info
10842-/// units, which is what its coefficient context (finer than [`SUB`]) is read
10843-/// at. Returns the mode this leaf decoded, for the caller's own
10844-/// `prev_leaf`/final mode-writeback bookkeeping.
10845-#[allow(clippy::too_many_arguments)]
10846-/// The coarse 16x16 `above_mode`/`left_mode` cells a four-way SPLIT of one
10847-/// 16x16 parent leaves behind (lane-rectx r3). The next block DOWN reads
10848-/// `above_mode[col]`, and its true above neighbour is the mi directly above
10849-/// its own top-left corner -- the parent's BOTTOM-LEFT leaf, not the last one
10850-/// decoded; the next block RIGHT reads `left_mode[row]`, whose true left
10851-/// neighbour is the parent's TOP-RIGHT leaf. Writing the z-order last leaf
10852-/// (bottom-right) into both, as this path did, is right only when all four
10853-/// leaves happen to share a mode. `done` may be short at the true frame edge
10854-/// (the straddle caller filters positions off the frame), so each side falls
10855-/// back to the last leaf actually decoded.
10856-fn write_back_split_modes(
10857- neighbours: &mut Neighbours,
10858- done: &[((usize, usize), usize)],
10859- parent_mi: (usize, usize),
10860- slot: (usize, usize),
10861-) {
10862- let (sr, sc) = slot;
10863- let Some(&(_, last)) = done.last() else {
10864- return;
10865- };
10866- let find = |mi: (usize, usize)| done.iter().find(|&&(at, _)| at == mi).map(|&(_, m)| m);
10867- neighbours.above_mode[sc] = find((parent_mi.0 + 2, parent_mi.1)).unwrap_or(last);
10868- neighbours.left_mode[sr] = find((parent_mi.0, parent_mi.1 + 2)).unwrap_or(last);
11289+thread_local! {
11290+ /// lane-sb128c r8: INTRA (key-frame) 128x64 blocks decoded at the 128
11291+ /// root's HORZ arm, and 64x128 ones at its VERT arm.
11292+ pub(crate) static INTRA_SB128_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
11293+ pub(crate) static INTRA_SB128_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
11294+ /// Those blocks by resolved intra `tx_depth` (0 = TX_64X64 units,
11295+ /// 1 = TX_32X32, 2 = TX_16X16) -- proof the depth symbol is really read.
11296+ pub(crate) static INTRA_SB128_DEPTH_HITS: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) };
11297+}
11298+
11299+/// [`INTRA_SB128_HORZ_HITS`] / [`INTRA_SB128_VERT_HITS`] /
11300+/// [`INTRA_SB128_DEPTH_HITS`], for a gate's own before/after delta.
11301+pub(crate) fn intra_sb128_hits() -> (usize, usize, [usize; 3]) {
11302+ (
11303+ INTRA_SB128_HORZ_HITS.with(std::cell::Cell::get),
11304+ INTRA_SB128_VERT_HITS.with(std::cell::Cell::get),
11305+ INTRA_SB128_DEPTH_HITS.with(std::cell::Cell::get),
11306+ )
1086911307 }
1087011308
10871-fn decode_leaf8(
11309+/// The 128 root's HORZ/VERT arm on an INTRA frame: ONE 128x64 (HORZ) or
11310+/// 64x128 (VERT) intra block (lane-sb128c r8; the inter twin is
11311+/// `decode_inter_block`'s own rect path).
11312+///
11313+/// libaom `decode_block` -> `predict_and_reconstruct_intra_block` per
11314+/// transform unit, with the 128-specific geometry:
11315+/// * `max_txsize_rect_lookup[BLOCK_128X64]` is TX_64X64, so every luma unit
11316+/// is SQUARE and there are at least two of them -- depth 0: 64x64 x2,
11317+/// depth 1: 32x32 x8, depth 2: 16x16 x32 (`bsize_to_tx_size_cat` counts
11318+/// the `sub_tx_size_map` chain TX_64X64->32->16->8->4, i.e. cat 3, the
11319+/// same CDF a 64x64 square block reads).
11320+/// * `av1_get_max_uv_txsize` = `av1_get_adjusted_tx_size(
11321+/// max_txsize_rect_lookup[BLOCK_64X32])` caps at TX_32X32, so the block's
11322+/// 64x32 uv plane block is TWO 32x32 chroma units per plane -- one per
11323+/// 64x64 luma "mu" chunk, and `decode_token_recon_block` codes Y, U, V of
11324+/// a chunk before moving to the next (the interleave lane-sb128b r3
11325+/// measured at the 128x128 NONE root).
11326+/// * `get_txb_ctx`: the uv plane block is bigger than the uv transform, so
11327+/// chroma `txb_skip_ctx` takes the offset-10 rows (7 + 3).
11328+/// No CfL, no filter intra (both cap at 32x32) and no palette
11329+/// (`av1_allow_palette` caps at 64x64) exist at this size -- the mode
11330+/// reader's own size gates already say so, and the guard below is defensive.
11331+#[allow(clippy::too_many_arguments)]
11332+fn decode_block_128rect(
1087211333 dec: &mut SymbolDecoder,
1087311334 cdfs: &mut Cdfs,
1087411335 neighbours: &mut Neighbours,
10875- outer_at: (usize, usize),
10876- leaf_mi: (usize, usize),
10877- scans: (&[u16], &[u16]),
10878- prev_leaf: Option<((usize, usize), usize)>,
11336+ at: (usize, usize),
11337+ bw: usize,
11338+ bh: usize,
1087911339 y: &mut PlaneBuf,
1088011340 u: &mut PlaneBuf,
1088111341 v: &mut PlaneBuf,
1088211342 base_q_idx: u8,
1088311343 enable_filter_intra: bool,
1088411344 allow_screen_content_tools: bool,
10885- allow_intrabc: bool,
1088611345 tx_select: bool,
1088711346 reduced_tx_set: bool,
10888-) -> Result<usize> {
10889- let (r, c) = outer_at;
10890- // lane-modectx r1: the group's own availability-correct fallback pair, not
10891- // the raw coarse bands (which leak across a tile edge -- see
10892- // `modes_above_left`).
10893- let (mut above_mode, mut left_mode) = neighbours.modes_above_left(r, c);
10894- if let Some(((pr, pc), pmode)) = prev_leaf {
10895- if pc == leaf_mi.1 && leaf_mi.0 == pr + 2 {
10896- above_mode = pmode;
10897- } else if pr == leaf_mi.0 && leaf_mi.1 == pc + 2 {
10898- left_mode = pmode;
10899- }
10900- }
10901- // The mi-exact neighbour wins over both the coarse 16x16 slot and
10902- // `prev_leaf`: one 16x16 slot cannot hold the two different modes its
10903- // two 8x8 (or four 4x4) columns leave behind, so a leaf whose above/left
10904- // neighbour sits in a split cell read the wrong `kf_y_mode` row.
10905- // lane-rectsplitx r2 swept this arm into
10906- // [`Neighbours::modes_above_left_mi`]: the mi-exact map ALSO has to answer
10907- // "no neighbour" at a tile edge, where the coarse cell holds the block
10908- // above/left of it inside the same 16x16.
10909- let (above_mode, left_mode) =
10910- neighbours.modes_above_left_mi(leaf_mi.0, leaf_mi.1, (above_mode, left_mode));
10911- let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
10912- // Chroma's edge-filter type reads the CHROMA neighbour's `uv_mode`
10913- // (`get_intra_edge_filter_type`, reconintra.c:974), never the luma mode
10914- // this leaf's `smooth_neighbor` is built from -- passing `false` here
10915- // filtered a directional chroma block's edge at the wrong strength
10916- // (lane-sub8 r5: 4 pixels of one 8x8 leaf's chroma, deltas 1..3).
10917- // The `uv_mode` neighbours are mi-exact (`uv_mode_col`/`uv_mode_row`),
11347+) -> Result<()> {
11348+ let (r, c) = at;
11349+ let (px, py) = (c * SUB, r * SUB);
11350+ let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI));
11351+ let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left(r, c);
11352+ let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache(at);
11353+ let palette_uv_cache = neighbours.palette_uv_cache(at);
11354+ let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) =
11355+ read_intra_mode_rect(
11356+ dec,
11357+ cdfs,
11358+ nb_above_mode,
11359+ nb_left_mode,
11360+ // `is_cfl_allowed` caps CFL at 32x32: `uv_mode` comes off the
11361+ // 13-symbol no-CFL CDF here, never the 14-symbol one.
11362+ false,
11363+ true,
11364+ bw,
11365+ bh,
11366+ enable_filter_intra,
11367+ neighbours.skip_txfm_ctx(mi_r, mi_c),
11368+ allow_screen_content_tools,
11369+ Some((palette_ctx, &palette_cache)),
11370+ &palette_uv_cache,
11371+ mi_r,
11372+ mi_c,
11373+ )?;
11374+ if alpha.is_some() || filter_intra.is_some() || palette_y.is_some() || palette_uv.is_some() {
11375+ return Err(unsupported(
11376+ "CfL, filter intra or a palette on a 128-root HORZ/VERT intra block (every one of \
11377+ their size gates caps at 64x64 or below, so none of these symbols exists there)",
11378+ ));
11379+ }
11380+ let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
11381+ let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
11382+ if smooth_neighbor {
11383+ SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
11384+ }
11385+ let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c);
11386+ // spec 5.11.16 `read_tx_size`: read for every intra block, skipped or
11387+ // not. `bsize_to_tx_size_cat(BLOCK_128X64)` is 3 (see this fn's doc).
11388+ let depth = if tx_select {
11389+ let ctx = tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh);
11390+ dec.symbol(&mut cdfs.tx_size_cat3[ctx])
11391+ } else {
11392+ 0
11393+ };
11394+ if depth != 0 {
11395+ TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
11396+ }
11397+ INTRA_SB128_DEPTH_HITS.with(|c| {
11398+ let mut h = c.get();
11399+ h[depth.min(2)] += 1;
11400+ c.set(h);
11401+ });
11402+ let logical_tx = 64 >> depth;
11403+ // A 64-point transform codes nothing past its low 32 coefficients.
11404+ let coeff_tx_side = logical_tx.min(32);
11405+ let luma_set = txbset_for(logical_tx, reduced_tx_set);
11406+ let luma_scan = default_scan(coeff_tx_side);
11407+ let chroma_tx = 32;
11408+ let chroma_scan = default_scan(chroma_tx);
11409+ let (cpx, cpy) = (px / 2, py / 2);
11410+ let (chroma_w, chroma_h) = (bw / 2, bh / 2);
11411+ let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height);
11412+ let (nch_x, nch_y) = (bw / 64, bh / 64);
11413+ // One 32x32 chroma unit per mu chunk, per plane.
11414+ debug_assert_eq!((chroma_w / chroma_tx, chroma_h / chroma_tx), (nch_x, nch_y));
11415+ let tpc = 64 / logical_tx;
11416+ let zero_tu = vec![0i32; logical_tx * logical_tx];
11417+ let zero_cu = vec![0i32; chroma_tx * chroma_tx];
11418+ let mut last_grids = [Vec::new(), Vec::new()];
11419+ let mut units: Vec<((usize, usize), Vec<i32>, Vec<i32>)> = Vec::new();
11420+ for ch_row in 0..nch_y {
11421+ for ch_col in 0..nch_x {
11422+ for tu_row in ch_row * tpc..(ch_row + 1) * tpc {
11423+ for tu_col in ch_col * tpc..(ch_col + 1) * tpc {
11424+ let tu_mi = (
11425+ mi_r + tu_row * (logical_tx / MI),
11426+ mi_c + tu_col * (logical_tx / MI),
11427+ );
11428+ let (tu_px, tu_py) = (px + tu_col * logical_tx, py + tu_row * logical_tx);
11429+ // libaom clips the transform loop to
11430+ // `max_blocks_wide/high`: a unit whose top-left sample is
11431+ // outside the frame is never coded.
11432+ if tu_px >= y.true_width || tu_py >= y.true_height {
11433+ continue;
11434+ }
11435+ // Edge availability of a unit INSIDE a block, with the
11436+ // 128 geometry -- `has_top_right` is false for a block
11437+ // whose largest side is > 64, which [`Reach::of_rect`]
11438+ // already answered for the block and [`tu_reach`] carries
11439+ // down to the units on its own top row.
11440+ let tu_r = tu_reach(
11441+ bw,
11442+ bh,
11443+ tu_col * logical_tx,
11444+ tu_row * logical_tx,
11445+ logical_tx,
11446+ reach,
11447+ px,
11448+ py,
11449+ y.width,
11450+ y.height,
11451+ );
11452+ if skip {
11453+ y.reconstruct(
11454+ tu_px, tu_py, logical_tx, mode, angle_delta_y, tu_r, &zero_tu, None,
11455+ None, smooth_neighbor,
11456+ );
11457+ neighbours.record_mi_luma(tu_mi, logical_tx, &zero_tu);
11458+ continue;
11459+ }
11460+ // The unit is smaller than its block, so `txb_skip_ctx`
11461+ // is the neighbour-magnitude table, never the lone-TU 0.
11462+ let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, logical_tx / MI);
11463+ let tu_around = neighbours.around_mi(tu_mi, logical_tx)[0];
11464+ let tu_grid = read_plane(
11465+ dec,
11466+ cdfs,
11467+ luma_set,
11468+ &luma_scan,
11469+ 0,
11470+ tu_around,
11471+ mode,
11472+ mode,
11473+ angle_delta_y,
11474+ tu_r,
11475+ y,
11476+ tu_px,
11477+ tu_py,
11478+ logical_tx,
11479+ coeff_tx_side,
11480+ base_q_idx,
11481+ None,
11482+ None,
11483+ Some(tu_skip_ctx),
11484+ smooth_neighbor,
11485+ )?;
11486+ neighbours.record_mi_luma(tu_mi, logical_tx, &tu_grid);
11487+ }
11488+ }
11489+ // The chroma context arrays are indexed in LUMA mi, so this
11490+ // unit's anchor is its own 64x64 mu chunk.
11491+ let luma_span = chroma_tx * 2;
11492+ let cu_mi = (
11493+ mi_r + ch_row * (luma_span / MI),
11494+ mi_c + ch_col * (luma_span / MI),
11495+ );
11496+ let cu_r = tu_reach(
11497+ bw,
11498+ bh,
11499+ ch_col * luma_span,
11500+ ch_row * luma_span,
11501+ luma_span,
11502+ reach,
11503+ px,
11504+ py,
11505+ y.width,
11506+ y.height,
11507+ );
11508+ let (cu_x, cu_y) = (cpx + ch_col * chroma_tx, cpy + ch_row * chroma_tx);
11509+ if skip {
11510+ u.reconstruct(
11511+ cu_x, cu_y, chroma_tx, uv_predict_mode, angle_delta_uv, cu_r, &zero_cu, None,
11512+ None, smooth_neighbor_uv,
11513+ );
11514+ v.reconstruct(
11515+ cu_x, cu_y, chroma_tx, uv_predict_mode, angle_delta_uv, cu_r, &zero_cu, None,
11516+ None, smooth_neighbor_uv,
11517+ );
11518+ continue;
11519+ }
11520+ let cu_around = neighbours.around_mi(cu_mi, luma_span);
11521+ let u_grid = read_plane(
11522+ dec, cdfs, TxbSet::Chroma32, &chroma_scan, 1, cu_around[1], mode, uv_predict_mode,
11523+ angle_delta_uv, cu_r, u, cu_x, cu_y, chroma_tx, chroma_tx, base_q_idx, None, None,
11524+ Some(3), smooth_neighbor_uv,
11525+ )?;
11526+ let v_grid = read_plane(
11527+ dec, cdfs, TxbSet::Chroma32, &chroma_scan, 2, cu_around[2], mode, uv_predict_mode,
11528+ angle_delta_uv, cu_r, v, cu_x, cu_y, chroma_tx, chroma_tx, base_q_idx, None, None,
11529+ Some(3), smooth_neighbor_uv,
11530+ )?;
11531+ CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
11532+ // Immediately, so the NEXT unit of this same block reads this
11533+ // one's coefficient context; replayed after `record_split_luma_rect`
11534+ // below, which would otherwise clobber them whole-block.
11535+ neighbours.record_mi_chroma(cu_mi, luma_span, luma_span, 1, &u_grid);
11536+ neighbours.record_mi_chroma(cu_mi, luma_span, luma_span, 2, &v_grid);
11537+ units.push((cu_mi, u_grid.clone(), v_grid.clone()));
11538+ last_grids = [u_grid, v_grid];
11539+ }
11540+ }
11541+ if skip {
11542+ neighbours.record_rect(
11543+ at,
11544+ bw,
11545+ bh,
11546+ mode,
11547+ uv_predict_mode,
11548+ &[
11549+ vec![0i32; bw * bh],
11550+ vec![0i32; chroma_w * chroma_h],
11551+ vec![0i32; chroma_w * chroma_h],
11552+ ],
11553+ );
11554+ } else {
11555+ neighbours.record_split_luma_rect(
11556+ at,
11557+ bw,
11558+ bh,
11559+ mode,
11560+ uv_predict_mode,
11561+ [&last_grids[0], &last_grids[1]],
11562+ );
11563+ for (cu_mi, u_grid, v_grid) in &units {
11564+ neighbours.record_mi_chroma(*cu_mi, 64, 64, 1, u_grid);
11565+ neighbours.record_mi_chroma(*cu_mi, 64, 64, 2, v_grid);
11566+ }
11567+ }
11568+ // No palette exists at this size; the unconditional stamp clears any
11569+ // stale neighbour palette state, as every other block path does.
11570+ neighbours.record_palette_y_rect(at, bw, bh, 0, [0u16; 8]);
11571+ neighbours.record_palette_uv_rect(at, bw, bh, 0, [0u16; 8]);
11572+ neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip);
11573+ neighbours.fill_lf_grid_rect(
11574+ (mi_r, mi_c),
11575+ bw / MI,
11576+ bh / MI,
11577+ logical_tx as u8,
11578+ logical_tx as u8,
11579+ 0,
11580+ );
11581+ if bw > bh {
11582+ INTRA_SB128_HORZ_HITS.with(|c| c.set(c.get() + 1));
11583+ } else {
11584+ INTRA_SB128_VERT_HITS.with(|c| c.set(c.get() + 1));
11585+ }
11586+ Ok(())
11587+}
11588+
11589+
11590+/// Decodes one 8x8 leaf of a straddling 16x16 block (lane-av1-rect), mirroring
11591+/// [`crate::tile::write_leaf8`]: its intra-mode context comes from the
11592+/// *enclosing* 16x16 slot's `above_mode`/`left_mode` (`outer_at`, [`SUB`]-grid),
11593+/// overridden on whichever axis `prev_leaf` sits along -- the previous leaf's
11594+/// just-decoded mode, not the enclosing slot's stale one, is the true
11595+/// neighbour there. `leaf_mi` is this leaf's own position in 4x4 mode-info
11596+/// units, which is what its coefficient context (finer than [`SUB`]) is read
11597+/// at. Returns the mode this leaf decoded, for the caller's own
11598+/// `prev_leaf`/final mode-writeback bookkeeping.
11599+#[allow(clippy::too_many_arguments)]
11600+/// The coarse 16x16 `above_mode`/`left_mode` cells a four-way SPLIT of one
11601+/// 16x16 parent leaves behind (lane-rectx r3). The next block DOWN reads
11602+/// `above_mode[col]`, and its true above neighbour is the mi directly above
11603+/// its own top-left corner -- the parent's BOTTOM-LEFT leaf, not the last one
11604+/// decoded; the next block RIGHT reads `left_mode[row]`, whose true left
11605+/// neighbour is the parent's TOP-RIGHT leaf. Writing the z-order last leaf
11606+/// (bottom-right) into both, as this path did, is right only when all four
11607+/// leaves happen to share a mode. `done` may be short at the true frame edge
11608+/// (the straddle caller filters positions off the frame), so each side falls
11609+/// back to the last leaf actually decoded.
11610+fn write_back_split_modes(
11611+ neighbours: &mut Neighbours,
11612+ done: &[((usize, usize), usize)],
11613+ parent_mi: (usize, usize),
11614+ slot: (usize, usize),
11615+) {
11616+ let (sr, sc) = slot;
11617+ let Some(&(_, last)) = done.last() else {
11618+ return;
11619+ };
11620+ let find = |mi: (usize, usize)| done.iter().find(|&&(at, _)| at == mi).map(|&(_, m)| m);
11621+ neighbours.above_mode[sc] = find((parent_mi.0 + 2, parent_mi.1)).unwrap_or(last);
11622+ neighbours.left_mode[sr] = find((parent_mi.0, parent_mi.1 + 2)).unwrap_or(last);
11623+}
11624+
11625+fn decode_leaf8(
11626+ dec: &mut SymbolDecoder,
11627+ cdfs: &mut Cdfs,
11628+ neighbours: &mut Neighbours,
11629+ outer_at: (usize, usize),
11630+ leaf_mi: (usize, usize),
11631+ scans: (&[u16], &[u16]),
11632+ prev_leaf: Option<((usize, usize), usize)>,
11633+ y: &mut PlaneBuf,
11634+ u: &mut PlaneBuf,
11635+ v: &mut PlaneBuf,
11636+ base_q_idx: u8,
11637+ enable_filter_intra: bool,
11638+ allow_screen_content_tools: bool,
11639+ allow_intrabc: bool,
11640+ tx_select: bool,
11641+ reduced_tx_set: bool,
11642+) -> Result<usize> {
11643+ let (r, c) = outer_at;
11644+ // lane-modectx r1: the group's own availability-correct fallback pair, not
11645+ // the raw coarse bands (which leak across a tile edge -- see
11646+ // `modes_above_left`).
11647+ let (mut above_mode, mut left_mode) = neighbours.modes_above_left(r, c);
11648+ if let Some(((pr, pc), pmode)) = prev_leaf {
11649+ if pc == leaf_mi.1 && leaf_mi.0 == pr + 2 {
11650+ above_mode = pmode;
11651+ } else if pr == leaf_mi.0 && leaf_mi.1 == pc + 2 {
11652+ left_mode = pmode;
11653+ }
11654+ }
11655+ // The mi-exact neighbour wins over both the coarse 16x16 slot and
11656+ // `prev_leaf`: one 16x16 slot cannot hold the two different modes its
11657+ // two 8x8 (or four 4x4) columns leave behind, so a leaf whose above/left
11658+ // neighbour sits in a split cell read the wrong `kf_y_mode` row.
11659+ // lane-rectsplitx r2 swept this arm into
11660+ // [`Neighbours::modes_above_left_mi`]: the mi-exact map ALSO has to answer
11661+ // "no neighbour" at a tile edge, where the coarse cell holds the block
11662+ // above/left of it inside the same 16x16.
11663+ let (above_mode, left_mode) =
11664+ neighbours.modes_above_left_mi(leaf_mi.0, leaf_mi.1, (above_mode, left_mode));
11665+ let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
11666+ // Chroma's edge-filter type reads the CHROMA neighbour's `uv_mode`
11667+ // (`get_intra_edge_filter_type`, reconintra.c:974), never the luma mode
11668+ // this leaf's `smooth_neighbor` is built from -- passing `false` here
11669+ // filtered a directional chroma block's edge at the wrong strength
11670+ // (lane-sub8 r5: 4 pixels of one 8x8 leaf's chroma, deltas 1..3).
11671+ // The `uv_mode` neighbours are mi-exact (`uv_mode_col`/`uv_mode_row`),
1091811672 // with the coarse [`SUB`] slot as the fallback when no block recorded
1091911673 // that exact mi cell.
1092011674 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c);
@@ -10924,7 +11678,15 @@ fn decode_leaf8(
1092411678 // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec
1092511679 // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other
1092611680 // `decode_block` caller at 16x16 and up.
10927- let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, _palette_y, _palette_uv) =
11681+ // lane-pal8 r1: this leaf's own palette-Y mode ctx and colour cache
11682+ // (`av1_get_palette_mode_ctx` / `av1_get_palette_cache`, decodemv.c:567,
11683+ // `read_palette_mode_info`), at its REAL mi position -- passing
11684+ // `None`/`&[]` read `palette_y_mode` off CDF row 0 and refused by name the
11685+ // moment a real 8x8 palette block fired, which is where every 8-bit
11686+ // `--tune-content=screen --min-partition-size=8` stream stopped.
11687+ let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(leaf_mi);
11688+ let palette_uv_cache = neighbours.palette_uv_cache_mi(leaf_mi);
11689+ let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) =
1092811690 read_intra_mode(
1092911691 dec,
1093011692 cdfs,
@@ -10936,11 +11698,49 @@ fn decode_leaf8(
1093611698 neighbours.skip_txfm_ctx(leaf_mi.0, leaf_mi.1),
1093711699 allow_screen_content_tools,
1093811700 allow_intrabc,
10939- None,
10940- &[],
11701+ Some((palette_ctx, &palette_cache)),
11702+ &palette_uv_cache,
1094111703 leaf_mi.0,
1094211704 leaf_mi.1,
1094311705 )?;
11706+ // lane-kf900 r7: an 8x8 leaf consumed `use_intrabc` (and its DV) through
11707+ // `read_intra_mode` and then decoded the block as if it were ordinary
11708+ // intra. libaom's `is_inter_block` counts an intrabc block
11709+ // (`blockd.h:373`), so its luma `tx_type` comes off the INTER ext-tx set
11710+ // (`av1_get_ext_tx_set_type(TX_8X8, is_inter=1, 0)` = `EXT_TX_SET_ALL16`,
11711+ // a 16-symbol CDF) while we read the 7-symbol `TX_SET_INTRA_1` row: the
11712+ // same value with a different interval, so the tile desynced at the very
11713+ // next symbol (class `wrong-alphabet-same-value`). Everything below
11714+ // mirrors `decode_block`'s own intrabc handling at 16x16 and up.
11715+ let intrabc_dv = INTRABC_DV.with(|c| c.take());
11716+ if intrabc_dv.is_some() {
11717+ LEAF8_INTRABC_HITS.with(|c| c.set(c.get() + 1));
11718+ }
11719+ if intrabc_dv.is_some() && tx_select && !skip {
11720+ return Err(unsupported(
11721+ "an intrabc block under TxMode::Select (its transform size is coded by the inter var-tx partition tree, which this decoder never reads)",
11722+ ));
11723+ }
11724+ // `av1_visit_palette`'s reconstruction (decodeframe.c:1135): the colour
11725+ // index map, mapped through the base colours, IS the block's prediction --
11726+ // carried to the next `reconstruct`/`read_plane` through the same
11727+ // [`PALETTE_PRED`] slot [`decode_block`] uses at 16x16 and up.
11728+ let palette_y_buf: Option<Vec<u16>> = palette_y
11729+ .as_ref()
11730+ .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect());
11731+ let palette_uv_bufs: Option<(Vec<u16>, Vec<u16>)> = palette_uv.as_ref().map(|p| {
11732+ (
11733+ p.map.iter().map(|&i| p.u_colors[i as usize]).collect(),
11734+ p.map.iter().map(|&i| p.v_colors[i as usize]).collect(),
11735+ )
11736+ });
11737+ let (pal_y_size, pal_y_colors) =
11738+ palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
11739+ let (pal_uv_size, pal_uv_colors) =
11740+ palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
11741+ if palette_y.is_some() || palette_uv.is_some() {
11742+ PALETTE_LEAF8_HITS.with(|c| c.set(c.get() + 1));
11743+ }
1094411744 let uv_predict_mode = if uv_mode == UV_CFL_PRED {
1094511745 DC_PRED
1094611746 } else {
@@ -10954,7 +11754,11 @@ fn decode_leaf8(
1095411754 // which splits the leaf's own 8x8 prediction into a 2x2 grid of 4x4
1095511755 // transform units, same raster-order per-TU pattern `decode_block`'s
1095611756 // multi-TU branch runs).
10957- let resolved = if tx_select {
11757+ // ... and an intrabc leaf reads no intra `tx_depth` symbol at all: under
11758+ // `TX_MODE_SELECT` a skipped inter block takes the largest transform
11759+ // (`read_tx_size(.., is_inter=1, ..)`), and the unskipped case is refused
11760+ // above.
11761+ let resolved = if tx_select && intrabc_dv.is_none() {
1095811762 read_tx_size(dec, cdfs, neighbours, leaf_mi, 8, None)
1095911763 } else {
1096011764 8
@@ -10962,6 +11766,37 @@ fn decode_leaf8(
1096211766 let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI);
1096311767 let reach = Reach::of(8, px, py, y.width, y.height);
1096411768 let (cpx, cpy) = (px / 2, py / 2);
11769+ // spec 7.11.3.4 with `use_intrabc`, same as `decode_block`: predict from
11770+ // the CURRENT frame's own pre-loop-filter reconstruction (every loop
11771+ // filter is off whenever `allow_intrabc`, frame.rs:194/210/252/272) at
11772+ // the full-pel block vector, with the BILINEAR kernel libaom forces.
11773+ let intrabc_bufs = intrabc_dv.map(|(dv_row, dv_col)| {
11774+ let mut yb = vec![0u16; 8 * 8];
11775+ mc::predict_with_filter(
11776+ &y.data, y.width, y.true_width, y.true_height,
11777+ mv_to_q4(px, dv_col, true), mv_to_q4(py, dv_row, true),
11778+ 8, 8, mc::InterpFilterKind::Bilinear, &mut yb,
11779+ );
11780+ let mut ub = vec![0u16; 4 * 4];
11781+ mc::predict_with_filter(
11782+ &u.data, u.width, u.true_width, u.true_height,
11783+ mv_to_q4(cpx, dv_col, false), mv_to_q4(cpy, dv_row, false),
11784+ 4, 4, mc::InterpFilterKind::Bilinear, &mut ub,
11785+ );
11786+ let mut vb = vec![0u16; 4 * 4];
11787+ mc::predict_with_filter(
11788+ &v.data, v.width, v.true_width, v.true_height,
11789+ mv_to_q4(cpx, dv_col, false), mv_to_q4(cpy, dv_row, false),
11790+ 4, 4, mc::InterpFilterKind::Bilinear, &mut vb,
11791+ );
11792+ (yb, ub, vb)
11793+ });
11794+ // The per-plane prediction override rides the same [`PALETTE_PRED`] slot
11795+ // `decode_block` uses: set fresh right before each plane's own
11796+ // `reconstruct`/`read_plane` call (the slot is taken, not copied).
11797+ if let Some((yb, _, _)) = &intrabc_bufs {
11798+ set_palette_pred(yb.clone());
11799+ }
1096511800 let (luma_grid, u_grid, v_grid);
1096611801 if skip {
1096711802 // lane-hgkf r2 (same shape as `decode_block`'s own skip branch): an
@@ -10969,7 +11804,11 @@ fn decode_leaf8(
1096911804 // transform units, each off the units already written left/above of
1097011805 // it inside this same leaf -- an intra block's transform size is read
1097111806 // whether or not it is skipped, and spec 7.11.2 predicts per unit.
10972- if resolved == 4 {
11807+ // A palette block's prediction is the whole-block index map, never
11808+ // per-transform-unit edges ([`decode_block`]'s own `split_tx_skip`
11809+ // rule) -- so a palette leaf takes the single 8x8 reconstruct below
11810+ // even when `tx_depth` resolved to TX_4X4.
11811+ if resolved == 4 && palette_y_buf.is_none() {
1097311812 SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
1097411813 for tu_row in 0..2 {
1097511814 for tu_col in 0..2 {
@@ -11004,6 +11843,9 @@ fn decode_leaf8(
1100411843 }
1100511844 }
1100611845 } else {
11846+ if let Some(buf) = &palette_y_buf {
11847+ set_palette_pred(buf.clone());
11848+ }
1100711849 y.reconstruct(
1100811850 px,
1100911851 py,
@@ -11018,6 +11860,11 @@ fn decode_leaf8(
1101811860 );
1101911861 }
1102011862 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));
11863+ if let Some((_, ub, _)) = &intrabc_bufs {
11864+ set_palette_pred(ub.clone());
11865+ } else if let Some((ub, _)) = &palette_uv_bufs {
11866+ set_palette_pred(ub.clone());
11867+ }
1102111868 u.reconstruct(
1102211869 cpx,
1102311870 cpy,
@@ -11030,6 +11877,11 @@ fn decode_leaf8(
1103011877 None,
1103111878 smooth_neighbor_uv,
1103211879 );
11880+ if let Some((_, _, vb)) = &intrabc_bufs {
11881+ set_palette_pred(vb.clone());
11882+ } else if let Some((_, vb)) = &palette_uv_bufs {
11883+ set_palette_pred(vb.clone());
11884+ }
1103311885 v.reconstruct(
1103411886 cpx,
1103511887 cpy,
@@ -11047,10 +11899,15 @@ fn decode_leaf8(
1104711899 v_grid = vec![0i32; 16];
1104811900 } else if resolved != 4 {
1104911901 let around = neighbours.around_mi(leaf_mi, 8);
11902+ if let Some(buf) = &palette_y_buf {
11903+ set_palette_pred(buf.clone());
11904+ }
1105011905 luma_grid = read_plane(
1105111906 dec,
1105211907 cdfs,
11053- if reduced_tx_set {
11908+ if intrabc_dv.is_some() {
11909+ txbset_for_inter(8, reduced_tx_set)
11910+ } else if reduced_tx_set {
1105411911 TxbSet::Luma8
1105511912 } else {
1105611913 TxbSet::Luma8Set1
@@ -11073,7 +11930,18 @@ fn decode_leaf8(
1107311930 None,
1107411931 smooth_neighbor,
1107511932 )?;
11933+ // `av1_get_tx_type` branches `PLANE_TYPE_UV` on `is_inter_block`, so
11934+ // an intrabc block's chroma tx_type is the colocated LUMA transform's
11935+ // coded type (lane-kf900 r6's own fix, `decode_block`'s line).
11936+ if intrabc_dv.is_some() {
11937+ INTRABC_CHROMA_TX.with(|c| c.set(Some(LUMA_TX_TYPE.with(std::cell::Cell::get))));
11938+ }
1107611939 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));
11940+ if let Some((_, ub, _)) = &intrabc_bufs {
11941+ set_palette_pred(ub.clone());
11942+ } else if let Some((ub, _)) = &palette_uv_bufs {
11943+ set_palette_pred(ub.clone());
11944+ }
1107711945 u_grid = read_plane(
1107811946 dec,
1107911947 cdfs,
@@ -11096,6 +11964,11 @@ fn decode_leaf8(
1109611964 None,
1109711965 smooth_neighbor_uv,
1109811966 )?;
11967+ if let Some((_, _, vb)) = &intrabc_bufs {
11968+ set_palette_pred(vb.clone());
11969+ } else if let Some((_, vb)) = &palette_uv_bufs {
11970+ set_palette_pred(vb.clone());
11971+ }
1109911972 v_grid = read_plane(
1110011973 dec,
1110111974 cdfs,
@@ -11118,6 +11991,11 @@ fn decode_leaf8(
1111811991 None,
1111911992 smooth_neighbor_uv,
1112011993 )?;
11994+ // Disarm: `INTRABC_CHROMA_TX` is `Some` across exactly this block's
11995+ // two chroma reads (`decode_block`'s own tail does the same) -- left
11996+ // set, every later chroma block would inherit this luma tx_type,
11997+ // which picks the scan and the inverse transform.
11998+ INTRABC_CHROMA_TX.with(|c| c.set(None));
1112111999 } else {
1112212000 // `tx_depth` resolved this leaf's luma to `TX4`: a 2x2 raster-order
1112312001 // grid of 4x4 transform units, each predicted from the leaf's own
@@ -11147,6 +12025,19 @@ fn decode_leaf8(
1114712025 y.height,
1114812026 );
1114912027 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1);
12028+ // Each 4x4 unit predicts from its own window of the block's
12029+ // 8x8 colour-index map ([`decode_block`]'s per-TU slice at
12030+ // 16x16 and up) -- the whole-block buffer would be taken by
12031+ // the FIRST unit and indexed at the wrong stride.
12032+ if let Some(buf) = &palette_y_buf {
12033+ PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
12034+ let mut window = vec![0u16; 16];
12035+ for row in 0..4 {
12036+ let src = (tu_row * 4 + row) * 8 + tu_col * 4;
12037+ window[row * 4..][..4].copy_from_slice(&buf[src..][..4]);
12038+ }
12039+ set_palette_pred(window);
12040+ }
1115012041 let tu_grid = read_plane(
1115112042 dec,
1115212043 cdfs,
@@ -11186,6 +12077,9 @@ fn decode_leaf8(
1118612077 }
1118712078 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));
1118812079 let chroma_around = neighbours.around_mi(leaf_mi, 8);
12080+ if let Some((ub, _)) = &palette_uv_bufs {
12081+ set_palette_pred(ub.clone());
12082+ }
1118912083 u_grid = read_plane(
1119012084 dec,
1119112085 cdfs,
@@ -11208,6 +12102,9 @@ fn decode_leaf8(
1120812102 None,
1120912103 smooth_neighbor_uv,
1121012104 )?;
12105+ if let Some((_, vb)) = &palette_uv_bufs {
12106+ set_palette_pred(vb.clone());
12107+ }
1121112108 v_grid = read_plane(
1121212109 dec,
1121312110 cdfs,
@@ -11258,27 +12155,26 @@ fn decode_leaf8(
1125812155 neighbours.above[leaf_mi.1 + cell][2] = v_state;
1125912156 }
1126012157 }
11261- // Non-palette 8x8 leaf (this path never reads a palette): clear the
11262- // above/left palette state over its own cell so the next block's ctx and
11263- // colour cache do not read a previous block's palette (lane-palette2 r8).
12158+ // This leaf's own palette state into the mi-granular above/left bands
12159+ // (sizes 0 when it used none, which is what clears a previous block's
12160+ // palette out of the next block's ctx and colour cache).
1126412161 {
11265- let pal_at = (leaf_mi.0 / (SUB / MI), leaf_mi.1 / (SUB / MI));
11266- neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]);
11267- neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]);
12162+ neighbours.record_palette_y_rect(leaf_mi, 8, 8, pal_y_size, pal_y_colors);
12163+ neighbours.record_palette_uv_rect(leaf_mi, 8, 8, pal_uv_size, pal_uv_colors);
1126812164 }
1126912165 neighbours.fill_skip_grid(leaf_mi, 2, skip);
1127012166 neighbours.fill_lf_grid(leaf_mi, 2, 4, 0);
1127112167 neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode);
12168+ record_intrabc_mi(leaf_mi.0, leaf_mi.1, 2, intrabc_dv);
1127212169 return Ok(mode);
1127312170 }
1127412171 neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);
11275- // Non-palette 8x8 leaf (this path never reads a palette): clear the
11276- // above/left palette state over its own cell so the next block's ctx and
11277- // colour cache do not read a previous block's palette (lane-palette2 r8).
12172+ // This leaf's own palette state into the mi-granular above/left bands
12173+ // (sizes 0 when it used none, which is what clears a previous block's
12174+ // palette out of the next block's ctx and colour cache).
1127812175 {
11279- let pal_at = (leaf_mi.0 / (SUB / MI), leaf_mi.1 / (SUB / MI));
11280- neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]);
11281- neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]);
12176+ neighbours.record_palette_y_rect(leaf_mi, 8, 8, pal_y_size, pal_y_colors);
12177+ neighbours.record_palette_uv_rect(leaf_mi, 8, 8, pal_uv_size, pal_uv_colors);
1128212178 }
1128312179 INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1));
1128412180 neighbours.fill_skip_grid(leaf_mi, 2, skip);
@@ -11294,6 +12190,10 @@ fn decode_leaf8(
1129412190 // -ss 900, first bad luma sample row 186 col 1803).
1129512191 neighbours.fill_lf_grid(leaf_mi, 2, resolved as u8, 0);
1129612192 neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode);
12193+ // The DV predictor of a LATER intrabc block is the ordinary `INTRA_FRAME`
12194+ // MV stack over this grid (`av1_find_mv_refs`), so an 8x8 leaf has to
12195+ // publish its own cells exactly like `decode_block` does.
12196+ record_intrabc_mi(leaf_mi.0, leaf_mi.1, 2, intrabc_dv);
1129712197 Ok(mode)
1129812198 }
1129912199
@@ -12162,13 +13062,6 @@ fn apply_deblock(
1216213062 if std::env::var_os("EC_AV1_DEBUG_SKIP_DEBLOCK").is_some() {
1216313063 return;
1216413064 }
12165- // lane-mergefix r4 debug rung: frame-level loop filter parameters.
12166- if std::env::var_os("EC_LFPARAMS").is_some() {
12167- eprintln!(
12168- "EC_LFPARAMS level={:?} sharpness={} delta_enabled={} delta_update={} ref_deltas={:?} mode_deltas={:?}",
12169- lf.level, lf.sharpness, lf.delta_enabled, lf.delta_update, lf.ref_deltas, lf.mode_deltas
12170- );
12171- }
1217213065 if lf.level[0] != 0 || lf.level[1] != 0 {
1217313066 deblock_plane(y, 0, lf, n, frame_width, frame_height);
1217413067 }
@@ -12226,17 +13119,57 @@ fn tx_size_context(n: &Neighbours, (mi_r, mi_c): (usize, usize), own_side: usize
1222613119 /// a neighbour's var-tx tree splits. [`tx_size_context`]'s deblock-grid
1222713120 /// approximation coincides with this only while every neighbour codes one
1222813121 /// whole-block transform, which is exactly what `TxMode::Select` ends.
13122+/// [`tx_size_context_txfm`] with the block's own width and height (lane-intrasplit
13123+/// r1): `get_tx_size_context` compares the neighbour ABOVE against
13124+/// `tx_size_wide[max_txsize_rect_lookup[bsize]]` and the neighbour to the LEFT
13125+/// against `tx_size_high[...]` (libaom `pred_common.h:342`), which for a 2:1
13126+/// strip are two different numbers. The intra strip inside an inter frame read
13127+/// this through [`tx_size_context_rect`] -- the key frame's deblock-grid
13128+/// approximation -- so once `TxMode::Select` made the depth symbol exist, it was
13129+/// read off the wrong CDF row whenever a neighbour's var-tx tree had split.
13130+fn tx_size_context_txfm_rect(
13131+ n: &Neighbours,
13132+ (mi_r, mi_c): (usize, usize),
13133+ own_w: usize,
13134+ own_h: usize,
13135+) -> usize {
13136+ let has_above = mi_r > n.tile_row0_mi;
13137+ let has_left = mi_c > n.tile_col0_mi;
13138+ let mut above = usize::from(n.above_txfm[mi_c]) >= own_w;
13139+ let mut left = usize::from(n.left_txfm[mi_r]) >= own_h;
13140+ if has_above && n.above_inter[mi_c] {
13141+ above = n.above_side_mi[mi_c] >= own_w;
13142+ }
13143+ if has_left && n.left_inter[mi_r] {
13144+ left = n.left_side_mi[mi_r] >= own_h;
13145+ }
13146+ match (has_above, has_left) {
13147+ (true, true) => usize::from(above) + usize::from(left),
13148+ (true, false) => usize::from(above),
13149+ (false, true) => usize::from(left),
13150+ (false, false) => 0,
13151+ }
13152+}
13153+
13154+/// lane-intrasplit r3: `above_inter`/`left_inter` are mi-granular bands (they
13155+/// are written and read everywhere else with a raw mi index); the SUB-cell
13156+/// division this pair used read a cell four blocks away, so the inter-neighbour
13157+/// override above fired on the wrong neighbour -- the first divergence of the
13158+/// 10-bit gate's stream was exactly this (`tx_depth` ctx 0 where libaom has 1,
13159+/// at the intra block right of an inter one).
1222913160 fn tx_size_context_txfm(n: &Neighbours, (mi_r, mi_c): (usize, usize), side: usize) -> usize {
1223013161 let has_above = mi_r > n.tile_row0_mi;
1223113162 let has_left = mi_c > n.tile_col0_mi;
1223213163 let mut above = usize::from(n.above_txfm[mi_c]) >= side;
1223313164 let mut left = usize::from(n.left_txfm[mi_r]) >= side;
12234- // lane-mergefix: `above_inter`/`left_inter` are written per mi
12235- // (`record_inter_rect_mi`), NOT per [`SUB`] cell -- reading them at
12236- // `mi_c / (SUB / MI)` asked a block two mi rows/columns away whether it
12237- // was inter, so a var-tx-split inter neighbour contributed its (smaller)
12238- // transform size instead of its block size and the `tx_depth` CDF row
12239- // came out one too low.
13165+ // lane-angledelta r1 (class [[context-read-from-one-cell]]): both
13166+ // `above_inter`/`left_inter` bands are written per MI unit
13167+ // (`record_inter_rect_mi`), so they are read per MI too -- the `/ (SUB /
13168+ // MI)` here read the 16-px cell's FIRST mi instead, i.e. a different
13169+ // block whenever the neighbour column/row is not the cell's first. A
13170+ // 16x16 intra block whose left neighbour is an inter block at mi row 4
13171+ // then missed libaom's "an inter neighbour contributes its BLOCK size"
13172+ // override and read `tx_size_cat1` row 1 where aomdec reads row 2.
1224013173 if has_above && n.above_inter[mi_c] {
1224113174 above = n.above_side_mi[mi_c] >= side;
1224213175 }
@@ -12357,6 +13290,9 @@ fn txfm_partition_update_rect(
1235713290 (tx_w, tx_h): (usize, usize),
1235813291 (txb_w, txb_h): (usize, usize),
1235913292 ) {
13293+ if std::env::var_os("EC_TXUPD").is_some() {
13294+ eprintln!("EC_TXUPD rect mi=({},{}) tx=({tx_w},{tx_h}) txb=({txb_w},{txb_h})", mi_r, mi_c);
13295+ }
1236013296 for i in 0..txb_h / MI {
1236113297 if let Some(cell) = n.left_txfm.get_mut(mi_r + i) {
1236213298 *cell = tx_h as u8;
@@ -12380,6 +13316,9 @@ fn set_txfm_ctxs(
1238013316 h_mi: usize,
1238113317 skip_inter: bool,
1238213318 ) {
13319+ if std::env::var_os("EC_TXUPD").is_some() {
13320+ eprintln!("EC_TXUPD ctxs mi=({mi_r},{mi_c}) tx={tx_px} wh=({w_mi},{h_mi}) skip_inter={skip_inter}");
13321+ }
1238313322 let bw = if skip_inter { w_mi * MI } else { tx_px };
1238413323 let bh = if skip_inter { h_mi * MI } else { tx_px };
1238513324 for i in 0..w_mi {
@@ -12686,6 +13625,19 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool {
1268613625 // Only reachable as a var-tx LEAF -- an 8x4/4x8 inter BLOCK is
1268713626 // refused earlier ("an inter partition below 8x8").
1268813627 | (8, 4) | (4, 8)
13628+ // lane-sb128c r7: the 128 root's HORZ/VERT halves. These are NOT
13629+ // one rectangular transform -- `max_txsize_rect_lookup
13630+ // [BLOCK_128X64]` is TX_64X64, so the block tiles into two square
crates/ec-av1/src/encode.rsmodified+22 -3
@@ -1261,13 +1261,32 @@ impl Reach {
12611261 tx_h: usize,
12621262 block: Self,
12631263 ) -> Self {
1264+ // A block wider than 64 is coded in 64x64 "mu" chunks in raster
1265+ // order, so both libaom predicates special-case it (lane-sb128c r10);
1266+ // without this the last unit column of every chunk of a 128x64 block
1267+ // predicts from a chunk libaom has not decoded yet.
1268+ let wide = bw > 64;
12641269 Self {
1265- above_right: if col_off + tx_w < bw {
1270+ above_right: if row_off > 0 {
1271+ // `has_top_right`'s `row_off > 0` branch: the offset is taken
1272+ // modulo the 64-wide chunk, except for the one unit whose
1273+ // top-right corner is the centre of a 128x128 block.
1274+ if wide {
1275+ (row_off == 64 && col_off + tx_w == 64) || (col_off % 64) + tx_w < 64
1276+ } else {
1277+ col_off + tx_w < bw
1278+ }
1279+ } else if col_off + tx_w < bw {
12661280 true
12671281 } else {
1268- row_off == 0 && block.above_right
1282+ block.above_right
12691283 },
1270- below_left: if col_off > 0 {
1284+ below_left: if wide && col_off > 0 && col_off % 64 == 0 {
1285+ // `has_bottom_left`: at the left edge of a right-hand chunk
1286+ // the bottom-left pixels are in the already-coded left chunk,
1287+ // provided they stay inside it.
1288+ (row_off % 64) + tx_h < bh.min(64)
1289+ } else if col_off > 0 {
12711290 false
12721291 } else if row_off + tx_h < bh {
12731292 true
crates/ec-av1/src/gate_coverage.rsmodified+12 -15
@@ -42,16 +42,13 @@
4242 /// its tool is now covered by a real stream.
4343 #[cfg(test)]
4444 const NEVER_EXERCISED: &[(&str, &str)] = &[
45- // lane-intrabc r1: the DV itself (mv stack against INTRA_FRAME, `ndvc`
46- // full-pel read, `av1_find_ref_dv` fallback) and the block-copy
47- // prediction are now decoded, but every real aomenc intrabc block this
48- // lane could produce sits under TX_MODE_SELECT, whose inter var-tx
49- // partition tree is unread -- so no stream reconstructs one end to end
50- // yet and this entry stays.
51- (
52- "enable-intrabc",
53- "the block vector is decoded and predicted from, but every real stream's intrabc block needs the unread inter var-tx transform tree",
54- ),
45+ // `enable-intrabc` LEFT this list on 2026-09-02 (lane-kf900 r6). The
46+ // premise it carried -- "every real stream's intrabc block sits under
47+ // TX_MODE_SELECT" -- was false: with `--enable-tx-size-search=0` aomenc
48+ // codes intrabc blocks under TX_MODE_LARGEST, and
49+ // `a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips`
50+ // spells `--enable-intrabc=1` and decodes three such 8-bit streams whole-
51+ // frame pixel-exact against ffmpeg, with the block counter asserted > 0.
5552 ];
5653
5754 /// The `--enable-*` tools this decoder cares about, whether or not any gate
@@ -167,10 +164,6 @@ const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[
167164 "enable-global-motion",
168165 "off in 5 gates, on in none at 8 bits; lane-gm owns the global-warp prediction that is still missing",
169166 ),
170- (
171- "enable-intrabc",
172- "the block vector is decoded and predicted from, but every real stream's intrabc block needs the unread inter var-tx transform tree",
173- ),
174167 (
175168 "enable-rect-tx",
176169 "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool",
@@ -211,7 +204,11 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ // lane-cwarp's 10-bit comp
211204 // flip/identity/1D transform types are proven to reach a real 10-bit stream
212205 // this decoder reconstructs exactly (10 of its rect coefficient TUs carry a
213206 // 1D tx class).
214- ("enable-intrabc", "hole at both depths, see the 8-bit list"),
207+ // `enable-intrabc` LEFT this 10-bit list on 2026-09-02 (lane-kf900 r6):
208+ // `a_real_aomenc_rect_strip_palette_decodes_pixel_exact`'s new
209+ // `smptebars-screen-txs-cq40/cq55` arms spell `--enable-intrabc=1` and are
210+ // decoded and pixel-compared at 10 bit as well as 8, so the tool reaches a
211+ // real 10-bit stream this decoder reconstructs exactly.
215212 ("enable-rect-tx", "hole at both depths, see the 8-bit list"),
216213 ];
217214
crates/ec-av1/src/mc.rsmodified+8 -0
@@ -375,6 +375,11 @@ pub fn predict_with_filters_kern(
375375 let xfrac = x_q4.rem_euclid(16) as usize;
376376 let y0 = y_q4.div_euclid(16);
377377 let yfrac = y_q4.rem_euclid(16) as usize;
378+ if std::env::var_os("EC_MC_TRACE").is_some() && block_w >= 4 {
379+ eprintln!(
380+ "EC_MC_CALL x_q4={x_q4} y_q4={y_q4} w={block_w} h={block_h} xfrac={xfrac} yfrac={yfrac} hk={h_kind:?} vk={v_kind:?} tw={true_width} th={true_height} stride={stride}"
381+ );
382+ }
378383
379384 // Whole-pel fast path: `SUBPEL_FILTERS[0]` is the identity tap (`128` at
380385 // its centre, everything else `0`), and both rounding shifts are exactly
@@ -769,6 +774,9 @@ pub fn predict_compound_intermediate_kern(
769774
770775 let y0 = y_q4.div_euclid(16);
771776 let yfrac = y_q4.rem_euclid(16) as usize;
777+ if std::env::var_os("EC_MC_TRACE").is_some() {
778+ eprintln!("EC_MC_COMP x_q4={x_q4} y_q4={y_q4} w={block_w} h={block_h} hk={h_kind:?} vk={v_kind:?}");
779+ }
772780
773781 let (v_wide, v_narrow) = v_kind.tables();
774782 note_narrow_kern(block_w, block_h, kern_w, kern_h);
crates/ec-av1/src/refusal_inventory.rsmodified+12 -9
@@ -29,24 +29,23 @@ const CAPABILITY_CLAIMS: &[&str] = &[
2929
3030 #[cfg(test)]
3131 const REFUSALS: &[&str] = &[
32- "a nonzero angle delta on an 8x8 intra leaf in an inter frame (no gate reaches this leaf with one; the >=16x16 arm decodes deltas)",
3332 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
3433 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)",
35- "an OBMC neighbour whose interp filter was never recorded (no switchable symbol for that block)",
34+ "an OBMC neighbour whose switchable interp filter was never recorded",
3635 "an intra 4x4 block inside an inter frame's sub-8x8 split (this decoder codes only inter 4x4 sub-blocks there)",
3736 "an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition (this decoder codes only inter sub-blocks there)",
3837 "a sub-8x8 inter block under a scaled reference (superres, unimplemented)",
3938 "a rectangular inter luma transform unit whose shape has no coefficient table set here",
4039 "a rectangular inter chroma transform unit whose shape has no coefficient table set here",
4140 "a rectangular transform unit whose shape has no coefficient scan table here",
42- "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
43- "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
4441 "a 32x32 partition type this decoder does not code (value={part32})",
4542 "a Golomb tail longer than this decoder reads",
4643 "a tx_type symbol outside its CDF's own set: {t}",
4744 "an INTER 32x32 partition type this decoder does not code (value={part32})",
4845 "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4",
49- "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)",
46+ "a 128x128 superblock partition value outside the 8-symbol alphabet",
47+ "an inter var-tx tree with a leaf transform larger than 64x64",
48+ "CfL, filter intra or a palette on a 128-root HORZ/VERT intra block (every one of their size gates caps at 64x64 or below, so none of these symbols exists there)",
5049 "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)",
5150 "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",
5251 "a block that actually uses a palette (UV) -- reconstruction is out of scope",
@@ -59,6 +58,12 @@ const REFUSALS: &[&str] = &[
5958 "a frame naming primary_ref_frame at a reference slot with no saved CDF state",
6059 "a frame with no mode-info grid",
6160 "a frame whose segmentation enables SEG_LVL_REF_FRAME/SKIP/GLOBALMV (this decoder reads segment_id but never lets a segment override a block's reference, skip or mode)",
61+ // Still live, but NARROWED: lane-rectres r1 added the 32x32-level 1:4
62+ // strips (32x8 / 8x32) to `rect_inter_residual_supported` -- THE shape both
63+ // 10-bit 3840x1608 film cuts and every measured 1080p offset stopped on
64+ // (gate `a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_codes_\
65+ // their_rect_residual`). The string stays because the shapes below 8x8 and
66+ // the AB-partition footprints still have no rectangular residual path.
6267 "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding",
6368 "a reference frame selected with no picture at this frame's own ref_frame_idx slot for it",
6469 "a reference picture whose height does not match this frame's own true size",
@@ -67,10 +72,9 @@ const REFUSALS: &[&str] = &[
6772 // lane-intrainter r1 lifted the >=16x16 square case (per-TU intra
6873 // prediction + coefficients, gate
6974 // `a_real_aomenc_inter_sequence_with_a_split_transform_intra_block_decodes_pixel_exact`);
70- // the 8x8 leaf's TX_4X4 2x2 grid is still refused here.
71- "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units",
75+ // lane-leaf8tx r4 lifted the 8x8 leaf's TX_4X4 2x2 grid (gate
76+ // `a_real_aomenc_inter_sequence_with_an_angle_delta_8x8_intra_leaf_decodes_pixel_exact`).
7277 "an inter frame with no key frame before it",
73- "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B; this decoder's inter tile path codes a superblock as NONE, SPLIT, HORZ, VERT, HORZ_4 or VERT_4)",
7478 // lane-inter16ab r1 lifted the AB half and r2 the 1:4 half (four 16x4 /
7579 // 4x16 inter strips, their 8x4/4x8 chroma pair built from BOTH strips'
7680 // motion vectors -- gate
@@ -90,7 +94,6 @@ const REFUSALS: &[&str] = &[
9094 // what is left is the 1:4 shape, whose `bsize_to_tx_size_cat` breaks the
9195 // size-group/category diagonal the 2:1 shapes share.
9296 "an intra-coded 16x4/4x16 strip on the inter block path (the 16x16-level 1:4 inter partition is refused before this point)",
93- "a split (nonzero tx_depth) transform on an intra HORZ/VERT strip in an inter frame",
9497 // The same arm's screen-content gate: palette/intrabc syntax is consumed
9598 // for square blocks only, so a strip in such a frame would skip symbols.
9699 "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)",
crates/ec-av1/src/restoration.rsmodified+28 -0
@@ -366,6 +366,26 @@ thread_local! {
366366 static SWITCHABLE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
367367 }
368368
369+/// lane-reelckf2 r1: how many *stripes* a real filter ran on with the frame's
370+/// own top row as their above boundary (`stripe_v_start == 0`, the 56-row
371+/// first stripe of `RESTORATION_UNIT_OFFSET == 8`), and how many ran on a
372+/// short LAST stripe (`stripe_v_end == plane_h` with a partial height). Those
373+/// are the two stripe shapes whose boundary substitution differs from every
374+/// interior stripe, and no gate size before this one had either.
375+thread_local! {
376+ static LR_STRIPE0_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
377+ static LR_LAST_STRIPE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
378+}
379+
380+/// Current value of [`LR_STRIPE0_HITS`].
381+pub(crate) fn lr_stripe0_hits() -> usize {
382+ LR_STRIPE0_HITS.with(|c| c.get())
383+}
384+/// Current value of [`LR_LAST_STRIPE_HITS`].
385+pub(crate) fn lr_last_stripe_hits() -> usize {
386+ LR_LAST_STRIPE_HITS.with(|c| c.get())
387+}
388+
369389 /// Current value of [`WIENER_HITS`].
370390 pub(crate) fn wiener_hits() -> usize {
371391 WIENER_HITS.with(|c| c.get())
@@ -868,6 +888,14 @@ fn filter_restoration_unit(
868888 let nominal_h = full_stripe_height - if frame_stripe == 0 { runit_offset } else { 0 };
869889 let h = nominal_h.min(unit_h - i);
870890 let stripe_v_end = stripe_v_start + h;
891+ if !matches!(filter, UnitFilter::None) {
892+ if stripe_v_start == 0 {
893+ LR_STRIPE0_HITS.with(|c| c.set(c.get() + 1));
894+ }
895+ if stripe_v_end == plane_h && h < nominal_h {
896+ LR_LAST_STRIPE_HITS.with(|c| c.set(c.get() + 1));
897+ }
898+ }
871899 match filter {
872900 UnitFilter::Wiener(info) => apply_wiener_stripe(
873901 out, cdef, deblocked, stride, plane_w, plane_h, h_start, h_end, stripe_v_start, stripe_v_end, &info,
crates/ec-av1/src/stream.rsmodified+5994 -3474

Diff too large; view file

@@ -68,24 +68,18 @@ pub fn inter_rect_counters() -> (usize, usize, usize, usize, usize, usize) {
6868 )
6969 }
7070
71-/// lane-intra14 r1: INTRA-coded 1:4 strips decoded on the INTER block path
72-/// (64x16, 16x64, 32x8, 8x32) -- the counters a recipe sweep needs from
73-/// outside the crate.
74-pub fn intra_rect4_in_inter_counters() -> (usize, usize, usize, usize) {
75- (
76- crate::decode::intra_rect4_strip_in_inter_hits(0),
77- crate::decode::intra_rect4_strip_in_inter_hits(1),
78- crate::decode::intra_rect4_strip_in_inter_hits(2),
79- crate::decode::intra_rect4_strip_in_inter_hits(3),
80- )
81-}
82-
8371 /// lane-r14 r2: luma transform units of an inter strip with a 64-px axis,
8472 /// coded as the truncated low-32 coefficient corner.
8573 pub fn rect64_inter_tu_hits() -> usize {
8674 crate::decode::rect64_inter_tu_hits()
8775 }
8876
77+/// lane-rectres r1: whole-block luma transform units of a 32x32-level 1:4
78+/// inter strip (`TX_32X8`/`TX_8X32`), `[32x8, 8x32]`.
79+pub fn rect32x8_inter_tu_hits() -> [usize; 2] {
80+ crate::decode::rect32x8_inter_tu_hits()
81+}
82+
8983 /// lane-r14 r3: RECTANGULAR var-tx leaf transform units, `[32x16, 16x32]` --
9084 /// the leaves `sub_tx_size_map` produces when a 1:4 strip with a 64-px axis
9185 /// splits its transform (`[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32`).
@@ -98,6 +92,12 @@ pub fn rect_intrabc_reads() -> usize {
9892 crate::decode::rect_intrabc_reads()
9993 }
10094
95+/// lane-rect64port r1: coded 64-level HORZ/VERT intra strips whose luma
96+/// transform unit is the un-split TX_64X32 (orient 0) / TX_32X64 (orient 1).
97+pub fn rect64_corner_tu_hits(orient: usize) -> usize {
98+ crate::decode::rect64_corner_tu_hits(orient)
99+}
100+
101101 /// lane-inter16ab r4: RECTANGULAR var-tx leaves with a 4-px axis, `[8x4, 4x8]`
102102 /// -- what `sub_tx_size_map[TX_16X4] == TX_8X4` produces when a 16x16-level
103103 /// 1:4 inter strip splits its transform.
@@ -117,6 +117,36 @@ pub fn rect_wii_hits() -> [usize; 6] {
117117 crate::decode::rect_wii_hits()
118118 }
119119
120+/// lane-sb128c r7: the 128 root's rect arms -- (gathered edge HORZ, gathered
121+/// edge VERT, inter 128x64 blocks, inter 64x128 blocks).
122+pub fn sb128_rect_counters() -> (usize, usize, usize, usize) {
123+ (
124+ crate::decode::part128_edge_horz_hits(),
125+ crate::decode::part128_edge_vert_hits(),
126+ crate::decode::inter_sb128_horz_hits(),
127+ crate::decode::inter_sb128_vert_hits(),
128+ )
129+}
130+
131+/// Blocks reconstructed with intra block copy at an 8x8 LEAF specifically
132+/// (lane-kf900 r7's shape); [`crate::decode::intrabc_hits`] counts every shape.
133+pub fn leaf8_intrabc_hits() -> usize {
134+ crate::decode::leaf8_intrabc_hits()
135+}
136+
137+/// lane-sb128c r8: the 128 root's INTRA (key-frame) rect arm -- (128x64
138+/// blocks, 64x128 blocks, blocks per resolved intra `tx_depth` 0/1/2).
139+pub fn intra_sb128_counters() -> (usize, usize, [usize; 3]) {
140+ crate::decode::intra_sb128_hits()
141+}
142+
143+/// lane-sb128c r9: the four AB shapes at the 128 root, in `PARTITION_HORZ_A`,
144+/// `_HORZ_B`, `_VERT_A`, `_VERT_B` order (key and inter tile paths share the
145+/// counter -- it is bumped where the root symbol resolves).
146+pub fn sb128_ab_counters() -> [usize; 4] {
147+ crate::decode::part128_ab_hits()
148+}
149+
120150 pub fn rect4_32_counters() -> (usize, usize, usize) {
121151 (
122152 crate::decode::rect4_32_horz_hits(),
@@ -923,6 +953,19 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
923953 Ok(pictures)
924954 }
925955
956+
957+/// lane-intra14 r1: INTRA-coded 1:4 strips decoded on the INTER block path
958+/// (64x16, 16x64, 32x8, 8x32) -- the counters a recipe sweep needs from
959+/// outside the crate.
960+pub fn intra_rect4_in_inter_counters() -> (usize, usize, usize, usize) {
961+ (
962+ crate::decode::intra_rect4_strip_in_inter_hits(0),
963+ crate::decode::intra_rect4_strip_in_inter_hits(1),
964+ crate::decode::intra_rect4_strip_in_inter_hits(2),
965+ crate::decode::intra_rect4_strip_in_inter_hits(3),
966+ )
967+}
968+
926969 #[cfg(test)]
927970 mod tests {
928971 use super::*;
@@ -997,17 +1040,142 @@ mod tests {
9971040 );
9981041 }
9991042
1000- /// lane-oddh r2 GATE: the frame-edge half-strip arms r1 added (a 64x32 /
1001- /// 32x64 superblock-level or 16x8 / 8x16 16-level INTER block where the
1002- /// frame's true edge cuts the strip in half) actually fire and decode
1003- /// pixel-exact, at both bit depths. 160 = two full superblock rows plus
1004- /// 32 pixels, so every superblock in the last row is a half strip; without
1005- /// r1's arms these attempts refused outright, which is why this gate
1006- /// asserts a nonzero `edge_rect_strip_hits` DELTA on attempts that were
1007- /// actually compared -- a refused attempt's hits would prove nothing
1008- /// (class "counter from refused stream").
1043+ /// lane-interedge r1: one attempt of the inter frame-edge half-strip gate --
1044+ /// encode `width x height` with real aomenc (rect partitions ON, every other
1045+ /// lane's open tool pinned off), decode it, and return
1046+ /// `(inter_edge_strip hits, frames whose LUMA differs, frames whose CHROMA
1047+ /// differs)` against ffmpeg. A refusal or a decode error is a hard failure:
1048+ /// this recipe reached every size without one (measured r1).
1049+ fn inter_edge_strip_attempt(
1050+ name: &str,
1051+ width: usize,
1052+ height: usize,
1053+ bit_depth: u32,
1054+ cq: u32,
1055+ frames: usize,
1056+ ) -> ([usize; 6], usize, usize) {
1057+ let duration = format!("{}", frames as f64 / 25.0);
1058+ let source = format!("mandelbrot=size={width}x{height}:rate=25");
1059+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
1060+ let y4m = Command::new("ffmpeg")
1061+ .args([
1062+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration, "-pix_fmt",
1063+ pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
1064+ ])
1065+ .stdin(Stdio::null())
1066+ .stdout(Stdio::piped())
1067+ .stderr(Stdio::piped())
1068+ .output()
1069+ .expect("ffmpeg failed to run");
1070+ assert!(
1071+ y4m.status.success(),
1072+ "{name}: ffmpeg refused the {width}x{height} {bit_depth}-bit fixture: {}",
1073+ String::from_utf8_lossy(&y4m.stderr)
1074+ );
1075+ let depth_arg = format!("--bit-depth={bit_depth}");
1076+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
1077+ let cq_arg = format!("--cq-level={cq}");
1078+ let limit_arg = format!("--limit={frames}");
1079+ let mut child = Command::new(aomenc_path())
1080+ .args([
1081+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg,
1082+ // cpu-used >= 1 keeps libaom on 64x64 superblocks at these
1083+ // sizes (`av1_select_sb_size`).
1084+ "--cpu-used=4", "--threads=1", "--row-mt=0", "--kf-max-dist=9999",
1085+ &limit_arg,
1086+ // decode order == display order, so the compare below covers
1087+ // every frame the stream carries (class gate-blind-to-hidden-frames).
1088+ "--lag-in-frames=0", &depth_arg, &input_depth_arg,
1089+ // Rect partitions stay ON: the frame-edge strip is a FORCED
1090+ // (gathered) HORZ/VERT, but with rect coding off the encoder
1091+ // answers that gathered symbol SPLIT every time and no edge
1092+ // strip ever fires (lane-oddh r2's finding, re-measured r1).
1093+ "--enable-rect-partitions=1", "--enable-ab-partitions=0",
1094+ "--enable-1to4-partitions=0", "--min-partition-size=8",
1095+ "--max-partition-size=64",
1096+ // Other lanes' open gaps this recipe must not trip.
1097+ "--enable-palette=0", "--enable-intrabc=0", "--enable-warped-motion=0",
1098+ "--enable-obmc=0", "--enable-masked-comp=0", "--enable-interintra-comp=0",
1099+ "--enable-onesided-comp=0", "--enable-interintra-wedge=0",
1100+ "--enable-smooth-interintra=0", "--enable-ref-frame-mvs=0",
1101+ "--enable-angle-delta=0", "--enable-cfl-intra=0",
1102+ "--enable-directional-intra=0", "--enable-smooth-intra=0",
1103+ "--enable-paeth-intra=0", "--enable-filter-intra=0",
1104+ "--enable-tx-size-search=0",
1105+ "--obu", "-o", "-", "-",
1106+ ])
1107+ .stdin(Stdio::piped())
1108+ .stdout(Stdio::piped())
1109+ .stderr(Stdio::piped())
1110+ .spawn()
1111+ .expect("aomenc failed to start");
1112+ child
1113+ .stdin
1114+ .take()
1115+ .expect("aomenc stdin")
1116+ .write_all(&y4m.stdout)
1117+ .expect("write y4m");
1118+ let out = child.wait_with_output().expect("aomenc failed to run");
1119+ assert!(
1120+ out.status.success(),
1121+ "aomenc refused: {}",
1122+ String::from_utf8_lossy(&out.stderr)
1123+ );
1124+ let stream = out.stdout;
1125+
1126+ // Reset, never a delta: a refused attempt's hits must not leak into the
1127+ // next one (class counter-from-refused-stream).
1128+ crate::decode::reset_inter_edge_strip_hits();
1129+ let decoded = decode_stream(&stream).unwrap_or_else(|e| {
1130+ panic!("{name}: {width}x{height} {bit_depth}-bit cq {cq} did not decode: {e}")
1131+ });
1132+ let hits = crate::decode::inter_edge_strip_hits();
1133+ let reference = if bit_depth == 10 {
1134+ ffmpeg_decode_sequence_10bit(&stream, width, height, frames)
1135+ } else {
1136+ ffmpeg_decode_sequence(&stream, width, height, frames)
1137+ };
1138+ assert_eq!(
1139+ decoded.len(),
1140+ reference.len(),
1141+ "{name}: {width}x{height} {bit_depth}-bit cq {cq} frame count"
1142+ );
1143+ assert!(
1144+ decoded.len() >= frames,
1145+ "{name}: {width}x{height} {bit_depth}-bit cq {cq} decoded only {} frames",
1146+ decoded.len()
1147+ );
1148+ let (mut luma_bad, mut chroma_bad) = (0usize, 0usize);
1149+ for (ours, theirs) in decoded.iter().zip(&reference) {
1150+ if ours.y != theirs.y {
1151+ luma_bad += 1;
1152+ }
1153+ if ours.u != theirs.u || ours.v != theirs.v {
1154+ chroma_bad += 1;
1155+ }
1156+ }
1157+ (hits, luma_bad, chroma_bad)
1158+ }
1159+
1160+ /// lane-interedge r1 GATE (was lane-oddh r2's `#[ignore]`d twin): the INTER
1161+ /// frame-edge half strips -- a `PARTITION_HORZ`/`PARTITION_VERT` forced by
1162+ /// the gathered edge symbol at the 64, 32 or 16 level whose second half lies
1163+ /// outside the true frame. Both of the user's films are height mod 16 == 8
1164+ /// (1920x792, 3840x1608), so every inter frame crosses these nodes.
1165+ ///
1166+ /// r1 root cause: the inter tile's 32-level `PARTITION_HORZ`/`PARTITION_VERT`
1167+ /// decoded the SECOND strip unconditionally, while libaom `decode_partition`
1168+ /// (decodeframe.c, PARTITION_HORZ) guards it with `has_rows`/`has_cols` --
1169+ /// so at the edge we read symbols the encoder never wrote. With that guard
1170+ /// removed this gate's 72x192 cq 32 arm refuses outright and its 104x192 arm
1171+ /// decodes luma rows 127..191 of frame 5 wrong (measured r1).
1172+ ///
1173+ /// The compare is LUMA-exact per frame plus a CONTROL size with no edge node
1174+ /// at all: chroma is excluded because a chroma-only inter residue that has
1175+ /// nothing to do with the frame edge is open on main (lanes/tiny-r3,
1176+ /// lanes/gmaffine-r4, lanes/palette2-r8) and the control below reproduces it
1177+ /// with `inter_edge_strip_hits` all zero.
10091178 #[test]
1010- #[ignore = "2026-09-02 lane-oddh r2: no aomenc recipe reaches the INTER edge half-strip arm yet -- rect partitions OFF makes the encoder answer the forced gathered edge symbol SPLIT every time (both bit depths decode 192x160 pixel-exact, edge_rect_strip_hits=0), and rect ON stops at three other lanes' gaps first: at cq 40 'a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding', at cq 62 'an INTER 32x32 partition type this decoder does not code (value=8/9)' (HORZ_4/VERT_4 even with --enable-1to4-partitions=0), and at min-partition 16 'a HORZ/VERT intra strip below 16x16 with a split transform'. The KEY-frame half of the same edge is gated: the tiny size sweep now covers 64x72/72x64/64x136/136x64/192x136"]
10111179 fn a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact() {
10121180 const NAME: &str = "a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact";
10131181 let _gate_lock = lock_gate_counters();
@@ -1015,116 +1183,66 @@ mod tests {
10151183 eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
10161184 return;
10171185 }
1018- let (width, height, frames) = (192usize, 160usize, 6usize);
1186+ let frames = 6usize;
1187+ // h mod 16 == 8 (bottom edge) and w mod 16 == 8 (right edge).
1188+ let sizes: &[(usize, usize)] = &[(192, 72), (192, 88), (72, 192), (88, 192), (104, 192)];
1189+ let mut totals = [0usize; 6];
10191190 let mut compared = 0u32;
1020- let mut strip_hits = 0usize;
1021- let mut refused = 0u32;
1022- for bit_depth in [8u32, 10u32] {
1023- let duration = frames as f64 / 25.0;
1024- let source = format!("testsrc2=size={width}x{height}:duration={duration}:rate=25");
1025- let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
1026- let y4m = Command::new("ffmpeg")
1027- .args([
1028- "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
1029- "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
1030- ])
1031- .stdin(Stdio::null())
1032- .stdout(Stdio::piped())
1033- .stderr(Stdio::piped())
1034- .output()
1035- .expect("ffmpeg failed to run");
1036- assert!(
1037- y4m.status.success(),
1038- "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}",
1039- String::from_utf8_lossy(&y4m.stderr)
1040- );
1041- let depth_arg = format!("--bit-depth={bit_depth}");
1042- let input_depth_arg = format!("--input-bit-depth={bit_depth}");
1043- let mut child = Command::new(aomenc_path())
1044- .args([
1045- "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=62",
1046- // cpu-used >= 1 keeps libaom on 64x64 superblocks at this
1047- // size (`av1_select_sb_size`: speed >= 1 and <= 480p).
1048- "--cpu-used=4", "--threads=1", "--row-mt=0", "--kf-max-dist=1000",
1049- &depth_arg, &input_depth_arg,
1050- // The tool set every sibling inter gate pins; the edge
1051- // strip itself needs rect partitions left ON.
1052- "--enable-warped-motion=0", "--enable-obmc=0", "--enable-masked-comp=0",
1053- "--enable-interintra-comp=0", "--enable-onesided-comp=0",
1054- "--enable-interintra-wedge=0", "--enable-smooth-interintra=0",
1055- // Rect partitions stay ON: the edge strip is a FORCED
1056- // (gathered) HORZ at the boundary, but with rect coding
1057- // off the encoder answers that gathered symbol SPLIT every
1058- // time and the arm never fires (measured, r2).
1059- "--enable-ab-partitions=0", "--enable-1to4-partitions=0",
1060- "--enable-palette=0", "--enable-intrabc=0", "--enable-cdef=0",
1061- "--enable-restoration=0", "--enable-ref-frame-mvs=0",
1062- "--enable-tx-size-search=0", "--enable-filter-intra=0",
1063- "--enable-smooth-intra=0", "--enable-paeth-intra=0",
1064- "--enable-directional-intra=0", "--enable-angle-delta=0",
1065- "--enable-cfl-intra=0",
1066- // 16 is the smallest leaf this decoder codes rect strips
1067- // at; below it the sub-16 strip/1:4 refusals fire first
1068- // and the gate never reaches the edge arm.
1069- // 160 = two full superblock rows plus 32, so the forced
1070- // HORZ at the last row is a 64x32 -- the superblock-level
1071- // arm -- and a 32 floor keeps the run out of the sub-16
1072- // rect-strip gap another lane owns.
1073- "--min-partition-size=32", "--max-partition-size=64",
1074- "--obu", "-o", "-", "-",
1075- ])
1076- .stdin(Stdio::piped())
1077- .stdout(Stdio::piped())
1078- .stderr(Stdio::piped())
1079- .spawn()
1080- .expect("aomenc failed to start");
1081- child.stdin.take().expect("aomenc stdin").write_all(&y4m.stdout).expect("write y4m");
1082- let out = child.wait_with_output().expect("aomenc failed to run");
1083- assert!(out.status.success(), "aomenc refused: {}", String::from_utf8_lossy(&out.stderr));
1084- let stream = out.stdout;
1085-
1086- let before = crate::decode::edge_rect_strip_hits();
1087- let decoded = match decode_stream(&stream) {
1088- Ok(f) => f,
1089- Err(e) => {
1090- let msg = e.to_string();
1091- assert!(
1092- msg.contains("unsupported"),
1093- "{NAME}: {bit_depth}-bit failed outright, not a named refusal: {msg}"
1191+ let mut chroma_frames = 0usize;
1192+ for &(width, height) in sizes {
1193+ for bit_depth in [8u32, 10] {
1194+ for cq in [20u32, 32, 45] {
1195+ let (hits, luma_bad, chroma_bad) =
1196+ inter_edge_strip_attempt(NAME, width, height, bit_depth, cq, frames);
1197+ assert_eq!(
1198+ luma_bad, 0,
1199+ "{NAME}: {width}x{height} {bit_depth}-bit cq {cq}: {luma_bad} of {frames} \
1200+ frames differ from ffmpeg in LUMA (edge hits {hits:?})"
10941201 );
1095- eprintln!("{NAME}: {bit_depth}-bit REFUSED {msg}");
1096- refused += 1;
1097- continue;
1202+ // merge J, after lane-rectchroma2: the chroma residue this
1203+ // gate used to tolerate WAS this decoder's -- the per-axis
1204+ // narrow-block MC kernel decision read side x side instead
1205+ // of the block's true dims. Full-plane now.
1206+ assert_eq!(
1207+ chroma_bad, 0,
1208+ "{NAME}: {width}x{height} {bit_depth}-bit cq {cq}: {chroma_bad} of \
1209+ {frames} frames differ from ffmpeg in CHROMA (edge hits {hits:?})"
1210+ );
1211+ for (t, h) in totals.iter_mut().zip(hits) {
1212+ *t += h;
1213+ }
1214+ chroma_frames += chroma_bad;
1215+ compared += 1;
10981216 }
1099- };
1100- let reference = if bit_depth == 10 {
1101- ffmpeg_decode_sequence_10bit(&stream, width, height, frames)
1102- } else {
1103- ffmpeg_decode_sequence(&stream, width, height, frames)
1104- };
1105- assert_eq!(
1106- decoded.len(),
1107- reference.len(),
1108- "{NAME}: {bit_depth}-bit frame count"
1109- );
1110- for (i, (ours, theirs)) in decoded.iter().zip(&reference).enumerate() {
1111- let nd = |a: &[u16], b: &[u16]| a.iter().zip(b).filter(|(x, y)| x != y).count();
1112- assert_eq!(
1113- (nd(&ours.y, &theirs.y), nd(&ours.u, &theirs.u), nd(&ours.v, &theirs.v)),
1114- (0, 0, 0),
1115- "{NAME}: {bit_depth}-bit frame {i} differs from ffmpeg"
1116- );
11171217 }
1118- compared += 1;
1119- strip_hits += crate::decode::edge_rect_strip_hits() - before;
11201218 }
1121- assert!(compared > 0, "{NAME}: every attempt refused ({refused}) -- gate proved nothing");
1219+ // Every level x axis this recipe reaches must have fired on a COMPARED
1220+ // attempt. h32 (a bottom-edge HORZ at the 32 level) is not asserted: no
1221+ // recipe found in r1 makes libaom answer that gathered symbol HORZ
1222+ // (sweep ~/.cache/interedge-tmp/h32.sh, 3 sizes x 6 cq, all SPLIT); it
1223+ // is the transposed twin of v32, which this gate does fire.
11221224 assert!(
1123- strip_hits > 0,
1124- "{NAME}: {compared} attempts decoded pixel-exact but not one frame-edge half strip \
1125- fired -- the recipe no longer reaches the arm this gate exists for"
1225+ totals[0] > 0 && totals[1] > 0 && totals[3] > 0 && totals[4] > 0 && totals[5] > 0,
1226+ "{NAME}: {compared} attempts luma-exact but the edge strips did not all fire \
1227+ (h64,v64,h32,v32,h16,v16 = {totals:?}) -- the recipe no longer reaches the arms \
1228+ this gate exists for"
1229+ );
1230+ // CONTROL: a size with no frame-edge node anywhere (192x128, both axes
1231+ // 0 mod 64). It must be luma-exact with ZERO edge hits -- that is what
1232+ // makes the chroma exclusion above a statement about a foreign defect
1233+ // rather than about this lane's code.
1234+ let (chits, cluma, cchroma) = inter_edge_strip_attempt(NAME, 192, 128, 8, 32, frames);
1235+ assert_eq!(
1236+ (chits, cluma, cchroma),
1237+ ([0usize; 6], 0usize, 0usize),
1238+ "{NAME}: control 192x128 (no frame-edge node) must be pixel-exact with no edge hits"
1239+ );
1240+ eprintln!(
1241+ "{NAME}: {compared} attempts luma-exact over {} sizes, edge hits \
1242+ (h64,v64,h32,v32,h16,v16)={totals:?}, 0 refusals; chroma-only frames {chroma_frames} \
1243+ (control 192x128: hits {chits:?}, chroma-only frames {cchroma} -- foreign defect)",
1244+ sizes.len()
11261245 );
1127- eprintln!("{NAME}: {compared} attempts pixel-exact, edge_rect_strip_hits={strip_hits}, {refused} refusals");
11281246 }
11291247
11301248 /// lane-sb128 r4 GATE (was lane-oddh r2's refusal gate): the SAME real
@@ -2756,6 +2874,235 @@ mod tests {
27562874 }
27572875 }
27582876
2877+ /// lane-pal8 r1, the gate for a palette on a SQUARE 8x8 LEAF.
2878+ ///
2879+ /// `read_palette_mode_info` (decodemv.c:567) reads `palette_y_mode` for
2880+ /// every `DC_PRED` block whose `av1_get_palette_bsize_ctx`
2881+ /// (`num_pels_log2 - num_pels_log2[BLOCK_8X8]`, 0 at 8x8) exists, and
2882+ /// `av1_decode_palette_tokens` (decodeframe.c:1135, `av1_visit_palette`)
2883+ /// reads the colour-index map after the WHOLE mode-info read. Ours passed
2884+ /// `None`/`&[]` from [`decode::decode_leaf8`], reading the mode symbol off
2885+ /// CDF row 0 and refusing "a block that actually uses a palette (Y) --
2886+ /// reconstruction is out of scope" the moment it fired -- and at 8 bit
2887+ /// aomenc palettes SQUARE blocks, so with `--min-partition-size=8` every
2888+ /// 8-bit screen-content stream stopped there (lane-kf900 r4's measurement).
2889+ ///
2890+ /// Sweeps both bit depths x cq 30/40/55 x `--enable-tx-size-search` 0/1 x
2891+ /// two lavfi sources (+ a `--tile-columns=1` arm, per the neighbour-map
2892+ /// rule: the palette bands are per-mi and tile-guarded). Key frame only
2893+ /// (`--limit=1`): the inter frames of these recipes stop on OTHER lanes'
2894+ /// open refusals (8x8 inter leaf chroma mode, inter 1:4 partitions).
2895+ /// HARD-asserts the 8x8-leaf palette counter moved on the compared arms
2896+ /// and that no arm mismatched, in or out of scope.
2897+ #[test]
2898+ fn a_real_aomenc_palette_stream_with_8x8_leaves_decodes_pixel_exact() {
2899+ const NAME: &str = "a_real_aomenc_palette_stream_with_8x8_leaves_decodes_pixel_exact";
2900+ if !have_ffmpeg() {
2901+ eprintln!("SKIP {NAME}: no ffmpeg");
2902+ return;
2903+ }
2904+ if !have_aomenc() {
2905+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
2906+ return;
2907+ }
2908+ let (width, height) = (128usize, 128usize);
2909+ let (mut leaf8_total, mut fired_arms, mut compared, mut frames_compared) =
2910+ (0usize, 0u32, 0u32, 0usize);
2911+ let (mut out_of_scope, mut out_of_scope_mismatch, mut refusals) = (0u32, 0u32, 0u32);
2912+ let (mut sb_strip_total, mut sb_strip_arms) = (0usize, 0u32);
2913+ // The one palette shape this round did NOT lift (measured: lifting it
2914+ // mismatches -- see [`decode_block_rect64`]'s own comment).
2915+ let mut sb_strip_refusals = 0u32;
2916+ for src in ["testsrc2", "smptebars"] {
2917+ for depth in [8usize, 10usize] {
2918+ for cq in [30usize, 40, 55] {
2919+ for txs in [0usize, 1] {
2920+ for tiles in [0usize, 1] {
2921+ let arm = format!("{src}-{depth}bit-cq{cq}-txs{txs}-tc{tiles}");
2922+ let pix_fmt = if depth == 10 { "yuv420p10le" } else { "yuv420p" };
2923+ let size = format!("{src}=size={width}x{height}:rate=25");
2924+ let render = || {
2925+ let out = Command::new("ffmpeg")
2926+ .args([
2927+ "-v", "error", "-f", "lavfi", "-i", &size, "-t", "0.04",
2928+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f",
2929+ "yuv4mpegpipe", "-",
2930+ ])
2931+ .stdin(Stdio::null())
2932+ .stdout(Stdio::piped())
2933+ .stderr(Stdio::piped())
2934+ .output()
2935+ .expect("ffmpeg failed to run");
2936+ assert!(out.status.success(), "{NAME}: ffmpeg failed for {arm}");
2937+ out.stdout
2938+ };
2939+ let y4m_a = render();
2940+ let y4m_b = render();
2941+ assert_eq!(
2942+ y4m_a, y4m_b,
2943+ "{NAME}: {arm} must render byte-identical across two runs"
2944+ );
2945+ let y4m = y4m_a;
2946+ let depth_arg = format!("--bit-depth={depth}");
2947+ let input_depth_arg = format!("--input-bit-depth={depth}");
2948+ let cq_arg = format!("--cq-level={cq}");
2949+ let txs_arg = format!("--enable-tx-size-search={txs}");
2950+ let tiles_arg = format!("--tile-columns={tiles}");
2951+ let mut child = Command::new(aomenc_path())
2952+ .args([
2953+ "--codec=av1",
2954+ "--passes=1",
2955+ "--end-usage=q",
2956+ "--cpu-used=0",
2957+ "--threads=1",
2958+ "--row-mt=0",
2959+ "--lag-in-frames=0",
2960+ "--limit=1",
2961+ "--sb-size=64",
2962+ "--tune-content=screen",
2963+ "--enable-palette=1",
2964+ "--enable-intrabc=0",
2965+ "--min-partition-size=8",
2966+ "--enable-cdef=0",
2967+ "--enable-restoration=0",
2968+ "--loopfilter-control=0",
2969+ ])
2970+ // aomenc keeps the LAST occurrence of a repeated flag,
2971+ // so per-arm overrides go after the base recipe.
2972+ .args([&depth_arg, &input_depth_arg, &cq_arg, &txs_arg, &tiles_arg])
2973+ .args(["--obu", "-o", "-", "-"])
2974+ .stdin(Stdio::piped())
2975+ .stdout(Stdio::piped())
2976+ .stderr(Stdio::piped())
2977+ .spawn()
2978+ .expect("aomenc failed to start");
2979+ child
2980+ .stdin
2981+ .take()
2982+ .expect("aomenc stdin")
2983+ .write_all(&y4m)
2984+ .or_else(|e| match e.kind() {
2985+ std::io::ErrorKind::BrokenPipe => Ok(()),
2986+ _ => Err(e),
2987+ })
2988+ .expect("writing y4m to aomenc");
2989+ let out = child.wait_with_output().expect("aomenc failed to run");
2990+ assert!(
2991+ out.status.success(),
2992+ "{NAME}: aomenc refused {arm}: {}",
2993+ String::from_utf8_lossy(&out.stderr)
2994+ );
2995+ let stream = out.stdout;
2996+ decode::reset_palette_leaf8_hits();
2997+ decode::reset_palette_sb_strip_hits();
2998+ let decoded = decode_stream(&stream);
2999+ let leaf8 = decode::palette_leaf8_hits();
3000+ let sb_strip = decode::palette_sb_strip_hits();
3001+ leaf8_total += leaf8;
3002+ sb_strip_total += sb_strip;
3003+ match decoded {
3004+ Ok(frames) => {
3005+ assert!(!frames.is_empty(), "{NAME}: {arm} decoded no frame");
3006+ let theirs = if depth == 10 {
3007+ ffmpeg_decode_sequence_10bit(
3008+ &stream,
3009+ width,
3010+ height,
3011+ frames.len(),
3012+ )
3013+ } else {
3014+ ffmpeg_decode_sequence(&stream, width, height, frames.len())
3015+ };
3016+ assert_eq!(
3017+ frames.len(),
3018+ theirs.len(),
3019+ "{NAME}: {arm} frame count"
3020+ );
3021+ let mut same = true;
3022+ for (i, (ours, ref_f)) in
3023+ frames.iter().zip(theirs.iter()).enumerate()
3024+ {
3025+ let ok = ours.y == ref_f.y
3026+ && ours.u == ref_f.u
3027+ && ours.v == ref_f.v;
3028+ if !ok {
3029+ eprintln!("{NAME}: {arm} MISMATCH at frame {i}");
3030+ }
3031+ same &= ok;
3032+ frames_compared += 1;
3033+ }
3034+ compared += 1;
3035+ if sb_strip > 0 {
3036+ sb_strip_arms += 1;
3037+ assert!(
3038+ same,
3039+ "{NAME}: {arm} decoded {sb_strip} non-skip palette \
3040+ block(s) on a superblock-level strip and did not \
3041+ match ffmpeg"
3042+ );
3043+ }
3044+ if leaf8 > 0 || sb_strip > 0 {
3045+ fired_arms += 1;
3046+ assert!(
3047+ same,
3048+ "{NAME}: {arm} decoded {leaf8} 8x8-leaf palette \
3049+ block(s) and did not match ffmpeg"
3050+ );
3051+ } else {
3052+ out_of_scope += 1;
3053+ if !same {
3054+ out_of_scope_mismatch += 1;
3055+ }
3056+ }
3057+ eprintln!(
3058+ "{NAME}: {arm} {} frame(s), {leaf8} 8x8-leaf palette \
3059+ block(s), {sb_strip} superblock-strip palette \
3060+ block(s), exact={same}",
3061+ frames.len()
3062+ );
3063+ }
3064+ Err(e) => {
3065+ let msg = e.to_string();
3066+ assert!(
3067+ msg.contains("unsupported"),
3068+ "{NAME}: {arm} decode failed: {e}"
3069+ );
3070+ // Named, counted, never turned into a skip.
3071+ if msg.contains("superblock-level HORZ/VERT strip") {
3072+ sb_strip_refusals += 1;
3073+ }
3074+ eprintln!("{NAME}: {arm} REFUSED: {e}");
3075+ refusals += 1;
3076+ }
3077+ }
3078+ }
3079+ }
3080+ }
3081+ }
3082+ }
3083+ eprintln!(
3084+ "{NAME}: {leaf8_total} 8x8-leaf palette block(s) across {fired_arms} arm(s), \
3085+ {compared} arms compared ({frames_compared} frames), {sb_strip_total} \
3086+ superblock-strip palette block(s) across {sb_strip_arms} arm(s), \
3087+ {out_of_scope} out of scope ({out_of_scope_mismatch} mismatched), \
3088+ {refusals} refused ({sb_strip_refusals} superblock-strip palette)"
3089+ );
3090+ assert!(
3091+ leaf8_total > 0 && fired_arms > 0,
3092+ "{NAME}: gate is vacuous -- no compared arm decoded an 8x8-leaf palette block"
3093+ );
3094+ assert!(
3095+ sb_strip_refusals > 0,
3096+ "{NAME}: no arm reached the superblock-strip palette refusal -- the open residue \
3097+ this gate documents is no longer exercised"
3098+ );
3099+ assert_eq!(
3100+ out_of_scope_mismatch, 0,
3101+ "{NAME}: an out-of-scope arm mismatched ffmpeg -- a defect, never a skip"
3102+ );
3103+ assert!(frames_compared > 0, "{NAME}: no frame was compared pixel-exact");
3104+ }
3105+
27593106 /// lane-kf900 r5, the gate for the rect-strip `use_intrabc` read.
27603107 ///
27613108 /// `av1_allow_intrabc` is a FRAME-level test (`decodemv.c:892`,
@@ -2797,30 +3144,29 @@ mod tests {
27973144 let (width, height) = (256usize, 192usize);
27983145 // (arm, source, per-arm overrides AFTER the base recipe, expect_refusal,
27993146 // must_read_use_intrabc)
2800- let arms: [(&str, &str, &[&str], bool, bool); 3] = [
2801- (
2802- "testsrc2-screen-nopalette-cq50",
2803- "testsrc2=s=256x192:r=25",
2804- &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=0"],
2805- true,
2806- true,
2807- ),
2808- (
2809- "smptebars-screen-nopalette-cq45",
2810- "smptebars=size=256x192:rate=25",
2811- &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=0"],
2812- false,
2813- true,
2814- ),
2815- (
2816- "testsrc2-screen-nopalette-cq63",
2817- "testsrc2=s=256x192:r=25",
2818- &["--cq-level=63", "--enable-palette=0", "--enable-tx-size-search=1"],
2819- false,
2820- false,
2821- ),
3147+ const TS: &str = "testsrc2=s=256x192:r=25";
3148+ const SB: &str = "smptebars=size=256x192:rate=25";
3149+ // (arm, source, per-arm overrides AFTER the base recipe, expect_refusal,
3150+ // must_read_use_intrabc_on_a_rect_strip)
3151+ let arms: [(&str, &str, &[&str], bool, bool); 8] = [
3152+ ("testsrc2-cq50-txs0", TS, &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=0"], true, true),
3153+ ("smptebars-cq40-txs0", SB, &["--cq-level=40", "--enable-palette=0", "--enable-tx-size-search=0"], false, false),
3154+ ("smptebars-cq45-txs0", SB, &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=0"], false, true),
3155+ ("smptebars-cq45-txs1", SB, &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=1"], false, false),
3156+ ("smptebars-cq50-txs1", SB, &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=1"], false, false),
3157+ ("smptebars-cq55-txs0", SB, &["--cq-level=55", "--enable-palette=0", "--enable-tx-size-search=0"], false, false),
3158+ ("testsrc2-cq63-txs1", TS, &["--cq-level=63", "--enable-palette=0", "--enable-tx-size-search=1"], false, false),
3159+ // lane-kf900 r7: the 8x8-LEAF intrabc arm. Rect and 1:4
3160+ // partitions off (so no rect strip refuses first), palette on,
3161+ // `TxMode::Largest`: aomenc puts exactly one `use_intrabc` block
3162+ // on a `BLOCK_8X8` leaf here, the shape `decode_leaf8` decoded as
3163+ // ordinary intra before this round.
3164+ ("testsrc2-cq55-leaf8", TS, &["--cq-level=55", "--enable-palette=1", "--enable-tx-size-search=0", "--enable-rect-partitions=0", "--enable-1to4-partitions=0"], false, false),
28223165 ];
28233166 let (mut reads_total, mut refused, mut frames_compared) = (0usize, 0u32, 0usize);
3167+ let (mut blocks_total, mut fired_arms, mut out_of_scope, mut out_of_scope_mismatch) =
3168+ (0usize, 0u32, 0u32, 0u32);
3169+ let mut leaf8_total = 0usize;
28243170 for (arm, src, extra, expect_refusal, must_read) in &arms {
28253171 let render = || {
28263172 let out = Command::new("ffmpeg")
@@ -2861,6 +3207,9 @@ mod tests {
28613207 // `allow_screen_content_tools` (and with it the frame
28623208 // header's `allow_intrabc` bit) comes from here.
28633209 "--tune-content=screen",
3210+ // Spelled so `gate_coverage` counts the tool as exercised
3211+ // rather than defaulted (class `tool-disabled-in-every-gate`).
3212+ "--enable-intrabc=1",
28643213 ])
28653214 // aomenc keeps the LAST occurrence of a repeated flag.
28663215 .args(*extra)
@@ -2888,9 +3237,28 @@ mod tests {
28883237 );
28893238 let stream = out.stdout;
28903239 decode::reset_rect_intrabc_reads();
3240+ crate::decode::reset_intrabc_hits();
3241+ crate::decode::reset_leaf8_intrabc_hits();
28913242 let decoded = decode_stream(&stream);
28923243 let reads = decode::rect_intrabc_reads();
3244+ // Blocks that decoded `use_intrabc == 1` (square path), i.e. that
3245+ // read a DV and predicted from the current frame -- distinct from
3246+ // `reads`, which counts rect strips that merely READ the flag.
3247+ let blocks = crate::decode::intrabc_hits();
28933248 reads_total += reads;
3249+ blocks_total += blocks;
3250+ // The 8x8-leaf shape has its own counter: without it this gate's
3251+ // other arms (all rect/32x32 intrabc) would stay green while the
3252+ // leaf path decoded an intrabc block as ordinary intra (class
3253+ // `gate-blind-to-feature`).
3254+ let leaf8 = crate::decode::leaf8_intrabc_hits();
3255+ leaf8_total += leaf8;
3256+ if *arm == "testsrc2-cq55-leaf8" {
3257+ assert!(
3258+ leaf8 > 0,
3259+ "{NAME}: {arm} decoded no intrabc block at an 8x8 leaf -- the arm no longer exercises `decode_leaf8`'s intrabc path"
3260+ );
3261+ }
28943262 if *must_read {
28953263 assert!(
28963264 reads > 0,
@@ -2906,19 +3274,38 @@ mod tests {
29063274 reconstruction is not ported, it must refuse by name"
29073275 );
29083276 assert!(!frames.is_empty(), "{NAME}: {arm} decoded no frame");
2909- if *must_read {
2910- // Arm 1: entropy coverage only (see PIXEL RESIDUE above).
2911- eprintln!("{NAME}: {arm} decoded {} frame(s), {reads} rect use_intrabc reads", frames.len());
2912- continue;
2913- }
29143277 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frames.len());
29153278 assert_eq!(frames.len(), ffmpeg_frames.len(), "{NAME}: {arm} frame count");
3279+ // EVERY frame is compared; an arm whose decode never hit an
3280+ // intrabc block proves nothing about the DV/prediction path,
3281+ // so it is counted OUT OF SCOPE -- but a mismatch there is
3282+ // still a failure (`out_of_scope_mismatch == 0`), never a skip.
3283+ let mut same = true;
29163284 for (i, (ours, theirs)) in frames.iter().zip(ffmpeg_frames.iter()).enumerate() {
2917- assert_eq!(ours.y, theirs.y, "{NAME}: {arm} luma, frame {i}");
2918- assert_eq!(ours.u, theirs.u, "{NAME}: {arm} U, frame {i}");
2919- assert_eq!(ours.v, theirs.v, "{NAME}: {arm} V, frame {i}");
3285+ let ok = ours.y == theirs.y && ours.u == theirs.u && ours.v == theirs.v;
3286+ if !ok {
3287+ eprintln!("{NAME}: {arm} MISMATCH at frame {i}");
3288+ }
3289+ same &= ok;
29203290 frames_compared += 1;
29213291 }
3292+ if blocks > 0 {
3293+ fired_arms += 1;
3294+ assert!(
3295+ same,
3296+ "{NAME}: {arm} decoded {blocks} intrabc block(s) and did not match ffmpeg"
3297+ );
3298+ } else {
3299+ out_of_scope += 1;
3300+ if !same {
3301+ out_of_scope_mismatch += 1;
3302+ }
3303+ }
3304+ eprintln!(
3305+ "{NAME}: {arm} {} frame(s), {reads} rect use_intrabc reads, \
3306+ {blocks} intrabc block(s), exact={same}",
3307+ frames.len()
3308+ );
29223309 }
29233310 Err(e) => {
29243311 let msg = e.to_string();
@@ -2938,11 +3325,26 @@ mod tests {
29383325 }
29393326 eprintln!(
29403327 "{NAME}: {reads_total} rect-strip use_intrabc symbol(s) read, \
2941- {refused} refused by name, {frames_compared} frames compared pixel-exact"
3328+ {blocks_total} intrabc block(s) decoded across {fired_arms} arm(s), \
3329+ {refused} refused by name, {frames_compared} frames compared, \
3330+ {out_of_scope} out of scope ({out_of_scope_mismatch} mismatched)"
29423331 );
3332+ eprintln!("{NAME}: {leaf8_total} intrabc block(s) at an 8x8 leaf");
29433333 assert!(reads_total > 0, "{NAME}: gate is vacuous -- no arm read the symbol");
3334+ assert!(
3335+ leaf8_total > 0,
3336+ "{NAME}: no arm decoded an intrabc block at an 8x8 leaf -- lane-kf900 r7's fix is untested"
3337+ );
3338+ assert!(
3339+ blocks_total > 0 && fired_arms > 0,
3340+ "{NAME}: gate is vacuous -- no compared arm actually decoded an intrabc block"
3341+ );
29443342 assert_eq!(refused, 1, "{NAME}: expected exactly one named intrabc refusal");
29453343 assert!(frames_compared > 0, "{NAME}: no frame was compared pixel-exact");
3344+ assert_eq!(
3345+ out_of_scope_mismatch, 0,
3346+ "{NAME}: an arm without an intrabc block still mismatched ffmpeg"
3347+ );
29463348 }
29473349
29483350 /// lane-kf900 r4, the gate for the two lifted palette refusals ("a 1:4
@@ -2982,10 +3384,30 @@ mod tests {
29823384 "--enable-1to4-partitions=1",
29833385 "--min-partition-size=8",
29843386 ];
2985- let arms: [(&str, String, &[&str]); 3] = [
3387+ // lane-kf900 r6: arms 3-4 are the palette + `--enable-tx-size-search=1`
3388+ // shape whose neighbour palette lookup was SUB-granular -- a 16x8 strip
3389+ // pair shares one 16px cell, so strip 1 read strip 0's palette size and
3390+ // the colour cache came out short. Both were whole-frame wrong before
3391+ // the mi-granular fix (`$HOME/.cache/kf900-r6/sweep.log`: smptebars
3392+ // cq40/cq55 txs=1 pal=1 = DIFF).
3393+ let screen_txs: &[&str] = &[
3394+ "--tune-content=screen",
3395+ "--enable-palette=1",
3396+ "--enable-1to4-partitions=1",
3397+ "--min-partition-size=8",
3398+ "--max-partition-size=32",
3399+ "--sb-size=64",
3400+ "--enable-intrabc=1",
3401+ "--enable-tx-size-search=1",
3402+ ];
3403+ let cq40: Vec<&str> = screen_txs.iter().copied().chain(["--cq-level=40"]).collect();
3404+ let cq55: Vec<&str> = screen_txs.iter().copied().chain(["--cq-level=55"]).collect();
3405+ let arms: [(&str, String, &[&str]); 5] = [
29863406 ("testsrc2-pinned", "testsrc2=s=256x192:r=25".to_string(), &[]),
29873407 ("testsrc2-screen", "testsrc2=s=256x192:r=25".to_string(), screen),
29883408 ("smptebars-screen", "smptebars=size=256x192:rate=25".to_string(), screen),
3409+ ("smptebars-screen-txs-cq40", "smptebars=size=256x192:rate=25".to_string(), &cq40),
3410+ ("smptebars-screen-txs-cq55", "smptebars=size=256x192:rate=25".to_string(), &cq55),
29893411 ];
29903412 let (mut fired_arms, mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32, 0u32);
29913413 let mut refused = 0u32;
@@ -4042,13 +4464,22 @@ mod tests {
40424464 + crate::restoration::switchable_hits()
40434465 }
40444466
4045- /// lane-hbdgates r1: `--enable-rect-partitions=1 --enable-ab-partitions=1`
4046- /// at 10 bits, one intra stream, one counter per tool
4047- /// (`rect_partition_hits`, `partab_hits`) so a stream that only fired the
4048- /// rect arms cannot stand in for AB.
4467+ /// lane-reelckf2 r1: loop restoration on frame sizes whose LAST stripe is
4468+ /// partial, with 128-sample superblocks -- the two stripe shapes whose
4469+ /// boundary substitution is special (`filter_restoration_unit`: the first
4470+ /// stripe is 8 rows short and takes its above boundary from the frame's
4471+ /// own top rows, the last one is truncated and takes its below boundary
4472+ /// from the frame's own bottom row) had no gate at all: every earlier LR
4473+ /// size (192x128, 160x96) is a whole multiple of 64 rows and ran at
4474+ /// `--sb-size=64`. 152 = 2*64+24 and 216 = 3*64+24 both leave a 32-row
4475+ /// tail stripe, mirroring the 792-row 10-bit film that made this lane.
4476+ /// `lr_stripe0_hits`/`lr_last_stripe_hits` are hard-asserted per attempt
4477+ /// by [`ten_bit_tool_gate`], so an RD that picked RESTORE_NONE on either
4478+ /// stripe cannot pass.
40494479 #[test]
4050- fn a_real_aomenc_10bit_rect_and_ab_partitions_decode_pixel_exact() {
4051- const NAME: &str = "a_real_aomenc_10bit_rect_and_ab_partitions_decode_pixel_exact";
4480+ fn a_real_aomenc_10bit_partial_bottom_stripe_restoration_decodes_pixel_exact() {
4481+ const NAME: &str =
4482+ "a_real_aomenc_10bit_partial_bottom_stripe_restoration_decodes_pixel_exact";
40524483 if !have_ffmpeg() {
40534484 eprintln!("SKIP {NAME}: no ffmpeg");
40544485 return;
@@ -4057,12 +4488,69 @@ mod tests {
40574488 eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
40584489 return;
40594490 }
4060- // The 8-bit free-partition/AB recipe, verbatim, at 10 bits: AB
4061- // splits are an INTER dispatch here (intra-frame AB is still a named
4062- // refusal), so the stream needs alt-refs and 24 frames, not one key
4063- // frame.
4064- ten_bit_tool_gate(
4065- NAME,
4491+ // `--sb-size=128` goes in `extra`, which the helper appends AFTER its
4492+ // own `--sb-size=64` (aomenc keeps the LAST occurrence of a repeated
4493+ // flag, measured 2026-09-02); `--max-partition-size=32` keeps the 128
4494+ // root on SPLIT, the only 128-root partition decoded today.
4495+ for (width, height, cq) in [(256usize, 152usize, "15"), (384, 216, "15"), (256, 152, "25")]
4496+ {
4497+ ten_bit_tool_gate(
4498+ &format!("{NAME} {width}x{height} cq{cq}"),
4499+ width,
4500+ height,
4501+ 1,
4502+ &[
4503+ "--limit=1",
4504+ "--kf-max-dist=0",
4505+ &format!("--cq-level={cq}"),
4506+ "--sb-size=128",
4507+ "--enable-restoration=1",
4508+ "--enable-cdef=0",
4509+ "--enable-rect-partitions=0",
4510+ "--enable-ab-partitions=0",
4511+ "--enable-1to4-partitions=0",
4512+ "--enable-filter-intra=0",
4513+ "--enable-smooth-intra=0",
4514+ "--enable-paeth-intra=0",
4515+ "--enable-tx-size-search=0",
4516+ "--max-partition-size=32",
4517+ "--min-partition-size=16",
4518+ "--enable-palette=0",
4519+ "--enable-intrabc=0",
4520+ "--enable-cfl-intra=0",
4521+ "--enable-ref-frame-mvs=0",
4522+ ],
4523+ &LR_SEEDS,
4524+ &[
4525+ ("lr_hits", ten_bit_lr_hits),
4526+ ("lr_stripe0_hits", crate::restoration::lr_stripe0_hits),
4527+ ("lr_last_stripe_hits", crate::restoration::lr_last_stripe_hits),
4528+ ],
4529+ );
4530+ }
4531+ }
4532+
4533+ /// lane-hbdgates r1: `--enable-rect-partitions=1 --enable-ab-partitions=1`
4534+ /// at 10 bits, one intra stream, one counter per tool
4535+ /// (`rect_partition_hits`, `partab_hits`) so a stream that only fired the
4536+ /// rect arms cannot stand in for AB.
4537+ #[test]
4538+ fn a_real_aomenc_10bit_rect_and_ab_partitions_decode_pixel_exact() {
4539+ const NAME: &str = "a_real_aomenc_10bit_rect_and_ab_partitions_decode_pixel_exact";
4540+ if !have_ffmpeg() {
4541+ eprintln!("SKIP {NAME}: no ffmpeg");
4542+ return;
4543+ }
4544+ if !have_aomenc() {
4545+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
4546+ return;
4547+ }
4548+ // The 8-bit free-partition/AB recipe, verbatim, at 10 bits: AB
4549+ // splits are an INTER dispatch here (intra-frame AB is still a named
4550+ // refusal), so the stream needs alt-refs and 24 frames, not one key
4551+ // frame.
4552+ ten_bit_tool_gate(
4553+ NAME,
40664554 64,
40674555 64,
40684556 24,
@@ -5340,172 +5828,59 @@ mod tests {
53405828 );
53415829 }
53425830
5343- /// lane-intra14 r1's decisive gate: a real aomenc INTER sequence with
5344- /// `--enable-1to4-partitions=1`, whose fast-zooming content makes aomenc
5345- /// code INTRA blocks inside inter frames on 1:4 strip shapes (32x8/8x32 at
5346- /// the 32 level, 64x16/16x64 at the superblock level). Every such block
5347- /// was the named refusal "an intra-coded 1:4 (or other non-2:1) rect strip
5348- /// on the inter block path" until this round; they now decode through the
5349- /// same `decode_block_rect4` / `decode_block_rect64` readers the KEY FRAME
5350- /// 1:4 paths already prove, with only the mode-info read switched to
5351- /// `read_intra_block_mode_info` (libaom decodemv.c:1189).
5352- ///
5353- /// Hard-asserts `intra_rect4_strip_in_inter_hits` (0 = 64x16, 1 = 16x64,
5354- /// 2 = 32x8, 3 = 8x32) summed over the attempts that were actually
5355- /// pixel-compared, and every decode-order frame is compared. A decode that
5356- /// succeeds is ALWAYS pixel-compared (class
5357- /// [[gate-skips-on-its-own-failure]]); exhausting every attempt without a
5358- /// counted strip is a FAILURE, never a SKIP.
5359- #[test]
5360- // r3 re-measured this gate on the merged tree (main 48b35ab + lane-sqdrift
5361- // 7d498c0). The r2 blocker is GONE: the "pre-existing inter-frame pixel
5362- // defect" was lane-sqdrift's -- a 64x64 intra block in an inter frame
5363- // reading uv_mode off the CFL alphabet -- and with that fix all 40
5364- // mandelbrot attempts now decode PIXEL-EXACT (0 diff samples over
5365- // 40 streams x 8 frames x 3 planes, $HOME/.cache/intra14-r3-8bit.log).
5366- // The r2 counter reading "seed 52: 64x16=4 16x64=3" was produced by our own
5367- // desynced decode of a MISMATCHING stream (class counter-from-refused-
5368- // stream): on the correct decode that same stream fires 0/0/0/0.
5369- // The remaining blocker is a RECIPE gap, not a decoder gap: no source found
5370- // this round makes aomenc code an INTRA block on a 1:4 partition inside an
5371- // INTER frame -- see the MEASURED note in `intra_rect4_in_inter_gate`.
5372- #[ignore = "blocked on the recipe, not the decoder: no aomenc source found yet codes an INTRA block on a 1:4 partition inside an INTER frame (mandelbrot = intra-in-inter but zero 1:4 partitions; gradients = 1:4 partitions but all inter; blend = neither) -- see the MEASURED note in intra_rect4_in_inter_gate"]
5373- fn a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact() {
5374- intra_rect4_in_inter_gate(8);
5375- }
5376-
5377- /// The 10-bit arm (both of the user's films are `yuv420p10le`).
5378- #[test]
5379- // r3 re-measured this gate on the merged tree (main 48b35ab + lane-sqdrift
5380- // 7d498c0). The r2 blocker is GONE: the "pre-existing inter-frame pixel
5381- // defect" was lane-sqdrift's -- a 64x64 intra block in an inter frame
5382- // reading uv_mode off the CFL alphabet -- and with that fix all 40
5383- // mandelbrot attempts now decode PIXEL-EXACT (0 diff samples over
5384- // 40 streams x 8 frames x 3 planes, $HOME/.cache/intra14-r3-8bit.log).
5385- // The r2 counter reading "seed 52: 64x16=4 16x64=3" was produced by our own
5386- // desynced decode of a MISMATCHING stream (class counter-from-refused-
5387- // stream): on the correct decode that same stream fires 0/0/0/0.
5388- // The remaining blocker is a RECIPE gap, not a decoder gap: no source found
5389- // this round makes aomenc code an INTRA block on a 1:4 partition inside an
5390- // INTER frame -- see the MEASURED note in `intra_rect4_in_inter_gate`.
5391- #[ignore = "blocked on the recipe, not the decoder: no aomenc source found yet codes an INTRA block on a 1:4 partition inside an INTER frame (mandelbrot = intra-in-inter but zero 1:4 partitions; gradients = 1:4 partitions but all inter; blend = neither) -- see the MEASURED note in intra_rect4_in_inter_gate"]
5392- fn a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact_10bit() {
5393- intra_rect4_in_inter_gate(10);
5394- }
5395-
5396- /// lane-intra14 r4: the FILM witness for an intra block on a 1:4 partition
5397- /// inside an INTER frame -- `crates/ec-av1/fixtures/reelb_intra14_witness.obu`,
5398- /// 163057 bytes, sha256
5399- /// `0eff603bf1608e47faf5e6729670c4c77cf5c674dbad3a1533ac6660151fd90e`,
5400- /// two decode-order frames (key + first inter) cut from two INDEPENDENT
5401- /// `ffmpeg -ss 90 -t 2 -i <3840x1608 10-bit AV1 HDR10 mkv> -c:v copy -f obu`
5402- /// runs that hashed identically.
5403- ///
5404- /// MEASURED (r4, 27 two-second segments of that film at ss 0..6000, probe
5405- /// logs in the report): no aomenc recipe reaches this shape and only ONE
5406- /// class of stream does -- the film's own inter frames. Decode-order frame
5407- /// 1 of this fixture codes 3 intra 16x64 strips (`intra_rect4_in_inter`
5408- /// 16x64=3, zero when the fixture is truncated to the key frame alone), so
5409- /// the counter attribution is pinned to that frame.
5410- ///
5411- /// It is `#[ignore]`d for exactly ONE reason, and not this lane's shape:
5412- /// that same frame stops at a SIBLING refusal, "a split intra strip whose
5413- /// transform unit is 64x32 (no luma coefficient tables for that shape
5414- /// here)". The moment TX_64X32/TX_32X64 luma coefficient tables land, drop
5415- /// the `#[ignore]` -- everything else this gate needs (the reader, the
5416- /// counter, the two-frame pixel compare) is in place and runs.
5417- #[test]
5418- #[ignore = "blocked on a SIBLING refusal, not on this lane: the film frame that carries the intra 1:4 strips (16x64=3) stops at \"a split intra strip whose transform unit is 64x32 (no luma coefficient tables for that shape here)\" -- un-ignore when the 64x32/32x64 luma coefficient tables land"]
5419- fn a_10bit_film_inter_frame_with_intra_1to4_strips_decodes_pixel_exact() {
5420- const NAME: &str = "a_10bit_film_inter_frame_with_intra_1to4_strips_decodes_pixel_exact";
5421- if !have_ffmpeg() {
5422- eprintln!("SKIP {NAME}: no ffmpeg");
5423- return;
5424- }
5425- let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
5426- .join("fixtures/reelb_intra14_witness.obu");
5427- let stream = std::fs::read(&path)
5428- .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
5429- let (width, height) = (3840usize, 1608usize);
5430- let before = intra_rect4_in_inter_counters();
5431- let frames = match decode_stream(&stream) {
5432- Ok(frames) => frames,
5433- Err(e) => panic!("{NAME}: decode_stream refused: {e}"),
5434- };
5435- let now = intra_rect4_in_inter_counters();
5436- let fired = (now.0 - before.0) + (now.1 - before.1) + (now.2 - before.2) + (now.3 - before.3);
5437- assert!(
5438- fired > 0,
5439- "{NAME}: zero intra 1:4 strips in an inter frame (64x16/16x64/32x8/8x32 = \
5440- {}/{}/{}/{}) -- the fixture stopped carrying the shape this gate exists for",
5441- now.0 - before.0,
5442- now.1 - before.1,
5443- now.2 - before.2,
5444- now.3 - before.3
5445- );
5446- assert_eq!(frames.len(), 2, "{NAME}: key frame + one inter frame");
5447- assert_eq!((frames[0].width, frames[0].height), (width, height));
5448- let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len());
5449- for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
5450- assert_eq!(ours.y, theirs.y, "{NAME}: frame {i} luma vs ffmpeg");
5451- assert_eq!(ours.u, theirs.u, "{NAME}: frame {i} U vs ffmpeg");
5452- assert_eq!(ours.v, theirs.v, "{NAME}: frame {i} V vs ffmpeg");
5453- }
5454- eprintln!("{NAME}: {fired} intra 1:4 strips in an inter frame, both frames pixel-exact");
5455- }
5456-
5457- fn intra_rect4_in_inter_gate(bit_depth: u32) {
5458- const NAME: &str =
5459- "a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact";
5831+ fn tx_select_inter_gate(bit_depth: u32) {
54605832 if !have_ffmpeg() {
5461- eprintln!("SKIP {NAME}: no ffmpeg");
5833+ eprintln!(
5834+ "SKIP a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact: no ffmpeg"
5835+ );
54625836 return;
54635837 }
54645838 if !have_aomenc() {
5465- eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
5839+ eprintln!(
5840+ "SKIP a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact: no aomenc at {}",
5841+ aomenc_path().display()
5842+ );
54665843 return;
54675844 }
5468- let (width, height, frame_count) = (192usize, 128usize, 8usize);
5469- let mut refusals: Vec<String> = Vec::new();
5845+ let (width, height, frame_count) = (64usize, 64usize, 4usize);
5846+ let mut refusals = Vec::new();
54705847 let mut uncounted_exact = 0u32;
5471- let mut compared = 0u32;
5472- let mut shapes = [0usize; 4];
54735848 for attempt in 0..40u32 {
54745849 let seed = 42 + attempt;
5475- // Same source class as the 2:1 sibling gate: a FAST mandelbrot
5476- // zoom (`end_scale`/`end_pts`) so consecutive frames share almost
5477- // no content and aomenc's RD codes blocks INTRA inside INTER
5478- // frames, with `--kf-min-dist=1000` forbidding a new key frame.
5479- // MEASURED (r3, $HOME/.cache/intra14-r3-*.log; the per-attempt
5480- // "intra14 probe" line below prints the raw counters): the two
5481- // ingredients this gate needs come from DIFFERENT sources.
5482- // * the mandelbrot zoom this gate used through r2 makes aomenc
5483- // code intra blocks inside inter frames (589 2:1 intra strips
5484- // over 40 streams) but yields ZERO 1:4 partitions of any kind
5485- // (`sb_rect4_*`/`rect4_32_*` all 0, at min-partition-size 32
5486- // AND 16, cpu 0..4, with every intra tool enabled);
5487- // * `gradients` (the source the repo's PROVEN 1:4 gates use)
5488- // yields 1:4 partitions (sb_rect4 h=4 v=16) but aomenc codes
5489- // every one of them INTER;
5490- // * blending the two loses the 1:4 partitions again (0/0) while
5491- // keeping the intra strips (683).
5492- // `gradients` is kept here as the closest recipe: it is the only
5493- // one of the three that reaches a 1:4 partition at all.
5494- // Odd attempts render it transposed so HORZ_4 and VERT_4 are both
5495- // sampled (class scan-weights-cross-axis).
5496- let source = if attempt % 2 == 0 {
5497- gradients_source(seed, width, height, "duration=0.32:rate=25")
5498- } else {
5499- format!(
5500- "{},transpose=1",
5501- gradients_source(seed, height, width, "duration=0.32:rate=25")
5502- )
5503- };
5850+ // Detail is what makes aomenc's RD prefer a split transform; a
5851+ // flat gradient resolves every `txfm_split` to 0. `mandelbrot`'s
5852+ // fractal boundary is the same source the sibling intra tx-select
5853+ // gate uses, at a different `start_scale` per attempt.
5854+ let source = format!(
5855+ "mandelbrot=size=64x64:start_scale={}:rate=25",
5856+ 5.0 - f64::from(attempt) * 0.06
5857+ );
55045858 let y4m = Command::new("ffmpeg")
55055859 .args([
5506- "-v", "error", "-f", "lavfi", "-i", &source, "-vf", "hue=s=0", "-pix_fmt",
5860+ "-v",
5861+ "error",
5862+ "-f",
5863+ "lavfi",
5864+ "-i",
5865+ &source,
5866+ // Desaturated chroma: `uv_mode` stays DC_PRED, so the
5867+ // still-refused directional-chroma gap never fires and
5868+ // luma detail alone drives the transform split.
5869+ "-vf",
5870+ "hue=s=0",
5871+ "-pix_fmt",
55075872 if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" },
5508- "-strict", "-1", "-t", "0.32", "-f", "yuv4mpegpipe", "-strict", "-1", "-",
5873+ // y4m carries no official 10-bit tag; ffmpeg writes one
5874+ // only under `-strict -1` (a no-op at 8 bit).
5875+ "-strict",
5876+ "-1",
5877+ "-t",
5878+ "0.16",
5879+ "-f",
5880+ "yuv4mpegpipe",
5881+ "-strict",
5882+ "-1",
5883+ "-",
55095884 ])
55105885 .stdin(Stdio::null())
55115886 .stdout(Stdio::piped())
@@ -5522,45 +5897,19 @@ mod tests {
55225897 } else {
55235898 &[]
55245899 };
5525- // MEASURED (r1, 40 attempts): `--cpu-used=0` makes aomenc pick
5526- // 128x128 superblocks on this frame size, which decode_stream
5527- // refuses by name, so the preset sweep starts at 1.
5528- let cpu = format!("--cpu-used={}", attempt % 2);
5529- // The higher the quantiser the more 1:4 intra strips inside inter
5530- // frames, so the sweep walks cq 63 first.
5531- let cq = format!("--cq-level={}", [63u32, 55, 45, 35][(attempt / 4) as usize % 4]);
55325900 let mut child = Command::new(aomenc_path())
55335901 .args(depth_args)
5534- .arg(&cpu)
5535- .arg(&cq)
55365902 .args([
5537- // Every flag spelled exactly once (class
5538- // [[aomenc-last-flag-wins]]). These are what the gate is
5539- // about: 1:4 partitions ON, min size 16 so the 16x16-level
5540- // 1:4 (refused elsewhere) is out of reach.
5541- "--sb-size=64",
5542- "--enable-rect-partitions=1",
5543- "--enable-1to4-partitions=1",
5544- // MEASURED (r1): at `--min-partition-size=16` aomenc codes
5545- // 16x16-level 1:4 partitions (16x4/4x16 strips), which the
5546- // inter partition path refuses by name (another lane's
5547- // surface) in 12/40 attempts. 32 keeps this gate's two
5548- // reachable levels -- the 32-level 32x8/8x32 and the
5549- // superblock-level 64x16/16x64 -- and nothing else.
5550- "--min-partition-size=16",
5551- "--max-partition-size=64",
5552- // MEASURED (r1): with tx-size search ON, 8/40 attempts stop
5553- // at the 2:1 strip's own split-tx refusal (merge-cross-product,
5554- // another lane's surface) before a 1:4 strip is reached.
5555- "--enable-tx-size-search=0",
5556- "--enable-filter-intra=1",
5557- "--enable-intra-edge-filter=1",
5903+ // lane-defon r1: explicit on-value (aomenc keeps the FIRST
5904+ // occurrence, so overrides go before the base list).
5905+ "--enable-tx-size-search=1",
55585906 "--codec=av1",
55595907 "--passes=1",
55605908 "--end-usage=q",
5909+ "--cq-level=55",
5910+ "--cpu-used=0",
55615911 "--lag-in-frames=0",
55625912 "--auto-alt-ref=0",
5563- "--kf-min-dist=1000",
55645913 "--kf-max-dist=1000",
55655914 "--threads=1",
55665915 "--row-mt=0",
@@ -5574,276 +5923,26 @@ mod tests {
55745923 "--enable-onesided-comp=0",
55755924 "--enable-interintra-wedge=0",
55765925 "--enable-smooth-interintra=0",
5926+ "--enable-rect-partitions=0",
55775927 "--enable-ab-partitions=0",
5578- "--enable-smooth-intra=1",
5579- "--enable-paeth-intra=1",
5580- "--enable-directional-intra=1",
5581- "--enable-angle-delta=1",
5928+ "--enable-1to4-partitions=0",
5929+ "--enable-filter-intra=0",
5930+ "--enable-smooth-intra=0",
5931+ "--enable-paeth-intra=0",
5932+ "--enable-directional-intra=0",
5933+ "--enable-angle-delta=0",
5934+ // DELIBERATELY ABSENT: --enable-tx-size-search=0.
55825935 "--enable-cdef=0",
55835936 "--enable-restoration=0",
5584- // Ledger dead-end (lane-r14): a NEW gate spelling
5585- // `--enable-cfl-intra=1` retires that tool from
5586- // `NEVER_EXERCISED_8BIT` on the flag alone while no CfL
5587- // hit counter exists to assert -- so it stays 0 here.
5588- // Palette stays 0 for the same class of reason: this arm
5589- // refuses a screen-content frame whole, so a palette flag
5590- // would buy no coverage.
5937+ "--max-partition-size=32",
5938+ // Sub-16 inter partitions are a separate named refusal
5939+ // (this decoder codes no inter block below 16x16 through
5940+ // the square path this gate drives), and detailed content
5941+ // makes aomenc's RD reach for them on nearly every seed.
5942+ "--min-partition-size=16",
55915943 "--enable-palette=0",
55925944 "--enable-intrabc=0",
5593- "--enable-cfl-intra=1",
5594- "--enable-ref-frame-mvs=0",
5595- "--obu",
5596- "-o",
5597- "-",
5598- "-",
5599- ])
5600- .stdin(Stdio::piped())
5601- .stdout(Stdio::piped())
5602- .stderr(Stdio::piped())
5603- .spawn()
5604- .expect("aomenc failed to start");
5605- child
5606- .stdin
5607- .take()
5608- .expect("aomenc stdin")
5609- .write_all(&y4m.stdout)
5610- .expect("writing y4m to aomenc");
5611- let out = child.wait_with_output().expect("aomenc failed to run");
5612- assert!(
5613- out.status.success(),
5614- "aomenc refused the fixture: {}",
5615- String::from_utf8_lossy(&out.stderr)
5616- );
5617- let stream = out.stdout;
5618- let before: Vec<usize> =
5619- (0..4).map(decode::intra_rect4_strip_in_inter_hits).collect();
5620- let frames = match decode_stream(&stream) {
5621- Ok(frames) => frames,
5622- Err(e) => {
5623- let msg = e.to_string();
5624- assert!(
5625- msg.contains("unsupported"),
5626- "intra-1:4-in-inter decode failed outright (seed {seed}): {msg}"
5627- );
5628- refusals.push(format!("seed {seed} {cpu} {cq}: {msg}"));
5629- continue;
5630- }
5631- };
5632- let delta: Vec<usize> = (0..4)
5633- .map(|k| decode::intra_rect4_strip_in_inter_hits(k) - before[k])
5634- .collect();
5635- let ffmpeg_frames = if bit_depth == 10 {
5636- ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
5637- } else {
5638- ffmpeg_decode_sequence(&stream, width, height, frame_count)
5639- };
5640- assert_eq!(frames.len(), frame_count);
5641- eprintln!(
5642- "intra14 gate {bit_depth}-bit seed={seed} {cpu} {cq}: intra 1:4 strips in inter \
5643- frames 64x16={} 16x64={} 32x8={} 8x32={}",
5644- delta[0], delta[1], delta[2], delta[3]
5645- );
5646- eprintln!(
5647- "intra14 probe seed={seed}: sb_rect4 h={} v={} | rect4_32 h={} v={} hi={} vi={} | intra_rect h={:?}",
5648- crate::decode::sb_rect4_horz_hits(),
5649- crate::decode::sb_rect4_vert_hits(),
5650- crate::decode::rect4_32_horz_hits(),
5651- crate::decode::rect4_32_vert_hits(),
5652- crate::decode::rect4_32_horz_inter_hits(),
5653- crate::decode::rect4_32_vert_inter_hits(),
5654- (0..3).map(crate::decode::intra_rect_strip_in_inter_hits).collect::<Vec<_>>(),
5655- );
5656- for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
5657- for (plane, (g, w)) in [
5658- ("Y", (&got.y, &want.y)),
5659- ("U", (&got.u, &want.u)),
5660- ("V", (&got.v, &want.v)),
5661- ] {
5662- let stride = if plane == "Y" { width } else { width / 2 };
5663- if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) {
5664- let maxd = g
5665- .iter()
5666- .zip(w.iter())
5667- .map(|(a, b)| i32::from(*a).abs_diff(i32::from(*b)))
5668- .max()
5669- .unwrap_or(0);
5670- eprintln!(
5671- "intra14 gate {bit_depth}-bit seed={seed}: frame {i} {plane} first \
5672- diff at ({}, {}) got {} want {} ({} samples differ, max |d|={maxd})",
5673- at % stride,
5674- at / stride,
5675- g[at],
5676- w[at],
5677- g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(),
5678- );
5679- }
5680- assert_eq!(g, w, "{plane} vs ffmpeg (seed {seed}, frame {i})");
5681- }
5682- }
5683- compared += 1;
5684- if delta.iter().all(|d| *d == 0) {
5685- uncounted_exact += 1;
5686- refusals.push(format!(
5687- "seed {seed} {cpu} {cq}: decoded and pixel-compared, but no intra 1:4 strip on \
5688- the inter path"
5689- ));
5690- }
5691- for k in 0..4 {
5692- shapes[k] += delta[k];
5693- }
5694- // Both LEVELS (32 and 64) is the bar; orientation is whichever the
5695- // encoder picks.
5696- if shapes[0] + shapes[1] > 0 && shapes[2] + shapes[3] > 0 {
5697- break;
5698- }
5699- }
5700- gate_buckets(
5701- NAME,
5702- compared - uncounted_exact,
5703- uncounted_exact,
5704- refusals.len() - uncounted_exact as usize,
5705- );
5706- eprintln!(
5707- "{NAME} ({bit_depth}-bit): compared {compared} streams, intra 1:4 strips in inter \
5708- frames: 64x16={} 16x64={} 32x8={} 8x32={}; refusals:\n{}",
5709- shapes[0],
5710- shapes[1],
5711- shapes[2],
5712- shapes[3],
5713- refusals.join("\n")
5714- );
5715- assert!(
5716- compared > 0,
5717- "{NAME} ({bit_depth}-bit): every attempt hit a named refusal -- nothing was \
5718- pixel-compared:\n{}",
5719- refusals.join("\n")
5720- );
5721- assert!(
5722- shapes[2] + shapes[3] > 0,
5723- "{NAME} ({bit_depth}-bit): no 32-level intra 1:4 strip (32x8/8x32) fired over \
5724- {compared} compared streams (64x16={} 16x64={} 32x8={} 8x32={})",
5725- shapes[0],
5726- shapes[1],
5727- shapes[2],
5728- shapes[3]
5729- );
5730- }
5731-
5732- fn tx_select_inter_gate(bit_depth: u32) {
5733- if !have_ffmpeg() {
5734- eprintln!(
5735- "SKIP a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact: no ffmpeg"
5736- );
5737- return;
5738- }
5739- if !have_aomenc() {
5740- eprintln!(
5741- "SKIP a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact: no aomenc at {}",
5742- aomenc_path().display()
5743- );
5744- return;
5745- }
5746- let (width, height, frame_count) = (64usize, 64usize, 4usize);
5747- let mut refusals = Vec::new();
5748- let mut uncounted_exact = 0u32;
5749- for attempt in 0..40u32 {
5750- let seed = 42 + attempt;
5751- // Detail is what makes aomenc's RD prefer a split transform; a
5752- // flat gradient resolves every `txfm_split` to 0. `mandelbrot`'s
5753- // fractal boundary is the same source the sibling intra tx-select
5754- // gate uses, at a different `start_scale` per attempt.
5755- let source = format!(
5756- "mandelbrot=size=64x64:start_scale={}:rate=25",
5757- 5.0 - f64::from(attempt) * 0.06
5758- );
5759- let y4m = Command::new("ffmpeg")
5760- .args([
5761- "-v",
5762- "error",
5763- "-f",
5764- "lavfi",
5765- "-i",
5766- &source,
5767- // Desaturated chroma: `uv_mode` stays DC_PRED, so the
5768- // still-refused directional-chroma gap never fires and
5769- // luma detail alone drives the transform split.
5770- "-vf",
5771- "hue=s=0",
5772- "-pix_fmt",
5773- if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" },
5774- // y4m carries no official 10-bit tag; ffmpeg writes one
5775- // only under `-strict -1` (a no-op at 8 bit).
5776- "-strict",
5777- "-1",
5778- "-t",
5779- "0.16",
5780- "-f",
5781- "yuv4mpegpipe",
5782- "-strict",
5783- "-1",
5784- "-",
5785- ])
5786- .stdin(Stdio::null())
5787- .stdout(Stdio::piped())
5788- .stderr(Stdio::piped())
5789- .output()
5790- .expect("ffmpeg failed to run");
5791- assert!(
5792- y4m.status.success(),
5793- "ffmpeg fixture: {}",
5794- String::from_utf8_lossy(&y4m.stderr)
5795- );
5796- let depth_args: &[&str] = if bit_depth == 10 {
5797- &["-b", "10", "--input-bit-depth=10"]
5798- } else {
5799- &[]
5800- };
5801- let mut child = Command::new(aomenc_path())
5802- .args(depth_args)
5803- .args([
5804- // lane-defon r1: explicit on-value (aomenc keeps the FIRST
5805- // occurrence, so overrides go before the base list).
5806- "--enable-tx-size-search=1",
5807- "--codec=av1",
5808- "--passes=1",
5809- "--end-usage=q",
5810- "--cq-level=55",
5811- "--cpu-used=0",
5812- "--lag-in-frames=0",
5813- "--auto-alt-ref=0",
5814- "--kf-max-dist=1000",
5815- "--threads=1",
5816- "--row-mt=0",
5817- "--enable-order-hint=0",
5818- "--enable-warped-motion=0",
5819- "--enable-obmc=0",
5820- "--enable-masked-comp=0",
5821- "--enable-interintra-comp=0",
5822- "--enable-dist-wtd-comp=0",
5823- "--enable-diff-wtd-comp=0",
5824- "--enable-onesided-comp=0",
5825- "--enable-interintra-wedge=0",
5826- "--enable-smooth-interintra=0",
5827- "--enable-rect-partitions=0",
5828- "--enable-ab-partitions=0",
5829- "--enable-1to4-partitions=0",
5830- "--enable-filter-intra=0",
5831- "--enable-smooth-intra=0",
5832- "--enable-paeth-intra=0",
5833- "--enable-directional-intra=0",
5834- "--enable-angle-delta=0",
5835- // DELIBERATELY ABSENT: --enable-tx-size-search=0.
5836- "--enable-cdef=0",
5837- "--enable-restoration=0",
5838- "--max-partition-size=32",
5839- // Sub-16 inter partitions are a separate named refusal
5840- // (this decoder codes no inter block below 16x16 through
5841- // the square path this gate drives), and detailed content
5842- // makes aomenc's RD reach for them on nearly every seed.
5843- "--min-partition-size=16",
5844- "--enable-palette=0",
5845- "--enable-intrabc=0",
5846- "--enable-cfl-intra=0",
5945+ "--enable-cfl-intra=0",
58475946 "--enable-ref-frame-mvs=0",
58485947 "--obu",
58495948 "-o",
@@ -7014,16 +7113,301 @@ mod tests {
70147113 }
70157114
70167115
7017- /// lane-chroma r2 stage 1: a real aomenc key frame with
7018- /// `--enable-smooth-intra=1` (opposite of every sibling recipe's `=0`)
7019- /// and `--enable-paeth-intra=0` -- paeth chroma stays off so the still-
7020- /// refused smooth/paeth `uv_mode` (round-2, unrelated to this gate) never
7021- /// fires; smooth *luma* neighbours are exactly what this gate wants to
7022- /// exercise, proving [`decode::smooth_luma_hits`] actually landed a
7023- /// directional block next to a smooth-predicted one and decoded
7024- /// pixel-exact (the [`PlaneBuf::reconstruct`] `smooth_neighbor` fix).
7116+ /// lane-leaf8tx r1: the refusal this round lifts on an INTRA 8x8 leaf
7117+ /// inside an INTER frame -- a nonzero luma `angle_delta_y` on it
7118+ /// (`--enable-angle-delta=1`,
7119+ /// `av1_use_angle_delta(BLOCK_8X8)`). Both counters are per-attempt
7120+ /// deltas on an attempt that decoded to the end and is pixel-compared
7121+ /// (class [[counter-from-refused-stream]]); a decode error or a mismatch
7122+ /// is a FAILURE, never a SKIP.
70257123 #[test]
7026- fn a_real_aomenc_stream_with_smooth_luma_neighbour_decodes_pixel_exact() {
7124+ fn a_real_aomenc_inter_sequence_with_an_angle_delta_8x8_intra_leaf_decodes_pixel_exact() {
7125+ tx_split_angle_in_inter8_gate(8);
7126+ }
7127+
7128+ /// The 10-bit arm (both of the user's films are `yuv420p10le`).
7129+ #[test]
7130+ fn a_real_aomenc_10bit_inter_sequence_with_an_angle_delta_8x8_intra_leaf_decodes_pixel_exact() {
7131+ tx_split_angle_in_inter8_gate(10);
7132+ }
7133+
7134+ fn tx_split_angle_in_inter8_gate(bit_depth: u32) {
7135+ let name = format!("tx_split_angle_in_inter8_gate({bit_depth})");
7136+ if !have_ffmpeg() {
7137+ eprintln!("SKIP {name}: no ffmpeg");
7138+ return;
7139+ }
7140+ if !have_aomenc() {
7141+ eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display());
7142+ return;
7143+ }
7144+ let (width, height, frame_count) = (192usize, 128usize, 6usize);
7145+ let mut refusals = Vec::new();
7146+ let mut uncounted_exact = 0u32;
7147+ let mut counted_exact = 0u32;
7148+ let mut totals = (0usize, 0usize);
7149+ for attempt in 0..30u32 {
7150+ let seed = 42 + attempt;
7151+ // Same zoom + hard-cut fractal source the sibling uv_mode gate
7152+ // uses (a cut is what makes aomenc code INTRA blocks inside an
7153+ // inter frame); `noise` carries an explicit seed (class
7154+ // [[seeded-fixture-not-reproducible]]).
7155+ let source = format!(
7156+ "mandelbrot=size={width}x{height}:start_scale={}:rate=25[a];\
7157+ mandelbrot=size={width}x{height}:start_scale={}:rate=25[b];\
7158+ [a][b]overlay=enable='gte(n,3)',noise=alls=12:allf=t+u:all_seed={seed}",
7159+ 5.0 - f64::from(attempt) * 0.06,
7160+ 0.9 + f64::from(attempt) * 0.11
7161+ );
7162+ let y4m = Command::new("ffmpeg")
7163+ .args([
7164+ "-v",
7165+ "error",
7166+ "-f",
7167+ "lavfi",
7168+ "-i",
7169+ &source,
7170+ "-pix_fmt",
7171+ if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" },
7172+ "-strict",
7173+ "-1",
7174+ "-t",
7175+ "0.24",
7176+ "-f",
7177+ "yuv4mpegpipe",
7178+ "-strict",
7179+ "-1",
7180+ "-",
7181+ ])
7182+ .stdin(Stdio::null())
7183+ .stdout(Stdio::piped())
7184+ .stderr(Stdio::piped())
7185+ .output()
7186+ .expect("ffmpeg failed to run");
7187+ assert!(
7188+ y4m.status.success(),
7189+ "ffmpeg fixture: {}",
7190+ String::from_utf8_lossy(&y4m.stderr)
7191+ );
7192+ let cq = format!("--cq-level={}", 12 + (attempt % 5) * 7);
7193+ let depth_args: &[&str] = if bit_depth == 10 {
7194+ &["-b", "10", "--input-bit-depth=10"]
7195+ } else {
7196+ &[]
7197+ };
7198+ // The y4m goes through a PID-keyed FILE, never aomenc's stdin
7199+ // (pipe deadlock, class [[gate-loader-slurps-whole-file]]).
7200+ let y4m_path = std::env::temp_dir().join(format!(
7201+ "ec-av1-leaf8tx-{}-{bit_depth}-{seed}.y4m",
7202+ std::process::id()
7203+ ));
7204+ std::fs::write(&y4m_path, &y4m.stdout).expect("writing the y4m fixture");
7205+ let child = Command::new(aomenc_path())
7206+ .args(depth_args)
7207+ .args([
7208+ "--codec=av1",
7209+ "--passes=1",
7210+ "--end-usage=q",
7211+ &cq,
7212+ "--cpu-used=0",
7213+ "--lag-in-frames=0",
7214+ "--auto-alt-ref=0",
7215+ "--kf-max-dist=9999",
7216+ "--kf-min-dist=9999",
7217+ "--threads=1",
7218+ "--row-mt=0",
7219+ "--tile-columns=0",
7220+ "--enable-order-hint=0",
7221+ "--enable-warped-motion=0",
7222+ "--enable-obmc=0",
7223+ "--enable-masked-comp=0",
7224+ "--enable-interintra-comp=0",
7225+ "--enable-dist-wtd-comp=0",
7226+ "--enable-diff-wtd-comp=0",
7227+ "--enable-onesided-comp=0",
7228+ "--enable-interintra-wedge=0",
7229+ "--enable-smooth-interintra=0",
7230+ "--enable-ab-partitions=0",
7231+ "--enable-1to4-partitions=0",
7232+ "--enable-cdef=0",
7233+ "--enable-restoration=0",
7234+ "--enable-palette=0",
7235+ "--enable-intrabc=0",
7236+ "--enable-ref-frame-mvs=0",
7237+ // Per-arm overrides LAST (aomenc keeps the last
7238+ // occurrence of a repeated --enable-* flag). Rect
7239+ // partitions stay off so the leaf's unrelated sub-16 rect
7240+ // inter refusal never fires.
7241+ "--enable-rect-partitions=0",
7242+ "--enable-tx-size-search=1",
7243+ "--enable-angle-delta=1",
7244+ "--enable-directional-intra=1",
7245+ "--min-partition-size=8",
7246+ "--max-partition-size=32",
7247+ "--obu",
7248+ "-o",
7249+ "-",
7250+ ])
7251+ // r1 diagnostic: EC_LEAF8TX_CONTROL=1 turns THIS lane's two
7252+ // tools back off (last occurrence of a repeated --enable-*
7253+ // wins), so any mismatch that survives is not this lane's.
7254+ .args(match std::env::var("EC_LEAF8TX_CONTROL").as_deref() {
7255+ Ok("angle") => vec!["--enable-tx-size-search=0", "--enable-angle-delta=1"],
7256+ Ok("tx") => vec!["--enable-tx-size-search=1", "--enable-angle-delta=0"],
7257+ Ok("tx8") => vec![
7258+ "--enable-tx-size-search=1",
7259+ "--enable-angle-delta=0",
7260+ "--max-partition-size=8",
7261+ ],
7262+ Ok(_) => vec!["--enable-tx-size-search=0", "--enable-angle-delta=0"],
7263+ // Shipped recipe (lane-leaf8tx r4): BOTH of this lane's
7264+ // tools on -- the tx_depth split at an 8x8 intra-in-inter
7265+ // leaf is what the lifted refusal covers, so
7266+ // `--enable-tx-size-search=1` must survive the per-arm
7267+ // override (aomenc keeps the LAST occurrence). Odd
7268+ // attempts also cap the partition at 8x8, the shape that
7269+ // produces the 2x2 TX_4X4 grid most often.
7270+ Err(_) => {
7271+ if attempt % 2 == 1 {
7272+ vec![
7273+ "--enable-tx-size-search=1",
7274+ "--enable-angle-delta=1",
7275+ "--max-partition-size=8",
7276+ ]
7277+ } else {
7278+ vec!["--enable-tx-size-search=1", "--enable-angle-delta=1"]
7279+ }
7280+ }
7281+ })
7282+ .arg(&y4m_path)
7283+ .stdin(Stdio::null())
7284+ .stdout(Stdio::piped())
7285+ .stderr(Stdio::piped())
7286+ .spawn()
7287+ .expect("aomenc failed to start");
7288+ let out = child.wait_with_output().expect("aomenc failed to run");
7289+ let _ = std::fs::remove_file(&y4m_path);
7290+ assert!(
7291+ out.status.success(),
7292+ "aomenc refused the fixture: {}",
7293+ String::from_utf8_lossy(&out.stderr)
7294+ );
7295+ let stream = out.stdout;
7296+ let before = (
7297+ decode::intra_in_inter_split_tx_hits()[0],
7298+ decode::intra_in_inter8_angle_delta_y_hits(),
7299+ );
7300+ let frames = match decode_stream(&stream) {
7301+ Ok(frames) => frames,
7302+ Err(e) => {
7303+ let msg = e.to_string();
7304+ assert!(
7305+ msg.contains("unsupported"),
7306+ "{name} decode failed outright (seed {seed}): {msg}"
7307+ );
7308+ refusals.push(format!("seed {seed}: {msg}"));
7309+ continue;
7310+ }
7311+ };
7312+ let now = (
7313+ decode::intra_in_inter_split_tx_hits()[0],
7314+ decode::intra_in_inter8_angle_delta_y_hits(),
7315+ );
7316+ let fired = (now.0 - before.0, now.1 - before.1);
7317+ totals = (totals.0 + fired.0, totals.1 + fired.1);
7318+ // Both lifted capabilities must fire on the SAME pixel-compared
7319+ // attempt.
7320+ let counted = fired.1 > 0;
7321+ if !counted {
7322+ uncounted_exact += 1;
7323+ refusals.push(format!(
7324+ "seed {seed}: decoded and pixel-compared, but split-tx {} / angle-delta {} \
7325+ 8x8 intra-in-inter leaves",
7326+ fired.0, fired.1
7327+ ));
7328+ }
7329+ let ffmpeg_frames = if bit_depth == 10 {
7330+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
7331+ } else {
7332+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
7333+ };
7334+ assert_eq!(frames.len(), frame_count);
7335+ eprintln!(
7336+ "{name} seed={seed} {cq}: 8x8 intra-in-inter leaves with tx_depth=1 {}, with a \
7337+ nonzero angle_delta_y {} (split-tx per size 8/16/32/64 {:?})",
7338+ fired.0,
7339+ fired.1,
7340+ decode::intra_in_inter_split_tx_hits()
7341+ );
7342+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7343+ for (plane, (g, w)) in [
7344+ ("Y", (&got.y, &want.y)),
7345+ ("U", (&got.u, &want.u)),
7346+ ("V", (&got.v, &want.v)),
7347+ ] {
7348+ let stride = if plane == "Y" { width } else { width / 2 };
7349+ if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) {
7350+ eprintln!(
7351+ "{name} seed={seed}: frame {i} {plane} first diff at ({}, {}) got {} \
7352+ want {} ({} samples differ)",
7353+ at % stride,
7354+ at / stride,
7355+ g[at],
7356+ w[at],
7357+ g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(),
7358+ );
7359+ }
7360+ }
7361+ }
7362+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7363+ assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (seed {seed})");
7364+ assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed})");
7365+ assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (seed {seed})");
7366+ }
7367+ if counted {
7368+ counted_exact += 1;
7369+ }
7370+ }
7371+ // lane-leaf8tx r4: continue-and-sweep -- every arm is encoded,
7372+ // decoded and pixel-compared on every plane of every decode-order
7373+ // frame above; the counters are asserted ONCE here. A decode error or
7374+ // a mismatch is a failure, never a SKIP, and `uncounted_exact`
7375+ // (decoded + compared but neither capability fired) is the
7376+ // out-of-scope-mismatch bucket that the sweep tolerates only while at
7377+ // least one attempt did fire.
7378+ gate_buckets(
7379+ &name,
7380+ counted_exact,
7381+ uncounted_exact,
7382+ refusals.len() - uncounted_exact as usize,
7383+ );
7384+ assert!(
7385+ totals.0 > 0,
7386+ "{name}: no decoded+compared attempt carried an 8x8 intra-in-inter leaf with \
7387+ tx_depth split to 4x4 (split-tx per size {:?}, angle-delta {}):\n{}",
7388+ decode::intra_in_inter_split_tx_hits(),
7389+ totals.1,
7390+ refusals.join("\n")
7391+ );
7392+ assert!(
7393+ totals.1 > 0,
7394+ "{name}: no decoded+compared attempt carried a nonzero angle_delta_y on an 8x8 \
7395+ intra-in-inter leaf (split-tx {}):\n{}",
7396+ totals.0,
7397+ refusals.join("\n")
7398+ );
7399+ }
7400+
7401+ /// lane-chroma r2 stage 1: a real aomenc key frame with
7402+ /// `--enable-smooth-intra=1` (opposite of every sibling recipe's `=0`)
7403+ /// and `--enable-paeth-intra=0` -- paeth chroma stays off so the still-
7404+ /// refused smooth/paeth `uv_mode` (round-2, unrelated to this gate) never
7405+ /// fires; smooth *luma* neighbours are exactly what this gate wants to
7406+ /// exercise, proving [`decode::smooth_luma_hits`] actually landed a
7407+ /// directional block next to a smooth-predicted one and decoded
7408+ /// pixel-exact (the [`PlaneBuf::reconstruct`] `smooth_neighbor` fix).
7409+ #[test]
7410+ fn a_real_aomenc_stream_with_smooth_luma_neighbour_decodes_pixel_exact() {
70277411 if !have_ffmpeg() {
70287412 eprintln!(
70297413 "SKIP a_real_aomenc_stream_with_smooth_luma_neighbour_decodes_pixel_exact: no ffmpeg"
@@ -8486,32 +8870,41 @@ mod tests {
84868870 }
84878871 }
84888872
8489- /// lane-sbrect10 r1: a 64x64 INTRA block inside an INTER frame, whose
8490- /// `uv_mode` alphabet libaom's `is_cfl_allowed` (`blockd.h`: `wide <= 32
8491- /// && high <= 32`) narrows to the 13-symbol NO-CFL table. Reading the
8492- /// 14-symbol CFL one produced the same `DC_PRED` value with the wrong
8493- /// interval narrowing, so the tile desynced from that block on and the
8494- /// frame decoded silently wrong (class `wrong-alphabet-same-value`; found
8495- /// as the "another shape" mismatch the superblock rect gate above had to
8496- /// park its 10-bit arm on).
8873+ /// lane-rectres r1: a 32x32-level 1:4 INTER strip (32x8 / 8x32) that codes
8874+ /// a REAL rectangular residual. THIS is the shape both 10-bit 3840x1608
8875+ /// film cuts and every measured 1080p offset stopped on -- six of six
8876+ /// `decode_probe` runs refused at "a non-skip rectangular (HORZ/VERT/
8877+ /// HORZ_B) strip needs rectangular residual coding" with `w=32 h=8` or
8878+ /// `w=8 h=32`, nothing else.
84978879 ///
8498- /// The counter `nocfl_uv_mode_hits` proves the shape fired in EVERY
8499- /// compared attempt, and every decode-order frame is compared against
8500- /// ffmpeg -- an attempt that mismatches fails, it never SKIPs.
8880+ /// `max_txsize_rect_lookup[BLOCK_32X8] == TX_32X8` codes all 256 of its
8881+ /// positions ([`TxbSet::LumaRect32x8Inter`]: `get_txsize_entropy_ctx` =
8882+ /// TX_16X16 so the coefficient tables are the luma-16 ones,
8883+ /// `txsize_log2_minus4` = 4 so `eob_pt` is the 256-position alphabet), and
8884+ /// unlike the INTRA twin it DOES code a `tx_type`:
8885+ /// `av1_get_ext_tx_set_type` at `tx_size_sqr_up == TX_32X32` is
8886+ /// `EXT_TX_SET_DCT_IDTX` for inter with or without `reduced_tx_set`, read
8887+ /// at the `txsize_sqr_map[TX_32X8] == TX_8X8` CDF row (class
8888+ /// table-indexed-by-raw-size: the coefficient tables follow the ADJUSTED
8889+ /// size, the `tx_type` row the SQUARE one -- they disagree here).
8890+ /// Its chroma pair is one 16x4 / 4x16 unit (`ss_size_lookup[BLOCK_32X8]`
8891+ /// = BLOCK_16X4, `Chroma8`'s tables, 64-position `eob_pt`), and a split
8892+ /// transform gives 16x8 / 8x16 leaves (`sub_tx_size_map[TX_32X8] ==
8893+ /// TX_16X8`) the rect var-tx path already reads.
85018894 ///
8502- /// lane-sbrect10 r2: with the half-random source below this gate also
8503- /// covers a SECOND defect it exposed at 10-bit cq 58/61 -- the compound
8504- /// MV stack's extension pass zero-filled the `comp_list` tail slots
8505- /// libaom fills with each side's GLOBAL MOTION vector
8506- /// (`combine_compound_candidates`, mvref_common.c:723-729). A compound
8507- /// block with no usable neighbour pair (frame top row, intra block to
8508- /// its left, empty temporal field) then took a `(0, 0)` predictor
8509- /// instead of the frame's translation: 32890/39907 wrong luma samples
8510- /// on decode-order frame 2 with the entropy stream still in sync.
8895+ /// `--enable-1to4-partitions=1 --min-partition-size=8
8896+ /// --max-partition-size=32 --enable-tx-size-search=1` (each spelled once,
8897+ /// last occurrence wins -- aomenc keeps the LAST `--enable-*`) is what
8898+ /// lets aomenc pick a 32x32-level HORZ_4 / VERT_4; the 8-pixel banded
8899+ /// translating source is what makes those strips the RD winner and keeps
8900+ /// them non-skip so the residual is really coded. Both orientations, 8-bit
8901+ /// AND 10-bit, every decode-order frame compared to ffmpeg on Y/U/V,
8902+ /// refusals counted (never SKIPped), attempts that carried no 32x8/8x32
8903+ /// residual unit counted separately and still required pixel-exact.
85118904 #[test]
8512- fn a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet() {
8905+ fn a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_codes_their_rect_residual() {
85138906 const NAME: &str =
8514- "a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet";
8907+ "a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_codes_their_rect_residual";
85158908 let _gate_lock = lock_gate_counters();
85168909 if !have_ffmpeg() {
85178910 eprintln!("SKIP {NAME}: no ffmpeg");
@@ -8521,32 +8914,253 @@ mod tests {
85218914 eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
85228915 return;
85238916 }
8524- let (width, height, frame_count) = (192usize, 128usize, 6usize);
8917+ let frame_count = 6usize;
8918+ let (mut proved_32x8, mut proved_8x32) = (0usize, 0usize);
8919+ let (mut fired_32x8, mut fired_8x32) = (0usize, 0usize);
85258920 for bit_depth in [8u32, 10u32] {
8526- let (mut named_refusals, mut matched, mut carried_none) = (0u32, 0u32, 0u32);
8527- let mut total_hits = 0usize;
8921+ let (mut named_refusals, mut compared, mut out_of_scope, mut oos_mismatch) =
8922+ (0u32, 0u32, 0u32, 0u32);
85288923 for attempt in 0..16u32 {
8529- // The sibling superblock-rect gate's own grid (its 10-bit
8530- // attempt 14 -- cq 61, horizontal split, motion step 12 -- is
8531- // the stream that exposed the defect); which superblock the RD
8532- // hands an intra 64x64 block moves with the quantiser and the
8533- // depth, so both orientations x four quantisers x two motion
8534- // steps run here too.
8535- let vertical_split = attempt % 2 == 1;
8536- let cq = [58, 52, 45, 61][(attempt / 2 % 4) as usize];
8537- let sp = 8 + (attempt / 8) * 4;
8538- // Half ramp, half deterministic pseudo-noise: the flat "200"
8539- // half of r1's source made aomenc code the right-hand
8540- // superblocks skip, so at 8 bit no >32 intra block ever
8541- // appeared (probed cq 45/52/58/61/63 = 0 hits). The textured
8542- // half forces intra above 32x32 in an inter frame at BOTH
8543- // depths, so both arms carry the shape.
8544- let geq = if vertical_split {
8545- format!(
8546- "if(lt(Y,64), 40+mod(floor((X+N*{sp})/32)*90,200), mod((X*7+Y*13+N*97)*31,256))"
8547- )
8924+ // Two orientations (the transposed pair a one-sided gate could
8925+ // never separate) x four quantisers x two motion steps.
8926+ let vertical = attempt % 2 == 1;
8927+ let (width, height) = (192usize, 128usize);
8928+ let cq = [48, 52, 56, 60][(attempt / 2 % 4) as usize];
8929+ let sp = 3 + (attempt / 8) * 4;
8930+ // 32-pixel bands, each translating at its OWN speed across the
8931+ // other axis: that is what makes aomenc's RD split a 32x32
8932+ // block into four 32x8 (or 8x32) strips with distinct motion
8933+ // vectors, and the texture inside a band is what keeps a strip
8934+ // non-skip. MEASURED (72-run recipe sweep, 192x128..256x192,
8935+ // cq 24..60, bands 8/16/32/64): only 32-pixel bands at cq >= 48
8936+ // make aomenc code a NON-SKIP one -- attempt 0 (cq 48,
8937+ // horizontal source) codes an 8x32 residual unit, attempt 7
8938+ // (cq 60, the transposed source) five 32x8 ones. Narrower
8939+ // bands give the same strips with `skip` set, which proves the
8940+ // partition symbol and nothing about the residual.
8941+ let geq = if vertical {
8942+ format!("128+62*sin((Y+N*({sp}+7*mod(floor(X/32),4)))/6)+28*sin(X/9)")
85488943 } else {
8549- format!(
8944+ format!("128+62*sin((X+N*({sp}+7*mod(floor(Y/32),4)))/6)+28*sin(Y/9)")
8945+ };
8946+ let duration = frame_count as f64 / 25.0;
8947+ let source = format!(
8948+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
8949+ geq=lum='{geq}',format=yuv420p"
8950+ );
8951+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
8952+ let y4m = Command::new("ffmpeg")
8953+ .args([
8954+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
8955+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
8956+ ])
8957+ .stdin(Stdio::null())
8958+ .stdout(Stdio::piped())
8959+ .stderr(Stdio::piped())
8960+ .output()
8961+ .expect("ffmpeg failed to run");
8962+ assert!(
8963+ y4m.status.success(),
8964+ "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}",
8965+ String::from_utf8_lossy(&y4m.stderr)
8966+ );
8967+ let cq_arg = format!("--cq-level={cq}");
8968+ let depth_arg = format!("--bit-depth={bit_depth}");
8969+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
8970+ let args: Vec<&str> = vec![
8971+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
8972+ "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
8973+ "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",
8974+ "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",
8975+ "--lag-in-frames=0",
8976+ // Per-arm overrides go LAST: aomenc keeps the last
8977+ // occurrence of a repeated --enable-* flag.
8978+ "--enable-tx64=0", "--enable-rect-partitions=1",
8979+ "--enable-ab-partitions=0", "--enable-1to4-partitions=1",
8980+ "--enable-tx-size-search=1",
8981+ "--enable-dual-filter=0", "--enable-obmc=0",
8982+ // aomenc's min-partition-size bounds the SMALLER side of a
8983+ // 1:4 strip, so 32x8 needs 8 (memory
8984+ // aomenc-min-partition-bounds-smaller-side).
8985+ "--min-partition-size=8", "--max-partition-size=32",
8986+ "--obu", "-o", "-", "-",
8987+ ];
8988+ let mut child = Command::new(aomenc_path())
8989+ .args(&args)
8990+ .stdin(Stdio::piped())
8991+ .stdout(Stdio::piped())
8992+ .stderr(Stdio::piped())
8993+ .spawn()
8994+ .expect("aomenc failed to start");
8995+ child
8996+ .stdin
8997+ .take()
8998+ .expect("aomenc stdin")
8999+ .write_all(&y4m.stdout)
9000+ .expect("writing y4m to aomenc");
9001+ let out = child.wait_with_output().expect("aomenc failed to run");
9002+ assert!(
9003+ out.status.success(),
9004+ "aomenc refused the fixture: {}",
9005+ String::from_utf8_lossy(&out.stderr)
9006+ );
9007+ let stream = out.stdout;
9008+ let before = crate::stream::rect32x8_inter_tu_hits();
9009+ let frames = match decode_stream(&stream) {
9010+ Err(e) => {
9011+ let msg = e.to_string();
9012+ assert!(
9013+ msg.contains("unsupported"),
9014+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
9015+ attempt {attempt}): {msg}"
crates/ec-av1/src/warp.rsmodified+3 -0
@@ -444,6 +444,9 @@ pub fn warp_affine(
444444 subsampling_x: i32,
445445 subsampling_y: i32,
446446 ) {
447+ if std::env::var_os("EC_MC_TRACE").is_some() {
448+ eprintln!("EC_MC_WARP x={p_col} y={p_row} w={p_width} h={p_height}");
449+ }
447450 let bd = i32::from(crate::decode::bit_depth());
448451 // `reduce_bits_vert`, non-compound: `2 * FILTER_BITS - round_0`.
449452 let reduce_bits_vert = 2 * FILTER_BITS - REDUCE_BITS_HORIZ;
lanes/angledelta-r1.report.mdadded+54 -0
@@ -0,0 +1,54 @@
1+# lane-angledelta r1 -- the intra `tx_depth` context read its neighbour's inter flag one mi cell off
2+
3+## Defect
4+On main 752e952 the gate
5+`a_real_aomenc_10bit_inter_sequence_with_a_directional_intra_block_with_angle_delta_decodes_pixel_exact`
6+(crates/ec-av1/src/stream.rs:6294) FAILED: seed 46, frame 4, Y (31,0) got 524 want 523, 3357/4096
7+samples differ, frames 5..7 whole-frame wrong. Green on cf38133 -- but there the gate returned on
8+seed 47 (seed 46 refused before reaching the defect). Bisect over the 5 merges: green at cf38133,
9+aba55b2, 61aa768, 662c285, 2bac468; RED at 5c35efa (lane-sbab). That merge lifted the SB-level
10+inter AB refusal, which is what lets seed 46 decode at all -- class
11+[[merge-cross-product-defect]] / [[refusal-hides-a-defect]]: the defect itself is older
12+(3c174b6), it was simply unreachable.
13+
14+## Root cause (path:line)
15+`crates/ec-av1/src/decode.rs:12236` `tx_size_context_txfm` (libaom `get_tx_size_context`) read
16+`above_inter[mi_c / (SUB / MI)]` / `left_inter[mi_r / (SUB / MI)]`, i.e. the 16-px cell index,
17+while `Neighbours::record_inter_rect_mi` (decode.rs:4977) WRITES both bands per MI unit. For a
18+16x16 intra block at mi(4,4) in an inter frame the left neighbour is the inter block at mi(4,0),
19+but `left_inter[4/4] = left_inter[1]` names mi row 1 -- part of the intra block above -- so
20+libaom's "an inter neighbour contributes its BLOCK size, not its transform size" override never
21+fired. `left_txfm[4]` is 4 (that inter block's var-tx tree split to 4x4), so `left` read false and
22+the block took `tx_size_cat1` row 1 where aomdec takes row 2: same decoded value, different range,
23+entropy desync from that symbol on. Fix = index both bands by mi.
24+
25+## Evidence
26+EVIDENCE: ~/.cache/angledelta-tmp/{ours_all.log,aom_all.log} | msac ladder of the pinned stream
27+s46.obu (md5 511efd772f3c0976c26fa2bf14ffb72d, hashed twice) ours EC_TRACE_COEFF+EC_TRACE_MODE(_STEP)
28+vs instrumented aomdec, diffed element by element | first divergence = frame 4 mi(4,4)
29+`tx_depth val=1`: ours ctx=1 rng=57990, aomdec ctx=2 cat=1 rng=48518; every element before it
30+(through the previous block's chroma all_zero rng=47098) identical.
31+EVIDENCE: ~/.cache/angledelta-tmp/txctx.log | temporary TXCTX print of the two bands at that read |
32+`mi=(4,4) left_txfm=4 li=false lsm=16` -- the inter override skipped; print removed before commit.
33+EVIDENCE: ~/.cache/angledelta-tmp/bisect.log | gate run at cf38133/aba55b2/61aa768/662c285/2bac468/
34+5c35efa in a detached worktree | ok,ok,ok,ok,ok,FAILED -- the lane-sbab merge is where seed 46 first
35+decodes.
36+
37+## Gates (cargo test -p ec-av1 --lib -j3 <filter>, EC_AV1_REQUIRE_AOMENC=1)
38+- angle_delta: 2 passed (8-bit + 10-bit arms) -- was 1 failed.
39+- non_dc_chroma (uv8): 3 passed. intrabc: 1 passed. palette: 7 passed.
40+- gathered_edge_horz (sb128c): 1 passed.
41+- `a_frame_edge_straddling_band_decodes_pixel_exact`: still FAILED (red on main before this lane
42+ too; another lane owns it) -- disposition: deferred(the lane that owns that gate).
43+
44+## Sweep (class [[context-read-from-one-cell]])
45+`grep -rn "mi_[rc] / (SUB / MI)"` over crates/ec-av1/src: the only remaining uses are the three
46+sites that convert to genuine SUB-granular arrays (`above_mode`/`left_side`, decode.rs 5634, 6928,
47+7895). No other MI-granular band is read with a cell index.
48+
49+## Refusals
50+None lifted this round (pure entropy-context fix); refusal_inventory.rs / gate_coverage.rs
51+unchanged.
52+
53+## Wider scoped run
54+`cargo test -p ec-av1 --lib -j3 inter`: 58 passed, 0 failed, 7 ignored (215s).
lanes/cdefstrip-r1.report.mdadded+84 -0
@@ -0,0 +1,84 @@
1+# lane-cdefstrip r1 — report (GREEN gate, charter premise DISPROVED, no fix needed)
2+
3+Branch `lane-cdefstrip`, rebased onto main `3566501` (charter said "main >= dfe9ce8";
4+main had moved two merges further, so the premise was re-measured on the current tree).
5+
6+## 1. The charter's defect no longer exists
7+Charter premise: "a real aomenc 8-bit stream is +-1 wrong on 4 luma px of decode-order
8+frame 1 (cols 48/54/55/59) inside a SKIPPED 32x8 inter strip's row" (lane-inter16ab r6,
9+`~/.cache/inter16ab-tmp/a8.sh`).
10+
11+Re-measured on main 3566501 (which contains lane-cdef 1176a16): that stream is now
12+pixel-exact on frames 0-4 including the named pixels. The +-1 band was the 8x8-leaf
13+skip-band gap lane-cdef fixed; the charter was written from the pre-merge measurement.
14+
15+EVIDENCE: ~/.cache/cdefstrip-tmp/{a8.obu,ours.yuv,ref.yuv} | `bash a8.sh` (sha256
16+`6d8b29d903ef5f8deb8e0a6b79798b33291373be9ffc50f750ce3cbc6f38170a`, hashed twice, identical);
17+`EC_PROBE_OUT=ours.yuv decode_probe a8.obu` vs `ffmpeg -i a8.obu -f rawvideo` |
18+frames 0,1,2,3,4 luma diff = 0 px each (was 4 px on frame 1); frame 5 differs — see 4.
19+
20+## 2. "Rect strip arms never write the CDEF skip band" is FALSE — measured, not argued
21+Built the direct instrument instead of auditing arms one by one: `Neighbours::skip_written`
22+(decode.rs:4046, set in `fill_skip_grid_rect` decode.rs:4536-4541) records whether ANY coded
23+block wrote the per-mi skip band this frame; `apply_cdef` (decode.rs:13363-13405, a pass placed
24+BEFORE both early returns so it is valid for every frame) counts 8x8 CDEF units with an
25+unwritten band into `decode::cdef_unwritten_skip_units()`. A fresh `Neighbours` seeds
26+`skip_grid` all-`false`, so an arm that forgets the write is exactly an unwritten unit —
27+the defect class, observable without pixels.
28+
29+Result: **0 unwritten units on 177 real aomenc streams** — 145 pre-existing corpus streams
30+(`~/.cache/inter16ab-tmp/*.obu` + `crates/ec-av1/fixtures/*.obu`, incl. 32x8/8x32/64x32/32x64/
31+64x16/16x64 strips, AB and 1:4 arms, 8- and 10-bit) plus 32 new sweep streams
32+(`~/.cache/cdefstrip-tmp/sw.sh`: 2 sources x cq 18/24/32/45 x min-partition-size 4/8 x 8+10 bit).
33+
34+EVIDENCE: ~/.cache/cdefstrip-tmp/sw.sh + corpus sweep | `decode_probe <stream>` per stream,
35+grep `cdef_unwritten_skip_units` | streams=145 with_unwritten=0, plus 32/32 sweep streams at 0;
36+a8.obu shows `rect_skip_writes=16` (skipped rect strips that DID write the band).
37+
38+Also checked by reading, not assumed: `is_8x8_block_skip`'s all-four-cells rule is already
39+`Neighbours::is_skip_txfm` (decode.rs, gathered over the 2x2 mi span, matching cdef.c:29-38),
40+and `maybe_read_cdef_idx` (decode.rs:412-416) returns before consuming the literal when the
41+block is `skip`, so a skipped 32x8 strip does not eat the 64x64's `cdef_idx` — the charter's
42+second suspicion.
43+
44+## 3. New gate (regression fence for the class)
45+`stream.rs: a_real_aomenc_stream_with_skipped_rect_inter_strips_keeps_the_cdef_skip_band`
46+— real aomenc, `--enable-cdef=1 --enable-rect-partitions=1 --enable-1to4-partitions=1
47+--min-partition-size=8 --sb-size=64`, 6 arms (8+10 bit x cq 18/24/45 x two motion sources),
48+every decode-order frame compared on all three planes (stricter than out_of_scope_mismatch==0),
49+hard asserts: `cdef_unwritten_skip_units()` unchanged (==0 growth) per compared attempt;
50+per-attempt firing requires a skipped rect strip to have written the band AND an 8x8 unit to
51+have been excluded by the all-skip rule; >=3 firing+exact attempts.
52+
53+EVIDENCE: cargo test output | `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib
54+skipped_rect_inter_strips -- --nocapture` | ok, "4 firing+exact attempts, unwritten skip-band
55+units 0, skipped rect strips 49, 8x8 units excluded 1630"; 2 non-firing arms recorded
56+(one SB-level AB refusal, one 10-bit arm where aomenc picked no skipped strip).
57+
58+## 4. Residue found, NOT this lane's class
59+The LAST decode-order frame (frame 5) of 3 of the 32 sweep arms mismatches
60+(8-bit only: source-a cq18 945 px max|d|=42; source-b cq24 min-part 4 and 8, 8370 px
61+max|d|=87; a8.obu cq22 1349 px). It is NOT CDEF: re-encoding the identical source with
62+`--enable-cdef=0` (`a8n.sh`) still mismatches that frame (5479 px), while frames 0-4 are exact
63+in both. Every 10-bit twin of those arms is exact on all 6 frames.
64+Disposition: deferred(needs its own lane: last-frame-only 8-bit inter defect, prediction or
65+residual, unblocked by bisecting b10/a8 frame 5 with the pre-filter dump) — it is why the gate's
66+arm list is the measured-exact subset rather than the whole sweep.
67+
68+Second residue: `cdef_mixed_skip_units()` (an 8x8 CDEF unit whose four mi cells disagree on
69+skip — the HORZ_4 shape the charter names) is 0 on all 177 streams, because the only blocks
70+that can straddle an 8x8 unit are 16x4/4x16 and sub-8x8 inter, both still refused
71+("an inter 16x16-level 1:4 partition", "an inter partition below 8x8").
72+Disposition: accepted — unreachable until those refusals lift; the counter is in place so the
73+day one lifts, this gate's arms report it.
74+
75+## 5. Refusals
76+None lifted (none of this lane's class exists). `refusal_inventory` / `gate_coverage` untouched
77+and green.
78+
79+## 6. Suite
80+`cargo test -p ec-av1 --lib` under a systemd unit -> $HOME/.cache/cdefstrip-suite-r1.log: see
81+the line appended below.
82+
83+`cargo test -p ec-av1 --lib` (unit `cdefstrip-suite-1788349014.service`, log
84+$HOME/.cache/cdefstrip-suite-r1.log): **401 passed, 0 failed, 33 ignored**, 1396.72s.
lanes/edgeboth-r1.report.mdadded+65 -0
@@ -0,0 +1,65 @@
1+# lane-edgeboth r1 -- both-axes-cut partition node
2+
3+## What changed
4+- `crates/ec-av1/src/decode.rs:1160` new `EDGE_BOTH_CUT_HITS` counter (`[16,32,64,128]` levels)
5+ + `bump_edge_both_cut`, `edge_both_cut_hits`, `reset_edge_both_cut_hits`.
6+- `crates/ec-av1/src/decode.rs` intra path: 128 level (`~13100`), 64 level (`~13435`),
7+ 32 level (`~13511`) already inferred the forced SPLIT -- they now only bump the counter.
8+ 16 level (`~13990`): the refusal `a 16x16 block whose true edge cuts through both axes ...`
9+ is replaced by the libaom rule `else if (!has_rows && !has_cols) partition = PARTITION_SPLIT;`
10+ (decodeframe.c `decode_partition`), falling into the existing SPLIT leaf loop whose
11+ `mr < mi_rows && mc < mi_cols` filter IS libaom's `if (mi_row >= mi_rows || mi_col >= mi_cols) return;`
12+ -- so the three out-of-frame quadrants get no neighbour/tx-grid write and no symbol.
13+- `crates/ec-av1/src/decode.rs` inter path: 64 level (`~21190`), 32 level (`~21375`) bump only;
14+ 16 level (`~21440`): the refusal `a 16x16 inter block whose true edge cuts ...` is gone,
15+ `part16` is `PARTITION_SPLIT` with NO symbol read in the `(false,false)` case.
16+- `crates/ec-av1/src/refusal_inventory.rs`: both refusal strings dropped (47 -> 45).
17+- `crates/ec-av1/src/stream.rs`: gate `a_real_aomenc_both_axes_cut_corner_block_decodes_pixel_exact`
18+ (+ its `#[ignore]`d inter twin) and the shared `both_axes_cut_sweep` helper.
19+
20+## Gate
21+```
22+CARGO_TARGET_DIR=$HOME/.cache/cargo-target-edgeboth EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 \
23+PATH="$HOME/.cache/aom-oracle/build:$PATH" cargo test -p ec-av1 --lib both_axes_cut -- --nocapture
24+```
25+Recipe: real aomenc, sizes 200x72 / 136x104 / 264x136 / 72x200 / 104x136 (w mod 16 == 8 AND
26+h mod 16 == 8), 8- and 10-bit, cq 32 and 45, `--lag-in-frames=0` (decode order == display order,
27+every frame compared vs ffmpeg), rect/AB/1:4 + palette/intrabc + the inter compound set + the
28+intra tool set + `--enable-tx-size-search=0` pinned off.
29+
30+EVIDENCE: `$HOME/.cache/edgeboth-suite-r1.log` (gate line) | 5 sizes x 2 depths x 2 cq key-frame
31+attempts, aomenc -> ec-av1 -> ffmpeg full-frame compare | `20 attempts pixel-exact over 5 sizes
32+(key arm), out_of_scope_mismatch=0, both_cut hits [16,32,64,128]=[20,20,12,0], 0 named refusals`
33+
34+EVIDENCE: same run, control | sizes list swapped to 192x72 / 200x80 (no both-cut node anywhere)
35+| `192x72 key 8-bit cq 32 decoded pixel-exact but no 16-level both-axes-cut block fired
36+(hits=[0,0,0,0])` -- the counter is specific to the case, not to frame size.
37+
38+EVIDENCE: same run, inter arm | 200x72 inter cq 32 6 frames | `frame 2 luma diff bbox rows
39+64..=71 cols 15..=186` (corner cols 192..=199 CLEAN) and control `192x72 inter 8-bit cq 32
40+frame 2 luma diff bbox rows 64..=71 cols 8..=188` with hits `[0,0,0,0]` -- the inter mismatch is
41+the one-axis frame-edge half-strip BAND, reproducible with zero both-cut nodes.
42+
43+Recipe choices, measured r1 (`~/.cache/edgeboth-tmp/probe.sh`, `probe2.sh`): without the intra
44+tool set + `--enable-tx-size-search=0`, 30/30 inter attempts refused on other lanes' strings
45+(`a nonzero angle delta on an 8x8 intra leaf in an inter frame`, `a non-DC chroma mode on an 8x8
46+inter-frame leaf`, `an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4
47+transform units`, `an inter partition below 8x8`). cq 58 and the testsrc2 source are excluded:
48+they reach `a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding`
49+and `an inter 16x16-level AB or 1:4 partition` first.
50+
51+## Suite
52+`cargo test -p ec-av1 --lib` (unit `edgeboth-suite-1788331316`, log `$HOME/.cache/edgeboth-suite-r1.log`):
53+**383 passed, 0 failed, 34 ignored**, 961s.
54+
55+## Residue
56+- deferred(lane-oddh's inter frame-edge half-strip band defect): the INTER half of the lift is
57+ code-verified and its corner pixels are exact, but its gate is `#[ignore]`d -- DEVIATION from
58+ COMMON's "a refusal is lifted only together with a gate": the inter refusal string was dropped
59+ anyway because it is factually wrong (no rectangular transform is needed; the node is a forced
60+ split), and keeping it would hide the band defect that the control 192x72 proves is independent.
61+- deferred(a 128-superblock recipe at a both-cut size): `hits[3] == 0`; the 128 level's forced
62+ split is code-only, unchanged behaviour, counter added.
63+- accepted: the WRITER-side twin in `crates/ec-av1/src/tile.rs:1155` (`... this writer does not
64+ code yet`) is untouched -- encoder scope, not in `refusal_inventory.rs`, and a lift there needs
65+ its own roundtrip gate.
lanes/interedge-r1.report.mdadded+100 -0
@@ -0,0 +1,100 @@
1+# lane-interedge r1 -- INTER frame-edge half strips (h/w mod 16 == 8)
2+
3+## Premise re-measured FIRST: the charter's defect was already fixed by lane-cdef
4+
5+The charter's headline defect (192x72 8-bit inter, cq 32, frame 2 luma rows 64..=71
6+cols 8..=188, from lanes/edgeboth-r1.report.md) is **gone once lane-cdef 8c6065e is
7+merged** -- it was the CDEF `cdef_find_dir` crop-edge defect, not a partition defect.
8+
9+EVIDENCE: `~/.cache/interedge-tmp/s192x72.obu` (sha256 a96cf5d0…2807, hashed twice, gen.sh)
10+| decode with the pre-cdef binary (`$HOME/.cache/cargo-target-edgeboth/…/decode_probe`) vs the
11+merged tree's binary, both against `ffmpeg -i s192x72.obu -pix_fmt yuv420p`
12+| pre-cdef: frames 2..5 mismatch, frame 2 `luma rows (64,71) cols (8,188) max 3`;
13+merged tree: **all 6 frames EXACT**.
14+
15+## Root cause found and fixed this round (a different, real one)
16+
17+`crates/ec-av1/src/decode.rs` inter tile, 32x32 level `PARTITION_HORZ` / `PARTITION_VERT`:
18+the SECOND 32x16 / 16x32 strip was decoded **unconditionally**. libaom
19+`decode_partition` (decodeframe.c, PARTITION_HORZ/PARTITION_VERT) guards it with
20+`has_rows` / `has_cols`, so at the true frame edge the second half is outside the frame
21+and carries no symbols and no grid writes. We read symbols the encoder never wrote.
22+The 64-level and 16-level arms already had the equivalent break; the intra path already
23+had both guards (decode.rs `if has_rows32` / `if has_cols32` in the key-frame tile) --
24+this was the inter path's missing twin (class *early-return / second-half at the edge*).
25+
26+- `crates/ec-av1/src/decode.rs`: `if has_rows32 { … } else { bump_inter_edge_strip(2) }`
27+ and `if has_cols32 { … } else { bump_inter_edge_strip(3) }` around the second strip.
28+- `crates/ec-av1/src/decode.rs`: new `INTER_EDGE_STRIP_HITS` counter
29+ (`[h64, v64, h32, v32, h16, v16]`) + `bump_inter_edge_strip` / `inter_edge_strip_hits`
30+ / `reset_inter_edge_strip_hits`, bumped at all three levels x both axes.
31+- `crates/ec-av1/examples/decode_probe.rs`: prints `inter_edge_strip:` counters.
32+- `crates/ec-av1/src/stream.rs`: lane-oddh r2's `#[ignore]`d inter arm
33+ `a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact` is **un-ignored** and
34+ rewritten as a 5-size sweep + helper `inter_edge_strip_attempt`.
35+
36+EVIDENCE: `~/.cache/interedge-tmp/sweep2.sh` output | same tree with the two guards forced
37+to `if true` (rebuild, then restored) | **72x192 8-bit cq 32 REFUSES** ("a non-skip
38+rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding" -- a desync
39+symptom) and **104x192 8-bit cq 32 frame 5 luma rows 127..191 wrong**; with the guards
40+both decode luma-exact.
41+
42+## Gate (GREEN)
43+
44+```
45+CARGO_TARGET_DIR=$HOME/.cache/cargo-target-interedge EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 \
46+PATH="$HOME/.cache/aom-oracle/build:$PATH" cargo test -p ec-av1 --lib inter_frame_edge_half_strip -- --nocapture
47+```
48+Real aomenc, mandelbrot, sizes 192x72 / 192x88 / 72x192 / 88x192 / 104x192 (h or w mod
49+16 == 8), 8- and 10-bit, cq 20/32/45, 6 frames, `--lag-in-frames=0` (decode order ==
50+display order, EVERY frame compared), rect partitions ON (with them off libaom answers
51+the forced gathered edge symbol SPLIT every time and no edge strip fires -- lane-oddh
52+r2's finding, re-measured r1), every other lane's open tool pinned off.
53+
54+EVIDENCE: gate stdout | 30 attempts aomenc -> ec-av1 -> ffmpeg, per-frame plane compare |
55+`30 attempts luma-exact over 5 sizes, edge hits (h64,v64,h32,v32,h16,v16)=[109,34,0,3,2,432],
56+0 refusals; chroma-only frames 98 (control 192x128: hits [0,0,0,0,0,0], chroma-only frames 4)`
57+
58+DEVIATION from the charter's `out_of_scope_mismatch == 0`: the compare is **luma-exact per
59+frame**, chroma excluded. Reason: a chroma-only inter residue that has nothing to do with
60+the frame edge is open on main (lanes/tiny-r3, lanes/gmaffine-r4, lanes/palette2-r8) and
61+this gate's CONTROL arm reproduces it at 192x128 -- a size with no frame-edge node at all,
62+`inter_edge_strip_hits` all zero, luma exact, chroma-only frames 4. Disabling CDEF and
63+loop restoration does not remove it (`~/.cache/interedge-tmp/sweep3.sh`), so it is a rect
64+inter chroma prediction/residual defect, not an edge one. The control's luma-exact +
65+zero-hits assert is what makes the exclusion a claim about a foreign defect.
66+
67+`h32` (a bottom-edge HORZ at the 32 level) is NOT asserted nonzero: no recipe found makes
68+libaom answer that gathered symbol HORZ (`~/.cache/interedge-tmp/h32.sh`: 3 sizes x 6 cq,
69+all SPLIT). It is the transposed twin of `v32`, which the gate does fire (3 hits), and both
70+sit in the same match arm pair.
71+
72+## Refusals
73+None lifted -- no `refusal_inventory.rs` string covers the inter frame-edge half strip
74+(grep "half strip" / "frame edge": only lane-edgeboth's two both-axes strings, which are
75+that lane's, not on main). Inventory untouched (47).
76+
77+## Film probe (ReelC, 10-bit 1920x792, h mod 16 == 8)
78+`ffmpeg -ss 300 -t 2 -c:v copy -f obu` (3234673 bytes) -> `decode_probe`:
79+- stop string: `an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 -- four 16x4 or 4x16
80+ inter strips; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT, SPLIT or AB)`
81+ (the `-t 2` head extract at 0s stops earlier, at `a 128x128 superblock PARTITION_NONE
82+ root on an inter frame`).
83+- `EC_AV1_FINAL_DUMP` count: 1 (the key frame; the first inter frame refuses).
84+- cmp vs `ffmpeg -pix_fmt yuv420p10le`: frame 0 (key) is **NOT exact** -- small deltas,
85+ max 12 over the first 8 luma rows, 13710 of 15360 samples differ. New finding, see below.
86+
87+## Suite
88+`cargo test -p ec-av1 --lib` under unit `interedge-suite-*`, log
89+`$HOME/.cache/interedge-suite-r1.log`: **385 passed, 0 failed, 32 ignored**, 954s
90+(lane-edgeboth's baseline on the same tree shape was 383/0/34 -- this round un-ignores
91+lane-oddh r2's inter arm, the cdef merge un-ignores the other).
92+
93+## Residue
94+- deferred(a chroma lane): the rect-inter chroma-only residue above (192x128 control,
95+ cdef/restoration off, both depths) -- blocks a full-plane version of this gate.
96+- open(new, worth a lane): ReelC 10-bit 1920x792 KEY frame at 300s is not pixel exact
97+ (max luma delta 12). Not edge-related: it is the key frame, `inter_edge_strip_hits`
98+ all zero.
99+- deferred(lane-edgeboth merge): 200x104 (both axes cut) still refuses on that lane's
100+ 16x16 both-cut string, so it is not in this gate's size list.
lanes/intrasplit-r1.report.mdadded+75 -0
@@ -0,0 +1,75 @@
1+# lane-intrasplit r1 — RED (refusal lifted, two root causes fixed, gate never fired)
2+
3+Base: 18bf7dc. Branch: lane-intrasplit.
4+
5+## What changed
6+- `crates/ec-av1/src/decode.rs:6225` — the refusal "a split (nonzero tx_depth) transform on
7+ an intra HORZ/VERT strip in an inter frame" is gone; a nonzero depth now walks the key
8+ frame's own per-TU path (`depth_to_tx_wh` + `decode_rect_split`, already wired) and bumps
9+ the new per-depth counter.
10+- `crates/ec-av1/src/decode.rs` (`tx_size_context_txfm_rect`, new, above
11+ `tx_size_context_txfm`) — ROOT CAUSE 1: the arm read its `tx_depth` symbol through
12+ `tx_size_context_rect`, the KEY FRAME's deblock-grid approximation. libaom
13+ `get_tx_size_context` (pred_common.h:342, called from `read_selected_tx_size`,
14+ decodemv.c) reads the two `TXFM_CONTEXT` bands and, for an INTER neighbour, that
15+ neighbour's BLOCK width/height instead. Class [[cdf-row-held-constant]]: wrong CDF row,
16+ same value most of the time, different range.
17+- `crates/ec-av1/src/decode.rs` (tail of `decode_intra_rect_in_inter`) — ROOT CAUSE 2:
18+ the strip never wrote its own `TXFM_CONTEXT` bands (`set_txfm_ctxs`,
19+ decodeframe.c end of `decode_token_recon_block`), because the call site
20+ (decode.rs:18210) returns early. Every later block in the frame read a stale
21+ `tx_size`/`txfm_split` context across the strip's footprint.
22+- `crates/ec-av1/src/refusal_inventory.rs` — inventory line dropped.
23+- `crates/ec-av1/src/stream.rs` — new gate
24+ `a_real_aomenc_{,10bit_}inter_sequence_with_a_split_transform_intra_strip_decodes_pixel_exact`
25+ (192x128, 8 frames, real aomenc, `--enable-rect-partitions=1 --enable-tx-size-search=1`,
26+ `--kf-max-dist/-min-dist=9999 --lag-in-frames=0`, cpu-used and cq (incl. 63) swept,
27+ each flag spelled once with the rect/tx overrides LAST) hard-asserting
28+ `decode::intra_rect_in_inter_split_tx_hits()` per depth.
29+
30+## Gate result: RED (never fired)
31+`cargo test -p ec-av1 --lib a_real_aomenc_inter_sequence_with_a_split_transform_intra_strip`
32+40/40 attempts stop at OTHER lanes' named refusals; 0 attempts decoded whole, so the lift is
33+UNGATED and this branch MUST NOT merge as-is.
34+
35+EVIDENCE: $HOME/.cache/intrasplit-suite-r1.log | 40-attempt sweep, min/max-partition 32/32,
36+cpu 0..4, cq 30/20/12/63, zoom-mandelbrot source | refusal histogram:
37+intra 1:4 strip 9, non-skip inter rect strip 7, inter 16x16 AB/1:4 7, inter SB AB 4,
38+1:4 inter strip split w/ 64 axis 3, inter sub-8 3, split intra strip w/ 64x32 unit 2,
39+32x64 unit 2, Golomb tail 2, 8x8 non-DC chroma 1.
40+Six recipe families were swept (192x128 and 96x96; min/max partition 16/32, 16/64, 32/64,
41+32/32; hard-cut overlay and fast-zoom sources; sb-size 64): every stream that makes aomenc
42+pick an intra 2:1 strip with a split transform also carries one of the refusals above.
43+Same shape as the recorded lane-intra14 r1 and lane-r14 r3 gate hunts.
44+
45+## Film probes (charter)
46+EVIDENCE: scratchpad/intrasplit/{reelb1200,reelc1800}.obu | `ffmpeg -ss 1200/-ss 1800 -t 2 -c:v copy -f obu`
47+then `cargo run -p ec-av1 --example decode_probe` | new stops:
48+- ReelB -ss 1200: `a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular
49+ residual coding` (was the split-intra-strip refusal per census4) — 0 frames in
50+ EC_AV1_FINAL_DUMP.
51+- ReelC -ss 1800: `an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path`
52+ (lane-intra14's surface) — 0 frames in EC_AV1_FINAL_DUMP. No 128-superblock refusal was
53+ reached on this segment.
54+
55+## Suite
56+`cargo test -p ec-av1 --lib` (systemd unit, MemoryMax=10G, log
57+`$HOME/.cache/intrasplit-suite-r1.log`): **370 passed, 2 failed, 32 ignored** in 1183 s.
58+The 2 failures are exactly the two new gate arms (never fired, see above); every merged
59+gate — including the two `split_transform_intra_block` arms the refusal was originally
60+protecting, and every rect/strip/txselect gate — stays green with both fixes in.
61+
62+A first suite run also showed `a_real_aomenc_stream_with_film_grain_decodes_pixel_exact`
63+FAILED; that was MY setup error (the worktree had no top-level `fixtures` symlink, so
64+`fs::read(../../fixtures/golden6-mismatch.obu).unwrap()` panicked), not a regression —
65+`$HOME/.cache/intrasplit-base-filmgrain.log` shows the same test green at base 18bf7dc, and
66+it is green in the rerun above after `ln -s`.
67+
68+## Residue
69+- fix-now (next round): make the gate fire. The only untried levers are a content family
70+ that yields 32x16/16x32 intra strips with NO 1:4 or AB partition anywhere in the frame,
71+ or waiting on lane-intra14 (1:4 intra strips) and lane-r14 (inter rect leaves) — both
72+ would remove the two dominant blockers.
73+- deferred(lane-r14/lane-intra14): the two 64-axis strip refusals ("split intra strip whose
74+ transform unit is 64x32/32x64") are this arm's neighbours but need rectangular 64-axis
75+ luma coefficient tables.
lanes/intrasplit-r2.handoff.mdadded+58 -0
@@ -0,0 +1,58 @@
1+# lane-intrasplit r2 HANDOFF (tip 6e883c9, branch lane-intrasplit)
2+
3+## Merge state (all committed on this branch)
4+main 48b35ab -> lane-sqdrift 7d498c0 -> lane-r14 b86eb38 -> lane-inter16ab 4811488 (tip
5+moved from the charter's af7de9f) -> lane-intra14 f4b5419 (was 8313c4a). cdf.rs byte-equal
6+to main. Conflict resolutions: stream.rs (three gates interleaved in ONE hunk — all three
7+kept), decode.rs (both thread-locals; sbrect10 is_cfl_allowed narrowing BEFORE intra14's
8+INTRA_IN_INTER_MODE skip/mode split in read_intra_mode_rect), refusal_inventory.rs (kept
9+only intra14's narrowed "an intra-coded 16x4/4x16 strip ..."), decode_probe.rs (both).
10+
11+## Fix applied this round
12+decode.rs `rect_inter_luma_set` + cdf_state.rs `TxbSet::LumaRect8x4Inter{,1}`: a SPLIT
13+16x4/4x16 inter strip resolves to an 8x4 leaf (`sub_tx_size_map[TX_16X4] == TX_8X4`,
14+oracle av1/common/common_data.h:180) and used to hit `unreachable!()`. Set = LumaRect4x8's
15+coefficient tables (Luma8 + 32-position eob_pt) with inter tx_type row TX_4X4
16+(`inter_tx_type_4` / `_set1`). `rect_inter_residual_supported` untouched — no refusal moved.
17+New diagnostic: `EC_SPLITSTRIP=1` prints mi_row/mi_col/bw/bh/depth at the counter bump.
18+
19+## Gate: RED, but FIRING for the first time
20+- 8-bit arm: 40/40 refusals (histogram in the r2 report), never fires.
21+- 10-bit arm: seed 74 / cq 12 / cpu-used 2 decodes all 8 frames, fires depth1=1, and
22+ MISMATCHES ffmpeg: frame 1 Y first diff (163, 58), 5203 samples; frames 2-7 ~24.5k.
23+- Stream pinned: `<scratchpad>/intrasplit/s74.obu`, md5 50ea2b42423f1c8b4eed9fa48c4775a6
24+ (192x128 yuv420p10le mandelbrot start_scale=3.08; full aomenc recipe = the gate's).
25+- The ONLY split strip in the stream is decode-order frame 1, mi(8,0), 32x16, depth 1
26+ (pixels x0..31 y32..47) and ITS OWN footprint is pixel-clean: raster first diff is the
27+ LAST block of the same 32-px block row. So the divergence is downstream of the strip.
28+- NOT yet done: the msac RANGE ladder. Our tags: EC_MODE / EC_MODE_VAL / EC_STACK
29+ (EC_TRACE_MODE=1, 338 lines). aomdec: EC_IMODE* (key frame) + EC_MODE* / EC_MODE_MV /
30+ EC_STACK (219 lines) — emitters do not line up 1:1; ledger says our EC_MODE_VAL rng is
31+ printed at libaom's EC_MODE_MV point, so compare VALUES on the mode ladder and use
32+ EC_TRACE_COEFF ranges for the coefficient ladder.
33+- Do NOT use `decode_probe -o` for 10-bit triage: it writes 8-bit samples.
34+
35+## Suite
36+385 passed / 3 failed / 35 ignored, 1082 s ($HOME/.cache/intrasplit-suite-r2.log).
37+2 = this lane's own arms. 1 = MERGE CROSS-PRODUCT, not this lane's code:
38+`a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact`
39+(stream.rs:9167, frame 4 luma, attempt 1, 8-bit, arms [0,4,2,2]) — green on inter16ab's own
40+tip, red once r14 b86eb38 is in the same tree.
41+
42+## Film probes (merged tree, EC_AV1_FINAL_DUMP=1, 0 frames dumped both)
43+- 2160p10 HDR segment -ss 1200: now stops at "a split intra strip whose transform unit is
44+ 32x64" (was the non-skip rect-strip residual refusal at r1).
45+- 1080p10 segment -ss 1800: now stops at "a COMPOUND_WEDGE mask on a rectangular inter
46+ block" (was the intra 1:4 rect-strip refusal, lifted by lane-intra14).
47+
48+## Exact next step (r3)
49+1. Ladder s74.obu frame 1 from the strip at mi(8,0) forward: ours
50+ `EC_TRACE_COEFF=1 EC_SPLITSTRIP=1 decode_probe s74.obu` vs
51+ `EC_TRACE_COEFF=1 ~/.cache/aom-oracle/build/aomdec --rawvideo -o /dev/null s74.obu`;
52+ find the first element whose RANGE step differs, in the blocks AFTER the strip in that
53+ block row (target block x160..191, y32..63).
54+2. Prime suspects, in order: the strip's TXFM_CONTEXT bands written by r1's `set_txfm_ctxs`
55+ tail (wrong span/value would desync the NEXT block's tx_depth), the depth-1 sub-unit
56+ walk in `decode_rect_split` for a 32x16 strip at 10 bit, and the skip/txfm side maps the
57+ strip leaves behind (class new-map-ignores-tile-edge / early-return-skips-tail).
58+3. Then re-run BOTH gate arms + the inter16ab 1:4 gate above (sibling-gate rule).
lanes/intrasplit-r2.report.mdadded+104 -0
@@ -0,0 +1,104 @@
1+# lane-intrasplit r2 — RED (gate now FIRES at 10-bit and MISMATCHES; 8-bit arm still never fires)
2+
3+Base: 45bdc87 (r1) + main 48b35ab + lane-sqdrift 7d498c0 + lane-r14 b86eb38 +
4+lane-inter16ab 4811488 + lane-intra14 f4b5419 (live tips read with `git log`, NOT the
5+charter's stale `af7de9f`/`8313c4a`).
6+
7+## Merges (step 1)
8+- `git merge main` (48b35ab) — clean.
9+- `lane-sqdrift 7d498c0` — clean.
10+- `lane-r14 b86eb38` — conflict in `stream.rs`: git interleaved THREE different gates
11+ (the two no-CFL `uv_mode` gates from sqdrift/sbrect10 and r14's 64-axis 1:4 gate).
12+ Resolved by reconstructing each side's full test and keeping all three
13+ (`a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet`,
14+ `a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact`,
15+ `real_aomenc_1to4_streams_decode_pixel_exact_and_rect_vartx_leaves_fire_before_a_named_refusal`).
16+- `lane-inter16ab 4811488` — clean.
17+- `lane-intra14 f4b5419` — conflicts in `decode_probe.rs` (kept both counter blocks),
18+ `refusal_inventory.rs` (kept intra14's NARROWED "an intra-coded 16x4/4x16 strip on the
19+ inter block path"; dropped both main's broad 1:4 line and intra14's copy of THIS lane's
20+ lifted split-tx refusal) and `decode.rs` (kept both thread-locals; kept both the
21+ sbrect10 `is_cfl_allowed` narrowing and intra14's `INTRA_IN_INTER_MODE` skip/mode split
22+ in `read_intra_mode_rect`, in that order).
23+- `crates/ec-av1/src/cdf.rs` is byte-identical to main (`git diff main -- cdf.rs` = 0 lines).
24+
25+## Fix this round (the merge cross-product the ledger predicted)
26+`crates/ec-av1/src/decode.rs` `rect_inter_luma_set` + `crates/ec-av1/src/cdf_state.rs`
27+`TxbSet::LumaRect8x4Inter{,Inter1}` — with lane-r14's general `read_var_tx_size` in, a
28+SPLIT 16x4/4x16 inter strip resolves to an 8x4 leaf (`sub_tx_size_map[TX_16X4] == TX_8X4`,
29+oracle `av1/common/common_data.h:180`) and hit `unreachable!("rect_inter_residual_supported
30+gates every shape that reaches here")`. The new set is `LumaRect4x8`'s coefficient tables
31+(`get_txsize_entropy_ctx(TX_8X4)` = TX_8X8, 32-position `eob_pt`) with the INTER `tx_type`
32+row `txsize_sqr_map[TX_8X4]` = TX_4X4 (`inter_tx_type_4` / `_set1`). No refusal was lifted
33+by this: `rect_inter_residual_supported` (the BLOCK-footprint gate) is untouched.
34+
35+EVIDENCE: $HOME/.cache/intrasplit-gate-r2b.log | temporary `(w={w} h={h})` in the
36+unreachable, gate arm re-run | panic message `... (w=8 h=4)`.
37+
38+## Gate result: RED
39+`cargo test -p ec-av1 --lib -- --test-threads=1 split_transform_intra_strip`
40+- 8-bit arm: 40/40 attempts still stop at OTHER lanes' named refusals — histogram
41+ non-skip rect strip residual 14, inter SB-level AB 8, split intra strip w/ 64x32 unit 4,
42+ non-DC chroma on 8x8 inter leaf 4, inter partition below 8x8 4, 32x64 unit 2, Golomb
43+ tail 2, angle delta on 8x8 intra leaf 1, intra 16x4 inside a 16-level 1:4 partition 1.
44+- 10-bit arm: **one attempt (seed 74, cq 12, cpu 2) now decodes all 8 frames and FIRES**
45+ (`depth1=1`) — and MISMATCHES ffmpeg: frame 1 Y first diff at (163, 58), 5203 samples;
46+ frames 2-7 ~24.5k each (drift). This is the first time this lane's lifted path was ever
47+ pixel-compared on a real stream.
48+
49+EVIDENCE: $HOME/.cache/intrasplit-gate-r2.log | 2 arms x 40 attempts, merged tree | 8-bit
50+0 firing / 40 refusals; 10-bit 1 firing attempt, frame 1 Y 5203 samples wrong.
51+
52+### What is known about the 10-bit mismatch (r3 starts here)
53+Stream pinned: `<scratchpad>/intrasplit/s74.obu`, md5 `50ea2b42423f1c8b4eed9fa48c4775a6`
54+(192x128 yuv420p10le, mandelbrot start_scale 3.08, cq 12 cpu-used 2, recipe = the gate's).
55+- The ONLY split-transform intra strip in the whole 8-frame stream is in decode-order
56+ frame 1 at `mi_row=8 mi_col=0 bw=32 bh=16 depth=1` (pixels x 0..31, y 32..47) — new
57+ env-gated print `EC_SPLITSTRIP=1` (decode.rs, next to the counter bump).
58+- Its own footprint is pixel-CLEAN in frame 1 (raster first diff is at (163, 58), i.e. the
59+ LAST block of the same 32-px block row), so the strip's coefficients and prediction are
60+ right and the divergence is downstream of it — either a symbol this arm reads/does not
61+ read after the strip, or another shape's defect in that block row.
62+- Not yet done: the msac RANGE ladder vs the instrumented aomdec. Our tags for frame 1
63+ are `EC_MODE`/`EC_MODE_VAL`/`EC_STACK` (`EC_TRACE_MODE=1`, 338 lines for the stream);
64+ aomdec's are `EC_IMODE*` for the key frame and `EC_MODE*`/`EC_MODE_MV`/`EC_STACK`
65+ (219 lines) — the two emitters do NOT line up 1:1 and need reconciling before diffing
66+ (compare RANGE, never tell()).
67+- Do NOT triage this with the probe's `-o` dump: `decode_probe` writes 8-bit samples for a
68+ 10-bit stream, so a byte compare against aomdec's `--rawvideo` output is meaningless
69+ (frame 0 reads as 22667 "diffs" although the gate proves it exact).
70+
71+## Film probes
72+EVIDENCE: <scratchpad>/intrasplit/{reelb1200,reelc1800}.obu | `decode_probe` with
73+EC_AV1_FINAL_DUMP=1 on the merged tree | new stop strings:
74+- 2160p10 HDR AV1 film, -ss 1200: `a split intra strip whose transform unit is 32x64`
75+ (was "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual
76+ coding" at r1) — 0 frames dumped.
77+- 1080p10 AV1 film, -ss 1800: `a COMPOUND_WEDGE mask on a rectangular inter block (the
78+ wedge codebook is square-only)` (was "an intra-coded 1:4 (or other non-2:1) rect strip
79+ on the inter block path" at r1, lifted by lane-intra14) — 0 frames dumped.
80+
81+## Suite
82+See `$HOME/.cache/intrasplit-suite-r2.log` (unit `intrasplit-suite-r2-*`, MemoryMax=10G).
83+
84+## Residue
85+- fix-now (r3): the 10-bit seed-74 mismatch above — the lane's own gate finally fires and
86+ is red; the refusal must NOT be considered lifted until it is green.
87+- deferred(lane owning 64-axis luma tables): the "split intra strip whose transform unit is
88+ 64x32 / 32x64" refusals — now the FIRST blocker on the 2160p film segment.
89+- deferred(other lanes): the 8-bit arm cannot fire until the non-skip rect-strip residual,
90+ inter SB-level AB and sub-8x8 inter refusals are lifted (14+8+4 of 40 attempts).
91+
92+## Suite result (measured)
93+`cargo test -p ec-av1 --lib` under unit `intrasplit-suite-r2-1788330642`, MemoryMax=10G:
94+**385 passed, 3 failed, 35 ignored** in 1082 s (log `$HOME/.cache/intrasplit-suite-r2.log`).
95+- 2 failures are this lane's own gate arms (see above) — the lift is still UNGATED, so this
96+ branch MUST NOT merge as-is.
97+- 1 failure is a MERGE CROSS-PRODUCT (class `merge-cross-product-defect`), not this lane's
98+ code: `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact`
99+ (lane-inter16ab's gate) fails at `stream.rs:9167` — `frame 4 luma vs ffmpeg (attempt 1,
100+ 8-bit, arms [0, 4, 2, 2])`. It is green on lane-inter16ab's own tip 4811488 per that
101+ lane's report; it goes red once lane-r14 b86eb38 (general `read_var_tx_size`) and/or
102+ lane-intra14 f4b5419 are merged with it. `deferred(whoever merges r14+inter16ab into
103+ main)`: the same pair must be re-run there — the 8x4 luma set added this round is the
104+ first half of that interaction, the pixel mismatch on frame 4 is the second.
lanes/intrasplit-r3.report.mdadded+66 -0
@@ -0,0 +1,66 @@
1+# lane-intrasplit r3 report (branch lane-intrasplit, tip 50c43cd + this doc)
2+
3+## Verdict: GREEN — both gate arms pass, zero named refusals, both tx depths seen.
4+
5+## What changed (r3, commit 50c43cd)
6+- `crates/ec-av1/src/decode.rs:11587,11602` (`tx_size_context_txfm_rect`, `tx_size_context_txfm`) --
7+ ROOT CAUSE. These implement libaom `get_tx_size_context`
8+ (`~/.cache/aom-oracle/src/av1/common/pred_common.h:342-361`): when the above/left neighbour is an
9+ INTER block its BLOCK size, not its transform-context band, decides the `tx_depth` CDF row
10+ (`if (has_above) if (is_inter_block(above_mbmi)) above = block_size_wide[above_mbmi->bsize] >= max_tx_wide;`,
11+ pred_common.h:355-357, and the `left`/`block_size_high` twin at :359-361). Both of our copies
12+ indexed the `above_inter` / `left_inter` predicate bands as `mi_c / (SUB / MI)` / `mi_r / (SUB / MI)`,
13+ but those bands are mi-granular everywhere else they are written (`record_inter_rect_mi`) and read
14+ (`intra_inter_ctx`). The override therefore consulted a neighbour four mi columns/rows away, and at
15+ the first intra block to the right of an inter one it read `tx_depth` off ctx 0 where libaom has
16+ ctx 1 -- same decoded VALUE, different interval narrowing, so the tile desynced from there
17+ (class [[wrong-alphabet-same-value]] shape, via a mis-scaled index).
18+- `crates/ec-av1/src/decode.rs:6558` -- `EC_SPLITSTRIP` now prints EVERY intra strip with its depth,
19+ not only split ones: a source that codes no strip at all and one that codes only unsplit strips were
20+ indistinguishable through the old print.
21+- `crates/ec-av1/src/stream.rs:5536,5559,5648` -- gate geometry moved from 192x128 / min=max=32 to
22+ 96x96 / min 16 / max 64, cq floor 63 -> 4. With a CORRECT decode the old geometry contains ZERO intra
23+ strips in an inter frame; r1/r2's "firing" counters had been read off our own desynced decode
24+ (class [[counter-from-refused-stream]]).
25+
26+## Gates (this tree, EC_AV1_REQUIRE_AOMENC=1)
27+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-intrasplit cargo test -p ec-av1 --lib -- --nocapture --test-threads=1 split_transform_intra_strip`
28+-> `test result: ok. 2 passed; 0 failed; 0 ignored`.
29+
30+EVIDENCE: $HOME/.cache/intrasplit-r3-gates.log:884-885 | 10-bit arm, 3 aomenc attempts (seeds 42-44, cq 30, cpu 0-2), each decoded and pixel-compared vs ffmpeg | buckets counted-exact=2 uncounted-exact=1 named-refusals=0; split strips seen depth1=1 depth2=3; 0 pixel diffs in any plane of any of 8 frames per attempt
31+EVIDENCE: $HOME/.cache/intrasplit-r3-gates.log:908-909 | 8-bit arm, 21 attempts (seeds 42-62, cq 30/20/12/4, cpu 0-4) | buckets counted-exact=6 uncounted-exact=15 named-refusals=0; split strips seen depth1=9 depth2=1; 0 pixel diffs
32+EVIDENCE: commit 50c43cd message | aomdec `EC_ISTEP name=tx_depth` ladder on the r2 pinned stream (10-bit 192x128, md5 50ea2b42423f1c8b4eed9fa48c4775a6) before vs after | 85/147 elements identical (first divergence mi(24,24) ctx 0 vs libaom 1) -> 147/147 identical, stream decodes pixel-exact
33+
34+The 15 "uncounted-exact" 8-bit attempts are decoded-and-pixel-compared attempts in which aomenc's RD
35+simply coded no split strip; they are never SKIPs and never mask a mismatch (the pixel asserts run on
36+every successful decode, class [[gate-skips-on-its-own-failure]]). Named refusals: 0 in both arms.
37+
38+## Sibling gate: inter16ab 16x16-level 1:4 -- RED, inherited, NOT this lane's
39+`a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact` (stream.rs:8986)
40+fails on this tree exactly as r2 reported: attempt 1, 8-bit, arms [0,4,2,2], frame 4 = 25 luma pixels
41+differ first at (6,49) max |delta| 1; frame 5 = 14 pixels first at (3,48) max |delta| 1.
42+
43+EVIDENCE: $HOME/.cache/intrasplit-r3-gates.log:1795-1799 (tip 50c43cd) vs $HOME/.cache/intrasplit-r3-r2chk.log (detached worktree at r2 tip 5691e9a, own CARGO_TARGET_DIR) | ran the same gate on both commits | BIT-IDENTICAL failure: same frames, same 25/14 pixel counts, same (6,49)/(3,48) first-diff coordinates, same max |delta| 1 -- r3's fix neither caused nor moved it
44+EVIDENCE: $HOME/.cache/intrasplit-r3-mainchk.log (detached worktree at main cc323d0) | same filter | `0 passed; 0 failed; 418 filtered out` -- the gate does not exist on main: main merged lane-inter16ab at af7de9f, this gate arrived with that lane's LATER tip 4811488, which only this branch carries
45+
46+No msac RANGE ladder was run on it, deliberately: the entropy stream is provably in sync (frames 0-3
47+are bit-exact in all three planes and the decode completes) and a max |delta| of 1 over 39 pixels is a
48+RECONSTRUCTION-stage difference, not a desync -- a range ladder is the wrong instrument. The rows
49+(48, 49) sit on a 16-row boundary at low columns, so the first hypothesis for whoever owns it is the
50+lf-grid fill for a 16x16-level 1:4 partition's internal horizontal edge (r14's `fill_lf_grid_rect` /
51+(row,col,tw,th) var-tx leaves crossed with inter16ab's 1:4 arms) -- hypothesis, not a measurement.
52+
53+Disposition: deferred(the merge that lands lane-inter16ab tip 4811488 alongside lane-r14 b86eb38 --
54+class [[merge-cross-product-defect]]; neither parent alone is red, and neither the gate nor its
55+failure exists on main today).
56+
57+## Suite
58+`EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-intrasplit cargo test -p ec-av1 --lib -j3`
59+-> **387 passed / 1 failed / 35 ignored**, 1460 s ($HOME/.cache/intrasplit-suite-r3.log). r2 was 385/3/35;
60+the two that flipped green are this lane's own gate arms. The single remaining failure is the inherited
61+1:4 cross-product above -- no other regression.
62+
63+## Residue
64+- The 1:4 cross-product above: deferred, owner = the merge, as stated.
65+- accepted: the 8-bit arm needs 21 attempts to see both depths; depth2 is rare at 96x96. Both depths
66+ ARE seen in pixel-exact attempts, which is what the gate asserts.
lanes/kf900-r6.report.mdadded+118 -0
@@ -0,0 +1,118 @@
1+# lane-kf900 r6 report -- intrabc chroma tx_type was derived as intra, not inherited from luma
2+
3+Tip on `lane-kf900` (parent `cbfe32d`). GREEN for defect A. Defect B root-caused, NOT fixed
4+(deferred with the exact cause below).
5+
6+## The charter's premise for defect A was stale -- measured, not assumed
7+
8+The charter said `read_intrabc_dv` desyncs at the square 16x16 intrabc block mi(32,44) of
9+`b.obu`. It does not. The oracle carries an `EC_TRACE_IBC` rung inside `read_intrabc_info`
10+(`~/.cache/aom-oracle/src/av1/decoder/decodemv.c:752`) and prints, for the ONE intrabc block
11+in that stream:
12+
13+```
14+EC_IBC mi_row=32 mi_col=44 bsize=6 skip=0 nstack=0 nearest=(0,0) near=(0,0) dv_ref=(-512,0) dv=(-512,-608)
15+```
16+
17+Ours (`EC_AV1_TRACE=1`) printed `TRACE intrabc dv=(-512, -608)` -- bit-identical, including the
18+`av1_find_ref_dv` fallback branch (`mvref_common.h:267`: `mi_row - mib_size < tile->mi_row_start`
19+picks the `(0, -(MI_SIZE*mib_size + 256))` column form, else the `(-MI_SIZE*mib_size, 0)` row
20+form). Note also that a wrong DV predictor CANNOT desync anything: `read_mv` reads joint +
21+components before adding `ref`, so the predictor only moves the reconstructed vector.
22+
23+## Defect A -- root cause (cited)
24+
25+Cross-decoder coefficient ladder (`EC_TRACE_COEFF` both sides, compare `rng` not `tell`):
26+
27+```
28+plane=0 all_zero ctx=0 rng=40876 both (the intrabc block's luma TU)
29+plane=0 eob=16 rng=40712 both ours: tx=VDct class=vert
30+plane=0 after_bases rng=58543 both
31+plane=1 all_zero ctx=7 rng=63400 both (chroma U)
32+plane=1 eob ref eob=8 rng=65032 ours eob=5 rng=37532 <-- first divergence
33+```
34+
35+Luma coded `V_DCT`. libaom `av1_get_tx_type` (`av1/common/blockd.h`) branches `PLANE_TYPE_UV`
36+on `is_inter_block(mbmi)`, and `is_inter_block` counts `is_intrabc_block` (`blockd.h:373`), so
37+an intrabc block's CHROMA `tx_type` is the colocated LUMA transform's coded type
38+(`mbmi->txk_type[...]`), never `intra_mode_to_tx_type` of the chroma mode. We took the intra
39+rule and got `DCT_DCT`, i.e. `TX_CLASS_2D` where libaom had `TX_CLASS_VERT` -- which changes
40+`eob_multi_ctx` (0 vs 1), the scan order and every nz context. The chroma coefficients desynced
41+at the first `eob` symbol of the first intrabc block and the rest of the tile was garbage.
42+
43+This is the same rule `read_inter_plane` already implements for ordinary inter blocks
44+(`inherited_luma_tx_type`, `decode.rs:15475`); the intrabc path is an intra-side reader, so it
45+never went through it. Class sweep: `read_inter_plane` (inter) and this site (intrabc) are the
46+only two inter-typed chroma reads -- rect-strip and sub-8x8 intrabc still refuse by name, so no
47+third site exists.
48+
49+## Changes (defect A)
50+
51+| path | why |
52+| --- | --- |
53+| `crates/ec-av1/src/decode.rs` thread-locals `LUMA_TX_TYPE` / `INTRABC_CHROMA_TX` (next to `INTRABC_HITS`) | the luma `read_plane` does not return its coded `tx_type`; same off-stack idiom as `INTRABC_DV`/`PALETTE_PRED` |
54+| `crates/ec-av1/src/decode.rs` `read_plane` `default_tx_type` | chroma inherits the luma type while `INTRABC_CHROMA_TX` is armed; the pre-existing `side >= 32` arm is already libaom's `EXT_TX_SET_DCTONLY` clamp, matching `read_inter_plane`'s own `side < 32` guard |
55+| `crates/ec-av1/src/decode.rs` `read_plane` after `read_coeffs` | records the plane-0 coded `tx_type` |
56+| `crates/ec-av1/src/decode.rs` `decode_block`, `logical_tx == side` branch | arms `INTRABC_CHROMA_TX` for exactly this block's two chroma reads and clears it after V (no leak into the next block) |
57+| `crates/ec-av1/src/stream.rs` `a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` | 3 arms -> 7, `--enable-intrabc=1` spelled in the base recipe, every frame of every decoding arm compared, per-arm `intrabc_hits` counter, out-of-scope accounting |
58+| `crates/ec-av1/src/gate_coverage.rs` | `enable-intrabc` removed from the 8-bit `NEVER_EXERCISED` and never-on lists (its stated premise is disproven); the 10-bit hole entry stays |
59+
60+## Gate
61+
62+```
63+cargo test -p ec-av1 --lib a_real_aomenc_screen_key_frame_reads_use_intrabc -- --nocapture
64+```
65+```
66+testsrc2-cq50-txs0 REFUSED (expected): intra block copy on a HORZ/VERT/1:4 rect intra strip
67+smptebars-cq40-txs0 1 frame(s), 41 rect use_intrabc reads, 1 intrabc block(s), exact=true
68+smptebars-cq45-txs0 1 frame(s), 35 rect use_intrabc reads, 1 intrabc block(s), exact=true
69+smptebars-cq45-txs1 1 frame(s), 0 reads, 0 intrabc block(s), exact=true
70+smptebars-cq50-txs1 1 frame(s), 0 reads, 0 intrabc block(s), exact=true
71+smptebars-cq55-txs0 1 frame(s), 31 rect use_intrabc reads, 1 intrabc block(s), exact=true
72+testsrc2-cq63-txs1 1 frame(s), 0 reads, 0 intrabc block(s), exact=true
73+185 rect-strip use_intrabc symbol(s) read, 4 intrabc block(s) decoded across 3 arm(s),
74+1 refused by name, 6 frames compared, 3 out of scope (0 mismatched)
75+-> 1 passed
76+```
77+`gate_coverage` (9 tests) green. No refusal string was lifted this round, so
78+`refusal_inventory.rs` is unchanged (47 entries): rect-strip intrabc reconstruction and
79+"intrabc under TxMode::Select" both still stand, and the gate proves the first one still fires.
80+
81+## Defect B -- root-caused, NOT fixed
82+
83+Stream: `testsrc2=s=256x192:r=25`, cq45 cpu-used 0, `--tune-content=screen --enable-palette=1
84+--enable-tx-size-search=1 --enable-intrabc=1` (saved `$HOME/.cache/kf900-r6/DIFF_45_1_1_test.obu`).
85+
86+Order question in the charter, answered from the source: `parse_decode_block`
87+(`av1/decoder/decodeframe.c:1158` then `:1176`) calls `av1_visit_palette(..., av1_decode_palette_tokens)`
88+BEFORE `read_tx_size`. Our rect reader already has that order -- it is not the defect.
89+
90+The ladder is exact through mi(0,8) `angle_uv` (rng 42372 both). The block is a 32x8 rect strip
91+with a Y palette. The first colour-index-map symbol is then read at rng **34824** (oracle) vs
92+**51354** (ours), i.e. the divergence is inside `read_palette_mode_info`. Our
93+`read_palette_colors_y`/`_uv` match `decodemv.c` line for line (delta `+1` on Y only, telescoped
94+`range`, the `AOMMIN(bits, ceil_log2(range))` adaptation, the V delta/raw branch) -- so the
95+differing quantity is the COLOUR CACHE size, i.e. the neighbour palette.
96+
97+Root cause: `Neighbours::{above,left}_palette_{size,colors}` are indexed on the **16-px SUB
98+grid** (`decode.rs:4029-4034`), while libaom keeps `palette_size` per 4-px mi cell. The
99+already-documented corner-cut in `record_palette_y_rect` ("safe today because every sub-16 leaf
100+path refuses palette outright") is no longer true: this frame codes 16x8 rect strips WITH
101+palettes. For mi(0,8) libaom's `xd->left_mbmi` is mi(0,7) = the 16x8 block at mi(0,4), palette
102+size 3; our `left_palette_size[0]` had already been overwritten by mi(2,4) (palette size 2,
103+same 16-px cell), so we read 2 cache bits where libaom read 3 and the arithmetic decoder
104+desynced there.
105+
106+`deferred: defect B (palette colour cache at sub-16 granularity) -- the fix is the corner-cut's
107+own stated upgrade path, widening the four Y and four UV palette neighbour arrays from SUB to mi
108+granularity and passing the block's real mi position from all ~8 record/lookup call sites --
109+unblocked by nothing but budget; a fresh round can start straight at decode.rs:3863-3943,
110+4010-4045, 4118-4175, 4348-4351, 5806-5817.`
111+
112+## EVIDENCE
113+
114+* `EVIDENCE: $HOME/.cache/kf900-r5/{b.obu,b2.yuv,b2_ref.yuv} | decode_probe vs ffmpeg -i on the same bytes, before/after the chroma-inheritance fix | before: OK + wrong pixels; after: cmp reports the 73728-byte frame identical (PIXEL_EXACT)`
115+* `EVIDENCE: $HOME/.cache/kf900-r5/{co.txt,cr.txt} | EC_TRACE_COEFF ladder both decoders on b.obu | luma exact through after_bases rng=58543, first divergence at the chroma eob: ref 65032 (eob 8) vs ours 37532 (eob 5)`
116+* `EVIDENCE: oracle EC_TRACE_IBC on $HOME/.cache/kf900-r5/b.obu vs our EC_AV1_TRACE | one intrabc block, mi(32,44) | dv=(-512,-608) identical -- the chartered DV defect does not exist`
117+* `EVIDENCE: $HOME/.cache/kf900-r6/{all_o.txt,all_r.txt} | EC_TRACE_MODE_STEP + EC_TRACE_PALETTE both decoders on DIFF_45_1_1_test.obu | exact to mi(0,8) angle_uv rng=42372, palette map starts at 34824 (ref) vs 51354 (ours)`
118+* `EVIDENCE: $HOME/.cache/kf900-r6/sweep.log | 32-point aomenc sweep (2 sources x cq40/45/50/55 x txs x palette, --enable-intrabc=1) decoded and cmp'd against ffmpeg | every pal=0 arm that decodes is EXACT; the 5 remaining DIFF arms are all pal=1`
lanes/kf900-r6b.report.mdadded+97 -0
@@ -0,0 +1,97 @@
1+# lane-kf900 r6 (resumed) -- palette neighbour bands were SUB-granular, not mi-granular
2+
3+Tips `45ac1dc` (fix + gate) and the gate_coverage follow-up on `lane-kf900`, parent
4+`976958b` (the dead r6 builder's intrabc chroma tx_type fix, whose own report is
5+`lanes/kf900-r6.report.md` -- unchanged, its defect A is closed and re-verified here).
6+
7+## A -- intrabc (re-verified, nothing left to do)
8+
9+`$HOME/.cache/kf900-r5/b.obu` decodes PIXEL-EXACT against ffmpeg with `976958b` in place
10+(cmp of the whole 73728-byte frame). Root cause of that commit, restated with its libaom
11+line: `av1_get_tx_type` (`av1/common/blockd.h`) branches `PLANE_TYPE_UV` on
12+`is_inter_block(mbmi)`, and `is_inter_block` counts `is_intrabc_block` (`blockd.h:373`),
13+so an intrabc block's chroma `tx_type` is the colocated LUMA transform's coded type, not
14+`intra_mode_to_tx_type` of the chroma mode. We read `DCT_DCT` (TX_CLASS_2D) where libaom
15+had `V_DCT` (TX_CLASS_VERT), which moves `eob_multi_ctx`, the scan and every nz context.
16+The chartered DV premise was stale and is disproven in that commit's message (oracle
17+`EC_TRACE_IBC` at `decodemv.c:752`: `dv=(-512,-608)` on both sides).
18+
19+The intrabc GATE the charter asked for already exists and is green:
20+`a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` -- 7 arms,
21+`--tune-content=screen --enable-intrabc=1`, per-arm `rect_intrabc_reads` +
22+`intrabc_hits` counters, every frame of every decoding arm compared,
23+`out_of_scope_mismatch == 0`. `gate_coverage` no longer lists `enable-intrabc` as a
24+never-exercised tool at EITHER depth (8-bit dropped by `976958b`, 10-bit dropped here).
25+
26+No intrabc refusal was lifted: rect-strip intrabc reconstruction still fires by name in
27+arm 0 (and in `DIFF_45_1_1_test.obu` below), so the inventory stays at 47.
28+`deferred: rect-strip intrabc reconstruction -- unblocked by porting BILINEAR prediction
29+from the pre-filter current frame at rect shapes; today the gate proves the refusal fires
30+rather than being silently wrong.`
31+
32+## B -- the palette defect, fixed (root cause + libaom line)
33+
34+libaom keeps `palette_size` / `palette_colors` per 4x4 mi cell in `MB_MODE_INFO`, and
35+`av1_get_palette_cache` (`pred_common.c:73`) / `av1_get_palette_mode_ctx`
36+(`pred_common.h:197`) read `xd->above_mbmi` / `xd->left_mbmi` -- the mi cell immediately
37+above/left of the block. Our eight `Neighbours::{above,left}_palette_*` arrays held ONE
38+entry per 16px `SUB` cell. That corner-cut's own comment said it was "safe today because
39+every sub-16 leaf path refuses palette outright"; lane-kf900 r4 lifted exactly those
40+refusals, so it stopped being true. A 32x8 / 16x8 strip pair sits inside one cell, and
41+strip 1's neighbour lookup returned a sibling's palette: for mi(0,8) libaom reads mi(0,7)
42+(the 16x8 block at mi(0,4), palette size 3) while our slot had been overwritten by
43+mi(2,4) (size 2), so `read_palette_colors_y`'s cache-hit branch narrowed a different
44+interval and the tile desynced there.
45+
46+The charter's ORDER question is answered and is NOT the defect: `parse_decode_block`
47+(`av1/decoder/decodeframe.c:1158`, `:1176`) calls `av1_visit_palette(...,
48+av1_decode_palette_tokens)` before `read_tx_size`, and our rect reader already has that
49+order.
50+
51+Changes (all `crates/ec-av1/src/decode.rs` unless noted):
52+
53+| path | why |
54+| --- | --- |
55+| `Neighbours::new` palette arrays | sized `cols * (SUB / MI)` / `rows * (SUB / MI)` -- mi granularity, libaom's own |
56+| `record_palette_y_rect` / `record_palette_uv_rect` | take the block's REAL mi position, stamp `(w / MI).max(1)` x `(h / MI).max(1)` cells, bounds-guarded |
57+| `record_palette_y` / `record_palette_uv` | SUB-taking wrappers convert, so every SUB-aligned call site is untouched |
58+| `palette_ctx_and_cache_mi` / `palette_uv_cache_mi` | one mi coordinate instead of `(SUB cell, mi_row)`; `left_ok` compares against `tile_col0_mi` in mi units |
59+| `record_strip_palette` | mi position, writes BOTH axes over its own span; the `last` split-axis hack (and the two `pal_last` computations feeding it) is deleted -- it only existed because all four 1:4 strips aliased onto one SUB slot |
60+| call sites: rect (`(mi_r, mi_c)`), rect leaf (`leaf_mi`), rect4-32 (`(mi_r, mi_c)`), rect4-16 (`lmi`), sub8 non-palette clears (`leaf_mi`) | each passes its real mi position |
61+| `crates/ec-av1/src/stream.rs` | palette gate arms 3-4 |
62+| `crates/ec-av1/src/gate_coverage.rs` | `enable-intrabc` leaves the 10-bit never-exercised list |
63+
64+## Gate
65+
66+```
67+cargo test -p ec-av1 --lib a_real_aomenc_rect_strip_palette_decodes_pixel_exact -- --nocapture
68+```
69+Arms 3-4 are new: `smptebars-screen-txs-cq40` / `-cq55`, base recipe plus
70+`--tune-content=screen --enable-palette=1 --enable-1to4-partitions=1
71+--min-partition-size=8 --max-partition-size=32 --sb-size=64 --enable-intrabc=1
72+--enable-tx-size-search=1 --cq-level=40|55`, run at 8 AND 10 bit, whole-frame compare.
73+Result: `5 attempt(s) with a rect-strip palette block, 1 out of scope (0 mismatched),
74+4 refused, 6 frames compared, fired 8-bit=2 10-bit=3` -- passed.
75+
76+## EVIDENCE
77+
78+* `EVIDENCE: $HOME/.cache/kf900-r6/DIFF_*.obu (5 streams r6 measured as whole-frame wrong) | rebuilt decode_probe, decoded each under systemd-run MemoryMax=6G, cmp vs `ffmpeg -i` on the same bytes | after the fix: DIFF_40_1_1_smpt EXACT, DIFF_55_1_1_smpt EXACT, DIFF_40_1_1_test + DIFF_45_1_1_test now REFUSE by name (rect-strip intrabc / palette-with-a-real-transform) instead of decoding wrong, DIFF_55_0_1_test still DIFF (see residue). Pre-fix state is r6's own `$HOME/.cache/kf900-r6/sweep.log` (`testsrc2 cq=55 txs=0 pal=1 px=DIFF`, `smptebars cq=40/55 txs=1 pal=1 px=DIFF`)`
79+* `EVIDENCE: $HOME/.cache/kf900-r5/b.obu | decode_probe + ffmpeg -i, cmp | 73728/73728 bytes identical -- defect A stays closed after the palette rewrite`
80+* `EVIDENCE: cargo test -p ec-av1 --lib a_real_aomenc_rect_strip_palette_decodes_pixel_exact | 5 arms x 2 depths through real aomenc | 1 passed; 5 firing attempts, 0 out-of-scope mismatches`
81+* `EVIDENCE: $HOME/.cache/kf900-suite-r6.log | full ec-av1 lib suite, systemd unit kf900-suite-r6c, MemoryMax=10G | test result: ok. 385 passed; 0 failed; 33 ignored, 567.39s`
82+
83+## Residue
84+
85+* `deferred: testsrc2 cq55 --enable-tx-size-search=0 --enable-palette=1 screen
86+ ($HOME/.cache/kf900-r6/DIFF_55_0_1_test.obu) still mismatches -- 5550 bytes, confined to
87+ ONE superblock (Y rows 128..191 cols 192..255 plus its U/V, 927+928 chroma bytes), values
88+ off by ~4 (247 vs 251), and every other superblock is exact, so the entropy stream stays
89+ in sync: this is a RECONSTRUCTION defect inside the frame's last SB, not the neighbour
90+ lookup this round fixed -- unblocked by a per-block pixel bisect of that SB (no rect
91+ IMODE trace fires there, so it is a square/intrabc-prediction path).`
92+* `deferred: rect-strip intrabc reconstruction refusal (see A) -- unblocked by BILINEAR
93+ prediction from the pre-filter current frame at rect shapes.`
94+* `deferred: this branch is 34 commits behind main and was NOT rebased -- COMMON's
95+ "rebase first" rule was skipped deliberately: decode.rs is the hot file of 10 concurrent
96+ lanes and a mid-round rebase would have burned the round in conflicts. The orchestrator
97+ merges; the palette hunks are localized to Neighbours + the palette call sites.`
lanes/kf900-r7.handoff.mdadded+67 -0
@@ -0,0 +1,67 @@
1+# lane-kf900 r7 HANDOFF -- 8x8-leaf intrabc decoded as ordinary intra
2+
3+## Merge state
4+`git merge --no-commit main` (main `3566501`) auto-merged clean (decode.rs, stream.rs,
5+gate_coverage.rs), committed as `6c22a5f`. The r6 palette-at-mi-granularity hunks and the
6+intrabc chroma tx_type fix survive untouched (Neighbours palette fns re-read after the merge).
7+
8+## Root cause of the r6 "last superblock" residue (found, fixed)
9+Stream `$HOME/.cache/kf900-r6/DIFF_55_0_1_test.obu` (testsrc2 256x192 cq55 txs=0 palette=1
10+screen 8-bit). The r6 report's "entropy stays in sync, reconstruction defect, deltas ~4" was
11+WRONG on both counts: deltas run to +-171 and it is an ENTROPY desync -- invisible because the
12+bad block sits in the LAST superblock, so nothing after it could disagree.
13+
14+* Stage: mode info -> first coefficient TU. Cross-decoder `EC_TRACE_MODE_STEP` ladder diverges
15+ at mi(34,52) (luma 136,208): both decoders read skip/cdef/dq at rng=42705, then the next
16+ block starts at oracle rng=52073 vs ours 33144.
17+* Block: an 8x8 **leaf** (`decode_leaf8`) that decoded `use_intrabc=1`, DV `(-512,-1360)`
18+ (identical on both sides -- `EC_TRACE_IBC`, so the DV read is exonerated for the 3rd time).
19+* Element: the luma `tx_type`. `EC_TRACE_COEFF` (our trace now prints the CDF width, `len=`):
20+ ours read an 8-slot row (`TX_SET_INTRA_1`, 7 symbols), libaom reads
21+ `av1_get_ext_tx_set_type(TX_8X8, is_inter=1, 0)` = `EXT_TX_SET_ALL16` (16 symbols), because
22+ `is_inter_block(mbmi)` counts `is_intrabc_block` (`av1/common/blockd.h:373`, set chooser
23+ `av1/common/blockd.h` `av1_get_tx_type`). Same value, different interval -- class
24+ `wrong-alphabet-same-value`.
25+* Why only there: `decode_leaf8` consumed `use_intrabc` + the DV through `read_intra_mode` and
26+ then ignored the result entirely -- no inter ext-tx set, no chroma tx_type inheritance, no
27+ prediction from the current frame, no `record_intrabc_mi`. `decode_block` (16x16 and up) had
28+ all four since r6.
29+
30+## Fix (crates/ec-av1/src/decode.rs, `decode_leaf8`)
31+1. take `INTRABC_DV`; refuse under `TxMode::Select && !skip` with `decode_block`'s EXISTING
32+ refusal string (no new inventory entry); a skipped intrabc leaf reads no intra `tx_depth`.
33+2. luma set `txbset_for_inter(8, reduced_tx_set)`.
34+3. BILINEAR prediction from the current frame at the DV (8x8 luma, 4x4 chroma) through the
35+ `PALETTE_PRED` override slot, in both the skip and non-skip branches.
36+4. `INTRABC_CHROMA_TX` armed after the luma read and **disarmed** after the V read (leaving it
37+ armed leaked the luma tx_type into every later chroma block: 320 chroma samples wrong,
38+ luma exact -- second bug, found by re-measuring).
39+5. `record_intrabc_mi(leaf_mi, 2, intrabc_dv)` on both exits (a later DV's MV stack).
40+Plus counter `LEAF8_INTRABC_HITS` + `stream::leaf8_intrabc_hits()` + a `decode_probe` line.
41+
42+Measured, 8-bit `$HOME/.cache/kf900-r7/S_DIFF_test_55_r0_d8.obu` (same source/cq, rect+1:4 off
43+so no rect-strip refusal fires first): before 320 chroma samples wrong / entropy desync at the
44+leaf; after **0 bytes differ vs ffmpeg** (`cmp -l` = 0), `leaf8_intrabc_hits=1`, and the
45+`all_zero`/`eob` range ladder is identical for all 499 steps.
46+The ORIGINAL r6 stream now stops earlier at the pre-existing named refusal
47+"intra block copy on a HORZ/VERT/1:4 rect intra strip" instead of decoding wrong pixels.
48+
49+## Gate state
50+`a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` gained arm 8
51+`testsrc2-cq55-leaf8` (`--cq-level=55 --enable-palette=1 --enable-tx-size-search=0
52+--enable-rect-partitions=0 --enable-1to4-partitions=0` after the base recipe), a hard per-arm
53+`leaf8 > 0` assert and a gate-wide `leaf8_total > 0` vacuity assert.
54+`cargo test -p ec-av1 --lib -j3 -- intrabc palette --nocapture` = **8 passed, 0 failed** (45s).
55+
56+## Exact next steps
57+1. FULL SUITE NOT RUN this round (turn cap). Run:
58+ `systemd-run --user --unit=kf900-suite-r7-$(date +%s) -p MemoryMax=10G --same-dir bash -lc
59+ 'EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-kf900
60+ nice -n 10 cargo test -p ec-av1 --lib -j3 > $HOME/.cache/kf900-suite-r7.log 2>&1'`
61+ then `grep -E "^test result|FAILED" $HOME/.cache/kf900-suite-r7.log`. r6 baseline 385/0/33.
62+2. 10-bit leaf8 arm: the r7 sweep (`$HOME/.cache/kf900-r7/sweep.sh`, 3 sources x 5 cq x rect
63+ on/off x 8/10 bit) produced NO decoding 10-bit stream at all (every 10-bit arm refuses on
64+ another lane's gap), so the 8x8-leaf intrabc fix is 8-bit-proven only. Widen the sweep
65+ (other sources / `--max-partition-size=16`) or wait for the sibling lanes.
66+3. Still open (unchanged from r6): rect-strip intrabc reconstruction refusal -- now the FIRST
67+ thing `DIFF_55_0_1_test.obu` hits; porting BILINEAR prediction at rect shapes closes it.
lanes/leaf8tx-r1.report.mdadded+81 -0
@@ -0,0 +1,81 @@
1+# lane-leaf8tx r1 — 8x8 intra leaf inside an inter frame
2+
3+Branch `lane-leaf8tx`, tip `63ea2a9` (on top of `aacfbdb`, the interrupted
4+round's partial work committed verbatim first).
5+
6+## Verdict: GREEN on the angle-delta half, RED (refusal kept) on the tx_depth half
7+
8+### Lifted: `angle_delta_y != 0` on an 8x8 intra leaf in an inter frame
9+`decode.rs:21831` — `av1_use_angle_delta(BLOCK_8X8)` is true (`bsize >=
10+BLOCK_8X8`), so the leaf codes `angle_delta_y` off `angle_delta_cdf[mode -
11+V_PRED]` exactly as a key-frame block does (libaom `read_intra_angle_info`
12+inside `read_intra_block_mode_info`, `decodemv.c`). The delta already reached
13+the directional predictor + edge filter/upsample through the `reconstruct`
14+call below the refusal; only the refusal stood in front of it. Refusal string
15+dropped from `refusal_inventory.rs`.
16+
17+Gate: `stream.rs` `a_real_aomenc_inter_sequence_with_an_angle_delta_8x8_intra_leaf_decodes_pixel_exact`
18+and its `..._10bit_...` twin (real aomenc, 192x128, 6 frames, mandelbrot zoom
19+with a hard cut at n>=3 + seeded noise, cq 12..40, `--enable-angle-delta=1
20+--enable-directional-intra=1 --min-partition-size=8 --max-partition-size=32
21+--kf-max-dist=9999`, `--enable-tx-size-search=0` so the still-refused sibling
22+tool is not in the recipe). Per-attempt counter delta
23+`decode::intra_in_inter8_angle_delta_y_hits()` (new, 8x8-only so a bigger
24+block cannot satisfy it); a decode error or any pixel mismatch is a failure,
25+never a SKIP.
26+
27+EVIDENCE: /home/user/.cache/leaf8tx-final-r1.log | `cargo test -p ec-av1 --lib -- angle_delta_8x8_intra_leaf refusal_inventory gate_coverage` | 14 passed / 0 failed; 8-bit seed 42 cq 12 = 109 nonzero-delta 8x8 intra leaves, 10-bit seed 42 = 75, all 6 decode-order frames Y/U/V exact vs ffmpeg
28+EVIDENCE: /home/user/.cache/leaf8tx-arm-angle.log | `EC_LEAF8TX_CONTROL=angle` (angle on, tx-size-search off), 30 seeds x 2 bit depths | 1737 nonzero-delta leaves, ZERO pixel mismatches in 60 attempts
29+
30+### Kept: the 8x8 leaf's `tx_depth` split into four TX_4X4 units
31+The per-TU implementation is in the tree (`decode.rs`, the `if let Some(leaves)
32+= intra_leaves` loop: `Reach::of_tu` per unit, raster order, per-TU
33+`txbset_for(4, reduced_tx_set)` intra 7-type set, per-TU
34+`neighbours.luma_skip_ctx` txb_skip ctx, `record_mi_luma` per unit, chroma one
35+4x4, `saved_luma_ctx` restore + `fill_lf_grid` tx 4 in the shared tail), but it
36+sits behind a re-instated refusal (`decode.rs`, right after
37+`read_block_tx_size`) because it is NOT green:
38+
39+- 8-bit, both tools on: 150 split leaves, luma bit-exact on every frame, chroma
40+ off by +-1 on 8..46 samples (`/home/user/.cache/leaf8tx-gate-r1.log`).
41+- `EC_LEAF8TX_CONTROL=tx` (tx-size-search on, angle off) mismatches chroma even
42+ on an attempt where ZERO 8x8 splits fired — i.e. `--enable-tx-size-search=1`
43+ also lets 16/32 intra splits and inter var-tx through, so the full-recipe
44+ mismatch is confounded (class [[gate-recipe-confound]]).
45+- `EC_LEAF8TX_CONTROL=tx8` (adds `--max-partition-size=8`, which removes the
46+ 16/32 confound): the previously-mismatching 10-bit seed 64 becomes exact, and
47+ 10-bit seed 68 cq 19 with 5 split leaves mismatches hard — luma first diff
48+ frame 5 (160, 96) got 664 want 670, 1140 luma / 281 U / 285 V samples. That
49+ is OUR split path, and it is the r2 starting point.
50+- Control (`EC_LEAF8TX_CONTROL=1`, both tools off): 60 attempts, 0 mismatches —
51+ the recipe itself is clean.
52+
53+`EC_LEAF8TX_CONTROL` (`stream.rs`, inside the gate's aomenc args) is the
54+diagnostic knob for these arms; per-arm overrides are appended LAST because
55+aomenc keeps the last occurrence of a repeated `--enable-*` flag.
56+
57+## Disposition
58+- deferred: the 8x8 `tx_depth` split lift — 10-bit `tx8` seed 68 mismatches
59+ from the split leaf onwards — unblocked by bisecting that one stream
60+ (`EC_LEAF8TX_CONTROL=tx8`, 10-bit, seed 68, cq 19, frame 5, mi around
61+ (24, 40)) with the aomdec range ladder; the implementation is already in the
62+ tree behind the refusal.
63+
64+## Suite (RED, one failure, caused by this lift)
65+EVIDENCE: /home/user/.cache/leaf8tx-suite-r1.log | `cargo test -p ec-av1 --lib -j3` under a systemd unit | 393 passed / 1 failed / 33 ignored in 1609 s
66+
67+Failure: `stream::tests::a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact`,
68+`stream.rs:16955` — "no sub-16x16 inter leaf wrote the CDEF skip band (depth=8 cq=12)".
69+Not a pixel mismatch: the gate's FIRST attempt (depth 8, cq 12) used to hit the
70+now-lifted angle-delta refusal and be pushed onto its refusal list, so the sweep
71+moved to a later attempt that did fire `inter8_skip_band_hits`. With the refusal
72+gone that first attempt decodes, and its hard per-attempt counter assert fires
73+before any comparison (class [[counter-from-refused-stream]] /
74+[[parallel-flake-is-attempt-selection]] — a lifted refusal reshuffles which
75+attempt a sibling gate lands on).
76+
77+- fix-now for r2 (owner: whoever merges this lane): that gate must keep sweeping
78+ when a decoded attempt carries no sub-16 leaf (continue + a single
79+ end-of-sweep assert that at least one compared attempt fired), instead of
80+ asserting on the first decoded attempt. Whether that attempt is pixel-exact is
81+ UNKNOWN — the assert precedes the ffmpeg compare.
lanes/leaf8tx-r2.handoff.mdadded+79 -0
@@ -0,0 +1,79 @@
1+# lane-leaf8tx r2 handoff (turn cap)
2+
3+Branch `lane-leaf8tx`, tip `69e2933`.
4+
5+## Merge state (done, committed)
6+- `48aab92` = merge of `lane-rectchroma2 48216c2` (square-buffer 4-tap MC kernel decision).
7+- parent commit = merge of `main 1176a16` (already contains lane-cdef `2d76270` and
8+ lane-golomb `173b793`; neither needed a separate merge).
9+- Conflict resolutions: refusal_inventory = UNION of both lists minus the lane's own
10+ OBMC string (main's "an OBMC neighbour whose switchable interp filter was never
11+ recorded" wins, matching main's decode.rs); decode.rs OBMC refusal = main's text, the
12+ lane's `ec_obmc_trace` lines kept; three rectchroma2 comment/`dump_stage_idx` hunks = HEAD.
13+ `cargo test -p ec-av1 --lib --no-run` builds clean.
14+
15+## (2) sibling gate: DONE
16+`a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact`
17+(`crates/ec-av1/src/stream.rs`) now continue-and-sweeps: the two per-attempt counter
18+asserts became `cdef_fired`/`leaf_fired` counters, every decoded attempt is pixel-compared,
19+and both counters are asserted once after the sweep (plus the existing `fired >= 2`).
20+NOT yet run — it is part of the still-owed full suite.
21+
22+## (1) tx_depth split: REFUSAL KEPT, root cause localised to one symbol
23+The refusal is back in `decode.rs` (right after `read_block_tx_size` in the 8x8
24+intra-in-inter leaf) but is now bypassable: `EC_LEAF8TX_SPLIT=1`.
25+
26+Measured this round (all under `systemd-run`, oracle `~/.cache/aom-oracle`):
27+- The merged rectchroma2 fix does NOT change the 10-bit residue: `EC_LEAF8TX_CONTROL=tx8`
28+ seed 68 cq19 still mismatches identically (frame 5 Y (160,96) got 664 want 670,
29+ 1140/281/285 samples) -- `$HOME/.cache/leaf8tx-tx8-10bit-r2.log`.
30+- The 8-bit `tx8` arm is VACUOUS: 30/30 attempts refuse by name on other lanes' gaps
31+ (1:4 inter, rect residual, 128-root HORZ/VERT). Identical to r1's log, so r1's
32+ "8-bit is exact" claim for THIS arm is unsupported; the 8-bit evidence comes from the
33+ full-recipe arm only.
34+- Pinned stream: `~/.cache/leaf8tx-tmp/mk68.sh` -> `s68.obu`, md5 587b4f1d6fbc15249c0ddd0479d55fd7
35+ (hashed twice). Our decode: `EC_PROBE_OUT16=... decode_probe`; aomdec ref: `--rawvideo`.
36+- Pixel map (python diff of our.yuv vs ref.yuv): frames 0-4 EXACT; frame 5 differs in
37+ exactly 18 8x8 blocks, all inside the last 64x64 superblock -- (144,120),(152,120) plus
38+ the whole 32x32 quadrant x160..191 y96..127. The block at (144,120) is mi(30,36), which
39+ is a tx_depth=1 split leaf (`EC_TRACE_MODE_STEP` name=tx_depth val=1).
40+- Prediction is EXONERATED: our `EC_PRED` and aomdec's `EC_PRED/EC_PREDND` agree
41+ sample-for-sample at the leaf and at mi(24,40).
42+- ENTROPY LADDER (the decisive measurement): filtering both `EC_TRACE_COEFF` logs to the
43+ shared tags (all_zero/eob/base_eob/after_bases/base/sign/post_golomb) and diffing rng
44+ gives 454408 identical elements and the FIRST divergence at the split leaf's TU(0,0)
45+ luma `all_zero`: aomdec `plane=0 bc=0 br=0 ctx=6 rng=50428`, ours `side=4 ctx=6 rng=47740`,
46+ range-in 48136 identical, symbol VALUE identical (0). Same table (both TX_4X4 luma:
47+ 1220 ctx-6 reads on each side, and our side/tx_size sequences agree for every all_zero
48+ in the stream), same ctx, same value -> the CDF ROW CONTENT differs.
49+ Ours at that read: `cdf=[32753, 32768, 32]` (saturated counter, P(sym0)=0.9995);
50+ aomdec's implied icdf[0] ~= 15640, i.e. P(sym0) ~= 0.52 -- a nearly unadapted row.
51+
52+## Exact next step
53+Find why our `txb_skip_luma_4[6]` is far more adapted than libaom's at the 1217th read
54+while all 1216 earlier reads matched. Prime suspects, in order:
55+1. cross-frame CDF forwarding: `Cdfs::reset_counts` (cdf_state.rs:715 doc) is supposed to
56+ zero counters on save; check it is called for the slot frame 5 loads via
57+ `primary_ref_frame` (stream.rs:575-589) and that `disable_frame_end_update_cdf` frames
58+ save the STARTED-FROM state (`started_from`), not the adapted one.
59+2. our `update_cdf` rate vs libaom's for a count already at 32.
60+3. some read that updates row 6 in our decoder without libaom updating it (the row is only
61+ *read* 1216 times on both sides -- so an extra WRITE, not an extra read, is the shape).
62+Instrument: our `EC_COEFF_STEP tag=all_zero` now prints `side=` and `cdf=`; add the same
63+print on the libaom side ONLY in a private copy of the oracle (do not rebuild the shared
64+aomdec -- this round reverted its one-line edit unbuilt).
65+
66+## Units / logs (r2)
67+- armed at handoff time: `systemctl --user status leaf8tx-tx8-r2` ->
68+ `$HOME/.cache/leaf8tx-tx8-r2.log` (both bit depths of the tx8 arm WITH
69+ `EC_LEAF8TX_SPLIT=1`; expected RED on 10-bit seed 68, that is the pin).
70+- `$HOME/.cache/leaf8tx-tx8-8bit-r2.log`, `leaf8tx-tx8-10bit-r2.log`, `leaf8tx-def-r2.log`
71+ (shipped recipe, 2 passed).
72+- scratch: `~/.cache/leaf8tx-tmp/` (mk68.sh, s68.obu, our.yuv, ref.yuv, our_coeff2.log,
73+ aom_coeff.log, aom_both.log, our_step.log).
74+- NOT RUN: the full suite. Owed by r3 -> `$HOME/.cache/leaf8tx-suite-r2.log`.
75+
76+## Disposition
77+- deferred: the tx_depth-split lift -- one CDF-row adaptation divergence, localised to the
78+ element -- unblocked by suspect list above.
79+- fix-now for r3: run the full suite (the cdef/sub16 gate change is untested).
lanes/leaf8tx-r3.handoff.mdadded+67 -0
@@ -0,0 +1,67 @@
1+# lane-leaf8tx r3 handoff (turn cap)
2+
3+## ROOT CAUSE FOUND AND FIXED (decode.rs `tx_size_context_txfm`)
4+
5+`crates/ec-av1/src/decode.rs:11943/11946` read the per-MI bands
6+`above_inter`/`left_inter` as `[mi_c / (SUB / MI)]` / `[mi_r / (SUB / MI)]`.
7+Those two vectors are written by `record_inter` as `[c + cell]` (per MI) and are
8+read as `[cmi]`/`[rmi]` at every other site (17426, 20183, 20614, 21180), so the
9+division read a column/row FOUR mi away. When that stale cell said "inter", the
10+neighbour contributed its 8-px BLOCK size instead of its 4-px TRANSFORM size and
11+`get_tx_size_context` returned 2 where libaom returns 1. Fix = index by `mi_c` /
12+`mi_r`. Only 2 sites in the file used the division (grep `/ (SUB / MI)]`); both
13+fixed, no sibling instances remain.
14+
15+libaom reference: `pred_common.h` `get_tx_size_context` (above/left from
16+`above_txfm_context[0]`, overridden by `block_size_wide/high` only when the
17+neighbour `is_inter_block`).
18+
19+## The r2 premise was WRONG -- do not chase txb_skip again
20+- The txb_skip CDF row is NOT divergent. libaom stores INVERTED cdfs: aomdec's
21+ `[15,0,32]` IS our `[32753,32768,32]`. Verified read-by-read: a private
22+ instrumented aomdec (`EC_TRACE_TXBCDF`, private build dir
23+ `~/.cache/leaf8tx-aombuild`, source patch reverted afterwards) printed
24+ `txb_skip_cdf[txs_ctx][ctx]` at every all_zero read; all 1220 luma
25+ (txs=0,ctx=6) reads carry cdfs identical to ours, and the per-class read
26+ histograms match exactly (aom `plane0 txs0 ctx6`=1220 = our `side=4 ctx=6`;
27+ aom chroma ctx 7/8/9 = our chroma rows 0/1/2).
28+- The real desync is one element EARLIER, in the MODE ladder: `EC_ISTEP`
29+ `name=tx_depth mi_row=30 mi_col=36` -- same range in (43044), same value (1),
30+ same ctx (2), different range out (ours 47744, aomdec 50432), because two
31+ blocks earlier at mi(20,46) we read ctx=2 where aomdec reads ctx=1 (identical
32+ range there by luck, class [[wrong-alphabet-same-value]]) and adapted the wrong
33+ `tx_size_cat0` row. Exactly 1 ctx mismatch in 449 tx_depth reads of the stream.
34+- Instrument fixed on our side too: the square coefficient path never traced the
35+ `br` rung, so the cross-decoder ladder was blind to base-range symbols and
36+ mis-reported the divergence. `EC_COEFF_STEP tag=br ...` added at decode.rs:3679.
37+
38+## EVIDENCE
39+EVIDENCE: ~/.cache/leaf8tx-tmp/our2.yuv vs ref.yuv | EC_LEAF8TX_SPLIT=1 decode_probe on the pinned 10-bit stream s68.obu (md5 587b4f1d6fbc15249c0ddd0479d55fd7) vs aomdec --rawvideo | `cmp` byte-identical (PIXEL EXACT; r2's 1140/281/285 mismatching samples are gone)
40+EVIDENCE: ~/.cache/leaf8tx-tmp/our_istep4.log | EC_TRACE_MODE_STEP ladder ours vs aomdec | 0 tx_depth ctx mismatches after the fix (was 1 at mi(20,46))
41+
42+## STATE / still owed
43+- The tx_depth-split REFUSAL IS STILL IN PLACE (decode.rs:22610, bypassable with
44+ `EC_LEAF8TX_SPLIT=1`); refusal_inventory.rs:72 unchanged. Lifting it needs the
45+ gate arms + a suite run, which the turn cap cut. The pixel-exact pin above is
46+ the proof that the lift is now unblocked.
47+- `a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact`
48+ (r2's continue-and-sweep conversion) was NOT run to completion: the r3 suite
49+ (`$HOME/.cache/leaf8tx-suite-r3base.log`, PRE-fix code) never printed a
50+ `test result` line before the cap; it shows 2 failures that predate this round's
51+ fix: `decode::tests::an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking`
52+ and `refusal_inventory::tests::the_decode_path_refuses_exactly_the_listed_cases`
53+ (both look like r2 merge-resolution fallout of the OBMC refusal string, not
54+ entropy). Re-run the whole suite on the fixed tree FIRST.
55+- The angle-delta gate and cdef/sub16 gate were not re-run this round.
56+
57+## Oracle source incident (fixed, read this before touching the oracle)
58+I ran `git checkout av1/decoder/decodetxb.c` in `~/.cache/aom-oracle/src` to drop
59+my own one-line probe and it wiped 50 lines of OTHER lanes' uncommitted
60+instrumentation (class [[checkout-ate-uncommitted-work]] again). Restored:
61+`scripts/instrument-aom-oracle.sh` re-applied rungs 3+11, and the remaining
62+hand-added prints (base/br in both `read_coeffs_reverse*`, all_zero, tx_type
63+outside the AOM_PLANE_Y branch, extended base_eob) were reconstructed from the
64+shared aomdec binary's format strings. Proof of restoration: a fresh trace from a
65+rebuild of the restored source is `cmp`-identical to the pre-incident
66+`~/.cache/leaf8tx-tmp/aom_coeff.log`. The SHARED `~/.cache/aom-oracle/build`
67+was never rebuilt.
lanes/leaf8tx-r4.report.mdadded+78 -0
@@ -0,0 +1,78 @@
1+# lane-leaf8tx r4 report -- refusal lifted, gate swept
2+
3+## What changed
4+- `crates/ec-av1/src/decode.rs:22602` -- the refusal "an 8x8 intra leaf in an inter frame
5+ whose tx_depth splits it into 4x4 transform units" and its `EC_LEAF8TX_SPLIT=1` env bypass
6+ are DELETED; the per-TU 4x4 path is now the only path for that leaf. (Root cause that
7+ unblocked it landed in r3, `d226074`: `tx_size_context_txfm` read `above_inter`/`left_inter`
8+ at `mi/4`.)
9+- `crates/ec-av1/src/refusal_inventory.rs:69` -- the refusal string removed, replaced by the
10+ lane note naming the gate that carries it.
11+- `crates/ec-av1/src/stream.rs:6574,6580` -- `tx_split_angle_in_inter8_gate` is now
12+ continue-and-sweep: all 30 aomenc arms of each bit-depth run, every decode-order frame is
13+ pixel-compared on Y/U/V (a mismatch is an immediate FAILURE, never a SKIP), and the two hit
14+ counters are asserted ONCE after the sweep -- `totals.0 > 0` (an 8x8 intra-in-inter leaf with
15+ tx_depth split to 4x4 was decoded AND compared) and `totals.1 > 0` (nonzero `angle_delta_y`).
16+- `crates/ec-av1/src/gate_coverage.rs` -- unchanged, and correctly so: it keys on `--enable-*`
17+ flags, and this gate already spells `--enable-tx-size-search=1`/`--enable-angle-delta=1`, so
18+ no entry named the lifted tool.
19+- `crates/ec-av1/src/stream.rs:6740` -- the SHIPPED recipe of that gate used to append
20+ `--enable-tx-size-search=0` (aomenc keeps the LAST occurrence), so the split it is meant to
21+ prove never fired: measured 0 split-tx hits on 30 arms. It now ships
22+ `--enable-tx-size-search=1 --enable-angle-delta=1`, and odd attempts add
23+ `--max-partition-size=8` (the shape that produces the 2x2 TX_4X4 grid most often).
24+- `crates/ec-av1/src/decode.rs:25668` -- the r2 merge kept main's refusal text ("an OBMC
25+ neighbour whose *switchable* interp filter was never recorded") but the unit test still
26+ asserted the pre-merge string; test updated to main's text. NOT a decode change.
27+- `crates/ec-av1/src/refusal_inventory.rs` -- two strings the r2 rectchroma2 merge made stale
28+ ("a 1:4 rect strip that actually uses a palette", "an inter partition below 8x8") deleted;
29+ `the_decode_path_refuses_exactly_the_listed_cases` demanded exactly that.
30+
31+## Gate
32+```
33+EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-leaf8tx \
34+ cargo test -p ec-av1 --lib -j3 -- --nocapture --test-threads=3 \
35+ angle_delta_8x8_intra_leaf cdef_and_sub16 refusal_inventory gate_coverage \
36+ an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking
37+```
38+`test result: ok. 16 passed; 0 failed; 0 ignored; 423 filtered out; finished in 79.26s`
39+(log `$HOME/.cache/leaf8tx-r4-step23.log`)
40+
41+EVIDENCE: $HOME/.cache/leaf8tx-r4-step23.log | 30 aomenc arms x 2 bit depths, every decode-order frame compared on Y/U/V vs ffmpeg | `tx_split_angle_in_inter8_gate(8): buckets counted-exact=29 uncounted-exact=1 named-refusals=0 (attempts 30)`, `tx_split_angle_in_inter8_gate(10): counted-exact=30 uncounted-exact=0 named-refusals=0 (attempts 30)`, 0 pixel mismatches
42+EVIDENCE: $HOME/.cache/leaf8tx-r4-step23.log | same run, split-leaf hit counter per arm | e.g. `(10) seed=43 --cq-level=19: 8x8 intra-in-inter leaves with tx_depth=1 315, nonzero angle_delta_y 124` -- the counter fires in the hundreds on decoded+compared attempts (it was 0 on every arm of the pre-r4 recipe)
43+
44+## Step 3 (by name, same 16-test run above): ALL OK
45+`cdef_and_sub16` (r2's continue-and-sweep conversion, never run before) ok; all 7
46+`gate_coverage` tests ok; `refusal_inventory::the_decode_path_refuses_exactly_the_listed_cases`
47+ok (after dropping the two stale strings); `an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking`
48+ok (after the test's expected string was aligned with main's refusal text -- it had been failing
49+since the r2 merge, i.e. NOT caused by this round's decode change).
50+Coordinator's ask: `a_real_aomenc_inter_sequence_with_a_split_transform_intra_block_decodes_pixel_exact`
51+and its `10bit_` twin both **ok** on this tree (full-suite log below) -- lane-mergefix's
52+independent `tx_size_context_txfm` fix agrees with r3's `d226074`.
53+
54+## Full suite
55+`systemd-run --user --unit=leaf8tx-suite-r4-... -p MemoryMax=10G` ->
56+`test result: FAILED. 404 passed; 1 failed; 34 ignored; 0 measured; 0 filtered out; finished in 683.00s`
57+(log `$HOME/.cache/leaf8tx-suite-r4.log`). Baseline for comparison, PRE-lift on the same tree
58+(`$HOME/.cache/leaf8tx-suite-r3base.log`): `403 passed; 2 failed` -- the two r2-merge failures
59+above, both now green.
60+
61+FAILED: `stream::tests::a_frame_edge_straddling_band_decodes_pixel_exact`
62+```
63+68x192 cq61 frames=5 10bit=false tile_cols=1 frame 1 plane Y: 2248 pixels differ,
64+first at row 56 col 50 (ours 117 vs ffmpeg 118) [edge32=[0, 34, 0, 0, 1, 17, 0, 1]]
65+```
66+This is the lift's cross-product, class [[refusal-hides-a-defect]] and exactly what that gate's
67+own doc comment (stream.rs:21573) predicted: its multi-tile arms were 32/32 refused BY NAME,
68+the census listing `6x "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4
69+transform units"`. With that refusal gone those arms decode for the first time and one of them
70+mismatches -- a defect the refusal was hiding, not a regression of the split-leaf path (the
71+leaf8tx gate itself is pixel-exact on 60/60 arms, and the two split-transform-intra-block gates
72+are green).
73+
74+Disposition: deferred(a round scoped to the CDEF frame-edge straddle x multi-tile x 8x8-split-leaf
75+cross-product; start by bisecting whether the 2248-pixel luma delta is CDEF filtering or the
76+entropy state of the newly decoded split leaves in that arm) -- not fix-now here: found at
77+T-30min of a 60-minute round, after the commit that lifts the refusal. It must NOT be closed by
78+re-adding the refusal.
lanes/mc64-r1.handoff.mdadded+29 -0
@@ -0,0 +1,29 @@
1+# lane-mc64 r1 handoff
2+
3+STREAM: `crates/ec-av1/fixtures/av1_192x128_8bit_intra64_in_inter.obu`
4+(md5 add55f625b6302c523455bb8662b19f5, sha256 e4cff46cb1700527c68efc866db27a2835705e949d646f73f0c9df577d594bd6).
5+The r2 aomenc recipe does NOT regenerate it (measured: 19003 bytes md5 278be003743daed5ea116cd41056537a). Use the fixture.
6+
7+DEFECT, restated correctly:
8+decode-order frame 2, superblock at px(128,64) = mi(16,32), `EC_PART_VAL bsize=12 value=0`
9+(PARTITION_NONE 64x64), **INTRA block in an inter frame** (aomdec prints no EC_MODE/EC_IMODE
10+for it because `read_intra_block_mode_info` is uninstrumented; ours prints
11+`EC_MODE ... is_inter=0 skip=false`). Pre-deblock luma differs in exactly that 64x64
12+(3720/4096 samples, delta -12..+9), chroma bit-exact. Frames 0 and 1 exact.
13+The charter's `mode=16 ref0=4 mv0=(-340,-116)` belongs to FRAME 1's mi(16,32), which is
14+PARTITION_SPLIT there and decodes exactly. Do not chase MC: `EC_MC_TRACE=1` shows zero
15+MC/warp/compound calls for this block.
16+
17+REPRO (both under systemd-run --user --scope -q -p MemoryMax=6G):
18+ EC_AV1_PREFILT_DUMP=<dir>/ref ~/.cache/aom-oracle/build/aomdec --rawvideo -o /dev/null <obu>
19+ EC_NOMEMGUARD=1 EC_AV1_PREFILT_DUMP=<dir>/our <target>/debug/examples/decode_probe <obu>
20+ cmp -l <dir>/ref.f2 <dir>/our.f2 | wc -l # 3720
21+Scratch scripts: ~/.cache/mc64-tmp/{cmp.sh,gen.sh,gen2.sh}. Decode stops at frame 3 with
22+lane-intra64split's "a split intra strip whose transform unit is 64x32" refusal — unrelated.
23+
24+NEXT: luma-only + chroma-exact on a 64x64 intra block points at the 64-length luma transform.
25+Bisect in this order: (1) TX_64X64 coefficient region (`av1_get_adjusted_tx_size` -> only the
26+top-left 32x32 is coded) and its eob domain; (2) the 64-point inverse (`transform.rs:276`
27+`hadamard` tail, `row_shift_wh(64,64) == 2`); (3) the 64x64 intra prediction itself.
28+`transform.rs:1412 a_64x64_transform_keeps_what_fits_in_its_coded_quarter` is the existing
29+64x64 self-check — it passes, so whatever is wrong is outside its span.
lanes/mc64-r1.report.mdadded+91 -0
@@ -0,0 +1,91 @@
1+# lane-mc64 r1 — RED (charter premise disproved; real defect re-localised)
2+
3+## Verdict
4+RED. The charter's defect description is wrong in its central fact: the
5+mismatching block is **not** an inter NEWMV block off GOLDEN with a half-pel
6+mv. It is a **64x64 INTRA block inside an inter frame** (no motion
7+compensation happens for it in either decoder), so every one of the charter's
8+six candidate causes (a)..(f) is about a code path this block never enters.
9+No fix shipped; the lane is re-pointed, with the measurement chain below.
10+
11+## Premise re-measurement (all commands run this round)
12+Stream pinned as `crates/ec-av1/fixtures/av1_192x128_8bit_intra64_in_inter.obu`
13+(byte-identical to the r2 scratch `s48.obu`, md5 `add55f625b6302c523455bb8662b19f5`,
14+sha256 `e4cff46cb1700527c68efc866db27a2835705e949d646f73f0c9df577d594bd6`).
15+
16+The r2 recipe **does not regenerate it**: re-running the gate's exact aomenc
17+argv (attempt 6 => seed 48, 192x128, `--cpu-used=2 --cq-level=40`, mandelbrot
18+`start_scale=4.64`) on the identical y4m (md5 `6de0c8c6c3ff90715b476d966c622932`,
19+hashed twice) yields a 19003-byte stream md5 `278be003743daed5ea116cd41056537a`,
20+not the 26321-byte `s48.obu`. Both file-output and the gate's stdin/stdout form
21+give the same 19003-byte result. So `s48.obu` came from some *other* r2 scratch
22+invocation; the .obu is therefore pinned as a fixture instead of as a recipe.
23+
24+EVIDENCE: ~/.cache/mc64-tmp/{gen.sh,gen2.sh,g48.obu,g48b.obu,s48.obu} | ffmpeg lavfi -> aomenc twice, file and pipe forms | md5 278be00... twice vs pinned add55f6..., sizes 19003 vs 26321
25+
26+Mismatch itself reproduces exactly as reported:
27+EVIDENCE: ~/.cache/mc64-tmp/{A.ref.f0..f2,A.our.f0..f2} | aomdec EC_AV1_PREFILT_DUMP vs our EC_AV1_PREFILT_DUMP on the pinned obu | frame 0 diff 0, frame 1 diff 0, frame 2 luma diff 3720 confined to x 128..191 y 64..127, chroma diff 0
28+
29+## ROOT LOCALISATION — the block is intra, not inter
30+1. `aomdec EC_TRACE=1 EC_TRACE_MODE=1` interleaved: the frame-2 superblock at
31+ mi(16,32) reads `EC_PART_VAL mi_row=16 mi_col=32 bsize=12 value=0`
32+ (PARTITION_NONE, 64x64) and then **no `EC_MODE` and no `EC_IMODE` line at
33+ all** — the next trace line is the following frame's first `EC_PART`
34+ (`tell=1`).
35+2. Oracle source, `av1/decoder/decodemv.c:1698-1710`: `read_inter_frame_mode_info`
36+ prints `EC_MODE` only from `read_inter_block_mode_info`; the
37+ `read_intra_block_mode_info` arm (intra block in an inter frame) is
38+ **uninstrumented**. Silence there means `inter_block == 0`, not "no block".
39+3. Our decoder agrees: `EC_MODE mi_row=16 mi_col=32 is_inter=0 skip=false`
40+ with `EC_IB px=128 py=64 side=64 w=64 h=64`, and **zero** MC / warp /
41+ compound calls for it (`EC_MC_TRACE` instruments `mc::predict_with_filters`,
42+ `mc::predict_compound_intermediate` and `warp::warp_affine`; 33 MC calls in
43+ the whole decode, none at this block).
44+4. The charter's `mode=16 ref0=4 mv0=(-340,-116)` line is real but belongs to
45+ **decode-order frame 1**, where mi(16,32) is `EC_PART_VAL bsize=12 value=3`
46+ (SPLIT) into four 32x32 blocks. Frame 1 is pixel-exact for us. This is the
47+ class `[[dump-not-call-unique]]` / `[[stale-output-faked-measurement]]`
48+ again: a coordinate-keyed grep with no frame key picked the wrong call.
49+
50+EVIDENCE: ~/.cache/mc64-tmp/{aom_both.log,aom_part.log,mct4.log} | aomdec EC_TRACE+EC_TRACE_MODE and our EC_MC_TRACE on the pinned obu | frame-2 mi(16,32) = PARTITION_NONE 64x64 with no mode trace line; ours is_inter=0, 0 MC calls; frame-1 mi(16,32) = PARTITION_SPLIT, that is where mv=(-340,-116) lives
51+
52+## What the defect actually is (direction, not yet a fix)
53+A 64x64 **intra** block in an inter frame: luma wrong by -12..+9 over 3720 of
54+4096 samples, chroma (32x32, TX_32X32) bit-exact. Luma is the only plane with a
55+64-length transform, and `av1_get_adjusted_tx_size` codes only the top-left
56+32x32 of a TX_64X64. So the suspects are, in order: the TX_64X64 coefficient
57+region / eob domain, the 64-point inverse transform's row/col zeroing, and the
58+intra prediction of a 64x64 block. The error is structured, not a constant
59+offset, which argues residual over prediction — 376 of 4096 samples are equal,
60+so it is not a wholesale desync either.
61+
62+## What changed
63+* `crates/ec-av1/src/decode.rs` — `stage_dump_idx()`; `dump_stage`/`dump_stage16`
64+ now key their file on the decode-order picture index instead of always
65+ writing `.f0`. Before this, `EC_AV1_POSTDEBLOCK_DUMP`/`POSTCDEF_DUMP` compared
66+ the LAST decoded frame no matter which frame you meant (the ledger records
67+ this for the pre-8c6065e prefilt dump; the postdeblock/postcdef twins were
68+ never fixed). This is a real instrument defect, fixed, not a workaround.
69+* `crates/ec-av1/src/decode.rs` — `EC_MC_TRACE` prints `EC_IB px py side w h`
70+ at `decode_inter_block` entry; `EC_MODE` now carries `is_inter=` and `skip=`.
71+* `crates/ec-av1/src/mc.rs`, `crates/ec-av1/src/warp.rs` — `EC_MC_TRACE` prints
72+ `EC_MC_CALL` / `EC_MC_COMP` / `EC_MC_WARP` with the q4 position, block size,
73+ subpel fractions and resolved kernels. Placed BEFORE the whole-pel fast path
74+ so a block that takes no MC call at all is visible as an absence.
75+* `crates/ec-av1/fixtures/av1_192x128_8bit_intra64_in_inter.obu` — the stream,
76+ pinned (`git add -f`), because its recipe does not reproduce it.
77+
78+## Refusals
79+None lifted, none added. No gate added: a gate asserting a counter for a shape
80+whose cause is unidentified would be theatre, and the charter's counter
81+("64x64 NEWMV single-ref blocks with half-pel mvs") counts a population this
82+defect is not in.
83+deferred(root cause): the gate — needs the TX_64X64-vs-prediction split below.
84+
85+## Residue
86+* fix-now (r2): split prediction from residual for frame-2 mi(16,32) by
87+ reconstructing the block with the residual forced to zero and comparing the
88+ *shape* of the error; then bisect TX_64X64 (adjusted 32x32 coefficient
89+ region, eob domain, `row_shift_wh(64,64)==2`, the 64-point `hadamard` tail at
90+ `transform.rs:276`) against `EC_TRACE_COEFF` from the oracle.
91+* accepted: the r2 recipe is not reproducible; the .obu is a fixture now.
lanes/mc64-r2.report.mdadded+73 -0
@@ -0,0 +1,73 @@
1+# lane-mc64 r2 -- the frame-2 64x64 intra-in-inter drift was the no-CFL uv_mode alphabet (fixed by the merge)
2+
3+## Verdict: GREEN. No decoder line of mine; the merge fixed it, and the round pins it.
4+
5+Tip `5bfb38b` on `lane-mc64` (base main `727f29a`, merged `lane-sqdrift` `7d498c0` at `0a2269b`).
6+
7+## 1. What the defect was
8+
9+Charter defect (r1 handoff): `crates/ec-av1/fixtures/av1_192x128_8bit_intra64_in_inter.obu`,
10+decode-order frame 2, mi(16,32), 64x64 `PARTITION_NONE` INTRA block inside an INTER frame --
11+3720/4096 luma samples wrong (-12..+9), chroma bit-exact, decode then dying at frame 3 on
12+lane-intra64split's "a split intra strip whose transform unit is 64x32" refusal.
13+
14+None of the six charter suspects (tx_depth granularity, 64x64 edge availability, edge filter
15+with inter neighbours, TX_64X64 coded corner, palette-at-64, delta_q) is the cause. The cause
16+is the one lane-sbrect10 found (`9f1f108`) and lane-sqdrift confirmed by ablation (`7d498c0`):
17+libaom `is_cfl_allowed` (`blockd.h`, spec 5.11.5: `block_size_wide[bsize] <= 32 &&
18+block_size_high[bsize] <= 32`) excludes a 64-axis block from CFL, so its `uv_mode` comes off
19+the 13-symbol `uv_mode_no_cfl` alphabet. We read the 14-symbol CFL one -- same `DC_PRED`
20+value, different interval narrowing (class `wrong-alphabet-same-value`). The luma-only,
21+chroma-exact signature that pointed r1 at the 64-length luma transform is a red herring: the
22+desynced tail happened to leave chroma intact on this frame, and the frame-3 refusal was a
23+phantom of our own desync (class `refusal-from-own-desync`).
24+
25+`decode.rs:6270` and `decode.rs:18781` (`cfl_allowed = bw.max(bh) <= 32`) arrive with the
26+merge; the merge conflicts I resolved were in the per-frame dump index (kept r1's shared
27+`stage_dump_idx()`) and two test blocks appended at the same point (both kept).
28+
29+## 2. Measurement, on the merged tree, same fixture, same command as r1
30+
31+EVIDENCE: /home/user/.cache/mc64-tmp/R2.{ref,our}.f0..f5 | `bash ~/.cache/mc64-tmp/cmp.sh crates/ec-av1/fixtures/av1_192x128_8bit_intra64_in_inter.obu R2` under `systemd-run --user --scope -q -p MemoryMax=6G` (instrumented aomdec `EC_AV1_PREFILT_DUMP` vs our `decode_probe`) | f0..f5 all `0` differing bytes; probe reports `OK: 6 frames decoded, 192x128` (r1: f2 = 3720 bytes differing, decode stopped at f3)
32+
33+## 3. The gate (new)
34+
35+`crates/ec-av1/src/stream.rs:7400`
36+`a_pinned_rect_stream_with_a_64x64_intra_block_in_an_inter_frame_decodes_pixel_exact`
37+
38+The RECT-ON twin of sqdrift's square-only gate (which the merge brings in and which is
39+rect-OFF by construction). The fixture is pinned rather than regenerated because its recipe
40+is not reproducible (r1 measured: re-encoding the same y4m gives 19003 bytes md5
41+`278be003743daed5ea116cd41056537a`, not the fixture's `add55f625b6302c523455bb8662b19f5`;
42+class `seeded-fixture-not-reproducible`). It asserts all 6 decode-order frames byte-exact
43+against the oracle through the existing `decode_all_frames_vs_oracle` helper (hidden frames
44+included, no SKIP on mismatch or decode error) and `nocfl_uv_mode_hits() > 0` as the witness
45+that the 64-axis no-CFL narrowing fired. `have_aomenc()` under `EC_AV1_REQUIRE_AOMENC=1`
46+fails instead of skipping.
47+
48+EVIDENCE: `cargo test -p ec-av1 --lib a_pinned_rect_stream_with_a_64x64` | run on the merged tree | `test result: ok. 1 passed; 0 failed`
49+
50+Non-vacuity, proved this round, not remembered:
51+
52+EVIDENCE: ablation `decode.rs:18781 let cfl_allowed = true;` rebuilt, test re-run, line reverted (`git diff --stat` after revert = stream.rs only) | same command | `test result: FAILED. 0 passed; 1 failed` (panic at stream.rs:2047, the oracle frame compare)
53+
54+## 4. Refusals
55+
56+None lifted. The frame-3 "split intra strip whose transform unit is 64x32" refusal this
57+stream used to hit was a phantom of the desync and is simply not reached now; it remains a
58+real ceiling for other streams, so `refusal_inventory.rs` is untouched. `refusal_inventory`
59++ `gate_coverage` tests green.
60+
61+## 5. Suite
62+
63+`$HOME/.cache/mc64-suite-r2.log` (unit `mc64-suite-r2-1788332399.service`): `test result: ok. 385 passed; 0 failed; 33 ignored; 0 measured; 0 filtered out; finished in 1152.96s`
64+
65+r1's unit `mc64-suite-1788331999.service` was still running at r2 start (186 ok, 0 FAILED,
66+`$HOME/.cache/mc64-suite-r1.log`) and was stopped -- one suite per target dir.
67+
68+## 6. Residue
69+
70+- accepted: no new decoder code this round; the lane's defect was fixed upstream in
71+ lane-sqdrift/lane-sbrect10 and is now pinned from the rect side too.
72+- deferred(another lane owns it): the "split intra strip whose transform unit is 64x32"
73+ refusal (lane-intra64split) -- unblocked by that lane's 64x32 TU work, not by this fixture.
lanes/mergefix-r2.report.mdmodified+4 -12
@@ -72,16 +72,8 @@ and 16-level ctx (0/0) already agree with aomdec, so this is a single-site defec
7272
7373 fix-now (handed off): see `lanes/mergefix-r2.handoff.md`.
7474
75-## Sibling gates (run AFTER the fix, one invocation)
76-
77-`cargo test -p ec-av1 --lib -j3 -- <9 names>` -> **ok. 9 passed; 0 failed** in 162.65s:
78-split_transform_intra_block (8-bit + 10-bit), intra_rect_strip (8-bit + 10-bit),
79-split_transform_horz_vert_strip, split_transform_superblock_strip,
80-coded_strip_whose_chroma_is_a_4to1_or_sub8_rect, sub8x8_inter_split,
81-16x16_level_ab_partitions.
82-
83-EVIDENCE: cargo test output | the 9 gates above re-run on the fixed tree | 9 passed 0 failed
84-
8575 ## Test totals
86-Full `cargo test -p ec-av1 --lib` NOT run this round (hard 50-minute deadline):
87-deferred(one suite run) -- the 9 sibling gates plus the lane's own gate were run by name.
76+Not run to completion this round (hard 50-minute deadline). The one gate above was run by
77+name. Sibling gates (split-transform, sb128c intra_rect_block/gathered_edge_horz,
78+uv8/intersub8/inter16ab/rectchroma2) are NOT yet re-run --
79+deferred(one `cargo test -p ec-av1 --lib` invocation with those names).
lanes/pal8-r1.handoff.mdadded+47 -0
@@ -0,0 +1,47 @@
1+# lane-pal8 r1 HANDOFF
2+
3+Branch `lane-pal8`, tip **7d9902c** (parent `3d5a737` = merge of lane-kf900 5a28354 into main 8810bad).
4+Everything below is COMMITTED; nothing is in-flight.
5+
6+## What the patch does
7+`crates/ec-av1/src/decode.rs` `decode_leaf8` (the square 8x8 intra leaf) now passes its
8+own per-mi palette ctx + colour cache into `read_intra_mode`
9+(`palette_ctx_and_cache_mi` / `palette_uv_cache_mi`, kf900's per-mi bands), keeps the
10+returned `PaletteY`/`PaletteUv`, reconstructs through the existing `PALETTE_PRED` slot
11+(whole 8x8; a per-4x4-TU window slice under a split `tx_depth`; a palette skip leaf takes
12+the single 8x8 reconstruct), and stamps the leaf's real palette size/colours into the
13+neighbour bands. New counter `PALETTE_LEAF8_HITS` + getter/reset.
14+References: `read_palette_mode_info` decodemv.c:567, `read_palette_colors_y/uv`
15+decodemv.c:478, `av1_visit_palette` / `av1_decode_palette_tokens` decodeframe.c:1135.
16+
17+## Refusal targeted / lifted
18+"a block that actually uses a palette (Y|UV) -- reconstruction is out of scope" is no
19+longer reachable from `decode_leaf8`. Both strings STAY in `refusal_inventory.rs` -- they
20+are still live on the inter-frame intra paths (decode.rs 19783/19788, 22479/22484), which
21+are another lane's scope. No inventory line was removable.
22+
23+## Localised, measured, NOT lifted
24+"a palette block with a real transform on a superblock-level HORZ/VERT strip". I removed
25+it and re-ran the gate: stream `testsrc2` 128x128 10-bit cq55 `--enable-tx-size-search=0
26+--tile-columns=1 --tune-content=screen --enable-palette=1 --min-partition-size=8
27+--limit=1` decodes frame 0 with a whole-frame mismatch vs ffmpeg. So the refusal is REAL,
28+not stale; restored with that measurement in the code comment, and the gate now asserts an
29+arm still reaches it. Next agent: bisect that stream's first `decode_block_rect64` palette
30+block with an msac range ladder (the corner-cropped luma path expands `min(bw,32)` x
31+`min(bh,32)` levels into a `bw`x`bh` grid and reconstructs once, so the prediction shape
32+already matches the palette buffer -- suspect the residual/scan or class
33+`refusal-hides-a-defect`).
34+
35+## Gate
36+`a_real_aomenc_palette_stream_with_8x8_leaves_decodes_pixel_exact` (stream.rs), 48 arms,
37+GREEN: 44 8x8-leaf palette blocks across 24 arms, 47 arms / 47 frames pixel-exact,
38+0 out-of-scope mismatches, 1 named refusal (the SB-strip one).
39+
40+## Untested / open
41+- Full suite: 401 passed / 1 failed / 33 ignored. Failure
42+ `a_frame_edge_straddling_band_decodes_pixel_exact` 68x192 cq35 10-bit tile_cols=1,
43+ frame 1, 6944 luma pixels. Attribution unverified -- run that single test at 3d5a737
44+ first (see lanes/pal8-r1.report.md for the exact command).
45+- Inter-frame palette (the 19783/22479 sites) untouched.
46+- The gate is key-frame only (`--limit=1`): the inter frames of this recipe stop on other
47+ lanes' refusals (non-DC chroma on an 8x8 inter leaf; inter 16x16 1:4 partitions).
lanes/pal8-r1.report.mdadded+94 -0
@@ -0,0 +1,94 @@
1+# lane-pal8 r1 -- palette on a square 8x8 leaf
2+
3+Built on `lane-kf900` 5a28354 (merged first, commit `merge lane-kf900`).
4+
5+## What changed
6+
7+- `crates/ec-av1/src/decode.rs` `decode_leaf8` (~10680): the square 8x8 leaf now
8+ passes its OWN palette-Y mode ctx + colour cache
9+ (`neighbours.palette_ctx_and_cache_mi(leaf_mi)` / `palette_uv_cache_mi`) into
10+ `read_intra_mode` instead of `None`/`&[]`, and keeps the returned
11+ `PaletteY`/`PaletteUv` instead of dropping them. Mirrors
12+ `read_palette_mode_info` (decodemv.c:567; `av1_get_palette_mode_ctx`,
13+ `av1_get_palette_cache`, `read_palette_colors_y/uv` at decodemv.c:478) and
14+ `av1_decode_palette_tokens` / `av1_visit_palette` (decodeframe.c:1135), whose
15+ colour-index map is read after the whole mode-info read -- both already
16+ implemented in `read_intra_mode`; only this call site was excluded.
17+ `palette_bsize_ctx(8)` is `num_pels_log2 - 6 = 0`, chroma map is the 4x4
18+ (`ss_size_lookup`) one `read_intra_mode` already decodes at `side / 2`.
19+- Same fn: reconstruction wired through the existing `PALETTE_PRED` slot --
20+ whole-block 8x8 buffer for the single-TX8 and skip arms, a per-4x4-TU window
21+ slice under a `tx_depth`-split leaf (the same slicing `decode_block` does at
22+ 16x16 and up); a palette skip leaf takes the single 8x8 reconstruct, never the
23+ per-TU one (`decode_block`'s own `split_tx_skip` rule).
24+- Same fn: the two `record_palette_y_rect(leaf_mi, 8, 8, 0, [0; 8])` tail sites
25+ now stamp the leaf's REAL palette size/colours into the per-mi neighbour bands
26+ (kf900's bands), so the next block's ctx and colour cache see it.
27+- New counters `PALETTE_LEAF8_HITS` (+ getter/reset) for the gate.
28+- `crates/ec-av1/src/stream.rs`: new gate
29+ `a_real_aomenc_palette_stream_with_8x8_leaves_decodes_pixel_exact`.
30+
31+## Refusals
32+
33+- LIFTED (for the square 8x8 leaf): `"a block that actually uses a palette (Y)
34+ -- reconstruction is out of scope"` and its UV twin no longer reachable from
35+ `decode_leaf8`. The two strings STAY in `refusal_inventory.rs`: they are still
36+ live on the inter-frame intra paths (decode.rs:19783/19788, 22479/22484),
37+ another lane's scope. No inventory line was removable this round.
38+- NOT lifted, MEASURED: `"a palette block with a real transform on a
39+ superblock-level HORZ/VERT strip"`. I removed it and re-ran the gate: the arm
40+ `testsrc2-10bit-cq55-txs0-tc1` decodes a whole-frame MISMATCH vs ffmpeg, so
41+ the refusal is real, not stale. Restored, with the measurement recorded in the
42+ code comment, and the gate now HARD-asserts that some arm still reaches it
43+ (`sb_strip_refusals > 0`) so the residue cannot silently disappear.
44+ Disposition: deferred(root-cause of the 64-level-strip palette mismatch --
45+ bisect the msac range of that stream's first SB-strip palette block, and check
46+ the class `refusal-hides-a-defect`: the mismatch may be an unrelated defect
47+ that the refusal was masking).
48+
49+## Gate
50+
51+`cargo test -p ec-av1 --lib a_real_aomenc_palette_stream_with_8x8_leaves -- --nocapture`
52+(`EC_AV1_REQUIRE_AOMENC=1`, oracle `~/.cache/aom-oracle/build/aomenc`).
53+48 arms: {testsrc2, smptebars} x {8, 10} bit x cq {30,40,55} x
54+`--enable-tx-size-search` {0,1} x `--tile-columns` {0,1}, 128x128,
55+`--tune-content=screen --enable-palette=1 --min-partition-size=8 --limit=1`
56+(key frame; the inter frames of this recipe stop on OTHER lanes' open refusals:
57+non-DC chroma on an 8x8 inter leaf, inter 16x16 1:4 partitions). Every decoded
58+frame compared against ffmpeg, `out_of_scope_mismatch == 0` asserted.
59+
60+EVIDENCE: ~/.cache/pal8-tmp/gate.log (pre-lift run) + the run below | aomenc 48 arms, ec-av1 decode, ffmpeg compare per frame | 44 8x8-leaf palette block(s) across 24 arm(s), 47 arms compared (47 frames), 23 out of scope (0 mismatched), 1 refused (1 superblock-strip palette) -- test result: ok
61+EVIDENCE: gate rerun with the SB-strip refusal REMOVED | same 48 arms | `testsrc2-10bit-cq55-txs0-tc1 MISMATCH at frame 0`, test FAILED -- which is why that refusal stayed
62+
63+Before this change the same 8-bit recipe refused with "a block that actually
64+uses a palette (Y)": measured with `~/.cache/pal8-tmp/enc.sh` + `decode_probe`
65+on 12 streams before the fix.
66+
67+## Suite
68+
69+`$HOME/.cache/pal8-suite-r1.log` -- see the tail of this file / the lane report line.
70+
71+## Suite (full, `$HOME/.cache/pal8-suite-r1.log`)
72+
73+`systemd-run --user --unit=pal8-suite-... -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3`
74+-> **401 passed, 1 failed, 33 ignored** in 1443 s. NOT the clean N/0 the charter asks for.
75+
76+The one failure is `stream::tests::a_frame_edge_straddling_band_decodes_pixel_exact`:
77+`68x192 cq35 frames=5 10bit=true tile_cols=1 frame 1 plane Y: 6944 pixels differ,
78+first at row 28 col 15 (ours 196 vs ffmpeg 197) [edge32=[5,27,0,5,2,16,0,1]]`.
79+That gate's own source comment already documents the 8-BIT twin of this arm as a
80+known, separate straddling-band defect ("68x192 cq35 frames=5 10bit=false frame 1
81+plane Y: 141 pixels differ ... LUMA, inside the 4-px straddling COLUMN"); the arm
82+here is the 10-bit one, which the merged lane-kf900 tip added.
83+
84+ATTRIBUTION NOT VERIFIED this round (turn cap). It is very unlikely to be this
85+lane's change -- the whole diff is inert unless a block actually decodes a
86+palette (`palette_y_buf.is_none()` keeps every non-palette path byte-identical)
87+-- but the recipe DOES use `--tune-content=screen`, so palette is live in it and
88+that must be checked, not assumed. Next step, one command:
89+`git worktree add --detach <scratch> 3d5a737` (the pre-change merge commit) with
90+its own `CARGO_TARGET_DIR` and run only
91+`cargo test -p ec-av1 --lib a_frame_edge_straddling_band_decodes_pixel_exact`.
92+Disposition: deferred(that one-test run at 3d5a737) -- if it fails there too, it
93+is the merged straddling-band residue and belongs to that lane; if it passes,
94+it is this lane's and the 8x8-leaf palette wiring must be bisected against it.
lanes/rect64port-r1.report.mdadded+45 -0
@@ -0,0 +1,45 @@
1+# lane-rect64port r1 — TX_64X32/TX_32X64 luma corner for a split intra strip
2+
3+Base: main 78d8ff7. Commit: 35f33c9 (branch lane-rect64port).
4+
5+## What changed
6+- `crates/ec-av1/src/decode.rs` — `decode_rect_split`: new `(64, 32) | (32, 64)` arm of the
7+ `luma_rect` table (guarded by `EC_RECT64_SPLIT`) plus the `luma_64corner` TU arm inside the
8+ transform-unit loop: `read_coeffs` on `TxbSet::Luma64` with `default_scan(TX32)`,
9+ txb_skip ctx 0, `Some((tx_w, tx_h))` for `av1_nz_map_ctx_offset`, corner copied into a
10+ `tx_w*tx_h` grid, `dequant_and_inverse_typed_wh` + `reconstruct_rect` +
11+ `record_mi_luma_rect`. Hand-ported from lane-intra64split 5ffbaf3 (its only decode hunk).
12+- `crates/ec-av1/src/decode.rs` — `RECT64_CORNER_TU_HITS` thread-local + `rect64_corner_tu_hits(orient)`
13+ (0 = 64x32, 1 = 32x64).
14+- `crates/ec-av1/src/stream.rs` — `pub fn rect64_corner_tu_hits`.
15+- `crates/ec-av1/examples/decode_probe.rs` — prints `rect64_corner_tu: 64x32=.. 32x64=..`.
16+- `refusal_inventory.rs` / `gate_coverage.rs`: UNCHANGED — the refusal is not lifted (see below).
17+
18+## Witness attempt — FAILED to produce a pixel comparison
19+The arm fires on both 10-bit 3840x1608 cuts, and the frontier moves, but the frame that
20+contains the shape never completes: it stops on a DIFFERENT refusal owned by the inter side,
21+`"a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding"`
22+(decode.rs:19156, `reject_residual && !skip && !rect_inter_residual_supported(..)`).
23+Truncating cut 0 to its 33 decoded frames and decoding gives `rect64_corner_tu: 0 0` — every
24+hit is inside the first REFUSED frame. So there is no frame to compare against ffmpeg, no gate
25+can be written, and the refusal stays.
26+
27+EVIDENCE: ~/.cache/rect64port-tmp/reelb300.log, ~/.cache/rect64port-tmp/full.log | decode_probe (release) on the two pinned film cuts, default vs EC_RECT64_SPLIT=1 | cut A: 33 frames dumped both ways, refusal "…transform unit is 32x64…" -> "…needs rectangular residual coding", counter 64x32=16 32x64=2; cut B: 1 frame dumped, same refusal swap, counter 64x32=0 32x64=2
28+EVIDENCE: ~/.cache/rect64port-tmp/t33.log + out.raw (389007360 B = 21 frames) | trunc.py cut A to 33 frame OBUs, decode with EC_PROBE_OUT16 | OK 21 frames 3840x1608, rect64_corner_tu 64x32=0 32x64=0 — the shape is confined to the refusing frame
29+
30+## Residue
31+- fix-now(next lane): the 64-level split intra strip needs the INTER rect-residual refusal at
32+ decode.rs:19151 lifted first; only then does a film frame carrying a 64x32/32x64 split intra
33+ strip finish and a pixel-exact witness gate become writable. Unblocked by: a lane that ports
34+ rectangular residual coding for non-skip HORZ/VERT/HORZ_B inter strips.
35+- deferred: the witness fixture `reelb_rect64_witness.obu` and the gate
36+ `a_10bit_film_inter_frame_with_a_64x32_split_intra_strip_decodes_pixel_exact` — nothing to pin
37+ while every candidate frame refuses.
38+
39+## Suite
40+`cargo test -p ec-av1 --lib -j3` (systemd unit, EC_AV1_REQUIRE_AOMENC=1):
41+417 passed, 3 failed, 37 ignored — identical totals and identical failing names to base 78d8ff7
42+(a_frame_edge_straddling_band, a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions,
43+real_aomenc_1to4_streams_..._rect_vartx_leaves_fire). No regression; refusal_inventory,
44+gate_coverage, split_transform_intra_strip and intra_1to4 tests are among the 417 passed.
45+EVIDENCE: $HOME/.cache/rect64port-suite-r1.log | full lib suite on 35f33c9 | 417/3/37, the 3 known reds
lanes/rectres-r1.report.mdadded+115 -0
@@ -0,0 +1,115 @@
1+# lane-rectres r1 — the 32x32-level 1:4 inter strip's rectangular residual
2+
3+## Step 1 MEASURE — the shape histogram (this is the whole finding)
4+
5+An env-gated one-liner at the refusal site (`crates/ec-av1/src/decode.rs`, in the
6+`reject_residual` block, `EC_RECTRES=1`) prints `(w, h, side, skip, is_inter, mi_row, mi_col)`.
7+Six probes, `EC_RECT64_SPLIT=1 EC_RECTRES=1`, each under `systemd-run --scope -p MemoryMax=6G`:
8+
9+| stream | refusing shape | skip | is_inter | at |
10+|---|---|---|---|---|
11+| 10-bit 3840x1608 cut 0 | **32x8** | 0 | 1 | mi 16,744 |
12+| 10-bit 3840x1608 cut 300 | **32x8** | 0 | 1 | mi 0,64 |
13+| 10-bit 1920x792 @900 | **8x32** | 0 | 1 | mi 24,148 |
14+| 10-bit 1920x792 @5400 | **32x8** | 0 | 1 | mi 20,448 |
15+| 10-bit 1920x792 @6300 | **8x32** | 0 | 1 | mi 0,56 |
16+| 10-bit 1920x792 @8100 | **32x8** | 0 | 1 | mi 10,184 |
17+
18+6 of 6 are the 32x32-level 1:4 strip. No 64-axis shape, no AB footprint, nothing else.
19+The charter's "most likely 32x64/64x32 and 64x16/16x64" premise is WRONG for these films —
20+those shapes are already supported and the films never stop on them.
21+
22+EVIDENCE: shell probe, 6 streams | `EC_RECT64_SPLIT=1 EC_RECTRES=1 decode_probe <cut>` | histogram above, 32x8 x4 / 8x32 x2, 0 other shapes
23+
24+## Step 2 IMPLEMENT — one shape family
25+
26+`max_txsize_rect_lookup[BLOCK_32X8] == TX_32X8`, all 256 positions coded.
27+
28+* `crates/ec-av1/src/cdf_state.rs` — new `TxbSet::LumaRect32x8Inter`: the existing INTRA
29+ `LumaRect32x8` tables (`get_txsize_entropy_ctx(TX_32X8)` = TX_16X16 -> luma-16 coefficient
30+ tables; `txsize_log2_minus4` = 4 -> 256-position `eob_pt`) **plus** a `tx_type` table the
31+ intra twin has none of. `av1_get_ext_tx_set_type` at `tx_size_sqr_up == TX_32X32` is
32+ `EXT_TX_SET_DCT_IDTX` for inter with *or without* `reduced_tx_set` (no branch), read at the
33+ `txsize_sqr_map[TX_32X8] == TX_8X8` row -> `inter_tx_type_8`. Class
34+ `table-indexed-by-raw-size`: the coefficient tables follow the ADJUSTED size and the
35+ `tx_type` row the SQUARE one, and here the two disagree.
36+* `crates/ec-av1/src/decode.rs` `rect_inter_residual_supported` — `+ (32, 8) | (8, 32)`.
37+* `crates/ec-av1/src/decode.rs` `rect_inter_luma_set` — `(32, 8) | (8, 32) => LumaRect32x8Inter`.
38+* `crates/ec-av1/src/decode.rs` `rect_inter_chroma_set` — `(16, 4) | (4, 16) => Chroma8`
39+ (`ss_size_lookup[BLOCK_32X8]` = BLOCK_16X4; TX_16X4 entropy ctx = TX_8X8, 64-position `eob_pt`).
40+* Counter `RECT32X8_INTER_TU_HITS` `[32x8, 8x32]` + `stream::rect32x8_inter_tu_hits()`, and
41+ `decode_probe` prints `rect32x8_inter_tu:`.
42+
43+Nothing else was needed: `SCAN_32X8`/`SCAN_8X32` already exist (the intra strip path uses them),
44+`sub_tx_size_map(32,8) == (16,8)` is an already-supported rect var-tx leaf, and
45+`read_inter_plane_rect`/`read_coeffs_rect` are shape-general.
46+
47+## Step 3 GATE
48+
49+`a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_codes_their_rect_residual`
50+(`crates/ec-av1/src/stream.rs`) — real aomenc, `--enable-1to4-partitions=1
51+--enable-rect-partitions=1 --enable-tx-size-search=1 --min-partition-size=8
52+--max-partition-size=32` (per-arm overrides last: aomenc keeps the last `--enable-*`),
53+16 attempts x {8-bit, 10-bit}, both orientations, every decode-order frame compared on Y/U/V
54+against ffmpeg, refusals counted never SKIPped, `oos_mismatch == 0` asserted, and one
55+hard assert per lifted shape on the PIXEL-COMPARED counter (a refused stream's hits are
56+tallied separately, class `counter-from-refused-stream`).
57+
58+Recipe found by a 72-run sweep (192x128..256x192, cq 24..60, bands 8/16/32/64): only
59+**32-pixel** motion bands at **cq >= 48** make aomenc code a NON-SKIP 32x32-level 1:4 strip.
60+Narrower bands give the same strips with `skip` set — they prove the partition symbol and
61+nothing about the residual (class `gate-blind-to-feature`).
62+
63+```
64+cargo test -p ec-av1 --lib a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips -- --nocapture
65+8-bit : 0 named refusals, 5 pixel-exact attempts carrying the arm, 11 carried none (0 mismatched)
66+10-bit: 0 named refusals, 4 pixel-exact attempts carrying the arm, 12 carried none (0 mismatched)
67+pixel-compared units 32x8=7 8x32=8 (decoded anywhere 32x8=7 8x32=8)
68+test result: ok. 1 passed; 0 failed
69+```
70+
71+EVIDENCE: /home/user/.cache/rectres-gate2.log | aomenc 32 streams (8+10 bit) -> decode -> ffmpeg Y/U/V compare | 15 pixel-compared 32x8/8x32 residual TUs, 0 mismatches
72+
73+`refusal_inventory.rs`: the string stays (sub-8x8 and AB footprints still have no rect
74+residual path) with a comment recording the narrowing. `gate_coverage.rs` needs no change —
75+it derives from `--enable-*` flags and this gate turns no tool off that others turn on.
76+
77+## Film frontier — before / after
78+
79+hg cut 0 (10-bit 3840x1608, 73 frame OBUs): **33 shown frames before, 33 after.** The gain is
80+INSIDE frame 34, not across frames: at prefix 50 that frame now decodes a 32x8 residual unit
81+(`rect32x8_inter_tu: 32x8=1`) and stops on a *different* wall —
82+`an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition`. All six cuts moved to
83+that same next refusal. So this lane removed one of at least two refusals in the films'
84+first blocking frame; the shown-frame count cannot move until the other lane lands.
85+
86+EVIDENCE: /home/user/.cache/rectres-bisect.log + probe on the 50-OBU prefix | trunc.py bisect over frame-OBU prefixes, decode_probe each | max OK prefix 49 OBUs = 33 shown frames; prefix 50 refuses on the intra-1:4 wall after coding one 32x8 residual TU
87+
88+## rect64 refusal — NOT lifted
89+
90+deferred: removing the `EC_RECT64_SPLIT` bypass — no witness exists. The 49-OBU prefix that
91+decodes clean reports `rect64_corner_tu: 64x32=0 32x64=0`; every rect64 hit (22 + 4) lives
92+inside the frame that still refuses on the intra 16x4/4x16 wall. Confirms the ledger dead-end
93+`lane-rect64port r1`. Unblocked by: the intra-16x4/4x16-in-inter-1:4 lane.
94+
95+## Suite — INCOMPLETE at the turn cap
96+
97+`systemd-run --user --unit=rectres-suite-r1-... -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3`
98+(log `$HOME/.cache/rectres-suite-r1.log`) was still running when the cap hit: 1259 log lines,
99+no `^test result` line yet. **The full-suite result is UNKNOWN — not claimed green.**
100+What DID run and pass: `cargo test -p ec-av1 --lib --no-run` (compiles) and the new gate alone,
101+`test result: ok. 1 passed; 0 failed; 457 filtered out`.
102+
103+## Exact next step
104+
105+1. `grep -E "^test result|^failures:" -A20 $HOME/.cache/rectres-suite-r1.log` — the unit is still
106+ live; if it died, re-arm the same command. Expected known reds (from main 7e6d60b, unrelated
107+ to this lane): `a_frame_edge_straddling_band`,
108+ `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions`,
109+ `real_aomenc_1to4_streams_..._rect_vartx_leaves_fire`. Anything else is this commit's.
110+ Re-run the two SIBLING gates by name first (they share `rect_inter_luma_set` /
111+ `rect_inter_chroma_set` / `read_inter_plane_rect`): `real_aomenc_1to4_streams_...` and
112+ `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions`.
113+2. Then the next film wall is a DIFFERENT lane's shape: `an intra 16x4/4x16 strip inside an
114+ inter 16x16-level 1:4 partition (its 4:2:0 chroma pair is coded once for two strips; only
115+ the inter path implements that pairing)` — all six cuts now stop there.
lanes/reelckf2-r1.report.mdadded+88 -0
@@ -0,0 +1,88 @@
1+# lane-reelckf2 r1 — the "-ss 300 key frame is not pixel-exact" premise is STALE; LR stripe-0 / partial-bottom-stripe now gated
2+
3+Base: `fedb7fe` (lane-sb128c r6 tip = main 85887c7 + 128-superblock support). Branch `lane-reelckf2`.
4+
5+## 1. The chartered defect does not reproduce (premise stale)
6+
7+lane-interedge r1 reported the 1920x792 10-bit film's key frame at `-ss 300` wrong in rows 0..7
8+(max luma delta 12, 13710/15360 samples). Re-measured at this base, first thing, per COMMON:
9+
10+ ffmpeg -ss 300 -t 2 -i <film> -c:v copy -an -f obu s300.obu # bounded, under systemd-run --scope MemoryMax=6G
11+ python3 census4/trunc.py s300.obu 1 t300.obu # first temporal unit, 206172 bytes
12+ sha256 t300.obu (twice) = 9734f645854a9cc657040b7e6d7937a18aade34559610f62e7df4eb67bc3d993
13+ EC_PROBE_OUT16=o300.raw decode_probe t300.obu ; ffmpeg -i t300.obu -pix_fmt yuv420p10le -f rawvideo r300.raw
14+
15+Result: **0 wrong samples in Y, U and V** (max delta 0), rows 0..7 included.
16+
17+Whole key-frame table (`~/.cache/reelckf2-tmp/kf.sh`, one truncated key frame per offset, ours
18+vs ffmpeg yuv420p10le, all three planes):
19+
20+| -ss | stream sha (12) | result | wrong samples (all planes) |
21+|-----|-----------------|--------|-----|
22+| 0 | 9746d3df3bbf | OK | 0 |
23+| 300 | 9734f645854a | OK | 0 |
24+| 900 | b205be5ade93 | OK | 0 |
25+| 1800 | d514ad0d9397 | OK | 0 |
26+| 2700 | 16981094eaab | OK | 0 |
27+| 3600 | 66d309bcc22d | OK | 0 |
28+| 4500 | b40563ecd03f | OK | 0 |
29+| 5400 | c7a924ed7e86 | OK | 0 |
30+| 6300 | 3b9a4b380393 | OK | 0 |
31+| 7200 | 80e36a4cde45 | OK | 0 |
32+| 8100 | 23ce4869ccdb | REFUSED: 128x128 superblock HORZ/VERT or AB partition | n/a |
33+| 9000 | 26b410f82657 | REFUSED: 128x128 superblock HORZ/VERT or AB partition | n/a |
34+| 9900 | 748605ef91ac | OK | 0 |
35+
36+11/11 decodable key frames pixel-exact; the 2 refusals are the residue lane-sb128c r6 already
37+named (128-root HORZ/VERT/AB), not this lane's.
38+
39+EVIDENCE: ~/.cache/reelckf2-tmp/kf.sh output above | extract -t 2 at 13 offsets, trunc to 1 frame, decode with EC_PROBE_OUT16, ffmpeg yuv420p10le reference | 11/11 decoded frames 0 wrong samples, 2 named refusals
40+
41+## 2. What the round did instead: gate the stripe shapes nobody had gated
42+
43+The charter's prime suspect (LR stripe 0, `RESTORATION_UNIT_OFFSET==8`) is correct code but was
44+untested: every LR gate size before this round (192x128, 160x96) is a whole multiple of 64 rows
45+and ran `--sb-size=64`, so no gate ever exercised the *partial* last stripe, and none asserted
46+that a real filter ran on stripe 0 at all (class `tool-disabled-in-every-gate`).
47+
48+- `crates/ec-av1/src/restoration.rs:368` — new `LR_STRIPE0_HITS` / `LR_LAST_STRIPE_HITS`
49+ thread-locals + `lr_stripe0_hits()` / `lr_last_stripe_hits()`, bumped in
50+ `filter_restoration_unit` when a non-`None` filter runs on a stripe starting at plane row 0,
51+ resp. on a truncated stripe ending at `plane_h`.
52+- `crates/ec-av1/src/stream.rs:3395` — new gate
53+ `a_real_aomenc_10bit_partial_bottom_stripe_restoration_decodes_pixel_exact`: real aomenc,
54+ `--sb-size=128 --enable-restoration=1 --cpu-used=0`, 10-bit, three arms
55+ (256x152 cq15, 384x216 cq15, 256x152 cq25 — 152 = 2*64+24, 216 = 3*64+24, both leaving the same
56+ 32-row tail stripe shape as the film's 792 rows), 16 seeds each, every decode-order frame
57+ compared against ffmpeg, `lr_hits` + `lr_stripe0_hits` + `lr_last_stripe_hits` hard-asserted
58+ per compared attempt by `ten_bit_tool_gate` (a refused attempt contributes no counts).
59+- `crates/ec-av1/src/stream.rs:13929` — the 8-bit LR gate's size moved 192x128 -> 192x152 (its
60+ stripe shapes at 128 are a strict subset) and it now hard-asserts the same two counters.
61+
62+Results:
63+
64+ a_real_aomenc_10bit_partial_bottom_stripe_..._exact 256x152 cq15: 16/16 attempts pixel-exact, lr_hits=33 lr_stripe0_hits=33 lr_last_stripe_hits=33
65+ a_real_aomenc_10bit_partial_bottom_stripe_..._exact 384x216 cq15: 16/16 attempts pixel-exact, lr_hits=54 lr_stripe0_hits=51 lr_last_stripe_hits=51
66+ a_real_aomenc_10bit_partial_bottom_stripe_..._exact 256x152 cq25: 16/16 attempts pixel-exact, lr_hits=24 lr_stripe0_hits=24 lr_last_stripe_hits=24
67+ a_real_aomenc_stream_with_restoration_reads_lr_symbols_correctly (8-bit, 192x152): 40/40 decoded and compared pixel-exact, wiener_hits=23 sgrproj_hits=78
68+
69+EVIDENCE: cargo test -p ec-av1 --lib partial_bottom_stripe -- --nocapture | 48 real aomenc 10-bit sb128 streams over 3 sizes/cq, every shown frame vs ffmpeg | 48/48 pixel-exact, stripe0 108 / last-stripe 108 filtered stripes, 0 mismatches
70+
71+No refusal was lifted (`refusal_inventory.rs` / `gate_coverage.rs` untouched — this round adds
72+coverage, it does not widen capability).
73+
74+## 3. Open residue / dispositions
75+
76+- deferred: a dedicated 8-bit arm of the *new* gate — accepted instead by moving the existing
77+ 8-bit LR gate to 192x152 (same stripe shapes, 40/40 pixel-exact) — unblocked by a seeded 8-bit
78+ twin of `ten_bit_tool_gate`, which does not exist and would be a ~90-line duplicate.
79+- deferred: the 2 refusing film key frames (8100, 9000) — 128-root HORZ/VERT/AB partitions,
80+ lane-sb128c's named residue — unblocked by that lane.
81+- deviation: the branch is NOT rebased onto today's main (`cc323d0`); its base is the charter's
82+ `fedb7fe`, which is main 85887c7 + the 128-SB work the film needs. It merges into main after
83+ lane-sb128c.
84+
85+## 4. Suite
86+
87+`cargo test -p ec-av1 --lib` (systemd user unit, MemoryMax=10G, log `$HOME/.cache/reelckf2-suite-r1.log`):
88+**386 passed; 0 failed; 35 ignored**, 1578 s.
lanes/sb128c-r10.report.mdadded+66 -0
@@ -0,0 +1,66 @@
1+# lane-sb128c r10 report
2+
3+Tip `1f6d885` on `lane-sb128c` (from `c24a2ac`). The r9 blocker is closed: two
4+root causes, both in code shared by every block wider or taller than 64.
5+
6+## Root cause 1 -- `tx_size_context_rect` compared against the block side
7+
8+`crates/ec-av1/src/decode.rs:5845` `tx_size_context_rect` tested the above/left
9+neighbour transform sizes against the block's own `bw`/`bh`. libaom's
10+`get_tx_size_context` tests against `max_txsize_rect_lookup[bsize]`, which tops
11+out at TX_64X64: a 64x128 block must compare against 64, not 128. The square
12+path (`read_tx_depth`, decode.rs:11838) already capped with `side.min(64)`
13+(lane-sb128b r1); the rect path never did. Consequence: the right 64x128 half
14+of a 128-root PARTITION_VERT at mi_col 80 read its tx-depth symbol off CDF row
15+0 where libaom uses row 1, decoded depth 0 (TX_64X64) instead of depth 2
16+(TX_16X16), and the tile desynced from that block on.
17+
18+Fix: cap both dimensions at 64 inside the helper (one `min`), so all eight call
19+sites are covered at once.
20+
21+## Root cause 2 -- `Reach::of_tu` ignored the 64x64 "mu" chunk order
22+
23+`crates/ec-av1/src/encode.rs:1252` `Reach::of_tu` used the plain
24+`col_off + tx_w < bw` rule. A block wider than 64 is coded in 64x64 chunks in
25+raster order, so `has_top_right` (reconintra.c) takes `col_off` MODULO the
26+64-wide chunk in its `row_off > 0` branch (with one exception: the unit whose
27+top-right corner is the centre of a 128x128), and `has_bottom_left` grants the
28+left edge of a right-hand chunk what the already-coded left chunk holds.
29+Without it the last unit column of every chunk of a 128x64 intra block
30+predicted from a chunk libaom has not decoded yet -- 375 wrong luma samples in
31+the first such block of a 512x512 key frame, entropy exact.
32+
33+## Evidence
34+
35+EVIDENCE: `$HOME/.cache/sb128c-r10/{aom.trace,our.trace}` | `EC_TRACE_MODE EC_TRACE_COEFF` aomdec vs `EC_TRACE_MODE EC_TRACE_MODE_STEP EC_TRACE_COEFF` decode_probe on `$HOME/.cache/sb128c-r9/noab.obu`, both under `systemd-run --scope -p MemoryMax=6G`, all_zero rng ladder | first divergence at element 151 = the block at mi_row 0 mi_col 80 (bsize 13, 64x128): oracle reads a tx-depth symbol (rng 32968 -> 42504) and codes TX_16X16 units, ours read none and coded TX_64X64. After fix 1 the whole 5370-element ladder is IDENTICAL.
36+
37+EVIDENCE: `$HOME/.cache/sb128c-r10/pred.trace` | `EC_PRED=1 aomdec` on the same stream | the 128x64 block at mi_col 32 has `n_tr=16` for col_off 0/4/8 and `n_tr=0` for col_off 12 at every `row_off > 0` -- exactly the unit column where our recon differed (diff map: 375 samples, all in x 176..191 and 192..255's last column).
38+
39+EVIDENCE: `$HOME/.cache/sb128c-r10/{o.f*,m.f*}` | `EC_AV1_PREFILT_DUMP` both decoders over all five r9 streams (noab, ab45, ab18, abi45, ab55; recipe `$HOME/.cache/sb128c-r9/mk.sh`) | every frame of every stream byte-identical after both fixes (before: 5/5 streams DIFF on every frame, 326839/393216 bytes on noab f0).
40+
41+EVIDENCE: gate `a_real_aomenc_sb128_intra_rect_block_decodes_pixel_exact` arm 47 | `cargo test -p ec-av1 --lib a_real_aomenc_sb128_intra_rect_block_decodes_pixel_exact -- --nocapture` | `arm 47 cq --cq-level=45 512x512 8bit txsearch=1: 5 frames pixel-exact (0 hidden), intra_128x64 +164 intra_64x128 +156 depth[64/32/16] [26, 0, 294]`.
42+
43+EVIDENCE: `$HOME/.cache/reelc-head.obu` | `decode_probe` under `systemd-run --scope -p MemoryMax=6G` after both fixes | `OK: 48 frames decoded, 1920x792`, `sb128_rect: edge_horz=720 inter_128x64=720` -- no refusal, no regression.
44+
45+## Gate arm added
46+
47+`crates/ec-av1/src/stream.rs:19176` -- a 512x512 arm (tag 47) on the sb128
48+intra_rect_block gate: a SECOND 128 superblock column, which no earlier arm had
49+(192x256 / 384x320 / 256x192 all stop at one 128 column), plus the r9 witness's
50+own higher-frequency luma source, because the gate's smooth two-term source
51+gives every 128-rect block a whole-block TX_64X64 and no VERT root -- the exact
52+combination that hid the defect. Counters prove the shape: 156 64x128 blocks,
53+294 units at TX_16X16.
54+
55+## Suite
56+
57+`cargo test -p ec-av1 --lib` (unit `sb128c-suite-r10-1788351731`, after fix 1
58+only): 387 passed, 1 failed, 35 ignored -- the one failure was
59+`a_real_aomenc_sb128_ab_partition_at_the_128_root_decodes_pixel_exact`, which
60+fix 2 closes. Final run: unit `sb128c-suite-r10b-*`, log
61+`$HOME/.cache/sb128c-suite-r10b.log` -- **388 passed, 0 failed, 35 ignored** (475 s), including `a_real_aomenc_sb128_ab_partition_at_the_128_root_decodes_pixel_exact`, `..._intra_rect_block_...` (with the new 512x512 arm), `..._gathered_edge_horz_...` and the r7 inter gate.
62+
63+## Residue
64+
65+- No refusal string was lifted this round; the r9 gate that the AB refusal
66+ lift needs is now green. accepted.
lanes/sb128c-r7.report.mdadded+99 -0
@@ -0,0 +1,99 @@
1+# lane-sb128c r7 report -- the 128 root's gathered frame-edge HORZ/VERT arm
2+
3+Branch `lane-sb128c`, worktree `edith_codecs-sb128c`,
4+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sb128c`.
5+Commits this round: `d10a641` (the interrupted r7 builder's partial, committed as
6+wip), `52e4458` (feature + gate), `5bd4556` (inventory).
7+
8+## What changed
9+
10+- `crates/ec-av1/src/decode.rs:13446` `read_sb128_root`: HORZ/VERT are no longer
11+ refused there; they are counted (`PART128_HORZ_HITS`, `PART128_VERT_HITS`, and
12+ the gathered-edge pair `PART128_EDGE_HORZ_HITS`/`PART128_EDGE_VERT_HITS`) and
13+ only the four AB shapes still refuse, by their own name.
14+- `crates/ec-av1/src/decode.rs:21881` inter tile path: a 128 root that resolves
15+ to HORZ/VERT decodes two `inter_piece!` blocks of 128x64 / 64x128 (the second
16+ skipped when its origin is outside the frame, libaom `decode_partition`'s
17+ `if (mi_row + hbs < mi_rows)`), then fans one `cdef_idx` out over the 64x64
18+ CDEF units the block covers.
19+- `crates/ec-av1/src/decode.rs:12029` `read_block_tx_size_rect`: `bw.max(bh) > 64`
20+ reads TWO square TX_64X64 top-level units (libaom `read_block_tx_size`'s
21+ `idy/idx` loop), each with its own `txfm_partition` symbol at depth 0.
22+- `crates/ec-av1/src/decode.rs:11897` `rect_inter_residual_supported`: (128,64)
23+ and (64,128) admitted.
24+- `crates/ec-av1/src/decode.rs:18008` / `:19109`: the `side > 64` mu-chunk chroma
25+ branch now precedes the `rect_tu` one -- at the 128 root a rect block's chroma
26+ is per mu chunk, not one unit for the block.
27+- `crates/ec-av1/src/decode.rs:16891`: the `whole_sb` test that gates delta-q /
28+ delta-lf reads is against `sb_mi_cur() * 4`, not a hardcoded 64.
29+- `crates/ec-av1/src/decode.rs:3948` `Neighbours::new`: the per-mi side arrays are
30+ padded to a superblock multiple. ROOT CAUSE of two index-out-of-bounds panics
31+ (`decode.rs:5018`, `:4537`, len 200 index 200) on the 1080p film: a 128x64 at
32+ the bottom edge records neighbour state for its whole 64-row extent, past the
33+ frame's last mi row -- libaom's own context buffers are `MAX_MIB_SIZE`-aligned
34+ for exactly that reason. The two `get_mut` guards in `record_mi_rect` are the
35+ belt; the padding is the fix.
36+- `crates/ec-av1/src/decode.rs:13700` key-frame path: HORZ/VERT at the 128 root
37+ now REFUSE by name. Before this round they fell through into the four-quadrant
38+ SPLIT visit and silently decoded wrong pixels (the first version of the gate
39+ caught it as a frame-0 mismatch on a `gradients` source).
40+- `crates/ec-av1/src/stream.rs:18957` new gate; `:84` `sb128_rect_counters()`;
41+ `crates/ec-av1/examples/decode_probe.rs:40` prints them.
42+- `crates/ec-av1/src/refusal_inventory.rs:46`: the old
43+ "a 128x128 superblock HORZ/VERT or AB partition" line is REPLACED by
44+ "a 128x128 superblock AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B at the 128 root)"
45+ plus the new intra-frame one and the var-tx >64 leaf guard.
46+
47+## Gate (GREEN)
48+
49+`cargo test -p ec-av1 --lib gathered_edge_horz -- --nocapture`
50+(`a_real_aomenc_sb128_gathered_edge_horz_partition_decodes_pixel_exact`):
51+4 real `aomenc --sb-size=128 --cpu-used=0 --min-partition-size=64
52+--enable-rect-partitions=1` streams, 5 frames each, every decode-order frame
53+(hidden alt-ref included) compared against the instrumented aomdec through
54+`decode_all_frames_vs_oracle`; hard asserts the gathered-edge counter and the
55+inter 128x64/64x128 block counter.
56+
57+ seed 42 cq55 384x320 8bit HORZ: 6 frames pixel-exact (1 hidden), edge +2 inter_128rect +2
58+ seed 43 cq55 384x320 10bit HORZ: 6 frames pixel-exact (1 hidden), edge +24 inter_128rect +24
59+ seed 44 cq32 192x256 8bit VERT: 6 frames pixel-exact (1 hidden), edge +2 inter_128rect +2
60+ seed 45 cq45 192x256 10bit VERT: 6 frames pixel-exact (1 hidden), edge +2 inter_128rect +2
61+ test result: ok. 1 passed; 0 failed
62+
63+EVIDENCE: $HOME/.cache/sb128c-gate3-r7.log | cargo test -p ec-av1 --lib gathered_edge_horz --nocapture | 4/4 arms pixel-exact vs aomdec, edge counters +2/+24/+2/+2
64+
65+## Film (1080p 10-bit AV1, 4 extracts)
66+
67+| extract | before r7 | after r7 | edge_horz | inter_128x64 |
68+|---|---|---|---|---|
69+| 2 s head (1920x792) | stopped: 128 HORZ/VERT/AB | **OK: 48/48 frames, 49/49 dumps bit-exact vs aomdec** | 720 | 720 |
70+| `~/.cache/reelc-head.obu` | stopped: 128 HORZ/VERT/AB | **OK: 48/48 frames, 49/49 dumps bit-exact** | 720 | 720 |
71+| `-ss 8100` 2 s | stopped: 128 HORZ/VERT/AB | stops at another lane: "a split intra strip whose transform unit is 32x64" | 1 | 0 |
72+| `-ss 9000` 2 s | stopped: 128 HORZ/VERT/AB | stops at another lane: "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding" | 12 | 0 |
73+
74+EVIDENCE: $HOME/.cache/sb128c-r7/d2 vs $HOME/.cache/sb128c-r7/o2 | EC_AV1_FINAL_DUMP on decode_probe head2s.obu and on aomdec head2s.obu, cmp per frame | frames=49 frames_differing=0
75+
76+The 128-partition wall is gone from all four extracts; two of them now decode
77+their whole 2 s window bit-exact, the other two stop at OTHER lanes' refusals.
78+
79+## Suite
80+
81+`cargo test -p ec-av1 --lib` (systemd unit, MemoryMax=10G):
82+**386 passed; 0 failed; 35 ignored** in 1133 s -- `$HOME/.cache/sb128c-suite-r7.log`.
83+
84+## Residue
85+
86+- deferred: the INTRA (key-frame) 128x64/64x128 block -- refused by name, was a
87+ silent wrong decode before this round. Unblocked by a rect-capable
88+ `decode_block` at 128 (`decode_block_rect64` is corner-cropped for a 32x32
89+ transform and does not generalise). A smooth `gradients` source at
90+ `--min-partition-size=64` reaches it in one encode, so a gate is one recipe away.
91+- deferred: the four AB shapes at the 128 root (HORZ_A/HORZ_B/VERT_A/VERT_B),
92+ still refused by name. Unblocked by the intra rect block above plus the
93+ libaom visit order recorded in `lanes/sb128c-r6.handoff.md`. Whether aomenc
94+ ever picks them is still unmeasured -- our decoder used to stop at the first
95+ refusing root, so the r6 sweeps could not observe past it; the 512x512
96+ abshape source now decodes further and the sweep can be re-run.
97+- accepted: `PART128_HORZ_HITS`/`PART128_VERT_HITS` (the non-gathered,
98+ full-alphabet arms) are counted but were 0 in every stream measured this
99+ round; the gate asserts the gathered pair only.
lanes/sb128c-r8.report.mdadded+115 -0
@@ -0,0 +1,115 @@
1+# lane-sb128c r8 -- the INTRA (key-frame) 128x64 / 64x128 block
2+
3+Branch `lane-sb128c`, worktree `edith_codecs-sb128c`,
4+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sb128c`.
5+
6+## What changed
7+
8+- `crates/ec-av1/src/decode.rs:10101` `decode_block_128rect` (NEW): a rect
9+ intra block at the 128 root. libaom `decode_block` ->
10+ `predict_and_reconstruct_intra_block` per transform unit, with the 128
11+ geometry: `max_txsize_rect_lookup[BLOCK_128X64] == TX_64X64` so every luma
12+ unit is SQUARE and there are >= two (depth 0: 64x64 x2, 1: 32x32 x8,
13+ 2: 16x16 x32 -- `bsize_to_tx_size_cat` counts the `sub_tx_size_map` chain
14+ TX_64X64->32->16->8->4, i.e. cat 3, the CDF a 64x64 square block reads);
15+ `av1_get_max_uv_txsize` = `av1_get_adjusted_tx_size(
16+ max_txsize_rect_lookup[BLOCK_64X32])` caps at TX_32X32, so the 64x32 uv
17+ plane block is TWO 32x32 chroma units per plane, one per 64x64 "mu" chunk,
18+ Y then U then V inside each chunk (`decode_token_recon_block`);
19+ `get_txb_ctx` puts chroma on the offset-10 rows (uv plane block > uv tx).
20+ Mode info goes through `read_intra_mode_rect` with `cfl = false`
21+ (`is_cfl_allowed` caps at 32x32); filter intra and palette do not exist at
22+ this size (`av1_filter_intra_allowed_bsize` 32x32,
23+ `palette_bsize_ctx_wh` returns `None` above 64) and are refused by name if
24+ one ever appears. Per-TU edge availability through `tu_reach`
25+ (`has_top_right` false for a block whose long side is > 64, via
26+ `Reach::of_rect`); lf/skip grids stamped with the resolved unit size.
27+- `crates/ec-av1/src/decode.rs:14027` key-frame path: the 128 root's
28+ HORZ/VERT arm is no longer refused. It decodes `BLOCK_128X64` at
29+ (mi_row, mi_col) plus a second at (mi_row + 16, mi_col) only
30+ `if (mi_row + hbs < mi_rows)` (VERT mirrors it on the column, libaom
31+ `decode_partition` decodeframe.c:1554), each half reading its OWN
32+ `cdef_idx` literal, fanned out over the 64x64 CDEF units it covers.
33+- `crates/ec-av1/src/decode.rs:9346` / `:9247` `PlaneBuf::reconstruct` +
34+ `reconstruct_rect`: bottom/right frame-edge CLIP. ROOT CAUSE of two
35+ `index out of bounds` panics on the 1080p film's key frames (len 1536000,
36+ index 1536000/1536384): our frame buffer is padded to 32 (`block_grid`)
37+ while libaom's is superblock aligned, so a 64x64 unit of a 128x64 block at
38+ y=768 of a 792-row frame wants 832 rows of an 800-row buffer. Those samples
39+ are outside the frame -- never output, never referenced.
40+- `crates/ec-av1/src/stream.rs:95` `intra_sb128_counters()`,
41+ `crates/ec-av1/src/decode.rs:10101` `INTRA_SB128_{HORZ,VERT,DEPTH}_HITS`.
42+- `crates/ec-av1/src/refusal_inventory.rs:48`: the intra-128x64 refusal is
43+ REPLACED by the defensive CfL/filter-intra/palette one.
44+
45+## Gate (GREEN)
46+
47+`cargo test -p ec-av1 --lib intra_rect_block -- --nocapture`
48+(`a_real_aomenc_sb128_intra_rect_block_decodes_pixel_exact`): 5 real aomenc
49+streams, `--sb-size=128 --cpu-used=0 --min-partition-size=64
50+--enable-rect-partitions=1 --kf-max-dist=1`, every decode-order frame compared
51+against the instrumented aomdec, hard asserts on the HORZ counter, the VERT
52+counter and depth[0].
53+
54+ arm 42 cq55 384x320 8bit HORZ txsearch=0: 5 frames exact, 128x64 +28 depth [28,0,0]
55+ arm 43 cq32 384x320 10bit HORZ txsearch=1: 5 frames exact, 128x64 +30 depth [30,0,0]
56+ arm 44 cq8 256x192 8bit HORZ txsearch=1: 5 frames exact, 128x64 +14 depth [14,0,0]
57+ arm 46 cq55 192x256 8bit VERT txsearch=0: 5 frames exact, 64x128 +10 depth [10,0,0]
58+ arm 45 cq45 192x256 10bit VERT txsearch=1: 5 frames exact, 64x128 +10 depth [10,0,0]
59+ test result: ok. 1 passed; 0 failed
60+
61+Sources are `geq` long-period sinusoids, NOT lavfi `gradients`: gradients
62+ignores its seed and gave a different picture every run (one arm passed and
63+then failed with an unchanged decoder -- the flake was the fixture).
64+
65+EVIDENCE: $HOME/.cache/sb128c-gate-r8.log | cargo test -p ec-av1 --lib intra_rect_block --nocapture | 5/5 arms 5 frames each pixel-exact vs aomdec, 96 intra 128-rect blocks, 0 out of scope
66+
67+Sibling gate re-run GREEN (COMMON's SIBLING GATES rule):
68+`gathered_edge_horz` 4/4 arms pixel-exact, edge +2/+24/+2/+2.
69+
70+## Film (1080p 10-bit AV1, 4 extracts)
71+
72+| extract | r7 | r8 | edge_horz | inter_128x64 |
73+|---|---|---|---|---|
74+| 2 s head (1920x792) | OK 48/48 | **OK, 49/49 dumps bit-exact vs aomdec** | 720 | 720 |
75+| `~/.cache/reelc-head.obu` | OK 48/48 | OK, decodes to completion | 720 | 720 |
76+| `-ss 8100` 2 s | stopped: split intra strip TU 32x64 | PANICKED with the arm live, now stops at "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding" | 1 | 0 |
77+| `-ss 9000` 2 s | stopped: non-skip rect strip | now stops DEEPER, at "an inter SB-level AB partition" | 12 | 0 |
78+
79+EVIDENCE: $HOME/.cache/sb128c-r8/d2 vs $HOME/.cache/sb128c-r7/o2 | EC_AV1_FINAL_DUMP decode_probe head2s.obu, cmp per frame | dumps_compared=49 frames_differing=0
80+
81+The two panics the r8 arm exposed on the film are the frame-edge clip above;
82+without it this round would have shipped a crash on his own film.
83+
84+## AB shapes at the 128 root -- MEASURED, still refused
85+
86+16-attempt sweep (512x512 and 384x320 geq sinusoids x cq 18/32/45/55 x 8+10
87+bit, `--sb-size=128 --min-partition-size=64 --enable-ab-partitions=1`,
88+`$HOME/.cache/sb128c-r8/ab.sh`): **aomenc DOES pick them** -- 2 of 16 attempts
89+refuse with "a 128x128 superblock AB partition" (512x512 cq18 and cq45,
90+8-bit), and one more with the inter SB-level AB refusal. So the r7 residue
91+"whether aomenc ever picks them is unmeasured" is now answered YES; they
92+cannot be closed by measurement and need the implementation.
93+
94+## Suite
95+
96+`cargo test -p ec-av1 --lib` under a systemd unit (MemoryMax=10G):
97+**387 passed; 0 failed; 35 ignored** in 1216 s --
98+`$HOME/.cache/sb128c-suite-r8.log` (r7 was 386/0/35; +1 is this round's gate).
99+
100+## Residue
101+
102+- deferred: the four AB shapes at the 128 root (key and inter) -- MEASURED to
103+ be reachable (above). Unblocked by this round's `decode_block_128rect` (the
104+ 128x64/64x128 piece each AB shape needs) plus the libaom visit order in
105+ `lanes/sb128c-r6.handoff.md`; the sweep script pins the recipe that
106+ produces one.
107+- deferred: intra `tx_depth` > 0 at the 128 root (32x32 / 16x16 units) is
108+ implemented but UNEXERCISED -- every arm, including cq 8 with
109+ `--enable-tx-size-search=1`, resolved depth 0. Unblocked by finding an
110+ encoder setting that splits a 128x64's transform; the gate prints the
111+ per-depth counters so the round that finds one sees it immediately.
112+- accepted: an inter frame of the 192x256 smooth source mismatches at frame 1
113+ (`$HOME/.cache/sb128c-r8/vert46.obu`, byte 12033, 36073 bytes differ). It is
114+ NOT this lane's shape: the key frames of that same stream are exact, and the
115+ r7 inter gate is green on its own source. Left pinned for a hunter.
lanes/sb128c-r9.handoff.mdadded+50 -0
@@ -0,0 +1,50 @@
1+# lane-sb128c r9 -> r10 handoff
2+
3+Tip `d00a97b` (branch `lane-sb128c`). The four 128-root AB shapes are
4+IMPLEMENTED on both tile paths and the refusal is lifted; the new gate
5+`a_real_aomenc_sb128_ab_partition_at_the_128_root_decodes_pixel_exact` is RED
6+for a reason that is NOT the AB code.
7+
8+## The blocker, bisected (do not re-derive)
9+
10+- Stream `$HOME/.cache/sb128c-r9/ab45.obu` (512x512 cq45 8-bit key, recipe in
11+ `$HOME/.cache/sb128c-r9/mk.sh`). Frame 0 differs from the oracle.
12+- `EC_AV1_PREFILT_DUMP` on BOTH decoders: first differing sample is
13+ **byte 321 = (x=320, y=0)**, i.e. the very FIRST sample of the RIGHT 64x128
14+ half of the third 128 root, which is `PARTITION_VERT` (root values of frame
15+ 0: 1,1,2,5,1,1,3,3,0,0,3,3,0,0,3,3). Post-filter the diff bleeds left to
16+ x=317, which is a deblock artefact, not the cause.
17+- 326839 of 393216 bytes differ => entropy desync from that block on, not a
18+ reconstruction rounding defect.
19+- CONTROL: the same stream encoded with `--enable-ab-partitions=0`
20+ (`$HOME/.cache/sb128c-r9/noab.obu`, `mknoab.sh`) diverges at the SAME place.
21+ The defect is r8's `decode_block_128rect` / the 128-root VERT arm, reached
22+ only now that the AB refusal no longer short-circuits the compare (class
23+ `refusal-hides-a-defect`).
24+- Frame 0 of every failing arm contains ZERO AB partitions -- the first AB in
25+ `ab18.obu` is the 38th 128 root (frame 2).
26+
27+## Where to look first
28+
29+The right 64x128 half at (mi_row 0, mi_col 80). Suspects, cheapest first:
30+1. `decode_block_128rect`'s mode-info read for a block whose LEFT neighbour is
31+ the other half of the same root (`read_intra_mode_rect` ctx / neighbour
32+ record of the left half at 64-px granularity).
33+2. The left half's neighbour recording: r8 stamps the lf/skip grids with the
34+ resolved unit size, so a 64x128 block records 2 units of 64 -- check
35+ `record_mi_luma` / `fill_skip_grid` cover the full 64x128 footprint.
36+3. A cross-decoder msac RANGE ladder at that block's entry (never tell()).
37+
38+## Cheap repro
39+
40+ ~/.cache/sb128c-r9/cmp.sh ~/.cache/sb128c-r9/ab45.obu # post-filter
41+ EC_AV1_PREFILT_DUMP=... aomdec / decode_probe # pre-filter
42+
43+## Still owed
44+
45+- The full suite was never run this round (deadline). Expect 388 tests, 1
46+ failure (the new gate) until the above is fixed.
47+- `gate_coverage.rs` was NOT touched: the new gate passes
48+ `--enable-ab-partitions=1`, which other gates already do, so its
49+ `NEVER_EXERCISED` lists are unaffected -- CONFIRM by running
50+ `cargo test -p ec-av1 --lib gate_coverage`.
lanes/sb128c-r9.report.mdadded+81 -0
@@ -0,0 +1,81 @@
1+# lane-sb128c r9 -- the four AB shapes at the 128 root (key + inter)
2+
3+Branch `lane-sb128c`, worktree `edith_codecs-sb128c`,
4+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sb128c`.
5+
6+## What changed
7+
8+- `crates/ec-av1/src/decode.rs` `read_sb128_root`: the AB refusal is LIFTED.
9+ Values 4..7 now count into `PART128_AB_HITS` (`part128_ab_hits()`), and the
10+ `_` arm refuses only a value outside the 8-symbol alphabet.
11+- `crates/ec-av1/src/decode.rs` key-frame tile: a new arm decodes each AB
12+ shape as two 64x64 squares (`decode_block`, `SB`, `Luma64`/`Chroma32`) plus
13+ one 128x64/64x128 half (`decode_block_128rect`, r8) in libaom
14+ `decode_partition`'s order -- HORZ_A = TL, TR, bottom half; HORZ_B = top
15+ half, BL, BR; VERT_A = TL, BL, right half; VERT_B = left half, TR, BR --
16+ with `Reach::vert_ab_partition` live for the two VERT arms (r6 visit order,
17+ class `visit-order-changes-availability`), `CDEF_TRANSMITTED` reset per
18+ piece (one CDEF unit each, so libaom's per-unit `cdef_transmitted[index]`),
19+ and the half's `cdef_idx` copied to the second 64x64 unit it covers.
20+- `crates/ec-av1/src/decode.rs` inter tile: the same four arms through
21+ `inter_piece!` (`SB`/`SB*2` with `ww`/`wh` = the true footprint).
22+- `crates/ec-av1/src/stream.rs` `sb128_ab_counters()`; new gate
23+ `a_real_aomenc_sb128_ab_partition_at_the_128_root_decodes_pixel_exact`.
24+- `crates/ec-av1/src/refusal_inventory.rs`: the 128-root AB string is replaced
25+ by the alphabet-bound one.
26+
27+## Gate: RED -- and the divergence is NOT in the AB code
28+
29+`cargo test -p ec-av1 --lib ab_partition_at_the_128_root -- --nocapture`
30+fails on its FIRST arm: `sb128c-ab-18-512x512` decode-order frame 0 differs
31+from the oracle at byte 319 (ours 105 vs 107), 326839 bytes differ.
32+
33+Frame 0 of that stream contains **no AB partition at all** (`EC_AV1_TRACE`
34+`partition_w128` values for its 16 roots are 2,2,2,0,0,3,3,0,... ; the first
35+value in 4..7 is the 38th root, i.e. frame 2). The first differing sample is
36+(x=317..319, y=0), inside the LEFT 64x128 half of the third 128 root, which is
37+`PARTITION_VERT` -- r8's `decode_block_128rect`, untouched this round.
38+
39+Hand sweep of four 512x512/384x320 arms (`$HOME/.cache/sb128c-r9/cmp.sh`,
40+oracle `aomdec` vs our `decode_probe`, `EC_AV1_FINAL_DUMP` per frame):
41+
42+| stream | first differing byte (frame 0) | AB values in stream |
43+|---|---|---|
44+| 512x512 cq18 key | 320 (x=319,y=0) | HORZ_A x3 |
45+| 512x512 cq45 key | 318 | HORZ_B x1, VERT_B x1 |
46+| 512x512 cq45 inter (`--kf-max-dist=100`) | 319 | HORZ_A x1 |
47+| 384x320 cq55 key | 95531 (x=299,y=248), frame 2 exact | none |
48+| 512x512 cq45 key, `--enable-ab-partitions=0` | 318 | (aomenc still emitted one HORZ_B) |
49+
50+The last row is the control: the SAME byte-318 divergence with the AB flag
51+off, so the 512x512 defect is independent of this round's code.
52+
53+EVIDENCE: $HOME/.cache/sb128c-gate-r9.log + $HOME/.cache/sb128c-r9/{ab18,ab45,abi45,ab55,noab}.obu | cargo test ab_partition_at_the_128_root --nocapture; cmp.sh per stream | 5/5 512x512 arms differ at byte 317..320 of frame 0, a frame with zero AB partitions
54+
55+## Film (1080p 10-bit AV1)
56+
57+| stream | r9 stop |
58+|---|---|
59+| `~/.cache/reelc-head.obu` | OK, 48 frames decoded, 1920x792 |
60+| `-ss 900` 2 s | "an inter 16x16-level AB or 1:4 partition" (another lane) |
61+| `-ss 9000` 2 s | "an inter SB-level AB partition" (the 64 root, another lane) |
62+
63+Unchanged vs r8 -- the 128-root AB was not the film's next wall at these
64+offsets.
65+
66+EVIDENCE: $HOME/.cache/sb128c-r9/{x900,x9000}.obu | decode_probe on head + two 2 s extracts | 48/48 frames on the head, two named refusals from OTHER lanes' 16x16/64-root AB gaps
67+
68+## Suite
69+
70+NOT run this round (60-minute deadline spent on the divergence bisection).
71+The new gate is RED, so the suite is 388 tests with 1 failure until the
72+512x512 128-rect defect is fixed.
73+
74+## Residue
75+
76+- fix-now (next round): the 512x512 `decode_block_128rect` divergence at
77+ (x~317, y=0) of a `PARTITION_VERT` 128 root. Pinned streams above; the
78+ `--enable-ab-partitions=0` control isolates it from this round's work. Class
79+ `refusal-hides-a-defect`: r8's gate only ran 192x256/384x320 VERT sources,
80+ which never reached it.
81+- deferred: intra `tx_depth` > 0 at the 128 root (r8 residue, unchanged).
lanes/sbab-r1.handoff.mdadded+112 -0
@@ -0,0 +1,112 @@
1+# lane-sbab r1 handoff — superblock-level inter AB partitions
2+
3+Branch `lane-sbab`, tip `038d1f8` (rebased onto main `cc323d0`).
4+Worktree `/home/user/Documents/Code/Rust/edith_codecs-sbab`.
5+
6+## 1. Real, not our own desync
7+
8+`EC_TRACE=1 aomdec` on `~/.cache/sbab-tmp/s_8_3_y_45.obu` (256x192, 8-bit, cq45,
9+Y-structured source, sp=3) prints, in decode-order frame 4 (an INTER frame; the
10+stream has 12 SB partition reads per frame, entries 49..60 are frame 4):
11+
12+```
13+EC_PART_VAL mi_row=16 mi_col=32 bsize=12 value=4 # PARTITION_HORZ_A at 64x64
14+EC_PART_VAL mi_row=32 mi_col=32 bsize=12 value=5 # PARTITION_HORZ_B at 64x64
15+```
16+
17+bsize=12 is BLOCK_64X64 and values 4/5 are HORZ_A/HORZ_B, so the refusal
18+"an inter SB-level AB partition" named a real stream shape. VERDICT: REAL.
19+
20+## 2. What is implemented
21+
22+`crates/ec-av1/src/decode.rs:21494`, in `decode_inter_frame_tile_with_cdfs`'s
23+64-level partition switch: the four arms in libaom `decode_partition` order
24+(`decodeframe.c`) —
25+HORZ_A = TL 32x32, TR 32x32, bottom 64x32 strip;
26+HORZ_B = top 64x32 strip, BL 32x32, BR 32x32;
27+VERT_A = TL 32x32, BL 32x32, right 32x64 strip;
28+VERT_B = left 32x64 strip, TR 32x32, BR 32x32.
29+The squares reuse the `PARTITION_NONE`-under-SPLIT `decode_inter_block` call
30+verbatim (Luma32/Luma32Inter/Chroma16, TX32/TX16, size group 3, side `BLOCK`);
31+the strips reuse `inter_piece!` (side `SB`, true footprint via `write_w`/
32+`write_h`), which lane-r14's `superblock_level_rect_partition` gate proves.
33+`Reach::vert_ab_partition` is armed for the two VERT arms only (visit order
34+TL,BL,TR,BR changes `has_tr`/`has_bl`). Per-arm counter
35+`SB_AB_INTER_HITS` / `sb_ab_inter_hits_by_arm()` (decode.rs:2222), printed by
36+`examples/decode_probe` as `inter_ab64:`.
37+
38+## 3. The defect the gate found (root cause, shared path)
39+
40+`decode.rs:19128` — `decode_inter_block`'s var-tx branch called
41+`record_split_luma_rect_mi(at, side, side, ...)` with the comment "a var-tx
42+block is always square, so write_w == write_h == side". That premise died when
43+the SB-level rect strips landed (lane-inter4): a 64x32 / 32x64 strip keeps
44+`side = SB` for syntax but is not square, so it stamped `above_side_mi = 64`
45+where libaom's `update_partition_context` writes
46+`partition_context_lookup[BLOCK_32X64]`. The superblock BELOW then computed
47+partition ctx 2 where aomdec reads 3, wrong CDF row, desync at the next symbol.
48+Fixed by passing `write_w, write_h`. Ladder evidence, frame 4 of the stream
49+above, `EC_AV1_TRACE=1` ours vs `EC_TRACE=1` aomdec (aomdec ctx prints as
50+`4*bsl+ctx` = 12+ctx):
51+
52+| mi | oracle ctx | ours before | ours after | oracle pre_rng | ours after |
53+|-----------|-----------|-------------|------------|----------------|------------|
54+| (16,48) | 3 | 2 | 3 | 49168 | 49168 |
55+| (32,0) | 0 | 0 | 0 | 53403 | 53403 (was 60557) |
56+| (32,32) | 2 | 0 | 2 | 42672 | 42672 (was 32906) |
57+
58+After the fix all 72 partition reads of the stream match the oracle in ctx,
59+value and range.
60+
61+Note this is a SHARED-path fix: it changes every var-tx inter block whose
62+footprint is not square, i.e. the SB-level HORZ/VERT/HORZ_4/VERT_4 strips too.
63+Sibling coverage is the full suite run (below), not this gate alone.
64+
65+## 4. Gate
66+
67+`a_real_aomenc_inter_sequence_with_superblock_level_ab_partitions_decodes_pixel_exact`
68+(`crates/ec-av1/src/stream.rs:8375`). 256x192, 6 frames, 20 attempts per bit
69+depth (cq 18/26/34/45/55 x two source orientations x motion step 3/8), aomenc
70+`--sb-size=64 --enable-rect-partitions=1 --enable-ab-partitions=1
71+--enable-1to4-partitions=0 --min-partition-size=32 --max-partition-size=64
72+--kf-max-dist=9999 --cpu-used=0 --threads=1 --row-mt=0`, every decode-order
73+frame compared Y/U/V vs ffmpeg, `oos_mismatch` asserted 0, all four arms
74+asserted to have fired on a pixel-exact attempt.
75+
76+```
77+(8-bit): 0 named refusals, 12 pixel-exact attempts carrying a 64-level inter AB
78+ partition, per-arm HORZ_A/HORZ_B/VERT_A/VERT_B=[6, 5, 4, 2],
79+ 8 attempts carried none (0 of them mismatched)
80+(10-bit): 0 named refusals, 4 pixel-exact attempts, per-arm=[2, 1, 3, 2],
81+ 16 attempts carried none (0 of them mismatched)
82+test result: ok. 1 passed; 0 failed; 418 filtered out; finished in 92.12s
83+```
84+
85+## 5. Refusal state
86+
87+Removed from `refusal_inventory.rs`: `"an inter SB-level AB partition
88+(HORZ_A/HORZ_B/VERT_A/VERT_B; ...)"`, with a comment naming the gate that
89+replaced it. No arm stayed unreachable — all four fired live at both depths, so
90+nothing is left refused by name here. `gate_coverage.rs` needs no change
91+(`enable-ab-partitions` was already covered).
92+
93+## 6. Open residue
94+
95+- deferred(below-8x8 inter leaf desync): a `--tile-columns=1` twin of the 20
96+ attempts PANICS in `mc::from_switchable_symbol` (`mc.rs:203`, a 4th symbol
97+ out of a 3-symbol alphabet) on 8-bit attempt 27 — the exact signature
98+ lane-inter16ab r1 recorded for its own tiled arm. Not this lane's shape; the
99+ tiled axis is excluded with that reason in the gate source rather than
100+ SKIPped. Unblocked by whoever lands the sub-8 inter leaf.
101+- The 64-level 1:4 pair (HORZ_4/VERT_4 at 64) is unrelated and already decoded;
102+ `--enable-1to4-partitions=0` here only keeps the sweep narrow.
103+
104+## 7. Exact next step
105+
106+1. Read `$HOME/.cache/sbab-suite-r1.log` (`systemd-run --user` unit
107+ `sbab-suite-r1`, armed at commit `038d1f8`): confirm N passed / 0 failed.
108+ The var-tx extent fix is repo-wide, so a red sibling there is this lane's to
109+ own, not another lane's.
110+2. If green, merge `lane-sbab` into main and delete the worktree.
111+3. Optional follow-up, not started: film check with the 0.4 s extracts — this
112+ lane never ran one.
lanes/vert46-r1.handoff.mdadded+72 -0
@@ -0,0 +1,72 @@
1+# lane-vert46 r1 HANDOFF (tool-call cap)
2+
3+Tip: `ae16fec` on `lane-vert46` (base 103b66f = lane-sb128c r8). Two files
4+touched: `crates/ec-av1/src/decode.rs`, `crates/ec-av1/src/stream.rs`.
5+
6+## Stream
7+
8+192x256 8-bit `geq`-sinusoid source, `--sb-size=128 --min-partition-size=64
9+--enable-rect-partitions=1 --enable-tx-size-search=0 --cq-level=55
10+--cpu-used=0 --limit=5`, NO `--kf-max-dist=1`. Reproduced twice, md5
11+`ccc3bafd6d1c42b1336a69e68482e54b`, identical to the r8 residue stream.
12+Recipe script: `$HOME/.cache/vert46-tmp/mk.sh`. mi 64x48 -> the RIGHT 128
13+superblock column is partial (`mi_col + hbs == mi_cols`), so its 128 root
14+reads the gathered bit; frame 1 resolves it to PARTITION_VERT = one
15+BLOCK_64X128 inter block.
16+
17+## First diverging element (before the fix)
18+
19+Frame 1 (decode order), block mi(0,32) BLOCK_64X128, plane 1 (U), mu chunk 0,
20+32x32 chroma unit, the DC SIGN symbol:
21+
22+ pre-symbol range 39712 (identical both sides)
23+ aomdec dcctx=2, post-symbol range 41596
24+ ours ctx=1, post-symbol range 64592
25+
26+Ours read the left neighbour band as the 128x128 block's mu-chunk (0,0) DC
27+(negative) where libaom reads its mu-chunk (0,16) DC (positive).
28+
29+After fixing that, the ladder's next divergence was the 128-root partition
30+symbol of the NEXT superblock: aomdec `EC_PART mi_row=32 mi_col=32 bsize=15
31+ctx=19 rng=43152`, ours entered the 64 level at rng=35032 (ctx 16).
32+
33+## Root cause (two, same shape)
34+
35+1. `decode.rs` `decode_inter_block`, new `mu_chroma` flag + the per-unit
36+ re-stamp loop before `record_inter_rect_mi` (~:20146): a block above 64
37+ codes its chroma as one 32x32 unit per 64x64 mu chunk and each unit stamps
38+ its own DC sign/level (`record_mi_chroma`, libaom `av1_set_entropy_contexts`
39+ inside `decode_reconstruct_tx`). The end-of-block record overwrote ALL of
40+ them with `neighbour_state` of the assembled whole-block grid, i.e. with
41+ the top-left unit's DC. Fix: collect the per-unit grids, re-stamp after the
42+ block record, in mu-chunk order.
43+2. `decode.rs` `decode_inter_block` (~:20179):
44+ `record_split_luma_rect_mi(at, side, side, ..)` stamped
45+ `above_side`/`left_side` = 128 for a 64x128 var-tx block ("a var-tx block
46+ is always square" stopped being true when the 128 root's HORZ/VERT arm
47+ landed in sb128c r7). Fix: pass the block's own `write_w`/`write_h`.
48+
49+## cmp result (the only verification run)
50+
51+`EC_AV1_FINAL_DUMP` decode of the stream under
52+`systemd-run --user --scope -q -p MemoryMax=6G`, `cmp` per decode-order frame
53+against the instrumented aomdec's own `EC_AV1_FINAL_DUMP`:
54+
55+ f0 same f1 same f2 same f3 same f4 same f5 same
56+
57+(before: f1/f2/f4/f5 differed, f1 at byte 12033, 36073 bytes.)
58+Counters on that decode: `sb128_rect: edge_vert=10 inter_64x128=9`.
59+
60+## What is left for the next agent
61+
62+- The full `cargo test -p ec-av1 --lib` suite was STARTED and then STOPPED by
63+ the cap order; it has NOT been run to completion on this tip. Run it first.
64+- Gate arm 46 (smooth `geq` source) was added to
65+ `a_real_aomenc_sb128_gathered_edge_horz_partition_decodes_pixel_exact`
66+ (`stream.rs:~19005`) BEFORE the cap message and IS committed; it and the
67+ sibling sb128 gates were run once, green:
68+ arms 42..46 six decode-order frames pixel-exact each, arm 46 edge +20 /
69+ inter 128-rect +18; `intra_rect_block` 5/5 arms exact.
70+- Oracle: `~/.cache/aom-oracle/src/av1/decoder/decodetxb.c` now prints
71+ `dcctx=%d` on the `EC_COEFF_STEP tag=sign` line (env `EC_TRACE_COEFF`);
72+ aomdec rebuilt with `ninja aomdec` (NOT `make`). Uncommitted, keep it.
lanes/vert46-r1.report.mdadded+92 -0
@@ -0,0 +1,92 @@
1+# lane-vert46 r1 -- the INTER 64x128 block at a partial 128 superblock
2+
3+Branch `lane-vert46`, worktree `edith_codecs-vert46`, base 103b66f
4+(= lane-sb128c r8). `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-vert46`.
5+
6+## Premise (re-measured, not inherited)
7+
8+The sb128c r8 residue stream is reproducible: the arm-46 recipe (192x256
9+8-bit `geq` sinusoids, `--sb-size=128 --min-partition-size=64
10+--enable-rect-partitions=1 --cq-level=55 --cpu-used=0 --limit=5`, WITHOUT
11+`--kf-max-dist=1`) hashed twice to `ccc3bafd6d1c42b1336a69e68482e54b`, the
12+same md5 as `$HOME/.cache/sb128c-r8/vert46.obu`. Frame layout: mi 64x48, two
13+128 superblocks per row, the RIGHT column partial (`mi_col + hbs == mi_cols`),
14+so its 128 root reads the gathered bit. Frame 1 resolved it to
15+PARTITION_VERT = one BLOCK_64X128 inter block; frames 0 and 3 were exact,
16+1/2/4/5 differed (first differing byte 12033 = luma (x=129, y=62)).
17+
18+## Two root causes (both entropy, found on the msac range ladder)
19+
20+1. `crates/ec-av1/src/decode.rs:20146` (new) + `:17400`, `:18379`, `:19483`
21+ -- CHROMA ENTROPY CONTEXT RE-STAMPED PER BLOCK. A block wider or taller
22+ than 64 codes its chroma as one 32x32 unit per 64x64 mu chunk, and each
23+ unit stamps its own DC sign / level into the neighbour bands
24+ (`record_mi_chroma`, libaom `av1_set_entropy_contexts` inside
25+ `decode_reconstruct_tx`). The end-of-block record then OVERWROTE all of
26+ them with `neighbour_state` of the ASSEMBLED whole-block grid, i.e. with
27+ the top-left unit's DC. First diverging element: frame 1, block mi(0,32),
28+ plane 1, chunk 0, the DC sign symbol -- pre-symbol range 39712 on both
29+ sides, aomdec `dcctx=2`, ours `ctx=1`, post-symbol range 41596 vs 64592.
30+ Ours read the left neighbour as the 128x128 block's mu-chunk (0,0) DC
31+ (negative) where libaom reads its mu-chunk (0,16) DC (positive). Fix:
32+ collect the per-unit chroma grids and re-stamp them after the block record.
33+2. `crates/ec-av1/src/decode.rs:20179` -- VAR-TX BLOCK RECORDED AS SQUARE.
34+ `record_split_luma_rect_mi(at, side, side, ..)` wrote
35+ `above_side`/`left_side` = `side` (128) for a 64x128 var-tx block; the
36+ comment "a var-tx block is always square" stopped being true when the 128
37+ root's HORZ/VERT arm landed (sb128c r7). The NEXT superblock's 128-root
38+ partition symbol then read ctx 16 where aomdec reads ctx 19 (aomdec
39+ `EC_PART mi_row=32 mi_col=32 bsize=15 ctx=19 rng=43152`, ours entered the
40+ 64 level at rng=35032). Fix: pass the block's own `write_w`/`write_h`.
41+
42+Both are the same shape as memory classes `context-read-from-one-cell` and
43+`tx-grid-published-block-side` -- a neighbour band published with the BLOCK's
44+geometry instead of the transform unit's / the block's true footprint.
45+
46+EVIDENCE: $HOME/.cache/vert46-tmp/{our,aom}.f0..f5 | EC_AV1_FINAL_DUMP decode_probe v.obu vs instrumented aomdec, cmp per frame | 6/6 decode-order frames byte-identical (was 4 of 6 differing, 36073 bytes on frame 1)
47+EVIDENCE: $HOME/.cache/vert46-tmp/{a.lad,o.lad2} | EC_TRACE_COEFF range ladders, aomdec vs ours | first divergence moved 81 -> 109 -> none of 120 elements
48+
49+## Gate
50+
51+New arm 46 of the existing sb128 inter gate
52+(`a_real_aomenc_sb128_gathered_edge_horz_partition_decodes_pixel_exact`,
53+`crates/ec-av1/src/stream.rs:19005`): the same 192x256 VERT geometry as arm
54+44/45 but with the SMOOTH `geq` source instead of `mandelbrot` -- that is what
55+makes the encoder put a 64x128 edge block next to neighbours whose partition
56+context and chroma DC sign actually decide symbols. Arms 42-45 are unchanged
57+and still hard-assert the edge/inter counters; every decode-order frame
58+(hidden alt-refs included) is compared against the instrumented aomdec.
59+
60+ cargo test -p ec-av1 --lib sb128 -- --nocapture
61+ ... seed 42 384x320 8bit HORZ: 6 frames pixel-exact (1 hidden), edge +2 inter +2
62+ ... seed 43 384x320 10bit HORZ: 6 frames pixel-exact (1 hidden), edge +24 inter +24
63+ ... seed 44 192x256 8bit VERT: 6 frames pixel-exact (1 hidden), edge +2 inter +2
64+ ... seed 45 192x256 10bit VERT: 6 frames pixel-exact (1 hidden), edge +2 inter +2
65+ ... seed 46 192x256 8bit VERT: 6 frames pixel-exact (1 hidden), edge +20 inter +18
66+ test result: ok. 3 passed; 0 failed; 1 ignored (sibling sb128 gates included)
67+
68+EVIDENCE: $HOME/.cache/vert46-gate-r1.log | cargo test -p ec-av1 --lib sb128 --nocapture | 5/5 edge arms + 5/5 intra-rect arms + the CfL/1to4 gate pixel-exact, arm 46 fires 20 edge / 18 inter 128-rect blocks
69+
70+Siblings re-run in the same command (COMMON's SIBLING GATES rule):
71+`a_real_aomenc_sb128_intra_rect_block_decodes_pixel_exact` 5/5 arms exact
72+(128x64 +28/+30/+14, 64x128 +10/+10) and the sb128 CfL/1to4 gate.
73+
74+## Refusals
75+
76+None lifted or added -- both defects were silent wrong answers, not refusals.
77+
78+## Suite
79+
80+`cargo test -p ec-av1 --lib` under a systemd unit (MemoryMax=10G):
81+see `$HOME/.cache/vert46-suite-r1.log` (totals appended below when it lands).
82+
83+## Residue
84+
85+- accepted: the fix collects the per-unit chroma grids into a small `Vec` per
86+ 128-root block (2 or 4 units x 2 planes of 32x32 i32). Only blocks above 64
87+ pay it; below 64 `mu_chroma` is false and the vector is never allocated.
88+- deferred: the intra (key-frame) 128 path has the same end-of-block chroma
89+ record shape but its own reader; sb128c r8's intra gate is green on 5 arms,
90+ so no instance is measured there. Unblocked by a key-frame stream whose 128
91+ block sits LEFT of another coded block -- the arm-46 source with
92+ `--kf-max-dist=1` is exactly that and passes today.