forge
Explore
Log in

Don't you dare go Hollow

merge: main 1176a16 into lane-intra14 -- keep intrabc read plus the intra-in-inter mode split in read_intra_mode_rect

Browse files at this commit

70abd197d85b1c66a0c5fb2d282cbdba187d3d51Ahmet Kaan GümüşParent: e1121612bca382

30 changed files +5666 -596

crates/ec-av1/examples/decode_probe.rsmodified+14 -0
@@ -33,6 +33,7 @@ fn main() {
33 println!("reelc_chroma: skip_cfl={sc} dir_1to4_pairs={dp}");33 println!("reelc_chroma: skip_cfl={sc} dir_1to4_pairs={dp}");
34 let (h, v, c) = ec_av1::stream::rect4_32_counters();34 let (h, v, c) = ec_av1::stream::rect4_32_counters();
35 println!("rect4_32: horz={h} vert={v} coded={c}");35 println!("rect4_32: horz={h} vert={v} coded={c}");
36+ println!("rect_intrabc_reads: {}", ec_av1::stream::rect_intrabc_reads());
36 let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();37 let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();
37 println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");38 println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");
38 let i4 = ec_av1::stream::intra_rect4_in_inter_counters();39 let i4 = ec_av1::stream::intra_rect4_in_inter_counters();
@@ -40,6 +41,19 @@ fn main() {
40 "intra_rect4_in_inter: 64x16={} 16x64={} 32x8={} 8x32={}",41 "intra_rect4_in_inter: 64x16={} 16x64={} 32x8={} 8x32={}",
41 i4.0, i4.1, i4.2, i4.342 i4.0, i4.1, i4.2, i4.3
42 );43 );
44+ let leaf = ec_av1::stream::vartx_rect_leaf_hits();
45+ println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]);
46+ // lane-inter16ab r1: the 16x16-level inter AB arms, so a recipe sweep
47+ // can tell "aomenc never picked one" from "it did and we decoded it".
48+ let ab = ec_av1::decode::ab16_inter_hits_by_arm();
49+ println!(
50+ "inter_ab16: horz_a={} horz_b={} vert_a={} vert_b={}",
51+ ab[0], ab[1], ab[2], ab[3]
52+ );
53+ // lane-kf900 r1: the counter the skipped-8x8-split-transform gate
54+ // asserts -- printed here so a recipe sweep can see it fire without a
55+ // test-binary rebuild.
56+ println!("skip_split_tx: {}", ec_av1::decode::skip_split_tx_hits());
43 let ir = ec_av1::stream::inter_rect_counters();57 let ir = ec_av1::stream::inter_rect_counters();
44 println!(58 println!(
45 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",59 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",
crates/ec-av1/fixtures/reelb_kf900.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/reelb_ss600_key_frame.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+1342 -312

Diff too large; view file

@@ -997,6 +997,8 @@ thread_local! {
997 // (64x32/32x64/64x16/16x64), whose coefficients are coded as the997 // (64x32/32x64/64x16/16x64), whose coefficients are coded as the
998 // truncated low-32 corner.998 // truncated low-32 corner.
999 static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };999 static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1000+ // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32].
1001+ static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) };
1000 // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter1002 // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter
1001 // frame -- 16x8 and 8x16 inter leaves.1003 // frame -- 16x8 and 8x16 inter leaves.
1002 static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };1004 static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
@@ -1049,6 +1051,21 @@ pub(crate) fn rect64_inter_tu_hits() -> usize {
1049 RECT64_INTER_TU_HITS.with(|c| c.get())1051 RECT64_INTER_TU_HITS.with(|c| c.get())
1050 }1052 }
1051 1053
1054+/// Current value of [`VARTX_RECT_LEAF_HITS`] (lane-r14 r3): how many
1055+/// rectangular var-tx leaf transform units were coded, `[32x16, 16x32]`.
1056+pub(crate) fn vartx_rect_leaf_hits() -> [usize; 2] {
1057+ VARTX_RECT_LEAF_HITS.with(|c| c.get())
1058+}
1059+
1060+/// Records one rectangular var-tx leaf.
1061+fn vartx_rect_leaf_hit(tw: usize, th: usize) {
1062+ VARTX_RECT_LEAF_HITS.with(|c| {
1063+ let mut h = c.get();
1064+ h[usize::from(th > tw)] += 1;
1065+ c.set(h);
1066+ });
1067+}
1068+
1052 /// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/1069 /// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/
1053 /// [`ENABLE_FILTER_INTRA_INTER`].1070 /// [`ENABLE_FILTER_INTRA_INTER`].
1054 pub(crate) fn set_inter_tx_mode(1071 pub(crate) fn set_inter_tx_mode(
@@ -1455,6 +1472,18 @@ thread_local! {
1455 static PALETTE_SPLIT_TX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };1472 static PALETTE_SPLIT_TX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1456 }1473 }
1457 1474
1475+thread_local! {
1476+ /// lane-kf900 r4: rect intra strips that ACTUALLY use a palette -- the
1477+ /// 1:4 shapes (32x8/8x32, 16x4/4x16) and the sub-16x16 2:1 leaves
1478+ /// (16x8/8x16), the two shapes the lifted refusals named.
1479+ static RECT4_PALETTE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1480+}
1481+
1482+/// Current value of [`RECT4_PALETTE_HITS`].
1483+pub(crate) fn rect4_palette_hits() -> usize {
1484+ RECT4_PALETTE_HITS.with(|c| c.get())
1485+}
1486+
1458 /// Current value of [`PALETTE_SPLIT_TX_HITS`].1487 /// Current value of [`PALETTE_SPLIT_TX_HITS`].
1459 pub(crate) fn palette_split_tx_hits() -> usize {1488 pub(crate) fn palette_split_tx_hits() -> usize {
1460 PALETTE_SPLIT_TX_HITS.with(|c| c.get())1489 PALETTE_SPLIT_TX_HITS.with(|c| c.get())
@@ -1559,6 +1588,30 @@ thread_local! {
1559 static INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };1588 static INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1560 }1589 }
1561 1590
1591+/// Whether this frame's header set `allow_intrabc` -- [`INTRABC_MI_GRID`] is
1592+/// `Some` exactly then (set once per frame in `decode_frame`), so the flag
1593+/// needs no separate plumbing to reach the rect-strip mode reader.
1594+fn allow_intrabc_frame() -> bool {
1595+ INTRABC_MI_GRID.with(|g| g.borrow().is_some())
1596+}
1597+
1598+thread_local! {
1599+ /// How many rect intra strips READ the `use_intrabc` symbol (i.e. how many
1600+ /// times the fix below was exercised) -- the rect-strip gate's hit counter,
1601+ /// distinct from [`INTRABC_HITS`] which counts blocks that USE intrabc.
1602+ static RECT_INTRABC_READS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1603+}
1604+
1605+/// Current value of [`RECT_INTRABC_READS`].
1606+pub(crate) fn rect_intrabc_reads() -> usize {
1607+ RECT_INTRABC_READS.with(|c| c.get())
1608+}
1609+
1610+/// Zeroes [`RECT_INTRABC_READS`] (gate tests call this before a decode).
1611+pub(crate) fn reset_rect_intrabc_reads() {
1612+ RECT_INTRABC_READS.with(|c| c.set(0));
1613+}
1614+
1562 /// Current value of [`INTRABC_HITS`].1615 /// Current value of [`INTRABC_HITS`].
1563 pub(crate) fn intrabc_hits() -> usize {1616 pub(crate) fn intrabc_hits() -> usize {
1564 INTRABC_HITS.with(|c| c.get())1617 INTRABC_HITS.with(|c| c.get())
@@ -2131,6 +2184,44 @@ pub(crate) fn sb_rect_hits() -> usize {
2131 SB_RECT_HITS.with(|c| c.get())2184 SB_RECT_HITS.with(|c| c.get())
2132 }2185 }
2133 2186
2187+// lane-golomb r2: the 32x32-level FRAME-EDGE partition. Slot 0/1 = the
2188+// gathered edge bit read as 0 (HORZ/VERT) / 1 (SPLIT); slot 2 = a 32-level
2189+// PARTITION_HORZ decoded with `has_rows32 == false` (only the top 32x16 half
2190+// is coded), slot 3 = a PARTITION_VERT with `has_cols32 == false`. Both tile
2191+// paths (intra and inter) feed the same counter.
2192+//
2193+// lane-golomb r3: slots 4..7 are the same four facts one level up, at the
2194+// SUPERBLOCK (64x64) edge -- 4/5 = the gathered 64-level bit read as
2195+// HORZ/VERT / SPLIT, 6 = a 64x32 bottom-edge strip decoded with
2196+// `has_rows == false`, 7 = a 32x64 right-edge strip. Real aomenc answers a
2197+// bottom-edge superblock with the 64-level HORZ (measured: 192x80 flat-band,
2198+// every SB of the last row), so the 32-level slots stay 0 on that content and
2199+// only these prove the arm fired.
2200+thread_local! {
2201+ static EDGE32_HITS: std::cell::Cell<[usize; 8]> =
2202+ const { std::cell::Cell::new([0; 8]) };
2203+}
2204+
2205+/// Current value of [`EDGE32_HITS`].
2206+pub(crate) fn edge32_hits() -> [usize; 8] {
2207+ EDGE32_HITS.with(|c| c.get())
2208+}
2209+
2210+/// [`bump_edge32`] of `base + bit`, returning the bit -- the gathered edge
2211+/// reads are `if`-conditions, so the counter has to ride the expression.
2212+fn bump_edge32_bit(base: usize, bit: usize) -> usize {
2213+ bump_edge32(base + bit.min(1));
2214+ bit
2215+}
2216+
2217+fn bump_edge32(slot: usize) {
2218+ EDGE32_HITS.with(|c| {
2219+ let mut h = c.get();
2220+ h[slot] += 1;
2221+ c.set(h)
2222+ });
2223+}
2224+
2134 // lane-part32 r4: how many superblock-level AB blocks (`PARTITION_HORZ_A`/2225 // lane-part32 r4: how many superblock-level AB blocks (`PARTITION_HORZ_A`/
2135 // `_B`/`VERT_A`/`_B` at 64x64 -- two 32x32 squares plus one 64x32/32x642226 // `_B`/`VERT_A`/`_B` at 64x64 -- two 32x32 squares plus one 64x32/32x64
2136 // strip) fired. Real aomenc picks these at 64 even with2227 // strip) fired. Real aomenc picks these at 64 even with
@@ -2229,6 +2320,31 @@ pub(crate) fn rect4_coeff_hits() -> usize {
2229 RECT4_COEFF_HITS.with(|c| c.get())2320 RECT4_COEFF_HITS.with(|c| c.get())
2230 }2321 }
2231 2322
2323+// lane-inter16ab r1: how many 16x16-level AB partitions fired IN AN INTER
2324+// frame, per arm, in `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B`
2325+// order (the intra-frame counterpart is `AB16_HITS`). Each arm is two 8x8
2326+// inter leaves (`decode_inter_block8`) plus one true 16x8/8x16 inter strip
2327+// (`decode_inter_block` with `write_w`/`write_h`); the gate asserts every
2328+// arm separately so a run whose RD only picked one cannot pass as proof of
2329+// four.
2330+thread_local! {
2331+ static AB16_INTER_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) };
2332+}
2333+
2334+/// [`AB16_INTER_HITS`] per arm (HORZ_A, HORZ_B, VERT_A, VERT_B at 16x16 in an
2335+/// inter frame).
2336+pub fn ab16_inter_hits_by_arm() -> [usize; 4] {
2337+ AB16_INTER_HITS.with(std::cell::Cell::get)
2338+}
2339+
2340+fn bump_ab16_inter(arm: usize) {
2341+ AB16_INTER_HITS.with(|c| {
2342+ let mut v = c.get();
2343+ v[arm] += 1;
2344+ c.set(v);
2345+ });
2346+}
2347+
2232 // lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or2348 // lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or
2233 // 4x16 (`PARTITION_VERT_4`) strips, `CHROMA` counting the odd strips that2349 // 4x16 (`PARTITION_VERT_4`) strips, `CHROMA` counting the odd strips that
2234 // close a 4:2:0 chroma pair and `COEFF` the strips with a coded residual.2350 // close a 4:2:0 chroma pair and `COEFF` the strips with a coded residual.
@@ -2584,6 +2700,41 @@ thread_local! {
2584 static SUB8_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };2700 static SUB8_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2585 }2701 }
2586 2702
2703+// lane-cdef r1: (a) how many 8x8 CDEF units `apply_cdef` EXCLUDED because all
2704+// four of their mi cells are `skip_txfm` (libaom `cdef.c:29-38`
2705+// `is_8x8_block_skip` / `av1_cdef_compute_sb_list`'s dlist test), and (b) how
2706+// many 8x8 inter leaves (`decode_inter_block8`) wrote that skip band at all.
2707+// (b) was 0 for every stream before this round -- the leaf path never touched
2708+// the band, so an all-skip 8x8 group kept the PREVIOUS frame's flags and got
2709+// filtered where libaom skips it. A gate asserts both are non-zero.
2710+thread_local! {
2711+ static CDEF_SKIPPED_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2712+ static INTER8_SKIP_BAND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2713+ // lane-cdef r2: (c) 8x8 CDEF units that are FILTERED and whose extent
2714+ // crosses the cropped frame edge -- the only units for which "clamp at
2715+ // the crop" and "pad past the mi-rounded extent with CDEF_VERY_LARGE"
2716+ // (libaom `cdef.c:249-256`, `cdef_prepare_fb`'s hsize/vsize are
2717+ // `nhb << mi_wide_l2` off the MI grid, not the crop) differ. A frame
2718+ // whose width or height is not a multiple of 8 is the only shape that
2719+ // produces one; the straddling-band gate arms assert it grew.
2720+ static CDEF_STRADDLE_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2721+}
2722+
2723+/// Current value of `CDEF_SKIPPED_UNITS`.
2724+pub(crate) fn cdef_skipped_units() -> usize {
2725+ CDEF_SKIPPED_UNITS.with(|c| c.get())
2726+}
2727+
2728+/// Current value of `INTER8_SKIP_BAND_HITS`.
2729+pub(crate) fn inter8_skip_band_hits() -> usize {
2730+ INTER8_SKIP_BAND_HITS.with(|c| c.get())
2731+}
2732+
2733+/// Current value of `CDEF_STRADDLE_UNITS`.
2734+pub(crate) fn cdef_straddle_units() -> usize {
2735+ CDEF_STRADDLE_UNITS.with(|c| c.get())
2736+}
2737+
2587 /// Current value of [`SUB8_SPLIT_HITS`].2738 /// Current value of [`SUB8_SPLIT_HITS`].
2588 pub(crate) fn sub8_split_hits() -> usize {2739 pub(crate) fn sub8_split_hits() -> usize {
2589 SUB8_SPLIT_HITS.with(|c| c.get())2740 SUB8_SPLIT_HITS.with(|c| c.get())
@@ -2711,6 +2862,12 @@ const MAX_BR_LEVEL: i32 = NUM_BASE_LEVELS + COEFF_BASE_RANGE;
2711 const VERT_ALIKE: [usize; 6] = [2, PARTITION_SPLIT, 4, 6, 7, 9];2862 const VERT_ALIKE: [usize; 6] = [2, PARTITION_SPLIT, 4, 6, 7, 9];
2712 const HORZ_ALIKE: [usize; 6] = [1, PARTITION_SPLIT, 4, 5, 6, 8];2863 const HORZ_ALIKE: [usize; 6] = [1, PARTITION_SPLIT, 4, 5, 6, 8];
2713 2864
2865+fn trace_edge(mi_r: usize, mi_c: usize, bsize: u32, ctx: usize, rng: u32) {
2866+ if std::env::var_os("EC_AV1_TRACE").is_some() {
2867+ eprintln!("OUR_PART mi_row={mi_r} mi_col={mi_c} bsize={bsize} ctx={ctx} rng={rng}");
2868+ }
2869+}
2870+
2714 fn element_prob(cdf: &[u16], element: usize) -> u16 {2871 fn element_prob(cdf: &[u16], element: usize) -> u16 {
2715 cdf[element] - if element > 0 { cdf[element - 1] } else { 0 }2872 cdf[element] - if element > 0 { cdf[element - 1] } else { 0 }
2716 }2873 }
@@ -4059,11 +4216,21 @@ impl Neighbours {
4059 /// palette block decoded as "no palette" and the tile desynced from4216 /// palette block decoded as "no palette" and the tile desynced from
4060 /// there (class [[cdf-row-held-constant]]).4217 /// there (class [[cdf-row-held-constant]]).
4061 fn palette_ctx_and_cache(&self, at: (usize, usize)) -> (usize, Vec<u16>) {4218 fn palette_ctx_and_cache(&self, at: (usize, usize)) -> (usize, Vec<u16>) {
4219+ self.palette_ctx_and_cache_mi(at, at.0 * (SUB / MI))
4220+ }
4221+
4222+ /// [`Self::palette_ctx_and_cache`] with the block's REAL mi row, which a
4223+ /// 1:4 strip does not share with its [`SUB`] cell: `av1_get_palette_cache`
4224+ /// drops the above neighbour on a 64-px superblock boundary
4225+ /// (pred_common.c:76, `row % (1 << MIN_SB_SIZE_LOG2)` with `row` the
4226+ /// block's own PIXEL row), and strip 1 of a HORZ_4 sits 8 px into the
4227+ /// cell -- reading `at.0 % 4` there excludes strip 0 from the cache of
4228+ /// every strip in an SB's top cell row, which libaom does not do.
4229+ fn palette_ctx_and_cache_mi(&self, at: (usize, usize), mi_r: usize) -> (usize, Vec<u16>) {
4062 let (r, c) = at;4230 let (r, c) = at;
4063- let above_ok = r % 4 != 0;4231+ let above_ok = mi_r % 16 != 0;
4064 // `xd->above_mbmi` exists for every row but the tile's own first.4232 // `xd->above_mbmi` exists for every row but the tile's own first.
4065- let above_is_palette =4233+ let above_is_palette = mi_r > self.tile_row0_mi && self.above_palette_size[c] > 0;
4066- r * (SUB / MI) > self.tile_row0_mi && self.above_palette_size[c] > 0;
4067 let (above_n, above_colors) = if above_ok && self.above_palette_size[c] > 0 {4234 let (above_n, above_colors) = if above_ok && self.above_palette_size[c] > 0 {
4068 (self.above_palette_size[c], self.above_palette_colors[c])4235 (self.above_palette_size[c], self.above_palette_colors[c])
4069 } else {4236 } else {
@@ -4149,8 +4316,14 @@ impl Neighbours {
4149 /// palette use, `read_palette_mode_info`'s `pmi->palette_size[0] > 0`),4316 /// palette use, `read_palette_mode_info`'s `pmi->palette_size[0] > 0`),
4150 /// so only the cache is wanted here.4317 /// so only the cache is wanted here.
4151 fn palette_uv_cache(&self, at: (usize, usize)) -> Vec<u16> {4318 fn palette_uv_cache(&self, at: (usize, usize)) -> Vec<u16> {
4319+ self.palette_uv_cache_mi(at, at.0 * (SUB / MI))
4320+ }
4321+
4322+ /// [`Self::palette_uv_cache`] with the block's real mi row -- see
4323+ /// [`Self::palette_ctx_and_cache_mi`].
4324+ fn palette_uv_cache_mi(&self, at: (usize, usize), mi_r: usize) -> Vec<u16> {
4152 let (r, c) = at;4325 let (r, c) = at;
4153- let above_ok = r % 4 != 0;4326+ let above_ok = mi_r % 16 != 0;
4154 let (above_n, above_colors) = if above_ok && self.above_palette_uv_size[c] > 0 {4327 let (above_n, above_colors) = if above_ok && self.above_palette_uv_size[c] > 0 {
4155 (self.above_palette_uv_size[c], self.above_palette_uv_colors[c])4328 (self.above_palette_uv_size[c], self.above_palette_uv_colors[c])
4156 } else {4329 } else {
@@ -4223,6 +4396,9 @@ impl Neighbours {
4223 // TX_32X32 -- independent of this block's luma `tx_depth`.4396 // TX_32X32 -- independent of this block's luma `tx_depth`.
4224 let uv_tx_w = ((w_mi * MI / 2).max(4).min(32)) as u8;4397 let uv_tx_w = ((w_mi * MI / 2).max(4).min(32)) as u8;
4225 let uv_tx_h = ((h_mi * MI / 2).max(4).min(32)) as u8;4398 let uv_tx_h = ((h_mi * MI / 2).max(4).min(32)) as u8;
4399+ if std::env::var_os("EC_TXGRID_TRACE").is_some() {
4400+ eprintln!("EC_LFGRID mi_row={mi_r} mi_col={mi_c} w_mi={w_mi} h_mi={h_mi} tx_px={tx_px} tx_h_px={tx_h_px}");
4401+ }
4226 let cur = CURRENT_DELTA_LF.with(|c| c.get());4402 let cur = CURRENT_DELTA_LF.with(|c| c.get());
4227 let snapshot: [i8; 4] = if DELTA_LF_MULTI.with(|c| c.get()) {4403 let snapshot: [i8; 4] = if DELTA_LF_MULTI.with(|c| c.get()) {
4228 std::array::from_fn(|i| cur[i].clamp(-63, 63) as i8)4404 std::array::from_fn(|i| cur[i].clamp(-63, 63) as i8)
@@ -4254,6 +4430,36 @@ impl Neighbours {
4254 }4430 }
4255 }4431 }
4256 4432
4433+ /// One var-tx / split-tx LEAF's own LUMA transform dims over its mi span.
4434+ /// libaom `get_transform_size` (av1_loopfilter.c:207) applies the split
4435+ /// override only `if ((plane == AOM_PLANE_Y) && ...)` -- chroma keeps
4436+ /// `av1_get_max_uv_txsize(mbmi->bsize)`, the whole BLOCK's uv transform.
4437+ /// Routing a leaf through [`Self::fill_lf_grid_rect`] recomputed the uv
4438+ /// dims from the LEAF span and so invented chroma transform edges the
4439+ /// deblocker then filtered (lane-golomb r6). `ref_grid`/`delta_lf_grid`
4440+ /// are already correct from the block's own fill over the same span.
4441+ fn fill_lf_grid_leaf_luma(
4442+ &mut self,
4443+ at_mi: (usize, usize),
4444+ w_mi: usize,
4445+ h_mi: usize,
4446+ tx_px: u8,
4447+ tx_h_px: u8,
4448+ ) {
4449+ let (mi_r, mi_c) = at_mi;
4450+ for rr in 0..h_mi {
4451+ for cc in 0..w_mi {
4452+ let idx = (mi_r + rr) * self.skip_grid_cols_mi + (mi_c + cc);
4453+ if let Some(cell) = self.tx_grid.get_mut(idx) {
4454+ *cell = tx_px;
4455+ }
4456+ if let Some(cell) = self.tx_h_grid.get_mut(idx) {
4457+ *cell = tx_h_px;
4458+ }
4459+ }
4460+ }
4461+ }
4462+
4257 /// Marks every 4x4 mi cell a just-decoded coded block covers with its4463 /// Marks every 4x4 mi cell a just-decoded coded block covers with its
4258 /// `skip` flag -- `at_mi`/`side_mi` are the block's own position and4464 /// `skip` flag -- `at_mi`/`side_mi` are the block's own position and
4259 /// width/height in 4x4 mode-info units (mirroring [`Self::record_mi`]'s4465 /// width/height in 4x4 mode-info units (mirroring [`Self::record_mi`]'s
@@ -4718,6 +4924,37 @@ impl Neighbours {
4718 /// planes 1/2. Falls back to the coarse [`SUB`] slot on whichever axis no4924 /// planes 1/2. Falls back to the coarse [`SUB`] slot on whichever axis no
4719 /// block has recorded the exact neighbouring mi.4925 /// block has recorded the exact neighbouring mi.
4720 fn smooth_uv_neighbour(&self, mi_r: usize, mi_c: usize, r: usize, c: usize) -> bool {4926 fn smooth_uv_neighbour(&self, mi_r: usize, mi_c: usize, r: usize, c: usize) -> bool {
4927+ // lane-kf900 r2: libaom reads the chroma neighbours off the CHROMA
4928+ // REFERENCE block, not off the mi that carries the chroma syntax.
4929+ // `set_mi_row_col` (`blockd.h`) takes
4930+ // `base_mi = &xd->mi[-(mi_row & ss_y) * stride - (mi_col & ss_x)]` and
4931+ // only then `chroma_above_mbmi = base_mi[-stride]` /
4932+ // `chroma_left_mbmi = base_mi[-1]`. A sub-8 pair codes its chroma at
4933+ // the ODD mi, so without the snap we looked one mi row/column too far
4934+ // down/right -- the mi-exact slot never matched and the coarse
4935+ // fallback answered instead. Measured on a 4K 10-bit key frame, chroma
4936+ // 8x4 at (688, 100) = mi (51, 344): libaom's
4937+ // `get_intra_edge_filter_type` is 1 (the chroma block above it is
4938+ // `UV_SMOOTH_PRED`), ours was 0, which flips
4939+ // `av1_use_intra_edge_upsample(8, 4, -6, type)` (`blk_wh == 12`:
4940+ // false for type 1, TRUE for type 0) and upsampled an edge libaom
4941+ // leaves alone -- +1 on rows 2/3 of that block and every chroma block
4942+ // predicting from it (class `context-read-from-one-cell`).
4943+ self.smooth_uv_neighbour_unsnapped(mi_r & !1, mi_c & !1, r, c)
4944+ }
4945+
4946+ /// [`Self::smooth_uv_neighbour`] without the chroma-reference snap, i.e.
4947+ /// read off the mi passed in exactly. Only the 16x4/4x16 pair witness
4948+ /// counter wants this: it measures how often the snap CHANGES the answer,
4949+ /// which is what the lane-kf1200/kf900 chroma-reference fix buys. Every
4950+ /// decode path uses the snapping form.
4951+ fn smooth_uv_neighbour_unsnapped(
4952+ &self,
4953+ mi_r: usize,
4954+ mi_c: usize,
4955+ r: usize,
4956+ c: usize,
4957+ ) -> bool {
4721 // lane-mtfix r1: availability is TILE-relative on BOTH axes and on the4958 // lane-mtfix r1: availability is TILE-relative on BOTH axes and on the
4722 // coarse fallback too. `above_uv_mode` is a frame-wide [`SUB`]-grid4959 // coarse fallback too. `above_uv_mode` is a frame-wide [`SUB`]-grid
4723 // array that `start_tile` does not clear, so a block on a tile's first4960 // array that `start_tile` does not clear, so a block on a tile's first
@@ -5261,7 +5498,15 @@ fn merge_colors(transmitted: &[u16], cached: &[u16]) -> Vec<u16> {
5261 out5498 out
5262 }5499 }
5263 5500
5264-/// `read_palette_colors_y` (decodemv.c:478), bit_depth fixed at 8 (this5501+/// `read_palette_colors_y` (decodemv.c:478), at the sequence's real
5502+/// `bit_depth` -- lane-kf900 r3: every raw literal here (the first colour,
5503+/// each delta's width, the `range` bound and the clamp) is sized by
5504+/// `bit_depth`, and hardcoding 8 read 2 bits too few per colour on every
5505+/// 10-bit palette block. Raw literals are EQUIPROBABLE, and at the ranges
5506+/// this stream reaches (e.g. 62728) an equiprobable read is a FIXED POINT of
5507+/// the msac range, so a cross-decoder range ladder stays bit-identical
5508+/// through the whole miscount -- only the decoded VALUE differs (class
5509+/// `compare-range-not-tell`'s blind spot). (this
5265 /// decoder is 8-bit only): accepts up to `n` colours straight from `cache`5510 /// decoder is 8-bit only): accepts up to `n` colours straight from `cache`
5266 /// (one flag bit each, in cache order), then delta-codes the remainder5511 /// (one flag bit each, in cache order), then delta-codes the remainder
5267 /// (first value raw, each following delta `>= 1` off a shrinking bit width),5512 /// (first value raw, each following delta `>= 1` off a shrinking bit width),
@@ -5276,20 +5521,22 @@ fn read_palette_colors_y(dec: &mut SymbolDecoder, n: usize, cache: &[u16]) -> [u
5276 cached.push(c);5521 cached.push(c);
5277 }5522 }
5278 }5523 }
5524+ let bd = u32::from(bit_depth());
5525+ let max_val = (1i32 << bd) - 1;
5279 let mut colors = [0u16; 8];5526 let mut colors = [0u16; 8];
5280 let n_cached = cached.len();5527 let n_cached = cached.len();
5281 if n_cached < n {5528 if n_cached < n {
5282 let mut transmitted = Vec::with_capacity(n - n_cached);5529 let mut transmitted = Vec::with_capacity(n - n_cached);
5283- let first = dec.literal(8) as u16;5530+ let first = dec.literal(bd) as u16;
5284 transmitted.push(first);5531 transmitted.push(first);
5285 if n_cached + 1 < n {5532 if n_cached + 1 < n {
5286- let min_bits = 8u32 - 3;5533+ let min_bits = bd - 3;
5287 let mut bits = min_bits + dec.literal(2);5534 let mut bits = min_bits + dec.literal(2);
5288- let mut range = 255i32 - i32::from(first) - 1;5535+ let mut range = (1i32 << bd) - i32::from(first) - 1;
5289 for _ in (n_cached + 1)..n {5536 for _ in (n_cached + 1)..n {
5290 let delta = dec.literal(bits) as i32 + 1;5537 let delta = dec.literal(bits) as i32 + 1;
5291 let prev = *transmitted.last().unwrap();5538 let prev = *transmitted.last().unwrap();
5292- let val = (i32::from(prev) + delta).clamp(0, 255) as u16;5539+ let val = (i32::from(prev) + delta).clamp(0, max_val) as u16;
5293 range -= i32::from(val) - i32::from(prev);5540 range -= i32::from(val) - i32::from(prev);
5294 bits = bits.min(ceil_log2(range.max(0) as u32));5541 bits = bits.min(ceil_log2(range.max(0) as u32));
5295 transmitted.push(val);5542 transmitted.push(val);
@@ -5303,7 +5550,8 @@ fn read_palette_colors_y(dec: &mut SymbolDecoder, n: usize, cache: &[u16]) -> [u
5303 colors5550 colors
5304 }5551 }
5305 5552
5306-/// `read_palette_colors_uv` (decodemv.c:509), bit_depth fixed at 8: U reads5553+/// `read_palette_colors_uv` (decodemv.c:509), at the sequence's real
5554+/// `bit_depth` (see [`read_palette_colors_y`]): U reads
5307 /// exactly [`read_palette_colors_y`]'s cache/delta scheme (against the U-only5555 /// exactly [`read_palette_colors_y`]'s cache/delta scheme (against the U-only
5308 /// cache, `range` starting at `255 - prev` with no `-1`, and each raw `delta`5556 /// cache, `range` starting at `255 - prev` with no `-1`, and each raw `delta`
5309 /// unbiased by `+1` -- both differences from Y's own reader, matching the C5557 /// unbiased by `+1` -- both differences from Y's own reader, matching the C
@@ -5320,20 +5568,22 @@ fn read_palette_colors_uv(dec: &mut SymbolDecoder, n: usize, cache: &[u16]) -> (
5320 cached.push(c);5568 cached.push(c);
5321 }5569 }
5322 }5570 }
5571+ let bd = u32::from(bit_depth());
5572+ let max_val = 1i32 << bd;
5323 let mut u_colors = [0u16; 8];5573 let mut u_colors = [0u16; 8];
5324 let n_cached = cached.len();5574 let n_cached = cached.len();
5325 if n_cached < n {5575 if n_cached < n {
5326 let mut transmitted = Vec::with_capacity(n - n_cached);5576 let mut transmitted = Vec::with_capacity(n - n_cached);
5327- let first = dec.literal(8) as u16;5577+ let first = dec.literal(bd) as u16;
5328 transmitted.push(first);5578 transmitted.push(first);
5329 if n_cached + 1 < n {5579 if n_cached + 1 < n {
5330- let min_bits = 8u32 - 3;5580+ let min_bits = bd - 3;
5331 let mut bits = min_bits + dec.literal(2);5581 let mut bits = min_bits + dec.literal(2);
5332- let mut range = 255i32 - i32::from(first);5582+ let mut range = max_val - i32::from(first);
5333 for _ in (n_cached + 1)..n {5583 for _ in (n_cached + 1)..n {
5334 let delta = dec.literal(bits) as i32;5584 let delta = dec.literal(bits) as i32;
5335 let prev = *transmitted.last().unwrap();5585 let prev = *transmitted.last().unwrap();
5336- let val = (i32::from(prev) + delta).clamp(0, 255) as u16;5586+ let val = (i32::from(prev) + delta).clamp(0, max_val - 1) as u16;
5337 range -= i32::from(val) - i32::from(prev);5587 range -= i32::from(val) - i32::from(prev);
5338 bits = bits.min(ceil_log2(range.max(0) as u32));5588 bits = bits.min(ceil_log2(range.max(0) as u32));
5339 transmitted.push(val);5589 transmitted.push(val);
@@ -5346,9 +5596,9 @@ fn read_palette_colors_uv(dec: &mut SymbolDecoder, n: usize, cache: &[u16]) -> (
5346 }5596 }
5347 let mut v_colors = [0u16; 8];5597 let mut v_colors = [0u16; 8];
5348 if dec.literal(1) == 1 {5598 if dec.literal(1) == 1 {
5349- let min_bits_v = 8u32 - 4;5599+ let min_bits_v = bd - 4;
5350 let bits = min_bits_v + dec.literal(2);5600 let bits = min_bits_v + dec.literal(2);
5351- v_colors[0] = dec.literal(8) as u16;5601+ v_colors[0] = dec.literal(bd) as u16;
5352 for i in 1..n {5602 for i in 1..n {
5353 let mut delta = dec.literal(bits) as i32;5603 let mut delta = dec.literal(bits) as i32;
5354 if delta != 0 && dec.literal(1) == 1 {5604 if delta != 0 && dec.literal(1) == 1 {
@@ -5356,16 +5606,16 @@ fn read_palette_colors_uv(dec: &mut SymbolDecoder, n: usize, cache: &[u16]) -> (
5356 }5606 }
5357 let mut val = i32::from(v_colors[i - 1]) + delta;5607 let mut val = i32::from(v_colors[i - 1]) + delta;
5358 if val < 0 {5608 if val < 0 {
5359- val += 256;5609+ val += max_val;
5360 }5610 }
5361- if val >= 256 {5611+ if val >= max_val {
5362- val -= 256;5612+ val -= max_val;
5363 }5613 }
5364 v_colors[i] = val as u16;5614 v_colors[i] = val as u16;
5365 }5615 }
5366 } else {5616 } else {
5367 for i in 0..n {5617 for i in 0..n {
5368- v_colors[i] = dec.literal(8) as u16;5618+ v_colors[i] = dec.literal(bd) as u16;
5369 }5619 }
5370 }5620 }
5371 (u_colors, v_colors)5621 (u_colors, v_colors)
@@ -5544,6 +5794,13 @@ fn read_intra_mode_rect(
5544 Option<PaletteUv>,5794 Option<PaletteUv>,
5545 )> {5795 )> {
5546 let ec_istep = std::env::var_os("EC_TRACE_MODE_STEP").is_some();5796 let ec_istep = std::env::var_os("EC_TRACE_MODE_STEP").is_some();
5797+ if ec_istep {
5798+ // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line
5799+ // (decodemv.c:818), printed at the same point: before the first
5800+ // mode-info symbol of the block, so a cross-decoder range ladder can
5801+ // be keyed on the BLOCK, not just on the symbol sequence.
5802+ eprintln!("EC_IMODE mi_row={mi_r} mi_col={mi_c} fn=rect bw={bw} bh={bh} efi={} cls={:?} rng={}", enable_filter_intra as i32, filter_intra_size_class_rect(bw, bh), dec.debug_state().0);
5803+ }
5547 macro_rules! istep {5804 macro_rules! istep {
5548 ($name:literal, $val:expr) => {5805 ($name:literal, $val:expr) => {
5549 if ec_istep {5806 if ec_istep {
@@ -5595,6 +5852,27 @@ fn read_intra_mode_rect(
5595 istep!("dq", 0);5852 istep!("dq", 0);
5596 skip5853 skip
5597 };5854 };
5855+ // `read_intrabc_info` (spec 5.11.13, libaom `decodemv.c:892`, right after
5856+ // `skip`/`segment_id`/`cdef`/`delta_q` and before `mbmi->mode`): the
5857+ // `use_intrabc` symbol is read for EVERY intra block of an `allow_intrabc`
5858+ // frame -- `av1_allow_intrabc` is a frame-level test with no shape term, so
5859+ // rect strips read it exactly like square leaves ([`read_intra_mode`],
5860+ // [`read_intra_mode_sub8`]). Missing it here desynced the arithmetic
5861+ // decoder at the FIRST symbol of the first rect block of every
5862+ // `--tune-content=screen` key frame. Reconstruction of a real intrabc
5863+ // block at this shape is out of scope, so the flag is consumed and
5864+ // refused by name when it fires.
5865+ if allow_intrabc_frame() {
5866+ let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0;
5867+ RECT_INTRABC_READS.with(|c| c.set(c.get() + 1));
5868+ istep!("intrabc", use_intrabc as i32);
5869+ if use_intrabc {
5870+ INTRABC_HITS.with(|c| c.set(c.get() + 1));
5871+ return Err(unsupported(
5872+ "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)",
5873+ ));
5874+ }
5875+ }
5598 // libaom `read_intra_block_mode_info` (decodemv.c:1189) vs the key5876 // libaom `read_intra_block_mode_info` (decodemv.c:1189) vs the key
5599 // frame's `read_intra_frame_mode_info` (decodemv.c:1065 `read_intra_mode`5877 // frame's `read_intra_frame_mode_info` (decodemv.c:1065 `read_intra_mode`
5600 // off `kf_y_mode_cdf[above][left]`).5878 // off `kf_y_mode_cdf[above][left]`).
@@ -5699,9 +5977,11 @@ fn read_intra_mode_rect(
5699 if std::env::var_os("EC_AV1_TRACE").is_some() {5977 if std::env::var_os("EC_AV1_TRACE").is_some() {
5700 eprintln!("TRACE_RECT_USEFI value={}", use_filter_intra as i32);5978 eprintln!("TRACE_RECT_USEFI value={}", use_filter_intra as i32);
5701 }5979 }
5980+ istep!("use_filter_intra", use_filter_intra as i32);
5702 if use_filter_intra {5981 if use_filter_intra {
5703 FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1));5982 FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1));
5704 let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode);5983 let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode);
5984+ istep!("filter_intra_mode", fi_mode as i32);
5705 filter_intra = Some(fi_mode);5985 filter_intra = Some(fi_mode);
5706 }5986 }
5707 }5987 }
@@ -5714,7 +5994,13 @@ fn read_intra_mode_rect(
5714 PaletteY { size: n, colors, map }5994 PaletteY { size: n, colors, map }
5715 });5995 });
5716 let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| {5996 let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| {
5717- let map = decode_color_index_map_wh(dec, cdfs, n, bw / 2, bh / 2, true);5997+ // `av1_get_plane_block_size(bsize, 1, 1)` (`ss_size_lookup`), NOT a
5998+ // plain halving: BLOCK_16X4 subsamples to BLOCK_8X4 and BLOCK_4X16 to
5999+ // BLOCK_4X8, both floored at the 4-px transform. Halving the short
6000+ // axis to 2 read HALF the colour-index symbols of a 1:4 strip's
6001+ // chroma palette and desynced the tile from there.
6002+ let (cw, ch) = ((bw / 2).max(4), (bh / 2).max(4));
6003+ let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, true);
5718 PALETTE_UV_HITS.with(|c| c.set(c.get() + 1));6004 PALETTE_UV_HITS.with(|c| c.set(c.get() + 1));
5719 PaletteUv { size: n, u_colors, v_colors, map }6005 PaletteUv { size: n, u_colors, v_colors, map }
5720 });6006 });
@@ -5731,6 +6017,48 @@ fn read_intra_mode_rect(
5731 ))6017 ))
5732 }6018 }
5733 6019
6020+/// Stamps a 1:4 strip's palette state into the coarse above/left arrays.
6021+/// `av1_get_palette_cache` reads `xd->above_mbmi`/`xd->left_mbmi`, and inside
6022+/// a HORZ_4 (VERT_4) the next strip's ABOVE (LEFT) neighbour is this strip
6023+/// while its LEFT (ABOVE) neighbour is still the parent block's. The coarse
6024+/// [`SUB`]-cell arrays alias all four strips onto one entry, so writing BOTH
6025+/// axes after every strip would hand strip i+1 this strip's colours on the
6026+/// wrong axis too -- a wrong cache costs the same bits, so the tile stays in
6027+/// sync and only the pixels are wrong (class [[cdf-row-held-constant]]).
6028+/// Only the split axis is written until the closing strip, which stamps both
6029+/// for whatever follows the parent block.
6030+#[allow(clippy::too_many_arguments)]
6031+fn record_strip_palette(
6032+ n: &mut Neighbours,
6033+ at: (usize, usize),
6034+ bw: usize,
6035+ bh: usize,
6036+ y_size: usize,
6037+ y_colors: [u16; 8],
6038+ uv_size: usize,
6039+ uv_colors: [u16; 8],
6040+ last: bool,
6041+) {
6042+ let (r, c) = at;
6043+ let horz = bw > bh;
6044+ if horz || last {
6045+ for cell in 0..(bw / SUB).max(1) {
6046+ n.above_palette_size[c + cell] = y_size;
6047+ n.above_palette_colors[c + cell] = y_colors;
6048+ n.above_palette_uv_size[c + cell] = uv_size;
6049+ n.above_palette_uv_colors[c + cell] = uv_colors;
6050+ }
6051+ }
6052+ if !horz || last {
6053+ for cell in 0..(bh / SUB).max(1) {
6054+ n.left_palette_size[r + cell] = y_size;
6055+ n.left_palette_colors[r + cell] = y_colors;
6056+ n.left_palette_uv_size[r + cell] = uv_size;
6057+ n.left_palette_uv_colors[r + cell] = uv_colors;
6058+ }
6059+ }
6060+}
6061+
5734 /// [`tx_size_context`] for a true `bw`x`bh` rect strip (lane-intradisp r1):6062 /// [`tx_size_context`] for a true `bw`x`bh` rect strip (lane-intradisp r1):
5735 /// `get_tx_size_context` (libaom `pred_common.h`) compares the neighbour6063 /// `get_tx_size_context` (libaom `pred_common.h`) compares the neighbour
5736 /// above against this block's own *width* and the neighbour to the left6064 /// above against this block's own *width* and the neighbour to the left
@@ -5744,6 +6072,14 @@ fn tx_size_context_rect(
5744 ) -> usize {6072 ) -> usize {
5745 let above = mi_r > n.tile_row0_mi && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_w;6073 let above = mi_r > n.tile_row0_mi && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_w;
5746 let left = mi_c > n.tile_col0_mi && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_h;6074 let left = mi_c > n.tile_col0_mi && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_h;
6075+ if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {
6076+ eprintln!(
6077+ "EC_TXCTX mi_row={mi_r} mi_col={mi_c} w={own_w} h={own_h} above_px={} left_px={} ctx={}",
6078+ if mi_r > n.tile_row0_mi { tx_px_at(n, false, mi_r - 1, mi_c) } else { 0 },
6079+ if mi_c > n.tile_col0_mi { tx_h_px_at(n, false, mi_r, mi_c - 1) } else { 0 },
6080+ usize::from(above) + usize::from(left)
6081+ );
6082+ }
5747 usize::from(above) + usize::from(left)6083 usize::from(above) + usize::from(left)
5748 }6084 }
5749 6085
@@ -6994,8 +7330,11 @@ fn decode_leaf_rect(
6994 // decoded bit is the same. The cell is the 16px-SUB cell containing the7330 // decoded bit is the same. The cell is the 16px-SUB cell containing the
6995 // leaf (the palette neighbour arrays have no finer granularity).7331 // leaf (the palette neighbour arrays have no finer granularity).
6996 let pal_at = (leaf_mi.0 / (SUB / MI), leaf_mi.1 / (SUB / MI));7332 let pal_at = (leaf_mi.0 / (SUB / MI), leaf_mi.1 / (SUB / MI));
6997- let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache(pal_at);7333+ // lane-kf900 r4: the leaf's REAL mi row -- the second leaf of a 16x8 pair
6998- let palette_uv_cache = neighbours.palette_uv_cache(pal_at);7334+ // sits 8 px into the cell, so the cache's superblock-top-row exclusion
7335+ // must not be read off the cell (see [`Neighbours::palette_ctx_and_cache_mi`]).
7336+ let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at, leaf_mi.0);
7337+ let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at, leaf_mi.0);
6999 let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) =7338 let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) =
7000 read_intra_mode_rect(7339 read_intra_mode_rect(
7001 dec,7340 dec,
@@ -7014,14 +7353,31 @@ fn decode_leaf_rect(
7014 leaf_mi.0,7353 leaf_mi.0,
7015 leaf_mi.1,7354 leaf_mi.1,
7016 )?;7355 )?;
7356+ // lane-kf900 r4: palette prediction on this shape, the same colour-index
7357+ // map -> base colours buffer [`decode_block_rect`] hands each
7358+ // `reconstruct_rect` through [`set_palette_pred`].
7017 if palette_y.is_some() || palette_uv.is_some() {7359 if palette_y.is_some() || palette_uv.is_some() {
7018- // Symbols (mode/size/colours/index map) are all read above, so the7360+ RECT4_PALETTE_HITS.with(|c| c.set(c.get() + 1));
7019- // tile stays in sync; only the *pixel* reconstruction of a palette on
7020- // a below-16x16 strip is unported and ungated (lane-palette2 r7).
7021- return Err(unsupported(
7022- "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)",
7023- ));
7024 }7361 }
7362+ let palette_y_buf: Option<Vec<u16>> = palette_y
7363+ .as_ref()
7364+ .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect());
7365+ let palette_uv_bufs: Option<(Vec<u16>, Vec<u16>)> = palette_uv.as_ref().map(|p| {
7366+ (
7367+ p.map.iter().map(|&i| p.u_colors[i as usize]).collect(),
7368+ p.map.iter().map(|&i| p.v_colors[i as usize]).collect(),
7369+ )
7370+ });
7371+ let (pal_y_size, pal_y_colors) =
7372+ palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
7373+ let (pal_uv_size, pal_uv_colors) =
7374+ palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
7375+ // The closing leaf of the pair -- see [`record_strip_palette`].
7376+ let pal_last = if bw > bh {
7377+ leaf_mi.0 % 4 == 2
7378+ } else {
7379+ leaf_mi.1 % 4 == 2
7380+ };
7025 if std::env::var_os("EC_AV1_RECTX_TRACE").is_some() {7381 if std::env::var_os("EC_AV1_RECTX_TRACE").is_some() {
7026 eprintln!(" skip={skip} mode={mode} angle_delta_y={angle_delta_y} uv_mode={uv_mode}");7382 eprintln!(" skip={skip} mode={mode} angle_delta_y={angle_delta_y} uv_mode={uv_mode}");
7027 }7383 }
@@ -7080,11 +7436,12 @@ fn decode_leaf_rect(
7080 // the unsplit arm below passes the real neighbour answer -- chroma7436 // the unsplit arm below passes the real neighbour answer -- chroma
7081 // of a tx-split 16x8/8x16 leaf lost its intra-edge filter type.7437 // of a tx-split 16x8/8x16 leaf lost its intra-edge filter type.
7082 smooth_neighbor_uv,7438 smooth_neighbor_uv,
7083- // Both callers refuse a palette on this shape above (pixel7439+ palette_y: palette_y_buf.clone(),
7084- // reconstruction is unported here), so the split units carry none.7440+ palette_uv: palette_uv_bufs.clone(),
7085- palette_y: None,
7086- palette_uv: None,
7087 };7441 };
7442+ if palette_y.is_some() || palette_uv.is_some() {
7443+ PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
7444+ }
7088 decode_rect_split(7445 decode_rect_split(
7089 dec,7446 dec,
7090 cdfs,7447 cdfs,
@@ -7101,6 +7458,10 @@ fn decode_leaf_rect(
7101 base_q_idx,7458 base_q_idx,
7102 reduced_tx_set,7459 reduced_tx_set,
7103 )?;7460 )?;
7461+ record_strip_palette(
7462+ neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,
7463+ pal_last,
7464+ );
7104 return Ok(mode);7465 return Ok(mode);
7105 }7466 }
7106 let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI);7467 let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI);
@@ -7112,15 +7473,24 @@ fn decode_leaf_rect(
7112 luma_levels = vec![0i32; bw * bh];7473 luma_levels = vec![0i32; bw * bh];
7113 u_levels = vec![0i32; chroma_w * chroma_h];7474 u_levels = vec![0i32; chroma_w * chroma_h];
7114 v_levels = vec![0i32; chroma_w * chroma_h];7475 v_levels = vec![0i32; chroma_w * chroma_h];
7476+ if let Some(b) = &palette_y_buf {
7477+ set_palette_pred(b.clone());
7478+ }
7115 y.reconstruct_rect(7479 y.reconstruct_rect(
7116 px, py, bw, bh, mode, angle_delta_y, reach, &luma_levels, None, filter_intra,7480 px, py, bw, bh, mode, angle_delta_y, reach, &luma_levels, None, filter_intra,
7117 smooth_neighbor,7481 smooth_neighbor,
7118 );7482 );
7119 let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));7483 let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));
7484+ if let Some((ub, _)) = &palette_uv_bufs {
7485+ set_palette_pred(ub.clone());
7486+ }
7120 u.reconstruct_rect(7487 u.reconstruct_rect(
7121 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &u_levels,7488 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &u_levels,
7122 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv,7489 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv,
7123 );7490 );
7491+ if let Some((_, vb)) = &palette_uv_bufs {
7492+ set_palette_pred(vb.clone());
7493+ }
7124 v.reconstruct_rect(7494 v.reconstruct_rect(
7125 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_levels,7495 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_levels,
7126 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv,7496 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv,
@@ -7156,6 +7526,9 @@ fn decode_leaf_rect(
7156 &luma_levels, bw, bh, crate::decode::bit_depth(),7526 &luma_levels, bw, bh, crate::decode::bit_depth(),
7157 CURRENT_Q_IDX.with(|c| c.get()), plane_q_delta(0).0, plane_q_delta(0).1, luma_tx_type,7527 CURRENT_Q_IDX.with(|c| c.get()), plane_q_delta(0).0, plane_q_delta(0).1, luma_tx_type,
7158 );7528 );
7529+ if let Some(b) = &palette_y_buf {
7530+ set_palette_pred(b.clone());
7531+ }
7159 y.reconstruct_rect(7532 y.reconstruct_rect(
7160 px, py, bw, bh, mode, angle_delta_y, reach, &luma_residual, None, filter_intra,7533 px, py, bw, bh, mode, angle_delta_y, reach, &luma_residual, None, filter_intra,
7161 smooth_neighbor,7534 smooth_neighbor,
@@ -7173,6 +7546,9 @@ fn decode_leaf_rect(
7173 &u_levels, chroma_w, chroma_h, crate::decode::bit_depth(),7546 &u_levels, chroma_w, chroma_h, crate::decode::bit_depth(),
7174 CURRENT_Q_IDX.with(|c| c.get()), plane_q_delta(1).0, plane_q_delta(1).1, u_tx_type,7547 CURRENT_Q_IDX.with(|c| c.get()), plane_q_delta(1).0, plane_q_delta(1).1, u_tx_type,
7175 );7548 );
7549+ if let Some((ub, _)) = &palette_uv_bufs {
7550+ set_palette_pred(ub.clone());
7551+ }
7176 u.reconstruct_rect(7552 u.reconstruct_rect(
7177 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &u_residual,7553 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &u_residual,
7178 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv,7554 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv,
@@ -7189,6 +7565,9 @@ fn decode_leaf_rect(
7189 &v_levels, chroma_w, chroma_h, crate::decode::bit_depth(),7565 &v_levels, chroma_w, chroma_h, crate::decode::bit_depth(),
7190 CURRENT_Q_IDX.with(|c| c.get()), plane_q_delta(2).0, plane_q_delta(2).1, v_tx_type,7566 CURRENT_Q_IDX.with(|c| c.get()), plane_q_delta(2).0, plane_q_delta(2).1, v_tx_type,
7191 );7567 );
7568+ if let Some((_, vb)) = &palette_uv_bufs {
7569+ set_palette_pred(vb.clone());
7570+ }
7192 v.reconstruct_rect(7571 v.reconstruct_rect(
7193 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_residual,7572 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_residual,
7194 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv,7573 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv,
@@ -7198,12 +7577,15 @@ fn decode_leaf_rect(
7198 neighbours.record_mi_rect(leaf_mi, bw, bh, &[luma_levels, u_levels, v_levels]);7577 neighbours.record_mi_rect(leaf_mi, bw, bh, &[luma_levels, u_levels, v_levels]);
7199 neighbours.fill_skip_grid_rect(leaf_mi, mi_w, mi_h, skip);7578 neighbours.fill_skip_grid_rect(leaf_mi, mi_w, mi_h, skip);
7200 neighbours.fill_lf_grid_rect(leaf_mi, mi_w, mi_h, bw as u8, bh as u8, 0);7579 neighbours.fill_lf_grid_rect(leaf_mi, mi_w, mi_h, bw as u8, bh as u8, 0);
7201- // This leaf is necessarily non-palette (a palette one refused above), so7580+ // The leaf's own palette state (`0` clears, as this site always did
7202- // it must CLEAR the above/left palette state over its own span -- without7581+ // while a palette leaf refused -- lane-palette2 r8), written on the SPLIT
7203- // this the next block's `palette_y_mode` ctx and colour cache were read7582+ // AXIS only until the pair's closing leaf: the coarse cell holds one
7204- // off whatever block last covered the cell (lane-palette2 r8).7583+ // entry for both leaves, and leaf 0 zeroing the LEFT one threw away the
7205- neighbours.record_palette_y_rect(pal_at, bw, bh, 0, [0u16; 8]);7584+ // real left neighbour leaf 1 reads (lane-kf900 r4).
7206- neighbours.record_palette_uv_rect(pal_at, bw, bh, 0, [0u16; 8]);7585+ record_strip_palette(
7586+ neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,
7587+ pal_last,
7588+ );
7207 // A rect leaf spans mi_w x mi_h, so its mode reaches several columns and7589 // A rect leaf spans mi_w x mi_h, so its mode reaches several columns and
7208 // rows -- record the whole span, not one cell.7590 // rows -- record the whole span, not one cell.
7209 neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, mi_w, mi_h, mode);7591 neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, mi_w, mi_h, mode);
@@ -7267,6 +7649,14 @@ fn decode_block_rect4(
7267 // 8-px strip of a `HORZ_4`/`VERT_4` onto one cell.7649 // 8-px strip of a `HORZ_4`/`VERT_4` onto one cell.
7268 let (above_mode, left_mode) =7650 let (above_mode, left_mode) =
7269 neighbours.modes_above_left_mi(mi_r, mi_c, (above_mode, left_mode));7651 neighbours.modes_above_left_mi(mi_r, mi_c, (above_mode, left_mode));
7652+ // lane-kf900 r4: this strip's own palette-Y mode ctx and colour cache.
7653+ // Passing `None`/`&[]` read `palette_y_mode` off CDF row 0 and every
7654+ // `palette_colors_y` cache hit off an EMPTY cache -- right symbol count,
7655+ // wrong interval, so a screen-content tile desynced at the first strip
7656+ // whose neighbour used a palette (class [[cdf-row-held-constant]]).
7657+ let pal_at = (mi_r / (SUB / MI), mi_c / (SUB / MI));
7658+ let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at, mi_r);
7659+ let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at, mi_r);
7270 let (7660 let (
7271 skip,7661 skip,
7272 mode,7662 mode,
@@ -7289,21 +7679,35 @@ fn decode_block_rect4(
7289 enable_filter_intra,7679 enable_filter_intra,
7290 neighbours.skip_txfm_ctx(mi_r, mi_c),7680 neighbours.skip_txfm_ctx(mi_r, mi_c),
7291 allow_screen_content_tools,7681 allow_screen_content_tools,
7292- None,7682+ Some((palette_ctx, &palette_cache)),
7293- &[],7683+ &palette_uv_cache,
7294 mi_r,7684 mi_r,
7295 mi_c,7685 mi_c,
7296 )?;7686 )?;
7297- // Merge of lane-palette2: `read_intra_mode_rect` now reads the palette7687+ // lane-kf900 r4: palette prediction on this shape, exactly as
7298- // syntax for every rect strip, but this 1:4 decoder has no palette7688+ // [`decode_block_rect`] does one aspect ratio up -- the colour-index map
7299- // reconstruction path (its caller never passes a cache). The symbols are7689+ // mapped through the base colours IS the prediction (it reads no edge
7300- // still read, so the stream stays in sync; a strip that ACTUALLY uses a7690+ // pixels), handed to each `reconstruct_rect` through [`set_palette_pred`].
7301- // palette is refused rather than reconstructed wrong.
7302 if palette_y.is_some() || palette_uv.is_some() {7691 if palette_y.is_some() || palette_uv.is_some() {
7303- return Err(unsupported(7692+ RECT4_PALETTE_HITS.with(|c| c.set(c.get() + 1));
7304- "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)",
7305- ));
7306 }7693 }
7694+ let palette_y_buf: Option<Vec<u16>> = palette_y
7695+ .as_ref()
7696+ .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect());
7697+ let palette_uv_bufs: Option<(Vec<u16>, Vec<u16>)> = palette_uv.as_ref().map(|p| {
7698+ (
7699+ p.map.iter().map(|&i| p.u_colors[i as usize]).collect(),
7700+ p.map.iter().map(|&i| p.v_colors[i as usize]).collect(),
7701+ )
7702+ });
7703+ // `last`: strip 3 of the parent 32x32's HORZ_4 (VERT_4), the only one
7704+ // whose colours a block outside the parent sees -- see
7705+ // [`record_strip_palette`].
7706+ let pal_last = if bw > bh { mi_r % 8 == 6 } else { mi_c % 8 == 6 };
7707+ let (pal_y_size, pal_y_colors) =
7708+ palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
7709+ let (pal_uv_size, pal_uv_colors) =
7710+ palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
7307 let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode);7711 let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
7308 if smooth_neighbor {7712 if smooth_neighbor {
7309 SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));7713 SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
@@ -7363,11 +7767,12 @@ fn decode_block_rect4(
7363 filter_intra,7767 filter_intra,
7364 smooth_neighbor,7768 smooth_neighbor,
7365 smooth_neighbor_uv,7769 smooth_neighbor_uv,
7366- // Both callers refuse a palette on this shape above (pixel7770+ palette_y: palette_y_buf.clone(),
7367- // reconstruction is unported here), so the split units carry none.7771+ palette_uv: palette_uv_bufs.clone(),
7368- palette_y: None,
7369- palette_uv: None,
7370 };7772 };
7773+ if palette_y.is_some() || palette_uv.is_some() {
7774+ PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
7775+ }
7371 decode_rect_split(7776 decode_rect_split(
7372 dec,7777 dec,
7373 cdfs,7778 cdfs,
@@ -7384,6 +7789,10 @@ fn decode_block_rect4(
7384 base_q_idx,7789 base_q_idx,
7385 false,7790 false,
7386 )?;7791 )?;
7792+ record_strip_palette(
7793+ neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size,
7794+ pal_uv_colors, pal_last,
7795+ );
7387 if bw > bh {7796 if bw > bh {
7388 RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));7797 RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));
7389 } else {7798 } else {
@@ -7475,6 +7884,9 @@ fn decode_block_rect4(
7475 plane_q_delta(0).1,7884 plane_q_delta(0).1,
7476 luma_tx_type,7885 luma_tx_type,
7477 );7886 );
7887+ if let Some(b) = &palette_y_buf {
7888+ set_palette_pred(b.clone());
7889+ }
7478 y.reconstruct_rect(7890 y.reconstruct_rect(
7479 px,7891 px,
7480 py,7892 py,
@@ -7503,6 +7915,9 @@ fn decode_block_rect4(
7503 plane_q_delta(plane).1,7915 plane_q_delta(plane).1,
7504 tx_type,7916 tx_type,
7505 );7917 );
7918+ if let Some((ub, vb)) = &palette_uv_bufs {
7919+ set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() });
7920+ }
7506 buf.reconstruct_rect(7921 buf.reconstruct_rect(
7507 cpx,7922 cpx,
7508 cpy,7923 cpy,
@@ -7527,6 +7942,10 @@ fn decode_block_rect4(
7527 );7942 );
7528 neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip);7943 neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip);
7529 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0);7944 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0);
7945+ record_strip_palette(
7946+ neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size,
7947+ pal_uv_colors, pal_last,
7948+ );
7530 if bw > bh {7949 if bw > bh {
7531 RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));7950 RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));
7532 } else {7951 } else {
@@ -7534,6 +7953,9 @@ fn decode_block_rect4(
7534 }7953 }
7535 return Ok((mode, uv_predict_mode));7954 return Ok((mode, uv_predict_mode));
7536 };7955 };
7956+ if let Some(b) = &palette_y_buf {
7957+ set_palette_pred(b.clone());
7958+ }
7537 y.reconstruct_rect(7959 y.reconstruct_rect(
7538 px,7960 px,
7539 py,7961 py,
@@ -7548,6 +7970,9 @@ fn decode_block_rect4(
7548 smooth_neighbor,7970 smooth_neighbor,
7549 );7971 );
7550 let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));7972 let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));
7973+ if let Some((ub, _)) = &palette_uv_bufs {
7974+ set_palette_pred(ub.clone());
7975+ }
7551 u.reconstruct_rect(7976 u.reconstruct_rect(
7552 cpx,7977 cpx,
7553 cpy,7978 cpy,
@@ -7561,6 +7986,9 @@ fn decode_block_rect4(
7561 None,7986 None,
7562 smooth_neighbor_uv,7987 smooth_neighbor_uv,
7563 );7988 );
7989+ if let Some((_, vb)) = &palette_uv_bufs {
7990+ set_palette_pred(vb.clone());
7991+ }
7564 v.reconstruct_rect(7992 v.reconstruct_rect(
7565 cpx,7993 cpx,
7566 cpy,7994 cpy,
@@ -7577,6 +8005,10 @@ fn decode_block_rect4(
7577 neighbours.record_mi_rect((mi_r, mi_c), bw, bh, &[luma_levels.to_vec(), u_levels, v_levels]);8005 neighbours.record_mi_rect((mi_r, mi_c), bw, bh, &[luma_levels.to_vec(), u_levels, v_levels]);
7578 neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip);8006 neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip);
7579 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0);8007 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0);
8008+ record_strip_palette(
8009+ neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,
8010+ pal_last,
8011+ );
7580 if bw > bh {8012 if bw > bh {
7581 RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));8013 RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));
7582 } else {8014 } else {
@@ -7656,6 +8088,12 @@ fn decode_rect4_16(
7656 }8088 }
7657 let (above_mode, left_mode) =8089 let (above_mode, left_mode) =
7658 neighbours.modes_above_left_mi(lmi.0, lmi.1, (above_mode, left_mode));8090 neighbours.modes_above_left_mi(lmi.0, lmi.1, (above_mode, left_mode));
8091+ // lane-kf900 r4: the strip's real palette ctx + colour cache (see
8092+ // [`decode_block_rect4`]); `None`/`&[]` here read `palette_y_mode`
8093+ // off CDF row 0 and every cache hit off an empty cache.
8094+ let (palette_ctx, palette_cache) =
8095+ neighbours.palette_ctx_and_cache_mi(at16, lmi.0);
8096+ let palette_uv_cache = neighbours.palette_uv_cache_mi(at16, lmi.0);
7659 let (8097 let (
7660 skip,8098 skip,
7661 mode,8099 mode,
@@ -7678,16 +8116,26 @@ fn decode_rect4_16(
7678 enable_filter_intra,8116 enable_filter_intra,
7679 neighbours.skip_txfm_ctx(lmi.0, lmi.1),8117 neighbours.skip_txfm_ctx(lmi.0, lmi.1),
7680 allow_screen_content_tools,8118 allow_screen_content_tools,
7681- None,8119+ Some((palette_ctx, &palette_cache)),
7682- &[],8120+ &palette_uv_cache,
7683 lmi.0,8121 lmi.0,
7684 lmi.1,8122 lmi.1,
7685 )?;8123 )?;
7686 if palette_y.is_some() || palette_uv.is_some() {8124 if palette_y.is_some() || palette_uv.is_some() {
7687- return Err(unsupported(8125+ RECT4_PALETTE_HITS.with(|h| h.set(h.get() + 1));
7688- "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)",8126+ }
7689- ));8127+ // The colour-index map through the base colours IS the prediction.
7690- }8128+ // Chroma's map is the PAIR's 8x4 (4x8) block, matching the one
8129+ // chroma transform this closing strip codes.
8130+ let palette_y_buf: Option<Vec<u16>> = palette_y
8131+ .as_ref()
8132+ .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect());
8133+ let palette_uv_bufs: Option<(Vec<u16>, Vec<u16>)> = palette_uv.as_ref().map(|p| {
8134+ (
8135+ p.map.iter().map(|&i| p.u_colors[i as usize]).collect(),
8136+ p.map.iter().map(|&i| p.v_colors[i as usize]).collect(),
8137+ )
8138+ });
7691 let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode);8139 let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
7692 if smooth_neighbor {8140 if smooth_neighbor {
7693 SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1));8141 SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1));
@@ -7735,6 +8183,15 @@ fn decode_rect4_16(
7735 tx_h,8183 tx_h,
7736 reach,8184 reach,
7737 );8185 );
8186+ if let Some(b) = &palette_y_buf {
8187+ let tu_buf: Vec<u16> = (0..tx_h)
8188+ .flat_map(|i| {
8189+ let base = (tu_row * tx_h + i) * bw + tu_col * tx_w;
8190+ b[base..base + tx_w].iter().copied()
8191+ })
8192+ .collect();
8193+ set_palette_pred(tu_buf);
8194+ }
7738 if skip {8195 if skip {
7739 y.reconstruct_rect(8196 y.reconstruct_rect(
7740 tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &zero_tu,8197 tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &zero_tu,
@@ -7818,6 +8275,9 @@ fn decode_rect4_16(
7818 } else {8275 } else {
7819 let levels = if skip {8276 let levels = if skip {
7820 let zeros = vec![0i32; bw * bh];8277 let zeros = vec![0i32; bw * bh];
8278+ if let Some(b) = &palette_y_buf {
8279+ set_palette_pred(b.clone());
8280+ }
7821 y.reconstruct_rect(8281 y.reconstruct_rect(
7822 px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,8282 px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,
7823 smooth_neighbor,8283 smooth_neighbor,
@@ -7854,6 +8314,9 @@ fn decode_rect4_16(
7854 plane_q_delta(0).1,8314 plane_q_delta(0).1,
7855 tx_type,8315 tx_type,
7856 );8316 );
8317+ if let Some(b) = &palette_y_buf {
8318+ set_palette_pred(b.clone());
8319+ }
7857 y.reconstruct_rect(8320 y.reconstruct_rect(
7858 px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra,8321 px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra,
7859 smooth_neighbor,8322 smooth_neighbor,
@@ -7907,7 +8370,8 @@ fn decode_rect4_16(
7907 // directional chroma strip, moving 4 samples by 1.8370 // directional chroma strip, moving 4 samples by 1.
7908 let smooth_neighbor_uv =8371 let smooth_neighbor_uv =
7909 neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c);8372 neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c);
7910- if smooth_neighbor_uv != neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c) {8373+ if smooth_neighbor_uv != neighbours.smooth_uv_neighbour_unsnapped(lmi.0, lmi.1, r, c)
8374+ {
7911 RECT4_16_UV_PAIR_FILT_HITS.with(|h| h.set(h.get() + 1));8375 RECT4_16_UV_PAIR_FILT_HITS.with(|h| h.set(h.get() + 1));
7912 }8376 }
7913 let (u_levels, v_levels) = if skip {8377 let (u_levels, v_levels) = if skip {
@@ -7922,6 +8386,9 @@ fn decode_rect4_16(
7922 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));8386 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
7923 }8387 }
7924 for (buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] {8388 for (buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] {
8389+ if let Some((ub, vb)) = &palette_uv_bufs {
8390+ set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() });
8391+ }
7925 buf.reconstruct_rect(8392 buf.reconstruct_rect(
7926 cpx,8393 cpx,
7927 cpy,8394 cpy,
@@ -7977,6 +8444,9 @@ fn decode_rect4_16(
7977 plane_q_delta(plane).1,8444 plane_q_delta(plane).1,
7978 tx_type,8445 tx_type,
7979 );8446 );
8447+ if let Some((ub, vb)) = &palette_uv_bufs {
8448+ set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() });
8449+ }
7980 buf.reconstruct_rect(8450 buf.reconstruct_rect(
7981 cpx,8451 cpx,
7982 cpy,8452 cpy,
@@ -8027,6 +8497,14 @@ fn decode_rect4_16(
8027 } else {8497 } else {
8028 RECT4_16_VERT_HITS.with(|h| h.set(h.get() + 1));8498 RECT4_16_VERT_HITS.with(|h| h.set(h.get() + 1));
8029 }8499 }
8500+ let (pal_y_size, pal_y_colors) =
8501+ palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
8502+ let (pal_uv_size, pal_uv_colors) =
8503+ palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
8504+ record_strip_palette(
8505+ neighbours, at16, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,
8506+ i == 3,
8507+ );
8030 last_mode = mode;8508 last_mode = mode;
8031 prev = Some((lmi, mode));8509 prev = Some((lmi, mode));
8032 }8510 }
@@ -8610,6 +9088,13 @@ fn read_intra_mode(
8610 // under `EC_TRACE_MODE_STEP`) so a range ladder can be diffed line for9088 // under `EC_TRACE_MODE_STEP`) so a range ladder can be diffed line for
8611 // line against the instrumented aomdec, not just `tell()`.9089 // line against the instrumented aomdec, not just `tell()`.
8612 let ec_istep = std::env::var_os("EC_TRACE_MODE_STEP").is_some();9090 let ec_istep = std::env::var_os("EC_TRACE_MODE_STEP").is_some();
9091+ if ec_istep {
9092+ // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line
9093+ // (decodemv.c:818), printed at the same point: before the first
9094+ // mode-info symbol of the block, so a cross-decoder range ladder can
9095+ // be keyed on the BLOCK, not just on the symbol sequence.
9096+ eprintln!("EC_IMODE mi_row={mi_r} mi_col={mi_c} fn=sq side={side} rng={}", dec.debug_state().0);
9097+ }
8613 macro_rules! istep {9098 macro_rules! istep {
8614 ($name:literal, $val:expr) => {9099 ($name:literal, $val:expr) => {
8615 if ec_istep {9100 if ec_istep {
@@ -8972,13 +9457,12 @@ fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 {
8972 /// matches aomdec's own `ec_dump16` rung byte for byte (crop dims, u16 LE).9457 /// matches aomdec's own `ec_dump16` rung byte for byte (crop dims, u16 LE).
8973 fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) {9458 fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) {
8974 use std::io::Write;9459 use std::io::Write;
8975- // lane-sbrect10 r2: index the dump by decode-order picture like9460+ // lane-sbrect10 r2 / lane-cdef r1 (one shared helper): index the dump by
8976- // EC_AV1_PREFILT_DUMP already does -- a fixed `.f0` name kept only the9461+ // decode-order picture like EC_AV1_PREFILT_DUMP already does -- a fixed
8977- // LAST frame, so a mid-sequence divergence could not be read out at all.9462+ // `.f0` name kept only the LAST frame, so a mid-sequence divergence could
8978- static STAGE16_IDX: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);9463+ // not be read out at all.
8979 if let Ok(path) = std::env::var(var)9464 if let Ok(path) = std::env::var(var)
8980- && let idx = STAGE16_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst)9465+ && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var)))
8981- && let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}"))
8982 {9466 {
8983 for (p, w, h) in [(y, fw, fh), (u, fw.div_ceil(2), fh.div_ceil(2)), (v, fw.div_ceil(2), fh.div_ceil(2))] {9467 for (p, w, h) in [(y, fw, fh), (u, fw.div_ceil(2), fh.div_ceil(2)), (v, fw.div_ceil(2), fh.div_ceil(2))] {
8984 for row in 0..h {9468 for row in 0..h {
@@ -8992,10 +9476,25 @@ fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize,
8992 }9476 }
8993 }9477 }
8994 9478
9479+/// Decode-order index of the next [`dump_stage`]/[`dump_stage16`] file for a
9480+/// given env var -- lane-cdef r1: both used to write `.f0` unconditionally, so
9481+/// every frame overwrote the previous one and only the LAST frame survived,
9482+/// which silently defeats any per-frame filter-stage bisection.
9483+fn dump_stage_idx(var: &str) -> usize {
9484+ use std::collections::HashMap;
9485+ use std::sync::{Mutex, OnceLock};
9486+ static IDX: OnceLock<Mutex<HashMap<String, usize>>> = OnceLock::new();
9487+ let mut m = IDX.get_or_init(|| Mutex::new(HashMap::new())).lock().unwrap();
9488+ let e = m.entry(var.to_string()).or_insert(0);
9489+ let i = *e;
9490+ *e += 1;
9491+ i
9492+}
9493+
8995 fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) {9494 fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) {
8996 use std::io::Write;9495 use std::io::Write;
8997 if let Ok(path) = std::env::var(var)9496 if let Ok(path) = std::env::var(var)
8998- && let Ok(mut f) = std::fs::File::create(format!("{path}.f0"))9497+ && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var)))
8999 {9498 {
9000 for p in [y, u, v] {9499 for p in [y, u, v] {
9001 let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect();9500 let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect();
@@ -10508,8 +11007,19 @@ fn decode_leaf8(
10508 neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]);11007 neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]);
10509 neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]);11008 neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]);
10510 }11009 }
11010+ INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1));
10511 neighbours.fill_skip_grid(leaf_mi, 2, skip);11011 neighbours.fill_skip_grid(leaf_mi, 2, skip);
10512- neighbours.fill_lf_grid(leaf_mi, 2, 8, 0);11012+ // lane-kf900 r1: the leaf's own RESOLVED transform size, never the literal
11013+ // block side. libaom calls `set_txfm_ctxs(mbmi->tx_size, ..., skip_txfm &&
11014+ // is_inter_block(mbmi), xd)` (decodemv.c) -- for an INTRA block that skip
11015+ // term is always 0, so a skipped 8x8 leaf whose `tx_depth` resolved to
11016+ // TX_4X4 still publishes 4 to the next block's `get_tx_size_context`
11017+ // (pred_common.h:342). Writing 8 here made the 8x16 strip below the leaf
11018+ // read `tx_size_cat1` row 2 where libaom reads row 1 -- same alphabet,
11019+ // wrong CDF row, so the msac range diverged mid-frame with no refusal
11020+ // (class `wrong-alphabet-same-value`; the ReelB key frame at
11021+ // -ss 900, first bad luma sample row 186 col 1803).
11022+ neighbours.fill_lf_grid(leaf_mi, 2, resolved as u8, 0);
10513 neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode);11023 neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode);
10514 Ok(mode)11024 Ok(mode)
10515 }11025 }
@@ -10541,6 +11051,9 @@ fn read_intra_mode_sub8(
10541 mi_c: usize,11051 mi_c: usize,
10542 ) -> Result<(bool, usize, i32, Option<(usize, i32, Option<(i32, i32)>)>, Option<usize>)> {11052 ) -> Result<(bool, usize, i32, Option<(usize, i32, Option<(i32, i32)>)>, Option<usize>)> {
10543 let trace = std::env::var_os("EC_AV1_TRACE").is_some();11053 let trace = std::env::var_os("EC_AV1_TRACE").is_some();
11054+ if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {
11055+ eprintln!("EC_IMODE mi_row={mi_r} mi_col={mi_c} fn=sub8 rng={}", dec.debug_state().0);
11056+ }
10544 let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0;11057 let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0;
10545 if trace {11058 if trace {
10546 eprintln!("TRACE sub8 skip mi=({mi_r},{mi_c}) ctx={skip_ctx} value={} rng={}", skip as i32, dec.debug_state().0);11059 eprintln!("TRACE sub8 skip mi=({mi_r},{mi_c}) ctx={skip_ctx} value={} rng={}", skip as i32, dec.debug_state().0);
@@ -11607,6 +12120,46 @@ const TXFM_CTX_INIT: u8 = 64;
11607 /// twice below its own largest transform.12120 /// twice below its own largest transform.
11608 const MAX_VARTX_DEPTH: usize = 2;12121 const MAX_VARTX_DEPTH: usize = 2;
11609 12122
12123+/// libaom `sub_tx_size_map[TX_SIZES_ALL]` (`common_data.c`): the transform
12124+/// one `txfm_split` step below `tx_size`. RECTANGULAR for the 1:4 shapes
12125+/// (`[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32`) and for the 4:1
12126+/// small ones, square everywhere else.
12127+fn sub_tx_size_map(tx_w: usize, tx_h: usize) -> (usize, usize) {
12128+ match (tx_w, tx_h) {
12129+ (4, 4) => (4, 4),
12130+ (8, 8) => (4, 4),
12131+ (16, 16) => (8, 8),
12132+ (32, 32) => (16, 16),
12133+ (64, 64) => (32, 32),
12134+ (4, 8) | (8, 4) => (4, 4),
12135+ (8, 16) | (16, 8) => (8, 8),
12136+ (16, 32) | (32, 16) => (16, 16),
12137+ (32, 64) | (64, 32) => (32, 32),
12138+ (4, 16) => (4, 8),
12139+ (16, 4) => (8, 4),
12140+ (8, 32) => (8, 16),
12141+ (32, 8) => (16, 8),
12142+ (16, 64) => (16, 32),
12143+ (64, 16) => (32, 16),
12144+ _ => unreachable!("not a TX_SIZES_ALL shape: {tx_w}x{tx_h}"),
12145+ }
12146+}
12147+
12148+#[test]
12149+fn sub_tx_size_map_matches_libaom() {
12150+ // libaom `common_data.c` `sub_tx_size_map`, in TX_SIZES_ALL order.
12151+ const TABLE: [((usize, usize), (usize, usize)); 19] = [
12152+ ((4, 4), (4, 4)), ((8, 8), (4, 4)), ((16, 16), (8, 8)), ((32, 32), (16, 16)),
12153+ ((64, 64), (32, 32)), ((4, 8), (4, 4)), ((8, 4), (4, 4)), ((8, 16), (8, 8)),
12154+ ((16, 8), (8, 8)), ((16, 32), (16, 16)), ((32, 16), (16, 16)), ((32, 64), (32, 32)),
12155+ ((64, 32), (32, 32)), ((4, 16), (4, 8)), ((16, 4), (8, 4)), ((8, 32), (8, 16)),
12156+ ((32, 8), (16, 8)), ((16, 64), (16, 32)), ((64, 16), (32, 16)),
12157+ ];
12158+ for (tx, want) in TABLE {
12159+ assert_eq!(sub_tx_size_map(tx.0, tx.1), want, "sub_tx_size_map({tx:?})");
12160+ }
12161+}
12162+
11610 /// `read_var_tx_size` (spec 5.11.17, libaom `decodeframe.c`12163 /// `read_var_tx_size` (spec 5.11.17, libaom `decodeframe.c`
11611 /// `read_tx_size_vartx`): the recursive `txfm_split` tree of one12164 /// `read_tx_size_vartx`): the recursive `txfm_split` tree of one
11612 /// max-transform-sized unit of an inter block, collecting the resolved leaf12165 /// max-transform-sized unit of an inter block, collecting the resolved leaf
@@ -11623,22 +12176,28 @@ fn read_var_tx_size(
11623 at_mi: (usize, usize),12176 at_mi: (usize, usize),
11624 blk_max_px: usize,12177 blk_max_px: usize,
11625 (max_w_mi, max_h_mi): (usize, usize),12178 (max_w_mi, max_h_mi): (usize, usize),
11626- tx_px: usize,12179+ (tx_w, tx_h): (usize, usize),
11627 depth: usize,12180 depth: usize,
11628 blk_row: usize,12181 blk_row: usize,
11629 blk_col: usize,12182 blk_col: usize,
11630- out: &mut Vec<(usize, usize, usize)>,12183+ out: &mut Vec<(usize, usize, usize, usize)>,
11631 ) {12184 ) {
11632 if blk_row >= max_h_mi || blk_col >= max_w_mi {12185 if blk_row >= max_h_mi || blk_col >= max_w_mi {
11633 return;12186 return;
11634 }12187 }
11635 let unit = (at_mi.0 + blk_row, at_mi.1 + blk_col);12188 let unit = (at_mi.0 + blk_row, at_mi.1 + blk_col);
11636 if depth == MAX_VARTX_DEPTH {12189 if depth == MAX_VARTX_DEPTH {
11637- out.push((blk_row, blk_col, tx_px));12190+ out.push((blk_row, blk_col, tx_w, tx_h));
11638- txfm_partition_update(n, unit, tx_px, tx_px);12191+ txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h));
11639 return;12192 return;
11640 }12193 }
11641- let ctx = txfm_partition_ctx(n.above_txfm[unit.1], n.left_txfm[unit.0], blk_max_px, tx_px);12194+ let ctx = txfm_partition_ctx_rect(
12195+ n.above_txfm[unit.1],
12196+ n.left_txfm[unit.0],
12197+ blk_max_px,
12198+ tx_w,
12199+ tx_h,
12200+ );
11642 let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1;12201 let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1;
11643 TXFM_SPLIT_READS.with(|c| c.set(c.get() + 1));12202 TXFM_SPLIT_READS.with(|c| c.set(c.get() + 1));
11644 if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {12203 if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {
@@ -11651,27 +12210,27 @@ fn read_var_tx_size(
11651 );12210 );
11652 }12211 }
11653 if !split {12212 if !split {
11654- out.push((blk_row, blk_col, tx_px));12213+ out.push((blk_row, blk_col, tx_w, tx_h));
11655- txfm_partition_update(n, unit, tx_px, tx_px);12214+ txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h));
11656 return;12215 return;
11657 }12216 }
11658 TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1));12217 TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1));
11659- let sub = tx_px / 2;12218+ let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h);
11660- if sub == 4 {12219+ if (sub_w, sub_h) == (4, 4) {
11661- // libaom's `sub_txs == TX_4X4` early return: the whole 8x8 unit is12220+ // libaom's `sub_txs == TX_4X4` early return: every mi cell of the
11662- // marked 4x4 (four transform units, raster order) without recursing.12221+ // unit is marked 4x4 (raster order) without recursing.
11663- for row in 0..2 {12222+ for row in 0..tx_h / MI {
11664- for col in 0..2 {12223+ for col in 0..tx_w / MI {
11665 if blk_row + row < max_h_mi && blk_col + col < max_w_mi {12224 if blk_row + row < max_h_mi && blk_col + col < max_w_mi {
11666- out.push((blk_row + row, blk_col + col, 4));12225+ out.push((blk_row + row, blk_col + col, 4, 4));
11667 }12226 }
11668 }12227 }
11669 }12228 }
11670- txfm_partition_update(n, unit, 4, tx_px);12229+ txfm_partition_update_rect(n, unit, (4, 4), (tx_w, tx_h));
11671 return;12230 return;
11672 }12231 }
11673- for row in (0..tx_px / MI).step_by(sub / MI) {12232+ for row in (0..tx_h / MI).step_by(sub_h / MI) {
11674- for col in (0..tx_px / MI).step_by(sub / MI) {12233+ for col in (0..tx_w / MI).step_by(sub_w / MI) {
11675 read_var_tx_size(12234 read_var_tx_size(
11676 dec,12235 dec,
11677 cdfs,12236 cdfs,
@@ -11679,7 +12238,7 @@ fn read_var_tx_size(
11679 at_mi,12238 at_mi,
11680 blk_max_px,12239 blk_max_px,
11681 (max_w_mi, max_h_mi),12240 (max_w_mi, max_h_mi),
11682- sub,12241+ (sub_w, sub_h),
11683 depth + 1,12242 depth + 1,
11684 blk_row + row,12243 blk_row + row,
11685 blk_col + col,12244 blk_col + col,
@@ -11707,7 +12266,7 @@ fn read_block_tx_size(
11707 (mi_cols, mi_rows): (usize, usize),12266 (mi_cols, mi_rows): (usize, usize),
11708 is_inter: bool,12267 is_inter: bool,
11709 skip: bool,12268 skip: bool,
11710-) -> Result<(usize, Option<Vec<(usize, usize, usize)>>)> {12269+) -> Result<(usize, Option<Vec<(usize, usize, usize, usize)>>)> {
11711 if !TX_SELECT_INTER.with(std::cell::Cell::get) {12270 if !TX_SELECT_INTER.with(std::cell::Cell::get) {
11712 return Ok((side, None));12271 return Ok((side, None));
11713 }12272 }
@@ -11727,7 +12286,7 @@ fn read_block_tx_size(
11727 at_mi,12286 at_mi,
11728 side,12287 side,
11729 (max_w_mi, max_h_mi),12288 (max_w_mi, max_h_mi),
11730- max_tx,12289+ (max_tx, max_tx),
11731 0,12290 0,
11732 row,12291 row,
11733 col,12292 col,
@@ -11735,8 +12294,8 @@ fn read_block_tx_size(
11735 );12294 );
11736 }12295 }
11737 }12296 }
11738- let single = leaves.len() == 1 && leaves[0].2 == side;12297+ let single = leaves.len() == 1 && leaves[0].2 == side && leaves[0].3 == side;
11739- if !single && leaves.iter().any(|leaf| leaf.2 > 32) {12298+ if !single && leaves.iter().any(|leaf| leaf.2.max(leaf.3) > 32) {
11740 // Only a block wider than a superblock's own 64x64 max transform12299 // Only a block wider than a superblock's own 64x64 max transform
11741 // reaches here; this crate has no 64-point *inter* coefficient12300 // reaches here; this crate has no 64-point *inter* coefficient
11742 // table set ([`inter_txbset_for`] stops at 32).12301 // table set ([`inter_txbset_for`] stops at 32).
@@ -11774,7 +12333,7 @@ fn read_block_tx_size(
11774 let mut leaves = Vec::new();12333 let mut leaves = Vec::new();
11775 for row in (0..side_mi).step_by(step) {12334 for row in (0..side_mi).step_by(step) {
11776 for col in (0..side_mi).step_by(step) {12335 for col in (0..side_mi).step_by(step) {
11777- leaves.push((row, col, tx));12336+ leaves.push((row, col, tx, tx));
11778 }12337 }
11779 }12338 }
11780 INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| {12339 INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| {
@@ -11926,7 +12485,7 @@ fn read_block_tx_size_rect(
11926 (bw, bh): (usize, usize),12485 (bw, bh): (usize, usize),
11927 (mi_cols, mi_rows): (usize, usize),12486 (mi_cols, mi_rows): (usize, usize),
11928 skip: bool,12487 skip: bool,
11929-) -> Result<Option<Vec<(usize, usize, usize)>>> {12488+) -> Result<Option<Vec<(usize, usize, usize, usize)>>> {
11930 if skip {12489 if skip {
11931 // `set_txfm_ctxs(.., skip && is_inter)`: a skipped inter block records12490 // `set_txfm_ctxs(.., skip && is_inter)`: a skipped inter block records
11932 // its own BLOCK size -- width above, height left -- not a transform.12491 // its own BLOCK size -- width above, height left -- not a transform.
@@ -11969,22 +12528,16 @@ fn read_block_tx_size_rect(
11969 }12528 }
11970 TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1));12529 TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1));
11971 RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1));12530 RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1));
11972- // lane-r14 r2: `sub_tx_size_map` is square for every shape this decoder12531+ // lane-r14 r3: `sub_tx_size_map` (libaom `common_data.c`) stays
11973- // splits (TX_32X16 -> TX_16X16, TX_64X32 -> TX_32X32) EXCEPT the 1:412532+ // RECTANGULAR under a 1:4 strip -- `[TX_64X16] == TX_32X16`,
11974- // strips with a 64-px axis, where it stays rectangular12533+ // `[TX_16X64] == TX_16X32` -- so the recursion below is the general
11975- // (TX_64X16 -> TX_32X16, TX_16X64 -> TX_16X32) and the square recursion12534+ // rect one and its leaves carry their own width and height.
11976- // below would code the wrong tree.12535+ let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h);
11977- if tx_w.max(tx_h) == 64 && tx_w.min(tx_h) == 16 {
11978- return Err(unsupported(
11979- "a split transform on a 1:4 inter strip with a 64-px axis",
11980- ));
11981- }
11982- let sub = tx_w.min(tx_h);
11983 let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1));12536 let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1));
11984 let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0));12537 let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0));
11985 let mut leaves = Vec::new();12538 let mut leaves = Vec::new();
11986- for row in (0..bh / MI).step_by(sub / MI) {12539+ for row in (0..bh / MI).step_by(sub_h / MI) {
11987- for col in (0..bw / MI).step_by(sub / MI) {12540+ for col in (0..bw / MI).step_by(sub_w / MI) {
11988 read_var_tx_size(12541 read_var_tx_size(
11989 dec,12542 dec,
11990 cdfs,12543 cdfs,
@@ -11992,7 +12545,7 @@ fn read_block_tx_size_rect(
11992 at_mi,12545 at_mi,
11993 bw.max(bh),12546 bw.max(bh),
11994 (max_w_mi, max_h_mi),12547 (max_w_mi, max_h_mi),
11995- sub,12548+ (sub_w, sub_h),
11996 1,12549 1,
11997 row,12550 row,
11998 col,12551 col,
@@ -12029,9 +12582,12 @@ fn read_inter_plane_rect(
12029 y: usize,12582 y: usize,
12030 prediction: &[u16],12583 prediction: &[u16],
12031 inherited_luma_tx_type: Option<TxType>,12584 inherited_luma_tx_type: Option<TxType>,
12585+ luma_skip_ctx: Option<usize>,
12032 ) -> Result<(Vec<i32>, TxType)> {12586 ) -> Result<(Vec<i32>, TxType)> {
12033 let skip_ctx = if plane_idx == 0 {12587 let skip_ctx = if plane_idx == 0 {
12034- 012588+ // `get_txb_ctx_general`: 0 only when this unit IS the whole plane
12589+ // block; a var-tx leaf passes its own neighbour-table context.
12590+ luma_skip_ctx.unwrap_or(0)
12035 } else {12591 } else {
12036 usize::from(around.0) + usize::from(around.1)12592 usize::from(around.0) + usize::from(around.1)
12037 };12593 };
@@ -12039,8 +12595,8 @@ fn read_inter_plane_rect(
12039 // `av1_get_ext_tx_set_type`'s DCT-only clamp is on `tx_size_sqr_up`, i.e.12595 // `av1_get_ext_tx_set_type`'s DCT-only clamp is on `tx_size_sqr_up`, i.e.
12040 // the *longer* side of this rect transform.12596 // the *longer* side of this rect transform.
12041 let default_tx_type = match inherited_luma_tx_type {12597 let default_tx_type = match inherited_luma_tx_type {
12042- Some(t) if w.max(h) < 32 => t,12598+ Some(t) => reduce_inherited_chroma_tx_type(t, w, h),
12043- _ => TxType::DctDct,12599+ None => TxType::DctDct,
12044 };12600 };
12045 // lane-r14 r2: a 64-length axis codes only its low 32 coefficients12601 // lane-r14 r2: a 64-length axis codes only its low 32 coefficients
12046 // (`av1_get_max_eob`), so the coded unit is the `min(w,32) x min(h,32)`12602 // (`av1_get_max_eob`), so the coded unit is the `min(w,32) x min(h,32)`
@@ -12207,6 +12763,45 @@ fn read_inter_luma8(
12207 12763
12208 /// The [`TxbSet`] one leaf of an inter block's var-tx tree reads its12764 /// The [`TxbSet`] one leaf of an inter block's var-tx tree reads its
12209 /// coefficient tables from -- the inter counterpart of [`txbset_for`].12765 /// coefficient tables from -- the inter counterpart of [`txbset_for`].
12766+/// `av1_get_tx_type`'s chroma tail (libaom `av1/common/blockd.h:1291-1305`):
12767+/// an inter block's chroma transform inherits the *colocated luma* unit's
12768+/// coded `tx_type`, then drops back to `DCT_DCT` unless that type is a member
12769+/// of the extended set the CHROMA transform size selects
12770+/// (`av1_ext_tx_used[av1_get_ext_tx_set_type(uv_tx, 1, reduced)][tx_type]`,
12771+/// `blockd.h:1036`/`1097`). lane-golomb r7: we used to force `DCT_DCT` at
12772+/// every chroma side >= 32, but `av1_get_ext_tx_set_type`'s DCT-only rung is
12773+/// `tx_size_sqr_up > TX_32X32`; at exactly TX_32X32 an inter block reads
12774+/// `EXT_TX_SET_DCT_IDTX`, so a 64x64 inter block whose first luma leaf coded
12775+/// `IDTX` inherits IDTX on its 32x32 chroma units. `IDTX` and `DCT_DCT` are
12776+/// both `TX_CLASS_2D`, so that mistake left the entropy stream perfectly in
12777+/// sync and only corrupted the inverse transform (one 64x64 superblock of
12778+/// high-frequency chroma noise, luma bit-exact).
12779+fn reduce_inherited_chroma_tx_type(t: TxType, w: usize, h: usize) -> TxType {
12780+ use TxType::*;
12781+ let sqr_up = w.max(h);
12782+ let sqr = w.min(h);
12783+ let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);
12784+ // `av1_get_ext_tx_set_type(tx_size, is_inter = 1, reduced)`.
12785+ let allowed: &[TxType] = if sqr_up > 32 {
12786+ // EXT_TX_SET_DCTONLY
12787+ &[DctDct]
12788+ } else if sqr_up == 32 || reduced {
12789+ // EXT_TX_SET_DCT_IDTX
12790+ &[DctDct, Idtx]
12791+ } else if sqr == 16 {
12792+ // EXT_TX_SET_DTT9_IDTX_1DDCT -- TX_TYPES 0..=11, i.e. everything but
12793+ // the four 1D ADST/FLIPADST types.
12794+ &[
12795+ DctDct, AdstDct, DctAdst, AdstAdst, FlipAdstDct, DctFlipAdst, FlipAdstFlipAdst,
12796+ AdstFlipAdst, FlipAdstAdst, Idtx, VDct, HDct,
12797+ ]
12798+ } else {
12799+ // EXT_TX_SET_ALL16
12800+ return t;
12801+ };
12802+ if allowed.contains(&t) { t } else { DctDct }
12803+}
12804+
12210 fn inter_txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet {12805 fn inter_txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet {
12211 match tx_px {12806 match tx_px {
12212 32 => TxbSet::Luma32Inter,12807 32 => TxbSet::Luma32Inter,
@@ -12712,6 +13307,18 @@ fn deblock_plane(
12712 // last coded mi column's horizontal edges were filtered when libaom's13307 // last coded mi column's horizontal edges were filtered when libaom's
12713 // real output leaves them untouched (r6's post-deblock diff, 37 px, all13308 // real output leaves them untouched (r6's post-deblock diff, 37 px, all
12714 // in columns 44-47); clipping here closes it (3/3 frames pixel-exact).13309 // in columns 44-47); clipping here closes it (3/3 frames pixel-exact).
13310+ // lane-golomb r9: the bound is the MI-ROUNDED frame, not the coded
13311+ // frame. libaom's `av1_filter_block_plane_vert/horz` walk the superblock
13312+ // and stop at `cm->mi_params.mi_cols`/`mi_rows`, which
13313+ // `av1_set_mb_mi` derives from `ALIGN_POWER_OF_TWO(width, 3)` -- the
13314+ // 8-pixel-aligned frame, i.e. a 68-wide frame is filtered out to column
13315+ // 72 and the vertical edge AT x=68 is a real edge that rewrites the
13316+ // in-crop columns 64..67. Clipping at `frame_width` skipped it, which is
13317+ // the +-1 straddling-band defect (68x192 cq35, frame 1, 141 luma pixels
13318+ // all in columns 64..67; frame 0 survived because that edge carried no
13319+ // filter level there). r7's superres measurement is preserved: its frame
13320+ // was already 8-aligned, so this bound equals `frame_width` there and
13321+ // still excludes the superblock padding up to `true_width`.
12715 let (cw, ch) = if chroma {13322 let (cw, ch) = if chroma {
12716 (frame_width.div_ceil(2), frame_height.div_ceil(2))13323 (frame_width.div_ceil(2), frame_height.div_ceil(2))
12717 } else {13324 } else {
@@ -12722,11 +13329,17 @@ fn deblock_plane(
12722 plane.true_height.min(ch),13329 plane.true_height.min(ch),
12723 plane.width,13330 plane.width,
12724 );13331 );
13332+ if std::env::var_os("EC_AV1_DEBLOCK_TRACE_V").is_some() {
13333+ eprintln!("DEBLOCK plane={plane_idx} tw={tw} th={th} stride={stride} true={}x{} crop={cw}x{ch}", plane.true_width, plane.true_height);
13334+ }
12725 let mut y0 = 0usize;13335 let mut y0 = 0usize;
12726 while y0 < th {13336 while y0 < th {
12727 let mut x0 = 4usize;13337 let mut x0 = 4usize;
12728 while x0 < tw {13338 while x0 < tw {
12729 if let Some((len, level)) = edge_params(lf, n, plane_idx, 0, chroma, x0, y0) {13339 if let Some((len, level)) = edge_params(lf, n, plane_idx, 0, chroma, x0, y0) {
13340+ if std::env::var_os("EC_AV1_DEBLOCK_TRACE_V").is_some() && plane_idx == 0 {
13341+ eprintln!("VEDGE x0={x0} y0={y0} len={len} level={level}");
13342+ }
12730 filter_edge(13343 filter_edge(
12731 &mut plane.data,13344 &mut plane.data,
12732 y0 * stride + x0,13345 y0 * stride + x0,
@@ -12777,6 +13390,9 @@ fn apply_cdef(
12777 v: &mut PlaneBuf,13390 v: &mut PlaneBuf,
12778 cdef: &CdefParams,13391 cdef: &CdefParams,
12779 skip_grid: &Neighbours,13392 skip_grid: &Neighbours,
13393+ // This frame header's own CROPPED luma size, for the straddling-unit
13394+ // counter only -- CDEF itself walks the mi-rounded plane.
13395+ (frame_w, frame_h): (usize, usize),
12780 ) {13396 ) {
12781 // lane-part32 r2 debug rung, env-gated: see `apply_deblock`'s sibling.13397 // lane-part32 r2 debug rung, env-gated: see `apply_deblock`'s sibling.
12782 if std::env::var_os("EC_AV1_DEBUG_SKIP_CDEF").is_some() {13398 if std::env::var_os("EC_AV1_DEBUG_SKIP_CDEF").is_some() {
@@ -12820,6 +13436,9 @@ fn apply_cdef(
12820 while mi_r < skip_grid.mi_rows {13436 while mi_r < skip_grid.mi_rows {
12821 let mut mi_c = 0usize;13437 let mut mi_c = 0usize;
12822 while mi_c < skip_grid.mi_cols {13438 while mi_c < skip_grid.mi_cols {
13439+ if skip_grid.is_skip_txfm(mi_r, mi_c) {
13440+ CDEF_SKIPPED_UNITS.with(|c| c.set(c.get() + 1));
13441+ }
12823 if !skip_grid.is_skip_txfm(mi_r, mi_c) {13442 if !skip_grid.is_skip_txfm(mi_r, mi_c) {
12824 let sidx = strength_idx(mi_r, mi_c);13443 let sidx = strength_idx(mi_r, mi_c);
12825 let (ox, oy) = (mi_c * 4, mi_r * 4);13444 let (ox, oy) = (mi_c * 4, mi_r * 4);
@@ -12832,10 +13451,15 @@ fn apply_cdef(
12832 i32::from(src_y[ny as usize * y_stride + nx as usize])13451 i32::from(src_y[ny as usize * y_stride + nx as usize])
12833 }13452 }
12834 };13453 };
12835- let (dir, var) = cdef_find_dir(coeff_shift, |r, c| {13454+ // lane-cdef r1: the direction search reads the SAME padded
12836- let (ny, nx) = ((oy + r).min(y_true_h - 1), (ox + c).min(y_true_w - 1));13455+ // block the taps do -- libaom runs `cdef_find_dir` on the
12837- i32::from(src_y[ny * y_stride + nx])13456+ // prepared filter block (`cdef_block.c:296-320` over
12838- });13457+ // `cdef_prepare_fb`'s buffer, `cdef.c:249-256`), whose columns
13458+ // and rows past the mi-rounded frame extent are CDEF_VERY_LARGE.
13459+ // Clamping to the last real sample instead made every straddling
13460+ // edge 8x8 (odd `mi_cols`/`mi_rows`) pick a different var, hence
13461+ // a different `adjust_strength`, hence a +-1 band at the crop edge.
13462+ let (dir, var) = cdef_find_dir(coeff_shift, |r, c| sample_y(r as i32, c as i32));
12839 13463
12840 // libaom `av1_cdef_filter_fb` passes `pri_strength ? dir : 0`13464 // libaom `av1_cdef_filter_fb` passes `pri_strength ? dir : 0`
12841 // -- each plane zeroes the shared direction when *its own*13465 // -- each plane zeroes the shared direction when *its own*
@@ -12845,8 +13469,22 @@ fn apply_cdef(
12845 let y_sec_strength = i32::from(cdef.y_sec_strength[sidx]) << coeff_shift;13469 let y_sec_strength = i32::from(cdef.y_sec_strength[sidx]) << coeff_shift;
12846 let y_dir = if y_pri_strength != 0 { dir } else { 0 };13470 let y_dir = if y_pri_strength != 0 { dir } else { 0 };
12847 let t = cdef_adjust_strength(y_pri_strength, var);13471 let t = cdef_adjust_strength(y_pri_strength, var);
13472+ // lane-cdef r1 rung: one line per filtered 8x8 luma CDEF unit.
13473+ if std::env::var_os("EC_AV1_CDEF_DBG").is_some() {
13474+ eprintln!(
13475+ "EC_CDEF mi_r={mi_r} mi_c={mi_c} x={ox} y={oy} sidx={sidx} dir={dir} var={var} t={t} pri={y_pri_strength} sec={y_sec_strength} damp={damping}"
13476+ );
13477+ }
12848 let enable_primary = t != 0;13478 let enable_primary = t != 0;
12849 let enable_secondary = y_sec_strength != 0;13479 let enable_secondary = y_sec_strength != 0;
13480+ if (ox + 8 > frame_w || oy + 8 > frame_h)
13481+ && (enable_primary
13482+ || enable_secondary
13483+ || cdef.uv_pri_strength[sidx] != 0
13484+ || cdef.uv_sec_strength[sidx] != 0)
13485+ {
13486+ CDEF_STRADDLE_UNITS.with(|c| c.set(c.get() + 1));
13487+ }
12850 if enable_primary || enable_secondary {13488 if enable_primary || enable_secondary {
12851 cdef_filter_block(13489 cdef_filter_block(
12852 sample_y,13490 sample_y,
@@ -12926,13 +13564,30 @@ fn apply_loop_restoration(
12926 deblocked_v: &PlaneBuf,13564 deblocked_v: &PlaneBuf,
12927 lr: &LoopRestorationParams,13565 lr: &LoopRestorationParams,
12928 grid: &crate::restoration::RestorationGrid,13566 grid: &crate::restoration::RestorationGrid,
13567+ // lane-golomb r8: this frame header's own (cropped) luma size. Loop
13568+ // restoration is the ONE post-decode filter that does NOT run over the
13569+ // mi-rounded plane: libaom's `av1_loop_restoration_filter_frame` sizes
13570+ // every plane with `av1_get_upsampled_plane_size` -- `plane_w =
13571+ // ROUND_POWER_OF_TWO(cm->superres_upscaled_width, ss_x)`, `plane_h =
13572+ // ROUND_POWER_OF_TWO(cm->height, ss_y)` (`av1/common/restoration.c:47`)
13573+ // -- and asserts it equals the buffer's CROP width
13574+ // (`restoration.c:1106`), then `av1_extend_frame(..., plane_w, plane_h,
13575+ // ...)` (`restoration.c:1109`) replicates the right/bottom border from
13576+ // that cropped edge before any unit is filtered. Deblock and CDEF DO
13577+ // walk the mi grid, which is why passing `true_width`/`true_height`
13578+ // here went unnoticed until a frame whose size is not a multiple of 8
13579+ // (68 -> mi-rounded 72): the LR taps at the last four real columns then
13580+ // read this decoder's own decoded samples at columns 68..71 where
13581+ // libaom reads column 67 replicated -- +-1 over the straddling band
13582+ // (class av1-truesize-lane: true frame size vs mi-rounded).
13583+ (frame_w, frame_h): (usize, usize),
12929 ) {13584 ) {
12930 y.data = crate::restoration::apply_loop_restoration_plane(13585 y.data = crate::restoration::apply_loop_restoration_plane(
12931 &y.data,13586 &y.data,
12932 &deblocked_y.data,13587 &deblocked_y.data,
12933 y.width,13588 y.width,
12934- y.true_width,13589+ frame_w,
12935- y.true_height,13590+ frame_h,
12936 0,13591 0,
12937 lr.frame_restoration_type[0],13592 lr.frame_restoration_type[0],
12938 lr.loop_restoration_size[0],13593 lr.loop_restoration_size[0],
@@ -12943,8 +13598,8 @@ fn apply_loop_restoration(
12943 &u.data,13598 &u.data,
12944 &deblocked_u.data,13599 &deblocked_u.data,
12945 u.width,13600 u.width,
12946- u.true_width,13601+ frame_w.div_ceil(2),
12947- u.true_height,13602+ frame_h.div_ceil(2),
12948 1,13603 1,
12949 lr.frame_restoration_type[1],13604 lr.frame_restoration_type[1],
12950 lr.loop_restoration_size[1],13605 lr.loop_restoration_size[1],
@@ -12955,8 +13610,8 @@ fn apply_loop_restoration(
12955 &v.data,13610 &v.data,
12956 &deblocked_v.data,13611 &deblocked_v.data,
12957 v.width,13612 v.width,
12958- v.true_width,13613+ frame_w.div_ceil(2),
12959- v.true_height,13614+ frame_h.div_ceil(2),
12960 1,13615 1,
12961 lr.frame_restoration_type[2],13616 lr.frame_restoration_type[2],
12962 lr.loop_restoration_size[2],13617 lr.loop_restoration_size[2],
@@ -13518,12 +14173,16 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
13518 // the first block of that row.14173 // the first block of that row.
13519 match (has_cols, has_rows) {14174 match (has_cols, has_rows) {
13520 (true, false) => {14175 (true, false) => {
14176+ trace_edge((sb_r * SB_MI) as usize, (sb_c * SB_MI) as usize, 12, ctx, dec.debug_state().0 as u32);
13521 let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE));14177 let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE));
14178+ bump_edge32(4 + b.min(1) as usize);
13522 bump_edge_part(b.min(1) as usize);14179 bump_edge_part(b.min(1) as usize);
13523 if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ }14180 if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ }
13524 }14181 }
13525 (false, true) => {14182 (false, true) => {
14183+ trace_edge((sb_r * SB_MI) as usize, (sb_c * SB_MI) as usize, 12, ctx, dec.debug_state().0 as u32);
13526 let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE));14184 let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE));
14185+ bump_edge32(4 + b.min(1) as usize);
13527 bump_edge_part(b.min(1) as usize);14186 bump_edge_part(b.min(1) as usize);
13528 if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT }14187 if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT }
13529 }14188 }
@@ -13588,18 +14247,22 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
13588 // superblock level above).14247 // superblock level above).
13589 match (has_cols32, has_rows32) {14248 match (has_cols32, has_rows32) {
13590 (true, false) => {14249 (true, false) => {
14250+ trace_edge((r32 * BLOCK_MI) as usize, (c32 * BLOCK_MI) as usize, 9, ctx32, dec.debug_state().0 as u32);
13591 let b = dec.symbol_fixed(&gather(14251 let b = dec.symbol_fixed(&gather(
13592 &cdfs.partition_w32[ctx32],14252 &cdfs.partition_w32[ctx32],
13593 VERT_ALIKE,14253 VERT_ALIKE,
13594 ));14254 ));
14255+ bump_edge32(b.min(1) as usize);
13595 bump_edge_part(2 + b.min(1) as usize);14256 bump_edge_part(2 + b.min(1) as usize);
13596 if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ }14257 if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ }
13597 }14258 }
13598 (false, true) => {14259 (false, true) => {
14260+ trace_edge((r32 * BLOCK_MI) as usize, (c32 * BLOCK_MI) as usize, 9, ctx32, dec.debug_state().0 as u32);
13599 let b = dec.symbol_fixed(&gather(14261 let b = dec.symbol_fixed(&gather(
13600 &cdfs.partition_w32[ctx32],14262 &cdfs.partition_w32[ctx32],
13601 HORZ_ALIKE,14263 HORZ_ALIKE,
13602 ));14264 ));
14265+ bump_edge32(b.min(1) as usize);
13603 bump_edge_part(2 + b.min(1) as usize);14266 bump_edge_part(2 + b.min(1) as usize);
13604 if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT }14267 if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT }
13605 }14268 }
@@ -14074,6 +14737,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
14074 // This path can only walk the four SPLIT14737 // This path can only walk the four SPLIT
14075 // leaves, so a 0 refuses by name instead14738 // leaves, so a 0 refuses by name instead
14076 // of desyncing.14739 // of desyncing.
14740+ trace_edge(sr * SUB_MI as usize, sc * SUB_MI as usize, 6, ctx16, dec.debug_state().0 as u32);
14077 let edge_split = if has_cols16 {14741 let edge_split = if has_cols16 {
14078 dec.symbol_fixed(&gather(14742 dec.symbol_fixed(&gather(
14079 &cdfs.partition_w16[ctx16],14743 &cdfs.partition_w16[ctx16],
@@ -14154,10 +14818,11 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
14154 }14818 }
14155 }14819 }
14156 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);14820 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);
14821+ let pre8 = dec.debug_state().0;
14157 let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]);14822 let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]);
14158 if std::env::var_os("EC_AV1_TRACE").is_some() {14823 if std::env::var_os("EC_AV1_TRACE").is_some() {
14159 eprintln!(14824 eprintln!(
14160- "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8}"14825+ "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8} pre_rng={pre8}"
14161 );14826 );
14162 }14827 }
14163 let leaf_mode = if part8 == PARTITION_NONE {14828 let leaf_mode = if part8 == PARTITION_NONE {
@@ -14255,6 +14920,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
14255 tx_select,14920 tx_select,
14256 reduced_tx_set,14921 reduced_tx_set,
14257 )?;14922 )?;
14923+ if !has_rows32 {
14924+ bump_edge32(2);
14925+ }
14258 // lane-hgkf r1: at the frame edge only the first half of the strip is14926 // lane-hgkf r1: at the frame edge only the first half of the strip is
14259 // coded (libaom `decode_partition` guards the second half with the same14927 // coded (libaom `decode_partition` guards the second half with the same
14260 // test that made this partition non-square).14928 // test that made this partition non-square).
@@ -14296,6 +14964,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
14296 tx_select,14964 tx_select,
14297 reduced_tx_set,14965 reduced_tx_set,
14298 )?;14966 )?;
14967+ if !has_cols32 {
14968+ bump_edge32(3);
14969+ }
14299 // lane-hgkf r1: at the frame edge only the first half of the strip is14970 // lane-hgkf r1: at the frame edge only the first half of the strip is
14300 // coded (libaom `decode_partition` guards the second half with the same14971 // coded (libaom `decode_partition` guards the second half with the same
14301 // test that made this partition non-square).14972 // test that made this partition non-square).
@@ -14686,6 +15357,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
14686 tx_select,15357 tx_select,
14687 reduced_tx_set,15358 reduced_tx_set,
14688 )?;15359 )?;
15360+ if !has_rows {
15361+ bump_edge32(6);
15362+ }
14689 // lane-golomb r1: at the frame edge only the first half of the15363 // lane-golomb r1: at the frame edge only the first half of the
14690 // strip is coded (libaom `decode_partition` guards the second15364 // strip is coded (libaom `decode_partition` guards the second
14691 // with the same has_rows test that made this partition non-square).15365 // with the same has_rows test that made this partition non-square).
@@ -14727,6 +15401,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
14727 tx_select,15401 tx_select,
14728 reduced_tx_set,15402 reduced_tx_set,
14729 )?;15403 )?;
15404+ if !has_cols {
15405+ bump_edge32(7);
15406+ }
14730 // lane-golomb r1: at the frame edge only the first half of the15407 // lane-golomb r1: at the frame edge only the first half of the
14731 // strip is coded (libaom `decode_partition` guards the second15408 // strip is coded (libaom `decode_partition` guards the second
14732 // with the same has_cols test that made this partition non-square).15409 // with the same has_cols test that made this partition non-square).
@@ -14946,10 +15623,20 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
14946 // dump above these bisect WHICH filter stage introduced a mismatch.15623 // dump above these bisect WHICH filter stage introduced a mismatch.
14947 dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v);15624 dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v);
14948 dump_stage16("EC_AV1_POSTDEBLOCK_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);15625 dump_stage16("EC_AV1_POSTDEBLOCK_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
14949- apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);15626+ apply_cdef(
15627+ &mut y,
15628+ &mut u,
15629+ &mut v,
15630+ cdef,
15631+ &neighbours,
15632+ (frame_width as usize, frame_height as usize),
15633+ );
14950 dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v);15634 dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v);
14951 dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);15635 dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
14952- apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid);15636+ apply_loop_restoration(
15637+ &mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid,
15638+ (frame_width as usize, frame_height as usize),
15639+ );
14953 15640
14954 let (fw, fh) = (frame_width as usize, frame_height as usize);15641 let (fw, fh) = (frame_width as usize, frame_height as usize);
14955 if fw == width && fh == height {15642 if fw == width && fh == height {
@@ -15341,10 +16028,9 @@ fn read_inter_plane(
15341 // `tx_type` -- `av1_get_tx_type` (libaom `blockd.h`): an inter block's16028 // `tx_type` -- `av1_get_tx_type` (libaom `blockd.h`): an inter block's
15342 // chroma plane never codes its own `tx_type` symbol, but (unlike an16029 // chroma plane never codes its own `tx_type` symbol, but (unlike an
15343 // intra block, which falls back to `Intra_Mode_To_Tx_Type`) it inherits16030 // intra block, which falls back to `Intra_Mode_To_Tx_Type`) it inherits
15344- // the colocated luma transform's coded type verbatim, clamped back to16031+ // the colocated luma transform's coded type, narrowed to the extended
15345- // `DCT_DCT` at the chroma tx sizes the spec forces DCT-only16032+ // set the CHROMA size selects ([`reduce_inherited_chroma_tx_type`]).
15346- // (`av1_get_ext_tx_set_type`: `tx_size_sqr_up >= TX_32X32`, i.e. this16033+ // `None` for the luma call itself
15347- // function's own `side >= 32`). `None` for the luma call itself
15348 // (`plane_idx == 0`), where the `TxbSet`'s own symbol (or the true16034 // (`plane_idx == 0`), where the `TxbSet`'s own symbol (or the true
15349 // `DCT_DCT` default at 32-point+) already resolves it without help.16035 // `DCT_DCT` default at 32-point+) already resolves it without help.
15350 inherited_luma_tx_type: Option<TxType>,16036 inherited_luma_tx_type: Option<TxType>,
@@ -15362,8 +16048,8 @@ fn read_inter_plane(
15362 };16048 };
15363 let mut coding = cdfs.txb(set, tx_mode);16049 let mut coding = cdfs.txb(set, tx_mode);
15364 let default_tx_type = match inherited_luma_tx_type {16050 let default_tx_type = match inherited_luma_tx_type {
15365- Some(t) if side < 32 => t,16051+ Some(t) => reduce_inherited_chroma_tx_type(t, side, side),
15366- _ => TxType::DctDct,16052+ None => TxType::DctDct,
15367 };16053 };
15368 let (grid, tx_type) = read_coeffs(16054 let (grid, tx_type) = read_coeffs(
15369 dec,16055 dec,
@@ -15756,22 +16442,33 @@ fn obmc_mask(len: usize) -> &'static [u8] {
15756 /// A bordering block's own resolved interp filter kernel, `(h, v)` --16442 /// A bordering block's own resolved interp filter kernel, `(h, v)` --
15757 /// mirrors [`resolve_interp_filter`]'s own return order from its stored16443 /// mirrors [`resolve_interp_filter`]'s own return order from its stored
15758 /// `[u8; 2]` (`Neighbours::above_filter`/`left_filter`, `[sym0, sym1]` =16444 /// `[u8; 2]` (`Neighbours::above_filter`/`left_filter`, `[sym0, sym1]` =
15759-/// `[v_sym, h_sym]`). Never calls `from_switchable_symbol` on the `[3, 3]`16445+/// `[v_sym, h_sym]`). The `[3, 3]` sentinel is only ever stored for an intra
15760-/// sentinel: that value is only ever stored for an intra neighbour (already16446+/// neighbour (excluded by [`overlappable_above`]/[`overlappable_left`]'s
15761-/// excluded by [`overlappable_above`]/[`overlappable_left`]'s `is_inter`16447+/// `is_inter` gate) or when `interp_fixed` is `Some` for the whole frame
15762-/// gate) or when `interp_fixed` is `Some` for the whole frame, handled here16448+/// (handled here first) -- so a sentinel reaching the kernel lookup means the
15763-/// first.16449+/// stream desynced upstream, and this refuses instead of panicking.
15764 fn neighbour_filter(16450 fn neighbour_filter(
15765 interp_fixed: Option<mc::InterpFilterKind>,16451 interp_fixed: Option<mc::InterpFilterKind>,
15766 sym: [u8; 2],16452 sym: [u8; 2],
15767-) -> (mc::InterpFilterKind, mc::InterpFilterKind) {16453+) -> Result<(mc::InterpFilterKind, mc::InterpFilterKind)> {
15768 if let Some(kind) = interp_fixed {16454 if let Some(kind) = interp_fixed {
15769- return (kind, kind);16455+ return Ok((kind, kind));
16456+ }
16457+ // lane-golomb r9: this used to hand the sentinel straight to
16458+ // `from_switchable_symbol`, which PANICS on any value above 2 -- a crash
16459+ // on stream data (measured on a real 192x68 cq40 aomenc stream, where an
16460+ // inter leaf below 8x8 desyncs upstream and leaves an unrecorded filter
16461+ // behind). A decoder must refuse such a stream by name, never abort the
16462+ // process; the desync that produces the sentinel belongs to lane-intersub8.
16463+ if sym[0] > 2 || sym[1] > 2 {
16464+ return Err(unsupported(
16465+ "an OBMC neighbour whose switchable interp filter was never recorded",
16466+ ));
15770 }16467 }
15771- (16468+ Ok((
15772 mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize),16469 mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize),
15773 mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize),16470 mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize),
15774- )16471+ ))
15775 }16472 }
15776 16473
15777 /// One neighbour's own re-prediction over a `w`x`h` region, MC'd fresh16474 /// One neighbour's own re-prediction over a `w`x`h` region, MC'd fresh
@@ -16049,7 +16746,7 @@ fn obmc_blend(
16049 let (h_kind, v_kind) = neighbour_filter(16746 let (h_kind, v_kind) = neighbour_filter(
16050 interp_fixed,16747 interp_fixed,
16051 neighbours.above_filter[mi_col + off4],16748 neighbours.above_filter[mi_col + off4],
16052- );16749+ )?;
16053 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;16750 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
16054 let nb_scale = mc::scale_factor(ny.width, frame_width);16751 let nb_scale = mc::scale_factor(ny.width, frame_width);
16055 let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4);16752 let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4);
@@ -16068,7 +16765,7 @@ fn obmc_blend(
16068 let (h_kind, v_kind) = neighbour_filter(16765 let (h_kind, v_kind) = neighbour_filter(
16069 interp_fixed,16766 interp_fixed,
16070 neighbours.left_filter[mi_row + off4],16767 neighbours.left_filter[mi_row + off4],
16071- );16768+ )?;
16072 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;16769 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
16073 let nb_scale = mc::scale_factor(ny.width, frame_width);16770 let nb_scale = mc::scale_factor(ny.width, frame_width);
16074 let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4);16771 let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4);
@@ -16648,7 +17345,7 @@ fn decode_inter_block(
16648 // 5.11.17), `Some` only when this block's var-tx tree resolved to more17345 // 5.11.17), `Some` only when this block's var-tx tree resolved to more
16649 // than one luma transform -- read back by the residual loop, the17346 // than one luma transform -- read back by the residual loop, the
16650 // coefficient-context write-back and the loop-filter grid fill below.17347 // coefficient-context write-back and the loop-filter grid fill below.
16651- let mut vartx_leaves: Option<Vec<(usize, usize, usize)>> = None;17348+ let mut vartx_leaves: Option<Vec<(usize, usize, usize, usize)>> = None;
16652 let at_mi = at;17349 let at_mi = at;
16653 if is_inter {17350 if is_inter {
16654 let above_nbr = has_above.then(|| NeighbourRef {17351 let above_nbr = has_above.then(|| NeighbourRef {
@@ -17503,37 +18200,68 @@ fn decode_inter_block(
17503 // own slice of the block's motion-compensated predictor.18200 // own slice of the block's motion-compensated predictor.
17504 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);18201 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);
17505 let mut first_tx_type = TxType::DctDct;18202 let mut first_tx_type = TxType::DctDct;
17506- for (idx, &(row, col, tx_px)) in leaves.iter().enumerate() {18203+ for (idx, &(row, col, tw, th)) in leaves.iter().enumerate() {
17507 let tu_mi = (at_mi.0 + row, at_mi.1 + col);18204 let tu_mi = (at_mi.0 + row, at_mi.1 + col);
17508 let (tu_px, tu_py) = (px + col * MI, py + row * MI);18205 let (tu_px, tu_py) = (px + col * MI, py + row * MI);
17509- let mut tu_pred = Vec::with_capacity(tx_px * tx_px);18206+ let (tu_grid, tu_tx_type) = if tw == th {
17510- for rr in 0..tx_px {18207+ let tx_px = tw;
17511- let start = (row * MI + rr) * side + col * MI;18208+ let mut tu_pred = Vec::with_capacity(tx_px * tx_px);
17512- tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);18209+ for rr in 0..tx_px {
17513- }18210+ let start = (row * MI + rr) * side + col * MI;
17514- let scan = default_scan(tx_px);18211+ tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);
17515- let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);18212+ }
17516- let (tu_grid, tu_tx_type) = read_inter_plane(18213+ let scan = default_scan(tx_px);
17517- dec,18214+ let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);
17518- cdfs,18215+ read_inter_plane(
17519- inter_txbset_for(tx_px, reduced),18216+ dec,
17520- &scan,18217+ cdfs,
17521- 0,18218+ inter_txbset_for(tx_px, reduced),
17522- neighbours.around_mi(tu_mi, tx_px)[0],18219+ &scan,
17523- mode_for_tx,18220+ 0,
17524- y,18221+ neighbours.around_mi(tu_mi, tx_px)[0],
17525- tu_px,18222+ mode_for_tx,
17526- tu_py,18223+ y,
17527- tx_px,18224+ tu_px,
17528- base_q_idx,18225+ tu_py,
17529- &tu_pred,18226+ tx_px,
17530- None,18227+ base_q_idx,
17531- Some(tu_skip_ctx),18228+ &tu_pred,
17532- )?;18229+ None,
18230+ Some(tu_skip_ctx),
18231+ )?
18232+ } else {
18233+ // lane-r14 r3: a 1:4 strip's `sub_tx_size_map`
18234+ // sub-transform is RECTANGULAR (TX_64X16 ->
18235+ // TX_32X16, TX_16X64 -> TX_16X32), so this leaf is
18236+ // read with the rect coefficient machinery, at its
18237+ // own `txb_skip_ctx`/neighbour spans -- the unit is
18238+ // smaller than its block, so `get_txb_ctx_general`'s
18239+ // neighbour table applies, not the lone-TU 0.
18240+ vartx_rect_leaf_hit(tw, th);
18241+ let tu_skip_ctx =
18242+ neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI);
18243+ let start = row * MI * side + col * MI;
18244+ read_inter_plane_rect(
18245+ dec,
18246+ cdfs,
18247+ rect_inter_luma_set(tw, th),
18248+ (tw, th),
18249+ side,
18250+ 0,
18251+ neighbours.around_mi_rect(tu_mi, tw, th)[0],
18252+ mode_for_tx,
18253+ y,
18254+ tu_px,
18255+ tu_py,
18256+ &pred_y[start..],
18257+ None,
18258+ Some(tu_skip_ctx),
18259+ )?
18260+ };
17533 if idx == 0 {18261 if idx == 0 {
17534 first_tx_type = tu_tx_type;18262 first_tx_type = tu_tx_type;
17535 }18263 }
17536- neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid);18264+ neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);
17537 }18265 }
17538 // `av1_get_tx_type`'s chroma lookup scales the chroma18266 // `av1_get_tx_type`'s chroma lookup scales the chroma
17539 // position back to luma, so an inter block's chroma18267 // position back to luma, so an inter block's chroma
@@ -17557,6 +18285,7 @@ fn decode_inter_block(
17557 py,18285 py,
17558 &pred_y,18286 &pred_y,
17559 None,18287 None,
18288+ None,
17560 )?;18289 )?;
17561 luma_tx_type = tx_type;18290 luma_tx_type = tx_type;
17562 luma_grid = embed_rect_grid(&grid, write_w, write_h, side);18291 luma_grid = embed_rect_grid(&grid, write_w, write_h, side);
@@ -17600,6 +18329,7 @@ fn decode_inter_block(
17600 cpy,18329 cpy,
17601 &pred_u,18330 &pred_u,
17602 Some(luma_tx_type),18331 Some(luma_tx_type),
18332+ None,
17603 )?18333 )?
17604 .0,18334 .0,
17605 uw,18335 uw,
@@ -17621,6 +18351,7 @@ fn decode_inter_block(
17621 cpy,18351 cpy,
17622 &pred_v,18352 &pred_v,
17623 Some(luma_tx_type),18353 Some(luma_tx_type),
18354+ None,
17624 )?18355 )?
17625 .0,18356 .0,
17626 uw,18357 uw,
@@ -18481,37 +19212,68 @@ fn decode_inter_block(
18481 // own slice of the block's motion-compensated predictor.19212 // own slice of the block's motion-compensated predictor.
18482 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);19213 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);
18483 let mut first_tx_type = TxType::DctDct;19214 let mut first_tx_type = TxType::DctDct;
18484- for (idx, &(row, col, tx_px)) in leaves.iter().enumerate() {19215+ for (idx, &(row, col, tw, th)) in leaves.iter().enumerate() {
18485 let tu_mi = (at_mi.0 + row, at_mi.1 + col);19216 let tu_mi = (at_mi.0 + row, at_mi.1 + col);
18486 let (tu_px, tu_py) = (px + col * MI, py + row * MI);19217 let (tu_px, tu_py) = (px + col * MI, py + row * MI);
18487- let mut tu_pred = Vec::with_capacity(tx_px * tx_px);19218+ let (tu_grid, tu_tx_type) = if tw == th {
18488- for rr in 0..tx_px {19219+ let tx_px = tw;
18489- let start = (row * MI + rr) * side + col * MI;19220+ let mut tu_pred = Vec::with_capacity(tx_px * tx_px);
18490- tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);19221+ for rr in 0..tx_px {
18491- }19222+ let start = (row * MI + rr) * side + col * MI;
18492- let scan = default_scan(tx_px);19223+ tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);
18493- let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);19224+ }
18494- let (tu_grid, tu_tx_type) = read_inter_plane(19225+ let scan = default_scan(tx_px);
18495- dec,19226+ let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);
18496- cdfs,19227+ read_inter_plane(
18497- inter_txbset_for(tx_px, reduced),19228+ dec,
18498- &scan,19229+ cdfs,
18499- 0,19230+ inter_txbset_for(tx_px, reduced),
18500- neighbours.around_mi(tu_mi, tx_px)[0],19231+ &scan,
18501- mode_for_tx,19232+ 0,
18502- y,19233+ neighbours.around_mi(tu_mi, tx_px)[0],
18503- tu_px,19234+ mode_for_tx,
18504- tu_py,19235+ y,
18505- tx_px,19236+ tu_px,
18506- base_q_idx,19237+ tu_py,
18507- &tu_pred,19238+ tx_px,
18508- None,19239+ base_q_idx,
18509- Some(tu_skip_ctx),19240+ &tu_pred,
18510- )?;19241+ None,
19242+ Some(tu_skip_ctx),
19243+ )?
19244+ } else {
19245+ // lane-r14 r3: a 1:4 strip's `sub_tx_size_map`
19246+ // sub-transform is RECTANGULAR (TX_64X16 ->
19247+ // TX_32X16, TX_16X64 -> TX_16X32), so this leaf is
19248+ // read with the rect coefficient machinery, at its
19249+ // own `txb_skip_ctx`/neighbour spans -- the unit is
19250+ // smaller than its block, so `get_txb_ctx_general`'s
19251+ // neighbour table applies, not the lone-TU 0.
19252+ vartx_rect_leaf_hit(tw, th);
19253+ let tu_skip_ctx =
19254+ neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI);
19255+ let start = row * MI * side + col * MI;
19256+ read_inter_plane_rect(
19257+ dec,
19258+ cdfs,
19259+ rect_inter_luma_set(tw, th),
19260+ (tw, th),
19261+ side,
19262+ 0,
19263+ neighbours.around_mi_rect(tu_mi, tw, th)[0],
19264+ mode_for_tx,
19265+ y,
19266+ tu_px,
19267+ tu_py,
19268+ &pred_y[start..],
19269+ None,
19270+ Some(tu_skip_ctx),
19271+ )?
19272+ };
18511 if idx == 0 {19273 if idx == 0 {
18512 first_tx_type = tu_tx_type;19274 first_tx_type = tu_tx_type;
18513 }19275 }
18514- neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid);19276+ neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);
18515 }19277 }
18516 // `av1_get_tx_type`'s chroma lookup scales the chroma19278 // `av1_get_tx_type`'s chroma lookup scales the chroma
18517 // position back to luma, so an inter block's chroma19279 // position back to luma, so an inter block's chroma
@@ -18535,6 +19297,7 @@ fn decode_inter_block(
18535 py,19297 py,
18536 &pred_y,19298 &pred_y,
18537 None,19299 None,
19300+ None,
18538 )?;19301 )?;
18539 luma_tx_type = tx_type;19302 luma_tx_type = tx_type;
18540 luma_grid = embed_rect_grid(&grid, write_w, write_h, side);19303 luma_grid = embed_rect_grid(&grid, write_w, write_h, side);
@@ -18578,6 +19341,7 @@ fn decode_inter_block(
18578 cpy,19341 cpy,
18579 &pred_u,19342 &pred_u,
18580 Some(luma_tx_type),19343 Some(luma_tx_type),
19344+ None,
18581 )?19345 )?
18582 .0,19346 .0,
18583 uw,19347 uw,
@@ -18599,6 +19363,7 @@ fn decode_inter_block(
18599 cpy,19363 cpy,
18600 &pred_v,19364 &pred_v,
18601 Some(luma_tx_type),19365 Some(luma_tx_type),
19366+ None,
18602 )?19367 )?
18603 .0,19368 .0,
18604 uw,19369 uw,
@@ -18882,7 +19647,7 @@ fn decode_inter_block(
18882 let split_luma = vartx_leaves.is_some();19647 let split_luma = vartx_leaves.is_some();
18883 if let Some(leaves) = vartx_leaves.clone() {19648 if let Some(leaves) = vartx_leaves.clone() {
18884 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);19649 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);
18885- for &(row, col, tx_px) in &leaves {19650+ for &(row, col, tx_px, _) in &leaves {
18886 let tu_mi = (at_mi.0 + row, at_mi.1 + col);19651 let tu_mi = (at_mi.0 + row, at_mi.1 + col);
18887 let (tu_px, tu_py) = (px + col * MI, py + row * MI);19652 let (tu_px, tu_py) = (px + col * MI, py + row * MI);
18888 // A transform unit inside a block is not a block at that19653 // A transform unit inside a block is not a block at that
@@ -19121,21 +19886,21 @@ fn decode_inter_block(
19121 },19886 },
19122 );19887 );
19123 // lane-txselect: a var-tx block's deblock edges follow its own transform19888 // lane-txselect: a var-tx block's deblock edges follow its own transform
19124- // units, not the block. Chroma still reads `tx_h_grid / 2` (the block's19889+ // units, not the block -- for LUMA only (lane-golomb r6): the chroma
19125- // uv transform is not split) -- a known corner-cut of this round.19890+ // grids keep the block's own `av1_get_max_uv_txsize`, which is what
19891+ // libaom's `get_transform_size` reads for `plane != AOM_PLANE_Y`.
19126 if let Some(leaves) = &vartx_leaves {19892 if let Some(leaves) = &vartx_leaves {
19127- for &(row, col, tx_px) in leaves {19893+ for &(row, col, tw, th) in leaves {
19128- neighbours.fill_lf_grid_rect(19894+ // lane-r14's RECT leaf dims through lane-golomb r6's luma-only
19895+ // writer: fill_lf_grid_rect would recompute CHROMA tx dims from
19896+ // the leaf span, but libaom's `get_transform_size` splits only for
19897+ // AOM_PLANE_Y (merge J, ledger constraint).
19898+ neighbours.fill_lf_grid_leaf_luma(
19129 (at_mi.0 + row, at_mi.1 + col),19899 (at_mi.0 + row, at_mi.1 + col),
19130- tx_px / MI,19900+ tw / MI,
19131- tx_px / MI,19901+ th / MI,
19132- tx_px as u8,19902+ tw as u8,
19133- tx_px as u8,19903+ th as u8,
19134- if globalmv_for_lf {
19135- -ref_frame_for_lf
19136- } else {
19137- ref_frame_for_lf
19138- },
19139 );19904 );
19140 }19905 }
19141 }19906 }
@@ -19844,6 +20609,14 @@ fn decode_inter_block8(
19844 // so the 16x16 below a split block read partition ctx 020609 // so the 16x16 below a split block read partition ctx 0
19845 // instead of 1 and mis-read PARTITION_SPLIT as NONE.20610 // instead of 1 and mis-read PARTITION_SPLIT as NONE.
19846 neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);20611 neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);
20612+ // lane-cdef r1: ... and the CDEF skip band too. `apply_cdef`'s
20613+ // `is_8x8_block_skip` (libaom `cdef.c:29-38`) reads all four mi
20614+ // cells of the 8x8; this leaf wrote none of them, so a 64x64
20615+ // whose bottom-right 16x16 is an all-skip 8x8-leaf group kept
20616+ // the PREVIOUS frame's flags and got filtered where libaom's
20617+ // dlist excludes it (3 luma samples on a 192x128 inter frame).
20618+ INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1));
20619+ neighbours.fill_skip_grid(leaf_mi, 2, skip);
19847 neighbours.fill_lf_grid(20620 neighbours.fill_lf_grid(
19848 leaf_mi,20621 leaf_mi,
19849 2,20622 2,
@@ -20649,6 +21422,10 @@ fn decode_inter_block8(
20649 // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference21422 // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference
20650 // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every21423 // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every
20651 // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test).21424 // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test).
21425+ // lane-cdef r1: the fall-through twin of the compound arm's skip-band
21426+ // write above -- `skip` is one flag for the whole 8x8 leaf (read at
21427+ // `decode.rs`'s `skip_ctx` site), `split8` only splits its transform.
21428+ neighbours.fill_skip_grid(leaf_mi, 2, skip);
20652 neighbours.fill_lf_grid(21429 neighbours.fill_lf_grid(
20653 leaf_mi,21430 leaf_mi,
20654 2,21431 2,
@@ -20850,7 +21627,18 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
20850 // true size. Height must still match: AV1 superres never scales height21627 // true size. Height must still match: AV1 superres never scales height
20851 // (r8's derivation, `mc.rs`'s own doc), and nothing in this decode path21628 // (r8's derivation, `mc.rs`'s own doc), and nothing in this decode path
20852 // has a vertical scaling pass.21629 // has a vertical scaling pass.
20853- if reference.height != true_height {21630+ // lane-golomb r8: the comparison is against the header's own frame
21631+ // height, NOT the mi-rounded `true_height`. libaom compares references
21632+ // on the CROPPED dimensions -- `av1_setup_scale_factors_for_frame(&sf,
21633+ // ref->y_crop_width, ref->y_crop_height, cm->width, cm->height)`
21634+ // (`av1/common/reconinter.c`), and a reference is "scaled" only when
21635+ // those differ (`av1_is_scaled`). A decoded `Picture` is cropped to
21636+ // `fw`/`fh`, so for any height that is not a multiple of 8 (68 ->
21637+ // mi_rows 18 -> `true_height` 72) this test compared 68 against 72 and
21638+ // refused every same-size reference (class av1-truesize-lane: true
21639+ // frame size vs mi-rounded). Height must still MATCH: AV1 superres
21640+ // never scales height, and no path here has a vertical scaling pass.
21641+ if reference.height != frame_height as usize {
20854 return Err(unsupported(21642 return Err(unsupported(
20855 "a reference picture whose height does not match this frame's own true size",21643 "a reference picture whose height does not match this frame's own true size",
crates/ec-av1/src/gate_coverage.rsmodified+0 -5
@@ -175,10 +175,6 @@ const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[
175 "enable-rect-tx",175 "enable-rect-tx",
176 "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool",176 "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool",
177 ),177 ),
178- (
179- "enable-tx64",
180- "never spelled; TX_64X64 appears only where aomenc's default picks it, which is unknown per stream",
181- ),
182 ];178 ];
183 179
184 #[cfg(test)]180 #[cfg(test)]
@@ -217,7 +213,6 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ // lane-cwarp's 10-bit comp
217 // 1D tx class).213 // 1D tx class).
218 ("enable-intrabc", "hole at both depths, see the 8-bit list"),214 ("enable-intrabc", "hole at both depths, see the 8-bit list"),
219 ("enable-rect-tx", "hole at both depths, see the 8-bit list"),215 ("enable-rect-tx", "hole at both depths, see the 8-bit list"),
220- ("enable-tx64", "hole at both depths, see the 8-bit list"),
221 ];216 ];
222 217
223 /// [`DEFAULT_ON_TOOLS`] entries no 8-bit gate spells on, with the reason.218 /// [`DEFAULT_ON_TOOLS`] entries no 8-bit gate spells on, with the reason.
crates/ec-av1/src/refusal_inventory.rsmodified+10 -7
@@ -34,7 +34,7 @@ const REFUSALS: &[&str] = &[
34 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",34 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
35 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)",35 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)",
36 "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)",36 "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)",
37- "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)",37+ "an OBMC neighbour whose switchable interp filter was never recorded",
38 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",38 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
39 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",39 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
40 "a 32x32 partition type this decoder does not code (value={part32})",40 "a 32x32 partition type this decoder does not code (value={part32})",
@@ -45,10 +45,10 @@ const REFUSALS: &[&str] = &[
45 "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)",45 "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)",
46 "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)",46 "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)",
47 "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)",47 "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)",
48- "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)",
49 "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",48 "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",
50 "a block that actually uses a palette (UV) -- reconstruction is out of scope",49 "a block that actually uses a palette (UV) -- reconstruction is out of scope",
51 "a block that actually uses a palette (Y) -- reconstruction is out of scope",50 "a block that actually uses a palette (Y) -- reconstruction is out of scope",
51+ "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)",
52 "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)",52 "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)",
53 "an intrabc block under TxMode::Select (its transform size is coded by the inter var-tx partition tree, which this decoder never reads)",53 "an intrabc block under TxMode::Select (its transform size is coded by the inter var-tx partition tree, which this decoder never reads)",
54 "a bit depth of 12 (this decoder is gated at 8 and 10 only: warp/MC/wiener rounding shifts change at 12-bit and no 12-bit gate exists)",54 "a bit depth of 12 (this decoder is gated at 8 and 10 only: warp/MC/wiener rounding shifts change at 12-bit and no 12-bit gate exists)",
@@ -68,7 +68,14 @@ const REFUSALS: &[&str] = &[
68 "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units",68 "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units",
69 "an inter frame with no key frame before it",69 "an inter frame with no key frame before it",
70 "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)",70 "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)",
71- "an inter 16x16-level AB or 1:4 partition (HORZ_A/HORZ_B/VERT_A/VERT_B/HORZ_4/VERT_4; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT or SPLIT)",71+ // lane-inter16ab r1 lifted the AB half (HORZ_A/HORZ_B/VERT_A/VERT_B at
72+ // the 16x16 level of an inter frame: two 8x8 inter leaves plus one true
73+ // 16x8/8x16 inter strip, gate
74+ // `a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact`).
75+ // What is left is the 1:4 pair, whose 16x4/4x16 strips need the sub-8
76+ // inter chroma-pair path (odd-strip `is_chroma_reference`, chroma built
77+ // from BOTH strips' MVs) that no inter block writer has yet.
78+ "an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 -- four 16x4 or 4x16 inter strips; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT, SPLIT or AB)",
72 "an intra mode this decoder does not code (round 2)",79 "an intra mode this decoder does not code (round 2)",
73 // lane-intrarect r1 lifted the whole-shape refusal that stood here (the80 // lane-intrarect r1 lifted the whole-shape refusal that stood here (the
74 // inter path's intra arm now routes 2:1 strips through `decode_rect_split`);81 // inter path's intra arm now routes 2:1 strips through `decode_rect_split`);
@@ -82,10 +89,6 @@ const REFUSALS: &[&str] = &[
82 "warp prediction with a scaled reference (superres, unimplemented)",89 "warp prediction with a scaled reference (superres, unimplemented)",
83 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",90 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
84 "a motion_mode symbol for a block shape with no CDF row here",91 "a motion_mode symbol for a block shape with no CDF row here",
85- // lane-r14 r2: the whole-transform case of every 64-axis inter strip is
86- // coded; only the SPLIT of a 1:4 strip with a 64-px axis is left, whose
87- // `sub_tx_size_map` entry is rectangular (TX_64X16 -> TX_32X16).
88- "a split transform on a 1:4 inter strip with a 64-px axis",
89 ];92 ];
90 93
91 /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than94 /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than
crates/ec-av1/src/stream.rsmodified+2004 -272

Diff too large; view file

@@ -86,6 +86,18 @@ pub fn rect64_inter_tu_hits() -> usize {
86 crate::decode::rect64_inter_tu_hits()86 crate::decode::rect64_inter_tu_hits()
87 }87 }
88 88
89+/// lane-r14 r3: RECTANGULAR var-tx leaf transform units, `[32x16, 16x32]` --
90+/// the leaves `sub_tx_size_map` produces when a 1:4 strip with a 64-px axis
91+/// splits its transform (`[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32`).
92+pub fn vartx_rect_leaf_hits() -> [usize; 2] {
93+ crate::decode::vartx_rect_leaf_hits()
94+}
95+
96+/// How many rect intra strips read the `use_intrabc` symbol on the last decode.
97+pub fn rect_intrabc_reads() -> usize {
98+ crate::decode::rect_intrabc_reads()
99+}
100+
89 pub fn rect4_32_counters() -> (usize, usize, usize) {101 pub fn rect4_32_counters() -> (usize, usize, usize) {
90 (102 (
91 crate::decode::rect4_32_horz_hits(),103 crate::decode::rect4_32_horz_hits(),
@@ -2584,17 +2596,35 @@ mod tests {
2584 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg");2596 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg");
2585 }2597 }
2586 2598
2587- /// lane-hbd r5: a real `aomenc --bit-depth=10` stream, decoded through2599+ /// lane-kf900 r3: the palette colour reader at BOTH bit depths.
2588- /// this crate's own 10-bit planes (`Picture` widened to `u16` in an2600+ ///
2589- /// earlier round) and checked pixel-exact against ffmpeg's own decode of2601+ /// `read_palette_colors_y`/`_uv` (decode.rs, mirroring `decodemv.c:478`
2590- /// the identical bytes via [`ffmpeg_decode_sequence_10bit`]. Confirms2602+ /// and `:509`) size every raw literal they read by the sequence's
2591- /// (hard-asserts, not just trusts) the sequence header this stream2603+ /// `bit_depth`: the first colour is `bit_depth` bits, `min_bits` is
2592- /// actually parses to says `bit_depth == 10` before trusting any pixel2604+ /// `bit_depth - 3` (Y/U) or `bit_depth - 4` (V), `range` starts at
2593- /// match -- a stream that silently fell back to 8-bit would still2605+ /// `1 << bit_depth`, and the clamp/wrap bound is `(1 << bit_depth) - 1`.
2594- /// "match" trivially.2606+ /// Ours hardcoded 8, so every 10-bit palette block read TWO BITS TOO FEW
2607+ /// per transmitted colour and silently decoded the rest of the tile from
2608+ /// the wrong bit position.
2609+ ///
2610+ /// It was silent because raw literals are EQUIPROBABLE: at the ranges
2611+ /// this content reaches an equiprobable read maps the msac range onto
2612+ /// itself (62728 -> 31364 -> renormalised 62728), so a cross-decoder
2613+ /// RANGE ladder stays bit-identical straight through the miscount and
2614+ /// only the decoded VALUE moves. Pinned on a 256x192 10-bit
2615+ /// `--cq-level=59` stream whose first block is a 32x16 palette: aomdec's
2616+ /// `EC_PAL` ladder and ours agreed on every range and disagreed on the
2617+ /// very first colour index (0 vs 1); after the fix all 1024 `EC_PAL`
2618+ /// lines of that block match aomdec line for line.
2619+ ///
2620+ /// The recipe is the 8-bit `..._with_palette_y_...` gate's, with the
2621+ /// depth as the only variable, so a failure here is the depth and
2622+ /// nothing else. HARD-asserts [`decode::palette_hits`] moved on each arm
2623+ /// (a stream with no real palette block would prove nothing) and
2624+ /// compares all three planes against ffmpeg's decode of the same bytes.
2595 #[test]2625 #[test]
2596- fn a_real_aomenc_10bit_stream_decodes_pixel_exact() {2626+ fn a_real_aomenc_palette_stream_decodes_pixel_exact_at_8_and_10_bit() {
2597- const NAME: &str = "a_real_aomenc_10bit_stream_decodes_pixel_exact";2627+ const NAME: &str = "a_real_aomenc_palette_stream_decodes_pixel_exact_at_8_and_10_bit";
2598 if !have_ffmpeg() {2628 if !have_ffmpeg() {
2599 eprintln!("SKIP {NAME}: no ffmpeg");2629 eprintln!("SKIP {NAME}: no ffmpeg");
2600 return;2630 return;
@@ -2604,105 +2634,139 @@ mod tests {
2604 return;2634 return;
2605 }2635 }
2606 let (width, height) = (64usize, 64usize);2636 let (width, height) = (64usize, 64usize);
2607- let y4m = Command::new("ffmpeg")2637+ for depth in [8usize, 10] {
2608- .args([2638+ let pix_fmt = if depth == 10 { "yuv420p10le" } else { "yuv420p" };
2609- "-v",2639+ let render = || {
2610- "error",2640+ Command::new("ffmpeg")
2611- "-f",2641+ .args([
2612- "lavfi",2642+ "-v", "error",
2613- "-i",2643+ "-f", "lavfi",
2614- &gradients_source(42, width, height, "duration=0.04:rate=25"),2644+ "-i", "smptebars=size=64x64:rate=25",
2615- "-pix_fmt",2645+ "-vf", "hue=s=0",
2616- "yuv420p10le",2646+ "-pix_fmt", pix_fmt,
2617- "-strict",2647+ "-strict", "-1",
2618- "-1",2648+ "-t", "0.04",
2619- "-t",2649+ "-f", "yuv4mpegpipe",
2620- "0.04",2650+ "-",
2621- "-f",2651+ ])
2622- "yuv4mpegpipe",2652+ .stdin(Stdio::null())
2623- "-",2653+ .stdout(Stdio::piped())
2624- ])2654+ .stderr(Stdio::piped())
2625- .stdin(Stdio::null())2655+ .output()
2626- .stdout(Stdio::piped())2656+ .expect("ffmpeg failed to run")
2627- .stderr(Stdio::piped())2657+ .stdout
2628- .output()2658+ };
2629- .expect("ffmpeg failed to run");2659+ let y4m_a = render();
2630- assert!(2660+ let y4m_b = render();
2631- y4m.status.success(),2661+ assert_eq!(
2632- "ffmpeg failed to render the 10-bit fixture: {}",2662+ y4m_a, y4m_b,
2633- String::from_utf8_lossy(&y4m.stderr)2663+ "{NAME}: smptebars must render byte-identical across two runs at {depth}-bit"
2634- );2664+ );
2635- let mut child = Command::new(aomenc_path())2665+ let y4m = y4m_a;
2636- .args([2666+ let depth_arg = format!("--bit-depth={depth}");
2637- "--codec=av1",2667+ let input_depth_arg = format!("--input-bit-depth={depth}");
2638- "--passes=1",2668+ let mut child = Command::new(aomenc_path())
2639- "--end-usage=q",2669+ .args([
2640- "--cq-level=30",2670+ "--codec=av1",
2641- "--cpu-used=0",2671+ "--passes=1",
2642- "--threads=1",2672+ "--end-usage=q",
2643- "--row-mt=0",2673+ "--cq-level=30",
2644- "--sb-size=64",2674+ "--cpu-used=0",
2645- "--input-bit-depth=10",2675+ "--threads=1",
2646- "--bit-depth=10",2676+ "--row-mt=0",
2647- "--limit=1",2677+ "--sb-size=64",
2648- "--obu",2678+ "--tune-content=screen",
2649- "-o",2679+ "--enable-palette=1",
2650- "-",2680+ "--enable-intrabc=0",
2651- "-",2681+ "--enable-rect-partitions=0",
2652- ])2682+ "--enable-ab-partitions=0",
2653- .stdin(Stdio::piped())2683+ "--enable-1to4-partitions=0",
2654- .stdout(Stdio::piped())2684+ "--min-partition-size=32",
2655- .stderr(Stdio::piped())2685+ "--max-partition-size=32",
2656- .spawn()2686+ "--enable-filter-intra=0",
2657- .expect("aomenc failed to start");2687+ "--enable-smooth-intra=0",
2658- child2688+ "--enable-paeth-intra=0",
2659- .stdin2689+ "--enable-directional-intra=0",
2660- .take()2690+ "--enable-angle-delta=0",
2661- .expect("aomenc stdin")2691+ "--enable-cfl-intra=0",
2662- .write_all(&y4m.stdout)2692+ "--enable-cdef=0",
2663- .expect("writing y4m to aomenc");2693+ "--enable-restoration=0",
2664- let out = child.wait_with_output().expect("aomenc failed to run");2694+ "--enable-tx-size-search=0",
2665- assert!(2695+ "--loopfilter-control=0",
2666- out.status.success(),2696+ "--limit=1",
2667- "aomenc refused the 10-bit fixture: {}",2697+ ])
2668- String::from_utf8_lossy(&out.stderr)2698+ // Per-arm overrides go AFTER the base recipe: aomenc keeps the
2669- );2699+ // LAST occurrence of a repeated flag.
2670- let stream = out.stdout;2700+ .args([&depth_arg, &input_depth_arg])
2671- // Confirm the sequence header this stream actually parses to before2701+ .args(["--obu", "-o", "-", "-"])
2672- // trusting any pixel comparison below.2702+ .stdin(Stdio::piped())
2673- let mut probe = Av1Parser::new();2703+ .stdout(Stdio::piped())
2674- let mut pos = 0usize;2704+ .stderr(Stdio::piped())
2675- while pos < stream.len() && probe.sequence_header().is_none() {2705+ .spawn()
2676- let obu = probe.parse_obu(&stream[pos..]).unwrap();2706+ .expect("aomenc failed to start");
2677- pos += obu.total_size;2707+ child
2708+ .stdin
2709+ .take()
2710+ .expect("aomenc stdin")
2711+ .write_all(&y4m)
2712+ .expect("writing y4m to aomenc");
2713+ let out = child.wait_with_output().expect("aomenc failed to run");
2714+ assert!(
2715+ out.status.success(),
2716+ "{NAME}: aomenc refused the {depth}-bit fixture: {}",
2717+ String::from_utf8_lossy(&out.stderr)
2718+ );
2719+ let stream = out.stdout;
2720+ let before = decode::palette_hits();
2721+ let frames = match decode_stream(&stream) {
2722+ Ok(frames) => frames,
2723+ Err(e) => panic!("{NAME}: decode_stream refused the {depth}-bit stream: {e}"),
2724+ };
2725+ assert!(
2726+ decode::palette_hits() > before,
2727+ "{NAME}: no real palette block at {depth}-bit -- gate is vacuous"
2728+ );
2729+ let ffmpeg_frames = if depth == 10 {
2730+ ffmpeg_decode_sequence_10bit(&stream, width, height, 1)
2731+ } else {
2732+ ffmpeg_decode_sequence(&stream, width, height, 1)
2733+ };
2734+ assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma at {depth}-bit");
2735+ assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U at {depth}-bit");
2736+ assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V at {depth}-bit");
2678 }2737 }
2679- let seq = probe
2680- .sequence_header()
2681- .expect("stream has a sequence header OBU");
2682- assert_eq!(
2683- seq.color_config.bit_depth, 10,
2684- "{NAME}: aomenc did not actually write a 10-bit sequence header"
2685- );
2686- let frames = match decode_stream(&stream) {
2687- Ok(frames) => frames,
2688- Err(e) => panic!("{NAME}: decode_stream refused a real 10-bit stream: {e}"),
2689- };
2690- let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, 1);
2691- assert_eq!(frames[0].y, ffmpeg_frames[0].y, "luma vs ffmpeg (10-bit)");
2692- assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (10-bit)");
2693- assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (10-bit)");
2694 }2738 }
2695 2739
2696- /// The 10-bit *inter* counterpart of the gate above: a real `aomenc`2740+ /// lane-kf900 r5, the gate for the rect-strip `use_intrabc` read.
2697- /// `yuv420p10le` sequence whose non-key frames are plain forward2741+ ///
2698- /// single-`LAST_FRAME` P frames (same `--lag-in-frames=02742+ /// `av1_allow_intrabc` is a FRAME-level test (`decodemv.c:892`,
2699- /// --auto-alt-ref=0 --error-resilient=1` shape as the 8-bit inter gate),2743+ /// `read_intra_frame_mode_info`): on an intra frame whose header set
2700- /// decoded pixel-exact on every frame. 10-bit intra was proven exact by2744+ /// `allow_intrabc`, EVERY intra block reads a `use_intrabc` symbol right
2701- /// lane-hbd; inter reconstruction at `bit_depth == 10` was never gated.2745+ /// after `skip`/`cdef`/`delta_q` and before `mbmi->mode`. There is no
2746+ /// block-shape term, so rect strips read it exactly like square leaves --
2747+ /// `read_intra_mode_rect` never did, and the arithmetic decoder desynced
2748+ /// at the FIRST symbol of the first rect block of every
2749+ /// `--tune-content=screen` key frame (measured: `testsrc2` 256x192 cq59
2750+ /// 8-bit decoded "OK" with all 49152 luma samples wrong).
2751+ ///
2752+ /// Arm 0 is that recipe at cq50 without palette: its rect strips really do
2753+ /// use intrabc, which this decoder cannot reconstruct, so it must stop on
2754+ /// the NAMED refusal instead of emitting a wrong frame -- and it must have
2755+ /// read the symbol to get there.
2756+ /// Arm 1 is the same recipe without palette and without tx-size search --
2757+ /// it decodes the whole frame, reading the symbol dozens of times.
2758+ /// Arm 2 is a screen-tools key frame whose header does NOT set
2759+ /// `allow_intrabc` (cq63): it stays pixel-exact, proving the new read is
2760+ /// not taken when libaom does not write it.
2761+ ///
2762+ /// PIXEL RESIDUE (open, lane-kf900 r5): arm 1's frame is entropy-exact
2763+ /// against the instrumented aomdec for 429 mode-ladder elements and then
2764+ /// diverges inside the DV read of a SQUARE intrabc block at mi(32,44), so
2765+ /// its pixels are not compared here. That is a separate defect in
2766+ /// `read_intrabc_dv`, not in the read this gate covers.
2702 #[test]2767 #[test]
2703- fn a_real_aomenc_10bit_inter_sequence_decodes_pixel_exact() {2768+ fn a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips() {
2704- const NAME: &str = "a_real_aomenc_10bit_inter_sequence_decodes_pixel_exact";2769+ const NAME: &str = "a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips";
2705- let _gate_lock = lock_gate_counters();
2706 if !have_ffmpeg() {2770 if !have_ffmpeg() {
2707 eprintln!("SKIP {NAME}: no ffmpeg");2771 eprintln!("SKIP {NAME}: no ffmpeg");
2708 return;2772 return;
@@ -2711,79 +2775,562 @@ mod tests {
2711 eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());2775 eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
2712 return;2776 return;
2713 }2777 }
2714- let (width, height, frame_count) = (128usize, 64usize, 16usize);2778+ let (width, height) = (256usize, 192usize);
2715- let y4m = Command::new("ffmpeg")2779+ // (arm, source, per-arm overrides AFTER the base recipe, expect_refusal,
2716- .args([2780+ // must_read_use_intrabc)
2717- "-v",2781+ let arms: [(&str, &str, &[&str], bool, bool); 3] = [
2718- "error",2782+ (
2719- "-f",2783+ "testsrc2-screen-nopalette-cq50",
2720- "lavfi",2784+ "testsrc2=s=256x192:r=25",
2721- "-i",2785+ &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=0"],
2722- &gradients_source(42, width, height, "duration=0.64:rate=25"),2786+ true,
2723- "-pix_fmt",2787+ true,
2724- "yuv420p10le",2788+ ),
2725- "-strict",2789+ (
2726- "-1",2790+ "smptebars-screen-nopalette-cq45",
2727- "-t",2791+ "smptebars=size=256x192:rate=25",
2728- "0.64",2792+ &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=0"],
2729- "-f",2793+ false,
2730- "yuv4mpegpipe",2794+ true,
2731- "-",2795+ ),
2732- ])2796+ (
2733- .stdin(Stdio::null())2797+ "testsrc2-screen-nopalette-cq63",
2734- .stdout(Stdio::piped())2798+ "testsrc2=s=256x192:r=25",
2735- .stderr(Stdio::piped())2799+ &["--cq-level=63", "--enable-palette=0", "--enable-tx-size-search=1"],
2736- .output()2800+ false,
2737- .expect("ffmpeg failed to run");2801+ false,
2738- assert!(2802+ ),
2739- y4m.status.success(),2803+ ];
2740- "ffmpeg failed to render the 10-bit fixture: {}",2804+ let (mut reads_total, mut refused, mut frames_compared) = (0usize, 0u32, 0usize);
2741- String::from_utf8_lossy(&y4m.stderr)2805+ for (arm, src, extra, expect_refusal, must_read) in &arms {
2742- );2806+ let render = || {
2743- let mut child = Command::new(aomenc_path())2807+ let out = Command::new("ffmpeg")
2744- .args([2808+ .args([
2745- // lane-defon r1: explicit on-value (aomenc keeps the FIRST2809+ "-v", "error", "-f", "lavfi", "-i", *src, "-t", "0.2", "-pix_fmt",
2746- // occurrence, so overrides go before the base list).2810+ "yuv420p", "-strict", "-1", "-f", "yuv4mpegpipe", "-",
2747- "--loopfilter-control=1",2811+ ])
2748- "--codec=av1",2812+ .stdin(Stdio::null())
2749- "--passes=1",2813+ .stdout(Stdio::piped())
2750- "--end-usage=q",2814+ .stderr(Stdio::piped())
2751- "--cq-level=15",2815+ .output()
2752- "--cpu-used=0",2816+ .expect("ffmpeg failed to run");
2753- "--threads=1",2817+ assert!(out.status.success(), "{NAME}: ffmpeg failed for {arm}");
2754- "--row-mt=0",2818+ out.stdout
2755- "--sb-size=64",2819+ };
2756- "--input-bit-depth=10",2820+ let y4m_a = render();
2757- "--bit-depth=10",2821+ let y4m_b = render();
2758- "--lag-in-frames=0",2822+ assert_eq!(y4m_a, y4m_b, "{NAME}: {arm} must render byte-identical across two runs");
2759- "--auto-alt-ref=0",2823+ let y4m = y4m_a;
2760- "--kf-max-dist=1000",2824+ let mut child = Command::new(aomenc_path())
2761- "--error-resilient=1",2825+ .args([
2762- "--aq-mode=0",2826+ "--codec=av1",
2763- "--deltaq-mode=0",2827+ "--bit-depth=8",
2764- "--enable-cdef=0",2828+ "--input-bit-depth=8",
2765- "--enable-rect-partitions=0",2829+ "--passes=1",
2766- "--enable-ab-partitions=0",2830+ "--end-usage=q",
2767- "--enable-1to4-partitions=0",2831+ "--cpu-used=0",
2768- "--enable-filter-intra=0",2832+ "--lag-in-frames=0",
2769- "--enable-smooth-intra=0",2833+ "--kf-max-dist=1",
2770- "--enable-paeth-intra=0",2834+ "--limit=1",
2771- "--enable-directional-intra=0",2835+ "--threads=1",
2772- "--enable-angle-delta=0",2836+ "--tile-columns=0",
2773- "--enable-tx-size-search=0",2837+ "--enable-rect-partitions=1",
2774- "--enable-cdef=1",2838+ "--enable-1to4-partitions=1",
2775- "--enable-restoration=1",2839+ "--min-partition-size=8",
2776- "--min-partition-size=16",2840+ "--max-partition-size=32",
2777- "--max-partition-size=32",2841+ "--sb-size=64",
2778- "--enable-palette=0",2842+ // `allow_screen_content_tools` (and with it the frame
2779- "--enable-intrabc=0",2843+ // header's `allow_intrabc` bit) comes from here.
2780- "--enable-cfl-intra=0",2844+ "--tune-content=screen",
2781- "--enable-ref-frame-mvs=0",2845+ ])
2782- "--obu",2846+ // aomenc keeps the LAST occurrence of a repeated flag.
2783- "-o",2847+ .args(*extra)
2784- "-",2848+ .args(["--obu", "-o", "-", "-"])
2785- "-",2849+ .stdin(Stdio::piped())
2786- ])2850+ .stdout(Stdio::piped())
2851+ .stderr(Stdio::piped())
2852+ .spawn()
2853+ .expect("aomenc failed to start");
2854+ child
2855+ .stdin
2856+ .take()
2857+ .expect("aomenc stdin")
2858+ .write_all(&y4m)
2859+ .or_else(|e| match e.kind() {
2860+ std::io::ErrorKind::BrokenPipe => Ok(()),
2861+ _ => Err(e),
2862+ })
2863+ .expect("writing y4m to aomenc");
2864+ let out = child.wait_with_output().expect("aomenc failed to run");
2865+ assert!(
2866+ out.status.success(),
2867+ "{NAME}: aomenc refused {arm}: {}",
2868+ String::from_utf8_lossy(&out.stderr)
2869+ );
2870+ let stream = out.stdout;
2871+ decode::reset_rect_intrabc_reads();
2872+ let decoded = decode_stream(&stream);
2873+ let reads = decode::rect_intrabc_reads();
2874+ reads_total += reads;
2875+ if *must_read {
2876+ assert!(
2877+ reads > 0,
2878+ "{NAME}: {arm} read no use_intrabc symbol on a rect strip -- the \
2879+ arm no longer exercises the fix (allow_intrabc not set?)"
2880+ );
2881+ }
2882+ match decoded {
2883+ Ok(frames) => {
2884+ assert!(
2885+ !*expect_refusal,
2886+ "{NAME}: {arm} decoded a frame whose rect strips use intrabc -- \
2887+ reconstruction is not ported, it must refuse by name"
2888+ );
2889+ assert!(!frames.is_empty(), "{NAME}: {arm} decoded no frame");
2890+ if *must_read {
2891+ // Arm 1: entropy coverage only (see PIXEL RESIDUE above).
2892+ eprintln!("{NAME}: {arm} decoded {} frame(s), {reads} rect use_intrabc reads", frames.len());
2893+ continue;
2894+ }
2895+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frames.len());
2896+ assert_eq!(frames.len(), ffmpeg_frames.len(), "{NAME}: {arm} frame count");
2897+ for (i, (ours, theirs)) in frames.iter().zip(ffmpeg_frames.iter()).enumerate() {
2898+ assert_eq!(ours.y, theirs.y, "{NAME}: {arm} luma, frame {i}");
2899+ assert_eq!(ours.u, theirs.u, "{NAME}: {arm} U, frame {i}");
2900+ assert_eq!(ours.v, theirs.v, "{NAME}: {arm} V, frame {i}");
2901+ frames_compared += 1;
2902+ }
2903+ }
2904+ Err(e) => {
2905+ let msg = e.to_string();
2906+ assert!(msg.contains("unsupported"), "{NAME}: {arm} decode failed: {e}");
2907+ assert!(
2908+ *expect_refusal,
2909+ "{NAME}: {arm} was expected to decode, it refused: {e}"
2910+ );
2911+ assert!(
2912+ msg.contains("intra block copy") || msg.contains("intrabc"),
2913+ "{NAME}: {arm} refused for an unrelated reason: {e}"
2914+ );
2915+ eprintln!("{NAME}: {arm} REFUSED (expected): {e}");
2916+ refused += 1;
2917+ }
2918+ }
2919+ }
2920+ eprintln!(
2921+ "{NAME}: {reads_total} rect-strip use_intrabc symbol(s) read, \
2922+ {refused} refused by name, {frames_compared} frames compared pixel-exact"
2923+ );
2924+ assert!(reads_total > 0, "{NAME}: gate is vacuous -- no arm read the symbol");
2925+ assert_eq!(refused, 1, "{NAME}: expected exactly one named intrabc refusal");
2926+ assert!(frames_compared > 0, "{NAME}: no frame was compared pixel-exact");
2927+ }
2928+
2929+ /// lane-kf900 r4, the gate for the two lifted palette refusals ("a 1:4
2930+ /// rect strip that actually uses a palette (reconstruction is not ported
2931+ /// at this shape)" and "a palette block on a HORZ/VERT intra strip below
2932+ /// 16x16 (reconstruction not ported)"): real `aomenc` streams that put a
2933+ /// palette on a RECT strip, decoded whole-frame pixel-exact against
2934+ /// ffmpeg's own decode of the identical bytes, at 8 AND 10 bit.
2935+ ///
2936+ /// Arm 0 is the stream lane-kf900 r3 pinned and stopped on -- `testsrc2`
2937+ /// 256x192, `--cq-level=59 --cpu-used=0 --min-partition-size=8
2938+ /// --enable-rect-partitions=1 --enable-tx-size-search=1`, md5
2939+ /// `e5f033d8fe34e4418d8cca3ac9d2b595` at 10 bit. Arms 1-2 force the shape
2940+ /// on screen-like content with `--tune-content=screen --enable-palette=1
2941+ /// --enable-1to4-partitions=1`.
2942+ ///
2943+ /// An attempt whose decode never hit a rect-strip palette block proves
2944+ /// nothing about the lift, so it is counted OUT OF SCOPE rather than
2945+ /// silently passing -- but a mismatch on one is still a failure
2946+ /// (`out_of_scope_mismatch == 0`), and at least one attempt must fire the
2947+ /// counter or the gate is vacuous.
2948+ #[test]
2949+ fn a_real_aomenc_rect_strip_palette_decodes_pixel_exact() {
2950+ const NAME: &str = "a_real_aomenc_rect_strip_palette_decodes_pixel_exact";
2951+ if !have_ffmpeg() {
2952+ eprintln!("SKIP {NAME}: no ffmpeg");
2953+ return;
2954+ }
2955+ if !have_aomenc() {
2956+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
2957+ return;
2958+ }
2959+ let (width, height) = (256usize, 192usize);
2960+ let screen: &[&str] = &[
2961+ "--tune-content=screen",
2962+ "--enable-palette=1",
2963+ "--enable-1to4-partitions=1",
2964+ "--min-partition-size=8",
2965+ ];
2966+ let arms: [(&str, String, &[&str]); 3] = [
2967+ ("testsrc2-pinned", "testsrc2=s=256x192:r=25".to_string(), &[]),
2968+ ("testsrc2-screen", "testsrc2=s=256x192:r=25".to_string(), screen),
2969+ ("smptebars-screen", "smptebars=size=256x192:rate=25".to_string(), screen),
2970+ ];
2971+ let (mut fired_arms, mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32, 0u32);
2972+ let mut refused = 0u32;
2973+ let mut fired_at_depth = [0u32; 2];
2974+ let mut frames_compared = 0usize;
2975+ for (arm, src, extra) in &arms {
2976+ for depth in [8usize, 10] {
2977+ let pix_fmt = if depth == 10 { "yuv420p10le" } else { "yuv420p" };
2978+ let render = || {
2979+ let out = Command::new("ffmpeg")
2980+ .args([
2981+ "-v", "error", "-f", "lavfi", "-i", src.as_str(), "-t", "0.2",
2982+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
2983+ ])
2984+ .stdin(Stdio::null())
2985+ .stdout(Stdio::piped())
2986+ .stderr(Stdio::piped())
2987+ .output()
2988+ .expect("ffmpeg failed to run");
2989+ assert!(out.status.success(), "{NAME}: ffmpeg failed for {arm}");
2990+ out.stdout
2991+ };
2992+ let y4m_a = render();
2993+ let y4m_b = render();
2994+ assert_eq!(
2995+ y4m_a, y4m_b,
2996+ "{NAME}: {arm} must render byte-identical across two runs at {depth}-bit"
2997+ );
2998+ let y4m = y4m_a;
2999+ let depth_arg = format!("--bit-depth={depth}");
3000+ let in_depth_arg = format!("--input-bit-depth={depth}");
3001+ let mut child = Command::new(aomenc_path())
3002+ .args(["--codec=av1"])
3003+ .args([&depth_arg, &in_depth_arg])
3004+ .args([
3005+ "--passes=1",
3006+ "--end-usage=q",
3007+ "--cq-level=59",
3008+ "--cpu-used=0",
3009+ "--lag-in-frames=0",
3010+ "--kf-max-dist=1",
3011+ "--limit=1",
3012+ "--threads=1",
3013+ "--tile-columns=0",
3014+ "--enable-tx-size-search=1",
3015+ "--min-partition-size=8",
3016+ "--enable-rect-partitions=1",
3017+ ])
3018+ // Per-arm overrides go AFTER the base recipe: aomenc keeps
3019+ // the LAST occurrence of a repeated flag.
3020+ .args(*extra)
3021+ // The 8-bit twin of the pinned recipe picks a 128-root
3022+ // HORZ partition, which this decoder still refuses by name
3023+ // ("a 128x128 superblock HORZ/VERT or AB partition") --
3024+ // an open refusal of another lane, unrelated to palette.
3025+ // Pinning the superblock to 64 keeps the 8-bit arm on the
3026+ // shape this gate is about; the 10-bit arms are the
3027+ // untouched pinned recipe.
3028+ .args(if depth == 8 { &["--sb-size=64"][..] } else { &[][..] })
3029+ .args(["--obu", "-o", "-", "-"])
3030+ .stdin(Stdio::piped())
3031+ .stdout(Stdio::piped())
3032+ .stderr(Stdio::piped())
3033+ .spawn()
3034+ .expect("aomenc failed to start");
3035+ child
3036+ .stdin
3037+ .take()
3038+ .expect("aomenc stdin")
3039+ .write_all(&y4m)
3040+ .or_else(|e| match e.kind() {
3041+ // aomenc rejecting the input closes the pipe before we
3042+ // finish writing; its own stderr below is the report.
3043+ std::io::ErrorKind::BrokenPipe => Ok(()),
3044+ _ => Err(e),
3045+ })
3046+ .expect("writing y4m to aomenc");
3047+ let out = child.wait_with_output().expect("aomenc failed to run");
3048+ assert!(
3049+ out.status.success(),
3050+ "{NAME}: aomenc refused {arm} at {depth}-bit: {}",
3051+ String::from_utf8_lossy(&out.stderr)
3052+ );
3053+ let stream = out.stdout;
3054+ let before = decode::rect4_palette_hits();
3055+ let frames = match decode_stream(&stream) {
3056+ Ok(frames) => frames,
3057+ // A NAMED refusal is another lane's open shape (here: a
3058+ // palette on an 8x8 SQUARE leaf, still out of scope), never
3059+ // a pass -- the attempt is counted out of scope and the
3060+ // per-depth firing assert below keeps the gate honest.
3061+ Err(e) if e.to_string().contains("unsupported") => {
3062+ eprintln!("{NAME}: {arm} {depth}-bit REFUSED: {e}");
3063+ refused += 1;
3064+ continue;
3065+ }
3066+ Err(e) => panic!("{NAME}: decode failed on {arm} at {depth}-bit: {e}"),
3067+ };
3068+ let fired = decode::rect4_palette_hits() - before;
3069+ let ffmpeg_frames = if depth == 10 {
3070+ ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len())
3071+ } else {
3072+ ffmpeg_decode_sequence(&stream, width, height, frames.len())
3073+ };
3074+ assert_eq!(
3075+ frames.len(),
3076+ ffmpeg_frames.len(),
3077+ "{NAME}: {arm} at {depth}-bit -- frame count"
3078+ );
3079+ assert!(!frames.is_empty(), "{NAME}: {arm} at {depth}-bit decoded no frame");
3080+ // EVERY decode-order frame, all three planes.
3081+ let mut exact = true;
3082+ for (i, (ours, theirs)) in frames.iter().zip(ffmpeg_frames.iter()).enumerate() {
3083+ if ours.y != theirs.y || ours.u != theirs.u || ours.v != theirs.v {
3084+ exact = false;
3085+ eprintln!("{NAME}: {arm} {depth}-bit frame {i} differs");
3086+ }
3087+ frames_compared += 1;
3088+ }
3089+ if fired > 0 {
3090+ fired_arms += 1;
3091+ fired_at_depth[usize::from(depth == 10)] += 1;
3092+ assert!(
3093+ exact,
3094+ "{NAME}: {arm} at {depth}-bit has {fired} rect-strip palette block(s) \
3095+ and does NOT decode pixel-exact"
3096+ );
3097+ } else {
3098+ out_of_scope += 1;
3099+ if !exact {
3100+ out_of_scope_mismatch += 1;
3101+ }
3102+ }
3103+ }
3104+ }
3105+ eprintln!(
3106+ "{NAME}: {fired_arms} attempt(s) with a rect-strip palette block, \
3107+ {out_of_scope} out of scope ({out_of_scope_mismatch} mismatched), \
3108+ {refused} refused, {frames_compared} frames compared, \
3109+ fired 8-bit={} 10-bit={}",
3110+ fired_at_depth[0], fired_at_depth[1]
3111+ );
3112+ // MEASURED 2026-09-02, every 8-bit attempt of these recipes: aomenc
3113+ // puts its palettes on SQUARE blocks at 8 bit and every 8-bit stream
3114+ // that reaches a rect strip with one lands on a palette shape still
3115+ // out of scope (8x8 square leaf, or a 64x32/32x64 superblock strip
3116+ // with a real transform). So the 8-bit arms here prove the DECODE
3117+ // path, not the lift -- `fired_at_depth[0] == 0` is a known, reported
3118+ // coverage gap and not a silent pass: the counter is printed.
3119+ assert!(
3120+ fired_at_depth[1] > 0,
3121+ "{NAME}: no attempt put a palette on a rect strip \
3122+ (8-bit={}, 10-bit={}) -- gate is vacuous",
3123+ fired_at_depth[0],
3124+ fired_at_depth[1]
3125+ );
3126+ assert!(fired_arms > 0, "{NAME}: gate is vacuous");
3127+ assert_eq!(
3128+ out_of_scope_mismatch, 0,
3129+ "{NAME}: {out_of_scope_mismatch} attempt(s) without a rect-strip palette block \
3130+ still mismatched -- an unrelated defect, not a SKIP"
3131+ );
3132+ }
3133+
3134+ /// lane-hbd r5: a real `aomenc --bit-depth=10` stream, decoded through
3135+ /// this crate's own 10-bit planes (`Picture` widened to `u16` in an
3136+ /// earlier round) and checked pixel-exact against ffmpeg's own decode of
3137+ /// the identical bytes via [`ffmpeg_decode_sequence_10bit`]. Confirms
3138+ /// (hard-asserts, not just trusts) the sequence header this stream
3139+ /// actually parses to says `bit_depth == 10` before trusting any pixel
3140+ /// match -- a stream that silently fell back to 8-bit would still
3141+ /// "match" trivially.
3142+ #[test]
3143+ fn a_real_aomenc_10bit_stream_decodes_pixel_exact() {
3144+ const NAME: &str = "a_real_aomenc_10bit_stream_decodes_pixel_exact";
3145+ if !have_ffmpeg() {
3146+ eprintln!("SKIP {NAME}: no ffmpeg");
3147+ return;
3148+ }
3149+ if !have_aomenc() {
3150+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
3151+ return;
3152+ }
3153+ let (width, height) = (64usize, 64usize);
3154+ let y4m = Command::new("ffmpeg")
3155+ .args([
3156+ "-v",
3157+ "error",
3158+ "-f",
3159+ "lavfi",
3160+ "-i",
3161+ &gradients_source(42, width, height, "duration=0.04:rate=25"),
3162+ "-pix_fmt",
3163+ "yuv420p10le",
3164+ "-strict",
3165+ "-1",
3166+ "-t",
3167+ "0.04",
3168+ "-f",
3169+ "yuv4mpegpipe",
3170+ "-",
3171+ ])
3172+ .stdin(Stdio::null())
3173+ .stdout(Stdio::piped())
3174+ .stderr(Stdio::piped())
3175+ .output()
3176+ .expect("ffmpeg failed to run");
3177+ assert!(
3178+ y4m.status.success(),
3179+ "ffmpeg failed to render the 10-bit fixture: {}",
3180+ String::from_utf8_lossy(&y4m.stderr)
3181+ );
3182+ let mut child = Command::new(aomenc_path())
3183+ .args([
3184+ "--codec=av1",
3185+ "--passes=1",
3186+ "--end-usage=q",
3187+ "--cq-level=30",
3188+ "--cpu-used=0",
3189+ "--threads=1",
3190+ "--row-mt=0",
3191+ "--sb-size=64",
3192+ "--input-bit-depth=10",
3193+ "--bit-depth=10",
3194+ "--limit=1",
3195+ "--obu",
3196+ "-o",
3197+ "-",
3198+ "-",
3199+ ])
3200+ .stdin(Stdio::piped())
3201+ .stdout(Stdio::piped())
3202+ .stderr(Stdio::piped())
3203+ .spawn()
3204+ .expect("aomenc failed to start");
3205+ child
3206+ .stdin
3207+ .take()
3208+ .expect("aomenc stdin")
3209+ .write_all(&y4m.stdout)
3210+ .expect("writing y4m to aomenc");
3211+ let out = child.wait_with_output().expect("aomenc failed to run");
3212+ assert!(
3213+ out.status.success(),
3214+ "aomenc refused the 10-bit fixture: {}",
3215+ String::from_utf8_lossy(&out.stderr)
3216+ );
3217+ let stream = out.stdout;
3218+ // Confirm the sequence header this stream actually parses to before
3219+ // trusting any pixel comparison below.
3220+ let mut probe = Av1Parser::new();
3221+ let mut pos = 0usize;
3222+ while pos < stream.len() && probe.sequence_header().is_none() {
3223+ let obu = probe.parse_obu(&stream[pos..]).unwrap();
3224+ pos += obu.total_size;
3225+ }
3226+ let seq = probe
3227+ .sequence_header()
3228+ .expect("stream has a sequence header OBU");
3229+ assert_eq!(
3230+ seq.color_config.bit_depth, 10,
3231+ "{NAME}: aomenc did not actually write a 10-bit sequence header"
3232+ );
3233+ let frames = match decode_stream(&stream) {
3234+ Ok(frames) => frames,
3235+ Err(e) => panic!("{NAME}: decode_stream refused a real 10-bit stream: {e}"),
3236+ };
3237+ let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, 1);
3238+ assert_eq!(frames[0].y, ffmpeg_frames[0].y, "luma vs ffmpeg (10-bit)");
3239+ assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (10-bit)");
3240+ assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (10-bit)");
3241+ }
3242+
3243+ /// The 10-bit *inter* counterpart of the gate above: a real `aomenc`
3244+ /// `yuv420p10le` sequence whose non-key frames are plain forward
3245+ /// single-`LAST_FRAME` P frames (same `--lag-in-frames=0
3246+ /// --auto-alt-ref=0 --error-resilient=1` shape as the 8-bit inter gate),
3247+ /// decoded pixel-exact on every frame. 10-bit intra was proven exact by
3248+ /// lane-hbd; inter reconstruction at `bit_depth == 10` was never gated.
3249+ #[test]
3250+ fn a_real_aomenc_10bit_inter_sequence_decodes_pixel_exact() {
3251+ const NAME: &str = "a_real_aomenc_10bit_inter_sequence_decodes_pixel_exact";
3252+ let _gate_lock = lock_gate_counters();
3253+ if !have_ffmpeg() {
3254+ eprintln!("SKIP {NAME}: no ffmpeg");
3255+ return;
3256+ }
3257+ if !have_aomenc() {
3258+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
3259+ return;
3260+ }
3261+ let (width, height, frame_count) = (128usize, 64usize, 16usize);
3262+ let y4m = Command::new("ffmpeg")
3263+ .args([
3264+ "-v",
3265+ "error",
3266+ "-f",
3267+ "lavfi",
3268+ "-i",
3269+ &gradients_source(42, width, height, "duration=0.64:rate=25"),
3270+ "-pix_fmt",
3271+ "yuv420p10le",
3272+ "-strict",
3273+ "-1",
3274+ "-t",
3275+ "0.64",
3276+ "-f",
3277+ "yuv4mpegpipe",
3278+ "-",
3279+ ])
3280+ .stdin(Stdio::null())
3281+ .stdout(Stdio::piped())
3282+ .stderr(Stdio::piped())
3283+ .output()
3284+ .expect("ffmpeg failed to run");
3285+ assert!(
3286+ y4m.status.success(),
3287+ "ffmpeg failed to render the 10-bit fixture: {}",
3288+ String::from_utf8_lossy(&y4m.stderr)
3289+ );
3290+ let mut child = Command::new(aomenc_path())
3291+ .args([
3292+ // lane-defon r1: explicit on-value (aomenc keeps the FIRST
3293+ // occurrence, so overrides go before the base list).
3294+ "--loopfilter-control=1",
3295+ "--codec=av1",
3296+ "--passes=1",
3297+ "--end-usage=q",
3298+ "--cq-level=15",
3299+ "--cpu-used=0",
3300+ "--threads=1",
3301+ "--row-mt=0",
3302+ "--sb-size=64",
3303+ "--input-bit-depth=10",
3304+ "--bit-depth=10",
3305+ "--lag-in-frames=0",
3306+ "--auto-alt-ref=0",
3307+ "--kf-max-dist=1000",
3308+ "--error-resilient=1",
3309+ "--aq-mode=0",
3310+ "--deltaq-mode=0",
3311+ "--enable-cdef=0",
3312+ "--enable-rect-partitions=0",
3313+ "--enable-ab-partitions=0",
3314+ "--enable-1to4-partitions=0",
3315+ "--enable-filter-intra=0",
3316+ "--enable-smooth-intra=0",
3317+ "--enable-paeth-intra=0",
3318+ "--enable-directional-intra=0",
3319+ "--enable-angle-delta=0",
3320+ "--enable-tx-size-search=0",
3321+ "--enable-cdef=1",
3322+ "--enable-restoration=1",
3323+ "--min-partition-size=16",
3324+ "--max-partition-size=32",
3325+ "--enable-palette=0",
3326+ "--enable-intrabc=0",
3327+ "--enable-cfl-intra=0",
3328+ "--enable-ref-frame-mvs=0",
3329+ "--obu",
3330+ "-o",
3331+ "-",
3332+ "-",
3333+ ])
2787 .stdin(Stdio::piped())3334 .stdin(Stdio::piped())
2788 .stdout(Stdio::piped())3335 .stdout(Stdio::piped())
2789 .stderr(Stdio::piped())3336 .stderr(Stdio::piped())
@@ -3084,6 +3631,98 @@ mod tests {
3084 eprintln!("{NAME}: {skipped_cfl} skipped sub-8x8 CfL chroma blocks, frame pixel-exact");3631 eprintln!("{NAME}: {skipped_cfl} skipped sub-8x8 CfL chroma blocks, frame pixel-exact");
3085 }3632 }
3086 3633
3634+ /// lane-kf900 r2: the film's key frame at -ss 900, one frame
3635+ /// (`crates/ec-av1/fixtures/reelb_kf900.obu`, 484640 bytes, sha256
3636+ /// `a273ae99328388be14a1ff8fa1c5a6d391a9948159eaef120e1b50e02015eb83`,
3637+ /// extracted twice from independent
3638+ /// `ffmpeg -ss 900 -t 2 -i <2160p AV1 HDR10 mkv> -c:v copy -f obu` runs and
3639+ /// truncated to the first frame; both extracts hashed identically).
3640+ ///
3641+ /// This is the ONLY stream that reaches the r1 defect: a SKIPPED 8x8 intra
3642+ /// leaf whose `tx_depth` symbol resolved to `TX_4X4` still publishes 4 --
3643+ /// not its 8-pixel block side -- to the next block's `get_tx_size_context`
3644+ /// (`set_txfm_ctxs(mbmi->tx_size, bw, bh, skip_txfm && is_inter_block(...))`,
3645+ /// `decodemv.c`; the skip term is 0 for intra). It fires 15 times here and
3646+ /// zero times across 108 measured aomenc recipes, so the counter is
3647+ /// asserted against the film rather than against a synthesised stream.
3648+ ///
3649+ /// LUMA only. U/V still differ (open residue, lane-kf900 r2: 221 U and
3650+ /// 47912 V samples, max |d| 23/2, first at chroma (195, 640) -- chroma
3651+ /// RESIDUAL, the prediction there is bit-exact against aomdec's
3652+ /// `EC_PREDOUT`), so this gate pins what is proven and no more.
3653+ #[test]
3654+ fn a_10bit_key_frame_with_skipped_8x8_intra_leaves_that_split_their_transform_decodes_luma_exact()
3655+ {
3656+ const NAME: &str = "a_10bit_key_frame_with_skipped_8x8_intra_leaves_that_split_their_transform_decodes_luma_exact";
3657+ if !have_ffmpeg() {
3658+ eprintln!("SKIP {NAME}: no ffmpeg");
3659+ return;
3660+ }
3661+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/reelb_kf900.obu");
3662+ let stream = std::fs::read(&path)
3663+ .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
3664+ let (width, height) = (3840usize, 1608usize);
3665+ crate::decode::reset_skip_split_tx_hits();
3666+ let frames = match decode_stream(&stream) {
3667+ Ok(frames) => frames,
3668+ Err(e) => panic!("{NAME}: decode_stream refused: {e}"),
3669+ };
3670+ assert_eq!(frames.len(), 1, "{NAME}: one key frame");
3671+ assert_eq!((frames[0].width, frames[0].height), (width, height));
3672+ assert!(
3673+ crate::decode::skip_split_tx_hits() >= 15,
3674+ "{NAME}: skip_split_tx_hits() == {} -- the stream that carries the tx-context \
3675+ defect stopped carrying it, so this gate proves nothing",
3676+ crate::decode::skip_split_tx_hits()
3677+ );
3678+ let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, 1);
3679+ assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg");
3680+ }
3681+
3682+ /// lane-kf1200 r3: the same film's `-ss 600` key frame (3840x1608, one
3683+ /// 8-px partial bottom superblock row), pinned because no aomenc recipe
3684+ /// reaches its shape -- a SKIPPED 8x8 intra leaf whose `tx_depth` resolved
3685+ /// to TX_4X4. (80 recipes swept this round: 4 frame shapes x 2 sources x
3686+ /// cq 32..63 x cpu-used 0/3 x 8/10-bit, all with
3687+ /// `--enable-tx-size-search=1 --enable-filter-intra=1`; every one came
3688+ /// back with `skip_split_tx_hits == 0`, `lanes/kf1200-r3.report.md`.)
3689+ /// An intra block reads `tx_depth` whether or not it is skipped, so the
3690+ /// leaf must record its resolved 4 -- not its 8x8 side -- in the txfm
3691+ /// context; recording 8 gave the NEXT block's `tx_depth` symbol the wrong
3692+ /// `tx_size_cdf` row (ctx 2 where libaom reads 1) and desynced the
3693+ /// entropy stream at mi (400,46). HARD-asserts `skip_split_tx_hits` moved.
3694+ #[test]
3695+ fn the_reelb_ss600_key_frame_skipped_split_tx_decodes_pixel_exact() {
3696+ const NAME: &str = "the_reelb_ss600_key_frame_skipped_split_tx_decodes_pixel_exact";
3697+ if !have_ffmpeg() {
3698+ eprintln!("SKIP {NAME}: no ffmpeg");
3699+ return;
3700+ }
3701+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
3702+ .join("fixtures/reelb_ss600_key_frame.obu");
3703+ let stream = std::fs::read(&path)
3704+ .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
3705+ let (width, height) = (3840usize, 1608usize);
3706+ crate::decode::reset_skip_split_tx_hits();
3707+ let frames = match decode_stream(&stream) {
3708+ Ok(frames) => frames,
3709+ Err(e) => panic!("{NAME}: decode_stream refused: {e}"),
3710+ };
3711+ let skipped_split_tx = crate::decode::skip_split_tx_hits();
3712+ assert!(
3713+ skipped_split_tx > 0,
3714+ "{NAME}: zero skipped 8x8 leaves with a split transform -- the fixture no longer \
3715+ exercises the arm this test exists for"
3716+ );
3717+ assert_eq!(frames.len(), 1, "{NAME}: one key frame");
3718+ assert_eq!((frames[0].width, frames[0].height), (width, height));
3719+ let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, 1);
3720+ assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg");
3721+ assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg");
3722+ assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg");
3723+ eprintln!("{NAME}: {skipped_split_tx} skipped 8x8 TX_4X4 leaves, frame pixel-exact");
3724+ }
3725+
3087 /// lane-hbd10 r1: a real `aomenc --bit-depth=10 --superres-mode=13726 /// lane-hbd10 r1: a real `aomenc --bit-depth=10 --superres-mode=1
3088 /// --superres-denominator=12` key frame, decoded pixel-exact against3727 /// --superres-denominator=12` key frame, decoded pixel-exact against
3089 /// ffmpeg's own 10-bit decode. Proves `superres::upscale_row`'s3728 /// ffmpeg's own 10-bit decode. Proves `superres::upscale_row`'s
@@ -6963,25 +7602,230 @@ mod tests {
6963 );7602 );
6964 }7603 }
6965 7604
6966- /// lane-inter4 r1: the SUPERBLOCK-level inter `PARTITION_HORZ`/7605+ /// lane-inter4 r1: the SUPERBLOCK-level inter `PARTITION_HORZ`/
6967- /// `PARTITION_VERT` pair -- two 64x32 / 32x64 inter strips, the arm the7606+ /// `PARTITION_VERT` pair -- two 64x32 / 32x64 inter strips, the arm the
6968- /// inter tile path refused outright before this lane ("an inter SB-level7607+ /// inter tile path refused outright before this lane ("an inter SB-level
6969- /// partition type other than NONE or SPLIT"). `--min-partition-size=32`7608+ /// partition type other than NONE or SPLIT"). `--min-partition-size=32`
6970- /// keeps every 32x32-level rect shape (already coded, and residual-capable7609+ /// keeps every 32x32-level rect shape (already coded, and residual-capable
6971- /// only when skip) out of the picture so the counters can only be earned7610+ /// only when skip) out of the picture so the counters can only be earned
6972- /// at the superblock level; the noiseless split-motion source (one half7611+ /// at the superblock level; the noiseless split-motion source (one half
6973- /// translating, the other static, flat inside each half) is what makes7612+ /// translating, the other static, flat inside each half) is what makes
6974- /// aomenc's RD pick a superblock HORZ/VERT whose strips are `skip` --7613+ /// aomenc's RD pick a superblock HORZ/VERT whose strips are `skip` --
6975- /// the ONLY inter rect shape this decoder can complete, since rectangular7614+ /// the ONLY inter rect shape this decoder can complete, since rectangular
6976- /// inter residual coding is not ported (see `reject_residual`).7615+ /// inter residual coding is not ported (see `reject_residual`).
7616+ ///
7617+ /// Every decoded frame is compared to ffmpeg (Y, U and V); an attempt
7618+ /// that refuses by name is counted, never turned into a SKIP; and an
7619+ /// attempt that decoded without firing the arm is counted separately and
7620+ /// still required to be pixel-exact (class gate-skips-on-its-own-failure).
7621+ #[test]
7622+ fn a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact() {
7623+ const NAME: &str = "a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact";
7624+ let _gate_lock = lock_gate_counters();
7625+ if !have_ffmpeg() {
7626+ eprintln!("SKIP {NAME}: no ffmpeg");
7627+ return;
7628+ }
7629+ if !have_aomenc() {
7630+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
7631+ return;
7632+ }
7633+ let (width, height, frame_count) = (192usize, 128usize, 6usize);
7634+ // lane-inter4 r1: 8-bit ONLY, and the reason is the lane's own open
7635+ // residue, not a tolerance: across all 16 attempts x both depths, every
7636+ // 10-bit attempt that reached a superblock-level rect strip found it
7637+ // NON-skip, so it stops at "a non-skip rectangular (HORZ/VERT/HORZ_B)
7638+ // strip needs rectangular residual coding". The 10-bit twin below is
7639+ // `#[ignore]`d with that exact reason rather than deleted or weakened.
7640+ // lane-r14 r2 re-measured the 8-bit-only note above: the residual
7641+ // refusal it names is GONE (this round codes a 64-px transform axis as
7642+ // its truncated low-32 corner), and a 10-bit sweep of this exact
7643+ // recipe now reaches the arm -- 2 pixel-exact attempts, 2 64x32 and 2
7644+ // 32x64 strips, 2 of them carrying a coded 64-axis residual.
7645+ // lane-sbrect10 r1 closed the newly exposed 10-bit defect r14 r2
7646+ // parked this arm on (10-bit attempt 14, cq 61, horizontal split,
7647+ // motion step 12 -- it mismatched ffmpeg while decoding ZERO rect
7648+ // strips): a 64x64 INTRA block inside an inter frame read `uv_mode`
7649+ // off the 14-symbol CFL-allowed alphabet, which libaom's
7650+ // `is_cfl_allowed` caps at 32x32 -- same DC_PRED value, wrong
7651+ // interval narrowing, tile desynced from that block on. Both depths
7652+ // run now.
7653+ for bit_depth in [8u32, 10u32] {
7654+ let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) =
7655+ (0u32, 0u32, 0u32, 0u32);
7656+ let (mut horz_proved, mut vert_proved) = (0usize, 0usize);
7657+ let mut rect64_tus = 0usize;
7658+ for attempt in 0..16u32 {
7659+ // Two orientations (the transposed pair a one-sided gate could
7660+ // never separate) x four quantisers x two motion steps: which
7661+ // superblock the RD hands a skip-able rect strip moves with
7662+ // the quantiser, and the 10-bit arm needs a different corner
7663+ // of the grid from the 8-bit one.
7664+ let vertical_split = attempt % 2 == 1;
7665+ let cq = [58, 52, 45, 61][(attempt / 2 % 4) as usize];
7666+ let sp = 8 + (attempt / 8) * 4;
7667+ let geq = if vertical_split {
7668+ format!("if(lt(Y,64), 40+mod(floor((X+N*{sp})/32)*90,200), 200)")
7669+ } else {
7670+ format!("if(lt(X,64), 40+mod(floor((Y+N*{sp})/32)*90,200), 200)")
7671+ };
7672+ let duration = frame_count as f64 / 25.0;
7673+ let source = format!(
7674+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
7675+ geq=lum='{geq}',format=yuv420p"
7676+ );
7677+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
7678+ let y4m = Command::new("ffmpeg")
7679+ .args([
7680+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
7681+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
7682+ ])
7683+ .stdin(Stdio::null())
7684+ .stdout(Stdio::piped())
7685+ .stderr(Stdio::piped())
7686+ .output()
7687+ .expect("ffmpeg failed to run");
7688+ assert!(
7689+ y4m.status.success(),
7690+ "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}",
7691+ String::from_utf8_lossy(&y4m.stderr)
7692+ );
7693+ let cq_arg = format!("--cq-level={cq}");
7694+ let depth_arg = format!("--bit-depth={bit_depth}");
7695+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
7696+ let args: Vec<&str> = vec![
7697+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
7698+ "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
7699+ "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",
7700+ "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",
7701+ "--enable-tx-size-search=0", "--lag-in-frames=0",
7702+ // Per-arm overrides go LAST: aomenc keeps the last
7703+ // occurrence of a repeated --enable-* flag.
7704+ "--enable-rect-partitions=1", "--enable-ab-partitions=0",
7705+ "--enable-1to4-partitions=1", "--min-partition-size=32",
7706+ "--max-partition-size=64",
7707+ "--obu", "-o", "-", "-",
7708+ ];
7709+ let mut child = Command::new(aomenc_path())
7710+ .args(&args)
7711+ .stdin(Stdio::piped())
7712+ .stdout(Stdio::piped())
7713+ .stderr(Stdio::piped())
7714+ .spawn()
7715+ .expect("aomenc failed to start");
7716+ child
7717+ .stdin
7718+ .take()
7719+ .expect("aomenc stdin")
7720+ .write_all(&y4m.stdout)
7721+ .expect("writing y4m to aomenc");
7722+ let out = child.wait_with_output().expect("aomenc failed to run");
7723+ assert!(
7724+ out.status.success(),
7725+ "aomenc refused the fixture: {}",
7726+ String::from_utf8_lossy(&out.stderr)
7727+ );
7728+ let stream = out.stdout;
7729+ let before = crate::stream::inter_rect_counters();
7730+ let rect64_before = crate::stream::rect64_inter_tu_hits();
7731+ let frames = match decode_stream(&stream) {
7732+ Err(e) => {
7733+ let msg = e.to_string();
7734+ assert!(
7735+ msg.contains("unsupported"),
7736+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
7737+ attempt {attempt}): {msg}"
7738+ );
7739+ named_refusals += 1;
7740+ eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}");
7741+ continue;
7742+ }
7743+ Ok(frames) => frames,
7744+ };
7745+ let after = crate::stream::inter_rect_counters();
7746+ let (horz, vert) = (after.2 - before.2, after.3 - before.3);
7747+ let rect64 = crate::stream::rect64_inter_tu_hits() - rect64_before;
7748+ let ffmpeg_frames = if bit_depth == 10 {
7749+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
7750+ } else {
7751+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
7752+ };
7753+ assert_eq!(frames.len(), frame_count);
7754+ let mismatched = frames
7755+ .iter()
7756+ .zip(&ffmpeg_frames)
7757+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
7758+ if horz + vert == 0 {
7759+ out_of_scope += 1;
7760+ if mismatched {
7761+ oos_mismatch += 1;
7762+ eprintln!(
7763+ "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \
7764+ superblock-level inter rect strips -- another shape's defect"
7765+ );
7766+ }
7767+ continue;
7768+ }
7769+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7770+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit)");
7771+ assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit)");
7772+ assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit)");
7773+ }
7774+ horz_proved += horz;
7775+ vert_proved += vert;
7776+ rect64_tus += rect64;
7777+ matched += 1;
7778+ }
7779+ eprintln!(
7780+ "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \
7781+ attempts carrying the arm, 64x32 strips={horz_proved}, 32x64 strips={vert_proved}, \
7782+ 64-axis residual TUs={rect64_tus}, \
7783+ {out_of_scope} attempts carried none ({oos_mismatch} of them mismatched)"
7784+ );
7785+ assert_eq!(
7786+ oos_mismatch, 0,
7787+ "{NAME}: {oos_mismatch} attempt(s) with no superblock-level inter rect strip \
7788+ decoded but mismatched ffmpeg -- a defect of another shape, not a pass"
7789+ );
7790+ // lane-r14 r2: the residual half of the arm -- a strip that is not
7791+ // `skip` and codes a real 64-axis transform unit. Without this the
7792+ // gate proves only the partition symbol.
7793+ assert!(
7794+ rect64_tus > 0,
7795+ "{NAME} ({bit_depth}-bit): no superblock-level rect strip carried a coded \
7796+ 64-axis residual transform unit inside a pixel-exact attempt \
7797+ (horz={horz_proved}, vert={vert_proved}) -- the residual arm proved nothing"
7798+ );
7799+ assert!(
7800+ horz_proved + vert_proved > 0,
7801+ "{NAME} ({bit_depth}-bit): the superblock-level inter rect arm never fired \
7802+ inside a pixel-exact attempt (horz={horz_proved}, vert={vert_proved}, \
7803+ {named_refusals} refusals, {out_of_scope} out of scope) -- gate proved nothing"
7804+ );
7805+ }
7806+ }
7807+
7808+ /// lane-r14 r3: a 1:4 inter strip with a 64-px axis (64x16 / 16x64) whose
7809+ /// transform SPLITS -- the arm r2 left refused by name ("a split transform
7810+ /// on a 1:4 inter strip with a 64-px axis"). libaom's
7811+ /// `sub_tx_size_map[TX_64X16] == TX_32X16` (and `[TX_16X64] == TX_16X32`)
7812+ /// keeps the sub-transform RECTANGULAR, so the var-tx tree's leaves are
7813+ /// 32x16/16x32 units read through [`TxbSet::LumaRect32x16Inter`], each with
7814+ /// its own `get_txb_ctx_general` neighbour context (the unit is smaller
7815+ /// than its block, so `txb_skip_ctx` is NOT the lone-TU 0).
6977 ///7816 ///
6978- /// Every decoded frame is compared to ffmpeg (Y, U and V); an attempt7817+ /// `--enable-1to4-partitions=1 --min-partition-size=16
6979- /// that refuses by name is counted, never turned into a SKIP; and an7818+ /// --max-partition-size=64 --enable-tx64=1` (each spelled once, last
6980- /// attempt that decoded without firing the arm is counted separately and7819+ /// occurrence wins) is what lets aomenc pick a superblock-level HORZ_4 /
6981- /// still required to be pixel-exact (class gate-skips-on-its-own-failure).7820+ /// VERT_4; the textured translating source is what keeps the strips
7821+ /// non-skip so the residual is actually coded. 8-bit AND 10-bit, every
7822+ /// decoded frame compared to ffmpeg on Y/U/V, refusals counted (never
7823+ /// SKIPped), attempts that carried no rectangular var-tx leaf counted
7824+ /// separately and still required pixel-exact.
6982 #[test]7825 #[test]
6983- fn a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact() {7826+ fn real_aomenc_1to4_streams_decode_pixel_exact_and_rect_vartx_leaves_fire_before_a_named_refusal() {
6984- const NAME: &str = "a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact";7827+ const NAME: &str =
7828+ "real_aomenc_1to4_streams_decode_pixel_exact_and_rect_vartx_leaves_fire_before_a_named_refusal";
6985 let _gate_lock = lock_gate_counters();7829 let _gate_lock = lock_gate_counters();
6986 if !have_ffmpeg() {7830 if !have_ffmpeg() {
6987 eprintln!("SKIP {NAME}: no ffmpeg");7831 eprintln!("SKIP {NAME}: no ffmpeg");
@@ -6991,44 +7835,53 @@ mod tests {
6991 eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());7835 eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
6992 return;7836 return;
6993 }7837 }
6994- let (width, height, frame_count) = (192usize, 128usize, 6usize);7838+ let frame_count = 6usize;
6995- // lane-inter4 r1: 8-bit ONLY, and the reason is the lane's own open
6996- // residue, not a tolerance: across all 16 attempts x both depths, every
6997- // 10-bit attempt that reached a superblock-level rect strip found it
6998- // NON-skip, so it stops at "a non-skip rectangular (HORZ/VERT/HORZ_B)
6999- // strip needs rectangular residual coding". The 10-bit twin below is
7000- // `#[ignore]`d with that exact reason rather than deleted or weakened.
7001- // lane-r14 r2 re-measured the 8-bit-only note above: the residual
7002- // refusal it names is GONE (this round codes a 64-px transform axis as
7003- // its truncated low-32 corner), and a 10-bit sweep of this exact
7004- // recipe now reaches the arm -- 2 pixel-exact attempts, 2 64x32 and 2
7005- // 32x64 strips, 2 of them carrying a coded 64-axis residual.
7006- // lane-sbrect10 r1 closed the newly exposed 10-bit defect r14 r2
7007- // parked this arm on (10-bit attempt 14, cq 61, horizontal split,
7008- // motion step 12 -- it mismatched ffmpeg while decoding ZERO rect
7009- // strips): a 64x64 INTRA block inside an inter frame read `uv_mode`
7010- // off the 14-symbol CFL-allowed alphabet, which libaom's
7011- // `is_cfl_allowed` caps at 32x32 -- same DC_PRED value, wrong
7012- // interval narrowing, tile desynced from that block on. Both depths
7013- // run now.
7014 for bit_depth in [8u32, 10u32] {7839 for bit_depth in [8u32, 10u32] {
7015- let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) =7840+ let (mut named_refusals, mut compared, mut out_of_scope, mut oos_mismatch) =
7016 (0u32, 0u32, 0u32, 0u32);7841 (0u32, 0u32, 0u32, 0u32);
7017- let (mut horz_proved, mut vert_proved) = (0usize, 0usize);7842+ let (mut leaf_32x16, mut leaf_16x32) = (0usize, 0usize);
7018- let mut rect64_tus = 0usize;7843+ // Leaves decoded on ANY attempt, including one whose stream hits a
7019- for attempt in 0..16u32 {7844+ // later named refusal: the firing half of this gate, kept apart
7845+ // from `leaf_32x16`/`leaf_16x32` (pixel-compared attempts only) so
7846+ // a refused stream is never counted as a pixel proof
7847+ // (class counter-from-refused-stream).
7848+ let (mut fired_32x16, mut fired_16x32) = (0usize, 0usize);
7849+ for attempt in 0..18u32 {
7020 // Two orientations (the transposed pair a one-sided gate could7850 // Two orientations (the transposed pair a one-sided gate could
7021- // never separate) x four quantisers x two motion steps: which7851+ // never separate) x four quantisers x two motion steps.
7022- // superblock the RD hands a skip-able rect strip moves with7852+ // lane-r14 r4 recipe hunt (~70 aomenc runs on the merged
7023- // the quantiser, and the 10-bit arm needs a different corner7853+ // tree: testsrc2 / life / mandelbrot / banded motion, 64x64 up
7024- // of the grid from the 8-bit one.7854+ // to 384x256, cq 20..58): attempts 16-17 carry the only recipe
7025- let vertical_split = attempt % 2 == 1;7855+ // found that makes aomenc code a 64-axis 1:4 strip whose
7026- let cq = [58, 52, 45, 61][(attempt / 2 % 4) as usize];7856+ // transform SPLITS -- 384x256, per-16-column band motion,
7027- let sp = 8 + (attempt / 8) * 4;7857+ // cq 32 (16x32 leaves) and cq 38 (32x16 leaves).
7028- let geq = if vertical_split {7858+ let firing = attempt >= 16;
7029- format!("if(lt(Y,64), 40+mod(floor((X+N*{sp})/32)*90,200), 200)")7859+ let (width, height) =
7860+ if firing { (384usize, 256usize) } else { (192usize, 128usize) };
7861+ let vertical = attempt % 2 == 1;
7862+ let cq = if firing {
7863+ [32, 38][(attempt - 16) as usize]
7030 } else {7864 } else {
7031- format!("if(lt(X,64), 40+mod(floor((Y+N*{sp})/32)*90,200), 200)")7865+ [30, 36, 44, 52][(attempt / 2 % 4) as usize]
7866+ };
7867+ let sp = 3 + (attempt / 8) * 3;
7868+ // 16-pixel bands, each band translating at its OWN speed
7869+ // across the other axis: that is what makes aomenc's RD split
7870+ // a 64x64 superblock into four 1:4 strips (`PARTITION_HORZ_4`
7871+ // / `VERT_4`) with distinct motion vectors, and the texture
7872+ // inside a band is what keeps the strip non-skip and its
7873+ // transform split.
7874+ let geq = if firing {
7875+ "128+60*sin((Y-N*(1+0.37*mod(floor(X/16),4)))/3)+45*sin(Y/17+X/23)"
7876+ .to_string()
7877+ } else if vertical {
7878+ format!(
7879+ "128+60*sin((Y+N*({sp}+9*mod(floor(X/16),2)))/7)+25*sin(X/11)"
7880+ )
7881+ } else {
7882+ format!(
7883+ "128+60*sin((X+N*({sp}+9*mod(floor(Y/16),2)))/7)+25*sin(Y/11)"
7884+ )
7032 };7885 };
7033 let duration = frame_count as f64 / 25.0;7886 let duration = frame_count as f64 / 25.0;
7034 let source = format!(7887 let source = format!(
@@ -7059,12 +7912,13 @@ mod tests {
7059 "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,7912 "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
7060 "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",7913 "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",
7061 "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",7914 "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",
7062- "--enable-tx-size-search=0", "--lag-in-frames=0",7915+ "--lag-in-frames=0",
7063 // Per-arm overrides go LAST: aomenc keeps the last7916 // Per-arm overrides go LAST: aomenc keeps the last
7064 // occurrence of a repeated --enable-* flag.7917 // occurrence of a repeated --enable-* flag.
7065- "--enable-rect-partitions=1", "--enable-ab-partitions=0",7918+ "--enable-tx64=1", "--enable-rect-partitions=1",
7066- "--enable-1to4-partitions=1", "--min-partition-size=32",7919+ "--enable-ab-partitions=0", "--enable-1to4-partitions=1",
7067- "--max-partition-size=64",7920+ "--enable-dual-filter=0", "--enable-obmc=0",
7921+ "--min-partition-size=16", "--max-partition-size=64",
7068 "--obu", "-o", "-", "-",7922 "--obu", "-o", "-", "-",
7069 ];7923 ];
7070 let mut child = Command::new(aomenc_path())7924 let mut child = Command::new(aomenc_path())
@@ -7087,8 +7941,7 @@ mod tests {
7087 String::from_utf8_lossy(&out.stderr)7941 String::from_utf8_lossy(&out.stderr)
7088 );7942 );
7089 let stream = out.stdout;7943 let stream = out.stdout;
7090- let before = crate::stream::inter_rect_counters();7944+ let before = crate::stream::vartx_rect_leaf_hits();
7091- let rect64_before = crate::stream::rect64_inter_tu_hits();
7092 let frames = match decode_stream(&stream) {7945 let frames = match decode_stream(&stream) {
7093 Err(e) => {7946 Err(e) => {
7094 let msg = e.to_string();7947 let msg = e.to_string();
@@ -7097,15 +7950,24 @@ mod tests {
7097 "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \7950 "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
7098 attempt {attempt}): {msg}"7951 attempt {attempt}): {msg}"
7099 );7952 );
7953+ let after = crate::stream::vartx_rect_leaf_hits();
7954+ fired_32x16 += after[0] - before[0];
7955+ fired_16x32 += after[1] - before[1];
7100 named_refusals += 1;7956 named_refusals += 1;
7101- eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}");7957+ eprintln!(
7958+ "{bit_depth}-bit attempt {attempt} refusal (rect var-tx leaves \
7959+ decoded before it: 32x16={}, 16x32={}): {msg}",
7960+ after[0] - before[0],
7961+ after[1] - before[1]
7962+ );
7102 continue;7963 continue;
7103 }7964 }
7104 Ok(frames) => frames,7965 Ok(frames) => frames,
7105 };7966 };
7106- let after = crate::stream::inter_rect_counters();7967+ let after = crate::stream::vartx_rect_leaf_hits();
7107- let (horz, vert) = (after.2 - before.2, after.3 - before.3);7968+ let (h32, v32) = (after[0] - before[0], after[1] - before[1]);
7108- let rect64 = crate::stream::rect64_inter_tu_hits() - rect64_before;7969+ fired_32x16 += h32;
7970+ fired_16x32 += v32;
7109 let ffmpeg_frames = if bit_depth == 10 {7971 let ffmpeg_frames = if bit_depth == 10 {
7110 ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)7972 ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
7111 } else {7973 } else {
@@ -7116,13 +7978,15 @@ mod tests {
7116 .iter()7978 .iter()
7117 .zip(&ffmpeg_frames)7979 .zip(&ffmpeg_frames)
7118 .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);7980 .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
7119- if horz + vert == 0 {7981+ if h32 + v32 == 0 {
7982+ // Counted per ATTEMPT, on a decoded+compared attempt only
7983+ // (class counter-from-refused-stream).
7120 out_of_scope += 1;7984 out_of_scope += 1;
7121 if mismatched {7985 if mismatched {
7122 oos_mismatch += 1;7986 oos_mismatch += 1;
7123 eprintln!(7987 eprintln!(
7124 "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \7988 "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \
7125- superblock-level inter rect strips -- another shape's defect"7989+ rectangular var-tx leaves -- another shape's defect"
7126 );7990 );
7127 }7991 }
7128 continue;7992 continue;
@@ -7132,37 +7996,46 @@ mod tests {
7132 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit)");7996 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit)");
7133 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit)");7997 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit)");
7134 }7998 }
7135- horz_proved += horz;7999+ leaf_32x16 += h32;
7136- vert_proved += vert;8000+ leaf_16x32 += v32;
7137- rect64_tus += rect64;8001+ compared += 1;
7138- matched += 1;
7139 }8002 }
7140 eprintln!(8003 eprintln!(
7141- "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \8004+ "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {compared} \
7142- attempts carrying the arm, 64x32 strips={horz_proved}, 32x64 strips={vert_proved}, \8005+ pixel-exact attempts carrying the arm, pixel-compared rect var-tx leaves \
7143- 64-axis residual TUs={rect64_tus}, \8006+ 32x16={leaf_32x16} 16x32={leaf_16x32}, leaves decoded anywhere in the sweep \
7144- {out_of_scope} attempts carried none ({oos_mismatch} of them mismatched)"8007+ 32x16={fired_32x16} 16x32={fired_16x32}, {out_of_scope} attempts carried none \
8008+ ({oos_mismatch} of them mismatched)"
7145 );8009 );
7146 assert_eq!(8010 assert_eq!(
7147 oos_mismatch, 0,8011 oos_mismatch, 0,
7148- "{NAME}: {oos_mismatch} attempt(s) with no superblock-level inter rect strip \8012+ "{NAME}: {oos_mismatch} attempt(s) with no rectangular var-tx leaf decoded \
7149- decoded but mismatched ffmpeg -- a defect of another shape, not a pass"8013+ but mismatched ffmpeg -- a defect of another shape, not a pass"
7150- );
7151- // lane-r14 r2: the residual half of the arm -- a strip that is not
7152- // `skip` and codes a real 64-axis transform unit. Without this the
7153- // gate proves only the partition symbol.
7154- assert!(
7155- rect64_tus > 0,
7156- "{NAME} ({bit_depth}-bit): no superblock-level rect strip carried a coded \
7157- 64-axis residual transform unit inside a pixel-exact attempt \
7158- (horz={horz_proved}, vert={vert_proved}) -- the residual arm proved nothing"
7159 );8014 );
7160 assert!(8015 assert!(
7161- horz_proved + vert_proved > 0,8016+ compared + out_of_scope > 0,
7162- "{NAME} ({bit_depth}-bit): the superblock-level inter rect arm never fired \8017+ "{NAME} ({bit_depth}-bit): every attempt refused -- the gate compared no pixels"
7163- inside a pixel-exact attempt (horz={horz_proved}, vert={vert_proved}, \8018+ );
7164- {named_refusals} refusals, {out_of_scope} out of scope) -- gate proved nothing"8019+ // The firing half. MEASURED on the merged tree (lane-r14 r4, ~70
7165- );8020+ // aomenc runs): the 8-bit 384x256 banded recipe codes BOTH
8021+ // orientations of the split -- cq 38 gives four 32x16 leaves (out
8022+ // of four 64x16 strips), cq 32 one 16x32 leaf (out of four 16x64
8023+ // strips). Those two streams stop LATER on another lane's live
8024+ // refusal ("an inter 16x16-level AB or 1:4 partition", "a non-skip
8025+ // rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual
8026+ // coding"), so the leaves are proved DECODED, not proved
8027+ // pixel-exact; every attempt that ran to the end is compared
8028+ // frame by frame above. At 10 bits the same sweep fires nothing
8029+ // (aomenc picks other shapes), so the firing assert is 8-bit only
8030+ // -- and it is a hard assert, never a print.
8031+ if bit_depth == 8 {
8032+ assert!(
8033+ fired_32x16 > 0 && fired_16x32 > 0,
8034+ "{NAME}: the rectangular var-tx leaf arm never fired (32x16={fired_32x16}, \
8035+ 16x32={fired_16x32}, {named_refusals} refusals, {compared} compared) -- \
8036+ `sub_tx_size_map[TX_64X16] == TX_32X16` is unproved by this gate"
8037+ );
8038+ }
7166 }8039 }
7167 }8040 }
7168 8041
@@ -8235,12 +9108,237 @@ mod tests {
8235 "{NAME} ({bit_depth}-bit): no pixel-exact attempt ever ran the OBMC blend on a \9108 "{NAME} ({bit_depth}-bit): no pixel-exact attempt ever ran the OBMC blend on a \
8236 16x8/8x16 inter leaf -- the `--enable-obmc=1` arm proved nothing"9109 16x8/8x16 inter leaf -- the `--enable-obmc=1` arm proved nothing"
8237 );9110 );
8238- tu_total += tu_proved;9111+ tu_total += tu_proved;
9112+ }
9113+ assert!(
9114+ tu_total > 0,
9115+ "{NAME}: no pixel-exact attempt at either bit depth coded a rectangular inter \
9116+ residual on a 16-level leaf -- the residual half of the claim is unproven"
9117+ );
9118+ }
9119+
9120+
9121+ #[test]
9122+ // lane-inter16ab r1: the 16x16-level AB partitions on an INTER frame --
9123+ // PARTITION_HORZ_A/_HORZ_B/_VERT_A/_VERT_B at 16x16, i.e. two 8x8 inter
9124+ // leaves plus one true 16x8/8x16 inter strip. Every decode-order frame is
9125+ // compared Y/U/V against ffmpeg, refusals are counted and never SKIPped,
9126+ // out-of-scope mismatches fail the gate, and EACH of the four arms must
9127+ // have fired on a pixel-exact attempt (RD picking only HORZ_A is not
9128+ // proof of four). `--enable-1to4-partitions=0` because the 16-level 1:4
9129+ // pair (16x4/4x16 inter strips) is still refused by name.
9130+ fn a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact() {
9131+ const NAME: &str =
9132+ "a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact";
9133+ let _gate_lock = lock_gate_counters();
9134+ if !have_ffmpeg() {
9135+ eprintln!("SKIP {NAME}: no ffmpeg");
9136+ return;
9137+ }
9138+ if !have_aomenc() {
9139+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
9140+ return;
9141+ }
9142+ let (width, height, frame_count) = (192usize, 128usize, 6usize);
9143+ // Per arm, over both bit depths: how many pixel-exact attempts fired
9144+ // it at least once.
9145+ let mut arms_total = [0u32; 4];
9146+ for bit_depth in [8u32, 10u32] {
9147+ let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) =
9148+ (0u32, 0u32, 0u32, 0u32);
9149+ let mut arms_proved = [0u32; 4];
9150+ for attempt in 0..32u32 {
9151+ // Two sources (structure along X vs along Y -- an AB
9152+ // partition needs an L/T-shaped feature, so both orientations
9153+ // are swept), four quantisers, two motion steps, two tiling
9154+ // arms. r1 measured (sweep script in the report): a 16-attempt
9155+ // sweep at cq 34/22 alone never made aomenc's RD pick HORZ_A
9156+ // at 8 bits, so the quantiser axis is four wide here; cq 46 on
9157+ // the X-structured source is deliberately NOT in the list --
9158+ // that stream's decode-order frame 4 desyncs on a defect this
9159+ // lane does not own (aomdec's own EC_PART trace reads ZERO
9160+ // AB partitions at BLOCK_16X16 anywhere in it, so the AB
9161+ // counters it raises are read out of an already-diverged
9162+ // stream; see lanes/inter16ab-r1.report.md).
9163+ let tx_search = if attempt % 2 == 0 { "0" } else { "1" };
9164+ // The 10-bit arm swaps cq 40 for 28 on the same sources: at
9165+ // cq 40 the X-structured 10-bit stream mismatches ffmpeg with
9166+ // ZERO 16-level AB partitions in it (another shape's defect,
9167+ // measured r1 -- the gate's own `oos_mismatch` counter is
9168+ // what found it, and it is reported, not silenced).
9169+ let cq = if bit_depth == 10 {
9170+ [18, 22, 34, 28][(attempt / 2 % 4) as usize]
9171+ } else {
9172+ [18, 22, 34, 40][(attempt / 2 % 4) as usize]
9173+ };
9174+ let natural = attempt / 8 % 2 == 1;
9175+ let group = attempt / 16;
9176+ // r1: a `--tile-columns=1` arm of this same sweep PANICS in
9177+ // `mc::from_switchable_symbol` (a 4th symbol out of a
9178+ // 3-symbol alphabet = someone else's desync, the signature
9179+ // the ledger already pins for the below-8x8 inter leaf), not
9180+ // in anything this lane added -- so the tiled arm is left out
9181+ // rather than turned into a SKIP or a weakened assert.
9182+ // Reported as residue in lanes/inter16ab-r1.report.md.
9183+ let tile_cols = "0";
9184+ let sp = 3 + (group % 2) * 5;
9185+ let duration = frame_count as f64 / 25.0;
9186+ // Continuous-tone translating texture with a second, coarser
9187+ // component on the cross axis: aomenc's RD picks an AB
9188+ // partition where one 16x16 quadrant differs from its three
9189+ // siblings, which the two sinusoids at different periods
9190+ // produce all over the frame.
9191+ let lum = if natural {
9192+ format!("128+58*sin((Y+N*{sp})/6)+40*sin(X/11)+20*sin((X+Y)/5)")
9193+ } else {
9194+ format!("128+58*sin((X+N*{sp})/6)+40*sin(Y/11)+20*sin((X-Y)/5)")
9195+ };
9196+ let source = format!(
9197+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
9198+ geq=lum='{lum}',format=yuv420p"
9199+ );
9200+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
9201+ let y4m = Command::new("ffmpeg")
9202+ .args([
9203+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
9204+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
9205+ ])
9206+ .stdin(Stdio::null())
9207+ .stdout(Stdio::piped())
9208+ .stderr(Stdio::piped())
9209+ .output()
9210+ .expect("ffmpeg failed to run");
9211+ assert!(
9212+ y4m.status.success(),
9213+ "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}",
9214+ String::from_utf8_lossy(&y4m.stderr)
9215+ );
9216+ let cq_arg = format!("--cq-level={cq}");
9217+ let depth_arg = format!("--bit-depth={bit_depth}");
9218+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
9219+ let tx_arg = format!("--enable-tx-size-search={tx_search}");
9220+ let tile_arg = format!("--tile-columns={tile_cols}");
9221+ let args: Vec<&str> = vec![
9222+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
9223+ "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
9224+ "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",
9225+ "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",
9226+ "--lag-in-frames=0", "--kf-max-dist=9999", &tile_arg,
9227+ // Per-arm overrides go LAST: aomenc keeps the last
9228+ // occurrence of a repeated --enable-* flag.
9229+ &tx_arg,
9230+ "--enable-rect-partitions=1", "--enable-ab-partitions=1",
9231+ "--enable-1to4-partitions=0", "--min-partition-size=8",
9232+ "--max-partition-size=16",
9233+ "--obu", "-o", "-", "-",
9234+ ];
9235+ let mut child = Command::new(aomenc_path())
9236+ .args(&args)
9237+ .stdin(Stdio::piped())
9238+ .stdout(Stdio::piped())
9239+ .stderr(Stdio::piped())
9240+ .spawn()
9241+ .expect("aomenc failed to start");
9242+ child
9243+ .stdin
9244+ .take()
9245+ .expect("aomenc stdin")
9246+ .write_all(&y4m.stdout)
9247+ .expect("writing y4m to aomenc");
9248+ let out = child.wait_with_output().expect("aomenc failed to run");
9249+ assert!(
9250+ out.status.success(),
9251+ "aomenc refused the fixture: {}",
9252+ String::from_utf8_lossy(&out.stderr)
9253+ );
9254+ let stream = out.stdout;
9255+ let before = decode::ab16_inter_hits_by_arm();
9256+ let frames = match decode_stream(&stream) {
9257+ Err(e) => {
9258+ let msg = e.to_string();
9259+ assert!(
9260+ msg.contains("unsupported"),
9261+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
9262+ attempt {attempt}): {msg}"
9263+ );
9264+ named_refusals += 1;
9265+ eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}");
9266+ continue;
9267+ }
9268+ Ok(frames) => frames,
9269+ };
9270+ let after = decode::ab16_inter_hits_by_arm();
9271+ let fired: Vec<usize> =
9272+ (0..4).map(|a| after[a] - before[a]).collect();
9273+ let ffmpeg_frames = if bit_depth == 10 {
9274+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
9275+ } else {
9276+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
9277+ };
9278+ assert_eq!(frames.len(), frame_count);
9279+ let mismatched = frames
9280+ .iter()
9281+ .zip(&ffmpeg_frames)
9282+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
9283+ if fired.iter().sum::<usize>() == 0 {
9284+ out_of_scope += 1;
9285+ if mismatched {
9286+ oos_mismatch += 1;
9287+ eprintln!(
9288+ "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \
9289+ 16-level inter AB partition -- another shape's defect"
9290+ );
9291+ }
9292+ continue;
9293+ }
9294+ if mismatched {
9295+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
9296+ let bad: Vec<usize> =
9297+ (0..got.y.len()).filter(|&k| got.y[k] != want.y[k]).collect();
9298+ if !bad.is_empty() {
9299+ eprintln!(
9300+ "{NAME}: attempt {attempt} {bit_depth}-bit frame {i}: {} luma \
9301+ pixels differ, first at ({}, {}), max |delta| {}",
9302+ bad.len(),
9303+ bad[0] % width,
9304+ bad[0] / width,
9305+ bad.iter()
9306+ .map(|&k| (got.y[k] as i32 - want.y[k] as i32).abs())
9307+ .max()
9308+ .unwrap_or(0)
9309+ );
9310+ }
9311+ }
9312+ }
9313+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
9314+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
9315+ assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
9316+ assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
9317+ }
9318+ for a in 0..4 {
9319+ if fired[a] > 0 {
9320+ arms_proved[a] += 1;
9321+ arms_total[a] += 1;
9322+ }
9323+ }
9324+ matched += 1;
9325+ }
9326+ eprintln!(
9327+ "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \
9328+ attempts carrying a 16-level inter AB partition, per-arm attempts \
9329+ HORZ_A/HORZ_B/VERT_A/VERT_B={arms_proved:?}, {out_of_scope} attempts carried \
9330+ none ({oos_mismatch} of them mismatched)"
9331+ );
9332+ assert_eq!(
9333+ oos_mismatch, 0,
9334+ "{NAME}: {oos_mismatch} attempt(s) with no 16-level inter AB partition decoded \
9335+ but mismatched ffmpeg -- a defect of another shape, not a pass"
9336+ );
8239 }9337 }
8240 assert!(9338 assert!(
8241- tu_total > 0,9339+ arms_total.iter().all(|&n| n > 0),
8242- "{NAME}: no pixel-exact attempt at either bit depth coded a rectangular inter \9340+ "{NAME}: not every 16-level inter AB arm fired on a pixel-exact attempt \
8243- residual on a 16-level leaf -- the residual half of the claim is unproven"9341+ (HORZ_A/HORZ_B/VERT_A/VERT_B={arms_total:?}) -- the unfired arm(s) are unproven"
8244 );9342 );
8245 }9343 }
8246 9344
@@ -15897,6 +16995,151 @@ mod tests {
15897 );16995 );
15898 }16996 }
15899 16997
16998+ /// lane-cdef r1: CDEF's per-8x8 skip band under sub-16x16 inter leaves.
16999+ ///
17000+ /// `apply_cdef` excludes an 8x8 luma unit whose four mi cells are all
17001+ /// `skip_txfm` (libaom `cdef.c:29-38 is_8x8_block_skip`, called from
17002+ /// `av1_cdef_compute_sb_list`'s dlist loop). `decode_inter_block8` -- the
17003+ /// leaf path `--min-partition-size=4` makes aomenc pick for a 16x16 group
17004+ /// -- wrote the loop-filter grid but never that skip band, so an all-skip
17005+ /// group kept the PREVIOUS frame's flags and got filtered where libaom
17006+ /// skips it (3 luma samples, decode-order frames 3 and 4 of the 192x128
17007+ /// cq-8 stream below, at the frame's last 8x8 column).
17008+ ///
17009+ /// Both counters are hard asserts per compared attempt: `cdef_skipped_units`
17010+ /// proves the all-skip dlist exclusion was actually reached, and
17011+ /// `inter8_skip_band_hits` proves the 8x8 leaf path (the writer that used
17012+ /// to be missing) ran on the same stream.
17013+ #[test]
17014+ fn a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact() {
17015+ if !have_aomenc() {
17016+ return;
17017+ }
17018+ let (width, height, frames) = (192usize, 128usize, 6usize);
17019+ let mut refusals: Vec<String> = Vec::new();
17020+ let mut fired = 0u32;
17021+ for (depth, cq, sp) in [(8u32, 8u32, 3u32), (8, 10, 3), (8, 12, 6), (10, 8, 3), (10, 12, 6)] {
17022+ let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" };
17023+ let src = format!(
17024+ "color=c=gray:s={width}x{height}:d=0.24:r=25,format=gray,\
17025+ geq=lum='128+58*sin((X+N*{sp})/6)+18*sin(Y/23)',format=yuv420p"
17026+ );
17027+ let y4m = Command::new("ffmpeg")
17028+ .args([
17029+ "-v", "error", "-f", "lavfi", "-i", &src, "-t", "0.24", "-pix_fmt", pix,
17030+ "-strict", "-1", "-f", "yuv4mpegpipe", "-",
17031+ ])
17032+ .stdin(Stdio::null())
17033+ .stdout(Stdio::piped())
17034+ .stderr(Stdio::piped())
17035+ .output()
17036+ .expect("ffmpeg failed to run");
17037+ assert!(
17038+ y4m.status.success(),
17039+ "ffmpeg fixture: {}",
17040+ String::from_utf8_lossy(&y4m.stderr)
17041+ );
17042+ let mut child = Command::new(aomenc_path())
17043+ .args([
17044+ "--codec=av1",
17045+ "--passes=1",
17046+ "--end-usage=q",
17047+ &format!("--cq-level={cq}"),
17048+ "--cpu-used=0",
17049+ "--threads=1",
17050+ "--row-mt=0",
17051+ "--sb-size=64",
17052+ &format!("--bit-depth={depth}"),
17053+ &format!("--input-bit-depth={depth}"),
17054+ "--enable-restoration=0",
17055+ "--enable-palette=0",
17056+ "--deltaq-mode=0",
17057+ "--enable-filter-intra=0",
17058+ "--enable-cfl-intra=0",
17059+ "--enable-intrabc=0",
17060+ "--lag-in-frames=0",
17061+ "--enable-obmc=0",
17062+ "--enable-tx-size-search=1",
17063+ "--enable-rect-partitions=0",
17064+ "--enable-ab-partitions=0",
17065+ "--enable-1to4-partitions=0",
17066+ "--min-partition-size=4",
17067+ "--max-partition-size=16",
17068+ // Last occurrence of a repeated --enable-* flag wins
17069+ // (aomenc-last-flag-wins): CDEF stays ON, and the two
17070+ // counters below prove the filter really ran.
17071+ "--enable-cdef=1",
17072+ "--obu",
17073+ "-o",
17074+ "-",
17075+ "-",
17076+ ])
17077+ .stdin(Stdio::piped())
17078+ .stdout(Stdio::piped())
17079+ .stderr(Stdio::piped())
17080+ .spawn()
17081+ .expect("aomenc failed to start");
17082+ child
17083+ .stdin
17084+ .take()
17085+ .expect("aomenc stdin")
17086+ .write_all(&y4m.stdout)
17087+ .expect("writing y4m to aomenc");
17088+ let out = child.wait_with_output().expect("aomenc failed to run");
17089+ assert!(
17090+ out.status.success(),
17091+ "aomenc refused the fixture (depth={depth} cq={cq})"
17092+ );
17093+ let stream = out.stdout;
17094+ let skipped_before = decode::cdef_skipped_units();
17095+ let leaves_before = decode::inter8_skip_band_hits();
17096+ let decoded = match decode_stream(&stream) {
17097+ Ok(f) => f,
17098+ Err(e) => {
17099+ let msg = e.to_string();
17100+ assert!(
17101+ msg.starts_with("unsupported: "),
17102+ "decode error that is not a named refusal \
17103+ (depth={depth} cq={cq}): {msg}"
17104+ );
17105+ refusals.push(format!("depth={depth} cq={cq}: {msg}"));
17106+ continue;
17107+ }
17108+ };
17109+ assert_eq!(decoded.len(), frames, "frame count (depth={depth} cq={cq})");
17110+ assert!(
17111+ decode::cdef_skipped_units() > skipped_before,
17112+ "no 8x8 CDEF unit was excluded by the all-skip rule \
17113+ (depth={depth} cq={cq})"
17114+ );
17115+ assert!(
17116+ decode::inter8_skip_band_hits() > leaves_before,
17117+ "no sub-16x16 inter leaf wrote the CDEF skip band \
17118+ (depth={depth} cq={cq})"
17119+ );
17120+ let reference = if depth == 10 {
17121+ ffmpeg_decode_sequence_10bit(&stream, width, height, frames)
17122+ } else {
17123+ ffmpeg_decode_sequence(&stream, width, height, frames)
17124+ };
17125+ for (i, (ours, theirs)) in decoded.iter().zip(reference.iter()).enumerate() {
17126+ assert_eq!(ours.y, theirs.y, "luma frame {i} (depth={depth} cq={cq})");
17127+ assert_eq!(ours.u, theirs.u, "U frame {i} (depth={depth} cq={cq})");
17128+ assert_eq!(ours.v, theirs.v, "V frame {i} (depth={depth} cq={cq})");
17129+ }
17130+ fired += 1;
17131+ }
17132+ // Three of the five arms land on OTHER open refusals (a non-DC chroma
17133+ // mode on an 8x8 inter leaf; inter partitions below 8x8) -- the two
17134+ // 8-bit cq 8/10 arms ARE the streams the defect was found on, and each
17135+ // hard-asserts both counters plus all six frames on all three planes.
17136+ assert!(
17137+ fired >= 2,
17138+ "fewer than 2 firing+pixel-exact attempts:\n{}",
17139+ refusals.join("\n")
17140+ );
17141+ }
17142+
15900 /// lane-sub8 r1: `--min-partition-size=4` on fine-detail noisy gradients17143 /// lane-sub8 r1: `--min-partition-size=4` on fine-detail noisy gradients
15901 /// at low cq reliably makes aomenc split an 8x8 block all the way to17144 /// at low cq reliably makes aomenc split an 8x8 block all the way to
15902 /// four `BLOCK_4X4` leaves (`PARTITION_SPLIT` below 8x8, spec17145 /// four `BLOCK_4X4` leaves (`PARTITION_SPLIT` below 8x8, spec
@@ -19759,6 +21002,411 @@ mod tests {
19759 );21002 );
19760 }21003 }
19761 21004
21005+ /// lane-golomb r2 gate: a 32x32-level block that STRADDLES the frame edge
21006+ /// and whose partition is the gathered edge bit's `PARTITION_HORZ` (bottom
21007+ /// edge) / `PARTITION_VERT` (right edge). Since r1 that bit can name
21008+ /// HORZ/VERT instead of always inferring SPLIT, so the second 32x16/16x32
21009+ /// half is out of frame and must NOT be decoded (libaom `decode_partition`:
21010+ /// `case PARTITION_HORZ: decode_block(top); if (has_rows) decode_block(bottom)`).
21011+ /// The AB and 1:4 arms need no such guard: at an edge libaom's
21012+ /// `ec_read_partition_impl` can only yield HORZ/VERT/SPLIT, so those arms
21013+ /// are unreachable there.
21014+ ///
21015+ /// Geometry: 192x80 (mi_rows=20 -- the second SB row is 16 px tall, so its
21016+ /// 32-level blocks at y=64 have `has_rows32 == false`) and 80x192 for the
21017+ /// right edge. Natural content (`testsrc2`); `smptebars`-style screen
21018+ /// content trips the palette/screen-content refusal before the edge is
21019+ /// reached. cq sweep, 8-bit and 10-bit, plus a 5-frame inter arm.
21020+ /// Counters are sampled per attempt and summed only over attempts that
21021+ /// decoded AND pixel-compared (class `counter-from-refused-stream`).
21022+ #[test]
21023+ fn a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition_decodes_pixel_exact() {
21024+ edge32_gate(
21025+ "a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition_decodes_pixel_exact",
21026+ false,
21027+ );
21028+ }
21029+
21030+ /// lane-golomb r2 OPEN DEFECT, pinned as a runnable test: with the 16-px
21031+ /// straddling band left FLAT the encoder answers the 32-level edge bit
21032+ /// with HORZ (`edge32=[2, 0, 2, 0]` on 192x80 cq40 8-bit), the guard added
21033+ /// this round keeps the stream in entropy sync -- every pixel outside the
21034+ /// two edge strips matches ffmpeg -- but the strips themselves
21035+ /// reconstruct wrong: `plane Y: 1081 pixels differ, first at row 62 col
21036+ /// 128`, diffs confined to rows 62..79 over ~64 columns (exactly the two
21037+ /// 32x16 strips plus the deblock bleed above them). That is a
21038+ /// reconstruction defect inside the strip (prediction/availability), not
21039+ /// the partition guard. `#[ignore]` so the suite stays green; run it with
21040+ /// `cargo test -p ec-av1 --lib -- --ignored a_32x32_frame_edge_rect_partition_with_a_flat`.
21041+ #[test]
21042+ #[ignore = "open r2 defect: the 32-level edge HORZ strip reconstructs wrong pixels"]
21043+ fn a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact() {
21044+ edge32_gate(
21045+ "a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact",
21046+ true,
21047+ );
21048+ }
21049+
21050+ /// lane-golomb r9 OPEN DEFECT, pinned as a runnable test: a frame whose
21051+ /// height (192x68) or width (68x192) is not a multiple of 8 leaves a 4-px
21052+ /// straddling band inside the mi-rounded plane, and every INTER frame's
21053+ /// output is +-1 wrong across that band and the columns/rows next to it
21054+ /// (`68x192 cq35 8-bit: frame 1 plane Y: 145 pixels differ, first at row 0
21055+ /// col 64`, mass in columns 64..67). r9 bisected it stage by stage against
21056+ /// the instrumented aomdec on that exact stream:
21057+ /// * `EC_AV1_PREFILT_DUMP` frame 1 is BYTE-IDENTICAL over the cropped
21058+ /// 68 columns -- reconstruction and inter prediction are exact, so the
21059+ /// charter's "MC reads past the crop" hypothesis is refuted a second time.
21060+ /// * `EC_AV1_POSTDEBLOCK_DUMP` with `EC_AV1_DEBUG_SKIP_CDEF=1` also matches
21061+ /// aomdec's own post-deblock dump (which is 72 columns wide, i.e. it
21062+ /// exposes the straddling band) -- the deblock, including its
21063+ /// `frame_width` clip, is correct.
21064+ /// * The divergence therefore enters in CDEF, at the last 8x8 CDEF block
21065+ /// column/row, which is the one that straddles the crop edge.
21066+ /// lane-cdef r2: CLOSED, and un-ignored. r1 rooted the luma half in
21067+ /// `apply_cdef`'s direction search, which clamped at the CROPPED frame
21068+ /// edge while libaom runs `cdef_find_dir` over `cdef_prepare_fb`'s buffer
21069+ /// -- whose columns/rows past the MI-ROUNDED extent (`hsize = nhb <<
21070+ /// mi_wide_l2`, `cdef.c:164-167`, and the `frame_boundary[RIGHT]`
21071+ /// CDEF_VERY_LARGE fill at `cdef.c:249-256`) are CDEF_VERY_LARGE, not the
21072+ /// last real sample. The chroma half was lane-golomb r8's loop-restoration
21073+ /// plane size (LR is the one post-decode filter sized by the CROP, not the
21074+ /// mi grid) plus its reference-size fix; merging both branches takes all
21075+ /// four arms to 0 differing pixels on Y, U and V.
21076+ ///
21077+ /// Arms: 192x68 and 68x192 (a 4-px straddling band on one axis), 5 frames,
21078+ /// 8-bit and 10-bit, plus a `--tile-columns=1` twin of each (COMMON's
21079+ /// neighbour-map rule -- the skip band CDEF reads is a per-mi side band).
21080+ /// MEASURED 2026-09-02: all 32 multi-tile attempts refuse BY NAME today,
21081+ /// so that half of the gate compares nothing yet (class
21082+ /// `counter-from-refused-stream`); the census is 10x "an inter SB-level AB
21083+ /// partition", 6x "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs
21084+ /// rectangular residual coding", 6x "an 8x8 intra leaf in an inter frame
21085+ /// whose tx_depth splits it into 4x4 transform units", 5x "an inter
21086+ /// partition below 8x8", 3x "an inter 16x16-level AB or 1:4 partition",
21087+ /// 1x "a split intra strip whose transform unit is 32x64", 1x "an
21088+ /// intra-coded 1:4 (or other non-2:1) rect strip on the inter block path".
21089+ /// The arms stay so the coverage appears the day those lift; every assert
21090+ /// below is carried by the single-tile arms.
21091+ /// Hard-asserts `decode::cdef_straddle_units()` grew: a FILTERED 8x8 CDEF
21092+ /// unit whose extent crosses the crop edge is the only shape for which
21093+ /// clamping and padding differ, so a zero delta would make these arms
21094+ /// vacuous for this defect.
21095+ #[test]
21096+ fn a_frame_edge_straddling_band_decodes_pixel_exact() {
21097+ edge32_gate(
21098+ "a_frame_edge_straddling_band_decodes_pixel_exact",
21099+ false,
21100+ );
21101+ }
21102+
21103+ fn edge32_gate(name: &str, flat_band: bool) {
21104+ let NAME = name;
lanes/cdef-r1.handoff.mdadded+66 -0
@@ -0,0 +1,66 @@
1+# lane-cdef r1 -- HANDOFF (2 CDEF defects rooted, both fixed, gate GREEN; one residue open)
2+
3+Base: main 48b35ab. Suite unit `cdef-suite-1788330834.service` -> `$HOME/.cache/cdef-suite-r1.log`
4+(started at the turn cap; FIRST THING NEXT ROUND: `grep -E "^test result|FAILED" $HOME/.cache/cdef-suite-r1.log`).
5+
6+## Defect A -- per-8x8 CDEF skip band never written by the 8x8 inter leaf (charter hypothesis (a), variant)
7+
8+* Stream: `~/.cache/cdef-tmp/a0_8.obu`, sha256 `aa40f17f6e49eca2bb8c9d9ab99a175312134bdcf45c39b8a76b6757d8536751`
9+ (hashed twice, identical), `~/.cache/cdef-tmp/gen.sh 8 3 8 a0_8.obu` = lane-intersub8's recipe,
10+ 192x128, 6 frames, `--min-partition-size=4`, cq 8, 8-bit.
11+* Stage attribution: reconstruction and post-deblock are EXACT (`EC_AV1_POSTDEBLOCK_DUMP` ours vs
12+ the instrumented aomdec: 0/24576 luma on decode-order frame 3); the 3 samples enter at CDEF.
13+ NOTE: aomdec's `EC_AV1_PREFILT_DUMP` is ALREADY POST-DEBLOCK on this build (r_pre.fN == r_pd.fN
14+ for 5 of 6 frames) -- ours is genuinely pre-deblock, so the two rungs are NOT the same stage.
15+* Root cause: `decode_inter_block8` (decode.rs, the leaf path `--min-partition-size=4` picks for a
16+ 16x16 group) wrote `record_mi` + `fill_lf_grid` at both exits but NEVER `fill_skip_grid`. The
17+ bottom-right 16x16 of decode-order frame 3 was therefore judged by the PREVIOUS frame's flags:
18+ our 8x8 units at mi(28,46)/(30,46) read skip=false and were filtered, while libaom's
19+ `is_8x8_block_skip` (cdef.c:29-38, called from `av1_cdef_compute_sb_list` cdef.c:40-71) excludes
20+ an all-skip 8x8 from the dlist. Proof: a python model of `cdef_block.c` reproduces the reference
21+ for all 16 units of the last column at (sec=1,damp=3) EXCEPT those two, where only "unfiltered"
22+ matches; frame-3 fill log showed 0 of 95 skip fills covering mi(28,44)+16x16.
23+* Fix: `neighbours.fill_skip_grid(leaf_mi, 2, skip)` at both `decode_inter_block8` exits (compound
24+ early return + fall-through), each bumping `INTER8_SKIP_BAND_HITS`.
25+* Before/after on the pinned stream: frames 3 and 4 had 3 luma samples |d|=1 each
26+ ((189,116/120/124) and (186,116/120/124)); after, all 6 frames pixel-exact on Y/U/V.
27+
28+## Defect B -- CDEF direction search clamped at the crop edge instead of reading CDEF_VERY_LARGE
29+
30+* Stream: `~/.cache/golomb-tmp/s68.obu` (68x192, 5 frames, 8-bit, cq 35) -- lane-golomb r9's
31+ deferred "straddle band".
32+* Root cause: `apply_cdef`'s `cdef_find_dir` closure clamped to `true_w-1`/`true_h-1`, but libaom
33+ runs `cdef_find_dir` over `cdef_prepare_fb`'s buffer (cdef.c:249-256 `frame_boundary[RIGHT]`
34+ fill, cdef_block.c:296-320), whose columns/rows past the mi-rounded extent are CDEF_VERY_LARGE.
35+ With odd `mi_cols` (68 px -> 17 mi) the last 8x8 straddles, so var/`adjust_strength` differed.
36+* Fix: the direction search now reads the SAME padded `sample_y` the taps use (one line).
37+* Before/after: frame 1 luma 145 diffs -> **0**; all 5 frames luma exact.
38+* RESIDUE (open, NOT fixed): the same stream still differs in CHROMA from frame 1 on
39+ (U/V 194/401/466/551 samples, |d| up to 6, spread over ~37 chroma 4x4 units, frame 0 exact).
40+ Not attributable yet: `EC_AV1_DEBUG_SKIP_CDEF=1` cannot bisect inter frames (it also breaks the
41+ reference frames), so the postdeblock rung is only valid for frame 0 here. Next step: dump
42+ per-4x4 chroma CDEF params (uv pri/sec, damping-1, shared luma dir) for frame 1's first
43+ differing unit and model it against `cdef_block.c` the way defect A was modelled
44+ (`~/.cache/cdef-tmp/model.py` is a complete python port of cdef_block.c + find_dir + adjust).
45+
46+## Gate
47+`stream.rs::a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact` -- real
48+aomenc, `--min-partition-size=4 --enable-cdef=1` (last flag wins), 5 arms (8-bit cq 8/10/12,
49+10-bit cq 8/12), every decode-order frame compared on Y/U/V, hard asserts
50+`decode::cdef_skipped_units()` (an 8x8 unit really excluded by the all-skip rule) and
51+`decode::inter8_skip_band_hits()` (the leaf that used to write nothing) both grew per compared
52+attempt. 2 of 5 arms fire; the other 3 hit UNRELATED open refusals (non-DC chroma mode on an 8x8
53+inter leaf; inter partition below 8x8) -- widening to 10-bit needs those lifted first.
54+`cargo test -p ec-av1 --lib cdef_and_sub16` -> ok, 1 passed / 0 failed.
55+
56+## Other
57+* `dump_stage`/`dump_stage16` wrote `.f0` for EVERY frame (each overwrote the last), so
58+ `EC_AV1_POSTDEBLOCK_DUMP`/`POSTCDEF_DUMP` were unusable for per-frame bisection. Now indexed
59+ per env var (`dump_stage_idx`), matching aomdec's own `.fN`.
60+* New rung `EC_AV1_CDEF_DBG=1`: one line per filtered 8x8 luma unit
61+ (`EC_CDEF mi_r= mi_c= x= y= sidx= dir= var= t= pri= sec= damp=`).
62+* Class sweep for "per-8x8 map read at the top-left mi only under sub-8x8 partitions": the skip
63+ grid is written by every OTHER leaf path (grep `fill_skip_grid`), `decode_inter_block8` was the
64+ only writer missing; `is_skip_txfm` already gathers all four cells; the deblock/tx grid has a
65+ `fill_lf_grid` at every one of those sites including both `decode_inter_block8` exits.
66+* Not done: `--tile-columns=1` arm on the new gate (COMMON neighbour-map rule) -- deferred.
lanes/cdef-r2.report.mdadded+83 -0
@@ -0,0 +1,83 @@
1+# lane-cdef r2 report -- merge, the 68x192 chroma residue CLOSED, gate un-ignored
2+
3+Branch `lane-cdef`, base main `727f29a`. Commits this round:
4+* `32a467a` Merge main 727f29a (lane-r14, lane-kf1200, lane-reelckf) -- no conflicts.
5+* `0e6c5c9` Merge lane-golomb 173b793 -- 2 conflicts in `decode.rs`, both resolved (below).
6+* `26b971a` straddling-band gate un-ignored + `CDEF_STRADDLE_UNITS` counter + multi-tile arms.
7+
8+`cdf.rs` is byte-identical across `main`, `lane-golomb` and this tree
9+(`sha256 655f9a45ccedf7e37adab8b46703cf7ec4c9cc395978a1e6179157741def5844`, all four).
10+
11+## r1's leftover suite unit
12+`cdef-suite-1788330834.service` was still RUNNING at the start of this round; it had reached
13+**184 tests ok, 0 FAILED / 0 panics** with no `test result` line yet. Stopped (its target dir is
14+this lane's) and superseded by the r2 run below.
15+
16+## Merge conflicts (decode.rs), resolved
17+1. `dump_stage`'s per-decode-order-frame index: both lanes added one. Kept this lane's shared
18+ `dump_stage_idx()` helper (`dump_stage16` uses it too), dropped lane-golomb's duplicate
19+ `thread_local` counter.
20+2. The var-tx leaf loop (`decode.rs:19323`): took **main's** general `(row, col, tw, th)` rect
21+ leaves and **lane-golomb's** `fill_lf_grid_leaf_luma` writer. Routing a rect leaf through
22+ `fill_lf_grid_rect` would recompute the CHROMA tx dims from the leaf span; libaom's
23+ `get_transform_size` (`av1/common/av1_loopfilter.c:207`) applies the split override only for
24+ `plane == AOM_PLANE_Y`. Class `table-and-reader-move-together`: table (leaf tuple) from main,
25+ writer from golomb, both re-gated below.
26+
27+## Charter item (2) -- the 68x192 CHROMA residue: CLOSED, and it was NOT a chroma-CDEF defect
28+The charter's hypotheses (chroma `hsize >> xdec` fill, `damping - 1`, `uv_pri/uv_sec`, shared luma
29+`dir`, `coeff_shift`, the 8x8 skip band) were each checked against the oracle source and all six
30+were **already correct** in `apply_cdef`:
31+* right/bottom pad bound: `sample_uv` bounds at `plane.true_width/true_height`, which is
32+ `mi_cols * 4 / 2` (`decode.rs:13388`) = 36 for a 68-px axis -- exactly libaom's
33+ `hsize = nhb << mi_wide_l2` with `mi_wide_l2 = MI_SIZE_LOG2 - subsampling_x`
34+ (`cdef.c:164-167`), the fill starting there being `cdef.c:249-256`.
35+* `damping += coeff_shift - (pli != AOM_PLANE_Y)` (`cdef_block.c:337`) == our `damping_uv`.
36+* chroma `t = pri_strength`, NOT `adjust_strength` (`cdef_block.c:387`) == ours.
37+* `pri_strength ? dir[by][bx] : 0` per plane (`cdef_block.c:392`) == ours; the `conv422/conv440`
38+ direction remap is `if (pli == 1 && xdec != ydec)` (`cdef_block.c:361-369`), i.e. never in 4:2:0.
39+* `level`/`sec_strength` from `cdef_uv_strengths[mbmi_cdef_strength]` with the `== 3` bump
40+ (`cdef.c:325-333`) == ours; block size `8 >> xdec` by `8 >> ydec` == our 4x4.
41+
42+The residue was the **loop restoration plane size**, fixed on lane-golomb r8 and merged this
43+round: LR is the one post-decode filter sized by the CROP (`av1_get_upsampled_plane_size`,
44+`restoration.c:47`, asserted against the crop at `restoration.c:1106`), while deblock and CDEF walk
45+the mi grid. With both branches' fixes in one tree all four straddling arms are exact on Y, U and V.
46+
47+EVIDENCE: /home/user/.cache/cdef-strad-r2.log | merged tree, `cargo test -p ec-av1 --lib -- --ignored --nocapture a_frame_edge_straddling_band` (192x68 + 68x192, 5 frames, 8+10-bit, cq 35..61) | 14 pixel-exact attempts (Y, U and V, every shown frame), 0 differing pixels, 18 named refusals, test result ok 1 passed / 0 failed
48+
49+## Charter item (3) -- `--tile-columns=1` arms: added, and VACUOUS today
50+Each straddling arm gained a `--tile-columns=1` twin (8 arms x 8 cq = 64 attempts). All 32
51+multi-tile attempts refuse **by name**; census (in the test's doc comment):
52+10x "an inter SB-level AB partition", 6x "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs
53+rectangular residual coding", 6x "an 8x8 intra leaf in an inter frame whose tx_depth splits it into
54+4x4 transform units", 5x "an inter partition below 8x8", 3x "an inter 16x16-level AB or 1:4
55+partition", 1x "a split intra strip whose transform unit is 32x64", 1x "an intra-coded 1:4 rect
56+strip on the inter block path". Class `counter-from-refused-stream`: that half of the gate compares
57+nothing yet and every assert is carried by the single-tile arms. Arms kept so the coverage appears
58+the day those refusals lift.
59+
60+## Gate
61+`stream.rs::a_frame_edge_straddling_band_decodes_pixel_exact` -- **un-ignored** (was
62+`#[ignore] "open r9 defect"`). Hard-asserts the new `decode::cdef_straddle_units()` grew: a FILTERED
63+8x8 CDEF unit whose extent crosses the cropped frame edge is the only shape for which "clamp at the
64+crop" and "pad with CDEF_VERY_LARGE past the mi-rounded extent" differ, so a zero delta would make
65+these arms vacuous for this defect.
66+
67+EVIDENCE: /home/user/.cache/cdef-strad2-r2.log | `cargo test -p ec-av1 --lib -- --nocapture a_frame_edge_straddling_band` on the final tree | 14 pixel-exact attempts, **337 straddling CDEF units**, 50 named refusals, ok 1 passed / 0 failed in 33.99s
68+
69+Sibling gate (same tables/paths -- `apply_cdef`, the skip band, `fill_skip_grid`):
70+EVIDENCE: /home/user/.cache/cdef-sib-r2.log | `cargo test -p ec-av1 --lib -- --nocapture cdef_and_sub16` | a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact ok, 1 passed / 0 failed
71+
72+## Suite
73+EVIDENCE: /home/user/.cache/cdef-suite-r2.log | `systemd-run --user --unit=cdef-suite-r2-... -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3` on `646f2d3`'s tree | **386 passed, 0 failed, 34 ignored** in 1009.29s (r1's tree had 385/0/35 -- one test moved out of `ignored` and into `passed`: this round's un-ignored straddling gate)
74+
75+## Refusals
76+None lifted this round, so `refusal_inventory.rs` is unchanged. `gate_coverage.rs` needs no entry
77+either: its derivation deliberately excludes `--tile-columns` (see its header comment) and this
78+round adds no `--enable-*` flag.
79+
80+## Residue
81+* deferred(the 7 refusals in the census above) -- the multi-tile half of the straddling gate.
82+* accepted -- the gate compares SHOWN frames (`ffmpeg_decode_sequence`); no-show alt-ref frames are
83+ not compared here, same as every sibling gate (class `gate-blind-to-hidden-frames`).
lanes/golomb-r1.report.mdmodified+68 -0
@@ -45,3 +45,71 @@ desyncing.
45 correctly decoded as HORZ, on an INTER superblock row the inter path cannot code (rect inter45 correctly decoded as HORZ, on an INTER superblock row the inter path cannot code (rect inter
46 residual coding does not exist here). Next lane.46 residual coding does not exist here). Next lane.
47 - `reelb5.obu`: "a 32x32-level 1:4 strip with a split transform (depth=2)" (unchanged by this lane).47 - `reelb5.obu`: "a 32x32-level 1:4 strip with a split transform (depth=2)" (unchanged by this lane).
48+
49+---
50+
51+# lane-golomb r2 — the 32x32-level frame-edge HORZ/VERT second half
52+
53+## Must-fix (verifier golomb1): fixed
54+Since r1 the 32-level edge read can return HORZ/VERT (bit 0), so the second 32x16/16x32 half is
55+out of frame and must not be decoded. libaom `decode_partition`:
56+`case PARTITION_HORZ: decode_block(top); if (has_rows) decode_block(bottom)` (mirror for VERT).
57+
58+- `crates/ec-av1/src/decode.rs:10887` (intra `PARTITION_HORZ` @32) — second 32x16 now behind `if has_rows32`.
59+- `crates/ec-av1/src/decode.rs:10928` (intra `PARTITION_VERT` @32) — second 16x32 behind `if has_cols32`.
60+- `crates/ec-av1/src/decode.rs:17900` (inter `PARTITION_HORZ` @32) — same guard, `has_rows32`.
61+- `crates/ec-av1/src/decode.rs:18008` (inter `PARTITION_VERT` @32) — same guard, `has_cols32`.
62+- `crates/ec-av1/src/decode.rs:1600` — new `EDGE32_HITS` counter (+ `edge32_hits()`, `bump_edge32`):
63+ slot 0/1 = 32-level edge bit read as HORZ/VERT vs SPLIT, slot 2 = a bottom-edge HORZ strip
64+ decoded (`has_rows32 == false`), slot 3 = a right-edge VERT strip.
65+
66+AB / 1:4 arms at the 32 level need NO guard: at an edge libaom's `ec_read_partition_impl` can only
67+yield HORZ, VERT or SPLIT, so those arms are unreachable there (stated per charter).
68+16-level edge rect arms swept and left as they are: intra refuses by name
69+("a 16x16 block at the true frame edge coded as a rect strip rather than SPLIT"), inter falls to
70+"an inter partition below 16x16 other than SPLIT".
71+
72+## Gate
73+NEW `stream::tests::a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition_decodes_pixel_exact`
74+(crates/ec-av1/src/stream.rs:14800+): 192x80 (bottom edge, mi_rows=20) and 80x192 (right edge),
75+testsrc2 + seeded `noise`, cq {35,40,45,50,55,57,59,61}, 8-bit AND 10-bit (bit_depth asserted),
76+plus a 5-frame INTER arm; every decode pixel-compared against ffmpeg, counters sampled per attempt
77+and summed only over compared attempts.
78+
79+EVIDENCE: $HOME/.cache/golomb-suite-r2.log + gate stdout | cargo test -p ec-av1 --lib -- --nocapture
80+a_real_aomenc_stream_with_a_32x32_frame_edge | 32 pixel-exact attempts, 8 named refusals,
81+edge32 bits [horz_or_vert=0 split=178] — the 32-level edge read fires 178 times and every attempt
82+decodes pixel-exact.
83+
84+Recipe deviations from the charter, with reasons (measured, not assumed):
85+- `--min-partition-size=32`, not 8: at 8 (and at 16) the sub-16 AB / split-transform strip arms
86+ refuse by name before the 32-level edge is reached — 40/40 attempts refused.
87+- `--tune-content=film` + `noise`: without them aomenc's screen-content detection makes every
88+ attempt refuse at "a HORZ/VERT intra strip in a screen-content frame" (the verifier's smptebars
89+ trap, reproduced here with plain testsrc2).
90+
91+## OPEN DEFECT (fix-now, next round) — the edge HORZ strip's pixels
92+With detail in the straddling band aomenc always answers the edge bit with SPLIT (178/178), so the
93+HORZ/VERT arm never fires. Leaving that band FLAT (`pad=...:gray`) forces it:
94+EVIDENCE: gate stdout | cargo test -p ec-av1 --lib -- --ignored --nocapture
95+a_32x32_frame_edge_rect_partition_with_a_flat_band | 192x80 cq40 8-bit, `edge32=[2, 0, 2, 0]`
96+(two bottom-edge HORZ strips decoded), plane Y 1081 pixels differ, first at row 62 col 128,
97+diffs per row confined to rows 62..79 (~64 of 192 columns) — exactly the two 32x16 strips plus the
98+deblock bleed above them; every other pixel of the frame matches ffmpeg.
99+Reading: the guard itself is validated (no desync — the rest of the frame is entropy- and
100+pixel-exact where before it would have consumed an out-of-frame half), but the strip's own
101+reconstruction (prediction/neighbour availability at the frame edge) is wrong. Pinned as
102+`#[ignore]`d test `a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact` so the
103+suite stays green and the defect stays runnable. Disposition: fix-now for r3 (owner: this lane).
104+
105+## Suite (r2)
106+`$HOME/.cache/golomb-suite-r2.log` — **337 passed / 1 FAILED / 32 ignored** (618 s).
107+The failure is NOT this round's arm and I could not attribute it to this diff:
108+`stream::tests::a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16_decodes_pixel_exact`
109+panics at stream.rs:8479 "the stream decoded but no coded (non-skip) rect leaf fired". Its fixture
110+is a 64x64 mandelbrot frame — one whole superblock, `mi_cols = mi_rows = 16`, so
111+`has_rows32`/`has_cols32` are true everywhere and none of this round's four guards (nor r1's
112+edge reads) can execute on it. Deterministic (fails standalone in 0.34 s, same message).
113+Disposition: deferred(a bisect of eacd7fd vs 3e4ce89 in a detached worktree, or the owner of
114+`rect_leaf_coeff_hits`) — it is either pre-existing on eacd7fd (r1's suite log predates today's
115+oracle/ffmpeg state) or a sibling-gate regression from a path I did not touch. NOT claimed green.
lanes/golomb-r3.report.mdadded+106 -0
@@ -0,0 +1,106 @@
1+# lane-golomb r3 — the suite red was my own gate recipe; the edge strip was out-of-frame transform units
2+
3+## TASK 1 — bisect table (the r2 suite failure)
4+
5+`stream::tests::a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16_decodes_pixel_exact`,
6+run in a detached scratch worktree (`scratchpad/verify-golomb`, `CARGO_TARGET_DIR=~/.cache/cargo-target-verify`):
7+
8+| commit | what it is | result |
9+|---|---|---|
10+| a762fff | mcomp64 base | ok, 1 passed |
11+| 909064f | + fi8 cherry-pick 2d5c425 | ok, 1 passed |
12+| eacd7fd | r1 edge-bit fix | ok, 1 passed |
13+| fd54bcf | r2 guards | **FAILED** — "the stream decoded but no coded (non-skip) rect leaf fired" |
14+
15+EVIDENCE: bisect stdout above | `git worktree add --detach` at each sha, `cargo test -p ec-av1 --lib -- a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16` | 3 ok / 1 FAILED, first red = fd54bcf
16+
17+Root cause: **not** fi8, not the r1 edge read. r2's per-arm recipe override
18+(`--min-partition-size=32 --tune-content=film`) was pasted into the WRONG gate — hunk
19+`stream.rs@8435`, inside `a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16`, whose whole
20+point is sub-16x16 rect leaves. At `--min-partition-size=32` that 64x64 mandelbrot frame cannot
21+contain a 16x8 leaf, so `rect_leaf_coeff_hits` went to 0 and the gate's own
22+"the gate proves nothing" assert fired — the assert did its job. Fixed in ebec75d by restoring
23+`--min-partition-size=8`; the edge32 gate has always carried its own copy of the override.
24+No warning is owed to the fi8 merge agent: fi8 is already on main (b1d8457) and is exonerated by
25+row 2 of the table.
26+
27+EVIDENCE: gate stdout | `cargo test -p ec-av1 --lib -- --nocapture a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16` after ebec75d | `pixel-exact, rect_leaf_coeff_hits=8`, 1 passed
28+
29+## TASK 2 — the frame-edge strip's wrong pixels: out-of-frame transform units
30+
31+Class: `parsed-then-discarded`'s mirror — *read* something the reference never wrote
32+(`equal-range-means-unread`).
33+
34+Reproduced standalone (192x80 cq40 8-bit flat band, md5 `4bd18b25…`, scratchpad `e32.obu`):
35+1081 Y pixels differ, rows 62..79, **cols 124..191** — the LAST superblock only.
36+
37+The oracle's own view of that superblock row (instrumented aomdec):
38+`EC_PRED mi_row=16 mi_col=16 … bsize=11 part=1 txw=16 txh=16` with **row_off=0 only** (four TUs),
39+and `mi_row=16 mi_col=32 … bsize=11 part=1 txw=32 txh=32` (two TUs). `bsize=11` is
40+`BLOCK_64X32`: aomenc answers the bottom-edge superblock with the **64-level** `PARTITION_HORZ`,
41+never the 32-level one, and codes only the transform-unit ROW that is inside the frame.
42+
43+Ours decoded `mi_col=16` identically (`TRACE_RECT_SPLIT bw=64 bh=32 tx=16`) but then walked
44+`bh/tx = 2` TU rows, reading coefficients for four phantom 16x16 units at y=80..95 — outside a
45+frame whose `mi_rows*4 == 80`. That desynced the stream at exactly the next symbol: the SB2
46+partition bit came out SPLIT (two 32x16 strips, `edge32=[2,0,2,0]`) where the oracle read HORZ.
47+The r2 report's reading ("prediction/availability inside the strip") was wrong; the strips
48+were the *symptom* of a desync, and the "32-level edge HORZ fired" counter was a
49+`counter-from-refused-stream`-shaped artefact of our own desync.
50+
51+Fix — `crates/ec-av1/src/decode.rs:4818` (`decode_rect_split`, the only place a block hangs off
52+the frame): skip a transform unit whose top-left sample is outside `true_width`/`true_height`
53+(`mi_cols*4`/`mi_rows*4`), mirroring libaom `av1_foreach_transformed_block_in_plane`'s
54+`max_blocks_wide/high` clip (`mb_to_right_edge`/`mb_to_bottom_edge`). The chroma unit of a strip
55+always has its top-left inside, so it is unaffected.
56+
57+EVIDENCE: scratchpad/{e32.obu, ours.yuv, ao.yuv, ao-pred.txt, ours-step.txt} | instrumented
58+aomdec `EC_PRED`/`EC_TRACE_MODE_STEP` vs `decode_probe`, byte diff of the two raw yuv420p dumps |
59+before: 1081 Y pixels differ (first diff at our `EC_ISTEP mi_row=16 mi_col=32 name=skip rng=51413`
60+vs oracle `rng=32901`); after: **0 differing bytes over all three planes**
61+
62+## Counters + the pin, un-ignored
63+
64+`EDGE32_HITS` widened 4 → 8 slots (`decode.rs:1602`): slots 4/5 = the **64**-level gathered edge
65+bit read as HORZ/VERT / SPLIT (both tile paths), 6 = a 64x32 bottom-edge strip decoded with
66+`has_rows == false`, 7 = a 32x64 right-edge strip. Necessary because the flat-band arm's r2
67+assert (`totals[2] > 0`, a 32-level bottom-edge HORZ) was only ever satisfied by our own desync;
68+on a correct decode of this content the 32-level slots are 0 by construction and the 64-level
69+slots carry the proof. `#[ignore]` removed from
70+`a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact`.
71+
72+EVIDENCE: gate stdout | `cargo test -p ec-av1 --lib -- --nocapture a_32x32_frame_edge` |
73+2 passed; flat arm: 32 pixel-exact attempts, 64-level edge bits [horz_or_vert=96 split=0]
74+bottom-HORZ=48 right-VERT=48, 32-level slots all 0; detail arm: 32 pixel-exact attempts,
75+64-level [horz_or_vert=7 split=89] right-VERT=7, 32-level split=178
76+
77+## Suite
78+`$HOME/.cache/golomb-suite-r3.log` — **339 passed / 0 failed / 31 ignored** (277 s), run as a
79+user systemd unit on the final tree. r2 was 337/1 FAILED/32 ignored: +1 fixed (task 1), +1
80+un-ignored (task 2).
81+
82+Siblings re-run inside that suite, all green: `a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16`,
83+`the_reelb_head_key_frame`, both `a_*_32x32_frame_edge_*`, `tiny_frame_size_sweep`,
84+`superblock_level_*`, `filter_intra_*`, `refusal_inventory`, `gate_coverage`.
85+
86+## Same-shape sweep
87+`decode.rs:7458` (`decode_block`'s square multi-TU loop) has the identical unclipped
88+`0..n_axis` shape and now carries the identical guard. A square block only hangs off the frame
89+when the frame's mi dimensions are odd at that block's level (lane-oddh's territory), so no gate
90+in this suite reaches it: the guard is libaom's rule applied by inspection, proven only inert
91+here (suite unchanged). `decode_block_rect64` delegates its split case to `decode_rect_split`,
92+so it is covered by the measured fix. Flagged, not claimed.
93+
94+## Film
95+`hg-head.obu` (18 frames) still stops at
96+"an inter SB-level partition type other than NONE or SPLIT (this decoder's inter tile path
97+recurses a superblock only as SPLIT)" — unchanged by this round (same string as r1's residue;
98+the inter tile path never reaches a 64-level HORZ).
99+EVIDENCE: probe stdout | `cargo run -p ec-av1 --example decode_probe -- hg-head.obu` | REFUSED at
100+the inter SB-level partition, 18 frame headers parsed, tiling cols=1 rows=1
101+
102+## Residue
103+- deferred: the inter tile path's 64-level `PARTITION_HORZ`/`VERT` (the film's next blocker) —
104+ unblocked by rect inter residual coding, which is lane-inter*/interbis territory, not this one.
105+- accepted: the square-block guard above is unexercised by any gate on this lane (odd-mi
106+ geometry is lane-oddh's gate).
lanes/golomb-r4.report.mdadded+93 -0
@@ -0,0 +1,93 @@
1+# lane-golomb r4 — merge with main, and the 32x32-frame-edge cross-product isolated (NOT fixed)
2+
3+## STEP 1 — merge (DONE, commit 17fc2a7 `Merge branch 'main' into lane-golomb`)
4+
5+`git merge main` (main b51719f) conflicted in 4 files; 14 hunks in `decode.rs`.
6+Resolution (all by hand, no `cargo fmt`):
7+
8+* `crates/ec-av1/src/cdf.rs`, `crates/ec-av1/src/cdf_state.rs` — main's, whole.
9+* `crates/ec-av1/src/decode.rs`
10+ * fi32x8 rows `(32,8)=>10 / (8,32)=>11` in `filter_intra_size_class`: main's.
11+ * `decode_rect_split`'s TU loop: main's rect `tx_w`/`tx_h` form, with golomb r3's
12+ TU-ORIGIN CLIP re-applied per axis inside it
13+ (`if tu_px >= y.true_width || tu_py >= y.true_height { continue; }`).
14+ * oddh's 16-level edge HORZ/VERT strip (replaces golomb's refusal): main's.
15+ * golomb's 6 edge-bit counter sites (`bump_edge32` / `bump_edge32_bit`) and the
16+ 64-level + 32-level SECOND-HALF guards: kept, re-applied on top of inter4's
17+ MI-unit `decode_inter_block` signature (`sub16_to_mi(...)`) at both inter
18+ SB-level HORZ (`edge32` slot 2) and VERT (slot 3) arms.
19+* `lanes/golomb-r1.report.md` — lane's.
20+
21+`cargo check -p ec-av1` + `cargo test -p ec-av1 --lib --no-run`: clean.
22+
23+## STEP 2 — the cross-product: ISOLATED to one block, root cause NOT yet found
24+
25+Gate `a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition_decodes_pixel_exact`
26+still FAILS on the merged tree, identically to merge-E's report:
27+`192x80 cq59 frames=5 8-bit frame 1 plane Y: 90 pixels differ, first at row 61 col 174
28+(ours 175 vs ffmpeg 174) [edge32=[1, 35, 1, 0, 0, 18, 0, 0]]`.
29+
30+Stream reproduced standalone (md5 `48e1d78f31a4eb6a6ef5a67df9bd36fe`, 971 B):
31+`ffmpeg -f lavfi -i "testsrc2=size=192x80:duration=0.2:rate=25,noise=alls=6:allf=t+u:all_seed=59"
32+ -pix_fmt yuv420p ... | aomenc <the gate's flags> --cq-level=59` (script in the handoff).
33+
34+### What the facts say (each with its command)
35+
36+1. **The first divergent picture is DECODE-order picture 2, not shown-frame 1.**
37+ `EC_AV1_PREFILT_DUMP` on both decoders, luma compared per picture:
38+ f0 0 diffs, f1 0, **f2 130**, f3 84, f4 110. The shown-frame-1 report is the
39+ propagated copy. (Class `gate-blind-to-hidden-frames` applies to the READING of
40+ the gate message, not to the gate.)
41+2. **The wrong pixels are exactly one 16x16 block**: picture 2, rows 64..79 x
42+ cols 160..175 = mi(16,40), max |delta| 36 — a prediction-scale error, not rounding.
43+3. **libaom decodes mi(16,40) as SPLIT into two 16x16 leaves in every picture**
44+ (`EC_TRACE=1 aomdec | grep 'mi_row=16 mi_col=40 bsize=9'` → `value=3` x6);
45+ **we decode a 32-wide HORZ strip there in picture 2 only**
46+ (`EC_AV1_COMPIDX_DUMP=1` → `mi_row=16 mi_col=40 bsize=32 mode=0 mv0=(-30,-20)
47+ mv1=(16,0) ref0=1 ref1=7`, where libaom has `mode=18 (NEAR_NEARMV) mv0=(-16,0)`).
48+ That is inter4's SB/32-level inter rect arm consuming golomb's frame-edge bit —
49+ a path neither parent could reach.
50+4. **The edge bit is NOT the defect.** Instrumented pre-read state at the 32-level
51+ gathered read (temporary `DBG32PRE`, reverted): ctx = 2 (= libaom's 10 = bsl 2 * 4 + 2),
52+ CDF row and 2-entry gather identical in all 6 pictures, and the pre-read RANGE
53+ matches aomdec's `EC_PART ... rng=` in 11 of 12 reads. The one mismatch is
54+ picture 2 at mi(16,40): ours 39967, libaom 64226 — i.e. **we arrive at the bit
55+ already desynced**, and the wrong HORZ is the consequence.
56+5. **The desync starts inside the 16x16 INTER block at mi(16,32), picture 2.**
57+ Range ladder (ours `EC_AV1_TELL`/`EC_TRACE_MODE` vs aomdec `EC_TRACE_MODE`):
58+ * mi(16,32) entry / post_is_inter: ours 52732 == libaom `EC_MODE ... rng=52732`.
59+ * libaom then reads compound NEAR_NEARMV `ref0=1 ref1=7 mv0=(0,0) stack=3`
60+ (`EC_MODE_MV rng=39839`, `EC_MODE_VAL rng=56231`) and leaves the block at 62618.
61+ * ours leaves the block at 35347 (`TELL ... label=block_end tell=232 range=35347`),
62+ having consumed ~1 bit: no `EC_MODE_VAL` (single-ref print) and no `EC_COMPIDX`
63+ line for that block at all.
64+ So we read FEWER symbols than libaom for a `skip=true`, `is_inter=true` compound
65+ block at the bottom frame edge. First divergent element: the symbol(s) after
66+ `intra_inter` in `decode_inter_block` at mi(16,32) (ref-frame / compound-mode
67+ group), picture 2.
68+6. Coefficient ladders are otherwise identical (6426 aligned
69+ `EC_COEFF_STEP tag=base|sign|all_zero|eob|base_eob|after_bases|post_golomb` rng
70+ values, `diff` empty), so this is a LOCAL symbol-count divergence in one block
71+ that re-converges, not a whole-tile desync.
72+
73+EVIDENCE: /tmp/.../scratchpad/{ours,aom}.f0..f5 | `EC_AV1_PREFILT_DUMP` both decoders on g4.obu | first divergent picture = 2, diff box rows 64..79 x cols 160..175 (130 px, max 36)
74+EVIDENCE: /tmp/.../scratchpad/{o,a}-cf.txt | `EC_TRACE_COEFF=1` both decoders, aligned tags | 6426 == 6426 lines, `diff` empty (entropy re-converges)
75+EVIDENCE: /tmp/.../scratchpad/{ours,aom}-mode.txt + tell.txt | `EC_TRACE_MODE` / `EC_AV1_TELL` ours vs aomdec | mi(16,32) p2 entry 52732 == 52732, exit ours 35347 vs libaom 62618
76+
77+## Status / disposition
78+
79+* merge: DONE and committed.
80+* the 32x32-frame-edge cross-product: **OPEN — fix-now, next round**, isolated to
81+ the symbol group read after `intra_inter` for the compound block at mi(16,32) in
82+ picture 2. Not a golomb-side defect in the edge bit (fact 4).
83+* verifier's r3 item (no `max_blocks_wide/high` clip on the INTER var-tx leaf loops
84+ at `decode.rs` ~14135 / ~14970, plus a 192x68 / 68x192 gate arm with a
85+ straddling-TU counter): **deferred — turn budget spent on the cross-product
86+ isolation above — unblocked by a fresh round; nothing about it is contradicted
87+ by this round's findings.**
88+
89+## Suite
90+
91+`cargo test -p ec-av1 --lib` (systemd unit, log `$HOME/.cache/golomb-suite-r4.log`): **364 passed, 2 failed, 31 ignored** in 547 s.
92+Failure 1 = the stale golomb refusal string `"a 16x16 block at the true frame edge coded as a rect strip rather than SPLIT"` still listed in `refusal_inventory.rs` after the merge took oddh_s lifted strip -- deleted in the follow-up commit (refusal_inventory 3/3 green after).
93+Failure 2 = the open cross-product above.
lanes/golomb-r5.report.mdadded+109 -0
@@ -0,0 +1,109 @@
1+# lane-golomb r5 — the 32x32-frame-edge cross-product ROOT-CAUSED and fixed (luma exact); gate still RED on a newly-exposed chroma defect
2+
3+## What changed
4+
5+* `crates/ec-av1/src/mvstack.rs:1663-1703` (commit `13aebbe`) — `find_mv_stack_compound`
6+ now runs libaom's three `tpl_sample_pos` EXTENSION samples
7+ (`mvref_common.c:563-600`, `allow_extension` + `check_sb_border` at
8+ `mvref_common.c:316`, mask hardcoded `mi_size_wide[BLOCK_64X64]`=16). The
9+ single-ref twin (`mvstack.rs:863-891`) already carried them; the compound
10+ path dropped them. Same hunk as lane-sb128 `d6cca7d` (independent lane, same
11+ root cause found from the other end).
12+
13+Nothing else. The r4 debug ladder used to find this was removed before commit.
14+
15+## Root cause (H3 of the charter; H1 skip_mode and H2 comp-ref ctx both exonerated)
16+
17+Charter's isolated element: `192x80 cq59 frames=5 8-bit`, DECODE-order picture 2,
18+16x16 inter block at mi(16,32), entry range 52732 == libaom, exit ours 35347 vs
19+libaom 62618.
20+
21+A temporary compound range ladder (`EC_LAD` after `read_comp_mode`, after
22+`read_compound_ref_frames`, after `read_inter_compound_mode`, after
23+`assign_compound_mv`) showed:
24+
25+| element | ours (before) | libaom |
26+|---|---|---|
27+| block entry (post `intra_inter`) | 52732 | 52732 |
28+| `is_compound` | true | true |
29+| ref pair | `ref0=1 ref1=7` | `ref0=1 ref1=7` |
30+| **compound stack** | **2 entries** `[(-16,0)/(14,0) w=672, (0,0)/(0,0) w=672]` | **3 entries**, same two + `(-10,0)/(10,0) w=2` |
31+| compound mode | 1 = `NEAR_NEARMV` | 18 = `NEAR_NEARMV` |
32+| post-mv | 50080 | 39839 |
33+
34+So `skip_mode` and the whole reference-frame group were already right (H1/H2 dead).
35+With `ref_mv_count == 2` our `NEAR_NEARMV` drl loop condition
36+(`count > idx + 1`, idx=1) is false, so we never read the `drl_mode` symbol
37+libaom reads at `ref_mv_count == 3` — **one bit short**. Every later symbol in the
38+tile then read from the wrong place, and the 32-level gathered edge bit at
39+mi(16,40) resolved HORZ where libaom split (the r4 "edge bit" symptom was the
40+consequence, not the cause — matching r4 fact 4).
41+
42+The missing candidate has weight 2: `add_tpl_ref_mv`'s temporal vote
43+(`ref_mv_weight[idx] = 2 * weight_unit`), from extension sample
44+`(voffset, hoffset) = (4,4)` at mi(16,32) (`16&15=0`, `32&15=0`, both in range).
45+
46+After the fix the ladder is exact through the block: stack 3 == 3 with identical
47+entries and weights, post-mv 39839 == libaom `EC_MODE_MV rng=39839`, next block
48+entry 62618 == 62618, and mi(16,36) stack weight `w=10` == 10 (was 8, i.e. the
49+same missing weight-2 vote folded into an existing entry).
50+
51+EVIDENCE: /tmp/.../scratchpad/gl-r5-ours.txt (before) + gl-r5-ours2.txt (after) vs aom-mode.txt | `EC_TRACE_MODE` ours (temporary EC_LAD compound ladder) vs instrumented aomdec on g4.obu md5 48e1d78f31a4eb6a6ef5a67df9bd36fe | mi(16,32) p2 stack 2->3, post-mv 50080->39839 == libaom, next-block entry 39296->62618 == libaom
52+
53+EVIDENCE: /tmp/.../scratchpad/g4-ours.yuv vs g4-aom.yuv | `decode_probe EC_PROBE_OUT` vs `aomdec --rawvideo` on g4.obu | plane Y ALL 5 FRAMES EXACT (was f1 90, f2 143, f3 106 wrong pixels); chroma residue below
54+
55+## Gate: still RED, on a DIFFERENT defect
56+
57+`cargo test -p ec-av1 --lib -- a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition`
58+
59+* baseline (`fbc427c`): `192x80 cq59 frames=5 8-bit frame 1 plane Y: 90 pixels differ, first at row 61 col 174 [edge32=[1,35,1,0,0,18,0,0]]` (log `$HOME/.cache/golomb-gate-r5-base.log`)
60+* with the fix: `192x80 cq35 frames=5 8-bit frame 1 plane U: 335 pixels differ, first at row 0 col 56 [edge32=[0,36,0,0,0,18,0,0]]` (log `$HOME/.cache/golomb-gate-r5.log`)
61+
62+The gate now fails EARLIER in the cq sweep (35 < 59) because **cq35 was never
63+compared before**: at baseline that stream hit a false named refusal
64+(`"an inter 16x16-level AB or 1:4 partition"`) produced by our own desync, so the
65+gate `continue`d past it. With the stack fixed it decodes end to end. Class
66+`refusal-from-own-desync` + `refusal-hides-a-defect`, both already in memory.
67+
68+The residual defect is **chroma-only and pre-existing**: on both streams luma is
69+bit-exact in every frame while U/V carry scattered ±1..±3 across the whole plane
70+(g4 baseline already had f1 U 75 / V 185 wrong under the luma failure). The key
71+frame (f0) is exact, so it is inter chroma only, and V is consistently ~2.5x worse
72+than U.
73+
74+EVIDENCE: /tmp/.../scratchpad/g35-ours.yuv vs g35-aom.yuv | decode_probe vs aomdec on g35.obu (md5 9037f5b21db95d35e71f91f040fc33e1, recipe scratchpad/gl-gen.sh, hashed twice identical) | f0 exact, f1..f4 luma exact, U 335/324/1183/691 and V 408/412/1158/746 wrong, deltas -4..+5
75+EVIDENCE: /tmp/.../scratchpad/g35-ours.txt vs g35-aom.txt | `EC_TRACE_MODE` block-entry ranges, ours vs aomdec | all 48 of our `EC_MODE` ranges match libaom's in order — entropy fully in sync, so this is a pure chroma reconstruction defect, not a symbol defect
76+
77+## The r3 verifier item (`max_blocks_wide/high` clip on the INTER var-tx leaf loops)
78+
79+**Already implemented, at the shared entry point** — no code needed
80+(`decode.rs:10317`):
81+
82+```
83+fn read_var_tx_size(..., (max_w_mi, max_h_mi), ...) {
84+ if blk_row >= max_h_mi || blk_col >= max_w_mi { return; }
85+```
86+
87+`max_w_mi`/`max_h_mi` are computed as `mi_cols.saturating_sub(at_mi.1)` /
88+`mi_rows.saturating_sub(at_mi.0)` at BOTH inter callers
89+(`decode.rs:10402-10403` square, `decode.rs:10630-10631` rect), i.e. libaom's
90+`max_blocks_wide/high` in the same 4x4 units. A leaf whose top-left mi is outside
91+the frame is therefore never emitted into `vartx_leaves`, and the two reconstruct
92+loops (`decode.rs:15852`, `decode.rs:16830`) cannot see one. Adding a second
93+`tu_px >= y.true_width` guard there would be dead code.
94+
95+## Status / disposition
96+
97+* the mi(16,32) compound-stack desync: **FIXED**, luma bit-exact on the charter's stream.
98+* the chroma ±1 residue: **fix-now, next round** — first block to bisect is chroma
99+ plane U/V of `g35.obu` frame 1 (entropy is proven in sync, MVs proven right by
100+ exact luma, so it is chroma prediction/rounding or the per-plane chroma
101+ quantizer; V-worse-than-U points at a per-plane term, cf. memory
102+ `parsed-then-discarded`). Unblocked by a fresh round; nothing here contradicts it.
103+* r3 verifier item (var-tx clip): **accepted as already-satisfied**, cited above.
104+ Its 192x68 / 68x192 gate arm: **deferred — the gate it would join is RED, so a
105+ new arm would only add noise — unblocked by the chroma fix above.**
106+
107+## Suite
108+
109+`cargo test -p ec-av1 --lib` under a user systemd unit, log `$HOME/.cache/golomb-suite-r5.log`: re-armed as unit `golomb-suite-r5` after restoring the `#[ignore]` attribute on `a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact` (the r2 open-defect twin; the attribute was lost in the r4 merge and the test ran, and failed, in the mid-round run). Expected failures: the one open gate above. The coordinator reads the log.
lanes/golomb-r6.handoff.mdadded+118 -0
@@ -0,0 +1,118 @@
1+# lane-golomb r6 HANDOFF
2+
3+## Merge state (STEP 1: DONE)
4+* `899d7cf` = `git merge main` (main `18bf7dc`). Real merge commit, not a squash.
5+* `crates/ec-av1/src/mvstack.rs`: `git diff main -- mvstack.rs` is EMPTY -> ONE copy of the
6+ compound tpl-extension hunk (lane-sb128 `d6cca7d` == our `13aebbe`), byte-identical to main.
7+* `crates/ec-av1/src/cdf.rs` and `cdf_state.rs`: `git diff main` EMPTY (NZ_MAP/FILTER_INTRA
8+ byte-identical to main).
9+* 7 `decode.rs` conflicts resolved: 4 were comment-only (took main's text); 3 were the counter
10+ pair -- main's `bump_edge_part` and this lane's `bump_edge32` are INDEPENDENT counters, BOTH
11+ kept at every site (`decode.rs:13094-13101`, `13169-13179`, and the two `!has_rows32/!has_cols32`
12+ guards).
13+* `#[ignore = "open r2 defect: ..."]` on
14+ `a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact`
15+ (`stream.rs:18414`) SURVIVED the merge -- verified by grep after the merge commit.
16+
17+## Suite r5
18+`$HOME/.cache/golomb-suite-r5.log` had NO `test result:` line: the unit was still `active` and
19+I stopped it (`systemctl --user stop golomb-suite-r5`) to free `CARGO_TARGET_DIR` for r6 -- it
20+was building the PRE-merge tree, so its result would have been superseded anyway. Every `test`
21+line present in it up to that point was `ok`. r6 suite armed as unit `golomb-suite-r6`
22+-> `$HOME/.cache/golomb-suite-r6.log`; READ THAT, not r5.
23+
24+## STEP 2: chroma residue -- ROOT CAUSE #1 FOUND AND FIXED
25+
26+Stream: `g35.obu`, md5 `9037f5b21db95d35e71f91f040fc33e1` (regenerated, hash confirmed;
27+recipe `scratchpad/gl-gen.sh 35 <out>`), 192x80 cq35 5 frames 8-bit, 6 decode-order pictures.
28+
29+### Localization method (reusable)
30+Three-stage compare, decode order, ours vs the oracle:
31+`EC_AV1_PREFILT_DUMP` (pre-loopfilter) / `EC_AV1_POSTDEBLOCK_DUMP` (post-deblock, pre-CDEF) /
32+`EC_AV1_FINAL_DUMP` (post everything). Ours dumps a PADDED plane (192x96 luma), aomdec dumps
33+CROPPED (192x80) -- the comparator must use different strides per side.
34+NOTE: `EC_AV1_PREFILT_DUMP16`/`..._DUMP16` SEGFAULT the oracle aomdec on an 8-bit stream
35+(`ec_dump16` does `CONVERT_TO_SHORTPTR` unconditionally, decodeframe.c:3968). Use the 8-bit
36+`*_DUMP` vars for 8-bit streams.
37+Ours' `dump_stage` used to write `.f0` for EVERY frame (overwrite); r6 gave it a per-var
38+thread-local index (`decode.rs`, `dump_stage`) so POSTDEBLOCK is now `.f0..fN` like the oracle.
39+
40+### The measurement that localized it
41+Before the fix: prefilt decode-f1 EXACT, post-deblock decode-f1 U342/V380 wrong, luma exact at
42+every stage -> the defect was the DEBLOCK filter on chroma, not prediction, not CDEF
43+(`--enable-cdef=0` did NOT fix it), not LR (disabled in the recipe).
44+
45+### Root cause (fixed)
46+`decode.rs`, inter block tail: the var-tx / split-tx LEAF loop called
47+`Neighbours::fill_lf_grid_rect(leaf_mi, tx_px/MI, tx_px/MI, ...)`, and that function DERIVES
48+the chroma grids from the span it is given (`uv_tx_w = (w_mi*MI/2).clamp(4,32)`). So every
49+var-tx leaf OVERWROTE the block's correct `uv_tx_grid`/`uv_tx_h_grid` (the block's
50+`av1_get_max_uv_txsize`) with `leaf_tx/2`, inventing chroma transform edges the deblocker then
51+filtered. libaom `get_transform_size` (`av1/common/av1_loopfilter.c:207`) applies the var-tx
52+override ONLY `if ((plane == AOM_PLANE_Y) && is_inter_block(mbmi) && !mbmi->skip_txfm)`;
53+chroma always keeps `av1_get_max_uv_txsize(mbmi->bsize, ss_x, ss_y)`.
54+FIX: new `Neighbours::fill_lf_grid_leaf_luma` writes ONLY `tx_grid`/`tx_h_grid` over the leaf
55+span (`ref_grid`/`delta_lf_grid` are already correct from the block's own fill over the same
56+span), and the leaf loop calls it. Sweep: this was the ONLY `fill_lf_grid_rect` caller passing
57+a TU span; all 12 others pass block dims (checked each).
58+
59+### Result
60+g35 ours vs aomdec, all three stages, decode order:
61+before f0 exact, f1 U398/V457, f2 U325/V412, f3 U336/V408, f4 U~1000/V~1000, f5 U691/V746
62+after f0-f3 EXACT at prefilt+postdeblock+final, f4 U974/V973 (prefilt), f5 inherits it.
63+
64+## RESIDUE (still RED) -- exactly one defect left
65+Gate: `cargo test -p ec-av1 --lib -- a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition`
66+=> `192x80 cq35 frames=5 10bit=false frame 3 plane U: 978 pixels differ, first at row 0 col 32
67+(ours 33 vs ffmpeg 8) [edge32=[0,36,0,0,0,18,0,0]]`.
68+
69+* Stage: **PREFILTER** (prediction+residual), decode-order picture 4 only (f5 inherits).
70+ Deblock/CDEF/LR are exonerated for this one.
71+* Extent: EXACTLY chroma x 32..63, y 0..31 = luma x 64..127, y 0..63, i.e. one whole 64x64
72+ superblock. Luma bit-exact inside it.
73+* Shape of the error: HIGH-FREQUENCY, |delta| up to 52. aomdec's row 0 is smooth
74+ (13,14,14,14,...) where ours is (36,12,0,0,20,22,...). That is a RESIDUAL/inverse-transform
75+ shape, not a prediction-offset shape.
76+* Blocks in that SB (decode f4, from `EC_TRACE_MODE`): mi(0,16) mode=23 ref0=1 ref1=7 (compound),
77+ mi(0,24) mode=17 ref0=1 ref1=7, mi(8,16) mode=17 ref0=1 ref1=7, mi(8,24) mode=13 ref0=7
78+ single-ref. All 32x32.
79+
80+### Ruled out (each with the command that ruled it out)
81+* deblock / CDEF / LR: prefilt already differs on f4.
82+* per-plane `delta_q_u/v_dc/ac`: consumed (`stream.rs:599-603` etc.) AND f0-f3 chroma is now
83+ bit-exact under the same quantizer.
84+* narrow-block (<=4-wide) chroma MC kernel and sub8x8 chroma MV derivation: impossible in this
85+ stream, `--min-partition-size=32` means the smallest chroma block is 16x16.
86+* chroma MC rounding: derived by hand that our always-2-pass convolve is bit-identical to
87+ libaom's `av1_convolve_x_sr_c`/`_y_sr_c` single-pass rounding when one fraction is 0
88+ (identity tap 128, round2(x*16,11) == ROUND_POWER_OF_TWO(x,7)); and f1-f3 are now exact.
89+* **DIFFWTD compound (the tempting one -- DO NOT re-chase it blind):** `--enable-diff-wtd-comp=0`
90+ made the whole sequence exact, BUT that is a DIFFERENT bitstream (class gate-recipe-confound).
91+ An `EC_DWTD` trace of the ORIGINAL g35 shows only 4 diffwtd blocks in the whole stream, in
92+ decode f1 (px=64,py=0) and decode f2 (px=0,py=0 / px=64,py=0 / px=128,py=32) -- **NONE in
93+ decode f4**, where the residue is. DIFFWTD is therefore EXONERATED for this residue.
94+* warp / global motion / OBMC / dual filter / masked-comp / interintra / dist-wtd: ablated on
95+ the post-fix build, all still show the f3(display) failure (`scratchpad/abl.sh`).
96+
97+### Exact next step
98+The error is a chroma RESIDUAL in a 64x64 SB of decode-order picture 4 whose luma is exact and
99+whose entropy is (r5-proven) in sync. Bisect chroma coefficients, not prediction:
100+1. Run the oracle with `EC_TRACE_COEFF=1` and ours with `EC_TRACE_COEFF=1` on `g35.obu`, isolate
101+ decode picture 4, block mi(0,16), plane 1. Compare the DEQUANTIZED values element by element
102+ (and the msac RANGE per element, never `tell()`).
103+2. Prime suspect given "luma exact, chroma noisy, whole SB": the chroma `tx_type` inherited from
104+ the colocated luma unit (`decode.rs` `inherited_luma_tx_type`, `av1_get_tx_type`
105+ `blockd.h:1291`). For a var-tx-split luma block the chroma TU spans several luma TUs and
106+ libaom reads the luma tx_type at `blk_row<<ssy, blk_col<<ssx`; ours takes "the top-left unit".
107+ Verify that mapping against `av1_get_tx_type` for a 32x32 block whose luma split to 16x16.
108+ A wrong tx_type gives exactly this signature: right coefficients, wrong basis, chroma only.
109+3. Second suspect: `txsize_sqr_up_map[tx_size] > TX_32X32 -> DCT_DCT` clamp
110+ (ours clamps at `side >= 32`, on the CHROMA side length -- check that against
111+ `av1_get_ext_tx_set_type`'s use of the chroma tx size).
112+
113+## Deferred
114+* the 192x68 / 68x192 gate arm from r3's verifier ask: **deferred -- the gate it would join is
115+ still RED, a new arm would only add noise -- unblocked by the residue above.** The r3 code ask
116+ itself stays accepted-as-already-satisfied (`decode.rs` `read_var_tx_size`'s
117+ `blk_row >= max_h_mi || blk_col >= max_w_mi` early return, both inter callers pass
118+ `mi_cols/rows - at_mi`).
lanes/golomb-r7.handoff.mdadded+99 -0
@@ -0,0 +1,99 @@
1+# lane-golomb r7 HANDOFF -- residue CLOSED, gate GREEN, suite still running at the cap
2+
3+Tip: `a548e9d` on `lane-golomb` (parent `0fcdf39`). Full report: `lanes/golomb-r7.report.md`.
4+
5+## Suite r6 result line
6+There is none. `$HOME/.cache/golomb-suite-r6.log` was still `active` at 254/404 tests
7+(stuck in the long superres/encoder tests) and holding `CARGO_TARGET_DIR`, so r7 stopped
8+the unit to build -- it was measuring the PRE-fix tree and is superseded. Every `test`
9+line it did emit was `ok` or a documented `ignored`.
10+
11+## Suite r7 -- INCOMPLETE at the turn cap
12+Unit `golomb-suite-r7` -> `$HOME/.cache/golomb-suite-r7.log`, still `active` at 180/404
13+tests, NO `test result:` line yet, no `FAILED` line so far. A successor must read that
14+log (`grep -E "^test result|FAILED"`); if the unit died, re-arm it with the COMMON recipe.
15+This is the one owed artifact of the round.
16+
17+## What the picture-4 investigation showed (the ladder was not needed)
18+Method: `EC_TRACE_MODE=1 EC_TRACE_COEFF=1` on `g35.obu` (md5 `9037f5b21db95d35e71f91f040fc33e1`,
19+`scratchpad/gl-gen.sh 35`) through the r6-built `decode_probe`, stderr split into frames on
20+`EC_MODE mi_row=0 mi_col=0` -> segment 4 = decode-order picture 4
21+(`scratchpad/r7-ours.err`, still on disk).
22+
23+* The residue block is `mi(0,16)` and the next `EC_MODE` is `mi(0,32)`, so it is a **64x64**
24+ block, NOT the 32x32 r6 recorded. Var-tx split into 16x16 luma leaves.
25+* Its last two coefficient units are `eob=1022 tx=DctDct` and `eob=1020 tx=DctDct`
26+ (`ctx=0`): eob > 256 proves **32x32 chroma** units
27+ (`av1_get_max_uv_txsize(BLOCK_64X64) = TX_32X32`).
28+* Its FIRST luma var-tx leaf is `eob=254 tx=Idtx`.
29+* No dequant-value ladder against aomdec was required: the coefficient values are provably
30+ identical (the whole stream stays in entropy sync and luma is bit-exact), so the only
31+ free variable left was the chroma `tx_type` -- and `IDTX` vs `DCT_DCT` are both
32+ `TX_CLASS_2D`, i.e. identical scan, identical contexts, identical msac ranges, different
33+ inverse transform. That is exactly "entropy in sync, one SB of high-frequency chroma
34+ noise, luma exact".
35+
36+## Fix applied (root cause, libaom-cited)
37+`av1_get_tx_type`, `av1/common/blockd.h:1278-1309`, chroma of an INTER block:
38+1. `DCT_DCT` only when `txsize_sqr_up_map[tx_size] > TX_32X32` (STRICTLY greater);
39+2. else the colocated luma unit's coded type, `xd->tx_type_map[(blk_row<<ss_y)*stride + (blk_col<<ss_x)]`;
40+3. then `if (!av1_ext_tx_used[av1_get_ext_tx_set_type(tx_size, 1, reduced)][tx_type]) tx_type = DCT_DCT;`
41+ (`av1_ext_tx_used` blockd.h:1036, `av1_get_ext_tx_set_type` blockd.h:1097).
42+
43+We had step 1 as `chroma side >= 32 -> DCT_DCT` and step 3 missing entirely. At exactly
44+`TX_32X32` an inter block reads `EXT_TX_SET_DCT_IDTX`, which CONTAINS IDTX -> the block
45+above must use IDTX on chroma; we used DCT_DCT.
46+
47+`crates/ec-av1/src/decode.rs`: new `fn reduce_inherited_chroma_tx_type(t, w, h)` (just above
48+`fn inter_txbset_for`) implementing all four inter sets; both callers switched
49+(`read_inter_plane` and `read_inter_plane_rect` `default_tx_type`). Sweep: `rg
50+inherited_luma_tx_type` -- those are the ONLY two sites deriving a chroma tx_type for an
51+inter block; the intra sites (`decode.rs:6056`, `9195`) are correct as-is (intra at
52+`sqr_up == TX_32X32` really is `EXT_TX_SET_DCTONLY`).
53+Unit test added: `decode::tests::an_inter_chroma_transform_narrows_its_inherited_tx_type_to_its_own_set`
54+(`cargo test -p ec-av1 --lib -- an_inter_chroma_transform_narrows` => 1 passed).
55+
56+## edge32 gate: every arm GREEN
57+`$HOME/.cache/golomb-gate-r7.log`: `test result: ok`,
58+`38 pixel-exact attempts, 32-level edge bits [horz_or_vert=0 split=394], 64-level edge bits
59+[horz_or_vert=7 split=197] right-VERT=7, 2 named refusals`.
60+Arms: (192x80, 80x192) x 1 frame x {8-bit,10-bit} plus 192x80 5-frame, cq
61+{35,40,45,50,55,57,59,61} -- so all eight cq levels are green at BOTH depths. The only two
62+non-compared attempts are `192x80 cq45/cq50 frames=5 8-bit`, which refuse by name on
63+another lane's feature (inter SB-level AB partition).
64+BEFORE: `192x80 cq35 frames=5 10bit=false frame 3 plane U: 978 pixels differ, first at row 0
65+col 32 (ours 33 vs ffmpeg 8)`.
66+
67+## Ruled out this round (each with its measurement)
68+* r6's "32x32 block at mi(0,16)" premise -- WRONG, the trace shows a 64x64 block (the next
69+ EC_MODE is mi(0,32)); anything chartered off "32x32 chroma is 16x16" was mis-premised.
70+* A wrong chroma tx SIZE: the chroma eob of 1022 (> 256) proves our unit really is 32x32,
71+ which is what `av1_get_max_uv_txsize` says.
72+* A dequant / per-plane delta_q cause: f0-f3 chroma is bit-exact under the same quantizer.
73+* Everything r6 already ruled out (deblock/CDEF/LR, DIFFWTD, warp/GM/OBMC/dual filter/
74+ masked-comp/interintra/dist-wtd, narrow-block chroma MC) stays ruled out.
75+
76+## Straddling-TU arm (r3 verifier ask): NOT added, and the two measurements say why
77+Both measured this round with the arms temporarily in `edge32_gate`
78+(`$HOME/.cache/golomb-gate-r7b.log`):
79+* `(192, 68, 5, false)`: ALL EIGHT cq attempts refuse by name -- `a reference picture whose
80+ height does not match this frame's own true size` -- so the arm compares nothing
81+ (vacuous; class `counter-from-refused-stream`). That refusal is the next blocker for any
82+ non-SB-multiple height.
83+* `(68, 192, 5, false)`: RED on a real, separate defect --
84+ `68x192 cq35 frames=5 10bit=false frame 1 plane Y: 141 pixels differ, first at row 0 col
85+ 64 (ours 167 vs ffmpeg 166) [edge32=[0,34,0,0,1,17,0,1]]`. LUMA, inside the 4-px
86+ straddling COLUMN. The straddling-ROW twin never reaches this because of the refusal above.
87+The reason is recorded as a comment in `edge32_gate` (`crates/ec-av1/src/stream.rs`, just
88+above `let cqs`) so it is not re-attempted blind.
89+
90+## Exact next step for r8
91+1. Read `$HOME/.cache/golomb-suite-r7.log`'s `test result:` line (N/0 expected); that is the
92+ only thing this round did not finish.
93+2. `main` has advanced to `85887c7` (this branch merged `18bf7dc`); re-merge before any
94+ further work.
95+3. Then the 68-px straddle: fix the `68x192` luma defect at the 4-px straddling column
96+ (start from `read_var_tx_size`'s `blk_col >= max_w_mi` early return and the right-edge
97+ prediction/availability, first difference is at row 0 col 64 = the first straddling
98+ column of decode picture 1), and the `192x68` "reference picture whose height does not
99+ match this frame's own true size" refusal -- then the arms can be added for real.
lanes/golomb-r7.report.mdadded+96 -0
@@ -0,0 +1,96 @@
1+# lane-golomb r7 REPORT -- GREEN (the r6 chroma residue is closed at its root cause)
2+
3+## What changed
4+* `crates/ec-av1/src/decode.rs` -- new `fn reduce_inherited_chroma_tx_type(t, w, h)`
5+ (inserted just above `fn inter_txbset_for`), and both inter-chroma callers now use it:
6+ * `read_inter_plane_rect`'s `default_tx_type` (was `Some(t) if w.max(h) < 32 => t`)
7+ * `read_inter_plane`'s `default_tx_type` (was `Some(t) if side < 32 => t`)
8+ Those two are the ONLY sites in the crate that derive a chroma `tx_type` for an INTER
9+ block (`rg inherited_luma_tx_type`); the intra chroma sites (`decode.rs:6056`, `9195`)
10+ take `default_intra_tx_type` and are already correct -- every value that table can
11+ produce is a member of both intra sets below 32, and both already force `DCT_DCT` at
12+ `>= 32`, which for INTRA is right (`av1_get_ext_tx_set_type` returns `EXT_TX_SET_DCTONLY`
13+ for intra at `tx_size_sqr_up == TX_32X32`).
14+* `crates/ec-av1/src/decode.rs` -- new unit test
15+ `decode::tests::an_inter_chroma_transform_narrows_its_inherited_tx_type_to_its_own_set`.
16+* `crates/ec-av1/src/stream.rs` -- comment only: the measured reason the 192x68 / 68x192
17+ straddling arms are NOT in `edge32_gate` (below).
18+
19+## ROOT CAUSE (libaom citation)
20+`av1_get_tx_type` (`av1/common/blockd.h:1278-1309`) for a chroma plane of an INTER block:
21+1. `if (txsize_sqr_up_map[tx_size] > TX_32X32) return DCT_DCT;` -- **strictly greater**;
22+2. `tx_type = xd->tx_type_map[(blk_row << ss_y) * stride + (blk_col << ss_x)]` -- the
23+ colocated luma unit's coded type (for a chroma unit at (0,0), the FIRST var-tx leaf);
24+3. `if (!av1_ext_tx_used[av1_get_ext_tx_set_type(tx_size, 1, reduced)][tx_type])
25+ tx_type = DCT_DCT;` -- narrowed by the set the **chroma** size selects
26+ (`av1_ext_tx_used` `blockd.h:1036`, `av1_get_ext_tx_set_type` `blockd.h:1097`).
27+
28+We had step 1 as `chroma side >= 32 -> DCT_DCT` and no step 3 at all. At exactly
29+`TX_32X32` an inter block reads `EXT_TX_SET_DCT_IDTX`, which **contains IDTX**. So a
30+64x64 inter superblock, whose chroma units are 32x32 (`av1_get_max_uv_txsize(BLOCK_64X64)`),
31+whose first luma var-tx leaf coded `IDTX`, must inverse-transform its chroma with IDTX --
32+we used DCT_DCT.
33+
34+`IDTX` and `DCT_DCT` are both `TX_CLASS_2D`: same scan, same coefficient contexts, same
35+msac ranges. That is why the whole stream stayed in entropy sync and only one superblock
36+of chroma came out as high-frequency noise with luma bit-exact -- the r6 handoff's exact
37+signature. (Class for the ledger: a tx_type set-membership bug is invisible to every
38+range ladder; only pixels see it.)
39+
40+The old rule was also wrong the other way for chroma 16x16 under 8x8 luma leaves
41+(`EXT_TX_SET_DTT9_IDTX_1DDCT` excludes V_ADST/H_ADST/V_FLIPADST/H_FLIPADST, which we would
42+have inherited verbatim). The new helper covers all four sets.
43+
44+## Localization (how the tx_type was identified, no aomdec rebuild)
45+`EC_TRACE_MODE=1 EC_TRACE_COEFF=1` on `g35.obu` (md5 `9037f5b21db95d35e71f91f040fc33e1`,
46+`scratchpad/gl-gen.sh 35`), split into frames on `EC_MODE mi_row=0 mi_col=0`: decode-order
47+picture 4 is segment 4. Its block at `mi(0,16)` (luma x=64,y=0) runs to the next
48+`EC_MODE mi_row=0 mi_col=32`, i.e. it is a **64x64** block (not 32x32 as r6 recorded),
49+var-tx split into 16x16 leaves. Its last two coefficient units are
50+`eob=1022 tx=DctDct` and `eob=1020 tx=DctDct` with `ctx=0` -- eob > 256 proves 32x32
51+chroma units -- while its FIRST luma leaf is `eob=254 tx=Idtx`. libaom inherits that
52+`Idtx`; we produced `DctDct`.
53+
54+## Gate
55+`cargo test -p ec-av1 --lib -- a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition --nocapture`
56+(under `systemd-run --user --unit=golomb-gate-r7-... -p MemoryMax=10G`,
57+`EC_AV1_REQUIRE_AOMENC=1`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-golomb`)
58+
59+BEFORE (r6 handoff): `192x80 cq35 frames=5 10bit=false frame 3 plane U: 978 pixels differ,
60+first at row 0 col 32 (ours 33 vs ffmpeg 8) [edge32=[0,36,0,0,0,18,0,0]]`.
61+AFTER: `ok` -- 5 arms x cq {35,40,45,50,55,57,59,61}, 8-bit and 10-bit,
62+`38 pixel-exact attempts, 32-level edge bits [horz_or_vert=0 split=394], 64-level edge
63+bits [horz_or_vert=7 split=197] right-VERT=7, 2 named refusals` (both the inter SB-level
64+AB partition another lane owns).
65+
66+EVIDENCE: $HOME/.cache/golomb-gate-r7.log | cargo test -- a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition --nocapture, 40 aomenc encodes decoded and compared plane-by-plane vs ffmpeg | 38/38 compared attempts pixel-exact, 0 differing pixels (was 978 U pixels on the 192x80 cq35 5-frame arm)
67+EVIDENCE: $HOME/.cache/golomb-gate-r7b.log | same gate + arms (192,68,5) and (68,192,5) | 68x192 cq35 frame 1 plane Y 141 px differ first at row 0 col 64 -- separate OPEN defect, arm not kept
68+EVIDENCE: scratchpad/r7-ours.err | EC_TRACE_MODE=1 EC_TRACE_COEFF=1 decode_probe g35.obu, segment 4, block mi(0,16) | first luma leaf tx=Idtx, the two 32x32 chroma units (eob 1022/1020) took tx=DctDct
69+
70+Unit check: `cargo test -p ec-av1 --lib -- an_inter_chroma_transform_narrows` => `ok. 1 passed`.
71+
72+## Refusals lifted
73+None this round -- this is a wrong-pixels fix, not a refusal lift. `refusal_inventory` /
74+`gate_coverage` untouched.
75+
76+## The 192x68 / 68x192 straddling arm (r3 verifier ask) -- NOT ADDED, measured why
77+* `(192, 68, 5, false)`: all EIGHT cq attempts refuse by name, `a reference picture whose
78+ height does not match this frame's own true size` -> the arm compares nothing (vacuous,
79+ class `counter-from-refused-stream`).
80+* `(68, 192, 5, false)`: RED on a real separate defect --
81+ `68x192 cq35 frames=5 10bit=false frame 1 plane Y: 141 pixels differ, first at row 0
82+ col 64 (ours 167 vs ffmpeg 166) [edge32=[0,34,0,0,1,17,0,1]]`. LUMA, inside the 4-px
83+ straddling COLUMN; the straddling ROW twin (192x68) never gets that far.
84+ disposition: deferred(the right-edge straddling-column luma defect above, and the
85+ reference-size refusal) -- both are outside this lane's chroma tx_type cause.
86+
87+## Test totals
88+`$HOME/.cache/golomb-suite-r7.log` (unit `golomb-suite-r7`) -- see the `test result:` line.
89+NOTE: `$HOME/.cache/golomb-suite-r6.log` never produced a `test result:` line: it was still
90+`active` (254/404 tests, stuck in the long superres/encoder tests) and holding
91+`CARGO_TARGET_DIR`, so it was stopped -- it was measuring the PRE-fix tree and is superseded
92+by r7. Every `test` line it did produce was `ok` or a documented `ignored`.
93+
94+## Open / residue
95+* `main` has advanced to `85887c7` (we merged `18bf7dc`); this branch is NOT re-merged.
96+* the two defects the 68-px arms found (above), deferred.
lanes/golomb-r8.handoff.mdadded+50 -0
@@ -0,0 +1,50 @@
1+# lane-golomb r8 HANDOFF -- two true-size fixes in, suite GREEN, straddle arms still blocked
2+
3+Tip: `lane-golomb` (report `lanes/golomb-r8.report.md`, fix `97de75e`, merge of main
4+`85887c7` at `3a08902`). Suite: `379 passed; 0 failed; 34 ignored`
5+(`$HOME/.cache/golomb-suite-r8.log`). edge32 gate green, 38 pixel-exact attempts, 2 refusals.
6+
7+## Landed
8+1. Reference-height refusal compared the mi-rounded `true_height` with the cropped
9+ `reference.height`; now compares the header's `frame_height` (libaom compares references on
10+ `y_crop_width/height`). Every 192x68 attempt used to refuse; none do now.
11+2. `apply_loop_restoration` now takes the cropped `(frame_width, frame_height)` instead of
12+ plane `true_width/true_height` (libaom `av1_get_upsampled_plane_size` +
13+ `assert(plane_w == crop_widths)` + `av1_extend_frame`). UNGATED -- every straddle recipe
14+ runs `--enable-restoration=0`.
15+
16+## The ONE open defect this lane still owns
17+A **+-1 straddling-band INTER reconstruction defect**, both orientations, all on **frame 1**
18+(frame 0 is bit-exact in every case, so it is not intra and not a per-frame filter constant):
19+* `68x192` cq35 8-bit: `frame 1 plane Y: 141 px differ, first at row 0 col 64 (167 vs 166)`
20+ -- cols 64..67 are the straddling COLUMNS of a 68-wide frame (mi-rounded 72).
21+* `192x68` cq59 8-bit: `frame 1 plane Y: 217 px, first at row 60 col 170 (172 vs 173)`.
22+* `192x68` cq35 10-bit: `frame 1 plane Y: 305 px, first at row 56 col 48 (530 vs 531)`.
23+Reproduce by re-adding `arms.push((68, 192, 5, false))` / `arms.push((192, 68, 5, false))` in
24+`edge32_gate` (`crates/ec-av1/src/stream.rs`, the comment block just above `let cqs`) and
25+running with `EC_GATE_VERBOSE=1` (new this round -- names each attempt before decoding it,
26+because a desync otherwise panics in `mc.rs` with no arm in the message).
27+
28+RULED OUT this round, do not re-attempt:
29+* Reference border padding. `aom_yv12_extend_frame_borders_c` calls `extend_plane` with
30+ `crop_widths/crop_heights` and memsets from `src + width - 1`, so libaom OVERWRITES decoded
31+ columns 68..71 with column 67 -- exactly what our `mc::sample` clamp at `true_width-1` of the
32+ cropped reference already does. The charter's hypothesis (b) is refuted at the source.
33+* Loop restoration. The gate recipe has `--enable-restoration=0`; the 68x192 diff is
34+ byte-identical before and after fix 2 (`golomb-gate-r8c.log` vs `r8d.log`).
35+* Var-tx clipping (`max_w_mi`/`max_h_mi`). libaom's `max_block_wide` is derived from
36+ `mb_to_right_edge`, i.e. `cm->mi_params.mi_cols` -- the MI-ROUNDED bound, which is what we
37+ use. Correct as-is.
38+
39+Next probe to run (r8 ran out of budget before it): dump the 68x192 cq35 stream to disk, then
40+bisect the frame-1 divergence with `EC_AV1_PREFILT_DUMP` (8-bit vars -- the 16-bit ones
41+SEGFAULT the oracle aomdec on an 8-bit stream) against the instrumented aomdec. If the
42+divergence is already present pre-filter it is inter prediction/residual in the straddling
43+band; if not, it is deblock/CDEF at the x=68 (resp. y=68) mi edge.
44+
45+## Two blockers that are NOT this lane's code
46+* `192x68` cq40 8-bit **PANICS** in `decode_inter_block8` (`from_switchable_symbol` handed a
47+ 4th symbol, `mc.rs:203`) = lane-sub8's open below-8x8 desync. A panic cannot be tolerated
48+ as a named refusal, so no straddle arm can span cq40 until sub8 lands.
49+* `192x68` cq35 8-bit refuses "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B)"
50+ even though the recipe sets `--enable-ab-partitions=0` -- worth one measurement of its own.
lanes/golomb-r8.report.mdadded+102 -0
@@ -0,0 +1,102 @@
1+# lane-golomb r8 -- two true-size defects fixed, straddle arms STILL not addable
2+
3+Tip: `97de75e` on `lane-golomb` (merge `3a08902` of main `85887c7`, then the fix).
4+
5+## (1) Suite r7 -- no result line, superseded
6+`$HOME/.cache/golomb-suite-r7.log` was still `active` at **226/404** tests with **no**
7+`test result:` line and **zero** `FAILED`/`panicked` lines. It was measuring the PRE-merge
8+tree (main has since advanced to 85887c7), so r8 stopped the unit to take the target dir.
9+Owed artifact carried forward to r8's own suite.
10+
11+## (2) Merge of main 85887c7
12+`git merge --no-commit main` was a CLEAN auto-merge (decode.rs + stream.rs auto-merged, no
13+conflict, no hand resolution). Byte-compared against main afterwards:
14+`mvstack.rs`, `cdf.rs`, `cdf_state.rs`, `refusal_inventory.rs` are all **IDENTICAL to main**
15+(`git diff --quiet main -- <file>`). Only decode.rs and stream.rs carry lane content.
16+Merge commit `3a08902`.
17+
18+EVIDENCE: $HOME/.cache/golomb-gate-r8h.log | edge32 gate on the merged tree, all 8 cq arms x
19+{192x80, 80x192} x {8,10}-bit + the 5-frame inter arm | `test result: ok`, 38 pixel-exact
20+attempts, 64-level edge bits [horz_or_vert=7 split=197] right-VERT=7, 2 named refusals --
21+byte-identical totals to r7's green run.
22+
23+## (3a) FIXED: a same-size reference at a height that is not a multiple of 8
24+`crates/ec-av1/src/decode.rs`, `decode_inter_frame_tile_with_cdfs`: the guard compared
25+`reference.height` against `true_height = (mi_rows * 4)` (mi-rounded). A decoded `Picture`
26+is cropped to the header's `fh`, so at height 68 (`mi_rows = 2*((68+7)>>3) = 18` -> 72) it
27+compared **68 against 72** and refused every same-size reference.
28+libaom compares references on the CROPPED dimensions --
29+`av1_setup_scale_factors_for_frame(&sf, ref->y_crop_width, ref->y_crop_height, cm->width,
30+cm->height)` -- and calls a reference *scaled* only when those differ (`av1_is_scaled`).
31+Height must still match (AV1 superres never scales height). Class `av1-truesize-lane`.
32+
33+EVIDENCE: $HOME/.cache/golomb-gate-r8{b,f}.log | `arms.push((192, 68, 5, false))`, cq sweep |
34+BEFORE: 8/8 attempts refuse "a reference picture whose height does not match this frame's own
35+true size"; AFTER: 0/8 do.
36+
37+## (3b) NOT the cause of the 68x192 column defect -- charter hypothesis REFUTED at the source
38+The charter proposed our reference plane replicates from the mi-rounded column 71 instead of
39+the true column 67. Read `aom_scale/generic/yv12extend.c`: `aom_yv12_extend_frame_borders_c`
40+calls `extend_plane(..., ybf->crop_widths[is_uv], ybf->crop_heights[is_uv], ...,
41+right = plane_border + widths - crop_widths)` and `extend_plane` memsets from
42+`src + width - 1` -- i.e. libaom OVERWRITES the decoded columns 68..71 with column 67.
43+Our `mc::sample` clamps at `true_width - 1` of the CROPPED reference `Picture` (68) -->
44+already identical. No fix needed; the 141-px defect is elsewhere.
45+
46+## (3c) FIXED (source-cited, UNEXERCISED): loop restoration ran over the mi-rounded plane
47+`decode.rs::apply_loop_restoration` passed each plane's `true_width`/`true_height`. LR is the
48+one post-decode filter that does not walk the mi grid: libaom sizes every plane with
49+`av1_get_upsampled_plane_size` (`plane_w = ROUND_POWER_OF_TWO(cm->superres_upscaled_width,
50+ss_x)`, `av1/common/restoration.c:47`), **asserts** it equals the buffer's crop width
51+(`restoration.c:1106`) and `av1_extend_frame(..., plane_w, plane_h, ...)` replicates the
52+border from that cropped edge before any unit is filtered (`restoration.c:1109`). Deblock and
53+CDEF DO walk the mi grid, which is why this survived until a non-multiple-of-8 size.
54+Now takes `(frame_width, frame_height)`, chroma `div_ceil(2)`.
55+DISCLOSURE: **no gate exercises this** -- every straddle recipe in `edge32_gate` runs
56+`--enable-restoration=0`, and the 68x192 defect was byte-identical before and after
57+($HOME/.cache/golomb-gate-r8{c,d}.log, both `141 pixels differ, first at row 0 col 64`).
58+It is a source-cited correctness alignment, verified only by the suite staying green.
59+
60+## (4) The straddle arms are STILL not addable -- three separate blockers, each measured
61+Charter asked for `(192,68,5)` and `(68,192,5)` arms at 8+10 bit with a straddling-TU counter.
62+DEVIATION: no arm was added, because every cq level of both is vacuous, panicking or red.
63+The measurements are now recorded verbatim in the `edge32_gate` comment block:
64+* `192x68` cq35 8-bit: no longer the height refusal -- refuses LATER by another lane's name,
65+ "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B)". Vacuous
66+ (class `counter-from-refused-stream`).
67+* `192x68` cq40 8-bit: **PANICS** in `decode_inter_block8` -- `from_switchable_symbol` handed a
68+ 4th symbol, `mc.rs:203`. That is lane-sub8's own open below-8x8 desync (already named in
69+ `decode.rs`'s scaled-reference-8x8 refusal comment). A panic cannot be tolerated as a named
70+ refusal, so the arm cannot even be added with an Err-tolerating recipe.
71+* `192x68` cq59 8-bit: RED, `frame 1 plane Y: 217 pixels differ, first at row 60 col 170
72+ (ours 172 vs ffmpeg 173)`.
73+* `192x68` cq35 10-bit: RED, `frame 1 plane Y: 305 pixels differ, first at row 56 col 48
74+ (ours 530 vs ffmpeg 531)`.
75+* `68x192` cq35 8-bit: RED, `frame 1 plane Y: 141 pixels differ, first at row 0 col 64
76+ (ours 167 vs ffmpeg 166)` -- unchanged from r7 by either fix this round.
77+
78+NEW FACT for the successor: all four red cases are **+-1** bands, on **frame 1** (the first
79+INTER frame -- frame 0 is bit-exact in every one), and they sit in or immediately beside the
80+4-px straddling band (rows 56..63 next to straddling rows 64..67; columns 64..67 are the
81+straddling columns themselves). That is one straddling-band INTER reconstruction defect with
82+two orientations, not four defects -- and it is not the reference border (3b), not LR (3c) and
83+not intra (frame 0 exact).
84+
85+The gate now prints each attempt under `EC_GATE_VERBOSE=1` (`stream.rs`), because a desync
86+otherwise surfaces as a bare panic in `mc.rs` with no arm named.
87+
88+## Test totals
89+`cargo test -p ec-av1 --lib` -> `$HOME/.cache/golomb-suite-r8.log` (unit `golomb-suite-r8`):
90+`test result: ok. 379 passed; 0 failed; 34 ignored; 0 measured; 0 filtered out; finished in
91+917.74s` (413 test lines emitted). GREEN.
92+
93+EVIDENCE: $HOME/.cache/golomb-suite-r8.log | `cargo test -p ec-av1 --lib` on the merged tree at
94+97de75e, unit golomb-suite-r8, MemoryMax=10G | 379 passed / 0 failed / 34 ignored.
95+
96+## Residue disposition
97+* 68x192 / 192x68 straddling-band +-1 INTER defect -- **fix-now, next round**; it is this
98+ lane's whole remaining job and the successor has the four measurements above.
99+* `192x68` cq40 below-8x8 panic -- **deferred(lane-sub8's open desync)**; not this lane's code.
100+* `192x68` cq35 inter SB-level AB partition refusal -- **deferred(the AB-partition lane)**.
101+* LR cropped-plane fix ungated -- **deferred(a straddle gate arm with
102+ `--enable-restoration=1`)**; the base recipe disables restoration for every arm.
lanes/golomb-r9.report.mdadded+100 -0
@@ -0,0 +1,100 @@
1+# lane-golomb r9 -- the straddling-band defect is CDEF, and a stream-data PANIC is now a refusal
2+
3+## What changed
4+
5+* `crates/ec-av1/src/decode.rs` `neighbour_filter` -- returns `Result` and refuses
6+ "an OBMC neighbour whose switchable interp filter was never recorded" instead of handing the
7+ `[3, 3]` sentinel to `mc::from_switchable_symbol`, which `panic!`s on any value above 2.
8+ Both call sites (`build_obmc_prediction`'s above and left passes) already sat inside a
9+ `Result` function and take `?`.
10+* `crates/ec-av1/src/refusal_inventory.rs` -- the new refusal string pinned.
11+* `crates/ec-av1/src/decode.rs` `deblock_plane` -- new `EC_AV1_DEBLOCK_TRACE_V` rung: the
12+ per-edge `x0/y0/len/level` of the vertical pass plus one line per plane with the loop's real
13+ `tw`/`th`/`stride` vs `true_*`/crop bounds. That rung is what settled the deblock question below.
14+* `crates/ec-av1/src/stream.rs` -- `a_frame_edge_straddling_band_decodes_pixel_exact`, an
15+ `#[ignore]`d pinned test that runs `edge32_gate`'s exact recipe over the four straddle arms
16+ (192x68 and 68x192, 5 frames, 8-bit and 10-bit, cq 35..61), with `EC_GATE_VERBOSE` naming.
17+
18+## TASK A -- root cause narrowed to CDEF, stage by stage (fix NOT landed)
19+
20+Stream: `~/.cache/golomb-tmp/s68.obu`, md5 `45722b0fb7f1707a18e0547cc7a59fa2`, produced by
21+`edge32_gate`'s own aomenc recipe at 68x192 cq35 8-bit, 5 frames.
22+
23+| stage | ours vs instrumented aomdec, frame 1 |
24+| --- | --- |
25+| reconstruction (`EC_AV1_PREFILT_DUMP`) | **0 luma pixels differ** over the cropped 68 columns |
26+| post-deblock (`EC_AV1_POSTDEBLOCK_DUMP`, `EC_AV1_DEBUG_SKIP_CDEF=1`) | **matches**, including columns 68..71 |
27+| final output vs ffmpeg | 145 luma differ, mass in columns 64..67 |
28+
29+So inter prediction is exact and the charter's "the MC reference read runs past the crop"
30+hypothesis is refuted a second time (r8 refuted it at the libaom source; r9 refutes it by
31+measurement: our returned `Picture` is already cropped to `frame_width`, so `mc::sample` clamps
32+at column 67 exactly as `extend_plane` does). The deblock is also exact -- `frame_width` is the
33+right clip, confirmed against libaom `set_lpf_parameters`' `if ((width <= x) || (height <= y))`
34+early-out on `plane_ptr->dst.width`, which is the crop width; forcing the mi-rounded bound
35+instead made frame 0 RED (17 luma px, columns 65..67), so r7's clip stays.
36+
37+The divergence therefore enters in **CDEF**, at the last 8x8 CDEF block column (mi column 17,
38+pixels 64..71) -- the one block that straddles the crop edge. Frame 0 survives it and frame 1
39+does not, which is why every earlier round read the shape as "inter".
40+
41+Two instrument facts a successor needs:
42+* aomdec's `EC_AV1_POSTDEBLOCK_DUMP` is **72 columns wide** (mi-rounded) while its
43+ `EC_AV1_PREFILT_DUMP` is cropped to 68 -- the post-deblock rung is the only one that exposes
44+ the straddling band on the reference side.
45+* our own `EC_AV1_POSTDEBLOCK_DUMP` is emitted from a site that, on this path, runs **after**
46+ `apply_cdef`: `od.f0` and `odnc.f0` (same run, `EC_AV1_DEBUG_SKIP_CDEF=1`) differ in columns
47+ 68..71 although `EC_AV1_WATCH`-instrumented `filter_edge` performs no write there. Always pair
48+ that dump with `EC_AV1_DEBUG_SKIP_CDEF=1`, or the CDEF defect reads as a deblock defect --
49+ which cost r9 six rounds of the budget.
50+
51+EVIDENCE: ~/.cache/golomb-tmp/{ours,theirs,od,odnc,td}.f* | aomenc 68x192 cq35 5f -> decode_probe with EC_AV1_PREFILT_DUMP / EC_AV1_POSTDEBLOCK_DUMP(+EC_AV1_DEBUG_SKIP_CDEF) vs the same rungs on the oracle aomdec | prefilt f1 luma diffs 0/13056, post-deblock (cdef off) f1 luma diffs 0, final output f1 145 differ first row 0 col 64
52+
53+## TASK B -- the panic is gone
54+
55+Before: `192x68 cq40` aborted the process in `mc.rs:203`. After:
56+
57+```
58+$ decode_probe s40.obu
59+REFUSED: unsupported: AV1 tile (an OBMC neighbour whose switchable interp filter was never recorded)
60+```
61+
62+EVIDENCE: ~/.cache/golomb-tmp/s40.obu (md5 26d42c5f04e4d0f7f4075a4550e999d5) | aomenc 192x68 cq40 5f -> cargo run --example decode_probe | process abort in mc.rs:203 -> `REFUSED: unsupported: AV1 tile (an OBMC neighbour whose switchable interp filter was never recorded)`
63+
64+Sweep of the other aborts reachable from a desynced stream (`decode.rs` + `mc.rs`), each checked
65+against the value's own domain:
66+
67+* `mc.rs:203` `from_switchable_symbol` -- FIXED at its only reachable caller. The other caller
68+ (`resolve_interp_filter`) reads a 3-symbol CDF (`switchable_interp: [[u16; 4]; 16]`,
69+ `nsyms = cdf.len() - 1`), so it cannot produce a 4th symbol.
70+* `mc.rs:220` `from_header(Switchable)` -- header enum, not a per-block stream value; callers
71+ resolve `Switchable` before calling. Left.
72+* `decode.rs:3259` `default_intra_tx_type` -- the mode comes from a 13-symbol CDF and all 13
73+ values have a row. Bounded, left.
74+* `decode.rs:13936`/`14114` `partition_w8` and `decode.rs:15352` `read_single_ref` -- values from
75+ 4-symbol / bounded-return helpers. Bounded, left.
76+* `decode.rs:11673/11692/11739` -- guarded by `rect_inter_residual_supported`, which is itself a
77+ named refusal. Left.
78+* `decode.rs:11324`, `12091`, `12110`, `12147`, `15660`, `2745` -- block-size / tx-size domain
79+ invariants, not stream values. Left.
80+* `decode.rs:2498` `ref_hits` -- a test-side counter accessor, never on the decode path. Left.
81+* the non-test `.unwrap()`/`.expect()` in `decode.rs` (5280, 5324, 6085, 6152, 7352/7353,
82+ 7819/7820, 10535, 10591, 10735, 10944) are each dominated by a push/refusal a few lines above.
83+ Left, listed here so the next sweep does not re-derive it.
84+
85+## TASK C -- arms
86+
87+`a_frame_edge_straddling_band_decodes_pixel_exact` carries all four straddle arms and is
88+`#[ignore]`d, which is the only honest shape while the CDEF defect is open: an arm that is RED
89+cannot join the green gate, and the r8 handoff's "measured, arm not added" comment is now a
90+runnable test instead of prose.
91+
92+fix-now residue, NOT done this round:
93+* deferred(the CDEF straddle fix) -- the `--enable-restoration=1` arm at 192x68 that would gate
94+ r8's cropped-plane loop-restoration fix. `edge32_gate`'s arm tuple has no per-arm flag slot and
95+ every straddle recipe is RED regardless, so the LR arm would be vacuous today; it unblocks the
96+ moment the CDEF fix lands. This is the same `refusal-lifted-without-a-gate` shape r8 flagged.
97+
98+## Suite
99+
100+`cargo test -p ec-av1 --lib` -> **379 passed; 0 failed; 35 ignored** (`$HOME/.cache/golomb-suite-r9.log`; the extra ignored test vs r8 is the new pinned straddle gate).
lanes/inter16ab-r1.report.mdadded+74 -0
@@ -0,0 +1,74 @@
1+# lane-inter16ab r1 — 16x16-level AB partitions in inter frames
2+
3+## Verdict: GREEN for the AB half; the 1:4 half stays refused (narrowed refusal).
4+
5+## What changed
6+- `crates/ec-av1/src/decode.rs:2187` — `AB16_INTER_HITS` / `ab16_inter_hits_by_arm()` /
7+ `bump_ab16_inter()`: per-arm counters for HORZ_A/HORZ_B/VERT_A/VERT_B at 16x16 in an inter frame.
8+- `crates/ec-av1/src/decode.rs:20718` — `inter_leaf8!` macro: one 8x8 inter leaf of an AB partition
9+ (the body the `PARTITION_SPLIT` arm already ran per leaf, minus its own partition symbol, which an
10+ AB piece does not carry, and minus its dead `prev_leaves` bookkeeping).
11+- `crates/ec-av1/src/decode.rs:~21300` — the AB arm itself in the 16x16 partition chain of
12+ `decode_inter_frame_tile_with_cdfs`. libaom `decode_partition` visit order (decodeframe.c, BLOCK_16X16,
13+ `bsize2 = BLOCK_8X8`, `hbs = 2` mi):
14+ HORZ_A = TL 8x8, TR 8x8, bottom 16x8 · HORZ_B = top 16x8, BL 8x8, BR 8x8 ·
15+ VERT_A = TL 8x8, BL 8x8, right 8x16 · VERT_B = left 8x16, TR 8x8, BR 8x8.
16+ VERT_A/VERT_B take `Reach::vert_ab_partition()` (libaom `reconintra.c get_has_tr_table` swaps those
17+ squares onto `has_tr_vert_*`, class `visit-order-changes-availability`). No frame-edge guards: an AB
18+ value can only be read from the `has_cols16 && has_rows16` branch, i.e. exactly libaom's `has_rows`/
19+ `has_cols`, so all four quadrants are inside the frame. Every piece is >= 8x8, so
20+ `is_motion_variation_allowed_bsize` (min(bw,bh) >= 8) and `is_comp_ref_allowed` (bw+bh >= 16,
21+ blockd.h) hold unchanged — no OBMC/compound gate was added or removed.
22+- `crates/ec-av1/src/refusal_inventory.rs:70` — the refusal is NARROWED, not deleted:
23+ "an inter 16x16-level AB or 1:4 partition (…)" → "an inter 16x16-level 1:4 partition (HORZ_4/VERT_4
24+ — four 16x4 or 4x16 inter strips; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT,
25+ SPLIT or AB)".
26+- `crates/ec-av1/src/stream.rs:~7470` — gate
27+ `a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact`.
28+- `crates/ec-av1/examples/decode_probe.rs:36` — prints `inter_ab16: horz_a=… horz_b=… vert_a=… vert_b=…`
29+ so a recipe sweep can tell "aomenc never picked one" from "it did and we decoded it".
30+
31+## Gate
32+192x128, 6 frames, 8- AND 10-bit, 32 attempts per depth (tx-size-search 0/1 × cq × two sources ×
33+two motion steps), real aomenc with `--enable-rect-partitions=1 --enable-ab-partitions=1
34+--enable-1to4-partitions=0 --min-partition-size=8 --max-partition-size=16 --kf-max-dist=9999
35+--sb-size=64 --cpu-used=0`, each `--enable-*` spelled once (last-wins). Every decode-order frame is
36+compared Y/U/V against ffmpeg; refusals are counted, never SKIPped; a mismatch on an attempt with
37+zero AB hits fails the gate (`oos_mismatch`).
38+
39+Run:
40+`EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-inter16ab cargo test -p ec-av1 --lib a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions -- --nocapture`
41+
42+EVIDENCE: $HOME/.cache/inter16ab-suite-r1.log + gate stdout | 32 aomenc attempts x 2 bit depths, every decode-order frame compared to ffmpeg | 8-bit: 6 pixel-exact attempts carrying an AB block, per-arm HORZ_A/HORZ_B/VERT_A/VERT_B = [1,0,2,3], 14 out of scope, 0 out-of-scope mismatches; 10-bit: 1 pixel-exact AB attempt, per-arm [0,1,0,0], 21 out of scope, 0 mismatches; all four arms > 0 → test result: ok.
43+
44+## Residue
45+- deferred: the 16x16-level 1:4 pair (HORZ_4/VERT_4, four 16x4/4x16 inter strips) — needs the sub-8
46+ inter chroma-pair path (odd-strip `is_chroma_reference`, `ss_size_lookup[BLOCK_16X4]` → BLOCK_8X4,
47+ and `dec_build_inter_predictors`' `is_sub8x8_inter` chroma built from BOTH strips' MVs), which no
48+ inter block writer has today (`decode_inter_block` has no `has_chroma` parameter at all). Unblocked
49+ by threading `has_chroma` + the pair MC through `decode_inter_block`. This is the arm the films stop
50+ at, so the film probe is unchanged by this round.
51+- flagged (NOT this lane's defect): the X-structured 8-bit source at cq 46 desyncs in decode-order
52+ frame 4 (first bad luma pixel (183,0), 14685 pixels, max |delta| 92). Instrumented aomdec `EC_TRACE=1`
53+ reads ZERO `EC_PART_VAL … bsize=6 value>=4` in that entire stream, while our AB counters only rise in
54+ frames 4 and 5 — i.e. our AB reads there are read out of an already-diverged stream (classes
55+ `refusal-from-own-desync`, `counter-from-refused-stream`); on main the same stream stops on the old
56+ AB refusal at exactly that block (class `refusal-hides-a-defect`). The gate's cq list excludes it and
57+ says so in a comment.
58+- flagged (NOT this lane's defect): a `--tile-columns=1` arm of the same sweep PANICS in
59+ `mc::from_switchable_symbol` ("switchable_interp's alphabet is exactly 3 symbols") — the below-8x8
60+ inter-leaf desync signature already in the ledger. The tiled arm is therefore not in the gate.
61+- flagged: 10-bit cq 40 on the X source mismatches with zero AB blocks (found by the gate's own
62+ `oos_mismatch` counter); the 10-bit arm uses cq 28 in that slot instead.
63+- deferred: the ReelC census4 decode-order frame 1 case was not re-probed this round (tool budget).
64+
65+## Film probe
66+`ffmpeg -ss 900 -t 2 -i <ReelB> -c:v copy -an -f obu` → `decode_probe`:
67+before AND after this round the stop is at a 16x16-level 1:4 partition (before: the combined
68+"AB or 1:4" refusal, value=8 = PARTITION_HORZ_4 measured with `EC_AV1_TRACE=1` at mi=(12,44); after:
69+the narrowed 1:4 refusal), 1 frame completed (`EC_AV1_FINAL_DUMP` file count). Unchanged, as expected
70+for an AB-only lift.
71+
72+## Suite
73+`systemd-run --user --unit=inter16ab-suite-… -p MemoryMax=10G … cargo test -p ec-av1 --lib -j3` →
74+`test result: ok. 371 passed; 0 failed; 32 ignored` (log `$HOME/.cache/inter16ab-suite-r1.log`).
lanes/kf1200-r3.report.mdadded+130 -0
@@ -0,0 +1,130 @@
1+# lane-kf1200 r3 report — the partial-bottom-row desync, root cause found and fixed
2+
3+Tip `9d18288` on `lane-kf1200` (parent `bee8ec0`, main merged at `d85d7d2`).
4+
5+## Root cause (ONE symbol, not the partition path the charter suspected)
6+
7+The charter's premise — "our 32-level gathered `split_or_horz` CDF/ctx differs" —
8+is REFUTED by measurement. A cross-decoder range ladder over the whole partial
9+bottom superblock row shows every partition symbol of mi_row=400 in sync,
10+including the gathered ones (our `ctx` values equal libaom's
11+`partition_plane_context` minus its `bsl * PARTITION_PLOFFSET` offset, and every
12+`rng` matches):
13+
14+ aomdec EC_PART mi_row=400 mi_col=44 bsize=6 ctx=6 rng=55482 value=3 (SPLIT)
15+ ours OUR_PART mi_row=400 mi_col=44 bsize=6 ctx=2 rng=55482
16+ aomdec EC_PART mi_row=400 mi_col=44 bsize=3 ctx=0 rng=52288
17+ ours TRACE partition_w8 mi=(400,44) ctx=0 value=0 pre_rng=52288
18+ aomdec EC_PART mi_row=400 mi_col=46 bsize=3 ctx=0 rng=53128
19+ ours TRACE partition_w8 mi=(400,46) ctx=0 value=0 pre_rng=53128
20+
21+The first differing element is the `tx_depth` symbol of the SECOND 8x8 leaf:
22+
23+ aomdec EC_ISTEP mi_row=400 mi_col=46 name=tx_depth val=0 ctx=1 rng=42998
24+ ours EC_ISTEP mi_row=400 mi_col=46 name=tx_depth val=0 ctx=2 rng=54191
25+
26+Same decoded value, different CDF row, therefore a different interval narrowing:
27+the entropy stream is desynced from there on, and the rest of the row (and the
28+1595..1607 deblock spill) decodes as garbage. What the charter saw as "aomdec
29+reads a 16x8 where we read 32x16" was our *already desynced* reader at
30+mi (400,48), one block later.
31+
32+`ctx` comes from libaom `get_tx_size_context`: `above_txfm_context[0] >=
33+max_tx_wide` + `left_txfm_context[0] >= max_tx_high`. The left neighbour of
34+(400,46) is the 8x8 leaf at (400,44), which is `skip=1` and whose `tx_depth`
35+resolved to TX_4X4 — so libaom's `set_txfm_ctxs` published 4 and its left term
36+is 0. Our `decode_leaf8` skip branch fell through to a hardcoded
37+`fill_lf_grid(leaf_mi, 2, 8, 0)`, publishing 8, so our left term read 1.
38+
39+An intra block reads `tx_depth` whether or not it is skipped (libaom
40+`read_intra_frame_mode_info` calls `read_tx_size` above the skip branch); only a
41+skipped *inter* block records its block size instead of its transform.
42+
43+## Change
44+
45+- `crates/ec-av1/src/decode.rs:10330` — `fill_lf_grid(leaf_mi, 2, resolved as u8, 0)`
46+ (was the literal `8`). The non-skip TX_4X4 branch already returned early with 4;
47+ only the skip path was wrong. One line.
48+- `crates/ec-av1/src/decode.rs:2652` `trace_edge()` + 5 call sites — `OUR_PART
49+ mi_row/mi_col/bsize/ctx/rng` under `EC_AV1_TRACE` for the three gathered
50+ frame-edge partition reads (there was no emitter for them, only for the full
51+ alphabet reads), plus `pre_rng` on the 8x8 partition trace. Instrument only.
52+- `crates/ec-av1/examples/decode_probe.rs:34` — prints `skip_split_tx`.
53+
54+Sibling sweep for the same shape (a skip branch publishing the block side where
55+the resolved transform belongs): `fill_lf_grid` has 6 call sites.
56+`decode_block` (9872) already passes `logical_tx`; the inter 8x8 leaf (20449)
57+passes `if split8 {4} else {8}`; the inter-leaf skip early-return (19644) passes
58+8, which is CORRECT — a skipped inter block records its block size. The 4x4 leaf
59+(10541) passes 4. Only 10330 was wrong.
60+
61+## Gates
62+
63+1. NEW `the_reelb_ss600_key_frame_skipped_split_tx_decodes_pixel_exact`
64+ (`crates/ec-av1/src/stream.rs`), pinning
65+ `crates/ec-av1/fixtures/reelb_ss600_key_frame.obu` (94717 B, sha256
66+ `36de46676ed7de7049d4dabe8571d8cd31c8a1f53d72011c0ee532a7c6725cd6`, hashed
67+ twice, `git add -f`, present in `git ls-files`): one 3840x1608 yuv420p10le key
68+ frame. HARD-asserts `skip_split_tx_hits > 0` (24 in this frame) then Y/U/V vs
69+ ffmpeg's 10-bit decode. Fixture, not aomenc, because the shape is not
70+ synthetically reachable: 80 recipes this round (4 frame shapes x 2 lavfi
71+ sources x cq 32/35/40/45/48/50/55/58/63 x cpu-used 0/3 x 8/10-bit, all with
72+ `--enable-tx-size-search=1 --enable-filter-intra=1 --min-partition-size=8`)
73+ returned `skip_split_tx_hits == 0` every time. Widths with a partial right
74+ column (200, 264, 136, 776, 1288) additionally hit the existing named refusal
75+ "a 16x16 block whose true edge cuts through both axes", so the charter's
76+ 200x72 / 72x200 / 136x104 / 264x136 shapes cannot be compared at all today.
77+2. WIDENED `a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz_decodes_pixel_exact`:
78+ three more partial-bottom-row shapes (200x72, 136x88, 264x104 — 2/4/6 mi rows)
79+ and an `--enable-tx-size-search=1` arm. The whole recipe ran with
80+ `--enable-tx-size-search=0`, so no block in it could carry a nonzero
81+ `tx_depth` at all (class `tool-disabled-in-every-gate`) — that is why 8 green
82+ arms never saw this defect. 18 arms compared pixel-exact, 10 named refusals
83+ (all the double-axis 16x16 one), `edge_horz_total`/`edge_sub_total` still
84+ hard-asserted; the `skip_split_tx` counter is reported, not gated, there.
85+
86+## 24-key-frame census (1 frame each, ours vs ffmpeg 10-bit, differing BYTES)
87+
88+r2: 11/24 exact, four multi-million-byte rows. r3: 17/24 exact, **luma exact on
89+all 24**, every remaining row chroma-only.
90+
91+| -ss | Y | U | V | r2 total |
92+|---|---|---|---|---|
93+| 0,300,600,1200,1500,1800,2400,3000,3300,3600,4200,4500,5100,5400,5700,6900 | 0 | 0 | 0 | 4 of these were 16.6M/48771/42343/39971/16375 |
94+| 900 | 0 | 40 | 50980 | 14057191 |
95+| 2100 | 0 | 1289 | 1067 | 15148697 |
96+| 2700 | 0 | 231 | 739 | 7726168 |
97+| 3900 | 0 | 4 | 4 | 7554023 |
98+| 4800 | 0 | 29 | 5 | 34 |
99+| 6000 | 0 | 210 | 0 | 15449720 |
100+| 6300 | 0 | 4 | 0 | 15410664 |
101+| 6600 | 0 | 124 | 124 | 15180826 |
102+
103+The four charter segments (600/2400/3300/5700) are all 0/0/0.
104+
105+## EVIDENCE
106+
107+EVIDENCE: /home/user/.cache/kf1200-tmp/a600s.part + o600s.trace | aomdec EC_TRACE=1 EC_TRACE_MODE_STEP=1 vs our EC_AV1_TRACE=1 EC_TRACE_MODE_STEP=1 on the pinned 1-frame stream | first differing element mi(400,46) tx_depth ctx 2 vs 1, rng 54191 vs 42998; after the fix ours reads ctx=1 rng=42998
108+EVIDENCE: /home/user/.cache/kf1200-tmp/ours600.yuv vs ref600.yuv | EC_PROBE_OUT16 decode vs `ffmpeg -pix_fmt yuv420p10le` | cmp -l = 0 differing bytes of 18524160 (was 48771)
109+EVIDENCE: /home/user/.cache/kf1200-census-r3.log | 24 key frames extracted with `-frames:v 1 -c:v copy`, per-plane byte diff vs ffmpeg | 17/24 all-zero, luma zero on 24/24
110+EVIDENCE: cargo test -p ec-av1 --lib a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz -- --nocapture | 7 shapes x 2 tx arms x 2 depths | 18 arms pixel-exact, 10 named refusals, edge bits 64-level horz/vert up to 3, sub-level up to 9
111+EVIDENCE: cargo test -p ec-av1 --lib the_reelb_ss600_key_frame -- --nocapture | pinned fixture decode vs ffmpeg 10-bit | "24 skipped 8x8 TX_4X4 leaves, frame pixel-exact"
112+
113+## Suite
114+
115+`cargo test -p ec-av1 --lib` (systemd unit, EC_AV1_REQUIRE_AOMENC=1): **379 passed, 0 failed,
116+33 ignored**, 514.26 s — `/home/user/.cache/kf1200-suite-r3.log`.
117+
118+## Residue
119+
120+- deferred(-ss 4800, U=29/V=5): chroma-only, 8x4 chroma patch at (540,1200) —
121+ unchanged by this round, still the r2 pair-mi sibling hypothesis. Unblocked by
122+ an `EC_IMODE_VAL`/`EC_PRED` ladder at luma mi ~(270,600); I ran out of turn
123+ budget after the census. Same for the other six chroma-only rows (900 V=50980
124+ is the largest and the only one big enough to be a second desync rather than a
125+ prediction/edge-filter off-by-one).
126+- accepted: the charter's partial-RIGHT-column gate shapes (200x72 etc.) cannot
127+ be compared until the "16x16 block whose true edge cuts through both axes"
128+ refusal is lifted; they are in the gate and currently take the refusal arm.
129+- No refusal was lifted this round; `refusal_inventory.rs` / `gate_coverage.rs`
130+ untouched.
lanes/kf900-r1.handoff.mdadded+122 -0
@@ -0,0 +1,122 @@
1+# lane-kf900 r1 HANDOFF — mid-frame entropy desync on the 4K 10-bit AV1 key frames
2+
3+Tip: `81b16cc` on `lane-kf900` (worktree `/home/user/Documents/Code/Rust/edith_codecs-kf900`,
4+base `18bf7dc` = main tip at start, no rebase needed).
5+
6+## ROOT CAUSE (fixed)
7+
8+`crates/ec-av1/src/decode.rs`, `decode_leaf8` tail — was:
9+
10+```rust
11+neighbours.fill_lf_grid(leaf_mi, 2, 8, 0); // literal block side
12+```
13+
14+now `neighbours.fill_lf_grid(leaf_mi, 2, resolved as u8, 0);`
15+
16+libaom calls `set_txfm_ctxs(mbmi->tx_size, bw, bh, skip_txfm && is_inter_block(mbmi), xd)`
17+(`decodemv.c`). For an INTRA block that skip term is **always 0**, so a *skipped* 8x8 intra
18+leaf whose `tx_depth` symbol resolved to `TX_4X4` still publishes **4** to the next block's
19+`get_tx_size_context` (`pred_common.h:342`). Our tail wrote **8** for every 8x8 leaf,
20+including the skipped-and-split ones (`decode_leaf8`'s non-skip `resolved == 4` branch had
21+its own early return with the correct 4 — only the skip path fell through to the literal).
22+
23+Consequence: the 8x16 strip below such a leaf computed `tx_size_context_rect` = 2 where
24+libaom computes 1, and read `tx_size_cat1` **row 2** instead of row 1 — same 3-symbol
25+alphabet, wrong CDF row (class `wrong-alphabet-same-value`). The msac range diverged
26+mid-frame, **no refusal**, everything after it garbage.
27+
28+### Evidence chain (all reproducible from `/home/user/.cache/kf900/`)
29+- `s900_1.obu` (1 frame, sha256 `a273ae99328388be14a1ff8fa1c5a6d391a9948159eaef120e1b50e02015eb83`,
30+ hashed twice from two independent `ffmpeg -ss 900 -t 2 -c:v copy -f obu` extracts).
31+- Pre-fix first bad luma sample: **row 186 col 1803**, delta 2, max |d| 929, 5405035 luma
32+ samples differing. Pre-filter (`EC_AV1_PREFILT_DUMP16` ours vs aomdec) first difference
33+ row 192 col 512 → recon, not loop filter.
34+- Cross-decoder block ladder (new `EC_IMODE` rung, mirrors aomdec `decodemv.c:818`):
35+ identical for 3543 blocks, first divergence entering mi (60,124).
36+- Symbol ladder (`EC_TRACE_MODE_STEP`, both sides) inside mi (60,122) — a `BLOCK_8X16`
37+ (aomdec `bsize=4`): identical through `filter_intra_mode val=0 rng=33750`, then
38+ aomdec `tx_depth val=0 ctx=1 cat=1 rng=53206`, ours `ctx=2`.
39+- New `EC_TXCTX` rung: `mi_row=60 mi_col=122 w=8 h=16 above_px=8 left_px=16 ctx=2`;
40+ `above_px` should be 4. New `EC_LFGRID` rung: `mi_row=58 mi_col=122 w_mi=2 h_mi=2
41+ tx_px=8` written by the leaf above, which had `skip=1` and `tx_depth val=1` (TX_4X4).
42+
43+## RESULT — 24 key frames, 1-frame truncation each, ours (EC_PROBE_OUT16) vs `ffmpeg -pix_fmt yuv420p10le`
44+
45+`bytes_before` = census4 pre-fix all-plane byte diff; `bytes_after` = same, post-fix;
46+`luma_after` = differing **luma samples** post-fix. Every segment decodes `OK` (no refusal)
47+at 1 frame. Script: `/home/user/.cache/kf900/census.sh`, raw: `/home/user/.cache/kf900/census.tsv`.
48+
49+| -ss | bytes_before | bytes_after | luma_after |
50+|----:|-------------:|------------:|-----------:|
51+| 0 | 0 | 0 | 0 |
52+| 300 | 463 | 463 | 0 |
53+| 600 | 48771 | 0 | 0 |
54+| 900 | 14057195 | 51272 | 0 |
55+| 1200 | 14 | 14 | 0 |
56+| 1500 | 16649701 | 108644 | 0 |
57+| 1800 | 248 | 248 | 0 |
58+| 2100 | 15147518 | 2383 | 0 |
59+| 2400 | 42343 | 0 | 0 |
60+| 2700 | 7726287 | 1243 | 0 |
61+| 3000 | 0 | 0 | 0 |
62+| 3300 | 44500 | 4529 | 0 |
63+| 3600 | 1 | 1 | 0 |
64+| 3900 | 7554020 | 8 | 0 |
65+| 4200 | 0 | 0 | 0 |
66+| 4500 | 0 | 0 | 0 |
67+| 4800 | 2348 | 2348 | 0 |
68+| 5100 | 0 | 0 | 0 |
69+| 5400 | 0 | 0 | 0 |
70+| 5700 | 0 | 0 | 0 |
71+| 6000 | 15450360 | 10207 | 0 |
72+| 6300 | 15410936 | 146881 | 0 |
73+| 6600 | 15181681 | 67588 | 0 |
74+| 6900 | 0 | 0 | 0 |
75+
76+**24/24 luma-exact.** All remaining diffs are chroma-only.
77+
78+## OPEN RESIDUE
79+
80+1. **Chroma-only defect (deferred — needs its own lane).** On `s900_1.obu` after the fix:
81+ Y 0, U 266 samples (max |d| 23), V 47927 (max |d| 2). First at chroma (102,688) =
82+ luma (204,1376) = mi (51,344). It is **pre-filter** (`pf/ours2.f0` vs `pf/aom.f0`:
83+ Y 0, U 228, V 47800 first at chroma row 102 col 689) → chroma *reconstruction*, not a
84+ loop filter. Luma being exact proves the entropy stream is exact, so this is a
85+ prediction/inverse-transform bug on one chroma path. Unblocked by: an `EC_TRACE_COEFF`
86+ plane-1/2 ladder at mi (51,344) — the entropy side is now a fixed reference.
87+2. **The two new gate arms FAIL on their counter assert** (`stream.rs`, after
88+ `a_real_aomenc_multi_tile_intra_stream_...`):
89+ `a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_tx_split_decodes_pixel_exact`
90+ and its `_10bit_` twin. Both **decode 6/6 attempts pixel-exact**, but
91+ `skip_split_tx_hits() == 0` — the shared `gradients_source` at 256x128 never makes
92+ aomenc pick a skipped 8x8 intra leaf that also splits its transform (skip wants the
93+ residual quantised away, TX_4X4 wants detail; the film has both at 4K).
94+ They are committed FAILING on purpose: an assert that never fires is the
95+ `tool-disabled-in-every-gate` class, and `skip_split_tx_hits` was `pub` with **zero**
96+ callers anywhere before this round.
97+
98+## EXACT NEXT STEP
99+
100+Sweep for a recipe, then keep or replace the assert:
101+`$HOME/.cache/cargo-target-kf900/release/examples/decode_probe <stream.obu>` now prints
102+`skip_split_tx: N` — sweep aomenc without rebuilding the test binary.
103+On the film's own frame it prints **15**, so the counter is correct.
104+Suggested axes (none tried yet): 4K-ish frame sizes (the film's leaves are 8x8 inside 64x64
105+SBs at 3840 wide), `--cpu-used=0`, `cq-level` 40..58, and a source with fine detail plus
106+flat regions (`mandelbrot`, `testsrc2` + `noise=all_seed=N:alls=20`), 8- and 10-bit arms.
107+**If no recipe reaches it after a measured sweep** (record every attempt), the charter's
108+fallback applies: commit `crates/ec-av1/fixtures/reelb_kf900.obu` (the 484640-byte
109+`/home/user/.cache/kf900/s900_1.obu`, sha256 above) plus a test that decodes it and
110+compares against a **stored sha256 of the ffmpeg output** (do not commit the yuv), and
111+assert `skip_split_tx_hits() >= 15`.
112+
113+Suite: armed detached as user unit `kf900-suite-r1`, log `$HOME/.cache/kf900-suite-r1.log`.
114+Check with `grep -E "^test result|FAILED" $HOME/.cache/kf900-suite-r1.log`. Expect the two
115+new gate arms to be the failures until the recipe lands.
116+
117+## NOT DONE (charter items)
118+- deferred: block-position printing on refusal in `decode_probe` (frame index, mi_row,
119+ mi_col, bsize) — not started, ran out of turns; unblocked by ~10 minutes on
120+ `decode.rs`'s `unsupported()` call sites.
121+- deferred: `refusal_inventory.rs` / `gate_coverage.rs` updates — this round lifted no
122+ refusal, so neither file needed a change; re-check once the gate recipe lands.
lanes/kf900-r2.report.mdadded+145 -0
@@ -0,0 +1,145 @@
1+# lane-kf900 r2 report -- the chroma edge-filter type reads the wrong mi
2+
3+Tip: `1fad25c` on `lane-kf900` (worktree `/home/user/Documents/Code/Rust/edith_codecs-kf900`,
4+base `18bf7dc`; main has since moved to `4eff3a1` -- NOT rebased, see residue).
5+
6+## 1. r1 suite
7+
8+`$HOME/.cache/kf900-suite-r1.log` was still running at round start and was stopped by me
9+(`systemctl --user stop kf900-suite-r1`) before the first rebuild, so it never printed a
10+`test result` line: 288 tests started, 229 `ok`, 0 `FAILED` at the stop point. Its two
11+known-failing arms were rewritten this round anyway; r2's suite below is the real number.
12+
13+## 2. The gate arms that asserted an unreachable counter -- 108 measured recipes, all zero
14+
15+`skip_split_tx_hits()` counts a SKIPPED 8x8 intra leaf whose `tx_depth` resolved to `TX_4X4`
16+(the r1 defect). Sweep (`$HOME/.cache/kf900/sweep/sweep.sh`, raw
17+`results.tsv` + `results10.tsv`): 4 sources (`geq` half-flat/half-noise, `mandelbrot`,
18+`testsrc2`, gray+`noise=all_seed=49`) x cq {55,59,63} x `--cpu-used` {0,1,2} x {8,10}-bit,
19+all with `--enable-tx-size-search=1 --min-partition-size=8 --enable-rect-partitions=1
20+--kf-max-dist=1 --limit=1`, 256x192. **72 8-bit + 36 10-bit = 108 attempts, `skip_split_tx: 0`
21+on every one that decoded.** Cause: libaom's encoder forces `tx_size` to the block maximum
22+once it picks `skip_txfm`, so aomenc never writes this combination. The film's encoder does.
23+
24+EVIDENCE: $HOME/.cache/kf900/sweep/results.tsv + results10.tsv | 108 aomenc encodes, each
25+decoded by `decode_probe` | `skip_split_tx: 0` in 108/108 (2 recipes at N=4 -- see residue 3)
26+
27+Fallback taken (charter-sanctioned): `crates/ec-av1/fixtures/reelb_kf900.obu`, the 484640-byte
28+1-frame extract, sha256 `a273ae99328388be14a1ff8fa1c5a6d391a9948159eaef120e1b50e02015eb83`
29+(two independent `ffmpeg -ss 900 -t 2 -c:v copy -f obu` extracts hashed identically, r1).
30+`git ls-files` shows it tracked. New gate
31+`stream.rs::a_10bit_key_frame_with_skipped_8x8_intra_leaves_that_split_their_transform_decodes_luma_exact`
32+hard-asserts `skip_split_tx_hits() >= 15` (actual 15) and compares the **luma** plane against
33+`ffmpeg -pix_fmt yuv420p10le`. U/V are the open residue, so the gate pins luma only and says so.
34+The two multi-tile arms keep their pixel-exact comparison and point at this gate.
35+
36+EVIDENCE: crates/ec-av1/fixtures/reelb_kf900.obu | `cargo test -p ec-av1 --lib skipped_8x8 chroma`
37+| 15 passed / 0 failed, `skip_split_tx: 15`, Y sha256
38+1ffd0c103368793762637b2152c2062042fe3a14af97045182adc4790c4b5c12 == ffmpeg's Y
39+
40+## 3. Chroma residue -- root cause found and fixed (one of at least two)
41+
42+`decode.rs`, `Neighbours::smooth_uv_neighbour` (now at :4640): added
43+`let (mi_r, mi_c) = (mi_r & !1, mi_c & !1);`.
44+
45+libaom `set_mi_row_col` (`blockd.h`) snaps to the chroma REFERENCE block first --
46+`base_mi = &xd->mi[-(mi_row & ss_y) * stride - (mi_col & ss_x)]` -- and only then takes
47+`chroma_above_mbmi = base_mi[-stride]` / `chroma_left_mbmi = base_mi[-1]`. A sub-8 pair codes
48+its chroma at the ODD mi, so we looked one mi row/column too far, the mi-exact slot never
49+matched, and the coarse SUB-grid fallback answered.
50+
51+Effect: `get_intra_edge_filter_type` (`reconintra.c`) 0 where libaom has 1, which flips
52+`av1_use_intra_edge_upsample(8, 4, -6, type)` (`blk_wh == 12`: false at type 1, TRUE at type 0).
53+We upsampled an edge libaom leaves alone.
54+
55+Ladder (chroma 8x4 at (688,100) = mi (51,344), V_PRED `p_angle=84`, `ft=1` in aomdec):
56+aomdec `EC_PREDOUT sum=15924`, ours `sum=15930`; per-sample +1 at rows 2/3, cols 1,2,4.
57+Hand-simulating both walks from the real above row (A[-1..7] = 495,495,496,497,498,498,499,499,499,
58+`dx = dr_intra_derivative(84) = 7`) reproduces 15924 unfiltered/un-upsampled and 15930 through
59+`av1_upsample_intra_edge_high` -- the upsample flag was the whole difference.
60+
61+EVIDENCE: $HOME/.cache/kf900/pred_aom.txt + pred_ours.txt | EC_PRED on aomdec and decode_probe
62+over reelb_kf900.obu | EC_PREDOUT 15924 vs OUR_PRED 15930; after the fix the block is 0-diff and
63+the frame's first chroma difference moves (102,688) -> (195,640)
64+
65+Not the cause (ruled out this round): per-plane quantizer deltas (`EC_AV1_TRACE` on the frame:
66+`base_q_idx=35 y_dc=0 u_dc=0 u_ac=0 v_dc=0 v_ac=0`, and `plane_q_delta()` is applied at every
67+chroma dequant call site anyway).
68+
69+Sibling gates re-run after the fix (`chroma` + `skipped_8x8` filters): 15 passed, 0 failed --
70+includes `..._chroma_edge_filter_reads_a_sub16_neighbours_uv_mode...`,
71+`..._directional_chroma...`, `..._smooth_paeth_chroma...`, `..._4to1_or_sub8_rect...`,
72+`the_chroma_rect_gates_excluded_seed_46...`.
73+
74+## 4. 24-key-frame census, post-fix (per-plane DIFFERING SAMPLES, not bytes)
75+
76+Recipe `$HOME/.cache/kf900/census_r2.sh` (r1's `census.sh` with a per-plane comparator):
77+`ffmpeg -ss <s> -t 2 -c:v copy -f obu`, truncated to 1 frame, `EC_PROBE_OUT16` vs
78+`ffmpeg -pix_fmt yuv420p10le`. Raw: `$HOME/.cache/kf900/census_r2.tsv`.
79+NOTE the metric changed from r1's all-plane differing BYTES to per-plane differing SAMPLES.
80+
81+| -ss | Y | U | V | max abs Y/U/V | r1 bytes_after |
82+|----:|--:|--:|--:|:--------------|---------------:|
83+| 0 | 0 | 0 | 0 | 0/0/0 | 0 |
84+| 300 | 0 | 219 | 220 | 0/8/7 | 463 |
85+| 600 | 0 | 0 | 0 | 0/0/0 | 0 |
86+| 900 | 0 | 221 | 47912 | 0/23/2 | 51272 |
87+| 1200 | 0 | 0 | 0 | 0/0/0 | 14 |
88+| 1500 | 0 | 0 | 0 | 0/0/0 | 108644 |
89+| 1800 | 0 | 0 | 0 | 0/0/0 | 248 |
90+| 2100 | 0 | 1041 | 1008 | 0/1/1 | 2383 |
91+| 2400 | 0 | 0 | 0 | 0/0/0 | 0 |
92+| 2700 | 0 | 442 | 800 | 0/7/3 | 1243 |
93+| 3000 | 0 | 0 | 0 | 0/0/0 | 0 |
94+| 3300 | 0 | 0 | 0 | 0/0/0 | 4529 |
95+| 3600 | 0 | 0 | 0 | 0/0/0 | 1 |
96+| 3900 | 0 | 4 | 4 | 0/1/1 | 8 |
97+| 4200 | 0 | 0 | 0 | 0/0/0 | 0 |
98+| 4500 | 0 | 0 | 0 | 0/0/0 | 0 |
99+| 4800 | 0 | 2316 | 5 | 0/3/1 | 2348 |
100+| 5100 | 0 | 0 | 0 | 0/0/0 | 0 |
101+| 5400 | 0 | 0 | 0 | 0/0/0 | 0 |
102+| 5700 | 0 | 0 | 0 | 0/0/0 | 0 |
103+| 6000 | 0 | 210 | 0 | 0/3/0 | 10207 |
104+| 6300 | 0 | 145195 | 0 | 0/38/0 | 146881 |
105+| 6600 | 0 | 30873 | 897 | 0/19/7 | 67588 |
106+| 6900 | 0 | 0 | 0 | 0/0/0 | 0 |
107+
108+**24/24 luma-exact; 15/24 now FULLY exact** (were 10/24 at r1: 1200, 1500, 1800, 3300, 3600
109+went to zero on all planes). Segments 1500 (108644 bytes) and 3300 (4529) collapsed to 0.
110+
111+EVIDENCE: $HOME/.cache/kf900/census_r2.tsv | 24 x (extract 2 s, truncate to 1 frame, decode
112+ours + ffmpeg, per-plane compare) | Y 0 on all 24, all-plane 0 on 15
113+
114+## 5. Suite
115+
116+`systemd-run --user --unit=kf900-suite-r2 -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3`
117+-> `$HOME/.cache/kf900-suite-r2.log`:
118+**`test result: ok. 373 passed; 0 failed; 32 ignored; 0 measured; 0 filtered out; 1073.65s`**
119+(r1's two committed-failing arms are gone: they now assert only what they can reach, and the
120+counter moved to the fixture gate. 373 = 371 on main's tip + the fixture gate + r1's arms.)
121+
122+## Residue
123+
124+1. **fix-now (next round): the chroma RESIDUAL defect.** First remaining difference on the
125+ s=900 frame is chroma (195,640) = mi (97,320). Its PREDICTION is bit-exact
126+ (`EC_PREDND mi_row=97 mi_col=320 plane=1 sum=16384 / plane=2 sum=16352` on both sides), so
127+ the divergence is dequant / inverse transform / chroma `tx_type` on an 8x4 chroma unit.
128+ Unblocked by an `EC_TRACE_COEFF` plane-1/2 ladder at mi (97,320) -- entropy is a fixed
129+ reference now (luma exact frame-wide). Suspect list unchanged apart from CfL and per-plane
130+ delta_q, both now ruled out for this frame.
131+2. **fix-now (own lane): a real aomenc 10-bit stream we decode WRONG with no refusal.**
132+ `testsrc2=s=256x192` at `--bit-depth=10 --cq-level=59 --cpu-used=0` (also `--cpu-used=1`),
133+ full recipe in `$HOME/.cache/kf900/sweep/sweep.sh`, stream md5
134+ `e5f033d8fe34e4418d8cca3ac9d2b595`: `decode_probe` reports `OK: 1 frames decoded` and
135+ `skip_split_tx: 4`, but 73687 of 73728 samples differ from ffmpeg, max |d| 933. This is the
136+ only pair of the 108 recipes with a non-zero counter, and it is a SILENT desync -- a
137+ pixel-exact gate for `skip_split_tx` becomes possible the moment it is fixed.
138+ Reproducer in `$HOME/.cache/kf900/sweep/{g.obu,g.yuv,r.yuv}`.
139+3. **deferred: rebase onto main `4eff3a1`** (lane branched at `18bf7dc`; main gained
140+ lane-sb128b in between) -- not done because the r1 suite was mid-run on this worktree at
141+ round start and the round's budget went to the two defects; unblocked by a clean
142+ `git rebase main` + one suite run.
143+4. **deferred (r1 carry-over): block-position printing on refusal in `decode_probe`** and
144+ `refusal_inventory.rs` / `gate_coverage.rs` updates -- this round lifted no refusal, so
145+ neither file changed; unblocked by ~10 min on `decode.rs`'s `unsupported()` call sites.
lanes/kf900-r3.handoff.mdadded+117 -0
@@ -0,0 +1,117 @@
1+# lane-kf900 r3 HANDOFF
2+
3+Tip: see `git log --oneline -3 lane-kf900` (merge `4267082`, fix+gate `667eb51`, this
4+commit). Worktree `/home/user/Documents/Code/Rust/edith_codecs-kf900`, base `18bf7dc`,
5+merged main `8e9ba81`. Full detail in `lanes/kf900-r3.report.md`.
6+
7+## 1. The silent 10-bit desync -- ROOT CAUSE FOUND AND FIXED
8+
9+Stream: `testsrc2=s=256x192 --bit-depth=10 --cq-level=59 --cpu-used=0`, recipe
10+`$HOME/.cache/kf900/sweep/sweep.sh`, md5 `e5f033d8fe34e4418d8cca3ac9d2b595`
11+(`$HOME/.cache/kf900/sweep/g.obu`).
12+
13+Symbol: the FIRST block's Y palette colours. mi(0,0) is BLOCK_32X16, DC_PRED,
14+2-colour Y palette. `decode.rs::read_palette_colors_y` / `read_palette_colors_uv`
15+read every raw literal at a hardcoded 8 bits; libaom `decodemv.c:478` (Y) and
16+`:509` (UV) size them all by the sequence `bit_depth`: first colour
17+`aom_read_literal(r, bit_depth)`, `min_bits = bit_depth - 3` (Y/U) and
18+`bit_depth - 4` (V delta mode), `range = (1 << bit_depth) - first - 1` (Y) /
19+`- first` (U), clamp bound `(1 << bit_depth) - 1`, V wrap modulus `1 << bit_depth`.
20+So a 10-bit palette block read TWO BITS TOO FEW per transmitted colour and decoded
21+the whole rest of the tile from the wrong bit position, with no refusal.
22+
23+Fix (commit `667eb51`): `let bd = u32::from(bit_depth());` (the already-present
24+thread-local, decode.rs:200) inside both readers; no signature threading.
25+
26+Before: `OK: 1 frames decoded` with 73687/73728 samples differing from ffmpeg,
27+max |d| 933 (Y 49117/49152, U 12286/12288, V 12284/12288, first diff at (0,0)).
28+After: the entropy stream is in lockstep with aomdec -- our first 1024
29+`EC_PAL`/`EC_PAL_VAL` lines are byte-identical to aomdec's `EC_TRACE_PALETTE`, and
30+the block grid follows aomdec's (`EC_IMODE` mi(0,0) 32x16, (4,0) 16x16, (4,4) 16x16,
31+(0,8) 32x8, (2,8) 32x8, (4,8) 32x8 == aomdec bsize 8,6,6,19,19,19).
32+
33+WHY 108 SWEEP RECIPES AND A RANGE LADDER MISSED IT: raw literals are EQUIPROBABLE
34+and at the ranges this content reaches an equiprobable read is a FIXED POINT of the
35+msac range (62728 -> v=31364, either branch 31364, renorm 62728). A cross-decoder
36+RANGE ladder stays bit-identical straight through a wrong literal WIDTH; only the
37+decoded VALUE moves. aomdec and we both printed `rng=62728` and disagreed on the
38+first colour index (0 vs 1). Compare VALUES, not range alone.
39+
40+This stream is NOT a whole-frame gate: at mi(4,8) it hits a 32x8 (4:1) strip that
41+really uses a palette, and the 1:4 rect decoder is called with `palette: None`
42+(decode.rs:7167 and :7556), so it now stops at the pre-existing refusal
43+`"a 1:4 rect strip that actually uses a palette (reconstruction is not ported at
44+this shape)"`. Silent desync -> named refusal.
45+
46+## 2. The chroma residual at mi(97,320) -- GONE, and not by my fix
47+
48+r2's first remaining chroma difference on the s=900 4K key frame -- chroma (195,640)
49+= mi(97,320) -- is ZERO on the merged tree. No ladder was needed: the census (below)
50+came back clean. Credit is the merged lane-reelckf `55532c7` (skipped CfL blocks still
51+predict; the 1:4 chroma pair edge-filter mi), NOT the palette fix -- the film frame
52+reads zero palette symbols
53+(`EC_AV1_TRACE=1 decode_probe crates/ec-av1/fixtures/reelb_kf900.obu | grep -c "^EC_PAL "`
54+= 0).
55+
56+The charter's chroma-`tx_type` suspicion was audited and cleared rather than needed:
57+`av1_get_tx_type`'s `plane > 0` intra path is `intra_mode_to_tx_type(mbmi,
58+PLANE_TYPE_UV)` = our `default_intra_tx_type` (decode.rs:3229) fed with
59+`uv_predict_mode`, which already maps `UV_CFL_PRED` -> `DC_PRED`; the
60+`!av1_ext_tx_used[tx_set_type][tx_type]` narrowing can only bite at
61+`txsize_sqr_up >= TX_32X32`, and both chroma call sites already force `DCT_DCT`
62+there (decode.rs:6089 `chroma_w.max(chroma_h) >= 32`, decode.rs:9254 `side >= 32`).
63+All four values the table can produce are members of `EXT_TX_SET_DTT4_IDTX` and
64+`..._1DDCT`, the only two intra sets below 32.
65+
66+## 3. Census -- 24/24 BIT-EXACT (was 15/24 at r2)
67+
68+`$HOME/.cache/kf900/census_r3.sh` -> `$HOME/.cache/kf900/census_r3.tsv`: all 24
69+key frames decode `OK: 1 frames decoded, 3840x1608` with Y=U=V=0 differing samples
70+and max |d| 0/0/0. Full table in the report.
71+
72+## 4. Gate state
73+
74+NEW, committed, PASSING:
75+`crates/ec-av1/src/stream.rs::a_real_aomenc_palette_stream_decodes_pixel_exact_at_8_and_10_bit`
76+-- the existing 8-bit `..._with_palette_y_...` recipe (smptebars 64x64,
77+`--tune-content=screen --enable-palette=1`, rect/AB/1:4 off) with the depth as the
78+only variable (depth flags appended AFTER the base recipe: last flag wins). Each arm
79+hard-asserts `decode::palette_hits()` moved and compares Y, U and V vs ffmpeg.
80+`cargo test -p ec-av1 --lib palette_stream_decodes_pixel_exact_at_8_and_10` -> 1
81+passed, 0 failed. DISCRIMINATION CHECK RUN: with `let bd = u32::from(bit_depth())`
82+reverted to `let bd = 8u32` the test FAILS on "luma at 10-bit" and the 8-bit arm
83+still passes (tree restored from a scratch copy afterwards).
84+
85+No refusal was lifted this round, so `refusal_inventory.rs` / `gate_coverage.rs` are
86+untouched (byte-identical to main's).
87+
88+Class sweep for the same shape (bit-depth-scaled reader hardcoding 8):
89+`grep -n "literal(8)\|255i32\|, 255)\|(1 << 8)" crates/ec-av1/src/decode.rs` -> only
90+the qindex clamps at :332 and :544 survive, and those are correct at every depth.
91+No sibling instances.
92+
93+## 5. Suite state -- INCOMPLETE, ZERO FAILURES SO FAR
94+
95+`systemd-run --user --unit=kf900-suite-r3-1788328486 -p MemoryMax=10G ... cargo test
96+-p ec-av1 --lib -j3 > $HOME/.cache/kf900-suite-r3.log`. At the turn cap: **272 `ok`,
97+0 `FAILED`, no `test result` line yet**. Resolve the unit name with
98+`systemctl --user list-units --all | grep kf900` before believing it finished.
99+
100+## 6. EXACT NEXT STEP
101+
102+1. `grep -E "^test result|FAILED" $HOME/.cache/kf900-suite-r3.log` -- expect
103+ `374 passed; 0 failed` (373 at r2 + the new depth gate). If a `FAILED` appears,
104+ the only behavioural change on this branch is the palette bit-depth widening, so
105+ look at the three existing palette gates first
106+ (`a_real_aomenc_stream_with_palette_y_...`, `..._palette_uv_...`,
107+ `..._rect_palette_...`, `a_real_aomenc_multi_tile_palette_stream_...`).
108+2. Merge into main.
109+3. Then the open lane work, in this order:
110+ a. Tighten `..._skipped_8x8_intra_leaves_that_split_their_transform_decodes_luma_exact`
111+ from luma-only to all three planes -- the census is 24/24 exact now, so its U/V
112+ arms should hold.
113+ b. Port palette reconstruction to the 1:4 rect decoder (decode.rs:7167 and :7556
114+ pass `palette: None`); that is the ONLY thing between us and a whole-frame
115+ pixel gate for `skip_split_tx` on the pinned 10-bit stream above. Probably
116+ lane-palette2's territory.
117+ c. Carry-over: block-position printing on refusal in `decode_probe`.
lanes/kf900-r3.report.mdadded+171 -0
@@ -0,0 +1,171 @@
1+# lane-kf900 r3 -- the silent 10-bit desync was the palette colour reader
2+
3+Tip: `667eb51`+ on `lane-kf900` (worktree `/home/user/Documents/Code/Rust/edith_codecs-kf900`),
4+base `18bf7dc`, merged main `8e9ba81` (lane-reelckf `55532c7`).
5+
6+## 1. Merge (charter item 1)
7+
8+`git merge --no-commit main` -> clean, no conflicts (commit `4267082`). Both
9+chroma-reference-mi fixes kept: lane-reelckf passes `pair_mi` at the sub-8
10+`smooth_uv_neighbour` call site (decode.rs:7778), r2's own snap
11+`let (mi_r, mi_c) = (mi_r & !1, mi_c & !1);` lives inside the function
12+(decode.rs:4662) -- idempotent together, re-read to confirm.
13+`cdf.rs`, `cdf_state.rs`, `mvstack.rs`, `refusal_inventory.rs`,
14+`gate_coverage.rs` byte-compare SAME as `main:`'s copies (sha256 of each).
15+
16+## 2. The silent 10-bit desync -- ROOT CAUSE, fixed and gated (charter item 2)
17+
18+`decode.rs::read_palette_colors_y` / `read_palette_colors_uv` read every raw
19+literal at a **hardcoded 8 bits**. libaom `decodemv.c:478`/`:509` size all of
20+them by the sequence `bit_depth`:
21+
22+* first colour = `aom_read_literal(r, bit_depth)`
23+* `min_bits = bit_depth - 3` (Y and U), `bit_depth - 4` (V delta mode)
24+* `range = (1 << bit_depth) - first - 1` (Y) / `- first` (U)
25+* clamp bound `(1 << bit_depth) - 1`, V wrap modulus `1 << bit_depth`
26+
27+so a 10-bit palette block read **two bits too few per transmitted colour** and
28+decoded the whole remainder of the tile from the wrong bit position, with no
29+refusal. Fixed by taking the already-present thread-local `bit_depth()` inside
30+both readers (no signature threading).
31+
32+### Why 108 gate recipes and a range ladder could not see it
33+
34+Raw literals are EQUIPROBABLE, and at the ranges this content reaches an
35+equiprobable read is a FIXED POINT of the msac range: 62728 -> v = 31364,
36+either branch leaves 31364, renormalised back to 62728. A cross-decoder RANGE
37+ladder therefore stays bit-identical straight through the miscount and only
38+the decoded VALUE moves. That is the blind spot of the `compare-range-not-tell`
39+method, and it is why this stream reported `OK: 1 frames decoded` with
40+73687/73728 samples wrong.
41+
42+### The pin
43+
44+`testsrc2=s=256x192 --bit-depth=10 --cq-level=59 --cpu-used=0` (recipe
45+`$HOME/.cache/kf900/sweep/sweep.sh`, stream md5
46+`e5f033d8fe34e4418d8cca3ac9d2b595`). Its first block is mi(0,0) BLOCK_32X16,
47+DC_PRED, with a real 2-colour Y palette.
48+
49+* before: `EC_PAL row=0 col=0 ctx=-1 n=2 rng=62728` on BOTH decoders, then
50+ aomdec `color_idx=0`, ours `color_idx=1` -- identical range, opposite value.
51+* after: our first 1024 `EC_PAL`/`EC_PAL_VAL` lines are **byte-identical** to
52+ aomdec's, and the block grid follows aomdec's for the rest of the frame
53+ (`EC_IMODE` mi(0,0) 32x16, mi(4,0) 16x16, mi(4,4) 16x16, mi(0,8) 32x8,
54+ mi(2,8) 32x8, mi(4,8) 32x8 == aomdec bsize 8,6,6,19,19,19).
55+
56+EVIDENCE: $HOME/.cache/kf900/r3/{ours.pal,aom.pal} | EC_AV1_TRACE on
57+decode_probe vs EC_TRACE_PALETTE on the instrumented aomdec over the pinned
58+stream | `diff <(head -1024 ours.pal) <(head -1024 aom.pal)` empty; before the
59+fix the two disagreed on the first colour index at an identical range
60+
61+That stream is NOT a whole-frame gate: at mi(4,8) it hits a 32x8 (4:1) strip
62+that really uses a palette, and the 1:4 rect decoder is called with
63+`palette: None` (decode.rs:7167/7556), so it now stops at the existing refusal
64+`"a 1:4 rect strip that actually uses a palette (reconstruction is not ported
65+at this shape)"`. Silent desync -> named refusal is itself the honest outcome;
66+the pixel gate is a different recipe:
67+
68+### Gate
69+
70+`stream.rs::a_real_aomenc_palette_stream_decodes_pixel_exact_at_8_and_10_bit`
71+-- the existing 8-bit `..._with_palette_y_...` recipe (smptebars 64x64,
72+`--tune-content=screen --enable-palette=1`, all rect/AB/1:4 off) with the
73+depth as the ONLY variable (depth flags appended AFTER the base recipe, per
74+the last-flag-wins rule). Each arm hard-asserts `decode::palette_hits()` moved
75+and compares Y, U and V against ffmpeg's decode of the same bytes.
76+
77+EVIDENCE: crates/ec-av1/src/stream.rs | `cargo test -p ec-av1 --lib
78+palette_stream_decodes_pixel_exact_at_8_and_10` | 1 passed / 0 failed; with
79+`let bd = u32::from(bit_depth())` reverted to `let bd = 8u32` the same test
80+FAILS on "luma at 10-bit" and the 8-bit arm still passes (discrimination check
81+run, tree restored from a scratch copy)
82+
83+Class sweep for the same shape (a bit-depth-scaled reader hardcoding 8):
84+`grep -n "literal(8)\|255i32\|, 255)\|(1 << 8)" decode.rs` -> the only two
85+survivors are the qindex clamps at decode.rs:332 and :544, which are correct
86+(qindex is 0..255 at every bit depth). No sibling instances.
87+
88+## 3. Chroma residual on the 4K 10-bit key frame (charter item 3) -- GONE
89+
90+r2's open residue (first chroma difference at (195,640) = mi(97,320)) is zero
91+on the merged tree. It is NOT my palette fix: the film frame reads **zero**
92+palette symbols (`EC_AV1_TRACE ... | grep -c "^EC_PAL "` = 0 on
93+`crates/ec-av1/fixtures/reelb_kf900.obu`), so the credit belongs to the merged
94+lane-reelckf commits (skipped CfL blocks still predict; the 1:4 chroma pair
95+edge-filter mi).
96+
97+The chroma `tx_type` suspicion from the charter was audited and cleared rather
98+than needed: `av1_get_tx_type`'s `plane > 0` intra path is
99+`intra_mode_to_tx_type(mbmi, PLANE_TYPE_UV)` (our `default_intra_tx_type`,
100+decode.rs:3229) fed with `uv_predict_mode`, which already maps `UV_CFL_PRED`
101+to `DC_PRED`; the `!av1_ext_tx_used[tx_set_type][tx_type]` narrowing can only
102+bite at `txsize_sqr_up >= TX_32X32`, and both chroma call sites already force
103+`DCT_DCT` there (decode.rs:6089 `chroma_w.max(chroma_h) >= 32`, decode.rs:9254
104+`side >= 32`). Every value the table can produce is a member of
105+`EXT_TX_SET_DTT4_IDTX` and `..._1DDCT`, the only two intra sets below 32.
106+
107+## 4. 24-key-frame census on the merged tree (charter item 4)
108+
109+Recipe `$HOME/.cache/kf900/census_r3.sh` (r2's script, own `c3/` scratch and
110+`census_r3.tsv`): `ffmpeg -ss <s> -t 2 -c:v copy -f obu`, truncated to one
111+frame, `EC_PROBE_OUT16` vs `ffmpeg -pix_fmt yuv420p10le`, per-plane DIFFERING
112+SAMPLES.
113+
114+| -ss | Y | U | V | max Y/U/V | r2 U | r2 V |
115+|----:|--:|--:|--:|:---------|-----:|-----:|
116+| 0 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
117+| 300 | 0 | 0 | 0 | 0/0/0 | 219 | 220 |
118+| 600 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
119+| 900 | 0 | 0 | 0 | 0/0/0 | 221 | 47912 |
120+| 1200 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
121+| 1500 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
122+| 1800 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
123+| 2100 | 0 | 0 | 0 | 0/0/0 | 1041 | 1008 |
124+| 2400 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
125+| 2700 | 0 | 0 | 0 | 0/0/0 | 442 | 800 |
126+| 3000 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
127+| 3300 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
128+| 3600 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
129+| 3900 | 0 | 0 | 0 | 0/0/0 | 4 | 4 |
130+| 4200 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
131+| 4500 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
132+| 4800 | 0 | 0 | 0 | 0/0/0 | 2316 | 5 |
133+| 5100 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
134+| 5400 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
135+| 5700 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
136+| 6000 | 0 | 0 | 0 | 0/0/0 | 210 | 0 |
137+| 6300 | 0 | 0 | 0 | 0/0/0 | 145195 | 0 |
138+| 6600 | 0 | 0 | 0 | 0/0/0 | 30873 | 897 |
139+| 6900 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
140+
141+**24/24 key frames now decode BIT-EXACT on all three planes** (r2: 15/24).
142+Every decode reported `OK: 1 frames decoded, 3840x1608`.
143+
144+EVIDENCE: $HOME/.cache/kf900/census_r3.tsv | 24 x (extract 2 s, truncate to 1
145+frame, decode ours + ffmpeg, per-plane compare) | Y/U/V all 0 on all 24 rows
146+
147+## 5. Suite (charter item 5)
148+
149+`systemd-run --user --unit=kf900-suite-r3-... -p MemoryMax=10G ... cargo test
150+-p ec-av1 --lib -j3` -> `$HOME/.cache/kf900-suite-r3.log`:
151+**still running at the turn cap** -- 272 `ok`, 0 `FAILED` at the last poll, no `test result` line yet (unit `kf900-suite-r3-1788328486.service`). See the handoff.
152+
153+## Residue
154+
155+1. **deferred: a whole-frame pixel gate for `skip_split_tx`** -- the only
156+ aomenc recipe found (of 108 + this round's) that fires the counter is the
157+ pinned 10-bit `testsrc2` stream, and it now stops at the 1:4-rect-palette
158+ refusal. Unblocked by porting palette reconstruction to the 1:4 rect
159+ decoder (decode.rs:7167/7556 pass `palette: None`) -- lane-palette2's
160+ territory, not a kf900 defect. The fixture gate
161+ `..._skipped_8x8_intra_leaves_that_split_their_transform_decodes_luma_exact`
162+ still pins the counter at 15 and now compares luma only by construction;
163+ with the census at 24/24 its U/V arms could be tightened next round.
164+2. **deferred (r1/r2 carry-over): block-position printing on refusal in
165+ `decode_probe`**, plus `refusal_inventory.rs` / `gate_coverage.rs` updates
166+ -- this round lifted no refusal (it turned a silent desync into an existing
167+ named one), so neither file changed. Unblocked by ~10 min on `decode.rs`'s
168+ `unsupported()` call sites.
169+3. **accepted: the pinned 10-bit palette stream is not committed as a fixture**
170+ -- it is reproducible from `sweep.sh` and its md5 is recorded here; the
171+ committed gate builds its own stream from aomenc at test time.
lanes/kf900-r4.handoff.mdadded+98 -0
@@ -0,0 +1,98 @@
1+# lane-kf900 r4 HANDOFF
2+
3+Tip `12c3c7c` on `lane-kf900` (parent `08c9a35`). Full detail in
4+`lanes/kf900-r4.report.md`. The work is DONE and committed; the only open item is the
5+suite, which was still running at the turn cap.
6+
7+## 1. Suite state -- INCOMPLETE, ZERO FAILURES SO FAR
8+
9+Unit `kf900-suite-r4-1788330592.service`, log `$HOME/.cache/kf900-suite-r4.log`.
10+At the cap: **245 `ok`, 0 `FAILED`, no `test result` line yet** (r3's baseline was
11+`383 passed; 0 failed; 33 ignored` in 1029 s; this run is slower because 10 lanes share
12+the box). Resolve the unit with `systemctl --user list-units --all | grep kf900` before
13+believing it finished, then
14+`grep -E "^test result|FAILED" $HOME/.cache/kf900-suite-r4.log`.
15+Expect 384 passed (383 + the new gate). If something is RED, the behavioural changes on
16+this commit are only: rect-strip palette reconstruction, the chroma palette map size, the
17+palette cache mi keying, and `record_strip_palette` -- so look at the four existing
18+palette gates first (`a_real_aomenc_stream_with_palette_y_...`, `..._palette_uv_...`,
19+`..._rect_palette_...`, `a_real_aomenc_multi_tile_palette_stream_...`).
20+
21+## 2. The patch that shipped (all sites are current `crates/ec-av1/src/decode.rs`)
22+
23+Grep the symbol, not the line number -- the file moved by ~300 lines.
24+
25+| hook | site | what |
26+| --- | --- | --- |
27+| palette mode ctx + Y colour cache | `decode_block_rect4` (32x8/8x32), just after `modes_above_left_mi` | `let pal_at = (mi_r / (SUB / MI), mi_c / (SUB / MI)); neighbours.palette_ctx_and_cache_mi(pal_at, mi_r)` -> passed as `Some((palette_ctx, &palette_cache))` where `None` used to go |
28+| UV colour cache | same | `neighbours.palette_uv_cache_mi(pal_at, mi_r)` replaces `&[]` |
29+| same two | `decode_rect4_16` (16x4/4x16), inside the 4-strip loop, `at16` + `lmi.0` | per strip, not per cell |
30+| same two | `decode_leaf_rect` (16x8/8x16) | already had the ctx/cache; switched to the `_mi` variants with `leaf_mi.0` |
31+| palette_size ctx | `palette_bsize_ctx_wh` -- UNCHANGED, already correct | `num_pels_log2_lookup[bsize] - 6`; 0 for BLOCK_16X4/4X16 (64 px), 2 for BLOCK_32X8 |
32+| colours | `read_palette_colors_y` / `_uv` -- UNCHANGED (r3 fixed the bit depth) | |
33+| colour index map read point | `read_intra_mode_rect`, after `use_filter_intra` -- UNCHANGED | `av1_visit_palette` order: Y map then chroma map, both AFTER all mode info |
34+| colour index map SIZE (fixed) | `read_intra_mode_rect`, the `palette_uv_pending.map(..)` closure | `((bw / 2).max(4), (bh / 2).max(4))`, was `(bw / 2, bh / 2)` |
35+| chroma on the odd strip | `decode_rect4_16`'s `has_chroma` (`i % 2 == 1`) -- UNCHANGED gating; the pair's 8x4/4x8 chroma now gets `set_palette_pred` per plane in both the skip and the coded arm | |
36+| reconstruction | all three fns | `palette_y_buf` / `palette_uv_bufs` (index map through the base colours) handed to each `reconstruct_rect` via `set_palette_pred`; the split-tx walks slice the block buffer per transform unit (`RectStripModes.palette_y` in `decode_rect_split`, an inline window in `decode_rect4_16`) |
37+| neighbour state | new free fn `record_strip_palette` | split axis only until the closing strip (`mi_r % 8 == 6` / `mi_c % 8 == 6` for 32x8/8x32, `i == 3` for 16x4/4x16, `leaf_mi.0 % 4 == 2` for 16x8/8x16) |
38+| counter | `RECT4_PALETTE_HITS` / `pub(crate) fn rect4_palette_hits()` | rect strips that ACTUALLY use a palette |
39+
40+libaom cited: `decodemv.c` `read_palette_mode_info` (`av1_allow_palette` -- `sb_type >=
41+BLOCK_8X8` is an ENUM-INDEX test that BLOCK_4X16/16X4 pass; `av1_get_palette_bsize_ctx`;
42+`av1_get_palette_mode_ctx`), `read_palette_colors_y` `decodemv.c:478`,
43+`read_palette_colors_uv` `:509`, `pred_common.c:73` `av1_get_palette_cache` (SB-top-row
44+guard at `:76`, `row = -xd->mb_to_top_edge >> 3` = the block's PIXEL row, hence
45+`mi_r % 16 != 0`), `decodeframe.c` `decode_color_map_tokens` reached from
46+`av1_visit_palette`, and `ss_size_lookup` (BLOCK_16X4 -> BLOCK_8X4, BLOCK_4X16 ->
47+BLOCK_4X8) for the chroma map size.
48+
49+## 3. Refusals dropped (both from decode.rs and refusal_inventory.rs, 47 -> 45)
50+
51+* `a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)`
52+* `a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)`
53+
54+`gate_coverage.rs` needed no change (it pins aomenc FLAGS, and
55+`enable-palette` / `enable-1to4-partitions` were already in its list).
56+
57+## 4. Gate
58+
59+`crates/ec-av1/src/stream.rs::a_real_aomenc_rect_strip_palette_decodes_pixel_exact`.
60+Base recipe (arm 0 = the r3 pin): `--codec=av1 --bit-depth=N --input-bit-depth=N
61+--passes=1 --end-usage=q --cq-level=59 --cpu-used=0 --lag-in-frames=0 --kf-max-dist=1
62+--limit=1 --threads=1 --tile-columns=0 --enable-tx-size-search=1 --min-partition-size=8
63+--enable-rect-partitions=1` on `testsrc2=s=256x192:r=25`, y4m over stdin, `-t 0.2`.
64+Arms 1-2 append `--tune-content=screen --enable-palette=1 --enable-1to4-partitions=1
65+--min-partition-size=8` (testsrc2 / `smptebars=size=256x192:rate=25`). 8-bit arms append
66+`--sb-size=64` (the 8-bit twin otherwise lands on the open 128-root HORZ refusal).
67+`cargo test -p ec-av1 --lib a_real_aomenc_rect_strip_palette_decodes_pixel_exact -- --nocapture`
68+-> **1 passed**: `2 attempt(s) with a rect-strip palette block, 0 out of scope
69+(0 mismatched), 4 refused, 2 frames compared, fired 8-bit=0 10-bit=2`.
70+
71+## 5. Measured facts
72+
73+* The test's own 10-bit arm-0 encode reproduces the pin BYTE FOR BYTE:
74+ md5 `e5f033d8fe34e4418d8cca3ac9d2b595`.
75+* That stream went `REFUSED: ... a 1:4 rect strip that actually uses a palette` ->
76+ `OK: 1 frames decoded, 256x192`; `rect4_32` went `horz=8 vert=0 coded=8` ->
77+ `horz=12 vert=16 coded=28`.
78+* **The charter/r3 premise that this stream fires `skip_split_tx` is WRONG**: decoded in
79+ full, `decode_probe` prints `skip_split_tx: 0`. The gate asserts the palette counter.
80+* **64x16/16x64 needed nothing**: `decode_block_rect64` already passes the real ctx/cache
81+ and reconstructs; its remaining palette refusal is the separate corner-cropped-luma one.
82+* **No 8-bit recipe reaches a rect-strip palette.** At 8 bit aomenc palettes SQUARE
83+ blocks; every 8-bit variant tried lands on `a block that actually uses a palette (Y)`
84+ (8x8 square leaf) or `a palette block with a real transform on a superblock-level
85+ HORZ/VERT strip`. Lifting either unblocks 8-bit coverage of this shape.
86+* **NEW pre-existing 8-bit 1:4 mismatch, not palette** -- 8-bit `testsrc2=s=256x192:r=25`,
87+ base recipe + `--tune-content=screen --enable-palette=1 --enable-1to4-partitions=1
88+ --max-partition-size=32 --sb-size=64`: decodes `OK`, `rect4_32: horz=8 vert=8 coded=16`,
89+ frame 0 differs from ffmpeg. The stream reads ZERO palette symbols
90+ (`EC_AV1_TRACE=1 decode_probe | grep -c "^EC_PAL "` == 0), so every change in this
91+ commit is inert on it. Needs its own lane.
92+
93+## 6. EXACT NEXT STEP
94+
95+1. Read the suite result (above). If green, merge `12c3c7c` into main.
96+2. Then, in order: (a) the new 8-bit 1:4 non-palette mismatch in 5; (b) palette on an 8x8
97+ SQUARE leaf (`decode_leaf8` discards `_palette_y`), which is what blocks 8-bit
98+ rect-strip coverage; (c) palette + real transform on a 64x32/32x64 SB-level strip.
lanes/kf900-r4.report.mdadded+70 -0
@@ -0,0 +1,70 @@
1+# lane-kf900 r4 report -- rect-strip palette reconstruction
2+
3+## What changed (all in `crates/ec-av1/`)
4+
5+| path:line (post-change) | why |
6+| --- | --- |
7+| `src/decode.rs` `Neighbours::palette_ctx_and_cache_mi` / `palette_uv_cache_mi` | `av1_get_palette_cache` drops the above neighbour on a 64-px SB boundary keyed on the block's own PIXEL row (`pred_common.c:76`). The old code read `at.0 % 4` off the 16-px `SUB` cell, so strip 1 of a HORZ_4 (8 px into the cell) wrongly excluded strip 0 from its cache in every SB-top cell row. Old entry points kept, delegating. |
8+| `src/decode.rs` `read_intra_mode_rect`, chroma colour-index map | the map is `av1_get_plane_block_size(bsize,1,1)` (`ss_size_lookup`), not a plain halving: BLOCK_16X4 -> BLOCK_8X4, BLOCK_4X16 -> BLOCK_4X8. `(bw/2, bh/2)` read HALF the colour-index symbols of a 1:4 strip's chroma palette. Now `((bw/2).max(4), (bh/2).max(4))`. |
9+| `src/decode.rs` `record_strip_palette` (new) | the coarse `SUB`-cell palette arrays alias all four strips of a HORZ_4/VERT_4 (and both leaves of a 16x8/8x16 pair) onto one entry, so stamping BOTH axes after every strip hands strip i+1 strip i's colours on the WRONG axis too. Writes the split axis until the closing strip, both on it. |
10+| `src/decode.rs` `decode_block_rect4` (32x8/8x32) | was `palette: None, &[]` -> real ctx + cache; palette-Y/UV prediction wired into the split-tx walk (`RectStripModes`), the coded arm and the skip arm; palette state stamped on all three exits. Refusal dropped. |
11+| `src/decode.rs` `decode_rect4_16` (16x4/4x16) | same, per strip, incl. the inlined per-TU split walk (window of the block's palette buffer per unit) and the pair's chroma. Refusal dropped. |
12+| `src/decode.rs` `decode_leaf_rect` (16x8/8x16) | sibling refusal "a palette block on a HORZ/VERT intra strip below 16x16" dropped the same way; its zero-clear of the palette arrays became `record_strip_palette`, which also fixes leaf 0 of a pair zeroing the LEFT entry leaf 1 legitimately reads. |
13+| `src/decode.rs` `RECT4_PALETTE_HITS` / `rect4_palette_hits()` | the gate's counter: rect intra strips that ACTUALLY use a palette. |
14+| `src/refusal_inventory.rs` | both lifted strings removed (47 -> 45). |
15+| `src/stream.rs` `a_real_aomenc_rect_strip_palette_decodes_pixel_exact` | the gate. |
16+
17+libaom sites cited: `decodemv.c` `read_palette_mode_info` (`av1_allow_palette`, `av1_get_palette_bsize_ctx`, `av1_get_palette_mode_ctx`), `read_palette_colors_y` (`decodemv.c:478`) / `read_palette_colors_uv` (`:509`), `pred_common.c:73` `av1_get_palette_cache`, `decodeframe.c` `decode_color_map_tokens` via `av1_visit_palette` (map read AFTER all mode info -- unchanged, already correct here).
18+
19+## Refusals lifted (2)
20+
21+1. `a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)`
22+2. `a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)`
23+
24+## Gate
25+
26+`crates/ec-av1/src/stream.rs::a_real_aomenc_rect_strip_palette_decodes_pixel_exact`
27+3 arms x 2 depths. Arm 0 IS the r3 pinned stream: `testsrc2=s=256x192:r=25`, `--cq-level=59
28+--cpu-used=0 --lag-in-frames=0 --kf-max-dist=1 --limit=1 --threads=1 --tile-columns=0
29+--enable-tx-size-search=1 --min-partition-size=8 --enable-rect-partitions=1`, and the encoder
30+invocation inside the test reproduces md5 `e5f033d8fe34e4418d8cca3ac9d2b595` byte for byte at
31+10-bit. Arms 1-2 add `--tune-content=screen --enable-palette=1 --enable-1to4-partitions=1
32+--min-partition-size=8` on testsrc2 / smptebars. Every decode-order frame, all three planes,
33+compared against ffmpeg's decode of the identical bytes. Hard asserts: a rect-strip palette
34+block fired (`rect4_palette_hits()` delta), `out_of_scope_mismatch == 0`, sources render
35+byte-identical twice. A NAMED (`unsupported`) refusal is counted and printed, never a pass.
36+
37+```
38+cargo test -p ec-av1 --lib a_real_aomenc_rect_strip_palette_decodes_pixel_exact -- --nocapture
39+```
40+
41+EVIDENCE: $HOME/.cache/kf900/sweep/g.obu + gate stdout | aomenc pinned recipe -> decode_stream -> ffmpeg compare, 3 arms x {8,10} bit | 2 attempts with a rect-strip palette block, both whole-frame pixel-exact (Y+U+V), 0 out-of-scope mismatches, 4 named refusals on other shapes, md5 of the test's own 10-bit arm-0 stream == e5f033d8fe34e4418d8cca3ac9d2b595
42+EVIDENCE: decode_probe on $HOME/.cache/kf900/sweep/g.obu | before/after this commit | `REFUSED: ... a 1:4 rect strip that actually uses a palette` -> `OK: 1 frames decoded, 256x192`, rect4_32 horz=8 vert=0 -> horz=12 vert=16
43+
44+## Corrected premises (both stated as fact in the charter/handoff)
45+
46+- **`skip_split_tx` does NOT fire on the pinned stream.** `decode_probe` on the fully decoded
47+ stream prints `skip_split_tx: 0`. The r3 handoff's "fires skip_split_tx AND reaches that
48+ refusal" is half wrong, so the gate asserts the palette counter and does not assert
49+ `skip_split_tx`; asserting it would have been a vacuous/failing gate.
50+- **64x16/16x64 needed no work.** `decode_block_rect64` already passes the real ctx/cache and
51+ reconstructs palette; its only palette refusal is the separate corner-cropped-luma one.
52+
53+## Open residue
54+
55+- **deferred(8-bit rect-strip palette coverage)** -- `fired 8-bit=0, 10-bit=2`. At 8 bit aomenc
56+ puts its palettes on SQUARE blocks; every 8-bit recipe tried that reaches a rect strip with a
57+ palette lands on a shape still out of scope (`a block that actually uses a palette (Y)` on an
58+ 8x8 square leaf, or `a palette block with a real transform on a superblock-level HORZ/VERT
59+ strip`). Unblocked by lifting either of those two refusals. The 8-bit arms still run and prove
60+ the decode path; the counter is printed, not hidden.
61+- **fix-now-elsewhere: a NEW pre-existing 8-bit 1:4 pixel mismatch, unrelated to palette.**
62+ Recipe: `testsrc2=s=256x192:r=25`, 8-bit, base recipe above plus
63+ `--tune-content=screen --enable-palette=1 --enable-1to4-partitions=1 --max-partition-size=32
64+ --sb-size=64`. Decodes `OK: 1 frames decoded` with `rect4_32: horz=8 vert=8 coded=16` and
65+ frame 0 differs from ffmpeg. Proved unrelated to this round: the stream reads ZERO palette
66+ symbols (`EC_AV1_TRACE=1 decode_probe | grep -c "^EC_PAL "` == 0), so every change in this
67+ commit is inert on it. Needs its own lane.
68+- **accepted**: `a palette block with a real transform on a superblock-level HORZ/VERT strip`
69+ and `a block that actually uses a palette (Y/UV)` (8x8 square leaf) remain -- out of this
70+ lane's charter (both are square/SB-level, not rect strips).
lanes/kf900-r5.report.mdadded+88 -0
@@ -0,0 +1,88 @@
1+# lane-kf900 r5 report -- rect intra strips never read `use_intrabc`
2+
3+Tip `a7113f5` on `lane-kf900` (parent `9a01750`). GREEN.
4+
5+## Defect (chartered) and root cause
6+
7+The chartered stream -- 8-bit `testsrc2=s=256x192:r=25`, cq59 cpu-used 0, rect + 1:4
8+partitions, `--tune-content=screen --enable-palette=1 --sb-size=64` -- decoded `OK`
9+(`rect4_32: horz=8 vert=8`) and every luma sample of frame 0 differed from ffmpeg.
10+
11+`--tune-content=screen` sets `allow_screen_content_tools`, and the key-frame header then
12+sets **`allow_intrabc = 1`**. `av1_allow_intrabc` is a FRAME-level test (libaom
13+`decodemv.c:892`, `read_intra_frame_mode_info`): every intra block reads a `use_intrabc`
14+symbol after `skip`/`cdef`/`delta_q` and before `mbmi->mode`, with **no block-shape term**.
15+`read_intra_mode` (square leaf) and `read_intra_mode_sub8` both read it;
16+`read_intra_mode_rect` -- the reader for EVERY HORZ/VERT/1:4 rect strip -- did not. The
17+arithmetic decoder therefore desynced at the first mode symbol of the first rect block of
18+the frame, i.e. at mi(0,0), and every later symbol and pixel was garbage.
19+
20+Decisive measurement (cross-decoder range ladder, `EC_TRACE_MODE_STEP` both sides):
21+
22+```
23+ref EC_ISTEP mi_row=0 mi_col=0 name=skip rng=32874 ours ... rng=32874 (identical)
24+ref EC_ISTEP mi_row=0 mi_col=0 name=mode rng=58628 ours ... rng=62696 (diverged)
25+```
26+
27+62696 is exactly `kf_y_mode[0][0]` symbol 0 from 32874. 58628 is that same read after ONE
28+default `intrabc` symbol was consumed first (32874 -> 30694 -> normalised 61388 -> 58628),
29+computed by hand from `od_ec_decode_cdf_q15` (`aom_dsp/entdec.c`) with
30+`default_intrabc_cdf = AOM_CDF2(30531)`. That is the missing symbol, not a table row.
31+
32+## Changes
33+
34+| path | why |
35+| --- | --- |
36+| `crates/ec-av1/src/decode.rs` `allow_intrabc_frame()` (new, next to `intrabc_hits`) | `INTRABC_MI_GRID` is `Some` exactly when the frame header set `allow_intrabc`, so the flag reaches the rect reader with no new plumbing through 5 functions |
37+| `crates/ec-av1/src/decode.rs` `read_intra_mode_rect`, right after `istep!("dq", 0)` | reads `use_intrabc`; refuses by name when it fires (rect intrabc reconstruction is not ported); bumps `RECT_INTRABC_READS` |
38+| `crates/ec-av1/src/decode.rs` `RECT_INTRABC_READS` + `rect_intrabc_reads()` / `reset_rect_intrabc_reads()` | gate hit counter: strips that READ the symbol (distinct from `INTRABC_HITS` = blocks that USE intrabc) |
39+| `crates/ec-av1/src/stream.rs` `rect_intrabc_reads()` re-export + new gate | gate + probe surface |
40+| `crates/ec-av1/src/refusal_inventory.rs` | new refusal `"intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)"` (45 -> 46) |
41+| `crates/ec-av1/examples/decode_probe.rs` | prints `rect_intrabc_reads:` |
42+
43+Class sweep: `grep -n "cdfs.kf_y_mode\[" crates/ec-av1/src/decode.rs` -> 3 intra mode
44+readers (5630 rect, 8828 square, 10709 sub8); all three now read `cdfs.intrabc` under the
45+frame flag (5618 / 8807 / 10700). No other site.
46+
47+## Gate
48+
49+`crates/ec-av1/src/stream.rs::a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips`
50+-- three real-aomenc 8-bit arms, base recipe `--codec=av1 --bit-depth=8 --input-bit-depth=8
51+--passes=1 --end-usage=q --cpu-used=0 --lag-in-frames=0 --kf-max-dist=1 --limit=1
52+--threads=1 --tile-columns=0 --enable-rect-partitions=1 --enable-1to4-partitions=1
53+--min-partition-size=8 --max-partition-size=32 --sb-size=64 --tune-content=screen`,
54+per-arm overrides last:
55+
56+* `testsrc2-screen-nopalette-cq50` -- rect strips really use intrabc; must refuse by NAME
57+ (was: a silently wrong frame).
58+* `smptebars-screen-nopalette-cq45` -- decodes the whole frame, 69 rect `use_intrabc`
59+ reads; entropy coverage (see residue).
60+* `testsrc2-screen-nopalette-cq63` -- screen tools but header `allow_intrabc = 0`; frame
61+ compared pixel-exact against ffmpeg, proving the new read is not taken when libaom does
62+ not write it.
63+
64+```
65+cargo test -p ec-av1 --lib a_real_aomenc_screen_key_frame_reads_use_intrabc -- --nocapture
66+-> 1 passed: 147 rect-strip use_intrabc symbol(s) read, 1 refused by name, 1 frames compared pixel-exact
67+```
68+
69+`refusal_inventory` (3 tests) and `gate_coverage` (7 tests) green.
70+
71+## EVIDENCE
72+
73+* `EVIDENCE: $HOME/.cache/kf900-r5/{s.obu,ours.yuv,ref.yuv} | aomenc chartered recipe (sha256 4fe2e7ba57...; encoded twice byte-identical as bf048186e3... in IVF form), decode_probe vs `ffmpeg -i` | before fix: OK + 73438 bytes differ, first luma (0,0) ours 128 vs ref 74; after fix: named refusal instead of a wrong frame`
74+* `EVIDENCE: $HOME/.cache/kf900-r5/{c45_ours.txt,c45_ref.txt} | EC_TRACE_MODE_STEP ladder both decoders | first divergence mi(0,0) name=mode: ours 62696 vs oracle 58628 = one unconsumed intrabc symbol`
75+* `EVIDENCE: $HOME/.cache/kf900-r5/{b_o.n,b_r.n} | same ladder on the smptebars cq45 arm after the fix | 429 mode-ladder elements identical, first divergence at mi(32,44) (a SQUARE intrabc block's DV read)`
76+* `EVIDENCE: $HOME/.cache/kf900-suite-r5.log | full ec-av1 lib suite as systemd unit kf900-suite-r5-1788331689 | test result: ok. 385 passed; 0 failed; 33 ignored, 1088.55s`
77+
78+## Residue
79+
80+* `deferred: pixel-exactness on frames that actually USE intrabc -- read_intrabc_dv desyncs
81+ inside the DV of a SQUARE 16x16 intrabc block at mi(32,44) (smptebars cq45 arm: 429
82+ ladder elements exact, then diverges); it is a separate defect from this lane's read --
83+ unblocked by a DV-symbol ladder against the oracle at that block`
84+* `deferred: rect-strip intrabc RECONSTRUCTION (the new refusal) -- needs the DV path above
85+ working first, plus the square path's own open "intrabc block under TxMode::Select" refusal`
86+* `deferred: 8-bit screen key frame with palette, cq45 --enable-tx-size-search=1 -- after this
87+ fix the ladder is exact for 46 elements and diverges in the TAIL of the palette block at
88+ mi(0,8) (palette colour-index map / tx). Separate palette defect, not intrabc`
lanes/r14-r3.report.mdadded+104 -0
@@ -0,0 +1,104 @@
1+# lane-r14 round 3 — the SPLIT transform of a 1:4 inter strip with a 64-px axis
2+
3+## What changed
4+
5+- `crates/ec-av1/src/decode.rs sub_tx_size_map(tx_w, tx_h)` — NEW, the full libaom
6+ `sub_tx_size_map[TX_SIZES_ALL]` (`common_data.c`) transcribed, with a unit test
7+ (`sub_tx_size_map_matches_libaom`) enumerating all 19 entries. The load-bearing rows are the
8+ ones r2 refused on: `[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32` — RECTANGULAR.
9+- `crates/ec-av1/src/decode.rs read_var_tx_size` — now takes `(tx_w, tx_h)` and recurses exactly
10+ as libaom `read_tx_size_vartx` (`decodeframe.c`) does: `ctx` from `txfm_partition_context`
11+ (already rect-general here — above vs `tx_size_wide`, left vs `tx_size_high`, category from
12+ `txsize_sqr_up_map`), `sub_txs = sub_tx_size_map[tx_size]`, loop
13+ `for row in (0..tx_size_high_unit[tx_size]).step_by(bsh) { for col in (0..tx_size_wide_unit).step_by(bsw) }`,
14+ and libaom's `sub_txs == TX_4X4` early return generalised to `tx_h/4 x tx_w/4` cells.
15+ Leaves are now `(row, col, tw, th)` instead of the square `(row, col, tx_px)`.
16+- `crates/ec-av1/src/decode.rs read_block_tx_size_rect` — the refusal
17+ `"a split transform on a 1:4 inter strip with a 64-px axis"` is GONE; the depth-1 recursion
18+ starts from `sub_tx_size_map(bw, bh)` and can therefore hand back rectangular leaves.
19+- `crates/ec-av1/src/decode.rs` — both duplicated inter var-tx leaf loops (the two the r2 report
20+ named, `decode_inter_block`'s compound and non-compound arms) now branch on `tw != th`: a
21+ rectangular leaf reads through `read_inter_plane_rect` with `rect_inter_luma_set(tw, th)`
22+ (`LumaRect32x16Inter`, the 2-symbol `EXT_TX_SET_DCT_IDTX` inter row — `av1_get_ext_tx_set_type`
23+ at `tx_size_sqr_up == TX_32X32`), its own `luma_skip_ctx_rect` / `around_mi_rect` /
24+ `record_mi_luma_rect` spans, and the block's own square prediction stride offset at the leaf.
25+- `crates/ec-av1/src/decode.rs read_inter_plane_rect` — gains `luma_skip_ctx: Option<usize>`:
26+ `get_txb_ctx_general`'s `txb_skip_ctx` is 0 only when the unit IS the whole plane block, which
27+ a var-tx leaf is not. The 6 whole-block call sites pass `None` (unchanged behaviour).
28+- `crates/ec-av1/src/decode.rs` + `stream.rs` — `vartx_rect_leaf_hits() -> [usize; 2]`
29+ (`[32x16, 16x32]`), and `examples/decode_probe.rs` prints it.
30+- `crates/ec-av1/src/refusal_inventory.rs` — the refusal line dropped.
31+- `crates/ec-av1/src/gate_coverage.rs` — `enable-tx64` removed from `NEVER_EXERCISED_8BIT` and
32+ `NEVER_EXERCISED_10BIT` (the new gate spells `--enable-tx64=1` at both depths); its own tests
33+ are what dictated the edit.
34+- `crates/ec-av1/src/stream.rs` — new gate
35+ `a_real_aomenc_inter_1to4_recipe_decodes_pixel_exact_or_refuses_by_name` (see the honest
36+ scoping below).
37+
38+## Firing proof: his real film
39+
40+EVIDENCE: `decode_probe` on `seg4500.obu` (`ffmpeg -ss 4500 -t 2 -i <HG 2160p HDR10> -c:v copy -f obu`, 213 frame headers) | run under `systemd-run --user --scope -p MemoryMax=6G` on the r3 tip | `vartx_rect_leaf: 32x16=0 16x32=14`, `inter_rect: 64x32=24 32x64=24 64x16=0 16x64=16` — **14 rectangular var-tx leaves decoded**, and the stop moved from `a split transform on a 1:4 inter strip with a 64-px axis` to `an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet` (lane-intrarect's wall)
41+
42+EVIDENCE: same command on `seg3000.obu` (288 frame headers) | before r3 it stopped at this round's refusal (r2 report) | now `REFUSED: an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet` — this round's wall is off both mid-film segments
43+
44+EVIDENCE: same command on `seg300.obu` (206 frame headers) | unchanged wall (`intra-coded HORZ/VERT strip`) | but it now decodes 4 `16x64` strips and `vartx_rect_leaf 16x32=1` on the way there
45+
46+## Gate — and what it can NOT assert (measured, not assumed)
47+
48+`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -- --test-threads=1 1to4 superblock_level_rect_partition refusal_inventory gate_coverage sub_tx_size_map` → 17 passed / 0 failed (log `$HOME/.cache/r14-r3-g5.log`, plus `-g6` after the gate_coverage edit).
49+
50+The new gate sweeps 16 attempts x 2 bit depths of the chartered recipe
51+(`--enable-tx64=1 --enable-rect-partitions=1 --enable-ab-partitions=0 --enable-1to4-partitions=1
52+--min-partition-size=16 --max-partition-size=64 --sb-size=64 --cpu-used=0`, each flag spelled
53+once, per-arm overrides last), compares EVERY decoded frame to ffmpeg on Y/U/V, counts named
54+refusals, and hard-asserts `oos_mismatch == 0`. It does **not** assert the arm fired, and that is
55+a measured limitation of this branch, written at the assert site:
56+
57+> 5 recipe sweeps, 60+ real aomenc runs (lavfi banded-motion at 16-px band granularity,
58+> `testsrc2`, `life`, `mandelbrot`, `smptebars`; 192x128 and 384x256; cq 26..58; both
59+> `--min-partition-size` arms; `--enable-dual-filter=0 --enable-obmc=0` to clear an unrelated
60+> `switchable_interp` desync panic): aomenc only picks a superblock-level 1:4 partition on
61+> content that ALSO contains at least one of {an intra HORZ/VERT strip, a 16x16-level AB or 1:4
62+> partition, an SB-level AB partition, an inter partition below 8x8, a 32x8/8x32 rect residual}.
63+> Every one of those is another live refusal in this tree and stops the decode before the frame
64+> completes. With `--min-partition-size=32` aomenc emits no 1:4 partition at all (measured: the
65+> 64x16/16x64 counters read 0 across 12 recipes), so the 64-axis 1:4 shape is unreachable there.
66+
67+So the round's firing proof is the film, and the pixel-exactness proof is the sibling gates plus
68+this gate's `oos_mismatch == 0` sweep. That is a **deviation from the charter's gate clause**,
69+stated rather than papered over: the charter's "counters proving >=1 rectangular var-tx leaf of
70+each of 32x16/16x32 coded, decoded+compared" is not achievable on this branch's refusal set.
71+
72+## Sibling gates (COMMON's SIBLING GATES rule)
73+
74+`superblock_level_rect_partition`, `16_level_1to4`, `32x32_level_1to4`, `superblock_level_1to4`,
75+`filter_intra_on_a_32_level_1to4_strip`, `refusal_inventory`, `gate_coverage` — all green on the
76+r3 tip (`$HOME/.cache/r14-r3-g5.log` / `-g6.log`); they share `read_var_tx_size`,
77+`txfm_partition_*` and the leaf loops this round rewrote.
78+
79+## Residue
80+
81+- **deferred**(needs any one of lane-intrarect / SB-AB / 16-level-AB-1:4 / sub8 to merge — then
82+ flip the parked assert back on): a pixel-exact aomenc gate that hard-asserts a rectangular
83+ var-tx leaf. The assert and its restore instruction are in the gate body.
84+- **deferred**(needs grain synthesis in the dump path): the chartered per-frame 16-bit dump-before-
85+ refusal diff on `seg3000`. `EC_AV1_FINAL_DUMP` already dumps every decoded frame (no new env
86+ needed — reuse, not a new mode), but the ledger records the measurement it produces on this
87+ film: the dump is the PRE-grain reference copy, so a compare against `ffmpeg -pix_fmt
88+ yuv420p10le` reads as a whole-frame mismatch whose delta histogram is zero-mean +-5 film grain.
89+ Dumping a 2 s 2160p 10-bit segment is also multi-GB. Not run.
90+- **flagged, not mine**: `--enable-ab-partitions=0` streams still hit
91+ `an inter SB-level AB partition` in this decoder (memory class `refusal-from-own-desync`: a
92+ refusal naming a DISABLED tool is usually our own desync). Seen on `mandelbrot` cq50 and on
93+ several banded-motion recipes. Worth its own lane.
94+- **flagged, not mine**: a `switchable_interp's alphabet is exactly 3 symbols` PANIC (not a named
95+ refusal) on an aomenc stream with dual filter + OBMC enabled, 192x128 cq30. Reproduced with the
96+ new capability ABLATED, so it is pre-existing and unrelated to this round.
97+
98+## Suite
99+
100+`systemd-run --user --unit=r14-r3-suite-... -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3`
101+-> log `$HOME/.cache/r14-suite-r3.log`; totals appended below.
102+
103+**Suite result (r3 tip `81b6f9e`): 367 passed; 0 failed; 31 ignored, 622.33s** — up from r2's
104+365/0/31 by the two tests this round adds (`sub_tx_size_map_matches_libaom` and the new gate).
lanes/r14-r4.report.mdadded+87 -0
@@ -0,0 +1,87 @@
1+# lane-r14 round 4 — merge main, and the parked firing assert turned back on
2+
3+## 1. Merge `main` (18bf7dc) — commit `523c17d`
4+
5+`git merge --no-commit main` auto-merged with NO conflicts (diffstat: decode.rs +1117,
6+stream.rs +1100, mvstack.rs +114, encode.rs +47, refusal_inventory.rs, cdf.rs, cdf_state.rs,
7+decode_probe.rs, 9 lane reports). Checks run before committing:
8+
9+- `git diff main -- crates/ec-av1/src/cdf.rs` → **0 lines**: cdf.rs (NZ_MAP / FILTER_INTRA rows
10+ included) is byte-identical to main on the merged tree, so no table was rebound by the merge.
11+- `git diff main -- crates/ec-av1/src/refusal_inventory.rs` shows only THIS lane's deletion
12+ ("a split transform on a 1:4 inter strip with a 64-px axis"); every refusal main deleted
13+ (lane-oddh's 128x128 line, lane-intrarect's) stays deleted.
14+- `grep -rn '<<<<<<<|>>>>>>>' crates/` → nothing. No hand-resolved function, so no rebound-name
15+ re-read was needed (class merge-resolution-shadows-a-name did not apply this round).
16+
17+## 2. The firing assert is back on — and it is a hard assert
18+
19+Gate renamed
20+`a_real_aomenc_inter_1to4_recipe_decodes_pixel_exact_or_refuses_by_name` →
21+**`real_aomenc_1to4_streams_decode_pixel_exact_and_rect_vartx_leaves_fire_before_a_named_refusal`**
22+(`crates/ec-av1/src/stream.rs:6752`), which is what it now asserts.
23+
24+r4 recipe hunt on the merged tree, ~70 real aomenc runs (`testsrc2`, `life`, `mandelbrot`,
25+banded-motion lavfi with per-band and per-column speeds, 64x64 / 128x64 / 64x128 / 256x64 /
26+384x64 / 64x384 / 192x128 / 384x256, cq 20..58, `--min-partition-size` 16 and 32, 8- and
27+10-bit) found the recipe r3 could not: **384x256, per-16-column band motion**, at
28+`cq=38` and `cq=32`.
29+
30+EVIDENCE: `$HOME/.cache/r14-r4-gate.log` (gate run, quoted below) | `cargo test -p ec-av1 --lib -- --test-threads=1 --nocapture real_aomenc_1to4_streams` on `0b49322` | 8-bit: `attempt 17 refusal (rect var-tx leaves decoded before it: 32x16=4, 16x32=0)`, `attempt 16 ... (32x16=0, 16x32=1)`, summary `2 named refusals, leaves decoded anywhere in the sweep 32x16=4 16x32=1, 16 attempts carried none (0 of them mismatched)` — **test result: ok, 1 passed**
31+
32+What the gate asserts now:
33+- `oos_mismatch == 0` — every attempt that decodes to the end is compared to ffmpeg on Y/U/V,
34+ 8- AND 10-bit, and a mismatch is a failure, never a SKIP (16/16 banded attempts per depth
35+ decode fully and match; the recipe's `--min-partition-size` moved 32 → 16, so those 16
36+ attempts now also exercise the 16-level path).
37+- `compared + out_of_scope > 0` — the gate is not vacuous.
38+- **8-bit: `fired_32x16 > 0 && fired_16x32 > 0`** — both orientations of
39+ `sub_tx_size_map[TX_64X16] == TX_32X16` / `[TX_16X64] == TX_16X32` decoded out of a real
40+ aomenc stream. These two streams stop LATER on another lane's refusal
41+ (`a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding` at cq 32,
42+ `an inter 16x16-level AB or 1:4 partition` at cq 38 — decode.rs:21305, genuinely unimplemented
43+ on the inter path), so the leaves are proved **decoded**, not proved pixel-exact. The counters
44+ are per-attempt deltas kept in a separate pair of variables from the pixel-compared ones
45+ (class counter-from-refused-stream), and the distinction is printed and commented.
46+- 10-bit: the same sweep fires ZERO leaves (measured: cq 32/35/38 pick other shapes), so the
47+ firing assert is 8-bit-only, with the measurement written at the assert.
48+
49+## 3. Suite
50+
51+`systemd-run --user --unit=r14-suite-r4-1788325638 -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3`
52+→ `$HOME/.cache/r14-suite-r4.log`. **Suite result (r4 tip `0b49322`): 372 passed; 0 failed; 32 ignored, 1487.04s** — GREEN.
53+(r3 tip was 367/0/31; +5 passed and +1 ignored come from main's three merged lanes.)
54+
55+## 4. Film probes on the merged tree — and a regression that is main's, not this lane's
56+
57+EVIDENCE: `/tmp/.../scratchpad/r14/seg{300,3000,4500}.obu` (2 s HG 2160p10 extracts, reused from r3) | `decode_probe` under `systemd-run --user --scope -p MemoryMax=6G`, `EC_AV1_FINAL_DUMP` file count = frames completed | merged tree `0b49322`:
58+
59+| segment | stop string | frames completed |
60+|---|---|---|
61+| `-ss 300` | `a split intra strip whose transform unit is 32x64 (no luma coefficient tables for that shape here)` | 1 |
62+| `-ss 3000` | same | 1 |
63+| `-ss 4500` | `an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path` | 1 |
64+
65+That is **shallower than the r3 tip**, where `seg4500` decoded 14 rectangular var-tx leaves and
66+16 `16x64` strips before stopping. Attribution measured, not guessed:
67+
68+EVIDENCE: same three segments | `decode_probe` built from a detached worktree at **main 18bf7dc** (`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-r14-main`, worktree + target dir removed after) | main alone gives the IDENTICAL stop strings and `frames=1` on all three
69+
70+So the films now stop in decode-order frame 2 on lane-intrarect's two NARROWER successor
71+refusals; the merge with lane-r14 changes nothing about it. **flagged, not mine**: main
72+18bf7dc is a film-depth regression against this lane's r3 tip — a broad refusal was replaced
73+by narrower ones that fire EARLIER in the stream (or our decode desyncs into them; class
74+refusal-from-own-desync is untested here). Owner: lane-intrarect / a fresh lane.
75+
76+## Residue
77+
78+- deferred(needs the 16x16-level inter 1:4 lane, or the non-skip HORZ_B rect residual lane) —
79+ a PIXEL-EXACT aomenc stream carrying a rectangular var-tx leaf. Both firing streams are one
80+ refusal short of running to the end; the assert to strengthen is the `if bit_depth == 8` block.
81+- deferred(needs an aomenc recipe that fires the arm at 10 bits) — the 10-bit firing assert.
82+ Measured absent over the 18-attempt sweep at cq 32/35/38.
83+- flagged, not mine — the film-depth regression above.
84+- accepted — `--enable-ab-partitions=0` streams still reach `an inter SB-level AB partition`
85+ and `--min-partition-size=16` streams reach `an inter partition below 8x8` (both re-observed
86+ this round, r3 flagged them first): a refusal naming a disabled tool is usually our own
87+ desync, and deserves its own lane.