forge
Explore
Log in

Don't you dare go Hollow

An 8x8 intra leaf ignored the use_intrabc it had just read

Browse files at this commit

68ca7c51e4ee92db5c8a6d290cf7daa598b6d35cAhmet Kaan GümüşParent: 9356e69
  • fix
    • an 8x8 intra leaf ignored the use_intrabc it had just read
Show full message
fix(av1): an 8x8 intra leaf ignored the use_intrabc it had just read

decode_leaf8 consumed use_intrabc and its DV through read_intra_mode and
then decoded the block as ordinary intra: it read the luma tx_type off the
7-symbol TX_SET_INTRA_1 row where libaom reads the 16-symbol
EXT_TX_SET_ALL16 (is_inter_block counts is_intrabc_block, blockd.h:373), so
the msac range diverged at the next symbol with no refusal -- invisible in
the r6 residue because the block sat in the frame's LAST superblock.

The leaf now mirrors decode_block: inter ext-tx set, BILINEAR prediction from
the current frame's pre-filter reconstruction at the DV (skip and non-skip),
chroma tx_type inherited from the coded luma type and DISARMED after the V
read (leaving it armed leaked into every later chroma block: 320 chroma
samples, luma exact), an inter-skip tx size under TxMode::Select (unskipped
is refused with decode_block's existing string), and record_intrabc_mi so a
later DV's MV stack sees the leaf.

Gate: a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips arm 8
"testsrc2-cq55-leaf8" (rect and 1:4 partitions off, palette on, tx-size-search
off) with a hard per-arm leaf8_intrabc_hits assert and a gate-wide vacuity
assert; 256x192 8-bit screen stream goes 320 wrong chroma samples + an entropy
desync -> whole frame identical to ffmpeg. Full suite still owed (handoff).
crates/ec-av1/examples/decode_probe.rsmodified+1 -0
@@ -34,6 +34,7 @@ fn main() {
34 let (h, v, c) = ec_av1::stream::rect4_32_counters();34 let (h, v, c) = ec_av1::stream::rect4_32_counters();
35 println!("rect4_32: horz={h} vert={v} coded={c}");35 println!("rect4_32: horz={h} vert={v} coded={c}");
36 println!("rect_intrabc_reads: {}", ec_av1::stream::rect_intrabc_reads());36 println!("rect_intrabc_reads: {}", ec_av1::stream::rect_intrabc_reads());
37+ println!("leaf8_intrabc_hits: {}", ec_av1::stream::leaf8_intrabc_hits());
37 let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();38 let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();
38 println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");39 println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");
39 let leaf = ec_av1::stream::vartx_rect_leaf_hits();40 let leaf = ec_av1::stream::vartx_rect_leaf_hits();
crates/ec-av1/src/decode.rsmodified+102 -3
@@ -1657,6 +1657,22 @@ pub(crate) fn reset_rect_intrabc_reads() {
1657 RECT_INTRABC_READS.with(|c| c.set(0));1657 RECT_INTRABC_READS.with(|c| c.set(0));
1658 }1658 }
1659 1659
1660+thread_local! {
1661+ /// Blocks that USED intrabc at an 8x8 LEAF (`decode_leaf8`) specifically
1662+ /// -- the shape lane-kf900 r7 fixed; [`INTRABC_HITS`] counts every shape.
1663+ static LEAF8_INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1664+}
1665+
1666+/// Current value of [`LEAF8_INTRABC_HITS`].
1667+pub(crate) fn leaf8_intrabc_hits() -> usize {
1668+ LEAF8_INTRABC_HITS.with(|c| c.get())
1669+}
1670+
1671+/// Zeroes [`LEAF8_INTRABC_HITS`] (gate tests call this before a decode).
1672+pub(crate) fn reset_leaf8_intrabc_hits() {
1673+ LEAF8_INTRABC_HITS.with(|c| c.set(0));
1674+}
1675+
1660 /// Current value of [`INTRABC_HITS`].1676 /// Current value of [`INTRABC_HITS`].
1661 pub(crate) fn intrabc_hits() -> usize {1677 pub(crate) fn intrabc_hits() -> usize {
1662 INTRABC_HITS.with(|c| c.get())1678 INTRABC_HITS.with(|c| c.get())
@@ -3591,7 +3607,7 @@ fn read_coeffs(
3591 let t = dec.symbol(tx_type_cdf);3607 let t = dec.symbol(tx_type_cdf);
3592 if std::env::var_os("EC_TRACE_COEFF").is_some() {3608 if std::env::var_os("EC_TRACE_COEFF").is_some() {
3593 let (rng, _) = dec.debug_state();3609 let (rng, _) = dec.debug_state();
3594- eprintln!("EC_COEFF_STEP tag=tx_type rng={rng}");3610+ eprintln!("EC_COEFF_STEP tag=tx_type len={len} rng={rng}");
3595 }3611 }
3596 if std::env::var_os("EC_AV1_EOBPT_CDF").is_some() {3612 if std::env::var_os("EC_AV1_EOBPT_CDF").is_some() {
3597 let (range, value) = dec.debug_state();3613 let (range, value) = dec.debug_state();
@@ -10652,6 +10668,24 @@ fn decode_leaf8(
10652 leaf_mi.0,10668 leaf_mi.0,
10653 leaf_mi.1,10669 leaf_mi.1,
10654 )?;10670 )?;
10671+ // lane-kf900 r7: an 8x8 leaf consumed `use_intrabc` (and its DV) through
10672+ // `read_intra_mode` and then decoded the block as if it were ordinary
10673+ // intra. libaom's `is_inter_block` counts an intrabc block
10674+ // (`blockd.h:373`), so its luma `tx_type` comes off the INTER ext-tx set
10675+ // (`av1_get_ext_tx_set_type(TX_8X8, is_inter=1, 0)` = `EXT_TX_SET_ALL16`,
10676+ // a 16-symbol CDF) while we read the 7-symbol `TX_SET_INTRA_1` row: the
10677+ // same value with a different interval, so the tile desynced at the very
10678+ // next symbol (class `wrong-alphabet-same-value`). Everything below
10679+ // mirrors `decode_block`'s own intrabc handling at 16x16 and up.
10680+ let intrabc_dv = INTRABC_DV.with(|c| c.take());
10681+ if intrabc_dv.is_some() {
10682+ LEAF8_INTRABC_HITS.with(|c| c.set(c.get() + 1));
10683+ }
10684+ if intrabc_dv.is_some() && tx_select && !skip {
10685+ return Err(unsupported(
10686+ "an intrabc block under TxMode::Select (its transform size is coded by the inter var-tx partition tree, which this decoder never reads)",
10687+ ));
10688+ }
10655 let uv_predict_mode = if uv_mode == UV_CFL_PRED {10689 let uv_predict_mode = if uv_mode == UV_CFL_PRED {
10656 DC_PRED10690 DC_PRED
10657 } else {10691 } else {
@@ -10665,7 +10699,11 @@ fn decode_leaf8(
10665 // which splits the leaf's own 8x8 prediction into a 2x2 grid of 4x410699 // which splits the leaf's own 8x8 prediction into a 2x2 grid of 4x4
10666 // transform units, same raster-order per-TU pattern `decode_block`'s10700 // transform units, same raster-order per-TU pattern `decode_block`'s
10667 // multi-TU branch runs).10701 // multi-TU branch runs).
10668- let resolved = if tx_select {10702+ // ... and an intrabc leaf reads no intra `tx_depth` symbol at all: under
10703+ // `TX_MODE_SELECT` a skipped inter block takes the largest transform
10704+ // (`read_tx_size(.., is_inter=1, ..)`), and the unskipped case is refused
10705+ // above.
10706+ let resolved = if tx_select && intrabc_dv.is_none() {
10669 read_tx_size(dec, cdfs, neighbours, leaf_mi, 8, None)10707 read_tx_size(dec, cdfs, neighbours, leaf_mi, 8, None)
10670 } else {10708 } else {
10671 810709 8
@@ -10673,6 +10711,37 @@ fn decode_leaf8(
10673 let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI);10711 let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI);
10674 let reach = Reach::of(8, px, py, y.width, y.height);10712 let reach = Reach::of(8, px, py, y.width, y.height);
10675 let (cpx, cpy) = (px / 2, py / 2);10713 let (cpx, cpy) = (px / 2, py / 2);
10714+ // spec 7.11.3.4 with `use_intrabc`, same as `decode_block`: predict from
10715+ // the CURRENT frame's own pre-loop-filter reconstruction (every loop
10716+ // filter is off whenever `allow_intrabc`, frame.rs:194/210/252/272) at
10717+ // the full-pel block vector, with the BILINEAR kernel libaom forces.
10718+ let intrabc_bufs = intrabc_dv.map(|(dv_row, dv_col)| {
10719+ let mut yb = vec![0u16; 8 * 8];
10720+ mc::predict_with_filter(
10721+ &y.data, y.width, y.true_width, y.true_height,
10722+ mv_to_q4(px, dv_col, true), mv_to_q4(py, dv_row, true),
10723+ 8, 8, mc::InterpFilterKind::Bilinear, &mut yb,
10724+ );
10725+ let mut ub = vec![0u16; 4 * 4];
10726+ mc::predict_with_filter(
10727+ &u.data, u.width, u.true_width, u.true_height,
10728+ mv_to_q4(cpx, dv_col, false), mv_to_q4(cpy, dv_row, false),
10729+ 4, 4, mc::InterpFilterKind::Bilinear, &mut ub,
10730+ );
10731+ let mut vb = vec![0u16; 4 * 4];
10732+ mc::predict_with_filter(
10733+ &v.data, v.width, v.true_width, v.true_height,
10734+ mv_to_q4(cpx, dv_col, false), mv_to_q4(cpy, dv_row, false),
10735+ 4, 4, mc::InterpFilterKind::Bilinear, &mut vb,
10736+ );
10737+ (yb, ub, vb)
10738+ });
10739+ // The per-plane prediction override rides the same [`PALETTE_PRED`] slot
10740+ // `decode_block` uses: set fresh right before each plane's own
10741+ // `reconstruct`/`read_plane` call (the slot is taken, not copied).
10742+ if let Some((yb, _, _)) = &intrabc_bufs {
10743+ set_palette_pred(yb.clone());
10744+ }
10676 let (luma_grid, u_grid, v_grid);10745 let (luma_grid, u_grid, v_grid);
10677 if skip {10746 if skip {
10678 // lane-hgkf r2 (same shape as `decode_block`'s own skip branch): an10747 // lane-hgkf r2 (same shape as `decode_block`'s own skip branch): an
@@ -10729,6 +10798,9 @@ fn decode_leaf8(
10729 );10798 );
10730 }10799 }
10731 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));10800 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));
10801+ if let Some((_, ub, _)) = &intrabc_bufs {
10802+ set_palette_pred(ub.clone());
10803+ }
10732 u.reconstruct(10804 u.reconstruct(
10733 cpx,10805 cpx,
10734 cpy,10806 cpy,
@@ -10741,6 +10813,9 @@ fn decode_leaf8(
10741 None,10813 None,
10742 smooth_neighbor_uv,10814 smooth_neighbor_uv,
10743 );10815 );
10816+ if let Some((_, _, vb)) = &intrabc_bufs {
10817+ set_palette_pred(vb.clone());
10818+ }
10744 v.reconstruct(10819 v.reconstruct(
10745 cpx,10820 cpx,
10746 cpy,10821 cpy,
@@ -10761,7 +10836,9 @@ fn decode_leaf8(
10761 luma_grid = read_plane(10836 luma_grid = read_plane(
10762 dec,10837 dec,
10763 cdfs,10838 cdfs,
10764- if reduced_tx_set {10839+ if intrabc_dv.is_some() {
10840+ txbset_for_inter(8, reduced_tx_set)
10841+ } else if reduced_tx_set {
10765 TxbSet::Luma810842 TxbSet::Luma8
10766 } else {10843 } else {
10767 TxbSet::Luma8Set110844 TxbSet::Luma8Set1
@@ -10784,7 +10861,16 @@ fn decode_leaf8(
10784 None,10861 None,
10785 smooth_neighbor,10862 smooth_neighbor,
10786 )?;10863 )?;
10864+ // `av1_get_tx_type` branches `PLANE_TYPE_UV` on `is_inter_block`, so
10865+ // an intrabc block's chroma tx_type is the colocated LUMA transform's
10866+ // coded type (lane-kf900 r6's own fix, `decode_block`'s line).
10867+ if intrabc_dv.is_some() {
10868+ INTRABC_CHROMA_TX.with(|c| c.set(Some(LUMA_TX_TYPE.with(std::cell::Cell::get))));
10869+ }
10787 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));10870 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));
10871+ if let Some((_, ub, _)) = &intrabc_bufs {
10872+ set_palette_pred(ub.clone());
10873+ }
10788 u_grid = read_plane(10874 u_grid = read_plane(
10789 dec,10875 dec,
10790 cdfs,10876 cdfs,
@@ -10807,6 +10893,9 @@ fn decode_leaf8(
10807 None,10893 None,
10808 smooth_neighbor_uv,10894 smooth_neighbor_uv,
10809 )?;10895 )?;
10896+ if let Some((_, _, vb)) = &intrabc_bufs {
10897+ set_palette_pred(vb.clone());
10898+ }
10810 v_grid = read_plane(10899 v_grid = read_plane(
10811 dec,10900 dec,
10812 cdfs,10901 cdfs,
@@ -10829,6 +10918,11 @@ fn decode_leaf8(
10829 None,10918 None,
10830 smooth_neighbor_uv,10919 smooth_neighbor_uv,
10831 )?;10920 )?;
10921+ // Disarm: `INTRABC_CHROMA_TX` is `Some` across exactly this block's
10922+ // two chroma reads (`decode_block`'s own tail does the same) -- left
10923+ // set, every later chroma block would inherit this luma tx_type,
10924+ // which picks the scan and the inverse transform.
10925+ INTRABC_CHROMA_TX.with(|c| c.set(None));
10832 } else {10926 } else {
10833 // `tx_depth` resolved this leaf's luma to `TX4`: a 2x2 raster-order10927 // `tx_depth` resolved this leaf's luma to `TX4`: a 2x2 raster-order
10834 // grid of 4x4 transform units, each predicted from the leaf's own10928 // grid of 4x4 transform units, each predicted from the leaf's own
@@ -10979,6 +11073,7 @@ fn decode_leaf8(
10979 neighbours.fill_skip_grid(leaf_mi, 2, skip);11073 neighbours.fill_skip_grid(leaf_mi, 2, skip);
10980 neighbours.fill_lf_grid(leaf_mi, 2, 4, 0);11074 neighbours.fill_lf_grid(leaf_mi, 2, 4, 0);
10981 neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode);11075 neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode);
11076+ record_intrabc_mi(leaf_mi.0, leaf_mi.1, 2, intrabc_dv);
10982 return Ok(mode);11077 return Ok(mode);
10983 }11078 }
10984 neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);11079 neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);
@@ -11003,6 +11098,10 @@ fn decode_leaf8(
11003 // -ss 900, first bad luma sample row 186 col 1803).11098 // -ss 900, first bad luma sample row 186 col 1803).
11004 neighbours.fill_lf_grid(leaf_mi, 2, resolved as u8, 0);11099 neighbours.fill_lf_grid(leaf_mi, 2, resolved as u8, 0);
11005 neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode);11100 neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode);
11101+ // The DV predictor of a LATER intrabc block is the ordinary `INTRA_FRAME`
11102+ // MV stack over this grid (`av1_find_mv_refs`), so an 8x8 leaf has to
11103+ // publish its own cells exactly like `decode_block` does.
11104+ record_intrabc_mi(leaf_mi.0, leaf_mi.1, 2, intrabc_dv);
11006 Ok(mode)11105 Ok(mode)
11007 }11106 }
11008 11107
crates/ec-av1/src/stream.rsmodified+32 -1
@@ -86,6 +86,12 @@ pub fn rect_intrabc_reads() -> usize {
86 crate::decode::rect_intrabc_reads()86 crate::decode::rect_intrabc_reads()
87 }87 }
88 88
89+/// Blocks reconstructed with intra block copy at an 8x8 LEAF specifically
90+/// (lane-kf900 r7's shape); [`crate::decode::intrabc_hits`] counts every shape.
91+pub fn leaf8_intrabc_hits() -> usize {
92+ crate::decode::leaf8_intrabc_hits()
93+}
94+
89 pub fn rect4_32_counters() -> (usize, usize, usize) {95 pub fn rect4_32_counters() -> (usize, usize, usize) {
90 (96 (
91 crate::decode::rect4_32_horz_hits(),97 crate::decode::rect4_32_horz_hits(),
@@ -2845,7 +2851,7 @@ mod tests {
2845 const SB: &str = "smptebars=size=256x192:rate=25";2851 const SB: &str = "smptebars=size=256x192:rate=25";
2846 // (arm, source, per-arm overrides AFTER the base recipe, expect_refusal,2852 // (arm, source, per-arm overrides AFTER the base recipe, expect_refusal,
2847 // must_read_use_intrabc_on_a_rect_strip)2853 // must_read_use_intrabc_on_a_rect_strip)
2848- let arms: [(&str, &str, &[&str], bool, bool); 7] = [2854+ let arms: [(&str, &str, &[&str], bool, bool); 8] = [
2849 ("testsrc2-cq50-txs0", TS, &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=0"], true, true),2855 ("testsrc2-cq50-txs0", TS, &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=0"], true, true),
2850 ("smptebars-cq40-txs0", SB, &["--cq-level=40", "--enable-palette=0", "--enable-tx-size-search=0"], false, false),2856 ("smptebars-cq40-txs0", SB, &["--cq-level=40", "--enable-palette=0", "--enable-tx-size-search=0"], false, false),
2851 ("smptebars-cq45-txs0", SB, &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=0"], false, true),2857 ("smptebars-cq45-txs0", SB, &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=0"], false, true),
@@ -2853,10 +2859,17 @@ mod tests {
2853 ("smptebars-cq50-txs1", SB, &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=1"], false, false),2859 ("smptebars-cq50-txs1", SB, &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=1"], false, false),
2854 ("smptebars-cq55-txs0", SB, &["--cq-level=55", "--enable-palette=0", "--enable-tx-size-search=0"], false, false),2860 ("smptebars-cq55-txs0", SB, &["--cq-level=55", "--enable-palette=0", "--enable-tx-size-search=0"], false, false),
2855 ("testsrc2-cq63-txs1", TS, &["--cq-level=63", "--enable-palette=0", "--enable-tx-size-search=1"], false, false),2861 ("testsrc2-cq63-txs1", TS, &["--cq-level=63", "--enable-palette=0", "--enable-tx-size-search=1"], false, false),
2862+ // lane-kf900 r7: the 8x8-LEAF intrabc arm. Rect and 1:4
2863+ // partitions off (so no rect strip refuses first), palette on,
2864+ // `TxMode::Largest`: aomenc puts exactly one `use_intrabc` block
2865+ // on a `BLOCK_8X8` leaf here, the shape `decode_leaf8` decoded as
2866+ // ordinary intra before this round.
2867+ ("testsrc2-cq55-leaf8", TS, &["--cq-level=55", "--enable-palette=1", "--enable-tx-size-search=0", "--enable-rect-partitions=0", "--enable-1to4-partitions=0"], false, false),
2856 ];2868 ];
2857 let (mut reads_total, mut refused, mut frames_compared) = (0usize, 0u32, 0usize);2869 let (mut reads_total, mut refused, mut frames_compared) = (0usize, 0u32, 0usize);
2858 let (mut blocks_total, mut fired_arms, mut out_of_scope, mut out_of_scope_mismatch) =2870 let (mut blocks_total, mut fired_arms, mut out_of_scope, mut out_of_scope_mismatch) =
2859 (0usize, 0u32, 0u32, 0u32);2871 (0usize, 0u32, 0u32, 0u32);
2872+ let mut leaf8_total = 0usize;
2860 for (arm, src, extra, expect_refusal, must_read) in &arms {2873 for (arm, src, extra, expect_refusal, must_read) in &arms {
2861 let render = || {2874 let render = || {
2862 let out = Command::new("ffmpeg")2875 let out = Command::new("ffmpeg")
@@ -2928,6 +2941,7 @@ mod tests {
2928 let stream = out.stdout;2941 let stream = out.stdout;
2929 decode::reset_rect_intrabc_reads();2942 decode::reset_rect_intrabc_reads();
2930 crate::decode::reset_intrabc_hits();2943 crate::decode::reset_intrabc_hits();
2944+ crate::decode::reset_leaf8_intrabc_hits();
2931 let decoded = decode_stream(&stream);2945 let decoded = decode_stream(&stream);
2932 let reads = decode::rect_intrabc_reads();2946 let reads = decode::rect_intrabc_reads();
2933 // Blocks that decoded `use_intrabc == 1` (square path), i.e. that2947 // Blocks that decoded `use_intrabc == 1` (square path), i.e. that
@@ -2936,6 +2950,18 @@ mod tests {
2936 let blocks = crate::decode::intrabc_hits();2950 let blocks = crate::decode::intrabc_hits();
2937 reads_total += reads;2951 reads_total += reads;
2938 blocks_total += blocks;2952 blocks_total += blocks;
2953+ // The 8x8-leaf shape has its own counter: without it this gate's
2954+ // other arms (all rect/32x32 intrabc) would stay green while the
2955+ // leaf path decoded an intrabc block as ordinary intra (class
2956+ // `gate-blind-to-feature`).
2957+ let leaf8 = crate::decode::leaf8_intrabc_hits();
2958+ leaf8_total += leaf8;
2959+ if *arm == "testsrc2-cq55-leaf8" {
2960+ assert!(
2961+ leaf8 > 0,
2962+ "{NAME}: {arm} decoded no intrabc block at an 8x8 leaf -- the arm no longer exercises `decode_leaf8`'s intrabc path"
2963+ );
2964+ }
2939 if *must_read {2965 if *must_read {
2940 assert!(2966 assert!(
2941 reads > 0,2967 reads > 0,
@@ -3006,7 +3032,12 @@ mod tests {
3006 {refused} refused by name, {frames_compared} frames compared, \3032 {refused} refused by name, {frames_compared} frames compared, \
3007 {out_of_scope} out of scope ({out_of_scope_mismatch} mismatched)"3033 {out_of_scope} out of scope ({out_of_scope_mismatch} mismatched)"
3008 );3034 );
3035+ eprintln!("{NAME}: {leaf8_total} intrabc block(s) at an 8x8 leaf");
3009 assert!(reads_total > 0, "{NAME}: gate is vacuous -- no arm read the symbol");3036 assert!(reads_total > 0, "{NAME}: gate is vacuous -- no arm read the symbol");
3037+ assert!(
3038+ leaf8_total > 0,
3039+ "{NAME}: no arm decoded an intrabc block at an 8x8 leaf -- lane-kf900 r7's fix is untested"
3040+ );
3010 assert!(3041 assert!(
3011 blocks_total > 0 && fired_arms > 0,3042 blocks_total > 0 && fired_arms > 0,
3012 "{NAME}: gate is vacuous -- no compared arm actually decoded an intrabc block"3043 "{NAME}: gate is vacuous -- no compared arm actually decoded an intrabc block"
lanes/kf900-r7.handoff.mdadded+67 -0
@@ -0,0 +1,67 @@
1+# lane-kf900 r7 HANDOFF -- 8x8-leaf intrabc decoded as ordinary intra
2+
3+## Merge state
4+`git merge --no-commit main` (main `3566501`) auto-merged clean (decode.rs, stream.rs,
5+gate_coverage.rs), committed as `6c22a5f`. The r6 palette-at-mi-granularity hunks and the
6+intrabc chroma tx_type fix survive untouched (Neighbours palette fns re-read after the merge).
7+
8+## Root cause of the r6 "last superblock" residue (found, fixed)
9+Stream `$HOME/.cache/kf900-r6/DIFF_55_0_1_test.obu` (testsrc2 256x192 cq55 txs=0 palette=1
10+screen 8-bit). The r6 report's "entropy stays in sync, reconstruction defect, deltas ~4" was
11+WRONG on both counts: deltas run to +-171 and it is an ENTROPY desync -- invisible because the
12+bad block sits in the LAST superblock, so nothing after it could disagree.
13+
14+* Stage: mode info -> first coefficient TU. Cross-decoder `EC_TRACE_MODE_STEP` ladder diverges
15+ at mi(34,52) (luma 136,208): both decoders read skip/cdef/dq at rng=42705, then the next
16+ block starts at oracle rng=52073 vs ours 33144.
17+* Block: an 8x8 **leaf** (`decode_leaf8`) that decoded `use_intrabc=1`, DV `(-512,-1360)`
18+ (identical on both sides -- `EC_TRACE_IBC`, so the DV read is exonerated for the 3rd time).
19+* Element: the luma `tx_type`. `EC_TRACE_COEFF` (our trace now prints the CDF width, `len=`):
20+ ours read an 8-slot row (`TX_SET_INTRA_1`, 7 symbols), libaom reads
21+ `av1_get_ext_tx_set_type(TX_8X8, is_inter=1, 0)` = `EXT_TX_SET_ALL16` (16 symbols), because
22+ `is_inter_block(mbmi)` counts `is_intrabc_block` (`av1/common/blockd.h:373`, set chooser
23+ `av1/common/blockd.h` `av1_get_tx_type`). Same value, different interval -- class
24+ `wrong-alphabet-same-value`.
25+* Why only there: `decode_leaf8` consumed `use_intrabc` + the DV through `read_intra_mode` and
26+ then ignored the result entirely -- no inter ext-tx set, no chroma tx_type inheritance, no
27+ prediction from the current frame, no `record_intrabc_mi`. `decode_block` (16x16 and up) had
28+ all four since r6.
29+
30+## Fix (crates/ec-av1/src/decode.rs, `decode_leaf8`)
31+1. take `INTRABC_DV`; refuse under `TxMode::Select && !skip` with `decode_block`'s EXISTING
32+ refusal string (no new inventory entry); a skipped intrabc leaf reads no intra `tx_depth`.
33+2. luma set `txbset_for_inter(8, reduced_tx_set)`.
34+3. BILINEAR prediction from the current frame at the DV (8x8 luma, 4x4 chroma) through the
35+ `PALETTE_PRED` override slot, in both the skip and non-skip branches.
36+4. `INTRABC_CHROMA_TX` armed after the luma read and **disarmed** after the V read (leaving it
37+ armed leaked the luma tx_type into every later chroma block: 320 chroma samples wrong,
38+ luma exact -- second bug, found by re-measuring).
39+5. `record_intrabc_mi(leaf_mi, 2, intrabc_dv)` on both exits (a later DV's MV stack).
40+Plus counter `LEAF8_INTRABC_HITS` + `stream::leaf8_intrabc_hits()` + a `decode_probe` line.
41+
42+Measured, 8-bit `$HOME/.cache/kf900-r7/S_DIFF_test_55_r0_d8.obu` (same source/cq, rect+1:4 off
43+so no rect-strip refusal fires first): before 320 chroma samples wrong / entropy desync at the
44+leaf; after **0 bytes differ vs ffmpeg** (`cmp -l` = 0), `leaf8_intrabc_hits=1`, and the
45+`all_zero`/`eob` range ladder is identical for all 499 steps.
46+The ORIGINAL r6 stream now stops earlier at the pre-existing named refusal
47+"intra block copy on a HORZ/VERT/1:4 rect intra strip" instead of decoding wrong pixels.
48+
49+## Gate state
50+`a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` gained arm 8
51+`testsrc2-cq55-leaf8` (`--cq-level=55 --enable-palette=1 --enable-tx-size-search=0
52+--enable-rect-partitions=0 --enable-1to4-partitions=0` after the base recipe), a hard per-arm
53+`leaf8 > 0` assert and a gate-wide `leaf8_total > 0` vacuity assert.
54+`cargo test -p ec-av1 --lib -j3 -- intrabc palette --nocapture` = **8 passed, 0 failed** (45s).
55+
56+## Exact next steps
57+1. FULL SUITE NOT RUN this round (turn cap). Run:
58+ `systemd-run --user --unit=kf900-suite-r7-$(date +%s) -p MemoryMax=10G --same-dir bash -lc
59+ 'EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-kf900
60+ nice -n 10 cargo test -p ec-av1 --lib -j3 > $HOME/.cache/kf900-suite-r7.log 2>&1'`
61+ then `grep -E "^test result|FAILED" $HOME/.cache/kf900-suite-r7.log`. r6 baseline 385/0/33.
62+2. 10-bit leaf8 arm: the r7 sweep (`$HOME/.cache/kf900-r7/sweep.sh`, 3 sources x 5 cq x rect
63+ on/off x 8/10 bit) produced NO decoding 10-bit stream at all (every 10-bit arm refuses on
64+ another lane's gap), so the 8x8-leaf intrabc fix is 8-bit-proven only. Widen the sweep
65+ (other sources / `--max-partition-size=16`) or wait for the sibling lanes.
66+3. Still open (unchanged from r6): rect-strip intrabc reconstruction refusal -- now the FIRST
67+ thing `DIFF_55_0_1_test.obu` hits; porting BILINEAR prediction at rect shapes closes it.