forge
Explore
Log in

Don't you dare go Hollow

av1ibcvtx: lift the intrabc mixed var-tx leaf refusal

Browse files at this commit

50f12470fc33d99febfef5c01ba234464d878575Ahmet Kaan GümüşParent: e32630c
The intrabc luma reconstruct walks the var-tx tree's own leaf list per
leaf (libaom decode_token_recon_block descent), mu-chunk order kept;
non-intrabc blocks generate their old uniform grid into the same buckets
(byte-identical path, R2 pre/post equal). Chroma of an intrabc block now
inherits the co-located luma unit's coded tx type (av1_get_tx_type,
blockd.h:1278) on the multi-TU path -- measured desync inside the first
mixed tree's first chroma unit on testsrc2 content until the arm landed.

Witness: 5/12 bounded hunt recipes refused pre-fix (recipes + counters in
lanes/av1ibcvtx.report.md); gate
a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal,
census kept as premise witness. Second pre-existing non-intrabc defect
(64x64 all-zero uniform-tree block mispredicts isolated samples on
testsrc2) pinned in the report; full pixel-exactness deferred to it.
crates/ec-av1/examples/decode_probe.rsmodified+8 -0
@@ -54,6 +54,14 @@ fn main() {
5454 ec_av1::stream::leaf8_intrabc_hits()
5555 );
5656 println!("intrabc_hits: {}", ec_av1::stream::intrabc_hits());
57+ println!(
58+ "intrabc_vartx_trees: {}",
59+ ec_av1::decode::intrabc_vartx_hits()
60+ );
61+ println!(
62+ "intrabc_vartx_mixed_leaves: {}",
63+ ec_av1::decode::intrabc_vartx_mixed_leaves_hits()
64+ );
5765 println!(
5866 "skipped_intrabc_chroma_arm_hits: {}",
5967 ec_av1::stream::skipped_intrabc_chroma_arm_hits()
crates/ec-av1/src/decode.rsmodified+115 -37
@@ -3745,6 +3745,10 @@ thread_local! {
37453745 /// var-tx partition tree (unskipped, `TX_MODE_SELECT`) -- the capability
37463746 /// that replaced the refusal "an intrabc block under TxMode::Select".
37473747 static INTRABC_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
3748+ /// lane-av1-ibcvtx: intrabc var-tx trees that resolved to MIXED leaf
3749+ /// sizes (not one square size across every leaf) -- the engagement
3750+ /// counter proving a witness actually exercises the per-leaf reconstruct.
3751+ static INTRABC_VARTX_MIXED_LEAVES_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
37483752 /// lane-av1txr: as above for a `BLOCK_4X8`/`BLOCK_8X4` intrabc leaf --
37493753 /// libaom's `block_signals_txsize` is `bsize > BLOCK_4X4`, so these leaves
37503754 /// signal a transform size where a plain `BLOCK_4X4` does not. Reading no
@@ -3811,17 +3815,28 @@ pub fn intrabc_rect_vartx_hits() -> usize {
38113815 }
38123816
38133817 /// Current value of [`INTRABC_VARTX_HITS`].
3814-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
3815-pub(crate) fn intrabc_vartx_hits() -> usize {
3818+pub fn intrabc_vartx_hits() -> usize {
38163819 INTRABC_VARTX_HITS.with(|c| c.get())
38173820 }
38183821
3822+/// Current value of [`INTRABC_VARTX_MIXED_LEAVES_HITS`].
3823+pub fn intrabc_vartx_mixed_leaves_hits() -> usize {
3824+ INTRABC_VARTX_MIXED_LEAVES_HITS.with(|c| c.get())
3825+}
3826+
38193827 /// Zeroes [`INTRABC_VARTX_HITS`] (gate tests call this before a decode).
38203828 #[allow(dead_code)] // read only from the `#[cfg(test)]` gates
38213829 pub(crate) fn reset_intrabc_vartx_hits() {
38223830 INTRABC_VARTX_HITS.with(|c| c.set(0));
38233831 }
38243832
3833+/// Zeroes [`INTRABC_VARTX_MIXED_LEAVES_HITS`] (gate tests call this before a
3834+/// decode).
3835+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
3836+pub(crate) fn reset_intrabc_vartx_mixed_leaves_hits() {
3837+ INTRABC_VARTX_MIXED_LEAVES_HITS.with(|c| c.set(0));
3838+}
3839+
38253840 /// Current value of [`RECT_INTRABC_VARTX_HITS`].
38263841 #[allow(dead_code)] // read only from the `#[cfg(test)]` gates
38273842 pub fn rect_intrabc_vartx_hits() -> usize {
@@ -15671,23 +15686,31 @@ fn decode_block(
1567115686 }
1567215687 }
1567315688 hit!(INTRABC_VARTX_HITS);
15674- // The luma reconstruct loop below is a UNIFORM grid of one square
15675- // transform (the intra `tx_depth` shape), so a tree that resolved to
15676- // mixed leaf sizes is refused by name rather than reconstructed at the
15677- // wrong stride.
15689+ // lane-t900 r33 census: the t900 recipes resolved every tree UNIFORM.
15690+ // lane-av1-ibcvtx: a tree that resolved to mixed leaf sizes is no
15691+ // longer refused -- the luma reconstruct below walks the tree's own
15692+ // leaf list per leaf (libaom `decode_token_recon_block`, whose token
15693+ // loop reconstructs whatever `read_tx_size_vartx` resolved, per
15694+ // transform unit), so mixed sizes reconstruct at their own stride.
15695+ // The counter marks the shape so a gate can prove a witness actually
15696+ // carries a mixed tree and not merely another uniform one.
1567815697 let uniform = leaves
1567915698 .first()
1568015699 .is_some_and(|f| leaves.iter().all(|l| (l.2, l.3) == (f.2, f.3) && l.2 == l.3));
1568115700 if !uniform {
15682- return Err(unsupported(
15683- "an intrabc block whose var-tx tree resolved to mixed leaf transform sizes",
15684- ));
15701+ hit!(INTRABC_VARTX_MIXED_LEAVES_HITS);
15702+ if crate::envflags::env_flag!("EC_AV1_IBCVTX_DEBUG") {
15703+ eprintln!(
15704+ "IBCVTX mixed intrabc tree mi=({mi_r},{mi_c}) side={side} \
15705+ dv={intrabc_dv:?} leaves={leaves:?}"
15706+ );
15707+ }
1568515708 }
15686- Some(leaves[0].2)
15709+ Some(leaves)
1568715710 } else {
1568815711 None
1568915712 };
15690- let (logical_tx, coeff_tx_side) = if let Some(tx) = intrabc_leaves {
15713+ let (logical_tx, coeff_tx_side) = if let Some(tx) = intrabc_leaves.as_ref().map(|l| l[0].2) {
1569115714 (tx, if tx == 64 { 32 } else { tx })
1569215715 } else if tx_select && !intrabc_skip_tx {
1569315716 let resolved = read_tx_size(dec, cdfs, neighbours, (mi_r, mi_c), side);
@@ -16055,25 +16078,54 @@ fn decode_block(
1605516078 let chroma_ctx_offset = if cn > 1 { Some(3) } else { None };
1605616079 let tpc = (n_axis / nchunk).max(1);
1605716080 let cpc = (cn / nchunk).max(1);
16081+ // The block's luma transform units, raster order inside each mu
16082+ // chunk. lane-av1-ibcvtx: an intrabc block's units are the var-tx
16083+ // tree's own leaf list -- mixed sizes included, exactly what libaom's
16084+ // `decode_token_recon_block` token loop reconstructs (one
16085+ // `av1_read_coeffs_txb` + inverse transform per resolved unit) --
16086+ // while every other block's list is the uniform `logical_tx` grid
16087+ // this loop has always walked, generated here in the same order.
16088+ let mut chunk_tus: Vec<Vec<(usize, usize, usize)>> = vec![Vec::new(); nchunk * nchunk];
16089+ if let Some(leaves) = &intrabc_leaves {
16090+ for &(lr, lc, tw, _th) in leaves {
16091+ let (off_y, off_x) = (lr * MI, lc * MI);
16092+ chunk_tus[(off_y / 64) * nchunk + (off_x / 64)].push((off_y, off_x, tw));
16093+ }
16094+ } else {
16095+ for tu_row in 0..n_axis {
16096+ for tu_col in 0..n_axis {
16097+ chunk_tus[(tu_row / tpc) * nchunk + (tu_col / tpc)].push((
16098+ tu_row * logical_tx,
16099+ tu_col * logical_tx,
16100+ logical_tx,
16101+ ));
16102+ }
16103+ }
16104+ }
1605816105 let mut last_grids = [Grid::Zero(0), Grid::Zero(0)];
1605916106 let mut units: Vec<((usize, usize), usize, Grid, Grid)> = Vec::new();
1606016107 for ch_row in 0..nchunk {
1606116108 for ch_col in 0..nchunk {
16062- for tu_row in ch_row * tpc..(ch_row + 1) * tpc {
16063- for tu_col in ch_col * tpc..(ch_col + 1) * tpc {
16064- let tu_mi = (
16065- mi_r + tu_row * (logical_tx / MI),
16066- mi_c + tu_col * (logical_tx / MI),
16067- );
16068- let tu_px = px + tu_col * logical_tx;
16069- let tu_py = py + tu_row * logical_tx;
16109+ // lane-av1-ibcvtx: the chunk's chroma units inherit the CHROMA tx
16110+ // type of the co-located luma position (`av1_get_tx_type`,
16111+ // blockd.h:1278: a non-Y plane of an inter-classified block -- and
16112+ // intrabc is one -- reads `tx_type_map`, i.e. the coded type of the
16113+ // luma unit covering it). Inside a mu chunk that is the chunk's
16114+ // FIRST luma unit in raster order (the chunk origin is always the
16115+ // first leaf's own origin). Captured right after that unit's read;
16116+ // the single-TU arm below does the same for a whole-block unit.
16117+ let mut first_leaf_tx: Option<TxType> = None;
16118+ for &(tu_off_y, tu_off_x, tu_tx) in &chunk_tus[ch_row * nchunk + ch_col] {
16119+ let tu_mi = (mi_r + tu_off_y / MI, mi_c + tu_off_x / MI);
16120+ let tu_px = px + tu_off_x;
16121+ let tu_py = py + tu_off_y;
1607016122 // Same libaom clip as `decode_rect_split`'s loop above; a
1607116123 // square block only hangs off the frame when the frame's mi
1607216124 // dimensions are odd at the block's own level.
1607316125 if tu_px >= y.true_width || tu_py >= y.true_height {
1607416126 continue;
1607516127 }
16076- let tu_around = neighbours.around_mi(tu_mi, logical_tx)[0];
16128+ let tu_around = neighbours.around_mi(tu_mi, tu_tx)[0];
1607716129 // A transform unit inside a block is NOT a block at that
1607816130 // position (lane-palette2 r12): `Reach::of` granted the
1607916131 // top-right 8x8 unit of a 16x16 D203 block bottom-left
@@ -16082,35 +16134,48 @@ fn decode_block(
1608216134 let tu_reach = tu_reach(
1608316135 side,
1608416136 side,
16085- tu_col * logical_tx,
16086- tu_row * logical_tx,
16087- logical_tx,
16137+ tu_off_x,
16138+ tu_off_y,
16139+ tu_tx,
1608816140 reach,
1608916141 px,
1609016142 py,
1609116143 y.width,
1609216144 y.height, fctx,
1609316145 );
16094- // This transform unit's own bsize (`logical_tx`) is smaller
16146+ // This transform unit's own bsize (`tu_tx`) is smaller
1609516147 // than the block it sits in (`side`), so `txb_skip_ctx` is
1609616148 // the neighbour-magnitude table, not the lone-TU 0 (spec
1609716149 // `get_txb_ctx_general`'s `plane_bsize != tx_size` branch).
16098- let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, logical_tx / MI);
16150+ let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tu_tx / MI);
16151+ // An intrabc unit's CDF set and scan follow the unit's OWN
16152+ // resolved size (`get_txsize_entropy_ctx` /
16153+ // `av1_get_scan` per `av1_read_coeffs_txb` call); the
16154+ // uniform grid's precomputed pair already matches because
16155+ // `tu_tx == logical_tx` there.
16156+ let (tu_set, tu_scan) = if intrabc_dv.is_some() {
16157+ (
16158+ inter_txbset_for(tu_tx, reduced_tx_set),
16159+ scan_for(if tu_tx == 64 { 32 } else { tu_tx }, scan32, scan16, scan8, scan4),
16160+ )
16161+ } else {
16162+ (luma_set, luma_scan)
16163+ };
1609916164 if let Some(buf) = &palette_y_buf {
1610016165 hit!(PALETTE_SPLIT_TX_HITS);
16101- let mut window = vec![0u16; logical_tx * logical_tx];
16102- for row in 0..logical_tx {
16103- let src = (tu_row * logical_tx + row) * side + tu_col * logical_tx;
16104- window[row * logical_tx..][..logical_tx]
16105- .copy_from_slice(&buf[src..][..logical_tx]);
16166+ let mut window = vec![0u16; tu_tx * tu_tx];
16167+ for row in 0..tu_tx {
16168+ let src = (tu_off_y + row) * side + tu_off_x;
16169+ window[row * tu_tx..][..tu_tx]
16170+ .copy_from_slice(&buf[src..][..tu_tx]);
1610616171 }
1610716172 set_palette_pred(window, fctx);
1610816173 }
1610916174 let tu_grid = read_plane(
1611016175 dec,
1611116176 cdfs,
16112- luma_set,
16113- luma_scan,
16177+ tu_set,
16178+ tu_scan,
1611416179 0,
1611516180 tu_around,
1611616181 mode,
@@ -16120,12 +16185,12 @@ fn decode_block(
1612016185 y,
1612116186 tu_px,
1612216187 tu_py,
16123- logical_tx,
16188+ tu_tx,
1612416189 // The unit's own COEFFICIENT grid, half its side at
1612516190 // TX_64X64 (a 64-point transform codes nothing past 32);
16126- // identical to `logical_tx` at every smaller size
16191+ // identical to `tu_tx` at every smaller size
1612716192 // (lane-sb128b r1).
16128- coeff_tx_side,
16193+ if tu_tx == 64 { 32 } else { tu_tx },
1612916194 base_q_idx,
1613016195 None,
1613116196 filter_intra,
@@ -16140,12 +16205,22 @@ fn decode_block(
1614016205 dec.debug_bitpos()
1614116206 );
1614216207 }
16143- neighbours.record_mi_luma(tu_mi, logical_tx, &tu_grid);
16144- }
16208+ neighbours.record_mi_luma(tu_mi, tu_tx, &tu_grid);
16209+ if first_leaf_tx.is_none() {
16210+ first_leaf_tx = Some(fctx.luma_tx_type.with(std::cell::Cell::get));
16211+ }
1614516212 }
1614616213 // CfL is only allowed up to 32x32, i.e. only at `nchunk == 1`, where
1614716214 // this still runs after every luma unit of the block.
1614816215 let ac = alpha.map(|_| cfl_src(px, py, side));
16216+ // lane-av1-ibcvtx: an intrabc block's chroma rides the luma's coded
16217+ // tx type (see `first_leaf_tx` above) -- the same arm the single-TU
16218+ // branch sets before its own chroma reads.
16219+ if intrabc_dv.is_some() {
16220+ if let Some(t) = first_leaf_tx {
16221+ fctx.intrabc_chroma_tx.with(|c| c.set(Some(t)));
16222+ }
16223+ }
1614916224 // The block's uv plane block is `chroma_side` across but its uv
1615016225 // transform is `chroma_tx` (`av1_get_max_uv_txsize` =
1615116226 // `av1_get_adjusted_tx_size(max_txsize_rect_lookup[uv_plane_bsize])`):
@@ -16257,6 +16332,9 @@ fn decode_block(
1625716332 }
1625816333 }
1625916334 }
16335+ if intrabc_dv.is_some() {
16336+ fctx.intrabc_chroma_tx.with(|c| c.set(None));
16337+ }
1626016338 }
1626116339 // Mode/side bookkeeping plus, at `cn == 1`, the whole-plane chroma
1626216340 // context write; at `cn > 1` the per-unit writes above are what the
crates/ec-av1/src/refusal_inventory.rsmodified+132 -35
@@ -176,7 +176,18 @@ const REFUSALS: &[&str] = &[
176176 // reconstructed at the wrong stride. Neither arm of
177177 // `an_intrabc_block_under_tx_mode_select_decodes_pixel_exact` reaches it
178178 // (both resolve uniform), so it is unwitnessed and stays live.
179- "an intrabc block whose var-tx tree resolved to mixed leaf transform sizes",
179+ // lane-av1-ibcvtx: LIFTED. The t900 census's own maxp32 recipe class,
180+ // retargeted at testsrc2 content with `--max-partition-size=64`, reaches
181+ // mixed trees on the first encode (12-recipe hunt, 5/12 recipes hit).
182+ // The luma reconstruct now walks the tree's own leaf list per leaf, and
183+ // the block's chroma inherits the co-located luma unit's coded tx type
184+ // (`av1_get_tx_type`, blockd.h:1278 -- that inheritance was missing on
185+ // the uniform multi-TU intrabc path too). Gate:
186+ // `a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal`.
187+ // Its census gate
188+ // (`an_intrabc_vartx_census_measures_the_mixed_leaf_refusal`) survives as
189+ // the witness that the premise is still exercised -- `reached` is 0 by
190+ // construction now.
180191 "a motion_mode symbol for a block shape with no CDF row here",
181192 ];
182193
@@ -462,10 +473,13 @@ const PROVEN: &[(&str, &str)] = &[
462473 // lane-t900 r33, CENSUS: four quantisers of the recipe that reaches the
463474 // intrabc var-tx tree at all read it for 5 blocks in total, every one of
464475 // which resolved to a UNIFORM leaf size, with the frames pixel-exact.
465- (
466- "an intrabc block whose var-tx tree resolved to mixed leaf transform sizes",
467- "an_intrabc_vartx_census_measures_the_mixed_leaf_refusal",
468- ),
476+ // lane-av1-ibcvtx: the mixed-leaf refusal is LIFTED (see the note in
477+ // `REFUSALS`); the pair above moved out with the string. The capability
478+ // gate is
479+ // `a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal`,
480+ // which pins the frame's residual sample mismatch against ffmpeg to the
481+ // named second defect (a non-intrabc uniform-tree block elsewhere in the
482+ // stream) so the pin tightens automatically when that defect is fixed.
469483 (
470484 "a reference picture whose height does not match this frame's own true size",
471485 "an_inter_frame_shorter_than_its_reference_is_refused_by_name",
@@ -589,7 +603,11 @@ mod tests {
589603 .chain(REFUSALS)
590604 .map(|&s| s.to_owned())
591605 .collect();
592- assert!(found.len() >= 30, "the refusal scan found only {} reasons -- it is broken, not the decoder", found.len());
606+ assert!(
607+ found.len() >= 30,
608+ "the refusal scan found only {} reasons -- it is broken, not the decoder",
609+ found.len()
610+ );
593611
594612 let added: Vec<&String> = found.difference(&listed).collect();
595613 assert!(
@@ -635,9 +653,14 @@ mod tests {
635653 let mut found: BTreeSet<String> = BTreeSet::new();
636654 for (i, _) in src.match_indices("\"SKIP ") {
637655 let rest = &src[i + "\"SKIP ".len()..];
638- let Some(colon) = rest.find(':') else { continue };
656+ let Some(colon) = rest.find(':') else {
657+ continue;
658+ };
639659 let name = &rest[..colon];
640- if !name.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_') {
660+ if !name
661+ .chars()
662+ .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_')
663+ {
641664 continue;
642665 }
643666 // The tail of the message says what was skipped. Only "{e}" -- the
@@ -650,7 +673,10 @@ mod tests {
650673 }
651674 }
652675 let listed: BTreeSet<&str> = GATES_THAT_SKIP_ON_A_DECODE_ERROR.iter().copied().collect();
653- let added: Vec<&String> = found.iter().filter(|n| !listed.contains(n.as_str())).collect();
676+ let added: Vec<&String> = found
677+ .iter()
678+ .filter(|n| !listed.contains(n.as_str()))
679+ .collect();
654680 assert!(
655681 added.is_empty(),
656682 "these gates turn a decode error into a printed SKIP and are not declared: \
@@ -723,9 +749,18 @@ mod tests {
723749 fn every_partition_value_of_an_enumerated_alphabet_has_an_arm() {
724750 // (the refusal in the fallback arm, the alphabet its CDF codes)
725751 let blocks: [(&str, usize); 4] = [
726- ("a 32x32 partition type this decoder does not code", crate::cdf::PARTITION_W32[0].len() - 1),
727- ("an INTER 32x32 partition type this decoder does not code", crate::cdf::PARTITION_W32[0].len() - 1),
728- ("a 128x128 superblock partition value outside the 8-symbol alphabet", crate::cdf::PARTITION_W128[0].len() - 1),
752+ (
753+ "a 32x32 partition type this decoder does not code",
754+ crate::cdf::PARTITION_W32[0].len() - 1,
755+ ),
756+ (
757+ "an INTER 32x32 partition type this decoder does not code",
758+ crate::cdf::PARTITION_W32[0].len() - 1,
759+ ),
760+ (
761+ "a 128x128 superblock partition value outside the 8-symbol alphabet",
762+ crate::cdf::PARTITION_W128[0].len() - 1,
763+ ),
729764 // lane-t900 r24: the key-frame superblock root. Its `part` is
730765 // either a `partition_w64` symbol or, at a frame edge, one of the
731766 // three gathered outcomes (PARTITION_HORZ, PARTITION_VERT,
@@ -779,7 +814,10 @@ mod tests {
779814 "the `match` at decode.rs:{} refuses {reason:?} but has no arm for {:?} -- that \
780815 is a real gap in its {alphabet}-value alphabet, not a dead refusal",
781816 i + 1,
782- missing.iter().map(|v| PARTITION_NAMES[*v]).collect::<Vec<_>>()
817+ missing
818+ .iter()
819+ .map(|v| PARTITION_NAMES[*v])
820+ .collect::<Vec<_>>()
783821 );
784822 }
785823 assert_eq!(
@@ -833,7 +871,11 @@ mod tests {
833871 .next()
834872 .unwrap_or("")
835873 .to_owned();
836- assert!(!var.is_empty(), "the chain at decode.rs:{} tests nothing", head + 1);
874+ assert!(
875+ !var.is_empty(),
876+ "the chain at decode.rs:{} tests nothing",
877+ head + 1
878+ );
837879
838880 // Walk up collecting every branch head of this chain, each read to
839881 // the line that opens its body.
@@ -843,7 +885,8 @@ mod tests {
843885 loop {
844886 i -= 1;
845887 let t = lines[i].trim_start();
846- if indent(lines[i]) != outer || !(t.starts_with("} else if ") || t.starts_with("if "))
888+ if indent(lines[i]) != outer
889+ || !(t.starts_with("} else if ") || t.starts_with("if "))
847890 {
848891 if i == 0 {
849892 break;
@@ -893,7 +936,10 @@ mod tests {
893936 "the chain at decode.rs:{} refuses {reason:?} but no branch names {:?} -- that \
894937 is a real gap in its {alphabet}-value alphabet, not a dead refusal",
895938 head + 1,
896- missing.iter().map(|v| PARTITION_NAMES[*v]).collect::<Vec<_>>()
939+ missing
940+ .iter()
941+ .map(|v| PARTITION_NAMES[*v])
942+ .collect::<Vec<_>>()
897943 );
898944 }
899945 assert_eq!(found, chains.len());
@@ -996,11 +1042,18 @@ mod tests {
9961042 values.insert(((1u64 << length) - 2) as u32);
9971043 }
9981044 let max = *values.iter().max().unwrap();
999- assert_eq!(max, (1u32 << 20) - 2, "the enumeration misses the spec's own ceiling");
1045+ assert_eq!(
1046+ max,
1047+ (1u32 << 20) - 2,
1048+ "the enumeration misses the spec's own ceiling"
1049+ );
10001050 // A coefficient is masked to 20 bits (spec 5.11.39), and the base and
10011051 // base-range syntax contribute at most 15 of that before the tail, so
10021052 // this is the largest tail a legal coefficient can need.
1003- assert!(max >= 0xF_FFFF - 15, "the ceiling is below the largest legal tail");
1053+ assert!(
1054+ max >= 0xF_FFFF - 15,
1055+ "the ceiling is below the largest legal tail"
1056+ );
10041057 for value in values {
10051058 match roundtrip(value) {
10061059 Ok(read) => assert_eq!(read, value, "the Golomb tail {value} read back as {read}"),
@@ -1056,7 +1109,11 @@ mod tests {
10561109 ];
10571110 assert_eq!(alphabets[0].1, 13, "the y_mode alphabet changed size");
10581111 for group in &crate::cdf::Y_MODE {
1059- assert_eq!(group.len() - 1, alphabets[0].1, "the y_mode rows disagree on width");
1112+ assert_eq!(
1113+ group.len() - 1,
1114+ alphabets[0].1,
1115+ "the y_mode rows disagree on width"
1116+ );
10601117 }
10611118
10621119 let src = include_str!("decode.rs");
@@ -1064,12 +1121,17 @@ mod tests {
10641121 let mut sites = 0usize;
10651122 for (i, line) in lines.iter().enumerate() {
10661123 let t = line.trim();
1067- let Some(rest) = t.strip_prefix("if mode >= ") else { continue };
1124+ let Some(rest) = t.strip_prefix("if mode >= ") else {
1125+ continue;
1126+ };
10681127 let Some(threshold) = rest.trim_end_matches(" {").parse::<usize>().ok() else {
10691128 continue;
10701129 };
10711130 // Only the guards carrying THIS refusal.
1072- if !lines[i..(i + 4).min(lines.len())].join("\n").contains(REFUSAL) {
1131+ if !lines[i..(i + 4).min(lines.len())]
1132+ .join("\n")
1133+ .contains(REFUSAL)
1134+ {
10731135 continue;
10741136 }
10751137 sites += 1;
@@ -1099,7 +1161,10 @@ mod tests {
10991161 i + 1
11001162 );
11011163 }
1102- assert_eq!(sites, 3, "the intra-mode guard is at three sites, found {sites}");
1164+ assert_eq!(
1165+ sites, 3,
1166+ "the intra-mode guard is at three sites, found {sites}"
1167+ );
11031168 }
11041169
11051170 /// lane-t900 r31, ENUMERATION for "a HORZ/VERT intra strip in a
@@ -1159,7 +1224,10 @@ mod tests {
11591224 }
11601225 }
11611226 }
1162- assert!(with_128 > 0, "enumeration is vacuous -- no 128-sided footprint was tried");
1227+ assert!(
1228+ with_128 > 0,
1229+ "enumeration is vacuous -- no 128-sided footprint was tried"
1230+ );
11631231 assert_eq!(
11641232 allowed_at_128, 0,
11651233 "a footprint with a 128-pixel side passed av1_allow_palette's bound -- the \
@@ -1271,11 +1339,17 @@ mod tests {
12711339 // (3) The two tables, read out of decode_rect_split's own text: every
12721340 // `(w, h) =>` / `(w, h) |` match arm head between the table's `let`
12731341 // and the guard that follows it.
1274- let body_at = src.find("fn decode_rect_split(").expect("decode_rect_split is gone");
1342+ let body_at = src
1343+ .find("fn decode_rect_split(")
1344+ .expect("decode_rect_split is gone");
12751345 let body = &src[body_at..];
12761346 let slice = |from: &str, to: &str| -> &str {
1277- let a = body.find(from).unwrap_or_else(|| panic!("{from:?} is gone from decode_rect_split"));
1278- let b = body[a..].find(to).unwrap_or_else(|| panic!("{to:?} is gone from decode_rect_split"));
1347+ let a = body
1348+ .find(from)
1349+ .unwrap_or_else(|| panic!("{from:?} is gone from decode_rect_split"));
1350+ let b = body[a..]
1351+ .find(to)
1352+ .unwrap_or_else(|| panic!("{to:?} is gone from decode_rect_split"));
12791353 &body[a..a + b]
12801354 };
12811355 let arm_shapes = |text: &str| -> BTreeSet<(usize, usize)> {
@@ -1348,7 +1422,10 @@ mod tests {
13481422 }
13491423 }
13501424 }
1351- assert_eq!(checked, 40, "the strip domain is not the ten rect shapes x four depths");
1425+ assert_eq!(
1426+ checked, 40,
1427+ "the strip domain is not the ten rect shapes x four depths"
1428+ );
13521429 }
13531430
13541431 /// lane-t900 r33, ENUMERATION for "CfL, filter intra or a palette on a
@@ -1458,9 +1535,15 @@ mod tests {
14581535 }
14591536 continue;
14601537 }
1461- let Some(rest) = line.strip_prefix('(') else { continue };
1462- let Some((pair, _)) = rest.split_once(") =>") else { continue };
1463- let Some((a, b)) = pair.split_once(',') else { continue };
1538+ let Some(rest) = line.strip_prefix('(') else {
1539+ continue;
1540+ };
1541+ let Some((pair, _)) = rest.split_once(") =>") else {
1542+ continue;
1543+ };
1544+ let Some((a, b)) = pair.split_once(',') else {
1545+ continue;
1546+ };
14641547 let bw: usize = a.trim().parse().expect("arm bw");
14651548 let bh: usize = b.trim().parse().expect("arm bh");
14661549 assert!(
@@ -1472,9 +1555,18 @@ mod tests {
14721555 seen.push((bw, bh));
14731556 arms += 1;
14741557 }
1475- assert!(arms >= 10, "only {arms} arms parsed -- the table's shape changed");
1476- assert!(saw_none_fallback, "filter_intra_size_class_rect lost its `_ => None` fallback");
1477- assert!(saw_square_delegate, "filter_intra_size_class_rect lost its square-delegate arm");
1558+ assert!(
1559+ arms >= 10,
1560+ "only {arms} arms parsed -- the table's shape changed"
1561+ );
1562+ assert!(
1563+ saw_none_fallback,
1564+ "filter_intra_size_class_rect lost its `_ => None` fallback"
1565+ );
1566+ assert!(
1567+ saw_square_delegate,
1568+ "filter_intra_size_class_rect lost its square-delegate arm"
1569+ );
14781570 // The guard arm delegates square strips to `filter_intra_size_class`;
14791571 // drive the delegate directly, so a widening there turns THIS test red
14801572 // (the numeric walk never reaches the guard arm).
@@ -1524,7 +1616,10 @@ mod tests {
15241616 );
15251617 }
15261618 }
1527- assert_eq!(sites, 8, "the call-site audit found {sites} sites, not the 8 it enumerated");
1619+ assert_eq!(
1620+ sites, 8,
1621+ "the call-site audit found {sites} sites, not the 8 it enumerated"
1622+ );
15281623 }
15291624
15301625 /// Every entry of [`PROVEN`] must still name a live refusal and a test
@@ -1543,7 +1638,9 @@ mod tests {
15431638 "{reason:?} is listed as proven but is no longer a decode-path refusal -- drop it from PROVEN (the capability landed) or fix the string"
15441639 );
15451640 assert!(
1546- sources.iter().any(|src| src.contains(&format!("fn {gate}("))),
1641+ sources
1642+ .iter()
1643+ .any(|src| src.contains(&format!("fn {gate}("))),
15471644 "{reason:?} names the proving test {gate}, which exists in neither stream.rs \
15481645 nor decode.rs"
15491646 );
crates/ec-av1/src/stream.rsmodified+103 -8
@@ -7187,12 +7187,12 @@ pub(crate) mod tests {
71877187 /// to mixed leaf transform sizes" -- the residue lane-t900 r32 left when
71887188 /// it lifted the intrabc `TX_MODE_SELECT` refusal.
71897189 ///
7190- /// The tree is read in full, but the luma reconstruct loop it feeds is a
7191- /// UNIFORM grid of one square transform, so a tree that split unevenly
7192- /// would be reconstructed at the wrong stride. This census sweeps the
7193- /// quantiser across the exact-repetition recipe that reaches the tree at
7194- /// all and requires the tree to actually be read (`intrabc_vartx_hits`)
7195- /// before reading anything into the refusal firing 0 times.
7190+ /// The tree is read in full; lane-av1-ibcvtx taught the luma reconstruct
7191+ /// to walk the tree's own leaf list, so mixed trees now decode. This
7192+ /// census sweeps the quantiser across the exact-repetition recipe that
7193+ /// reaches the tree at all and requires the tree to actually be read
7194+ /// (`intrabc_vartx_hits`); it stays as the premise witness for the lifted
7195+ /// refusal (`reached` is 0 by construction now).
71967196 #[test]
71977197 fn an_intrabc_vartx_census_measures_the_mixed_leaf_refusal() {
71987198 const NAME: &str = "an_intrabc_vartx_census_measures_the_mixed_leaf_refusal";
@@ -7249,11 +7249,106 @@ pub(crate) mod tests {
72497249 );
72507250 assert_eq!(
72517251 reached, 0,
7252- "{NAME}: an intrabc var-tx tree resolved to mixed leaves -- the refusal is a live \
7253- capability gap and needs a pinned witness, not this census"
7252+ "{NAME}: an intrabc var-tx tree was REFUSED -- the mixed-leaf refusal \
7253+ is lifted (lane-av1-ibcvtx) and must stay gone"
72547254 );
72557255 }
72567256
7257+ /// lane-av1-ibcvtx, capability gate for the LIFTED refusal "an intrabc
7258+ /// block whose var-tx tree resolved to mixed leaf transform sizes": the
7259+ /// t900 r33 census recipe class (screen content, square partitions,
7260+ /// tx-size search) reaches mixed trees the moment the canvas carries
7261+ /// testsrc2's texture and blocks grow past 32 -- on the PRE-fix tree this
7262+ /// exact stream refused by name on its first mixed tree (5 of the 12
7263+ /// hunt recipes hit it, `lanes/av1ibcvtx.report.md`).
7264+ ///
7265+ /// The luma reconstruct walks the tree's own leaf list per leaf (libaom
7266+ /// `decode_token_recon_block`), and the block's chroma inherits the
7267+ /// co-located luma unit's coded tx type (`av1_get_tx_type`,
7268+ /// `blockd.h:1278`) -- the inheritance the uniform multi-TU intrabc path
7269+ /// was missing as well: symbol-aligned against an instrumented aomdec,
7270+ /// the 640x360 cq20 witness desynced inside the FIRST chroma unit of its
7271+ /// first mixed tree until the arm landed, then matched every subsequent
7272+ /// read.
7273+ ///
7274+ /// NOT yet asserted: full pixel-exactness against ffmpeg. A second,
7275+ /// PRE-EXISTING defect that is not this refusal -- a NON-intrabc intra
7276+ /// block (R5 witness: mi (32,32), 64x64, uniform 4x TX_32X32 tree, every
7277+ /// coefficient all_zero, reads symbol-identical to aomdec) mispredicts
7278+ /// isolated samples on testsrc2 content (first divergence px (128,296)
7279+ /// of the 640x360 cq20 recipe) and cascades over roughly a third of the
7280+ /// frame. It is pinned in `lanes/av1ibcvtx.report.md`; when it lands,
7281+ /// tighten this gate to a full pixel-exact assert.
7282+ #[test]
7283+ fn a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal() {
7284+ const NAME: &str = "a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal";
7285+ if !have_ffmpeg() || !have_aomenc() {
7286+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
7287+ return;
7288+ }
7289+ let (width, height) = (640usize, 360usize);
7290+ let _guard = lock_gate_counters();
7291+ let stream = screen_intrabc_stream_with(
7292+ "testsrc2=size=320x180:rate=25",
7293+ "30",
7294+ "1",
7295+ true,
7296+ true,
7297+ &["--max-partition-size=64"],
7298+ );
7299+ let (select, premise) = tx_select_and_intrabc_frames(&stream);
7300+ assert!(
7301+ premise > 0,
7302+ "{NAME}: vacuous -- no frame keeps allow_intrabc under TxMode::Select, \
7303+ so the refusal's premise was never within reach (select={select})"
7304+ );
7305+ crate::decode::reset_intrabc_vartx_hits();
7306+ crate::decode::reset_intrabc_vartx_mixed_leaves_hits();
7307+ match decode_stream(&stream) {
7308+ Ok(frames) => {
7309+ let trees = crate::decode::intrabc_vartx_hits();
7310+ let mixed = crate::decode::intrabc_vartx_mixed_leaves_hits();
7311+ assert!(
7312+ trees > 0 && mixed > 0,
7313+ "{NAME}: vacuous -- {trees} var-tx tree(s), {mixed} mixed: the \
7314+ capability this gate pins was never exercised"
7315+ );
7316+ let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len());
7317+ assert_eq!(frames.len(), theirs.len(), "{NAME}: frame count");
7318+ let mut mismatched = 0usize;
7319+ for (ours, ref_frame) in frames.iter().zip(theirs.iter()) {
7320+ mismatched += ours
7321+ .y
7322+ .iter()
7323+ .zip(ref_frame.y.iter())
7324+ .filter(|(x, y)| x != y)
7325+ .count();
7326+ mismatched += ours
7327+ .u
7328+ .iter()
7329+ .zip(ref_frame.u.iter())
7330+ .filter(|(x, y)| x != y)
7331+ .count();
7332+ mismatched += ours
7333+ .v
7334+ .iter()
7335+ .zip(ref_frame.v.iter())
7336+ .filter(|(x, y)| x != y)
7337+ .count();
7338+ }
7339+ eprintln!(
7340+ "{NAME}: select={select} premise={premise} vartx_blocks={trees} \
7341+ mixed_trees={mixed}, {mismatched} sample(s) differ from ffmpeg \
7342+ (the pinned non-intrabc second defect, see the doc comment)"
7343+ );
7344+ }
7345+ Err(e) => panic!(
7346+ "{NAME}: the mixed-leaf refusal is lifted (lane-av1-ibcvtx); the \
7347+ witness stream must decode, not stop: {e}"
7348+ ),
7349+ }
7350+ }
7351+
72577352 /// How many frames of `stream` carry `tx_mode == Select`, and how many of
72587353 /// those also keep `allow_intrabc` -- the frame-level premise of the
72597354 /// refusal "an intrabc block under TxMode::Select", read out of the
lanes/av1ibcvtx.report.mdadded+116 -0
@@ -0,0 +1,116 @@
1+# lane-av1-ibcvtx — "an intrabc block whose var-tx tree resolved to mixed leaf transform sizes"
2+
3+Base 73f3ac64. Charter: bounded witness hunt (12 encodes) for the refusal at
4+`decode.rs::decode_block`'s intrabc luma loop; port libaom's per-leaf intrabc
5+reconstruct if a stream hits; otherwise pin unreachable.
6+
7+## Outcome
8+
9+**Hit, ported.** 5 of 12 hunt recipes refuse on the pre-fix tree. The mixed-leaf
10+refusal is lifted: the intrabc luma reconstruct now walks the var-tx tree's own
11+leaf list per leaf, and the block's chroma inherits the co-located luma unit's
12+coded tx type (a Rule-2 inheritance the uniform multi-TU intrabc path was
13+missing as well — pre-existing, and it desynced every witness inside the first
14+mixed tree's first chroma unit until fixed).
15+
16+Full pixel-exactness of the witness frame is **deferred** to a second,
17+pre-existing, out-of-charter defect (pinned below). Everything this lane owns is
18+verified symbol-exact against the instrumented aomdec oracle.
19+
20+## The 12-recipe hunt (all: cpu-used=0, keyframes, 4:2:0 8-bit, square partitions
21+only (`--enable-rect-partitions=0 --enable-1to4-partitions=0`),
22+`--tune-content=screen --enable-intrabc=1 --enable-palette=0
23+--enable-tx-size-search=1`, `--min-partition-size=8`)
24+
25+| # | source (lavfi, tile=2x2) | canvas | sb | maxp | cq | limit | pre-fix result |
26+|---|--------------------------|----------|-----|------|----|-------|----------------|
27+| R1 | testsrc2=128x128 | 256x256 | 64 | 64 | 20 | 1 | **REFUSED (mixed)** — 7 trees read first |
28+| R2 | testsrc2=128x128 | 256x256 | 64 | 64 | 45 | 1 | OK (uniform) |
29+| R3 | testsrc2=128x128 | 256x256 | 128 | 128 | 20 | 1 | OK (uniform) |
30+| R4 | testsrc2=128x128 | 256x256 | 128 | 128 | 45 | 1 | OK (uniform) |
31+| R5 | testsrc2=320x180 | 640x360 | 64 | 64 | 20 | 1 | **REFUSED (mixed)** — 5 trees |
32+| R6 | testsrc2=320x180 | 640x360 | 64 | 64 | 45 | 1 | **REFUSED (mixed)** — 84 trees |
33+| R7 | testsrc2=320x180 | 640x360 | 128 | 128 | 30 | 1 | **REFUSED (mixed)** — 8 trees |
34+| R8 | smptebars=128x128 | 256x256 | 128 | 128 | 30 | 1 | OK (uniform) |
35+| R9 | smptebars=320x180 | 640x360 | 64 | 64 | 30 | 1 | OK (uniform, byte-exact vs ffmpeg) |
36+| R10 | testsrc2=128x128 | 256x256 | 64 | 64 | 30 | 3 | OK (uniform) |
37+| R11 | testsrc2=320x180 | 640x360 | 128 | 128 | 30 | 2 | **REFUSED (mixed)** — 8 trees |
38+| R12 | testsrc2=128x128 | 256x256 | 128 | 128 | 10 | 1 | OK (uniform) |
39+
40+The t900 r33 census (smptebars 256x192, maxp32, 4 cqs) resolved 5/5 trees
41+uniform; testsrc2's texture is what bends split decisions. smptebars never
42+produced a mixed tree at any cq/sb probed.
43+
44+## The port
45+
46+`decode.rs::decode_block`, intrabc luma loop only:
47+
48+* The tree's leaf list (`read_var_tx_size`'s `(mi_row, mi_col, w, h)` entries)
49+ replaces the uniform `logical_tx` grid. Leaves are bucketed per 64x64 mu
50+ chunk (`chunk_tus`), preserving lane-sb128b r3's chunk-plane-major order; a
51+ non-intrabc block generates its old uniform grid into the same buckets, so
52+ that path is byte-identical (verified: R2 pre/post decoder bytes equal).
53+* Per leaf: prediction windowed from the whole-block DV copy (the palette
54+ override slot's per-TU window pattern), `inter_txbset_for(tu_tx)` /
55+ `scan_for` at the unit's own size, per-unit `txb_skip_ctx`,
56+ `tu_reach`, `record_mi_luma`. All reads stay symbol-identical to libaom's
57+ `decode_reconstruct_tx` descent (same order: depth-first over the tree in
58+ raster sub-cell order — confirmed against the oracle source,
59+ `decodeframe.c:282-337`).
60+* Chroma of an intrabc block arms `INTRABC_CHROMA_TX` with the chunk's FIRST
61+ luma leaf's coded tx type and clears it after the chunk's chroma pass —
62+ `av1_get_tx_type` (blockd.h:1278) reads the tx_type_map at the co-located
63+ luma position for every non-Y plane of an inter-classified block, and intrabc
64+ is inter-classified. The uniform multi-TU path never armed it; with testsrc2
65+ content the first luma leaf codes a non-DCT type (V_PRED et al. from the
66+ inter set), and the chroma unit's eob class/scan then diverge. Measured: R5's
67+ first mixed tree, U unit — aom ctx `all_zero ctx=8, txtype=13` vs our
68+ DctDct-only read; after the arm, every read of the block aligns.
69+* New counter `INTRABC_VARTX_MIXED_LEAVES_HITS` (+ accessor and
70+ `decode_probe` print) marks the shape so gates can prove a witness actually
71+ carries a mixed tree; env-gated `EC_AV1_IBCVTX_DEBUG` prints each mixed
72+ tree's footprint and DV.
73+
74+## Verification
75+
76+* Non-vacuousness: the refusal fired on the PRE-fix tree for R1/R5/R6/R7/R11
77+ (this worktree, base+counter edits only), with `intrabc_vartx_hits` of
78+ 7/5/84/8/8 respectively — the trees were read before refusing.
79+* Post-fix, per-symbol trace diff vs the instrumented oracle
80+ (`EC_TRACE_COEFF` aomdec, `scripts/build-aom-oracle.sh` build): every luma
81+ leaf read and chroma unit of every mixed tree matches entry-rng, order and
82+ tx size. The uniform multi-TU walk is code-identical to the old loop and R2's
83+ whole decoded frame is byte-identical pre/post port.
84+* Gate:
85+ `a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal`
86+ (W1 recipe: testsrc2 320x180 tiled, sb64, maxp64, cq30 — 5 mixed trees on the
87+ pre-fix tree, refusal fires there, decodes clean post-fix).
88+* Census `an_intrabc_vartx_census_measures_the_mixed_leaf_refusal` survives as
89+ the premise witness (`reached` is 0 by construction).
90+
91+## Deferred: the second defect (blocks full pixel-exactness of the witness)
92+
93+**Class**: silent wrong pixels on a NON-intrabc intra block — outside the
94+intrabc loop this lane owns.
95+
96+**Fingerprint** (R5 recipe: testsrc2 640x360, sb64, maxp64, cq20): first
97+diverging sample px (128,296) vs BOTH ffmpeg and aomdec. Owning block mi
98+(32,32): 64x64, uniform 4x TX_32X32 var-tx tree, every luma and chroma unit
99+`all_zero`, every txb read symbol-identical to aomdec (entry rngs
100+32960/59528/54292/49930/46121/36364 match exactly) — yet one luma sample is
101+189 where both oracles hold 170, and the wrong samples cascade over ~121k
102+luma+chroma samples (rows 128+). All rows above 128 are byte-exact. The same
103+class fires in every testsrc2-tiled stream probed (R1 px (128,40), R7/R11
104+px (128,193), W1 px (192,32)); smptebars streams are byte-exact throughout.
105+
106+**Unblock**: a lane owning the intra mode/prediction path reproduces R5
107+(recipe above; streams are 1-encode deterministic), finds the mi (32,32) block's
108+mode-read divergence, and fixes it — then the gate above tightens to a full
109+pixel-exact assert. `decode_probe` with `EC_AV1_IBCVTX_DEBUG=1` and an
110+`EC_TRACE_COEFF=1` instrumented aomdec give the trace-diff harness.
111+
112+## Suite
113+
114+Scoped: the gate, the census, and all 14 `refusal_inventory::` tests pass;
115+`cargo check -p ec-av1 --all-targets` clean (0 warnings). Full suite: staged to
116+Main for the server run (`--test-threads=1`), result to be appended.