forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-kf900' (5a28354): intrabc chroma tx_type and palette neighbour bands

Browse files at this commit

11a8d8e5661e0a26576df38c0ec8822d14c84529Ahmet Kaan GümüşParent: 959902b9186646
Chroma transform units under intrabc inherit the luma tx_type; palette
neighbour bands are recorded per mi. Clean merge, no conflicts.

Gates: intrabc (7 arms) / rect_strip_palette / palette / refusal_inventory /
gate_coverage / base_ctx_rect_offsets -- 23 passed. Both
split_transform_intra_block arms are green again; only
a_frame_edge_straddling_band_decodes_pixel_exact remains red (known
cross-product, mergefix lane).

Merged at r6 (5a28354) and NOT retired: the lane's r7 round is still running
in its worktree.
crates/ec-av1/src/decode.rsmodified+146 -116
@@ -1674,6 +1674,21 @@ thread_local! {
1674 static INTRABC_DV: std::cell::Cell<Option<(i32, i32)>> = const { std::cell::Cell::new(None) };1674 static INTRABC_DV: std::cell::Cell<Option<(i32, i32)>> = const { std::cell::Cell::new(None) };
1675 /// How many blocks decoded `use_intrabc == 1` -- the gate's hit counter.1675 /// How many blocks decoded `use_intrabc == 1` -- the gate's hit counter.
1676 static INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };1676 static INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1677+ /// The `tx_type` the last plane-0 [`read_plane`] actually coded, kept so
1678+ /// an intrabc block's chroma reads can inherit it (see
1679+ /// [`INTRABC_CHROMA_TX`]). Written on every luma read; only ever read
1680+ /// through that one arming site.
1681+ static LUMA_TX_TYPE: std::cell::Cell<TxType> = const { std::cell::Cell::new(TxType::DctDct) };
1682+ /// libaom `av1_get_tx_type` (`blockd.h:1350`): for `PLANE_TYPE_UV` it
1683+ /// branches on `is_inter_block(mbmi)` -- which `is_intrabc_block` also
1684+ /// satisfies (`blockd.h:373`) -- and takes the *colocated luma
1685+ /// transform's coded* `tx_type` (`mbmi->txk_type[...]`), never
1686+ /// `intra_mode_to_tx_type` of the chroma mode. `Some` only across an
1687+ /// intrabc block's two chroma [`read_plane`] calls; the type decides the
1688+ /// `TX_CLASS`, hence the scan order, `eob_multi_ctx` and every nz context
1689+ /// -- getting it wrong desyncs the chroma coefficients, it is not a
1690+ /// reconstruction-only detail.
1691+ static INTRABC_CHROMA_TX: std::cell::Cell<Option<TxType>> = const { std::cell::Cell::new(None) };
1677 }1692 }
1678 1693
1679 /// Whether this frame's header set `allow_intrabc` -- [`INTRABC_MI_GRID`] is1694 /// Whether this frame's header set `allow_intrabc` -- [`INTRABC_MI_GRID`] is
@@ -4386,14 +4401,14 @@ impl Neighbours {
4386 uv_tx_h_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)],4401 uv_tx_h_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)],
4387 ref_grid: vec![0i8; cols * (SUB / MI) * rows * (SUB / MI)],4402 ref_grid: vec![0i8; cols * (SUB / MI) * rows * (SUB / MI)],
4388 delta_lf_grid: vec![[0i8; 4]; cols * (SUB / MI) * rows * (SUB / MI)],4403 delta_lf_grid: vec![[0i8; 4]; cols * (SUB / MI) * rows * (SUB / MI)],
4389- above_palette_size: vec![0; cols],4404+ above_palette_size: vec![0; cols * (SUB / MI)],
4390- left_palette_size: vec![0; rows],4405+ left_palette_size: vec![0; rows * (SUB / MI)],
4391- above_palette_colors: vec![[0u16; 8]; cols],4406+ above_palette_colors: vec![[0u16; 8]; cols * (SUB / MI)],
4392- left_palette_colors: vec![[0u16; 8]; rows],4407+ left_palette_colors: vec![[0u16; 8]; rows * (SUB / MI)],
4393- above_palette_uv_size: vec![0; cols],4408+ above_palette_uv_size: vec![0; cols * (SUB / MI)],
4394- left_palette_uv_size: vec![0; rows],4409+ left_palette_uv_size: vec![0; rows * (SUB / MI)],
4395- above_palette_uv_colors: vec![[0u16; 8]; cols],4410+ above_palette_uv_colors: vec![[0u16; 8]; cols * (SUB / MI)],
4396- left_palette_uv_colors: vec![[0u16; 8]; rows],4411+ left_palette_uv_colors: vec![[0u16; 8]; rows * (SUB / MI)],
4397 tile_row0_mi: 0,4412 tile_row0_mi: 0,
4398 tile_col0_mi: 0,4413 tile_col0_mi: 0,
4399 }4414 }
@@ -4453,7 +4468,7 @@ impl Neighbours {
4453 /// mirrors [`Self::record_rect`]'s loop shape, square-only (this lane's4468 /// mirrors [`Self::record_rect`]'s loop shape, square-only (this lane's
4454 /// call sites are all square blocks).4469 /// call sites are all square blocks).
4455 fn record_palette_y(&mut self, at: (usize, usize), side: usize, size: usize, colors: [u16; 8]) {4470 fn record_palette_y(&mut self, at: (usize, usize), side: usize, size: usize, colors: [u16; 8]) {
4456- self.record_palette_y_rect(at, side, side, size, colors);4471+ self.record_palette_y_rect((at.0 * (SUB / MI), at.1 * (SUB / MI)), side, side, size, colors);
4457 }4472 }
4458 4473
4459 /// [`Self::record_palette_y`] with independent above (`w`)/left (`h`)4474 /// [`Self::record_palette_y`] with independent above (`w`)/left (`h`)
@@ -4462,29 +4477,30 @@ impl Neighbours {
4462 /// differ.4477 /// differ.
4463 fn record_palette_y_rect(4478 fn record_palette_y_rect(
4464 &mut self,4479 &mut self,
4465- at: (usize, usize),4480+ mi: (usize, usize),
4466 w: usize,4481 w: usize,
4467 h: usize,4482 h: usize,
4468 size: usize,4483 size: usize,
4469 colors: [u16; 8],4484 colors: [u16; 8],
4470 ) {4485 ) {
4471- let (r, c) = at;4486+ let (r, c) = mi;
4472- // `.max(1)`: a below-16px span covers no whole SUB cell, so the plain4487+ // lane-kf900 r6: mi (4px) granularity, libaom's own -- `palette_size`
4473- // `w / SUB` loop was a NO-OP for every 16x8/8x16/8x8/4x4 leaf and the4488+ // lives per mi cell in `MB_MODE_INFO`, and `xd->left_mbmi` is the mi
4474- // next block read a long-dead palette out of the above/left arrays4489+ // cell immediately left of the block, not its 16px [`SUB`] cell. The
4475- // (class [[cdf-row-held-constant]], lane-palette2 r8). libaom keeps4490+ // old SUB grid let a 16x8 strip pair share one slot, so the second
4476- // `palette_size` per 4px mi cell; corner-cut: our grid is 16px, so a4491+ // strip of mi(0,8) read the FIRST strip's palette size and the colour
4477- // sub-16 leaf stamps its whole containing cell -- safe today because4492+ // cache came out one entry short (class [[context-read-from-one-cell]]).
4478- // every sub-16 leaf path refuses palette outright (so it can only4493+ for cell in 0..(w / MI).max(1) {
4479- // ever stamp `size == 0`, and its cell holds no palette sibling).4494+ if let Some(e) = self.above_palette_size.get_mut(c + cell) {
4480- // Upgrade path: widen the palette arrays to mi granularity.4495+ *e = size;
4481- for cell in 0..(w / SUB).max(1) {4496+ self.above_palette_colors[c + cell] = colors;
4482- self.above_palette_size[c + cell] = size;4497+ }
4483- self.above_palette_colors[c + cell] = colors;
4484 }4498 }
4485- for cell in 0..(h / SUB).max(1) {4499+ for cell in 0..(h / MI).max(1) {
4486- self.left_palette_size[r + cell] = size;4500+ if let Some(e) = self.left_palette_size.get_mut(r + cell) {
4487- self.left_palette_colors[r + cell] = colors;4501+ *e = size;
4502+ self.left_palette_colors[r + cell] = colors;
4503+ }
4488 }4504 }
4489 }4505 }
4490 4506
@@ -4502,7 +4518,7 @@ impl Neighbours {
4502 /// palette block decoded as "no palette" and the tile desynced from4518 /// palette block decoded as "no palette" and the tile desynced from
4503 /// there (class [[cdf-row-held-constant]]).4519 /// there (class [[cdf-row-held-constant]]).
4504 fn palette_ctx_and_cache(&self, at: (usize, usize)) -> (usize, Vec<u16>) {4520 fn palette_ctx_and_cache(&self, at: (usize, usize)) -> (usize, Vec<u16>) {
4505- self.palette_ctx_and_cache_mi(at, at.0 * (SUB / MI))4521+ self.palette_ctx_and_cache_mi((at.0 * (SUB / MI), at.1 * (SUB / MI)))
4506 }4522 }
4507 4523
4508 /// [`Self::palette_ctx_and_cache`] with the block's REAL mi row, which a4524 /// [`Self::palette_ctx_and_cache`] with the block's REAL mi row, which a
@@ -4512,11 +4528,11 @@ impl Neighbours {
4512 /// block's own PIXEL row), and strip 1 of a HORZ_4 sits 8 px into the4528 /// block's own PIXEL row), and strip 1 of a HORZ_4 sits 8 px into the
4513 /// cell -- reading `at.0 % 4` there excludes strip 0 from the cache of4529 /// cell -- reading `at.0 % 4` there excludes strip 0 from the cache of
4514 /// every strip in an SB's top cell row, which libaom does not do.4530 /// every strip in an SB's top cell row, which libaom does not do.
4515- fn palette_ctx_and_cache_mi(&self, at: (usize, usize), mi_r: usize) -> (usize, Vec<u16>) {4531+ fn palette_ctx_and_cache_mi(&self, mi: (usize, usize)) -> (usize, Vec<u16>) {
4516- let (r, c) = at;4532+ let (r, c) = mi;
4517- let above_ok = mi_r % 16 != 0;4533+ let above_ok = r % 16 != 0;
4518 // `xd->above_mbmi` exists for every row but the tile's own first.4534 // `xd->above_mbmi` exists for every row but the tile's own first.
4519- let above_is_palette = mi_r > self.tile_row0_mi && self.above_palette_size[c] > 0;4535+ let above_is_palette = r > self.tile_row0_mi && self.above_palette_size[c] > 0;
4520 let (above_n, above_colors) = if above_ok && self.above_palette_size[c] > 0 {4536 let (above_n, above_colors) = if above_ok && self.above_palette_size[c] > 0 {
4521 (self.above_palette_size[c], self.above_palette_colors[c])4537 (self.above_palette_size[c], self.above_palette_colors[c])
4522 } else {4538 } else {
@@ -4527,7 +4543,7 @@ impl Neighbours {
4527 // (`left_available`), not the frame's -- without this guard a second4543 // (`left_available`), not the frame's -- without this guard a second
4528 // tile column reads the previous tile's palette colours into its cache4544 // tile column reads the previous tile's palette colours into its cache
4529 // and its `palette_y_mode` ctx.4545 // and its `palette_y_mode` ctx.
4530- let left_ok = c > self.tile_col0_mi / (SUB / MI);4546+ let left_ok = c > self.tile_col0_mi;
4531 let (left_n, left_colors) = if left_ok && self.left_palette_size[r] > 0 {4547 let (left_n, left_colors) = if left_ok && self.left_palette_size[r] > 0 {
4532 (self.left_palette_size[r], self.left_palette_colors[r])4548 (self.left_palette_size[r], self.left_palette_colors[r])
4533 } else {4549 } else {
@@ -4569,7 +4585,13 @@ impl Neighbours {
4569 /// (U-channel) palette size/colours -- `size == 0` clears stale state the4585 /// (U-channel) palette size/colours -- `size == 0` clears stale state the
4570 /// same way (lane-palette2 r1).4586 /// same way (lane-palette2 r1).
4571 fn record_palette_uv(&mut self, at: (usize, usize), side: usize, size: usize, colors: [u16; 8]) {4587 fn record_palette_uv(&mut self, at: (usize, usize), side: usize, size: usize, colors: [u16; 8]) {
4572- self.record_palette_uv_rect(at, side, side, size, colors);4588+ self.record_palette_uv_rect(
4589+ (at.0 * (SUB / MI), at.1 * (SUB / MI)),
4590+ side,
4591+ side,
4592+ size,
4593+ colors,
4594+ );
4573 }4595 }
4574 4596
4575 /// [`Self::record_palette_uv`] with independent above (`w`)/left (`h`)4597 /// [`Self::record_palette_uv`] with independent above (`w`)/left (`h`)
@@ -4578,21 +4600,25 @@ impl Neighbours {
4578 /// luma resolution regardless of which plane the recorded state is for).4600 /// luma resolution regardless of which plane the recorded state is for).
4579 fn record_palette_uv_rect(4601 fn record_palette_uv_rect(
4580 &mut self,4602 &mut self,
4581- at: (usize, usize),4603+ mi: (usize, usize),
4582 w: usize,4604 w: usize,
4583 h: usize,4605 h: usize,
4584 size: usize,4606 size: usize,
4585 colors: [u16; 8],4607 colors: [u16; 8],
4586 ) {4608 ) {
4587- let (r, c) = at;4609+ let (r, c) = mi;
4588- // See [`Self::record_palette_y_rect`] for the `.max(1)`.4610+ // mi granularity, see [`Self::record_palette_y_rect`].
4589- for cell in 0..(w / SUB).max(1) {4611+ for cell in 0..(w / MI).max(1) {
4590- self.above_palette_uv_size[c + cell] = size;4612+ if let Some(e) = self.above_palette_uv_size.get_mut(c + cell) {
4591- self.above_palette_uv_colors[c + cell] = colors;4613+ *e = size;
4614+ self.above_palette_uv_colors[c + cell] = colors;
4615+ }
4592 }4616 }
4593- for cell in 0..(h / SUB).max(1) {4617+ for cell in 0..(h / MI).max(1) {
4594- self.left_palette_uv_size[r + cell] = size;4618+ if let Some(e) = self.left_palette_uv_size.get_mut(r + cell) {
4595- self.left_palette_uv_colors[r + cell] = colors;4619+ *e = size;
4620+ self.left_palette_uv_colors[r + cell] = colors;
4621+ }
4596 }4622 }
4597 }4623 }
4598 4624
@@ -4602,21 +4628,21 @@ impl Neighbours {
4602 /// palette use, `read_palette_mode_info`'s `pmi->palette_size[0] > 0`),4628 /// palette use, `read_palette_mode_info`'s `pmi->palette_size[0] > 0`),
4603 /// so only the cache is wanted here.4629 /// so only the cache is wanted here.
4604 fn palette_uv_cache(&self, at: (usize, usize)) -> Vec<u16> {4630 fn palette_uv_cache(&self, at: (usize, usize)) -> Vec<u16> {
4605- self.palette_uv_cache_mi(at, at.0 * (SUB / MI))4631+ self.palette_uv_cache_mi((at.0 * (SUB / MI), at.1 * (SUB / MI)))
4606 }4632 }
4607 4633
4608 /// [`Self::palette_uv_cache`] with the block's real mi row -- see4634 /// [`Self::palette_uv_cache`] with the block's real mi row -- see
4609 /// [`Self::palette_ctx_and_cache_mi`].4635 /// [`Self::palette_ctx_and_cache_mi`].
4610- fn palette_uv_cache_mi(&self, at: (usize, usize), mi_r: usize) -> Vec<u16> {4636+ fn palette_uv_cache_mi(&self, mi: (usize, usize)) -> Vec<u16> {
4611- let (r, c) = at;4637+ let (r, c) = mi;
4612- let above_ok = mi_r % 16 != 0;4638+ let above_ok = r % 16 != 0;
4613 let (above_n, above_colors) = if above_ok && self.above_palette_uv_size[c] > 0 {4639 let (above_n, above_colors) = if above_ok && self.above_palette_uv_size[c] > 0 {
4614 (self.above_palette_uv_size[c], self.above_palette_uv_colors[c])4640 (self.above_palette_uv_size[c], self.above_palette_uv_colors[c])
4615 } else {4641 } else {
4616 (0, [0u16; 8])4642 (0, [0u16; 8])
4617 };4643 };
4618 // Same tile-relative left availability as the luma cache above.4644 // Same tile-relative left availability as the luma cache above.
4619- let left_ok = c > self.tile_col0_mi / (SUB / MI);4645+ let left_ok = c > self.tile_col0_mi;
4620 let (left_n, left_colors) = if left_ok && self.left_palette_uv_size[r] > 0 {4646 let (left_n, left_colors) = if left_ok && self.left_palette_uv_size[r] > 0 {
4621 (self.left_palette_uv_size[r], self.left_palette_uv_colors[r])4647 (self.left_palette_uv_size[r], self.left_palette_uv_colors[r])
4622 } else {4648 } else {
@@ -6328,40 +6354,43 @@ fn read_intra_mode_rect(
6328 ))6354 ))
6329 }6355 }
6330 6356
6331-/// Stamps a 1:4 strip's palette state into the coarse above/left arrays.6357+/// Stamps a 1:4 strip's palette state into the mi-granular above/left arrays,
6332-/// `av1_get_palette_cache` reads `xd->above_mbmi`/`xd->left_mbmi`, and inside6358+/// at the strip's REAL mi position. `av1_get_palette_cache` reads
6333-/// a HORZ_4 (VERT_4) the next strip's ABOVE (LEFT) neighbour is this strip6359+/// `xd->above_mbmi`/`xd->left_mbmi`, i.e. the mi cell above/left of the
6334-/// while its LEFT (ABOVE) neighbour is still the parent block's. The coarse6360+/// block, so each strip owns its own rows and columns and no aliasing rule
6335-/// [`SUB`]-cell arrays alias all four strips onto one entry, so writing BOTH6361+/// is needed (lane-kf900 r6).
6336-/// axes after every strip would hand strip i+1 this strip's colours on the
6337-/// wrong axis too -- a wrong cache costs the same bits, so the tile stays in
6338-/// sync and only the pixels are wrong (class [[cdf-row-held-constant]]).
6339-/// Only the split axis is written until the closing strip, which stamps both
6340-/// for whatever follows the parent block.
6341 #[allow(clippy::too_many_arguments)]6362 #[allow(clippy::too_many_arguments)]
6342 fn record_strip_palette(6363 fn record_strip_palette(
6343 n: &mut Neighbours,6364 n: &mut Neighbours,
6344- at: (usize, usize),6365+ mi: (usize, usize),
6345 bw: usize,6366 bw: usize,
6346 bh: usize,6367 bh: usize,
6347 y_size: usize,6368 y_size: usize,
6348 y_colors: [u16; 8],6369 y_colors: [u16; 8],
6349 uv_size: usize,6370 uv_size: usize,
6350 uv_colors: [u16; 8],6371 uv_colors: [u16; 8],
6351- last: bool,
6352 ) {6372 ) {
6353- let (r, c) = at;6373+ let (r, c) = mi;
6354- let horz = bw > bh;6374+ // lane-kf900 r6: the palette side bands are mi-granular now, so a strip
6355- if horz || last {6375+ // writes its OWN span on BOTH axes -- the old `last` split-axis rule only
6356- for cell in 0..(bw / SUB).max(1) {6376+ // existed because the 16px [`SUB`] cell held one slot for all the strips
6357- n.above_palette_size[c + cell] = y_size;6377+ // of a HORZ_4/VERT_4 and leaf 0 zeroing the other axis threw away the
6358- n.above_palette_colors[c + cell] = y_colors;6378+ // real neighbour leaf 1 reads.
6359- n.above_palette_uv_size[c + cell] = uv_size;6379+ {
6360- n.above_palette_uv_colors[c + cell] = uv_colors;6380+ for cell in 0..(bw / MI).max(1) {
6381+ if let Some(e) = n.above_palette_size.get_mut(c + cell) {
6382+ *e = y_size;
6383+ n.above_palette_colors[c + cell] = y_colors;
6384+ n.above_palette_uv_size[c + cell] = uv_size;
6385+ n.above_palette_uv_colors[c + cell] = uv_colors;
6386+ }
6361 }6387 }
6362 }6388 }
6363- if !horz || last {6389+ {
6364- for cell in 0..(bh / SUB).max(1) {6390+ for cell in 0..(bh / MI).max(1) {
6391+ if n.left_palette_size.get(r + cell).is_none() {
6392+ break;
6393+ }
6365 n.left_palette_size[r + cell] = y_size;6394 n.left_palette_size[r + cell] = y_size;
6366 n.left_palette_colors[r + cell] = y_colors;6395 n.left_palette_colors[r + cell] = y_colors;
6367 n.left_palette_uv_size[r + cell] = uv_size;6396 n.left_palette_uv_size[r + cell] = uv_size;
@@ -7210,10 +7239,10 @@ fn decode_block_rect(
7210 // wrong VALUE -- same bit count, so the entropy stream stayed in sync7239 // wrong VALUE -- same bit count, so the entropy stream stayed in sync
7211 // and only those pixels were wrong (lane-palette2 r10).7240 // and only those pixels were wrong (lane-palette2 r10).
7212 let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));7241 let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
7213- neighbours.record_palette_y_rect(at, bw, bh, py_size, py_colors);7242+ neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, py_size, py_colors);
7214 let (puv_size, puv_colors) =7243 let (puv_size, puv_colors) =
7215 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));7244 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
7216- neighbours.record_palette_uv_rect(at, bw, bh, puv_size, puv_colors);7245+ neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors);
7217 RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1));7246 RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1));
7218 return Ok(());7247 return Ok(());
7219 }7248 }
@@ -7478,10 +7507,10 @@ fn decode_block_rect(
7478 }7507 }
7479 }7508 }
7480 let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));7509 let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
7481- neighbours.record_palette_y_rect(at, bw, bh, py_size, py_colors);7510+ neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, py_size, py_colors);
7482 let (puv_size, puv_colors) =7511 let (puv_size, puv_colors) =
7483 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));7512 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
7484- neighbours.record_palette_uv_rect(at, bw, bh, puv_size, puv_colors);7513+ neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors);
7485 neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip);7514 neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip);
7486 neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0);7515 neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0);
7487 RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1));7516 RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1));
@@ -7567,12 +7596,13 @@ fn decode_leaf_rect(
7567 // a palette narrows the wrong interval and desyncs the tile even when the7596 // a palette narrows the wrong interval and desyncs the tile even when the
7568 // decoded bit is the same. The cell is the 16px-SUB cell containing the7597 // decoded bit is the same. The cell is the 16px-SUB cell containing the
7569 // leaf (the palette neighbour arrays have no finer granularity).7598 // leaf (the palette neighbour arrays have no finer granularity).
7570- let pal_at = (leaf_mi.0 / (SUB / MI), leaf_mi.1 / (SUB / MI));7599+ // lane-kf900 r6: the leaf's REAL mi position -- the second leaf of a 16x8
7571- // lane-kf900 r4: the leaf's REAL mi row -- the second leaf of a 16x8 pair7600+ // pair sits 8 px into the 16px cell, and both the cache's superblock-top-row
7572- // sits 8 px into the cell, so the cache's superblock-top-row exclusion7601+ // exclusion and the neighbour palette lookup itself are mi-granular
7573- // must not be read off the cell (see [`Neighbours::palette_ctx_and_cache_mi`]).7602+ // (see [`Neighbours::palette_ctx_and_cache_mi`]).
7574- let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at, leaf_mi.0);7603+ let pal_at = leaf_mi;
7575- let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at, leaf_mi.0);7604+ let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at);
7605+ let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at);
7576 let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) =7606 let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) =
7577 read_intra_mode_rect(7607 read_intra_mode_rect(
7578 dec,7608 dec,
@@ -7610,12 +7640,6 @@ fn decode_leaf_rect(
7610 palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));7640 palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
7611 let (pal_uv_size, pal_uv_colors) =7641 let (pal_uv_size, pal_uv_colors) =
7612 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));7642 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
7613- // The closing leaf of the pair -- see [`record_strip_palette`].
7614- let pal_last = if bw > bh {
7615- leaf_mi.0 % 4 == 2
7616- } else {
7617- leaf_mi.1 % 4 == 2
7618- };
7619 if std::env::var_os("EC_AV1_RECTX_TRACE").is_some() {7643 if std::env::var_os("EC_AV1_RECTX_TRACE").is_some() {
7620 eprintln!(" skip={skip} mode={mode} angle_delta_y={angle_delta_y} uv_mode={uv_mode}");7644 eprintln!(" skip={skip} mode={mode} angle_delta_y={angle_delta_y} uv_mode={uv_mode}");
7621 }7645 }
@@ -7698,7 +7722,6 @@ fn decode_leaf_rect(
7698 )?;7722 )?;
7699 record_strip_palette(7723 record_strip_palette(
7700 neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,7724 neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,
7701- pal_last,
7702 );7725 );
7703 return Ok(mode);7726 return Ok(mode);
7704 }7727 }
@@ -7822,7 +7845,6 @@ fn decode_leaf_rect(
7822 // real left neighbour leaf 1 reads (lane-kf900 r4).7845 // real left neighbour leaf 1 reads (lane-kf900 r4).
7823 record_strip_palette(7846 record_strip_palette(
7824 neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,7847 neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,
7825- pal_last,
7826 );7848 );
7827 // A rect leaf spans mi_w x mi_h, so its mode reaches several columns and7849 // A rect leaf spans mi_w x mi_h, so its mode reaches several columns and
7828 // rows -- record the whole span, not one cell.7850 // rows -- record the whole span, not one cell.
@@ -7892,9 +7914,9 @@ fn decode_block_rect4(
7892 // `palette_colors_y` cache hit off an EMPTY cache -- right symbol count,7914 // `palette_colors_y` cache hit off an EMPTY cache -- right symbol count,
7893 // wrong interval, so a screen-content tile desynced at the first strip7915 // wrong interval, so a screen-content tile desynced at the first strip
7894 // whose neighbour used a palette (class [[cdf-row-held-constant]]).7916 // whose neighbour used a palette (class [[cdf-row-held-constant]]).
7895- let pal_at = (mi_r / (SUB / MI), mi_c / (SUB / MI));7917+ let pal_at = (mi_r, mi_c);
7896- let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at, mi_r);7918+ let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at);
7897- let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at, mi_r);7919+ let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at);
7898 let (7920 let (
7899 skip,7921 skip,
7900 mode,7922 mode,
@@ -7938,10 +7960,6 @@ fn decode_block_rect4(
7938 p.map.iter().map(|&i| p.v_colors[i as usize]).collect(),7960 p.map.iter().map(|&i| p.v_colors[i as usize]).collect(),
7939 )7961 )
7940 });7962 });
7941- // `last`: strip 3 of the parent 32x32's HORZ_4 (VERT_4), the only one
7942- // whose colours a block outside the parent sees -- see
7943- // [`record_strip_palette`].
7944- let pal_last = if bw > bh { mi_r % 8 == 6 } else { mi_c % 8 == 6 };
7945 let (pal_y_size, pal_y_colors) =7963 let (pal_y_size, pal_y_colors) =
7946 palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));7964 palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
7947 let (pal_uv_size, pal_uv_colors) =7965 let (pal_uv_size, pal_uv_colors) =
@@ -8029,7 +8047,7 @@ fn decode_block_rect4(
8029 )?;8047 )?;
8030 record_strip_palette(8048 record_strip_palette(
8031 neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size,8049 neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size,
8032- pal_uv_colors, pal_last,8050+ pal_uv_colors,
8033 );8051 );
8034 if bw > bh {8052 if bw > bh {
8035 RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));8053 RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));
@@ -8182,7 +8200,7 @@ fn decode_block_rect4(
8182 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0);8200 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0);
8183 record_strip_palette(8201 record_strip_palette(
8184 neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size,8202 neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size,
8185- pal_uv_colors, pal_last,8203+ pal_uv_colors,
8186 );8204 );
8187 if bw > bh {8205 if bw > bh {
8188 RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));8206 RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));
@@ -8245,7 +8263,6 @@ fn decode_block_rect4(
8245 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0);8263 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0);
8246 record_strip_palette(8264 record_strip_palette(
8247 neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,8265 neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,
8248- pal_last,
8249 );8266 );
8250 if bw > bh {8267 if bw > bh {
8251 RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));8268 RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));
@@ -8329,9 +8346,8 @@ fn decode_rect4_16(
8329 // lane-kf900 r4: the strip's real palette ctx + colour cache (see8346 // lane-kf900 r4: the strip's real palette ctx + colour cache (see
8330 // [`decode_block_rect4`]); `None`/`&[]` here read `palette_y_mode`8347 // [`decode_block_rect4`]); `None`/`&[]` here read `palette_y_mode`
8331 // off CDF row 0 and every cache hit off an empty cache.8348 // off CDF row 0 and every cache hit off an empty cache.
8332- let (palette_ctx, palette_cache) =8349+ let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(lmi);
8333- neighbours.palette_ctx_and_cache_mi(at16, lmi.0);8350+ let palette_uv_cache = neighbours.palette_uv_cache_mi(lmi);
8334- let palette_uv_cache = neighbours.palette_uv_cache_mi(at16, lmi.0);
8335 let (8351 let (
8336 skip,8352 skip,
8337 mode,8353 mode,
@@ -8740,8 +8756,7 @@ fn decode_rect4_16(
8740 let (pal_uv_size, pal_uv_colors) =8756 let (pal_uv_size, pal_uv_colors) =
8741 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));8757 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
8742 record_strip_palette(8758 record_strip_palette(
8743- neighbours, at16, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,8759+ neighbours, lmi, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,
8744- i == 3,
8745 );8760 );
8746 last_mode = mode;8761 last_mode = mode;
8747 prev = Some((lmi, mode));8762 prev = Some((lmi, mode));
@@ -8936,10 +8951,10 @@ fn decode_block_rect64(
8936 // split-tx superblock strip would otherwise leave the above/left8951 // split-tx superblock strip would otherwise leave the above/left
8937 // palette arrays holding a dead block's colours.8952 // palette arrays holding a dead block's colours.
8938 let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));8953 let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
8939- neighbours.record_palette_y_rect(at, bw, bh, py_size, py_colors);8954+ neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, py_size, py_colors);
8940 let (puv_size, puv_colors) =8955 let (puv_size, puv_colors) =
8941 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));8956 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
8942- neighbours.record_palette_uv_rect(at, bw, bh, puv_size, puv_colors);8957+ neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors);
8943 RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1));8958 RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1));
8944 return Ok(());8959 return Ok(());
8945 }8960 }
@@ -9251,10 +9266,10 @@ fn decode_block_rect64(
9251 RECT_COEFF_HITS.with(|c| c.set(c.get() + 1));9266 RECT_COEFF_HITS.with(|c| c.set(c.get() + 1));
9252 }9267 }
9253 let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));9268 let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
9254- neighbours.record_palette_y_rect(at, bw, bh, py_size, py_colors);9269+ neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, py_size, py_colors);
9255 let (puv_size, puv_colors) =9270 let (puv_size, puv_colors) =
9256 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));9271 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
9257- neighbours.record_palette_uv_rect(at, bw, bh, puv_size, puv_colors);9272+ neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors);
9258 neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip);9273 neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip);
9259 neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0);9274 neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0);
9260 SB_RECT_HITS.with(|c| c.set(c.get() + 1));9275 SB_RECT_HITS.with(|c| c.set(c.get() + 1));
@@ -10130,6 +10145,13 @@ fn read_plane(
10130 // narrows there — only `Chroma32` and up do).10145 // narrows there — only `Chroma32` and up do).
10131 let default_tx_type = if plane_idx == 0 || side >= 32 {10146 let default_tx_type = if plane_idx == 0 || side >= 32 {
10132 TxType::DctDct10147 TxType::DctDct
10148+ } else if let Some(inherited) = INTRABC_CHROMA_TX.with(std::cell::Cell::get) {
10149+ // See [`INTRABC_CHROMA_TX`]: an intrabc block is an inter block for
10150+ // `av1_get_tx_type`, so chroma inherits luma's coded type (the
10151+ // `side >= 32` arm above is already libaom's `EXT_TX_SET_DCTONLY`
10152+ // clamp at `tx_size_sqr_up >= TX_32X32`, matching
10153+ // [`read_inter_plane`]'s own `side < 32` guard).
10154+ inherited
10133 } else {10155 } else {
10134 default_intra_tx_type(predict_mode as u8)10156 default_intra_tx_type(predict_mode as u8)
10135 };10157 };
@@ -10143,6 +10165,9 @@ fn read_plane(
10143 None,10165 None,
10144 )?;10166 )?;
10145 note_chroma_class1(plane_idx, tx_type);10167 note_chroma_class1(plane_idx, tx_type);
10168+ if plane_idx == 0 {
10169+ LUMA_TX_TYPE.with(|c| c.set(tx_type));
10170+ }
10146 // A 64x64 luma block's transform covers the whole 64x64 area, but only its10171 // A 64x64 luma block's transform covers the whole 64x64 area, but only its
10147 // top-left 32x32 of frequencies are coded (spec 5.11.40); the rest of the10172 // top-left 32x32 of frequencies are coded (spec 5.11.40); the rest of the
10148 // dequantized grid stays zero, which `inverse_transform_2d`'s own `< 32`10173 // dequantized grid stays zero, which `inverse_transform_2d`'s own `< 32`
@@ -10543,6 +10568,12 @@ fn decode_block(
10543 smooth_neighbor,10568 smooth_neighbor,
10544 )?;10569 )?;
10545 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));10570 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
10571+ // Armed for exactly this block's two chroma reads (see
10572+ // [`INTRABC_CHROMA_TX`]); the luma call above just set
10573+ // [`LUMA_TX_TYPE`] to the type it coded.
10574+ if intrabc_dv.is_some() {
10575+ INTRABC_CHROMA_TX.with(|c| c.set(Some(LUMA_TX_TYPE.with(std::cell::Cell::get))));
10576+ }
10546 if let Some((ub, _)) = &palette_uv_bufs {10577 if let Some((ub, _)) = &palette_uv_bufs {
10547 set_palette_pred(ub.clone());10578 set_palette_pred(ub.clone());
10548 }10579 }
@@ -10599,6 +10630,7 @@ fn decode_block(
10599 None,10630 None,
10600 smooth_neighbor_uv,10631 smooth_neighbor_uv,
10601 )?;10632 )?;
10633+ INTRABC_CHROMA_TX.with(|c| c.set(None));
10602 neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]);10634 neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]);
10603 } else {10635 } else {
10604 // Several luma transform units, raster order (spec10636 // Several luma transform units, raster order (spec
@@ -11240,9 +11272,8 @@ fn decode_leaf8(
11240 // above/left palette state over its own cell so the next block's ctx and11272 // above/left palette state over its own cell so the next block's ctx and
11241 // colour cache do not read a previous block's palette (lane-palette2 r8).11273 // colour cache do not read a previous block's palette (lane-palette2 r8).
11242 {11274 {
11243- let pal_at = (leaf_mi.0 / (SUB / MI), leaf_mi.1 / (SUB / MI));11275+ neighbours.record_palette_y_rect(leaf_mi, 8, 8, 0, [0u16; 8]);
11244- neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]);11276+ neighbours.record_palette_uv_rect(leaf_mi, 8, 8, 0, [0u16; 8]);
11245- neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]);
11246 }11277 }
11247 neighbours.fill_skip_grid(leaf_mi, 2, skip);11278 neighbours.fill_skip_grid(leaf_mi, 2, skip);
11248 neighbours.fill_lf_grid(leaf_mi, 2, 4, 0);11279 neighbours.fill_lf_grid(leaf_mi, 2, 4, 0);
@@ -11254,9 +11285,8 @@ fn decode_leaf8(
11254 // above/left palette state over its own cell so the next block's ctx and11285 // above/left palette state over its own cell so the next block's ctx and
11255 // colour cache do not read a previous block's palette (lane-palette2 r8).11286 // colour cache do not read a previous block's palette (lane-palette2 r8).
11256 {11287 {
11257- let pal_at = (leaf_mi.0 / (SUB / MI), leaf_mi.1 / (SUB / MI));11288+ neighbours.record_palette_y_rect(leaf_mi, 8, 8, 0, [0u16; 8]);
11258- neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]);11289+ neighbours.record_palette_uv_rect(leaf_mi, 8, 8, 0, [0u16; 8]);
11259- neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]);
11260 }11290 }
11261 INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1));11291 INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1));
11262 neighbours.fill_skip_grid(leaf_mi, 2, skip);11292 neighbours.fill_skip_grid(leaf_mi, 2, skip);
@@ -26903,19 +26933,19 @@ mod tests {
26903 fn a_sub16_leaf_after_a_palette_block_yields_palette_ctx_zero() {26933 fn a_sub16_leaf_after_a_palette_block_yields_palette_ctx_zero() {
26904 let mut n = Neighbours::new(4, 4, 16, 16);26934 let mut n = Neighbours::new(4, 4, 16, 16);
26905 // A real 16x16 palette block covering SUB cell (1, 1).26935 // A real 16x16 palette block covering SUB cell (1, 1).
26906- n.record_palette_y_rect((1, 1), 16, 16, 2, [7, 9, 0, 0, 0, 0, 0, 0]);26936+ n.record_palette_y_rect((4, 4), 16, 16, 2, [7, 9, 0, 0, 0, 0, 0, 0]);
26907 let (ctx, cache) = n.palette_ctx_and_cache((1, 1));26937 let (ctx, cache) = n.palette_ctx_and_cache((1, 1));
26908 assert_eq!(ctx, 2, "the palette block itself must be visible");26938 assert_eq!(ctx, 2, "the palette block itself must be visible");
26909 assert_eq!(cache, vec![7, 9]);26939 assert_eq!(cache, vec![7, 9]);
26910 // An 8x8 non-palette leaf in that same cell.26940 // An 8x8 non-palette leaf in that same cell.
26911- n.record_palette_y_rect((1, 1), 8, 8, 0, [0u16; 8]);26941+ n.record_palette_y_rect((4, 4), 8, 8, 0, [0u16; 8]);
26912 let (ctx, cache) = n.palette_ctx_and_cache((1, 1));26942 let (ctx, cache) = n.palette_ctx_and_cache((1, 1));
26913 assert_eq!(ctx, 0, "a sub-16 non-palette leaf must clear its own cell");26943 assert_eq!(ctx, 0, "a sub-16 non-palette leaf must clear its own cell");
26914 assert!(cache.is_empty(), "and its stale colour cache with it");26944 assert!(cache.is_empty(), "and its stale colour cache with it");
26915 // Same for the chroma half.26945 // Same for the chroma half.
26916- n.record_palette_uv_rect((1, 1), 16, 16, 2, [1, 2, 0, 0, 0, 0, 0, 0]);26946+ n.record_palette_uv_rect((4, 4), 16, 16, 2, [1, 2, 0, 0, 0, 0, 0, 0]);
26917 assert_eq!(n.palette_uv_cache((1, 1)), vec![1, 2]);26947 assert_eq!(n.palette_uv_cache((1, 1)), vec![1, 2]);
26918- n.record_palette_uv_rect((1, 1), 8, 8, 0, [0u16; 8]);26948+ n.record_palette_uv_rect((4, 4), 8, 8, 0, [0u16; 8]);
26919 assert!(n.palette_uv_cache((1, 1)).is_empty());26949 assert!(n.palette_uv_cache((1, 1)).is_empty());
26920 }26950 }
26921 26951
crates/ec-av1/src/gate_coverage.rsmodified+12 -15
@@ -42,16 +42,13 @@
42 /// its tool is now covered by a real stream.42 /// its tool is now covered by a real stream.
43 #[cfg(test)]43 #[cfg(test)]
44 const NEVER_EXERCISED: &[(&str, &str)] = &[44 const NEVER_EXERCISED: &[(&str, &str)] = &[
45- // lane-intrabc r1: the DV itself (mv stack against INTRA_FRAME, `ndvc`45+ // `enable-intrabc` LEFT this list on 2026-09-02 (lane-kf900 r6). The
46- // full-pel read, `av1_find_ref_dv` fallback) and the block-copy46+ // premise it carried -- "every real stream's intrabc block sits under
47- // prediction are now decoded, but every real aomenc intrabc block this47+ // TX_MODE_SELECT" -- was false: with `--enable-tx-size-search=0` aomenc
48- // lane could produce sits under TX_MODE_SELECT, whose inter var-tx48+ // codes intrabc blocks under TX_MODE_LARGEST, and
49- // partition tree is unread -- so no stream reconstructs one end to end49+ // `a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips`
50- // yet and this entry stays.50+ // spells `--enable-intrabc=1` and decodes three such 8-bit streams whole-
51- (51+ // frame pixel-exact against ffmpeg, with the block counter asserted > 0.
52- "enable-intrabc",
53- "the block vector is decoded and predicted from, but every real stream's intrabc block needs the unread inter var-tx transform tree",
54- ),
55 ];52 ];
56 53
57 /// The `--enable-*` tools this decoder cares about, whether or not any gate54 /// The `--enable-*` tools this decoder cares about, whether or not any gate
@@ -167,10 +164,6 @@ const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[
167 "enable-global-motion",164 "enable-global-motion",
168 "off in 5 gates, on in none at 8 bits; lane-gm owns the global-warp prediction that is still missing",165 "off in 5 gates, on in none at 8 bits; lane-gm owns the global-warp prediction that is still missing",
169 ),166 ),
170- (
171- "enable-intrabc",
172- "the block vector is decoded and predicted from, but every real stream's intrabc block needs the unread inter var-tx transform tree",
173- ),
174 (167 (
175 "enable-rect-tx",168 "enable-rect-tx",
176 "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool",169 "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool",
@@ -211,7 +204,11 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ // lane-cwarp's 10-bit comp
211 // flip/identity/1D transform types are proven to reach a real 10-bit stream204 // flip/identity/1D transform types are proven to reach a real 10-bit stream
212 // this decoder reconstructs exactly (10 of its rect coefficient TUs carry a205 // this decoder reconstructs exactly (10 of its rect coefficient TUs carry a
213 // 1D tx class).206 // 1D tx class).
214- ("enable-intrabc", "hole at both depths, see the 8-bit list"),207+ // `enable-intrabc` LEFT this 10-bit list on 2026-09-02 (lane-kf900 r6):
208+ // `a_real_aomenc_rect_strip_palette_decodes_pixel_exact`'s new
209+ // `smptebars-screen-txs-cq40/cq55` arms spell `--enable-intrabc=1` and are
210+ // decoded and pixel-compared at 10 bit as well as 8, so the tool reaches a
211+ // real 10-bit stream this decoder reconstructs exactly.
215 ("enable-rect-tx", "hole at both depths, see the 8-bit list"),212 ("enable-rect-tx", "hole at both depths, see the 8-bit list"),
216 ];213 ];
217 214
crates/ec-av1/src/stream.rsmodified+82 -32
@@ -2871,30 +2871,22 @@ mod tests {
2871 let (width, height) = (256usize, 192usize);2871 let (width, height) = (256usize, 192usize);
2872 // (arm, source, per-arm overrides AFTER the base recipe, expect_refusal,2872 // (arm, source, per-arm overrides AFTER the base recipe, expect_refusal,
2873 // must_read_use_intrabc)2873 // must_read_use_intrabc)
2874- let arms: [(&str, &str, &[&str], bool, bool); 3] = [2874+ const TS: &str = "testsrc2=s=256x192:r=25";
2875- (2875+ const SB: &str = "smptebars=size=256x192:rate=25";
2876- "testsrc2-screen-nopalette-cq50",2876+ // (arm, source, per-arm overrides AFTER the base recipe, expect_refusal,
2877- "testsrc2=s=256x192:r=25",2877+ // must_read_use_intrabc_on_a_rect_strip)
2878- &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=0"],2878+ let arms: [(&str, &str, &[&str], bool, bool); 7] = [
2879- true,2879+ ("testsrc2-cq50-txs0", TS, &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=0"], true, true),
2880- true,2880+ ("smptebars-cq40-txs0", SB, &["--cq-level=40", "--enable-palette=0", "--enable-tx-size-search=0"], false, false),
2881- ),2881+ ("smptebars-cq45-txs0", SB, &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=0"], false, true),
2882- (2882+ ("smptebars-cq45-txs1", SB, &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=1"], false, false),
2883- "smptebars-screen-nopalette-cq45",2883+ ("smptebars-cq50-txs1", SB, &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=1"], false, false),
2884- "smptebars=size=256x192:rate=25",2884+ ("smptebars-cq55-txs0", SB, &["--cq-level=55", "--enable-palette=0", "--enable-tx-size-search=0"], false, false),
2885- &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=0"],2885+ ("testsrc2-cq63-txs1", TS, &["--cq-level=63", "--enable-palette=0", "--enable-tx-size-search=1"], false, false),
2886- false,
2887- true,
2888- ),
2889- (
2890- "testsrc2-screen-nopalette-cq63",
2891- "testsrc2=s=256x192:r=25",
2892- &["--cq-level=63", "--enable-palette=0", "--enable-tx-size-search=1"],
2893- false,
2894- false,
2895- ),
2896 ];2886 ];
2897 let (mut reads_total, mut refused, mut frames_compared) = (0usize, 0u32, 0usize);2887 let (mut reads_total, mut refused, mut frames_compared) = (0usize, 0u32, 0usize);
2888+ let (mut blocks_total, mut fired_arms, mut out_of_scope, mut out_of_scope_mismatch) =
2889+ (0usize, 0u32, 0u32, 0u32);
2898 for (arm, src, extra, expect_refusal, must_read) in &arms {2890 for (arm, src, extra, expect_refusal, must_read) in &arms {
2899 let render = || {2891 let render = || {
2900 let out = Command::new("ffmpeg")2892 let out = Command::new("ffmpeg")
@@ -2935,6 +2927,9 @@ mod tests {
2935 // `allow_screen_content_tools` (and with it the frame2927 // `allow_screen_content_tools` (and with it the frame
2936 // header's `allow_intrabc` bit) comes from here.2928 // header's `allow_intrabc` bit) comes from here.
2937 "--tune-content=screen",2929 "--tune-content=screen",
2930+ // Spelled so `gate_coverage` counts the tool as exercised
2931+ // rather than defaulted (class `tool-disabled-in-every-gate`).
2932+ "--enable-intrabc=1",
2938 ])2933 ])
2939 // aomenc keeps the LAST occurrence of a repeated flag.2934 // aomenc keeps the LAST occurrence of a repeated flag.
2940 .args(*extra)2935 .args(*extra)
@@ -2962,9 +2957,15 @@ mod tests {
2962 );2957 );
2963 let stream = out.stdout;2958 let stream = out.stdout;
2964 decode::reset_rect_intrabc_reads();2959 decode::reset_rect_intrabc_reads();
2960+ crate::decode::reset_intrabc_hits();
2965 let decoded = decode_stream(&stream);2961 let decoded = decode_stream(&stream);
2966 let reads = decode::rect_intrabc_reads();2962 let reads = decode::rect_intrabc_reads();
2963+ // Blocks that decoded `use_intrabc == 1` (square path), i.e. that
2964+ // read a DV and predicted from the current frame -- distinct from
2965+ // `reads`, which counts rect strips that merely READ the flag.
2966+ let blocks = crate::decode::intrabc_hits();
2967 reads_total += reads;2967 reads_total += reads;
2968+ blocks_total += blocks;
2968 if *must_read {2969 if *must_read {
2969 assert!(2970 assert!(
2970 reads > 0,2971 reads > 0,
@@ -2980,19 +2981,38 @@ mod tests {
2980 reconstruction is not ported, it must refuse by name"2981 reconstruction is not ported, it must refuse by name"
2981 );2982 );
2982 assert!(!frames.is_empty(), "{NAME}: {arm} decoded no frame");2983 assert!(!frames.is_empty(), "{NAME}: {arm} decoded no frame");
2983- if *must_read {
2984- // Arm 1: entropy coverage only (see PIXEL RESIDUE above).
2985- eprintln!("{NAME}: {arm} decoded {} frame(s), {reads} rect use_intrabc reads", frames.len());
2986- continue;
2987- }
2988 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frames.len());2984 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frames.len());
2989 assert_eq!(frames.len(), ffmpeg_frames.len(), "{NAME}: {arm} frame count");2985 assert_eq!(frames.len(), ffmpeg_frames.len(), "{NAME}: {arm} frame count");
2986+ // EVERY frame is compared; an arm whose decode never hit an
2987+ // intrabc block proves nothing about the DV/prediction path,
2988+ // so it is counted OUT OF SCOPE -- but a mismatch there is
2989+ // still a failure (`out_of_scope_mismatch == 0`), never a skip.
2990+ let mut same = true;
2990 for (i, (ours, theirs)) in frames.iter().zip(ffmpeg_frames.iter()).enumerate() {2991 for (i, (ours, theirs)) in frames.iter().zip(ffmpeg_frames.iter()).enumerate() {
2991- assert_eq!(ours.y, theirs.y, "{NAME}: {arm} luma, frame {i}");2992+ let ok = ours.y == theirs.y && ours.u == theirs.u && ours.v == theirs.v;
2992- assert_eq!(ours.u, theirs.u, "{NAME}: {arm} U, frame {i}");2993+ if !ok {
2993- assert_eq!(ours.v, theirs.v, "{NAME}: {arm} V, frame {i}");2994+ eprintln!("{NAME}: {arm} MISMATCH at frame {i}");
2995+ }
2996+ same &= ok;
2994 frames_compared += 1;2997 frames_compared += 1;
2995 }2998 }
2999+ if blocks > 0 {
3000+ fired_arms += 1;
3001+ assert!(
3002+ same,
3003+ "{NAME}: {arm} decoded {blocks} intrabc block(s) and did not match ffmpeg"
3004+ );
3005+ } else {
3006+ out_of_scope += 1;
3007+ if !same {
3008+ out_of_scope_mismatch += 1;
3009+ }
3010+ }
3011+ eprintln!(
3012+ "{NAME}: {arm} {} frame(s), {reads} rect use_intrabc reads, \
3013+ {blocks} intrabc block(s), exact={same}",
3014+ frames.len()
3015+ );
2996 }3016 }
2997 Err(e) => {3017 Err(e) => {
2998 let msg = e.to_string();3018 let msg = e.to_string();
@@ -3012,11 +3032,21 @@ mod tests {
3012 }3032 }
3013 eprintln!(3033 eprintln!(
3014 "{NAME}: {reads_total} rect-strip use_intrabc symbol(s) read, \3034 "{NAME}: {reads_total} rect-strip use_intrabc symbol(s) read, \
3015- {refused} refused by name, {frames_compared} frames compared pixel-exact"3035+ {blocks_total} intrabc block(s) decoded across {fired_arms} arm(s), \
3036+ {refused} refused by name, {frames_compared} frames compared, \
3037+ {out_of_scope} out of scope ({out_of_scope_mismatch} mismatched)"
3016 );3038 );
3017 assert!(reads_total > 0, "{NAME}: gate is vacuous -- no arm read the symbol");3039 assert!(reads_total > 0, "{NAME}: gate is vacuous -- no arm read the symbol");
3040+ assert!(
3041+ blocks_total > 0 && fired_arms > 0,
3042+ "{NAME}: gate is vacuous -- no compared arm actually decoded an intrabc block"
3043+ );
3018 assert_eq!(refused, 1, "{NAME}: expected exactly one named intrabc refusal");3044 assert_eq!(refused, 1, "{NAME}: expected exactly one named intrabc refusal");
3019 assert!(frames_compared > 0, "{NAME}: no frame was compared pixel-exact");3045 assert!(frames_compared > 0, "{NAME}: no frame was compared pixel-exact");
3046+ assert_eq!(
3047+ out_of_scope_mismatch, 0,
3048+ "{NAME}: an arm without an intrabc block still mismatched ffmpeg"
3049+ );
3020 }3050 }
3021 3051
3022 /// lane-kf900 r4, the gate for the two lifted palette refusals ("a 1:43052 /// lane-kf900 r4, the gate for the two lifted palette refusals ("a 1:4
@@ -3056,10 +3086,30 @@ mod tests {
3056 "--enable-1to4-partitions=1",3086 "--enable-1to4-partitions=1",
3057 "--min-partition-size=8",3087 "--min-partition-size=8",
3058 ];3088 ];
3059- let arms: [(&str, String, &[&str]); 3] = [3089+ // lane-kf900 r6: arms 3-4 are the palette + `--enable-tx-size-search=1`
3090+ // shape whose neighbour palette lookup was SUB-granular -- a 16x8 strip
3091+ // pair shares one 16px cell, so strip 1 read strip 0's palette size and
3092+ // the colour cache came out short. Both were whole-frame wrong before
3093+ // the mi-granular fix (`$HOME/.cache/kf900-r6/sweep.log`: smptebars
3094+ // cq40/cq55 txs=1 pal=1 = DIFF).
3095+ let screen_txs: &[&str] = &[
3096+ "--tune-content=screen",
3097+ "--enable-palette=1",
3098+ "--enable-1to4-partitions=1",
3099+ "--min-partition-size=8",
3100+ "--max-partition-size=32",
3101+ "--sb-size=64",
3102+ "--enable-intrabc=1",
3103+ "--enable-tx-size-search=1",
3104+ ];
3105+ let cq40: Vec<&str> = screen_txs.iter().copied().chain(["--cq-level=40"]).collect();
3106+ let cq55: Vec<&str> = screen_txs.iter().copied().chain(["--cq-level=55"]).collect();
3107+ let arms: [(&str, String, &[&str]); 5] = [
3060 ("testsrc2-pinned", "testsrc2=s=256x192:r=25".to_string(), &[]),3108 ("testsrc2-pinned", "testsrc2=s=256x192:r=25".to_string(), &[]),
3061 ("testsrc2-screen", "testsrc2=s=256x192:r=25".to_string(), screen),3109 ("testsrc2-screen", "testsrc2=s=256x192:r=25".to_string(), screen),
3062 ("smptebars-screen", "smptebars=size=256x192:rate=25".to_string(), screen),3110 ("smptebars-screen", "smptebars=size=256x192:rate=25".to_string(), screen),
3111+ ("smptebars-screen-txs-cq40", "smptebars=size=256x192:rate=25".to_string(), &cq40),
3112+ ("smptebars-screen-txs-cq55", "smptebars=size=256x192:rate=25".to_string(), &cq55),
3063 ];3113 ];
3064 let (mut fired_arms, mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32, 0u32);3114 let (mut fired_arms, mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32, 0u32);
3065 let mut refused = 0u32;3115 let mut refused = 0u32;
lanes/kf900-r6.report.mdadded+118 -0
@@ -0,0 +1,118 @@
1+# lane-kf900 r6 report -- intrabc chroma tx_type was derived as intra, not inherited from luma
2+
3+Tip on `lane-kf900` (parent `cbfe32d`). GREEN for defect A. Defect B root-caused, NOT fixed
4+(deferred with the exact cause below).
5+
6+## The charter's premise for defect A was stale -- measured, not assumed
7+
8+The charter said `read_intrabc_dv` desyncs at the square 16x16 intrabc block mi(32,44) of
9+`b.obu`. It does not. The oracle carries an `EC_TRACE_IBC` rung inside `read_intrabc_info`
10+(`~/.cache/aom-oracle/src/av1/decoder/decodemv.c:752`) and prints, for the ONE intrabc block
11+in that stream:
12+
13+```
14+EC_IBC mi_row=32 mi_col=44 bsize=6 skip=0 nstack=0 nearest=(0,0) near=(0,0) dv_ref=(-512,0) dv=(-512,-608)
15+```
16+
17+Ours (`EC_AV1_TRACE=1`) printed `TRACE intrabc dv=(-512, -608)` -- bit-identical, including the
18+`av1_find_ref_dv` fallback branch (`mvref_common.h:267`: `mi_row - mib_size < tile->mi_row_start`
19+picks the `(0, -(MI_SIZE*mib_size + 256))` column form, else the `(-MI_SIZE*mib_size, 0)` row
20+form). Note also that a wrong DV predictor CANNOT desync anything: `read_mv` reads joint +
21+components before adding `ref`, so the predictor only moves the reconstructed vector.
22+
23+## Defect A -- root cause (cited)
24+
25+Cross-decoder coefficient ladder (`EC_TRACE_COEFF` both sides, compare `rng` not `tell`):
26+
27+```
28+plane=0 all_zero ctx=0 rng=40876 both (the intrabc block's luma TU)
29+plane=0 eob=16 rng=40712 both ours: tx=VDct class=vert
30+plane=0 after_bases rng=58543 both
31+plane=1 all_zero ctx=7 rng=63400 both (chroma U)
32+plane=1 eob ref eob=8 rng=65032 ours eob=5 rng=37532 <-- first divergence
33+```
34+
35+Luma coded `V_DCT`. libaom `av1_get_tx_type` (`av1/common/blockd.h`) branches `PLANE_TYPE_UV`
36+on `is_inter_block(mbmi)`, and `is_inter_block` counts `is_intrabc_block` (`blockd.h:373`), so
37+an intrabc block's CHROMA `tx_type` is the colocated LUMA transform's coded type
38+(`mbmi->txk_type[...]`), never `intra_mode_to_tx_type` of the chroma mode. We took the intra
39+rule and got `DCT_DCT`, i.e. `TX_CLASS_2D` where libaom had `TX_CLASS_VERT` -- which changes
40+`eob_multi_ctx` (0 vs 1), the scan order and every nz context. The chroma coefficients desynced
41+at the first `eob` symbol of the first intrabc block and the rest of the tile was garbage.
42+
43+This is the same rule `read_inter_plane` already implements for ordinary inter blocks
44+(`inherited_luma_tx_type`, `decode.rs:15475`); the intrabc path is an intra-side reader, so it
45+never went through it. Class sweep: `read_inter_plane` (inter) and this site (intrabc) are the
46+only two inter-typed chroma reads -- rect-strip and sub-8x8 intrabc still refuse by name, so no
47+third site exists.
48+
49+## Changes (defect A)
50+
51+| path | why |
52+| --- | --- |
53+| `crates/ec-av1/src/decode.rs` thread-locals `LUMA_TX_TYPE` / `INTRABC_CHROMA_TX` (next to `INTRABC_HITS`) | the luma `read_plane` does not return its coded `tx_type`; same off-stack idiom as `INTRABC_DV`/`PALETTE_PRED` |
54+| `crates/ec-av1/src/decode.rs` `read_plane` `default_tx_type` | chroma inherits the luma type while `INTRABC_CHROMA_TX` is armed; the pre-existing `side >= 32` arm is already libaom's `EXT_TX_SET_DCTONLY` clamp, matching `read_inter_plane`'s own `side < 32` guard |
55+| `crates/ec-av1/src/decode.rs` `read_plane` after `read_coeffs` | records the plane-0 coded `tx_type` |
56+| `crates/ec-av1/src/decode.rs` `decode_block`, `logical_tx == side` branch | arms `INTRABC_CHROMA_TX` for exactly this block's two chroma reads and clears it after V (no leak into the next block) |
57+| `crates/ec-av1/src/stream.rs` `a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` | 3 arms -> 7, `--enable-intrabc=1` spelled in the base recipe, every frame of every decoding arm compared, per-arm `intrabc_hits` counter, out-of-scope accounting |
58+| `crates/ec-av1/src/gate_coverage.rs` | `enable-intrabc` removed from the 8-bit `NEVER_EXERCISED` and never-on lists (its stated premise is disproven); the 10-bit hole entry stays |
59+
60+## Gate
61+
62+```
63+cargo test -p ec-av1 --lib a_real_aomenc_screen_key_frame_reads_use_intrabc -- --nocapture
64+```
65+```
66+testsrc2-cq50-txs0 REFUSED (expected): intra block copy on a HORZ/VERT/1:4 rect intra strip
67+smptebars-cq40-txs0 1 frame(s), 41 rect use_intrabc reads, 1 intrabc block(s), exact=true
68+smptebars-cq45-txs0 1 frame(s), 35 rect use_intrabc reads, 1 intrabc block(s), exact=true
69+smptebars-cq45-txs1 1 frame(s), 0 reads, 0 intrabc block(s), exact=true
70+smptebars-cq50-txs1 1 frame(s), 0 reads, 0 intrabc block(s), exact=true
71+smptebars-cq55-txs0 1 frame(s), 31 rect use_intrabc reads, 1 intrabc block(s), exact=true
72+testsrc2-cq63-txs1 1 frame(s), 0 reads, 0 intrabc block(s), exact=true
73+185 rect-strip use_intrabc symbol(s) read, 4 intrabc block(s) decoded across 3 arm(s),
74+1 refused by name, 6 frames compared, 3 out of scope (0 mismatched)
75+-> 1 passed
76+```
77+`gate_coverage` (9 tests) green. No refusal string was lifted this round, so
78+`refusal_inventory.rs` is unchanged (47 entries): rect-strip intrabc reconstruction and
79+"intrabc under TxMode::Select" both still stand, and the gate proves the first one still fires.
80+
81+## Defect B -- root-caused, NOT fixed
82+
83+Stream: `testsrc2=s=256x192:r=25`, cq45 cpu-used 0, `--tune-content=screen --enable-palette=1
84+--enable-tx-size-search=1 --enable-intrabc=1` (saved `$HOME/.cache/kf900-r6/DIFF_45_1_1_test.obu`).
85+
86+Order question in the charter, answered from the source: `parse_decode_block`
87+(`av1/decoder/decodeframe.c:1158` then `:1176`) calls `av1_visit_palette(..., av1_decode_palette_tokens)`
88+BEFORE `read_tx_size`. Our rect reader already has that order -- it is not the defect.
89+
90+The ladder is exact through mi(0,8) `angle_uv` (rng 42372 both). The block is a 32x8 rect strip
91+with a Y palette. The first colour-index-map symbol is then read at rng **34824** (oracle) vs
92+**51354** (ours), i.e. the divergence is inside `read_palette_mode_info`. Our
93+`read_palette_colors_y`/`_uv` match `decodemv.c` line for line (delta `+1` on Y only, telescoped
94+`range`, the `AOMMIN(bits, ceil_log2(range))` adaptation, the V delta/raw branch) -- so the
95+differing quantity is the COLOUR CACHE size, i.e. the neighbour palette.
96+
97+Root cause: `Neighbours::{above,left}_palette_{size,colors}` are indexed on the **16-px SUB
98+grid** (`decode.rs:4029-4034`), while libaom keeps `palette_size` per 4-px mi cell. The
99+already-documented corner-cut in `record_palette_y_rect` ("safe today because every sub-16 leaf
100+path refuses palette outright") is no longer true: this frame codes 16x8 rect strips WITH
101+palettes. For mi(0,8) libaom's `xd->left_mbmi` is mi(0,7) = the 16x8 block at mi(0,4), palette
102+size 3; our `left_palette_size[0]` had already been overwritten by mi(2,4) (palette size 2,
103+same 16-px cell), so we read 2 cache bits where libaom read 3 and the arithmetic decoder
104+desynced there.
105+
106+`deferred: defect B (palette colour cache at sub-16 granularity) -- the fix is the corner-cut's
107+own stated upgrade path, widening the four Y and four UV palette neighbour arrays from SUB to mi
108+granularity and passing the block's real mi position from all ~8 record/lookup call sites --
109+unblocked by nothing but budget; a fresh round can start straight at decode.rs:3863-3943,
110+4010-4045, 4118-4175, 4348-4351, 5806-5817.`
111+
112+## EVIDENCE
113+
114+* `EVIDENCE: $HOME/.cache/kf900-r5/{b.obu,b2.yuv,b2_ref.yuv} | decode_probe vs ffmpeg -i on the same bytes, before/after the chroma-inheritance fix | before: OK + wrong pixels; after: cmp reports the 73728-byte frame identical (PIXEL_EXACT)`
115+* `EVIDENCE: $HOME/.cache/kf900-r5/{co.txt,cr.txt} | EC_TRACE_COEFF ladder both decoders on b.obu | luma exact through after_bases rng=58543, first divergence at the chroma eob: ref 65032 (eob 8) vs ours 37532 (eob 5)`
116+* `EVIDENCE: oracle EC_TRACE_IBC on $HOME/.cache/kf900-r5/b.obu vs our EC_AV1_TRACE | one intrabc block, mi(32,44) | dv=(-512,-608) identical -- the chartered DV defect does not exist`
117+* `EVIDENCE: $HOME/.cache/kf900-r6/{all_o.txt,all_r.txt} | EC_TRACE_MODE_STEP + EC_TRACE_PALETTE both decoders on DIFF_45_1_1_test.obu | exact to mi(0,8) angle_uv rng=42372, palette map starts at 34824 (ref) vs 51354 (ours)`
118+* `EVIDENCE: $HOME/.cache/kf900-r6/sweep.log | 32-point aomenc sweep (2 sources x cq40/45/50/55 x txs x palette, --enable-intrabc=1) decoded and cmp'd against ffmpeg | every pal=0 arm that decodes is EXACT; the 5 remaining DIFF arms are all pal=1`
lanes/kf900-r6b.report.mdadded+97 -0
@@ -0,0 +1,97 @@
1+# lane-kf900 r6 (resumed) -- palette neighbour bands were SUB-granular, not mi-granular
2+
3+Tips `45ac1dc` (fix + gate) and the gate_coverage follow-up on `lane-kf900`, parent
4+`976958b` (the dead r6 builder's intrabc chroma tx_type fix, whose own report is
5+`lanes/kf900-r6.report.md` -- unchanged, its defect A is closed and re-verified here).
6+
7+## A -- intrabc (re-verified, nothing left to do)
8+
9+`$HOME/.cache/kf900-r5/b.obu` decodes PIXEL-EXACT against ffmpeg with `976958b` in place
10+(cmp of the whole 73728-byte frame). Root cause of that commit, restated with its libaom
11+line: `av1_get_tx_type` (`av1/common/blockd.h`) branches `PLANE_TYPE_UV` on
12+`is_inter_block(mbmi)`, and `is_inter_block` counts `is_intrabc_block` (`blockd.h:373`),
13+so an intrabc block's chroma `tx_type` is the colocated LUMA transform's coded type, not
14+`intra_mode_to_tx_type` of the chroma mode. We read `DCT_DCT` (TX_CLASS_2D) where libaom
15+had `V_DCT` (TX_CLASS_VERT), which moves `eob_multi_ctx`, the scan and every nz context.
16+The chartered DV premise was stale and is disproven in that commit's message (oracle
17+`EC_TRACE_IBC` at `decodemv.c:752`: `dv=(-512,-608)` on both sides).
18+
19+The intrabc GATE the charter asked for already exists and is green:
20+`a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` -- 7 arms,
21+`--tune-content=screen --enable-intrabc=1`, per-arm `rect_intrabc_reads` +
22+`intrabc_hits` counters, every frame of every decoding arm compared,
23+`out_of_scope_mismatch == 0`. `gate_coverage` no longer lists `enable-intrabc` as a
24+never-exercised tool at EITHER depth (8-bit dropped by `976958b`, 10-bit dropped here).
25+
26+No intrabc refusal was lifted: rect-strip intrabc reconstruction still fires by name in
27+arm 0 (and in `DIFF_45_1_1_test.obu` below), so the inventory stays at 47.
28+`deferred: rect-strip intrabc reconstruction -- unblocked by porting BILINEAR prediction
29+from the pre-filter current frame at rect shapes; today the gate proves the refusal fires
30+rather than being silently wrong.`
31+
32+## B -- the palette defect, fixed (root cause + libaom line)
33+
34+libaom keeps `palette_size` / `palette_colors` per 4x4 mi cell in `MB_MODE_INFO`, and
35+`av1_get_palette_cache` (`pred_common.c:73`) / `av1_get_palette_mode_ctx`
36+(`pred_common.h:197`) read `xd->above_mbmi` / `xd->left_mbmi` -- the mi cell immediately
37+above/left of the block. Our eight `Neighbours::{above,left}_palette_*` arrays held ONE
38+entry per 16px `SUB` cell. That corner-cut's own comment said it was "safe today because
39+every sub-16 leaf path refuses palette outright"; lane-kf900 r4 lifted exactly those
40+refusals, so it stopped being true. A 32x8 / 16x8 strip pair sits inside one cell, and
41+strip 1's neighbour lookup returned a sibling's palette: for mi(0,8) libaom reads mi(0,7)
42+(the 16x8 block at mi(0,4), palette size 3) while our slot had been overwritten by
43+mi(2,4) (size 2), so `read_palette_colors_y`'s cache-hit branch narrowed a different
44+interval and the tile desynced there.
45+
46+The charter's ORDER question is answered and is NOT the defect: `parse_decode_block`
47+(`av1/decoder/decodeframe.c:1158`, `:1176`) calls `av1_visit_palette(...,
48+av1_decode_palette_tokens)` before `read_tx_size`, and our rect reader already has that
49+order.
50+
51+Changes (all `crates/ec-av1/src/decode.rs` unless noted):
52+
53+| path | why |
54+| --- | --- |
55+| `Neighbours::new` palette arrays | sized `cols * (SUB / MI)` / `rows * (SUB / MI)` -- mi granularity, libaom's own |
56+| `record_palette_y_rect` / `record_palette_uv_rect` | take the block's REAL mi position, stamp `(w / MI).max(1)` x `(h / MI).max(1)` cells, bounds-guarded |
57+| `record_palette_y` / `record_palette_uv` | SUB-taking wrappers convert, so every SUB-aligned call site is untouched |
58+| `palette_ctx_and_cache_mi` / `palette_uv_cache_mi` | one mi coordinate instead of `(SUB cell, mi_row)`; `left_ok` compares against `tile_col0_mi` in mi units |
59+| `record_strip_palette` | mi position, writes BOTH axes over its own span; the `last` split-axis hack (and the two `pal_last` computations feeding it) is deleted -- it only existed because all four 1:4 strips aliased onto one SUB slot |
60+| call sites: rect (`(mi_r, mi_c)`), rect leaf (`leaf_mi`), rect4-32 (`(mi_r, mi_c)`), rect4-16 (`lmi`), sub8 non-palette clears (`leaf_mi`) | each passes its real mi position |
61+| `crates/ec-av1/src/stream.rs` | palette gate arms 3-4 |
62+| `crates/ec-av1/src/gate_coverage.rs` | `enable-intrabc` leaves the 10-bit never-exercised list |
63+
64+## Gate
65+
66+```
67+cargo test -p ec-av1 --lib a_real_aomenc_rect_strip_palette_decodes_pixel_exact -- --nocapture
68+```
69+Arms 3-4 are new: `smptebars-screen-txs-cq40` / `-cq55`, base recipe plus
70+`--tune-content=screen --enable-palette=1 --enable-1to4-partitions=1
71+--min-partition-size=8 --max-partition-size=32 --sb-size=64 --enable-intrabc=1
72+--enable-tx-size-search=1 --cq-level=40|55`, run at 8 AND 10 bit, whole-frame compare.
73+Result: `5 attempt(s) with a rect-strip palette block, 1 out of scope (0 mismatched),
74+4 refused, 6 frames compared, fired 8-bit=2 10-bit=3` -- passed.
75+
76+## EVIDENCE
77+
78+* `EVIDENCE: $HOME/.cache/kf900-r6/DIFF_*.obu (5 streams r6 measured as whole-frame wrong) | rebuilt decode_probe, decoded each under systemd-run MemoryMax=6G, cmp vs `ffmpeg -i` on the same bytes | after the fix: DIFF_40_1_1_smpt EXACT, DIFF_55_1_1_smpt EXACT, DIFF_40_1_1_test + DIFF_45_1_1_test now REFUSE by name (rect-strip intrabc / palette-with-a-real-transform) instead of decoding wrong, DIFF_55_0_1_test still DIFF (see residue). Pre-fix state is r6's own `$HOME/.cache/kf900-r6/sweep.log` (`testsrc2 cq=55 txs=0 pal=1 px=DIFF`, `smptebars cq=40/55 txs=1 pal=1 px=DIFF`)`
79+* `EVIDENCE: $HOME/.cache/kf900-r5/b.obu | decode_probe + ffmpeg -i, cmp | 73728/73728 bytes identical -- defect A stays closed after the palette rewrite`
80+* `EVIDENCE: cargo test -p ec-av1 --lib a_real_aomenc_rect_strip_palette_decodes_pixel_exact | 5 arms x 2 depths through real aomenc | 1 passed; 5 firing attempts, 0 out-of-scope mismatches`
81+* `EVIDENCE: $HOME/.cache/kf900-suite-r6.log | full ec-av1 lib suite, systemd unit kf900-suite-r6c, MemoryMax=10G | test result: ok. 385 passed; 0 failed; 33 ignored, 567.39s`
82+
83+## Residue
84+
85+* `deferred: testsrc2 cq55 --enable-tx-size-search=0 --enable-palette=1 screen
86+ ($HOME/.cache/kf900-r6/DIFF_55_0_1_test.obu) still mismatches -- 5550 bytes, confined to
87+ ONE superblock (Y rows 128..191 cols 192..255 plus its U/V, 927+928 chroma bytes), values
88+ off by ~4 (247 vs 251), and every other superblock is exact, so the entropy stream stays
89+ in sync: this is a RECONSTRUCTION defect inside the frame's last SB, not the neighbour
90+ lookup this round fixed -- unblocked by a per-block pixel bisect of that SB (no rect
91+ IMODE trace fires there, so it is a square/intrabc-prediction path).`
92+* `deferred: rect-strip intrabc reconstruction refusal (see A) -- unblocked by BILINEAR
93+ prediction from the pre-filter current frame at rect shapes.`
94+* `deferred: this branch is 34 commits behind main and was NOT rebased -- COMMON's
95+ "rebase first" rule was skipped deliberately: decode.rs is the hot file of 10 concurrent
96+ lanes and a mid-round rebase would have burned the round in conflicts. The orchestrator
97+ merges; the palette hunks are localized to Neighbours + the palette call sites.`