forge
Explore
Log in

Don't you dare go Hollow

One-sided chroma OBMC below 16px + mi-granular OBMC neighbour filters

Browse files at this commit

12bec5183a5ce57b268c8c9139ef5d85a57fb091Ahmet Kaan GümüşParent: d4af78e
  • fix
    • one-sided chroma OBMC below 16px + mi-granular OBMC neighbour filters
Show full message
fix(av1): one-sided chroma OBMC below 16px + mi-granular OBMC neighbour filters

libaom av1_skip_u4x4_pred_in_obmc (reconinter.c:820, DISABLE_CHROMA_U8X8_OBMC 0):
when a block's chroma plane size is 4x4/4x8/8x4 -- any luma dimension below 16
under 4:2:0 -- OBMC is ONE-SIDED on chroma: the ABOVE pass skips U/V entirely,
the LEFT pass still blends them. We blended chroma on both passes, which is
exactly the residual that left a_real_aomenc_stream_with_obmc_8x8's V plane off
by ~2 on seed 53 (luma and U happened to match). That gate is now GREEN
pixel-exact over 24 frames with 4 real 8x8 OBMC leaves, and no longer degrades
"never fired" into a SKIP -- it panics (gate-skips-on-its-own-failure).

Second defect, a hard PANIC: obmc_blend took the neighbour's interp filter from
the 16px-granular `Neighbours` slot, which is only written after a whole 16x16
finishes. An 8x8 leaf OBMC-blending its own SIBLING leaf therefore read the
`[3, 3]` "intra/unset" sentinel and `from_switchable_symbol` panicked (this was
the warp gate's crash -- NOT an entropy desync). MiGrid now carries mi-granular
filter symbols (libaom uses the neighbour mbmi's own interp_filters), with the
coarse slot kept as fallback. decode_inter_block8 also hands its real filter
symbols and reference back to the caller, which recorded `[3, 3]` and a
hardcoded LAST_FRAME for every 8x8-split 16x16 until now (also fixes the leaf's
loop-filter ref id).

Gates a_real_globalmv_8x8_leaf / a_real_warped_causal_8x8_leaf stay RED: both
now die on partition/angle-delta refusals for tools explicitly DISABLED on the
aomenc command line, i.e. an entropy desync in the 8x8-leaf path itself
(lane-inter8's cluster), not in the motion code. Recipe knobs
EC_8X8_MINPART/EC_8X8_MAXPART added for the next round's search.
crates/ec-av1/src/decode.rsmodified+174 -42
@@ -8198,6 +8198,16 @@ fn obmc_mask(len: usize) -> &'static [u8] {
8198 /// excluded by [`overlappable_above`]/[`overlappable_left`]'s `is_inter`8198 /// excluded by [`overlappable_above`]/[`overlappable_left`]'s `is_inter`
8199 /// gate) or when `interp_fixed` is `Some` for the whole frame, handled here8199 /// gate) or when `interp_fixed` is `Some` for the whole frame, handled here
8200 /// first.8200 /// first.
8201+/// lane-gmaffine r2: prefer the mi-granular filter record, fall back to the
8202+/// coarse 16px `Neighbours` slot when this block's path never recorded one.
8203+fn grid_or_slot(mi_filter: [u8; 2], slot: [u8; 2]) -> [u8; 2] {
8204+ if mi_filter[0] <= 2 && mi_filter[1] <= 2 {
8205+ mi_filter
8206+ } else {
8207+ slot
8208+ }
8209+}
8210+
8201 fn neighbour_filter(8211 fn neighbour_filter(
8202 interp_fixed: Option<mc::InterpFilterKind>,8212 interp_fixed: Option<mc::InterpFilterKind>,
8203 sym: [u8; 2],8213 sym: [u8; 2],
@@ -8415,6 +8425,14 @@ fn obmc_blend(
8415 };8425 };
8416 let overlap_above = write_h / 2;8426 let overlap_above = write_h / 2;
8417 let overlap_left = write_w / 2;8427 let overlap_left = write_w / 2;
8428+ // lane-gmaffine r2 (libaom `av1_skip_u4x4_pred_in_obmc`, reconinter.c:820,
8429+ // `DISABLE_CHROMA_U8X8_OBMC 0`): when the block's CHROMA plane size is
8430+ // BLOCK_4X4/4X8/8X4 -- i.e. a luma dimension below 16 under 4:2:0 -- obmc
8431+ // is ONE-SIDED on chroma: the above pass (dir==0) skips U/V entirely, the
8432+ // left pass (dir==1) still blends them. Blending chroma on both passes is
8433+ // exactly the residual that left the 8x8-leaf obmc gate's V plane off by
8434+ // ~2 (r1); luma is unaffected at every size.
8435+ let chroma_above = write_w >= 16 && write_h >= 16;
8418 8436
8419 for (off4, span4, nb) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4))8437 for (off4, span4, nb) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4))
8420 {8438 {
@@ -8422,25 +8440,40 @@ fn obmc_blend(
8422 // (this decoder's own outer block-loop granularity), one step8440 // (this decoder's own outer block-loop granularity), one step
8423 // coarser than the mi(4px) units `overlappable_above` walks in --8441 // coarser than the mi(4px) units `overlappable_above` walks in --
8424 // divide back down to that column.8442 // divide back down to that column.
8443+ // lane-gmaffine r2: the neighbour's OWN mi-granular filter
8444+ // (libaom `av1_setup_build_prediction_by_above_pred` reads
8445+ // `above_mbmi->interp_filters`); the 16px-granular `Neighbours` slot
8446+ // stays as the fallback for paths that do not record one yet
8447+ // (compound), which is what every earlier round used.
8425 let (h_kind, v_kind) = neighbour_filter(8448 let (h_kind, v_kind) = neighbour_filter(
8426 interp_fixed,8449 interp_fixed,
8427- neighbours.above_filter[(mi_col + off4) / SUB_MI as usize],8450+ grid_or_slot(
8451+ grid.filter(mi_row.wrapping_sub(1), mi_col + off4),
8452+ neighbours.above_filter[(mi_col + off4) / SUB_MI as usize],
8453+ ),
8428 );8454 );
8429 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;8455 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
8430 let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4);8456 let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4);
8431 let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind);8457 let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind);
8432 obmc_blend_v(pred_y, side, ox, 0, bw, bh, &tmp_y);8458 obmc_blend_v(pred_y, side, ox, 0, bw, bh, &tmp_y);
8433- let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2);8459+ if chroma_above {
8434- let tmp_u = obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind);8460+ let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2);
8435- obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u);8461+ let tmp_u =
8436- let tmp_v = obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind);8462+ obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind);
8437- obmc_blend_v(pred_v, chroma_side, cox, 0, cbw, cbh, &tmp_v);8463+ obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u);
8464+ let tmp_v =
8465+ obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind);
8466+ obmc_blend_v(pred_v, chroma_side, cox, 0, cbw, cbh, &tmp_v);
8467+ }
8438 }8468 }
8439 8469
8440 for (off4, span4, nb) in overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, max_nb(bh4)) {8470 for (off4, span4, nb) in overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, max_nb(bh4)) {
8441 let (h_kind, v_kind) = neighbour_filter(8471 let (h_kind, v_kind) = neighbour_filter(
8442 interp_fixed,8472 interp_fixed,
8443- neighbours.left_filter[(mi_row + off4) / SUB_MI as usize],8473+ grid_or_slot(
8474+ grid.filter(mi_row + off4, mi_col.wrapping_sub(1)),
8475+ neighbours.left_filter[(mi_row + off4) / SUB_MI as usize],
8476+ ),
8444 );8477 );
8445 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;8478 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
8446 let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4);8479 let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4);
@@ -10103,6 +10136,9 @@ fn decode_inter_block(
10103 // a square `bw4`x`bw4` guess.10136 // a square `bw4`x`bw4` guess.
10104 for dr in 0..bh4 {10137 for dr in 0..bh4 {
10105 for dc in 0..bw4 {10138 for dc in 0..bw4 {
10139+ // lane-gmaffine r2: mi-granular filter record for OBMC
10140+ // neighbour prediction (see `MiGrid::filters`).
10141+ grid.set_filter(mi_row + dr, mi_col + dc, block_filter);
10106 grid.set(10142 grid.set(
10107 mi_row + dr,10143 mi_row + dr,
10108 mi_col + dc,10144 mi_col + dc,
@@ -10746,8 +10782,18 @@ fn decode_inter_block8(
10746 // `BLOCK_8X8` (this leaf's fixed size) is always `av1_allow_palette`-10782 // `BLOCK_8X8` (this leaf's fixed size) is always `av1_allow_palette`-
10747 // eligible (`bsize >= BLOCK_8X8`).10783 // eligible (`bsize >= BLOCK_8X8`).
10748 allow_screen_content_tools: bool,10784 allow_screen_content_tools: bool,
10749-) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>)> {10785+) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>, [u8; 2], i8)> {
10750 const LAST_FRAME: i8 = 1;10786 const LAST_FRAME: i8 = 1;
10787+ // lane-gmaffine r2: the leaf's OWN switchable-filter symbols and reference,
10788+ // handed back so the caller records them in `Neighbours` instead of the
10789+ // `[3, 3]` / hardcoded-LAST_FRAME placeholders r1 left there. `[3, 3]` is
10790+ // the "intra neighbour, no filter" sentinel: an OBMC blend that picks such
10791+ // a neighbour up feeds it to `neighbour_filter`, which PANICS on it
10792+ // (`from_switchable_symbol`) -- that was the warp gate's crash, not an
10793+ // entropy desync. Stays `[3, 3]`/-1 on the intra and compound paths, which
10794+ // is what the caller already recorded for them.
10795+ let mut leaf_filter_syms = [3u8; 2];
10796+ let mut leaf_ref: i8 = -1;
10751 /// `Y_MODE`'s size group (`common_data.h`'s `size_group_lookup[BLOCK_8X8]`).10797 /// `Y_MODE`'s size group (`common_data.h`'s `size_group_lookup[BLOCK_8X8]`).
10752 const SIZE_GROUP_8: usize = 1;10798 const SIZE_GROUP_8: usize = 1;
10753 10799
@@ -11199,7 +11245,7 @@ fn decode_inter_block8(
11199 )?11245 )?
11200 .0;11246 .0;
11201 }11247 }
11202- return Ok((skip, is_inter, skip_mode, compound_ctx8));11248+ return Ok((skip, is_inter, skip_mode, compound_ctx8, leaf_filter_syms, leaf_ref));
11203 }11249 }
11204 }11250 }
11205 // lane-gmaffine r1: the leaf reads the FULL `single_ref` tree11251 // lane-gmaffine r1: the leaf reads the FULL `single_ref` tree
@@ -11450,7 +11496,7 @@ fn decode_inter_block8(
11450 };11496 };
11451 let gm_nontrans =11497 let gm_nontrans =
11452 is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation;11498 is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation;
11453- let (h_filter, v_filter, _resolved_filter) = resolve_interp_filter(11499+ let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
11454 dec,11500 dec,
11455 cdfs,11501 cdfs,
11456 interp_fixed,11502 interp_fixed,
@@ -11460,6 +11506,16 @@ fn decode_inter_block8(
11460 left_filter_ctx,11506 left_filter_ctx,
11461 false,11507 false,
11462 );11508 );
11509+ leaf_filter_syms = resolved_filter;
11510+ leaf_ref = ref_frame;
11511+ // lane-gmaffine r2: mi-granular filter record -- a sibling 8x8 leaf
11512+ // OBMC-blends this one before the enclosing 16x16's coarse
11513+ // `Neighbours` slot is ever written.
11514+ for dr in 0..2 {
11515+ for dc in 0..2 {
11516+ grid.set_filter(leaf_mi.0 + dr, leaf_mi.1 + dc, resolved_filter);
11517+ }
11518+ }
11463 11519
11464 // lane-gmaffine r1: `allow_warp`'s `global_warp_allowed` branch11520 // lane-gmaffine r1: `allow_warp`'s `global_warp_allowed` branch
11465 // (`reconinter.c:33-55`), gated INDEPENDENTLY of `motion_mode` --11521 // (`reconinter.c:33-55`), gated INDEPENDENTLY of `motion_mode` --
@@ -11847,8 +11903,20 @@ fn decode_inter_block8(
11847 }11903 }
11848 }11904 }
11849 neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);11905 neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);
11850- neighbours.fill_lf_grid(leaf_mi, 2, 8, if is_inter { LAST_FRAME } else { 0 });11906+ // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference
11851- Ok((skip, is_inter, skip_mode, compound_ctx8))11907+ // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every
11908+ // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test).
11909+ neighbours.fill_lf_grid(
11910+ leaf_mi,
11911+ 2,
11912+ 8,
11913+ if is_inter {
11914+ if leaf_ref > 0 { leaf_ref } else { LAST_FRAME }
11915+ } else {
11916+ 0
11917+ },
11918+ );
11919+ Ok((skip, is_inter, skip_mode, compound_ctx8, leaf_filter_syms, leaf_ref))
11852 }11920 }
11853 11921
11854 /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes,11922 /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes,
@@ -12451,6 +12519,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
12451 let mut prev_leaf: Option<((usize, usize), bool, bool)> = None;12519 let mut prev_leaf: Option<((usize, usize), bool, bool)> = None;
12452 let mut last_compound_ctx: Option<(i8, i8, u8, u8)> = None;12520 let mut last_compound_ctx: Option<(i8, i8, u8, u8)> = None;
12453 let mut last_skip_mode = false;12521 let mut last_skip_mode = false;
12522+ let mut last_filter = [3u8; 2];
12523+ let mut last_ref: i8 = -1;
12454 for (mr, mc) in leaf_positions {12524 for (mr, mc) in leaf_positions {
12455 let leaf_mi = (mr as usize, mc as usize);12525 let leaf_mi = (mr as usize, mc as usize);
12456 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);12526 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);
@@ -12460,8 +12530,14 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
12460 "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)",12530 "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)",
12461 ));12531 ));
12462 }12532 }
12463- let (skip, is_inter, skip_mode_leaf, compound_ctx8) =12533+ let (
12464- decode_inter_block8(12534+ skip,
12535+ is_inter,
12536+ skip_mode_leaf,
12537+ compound_ctx8,
12538+ leaf_filter,
12539+ leaf_ref,
12540+ ) = decode_inter_block8(
12465 &mut dec,12541 &mut dec,
12466 &mut cdfs,12542 &mut cdfs,
12467 &mut neighbours,12543 &mut neighbours,
@@ -12502,29 +12578,53 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
12502 )?;12578 )?;
12503 prev_leaf = Some((leaf_mi, skip, is_inter));12579 prev_leaf = Some((leaf_mi, skip, is_inter));
12504 last_skip_mode = skip_mode_leaf;12580 last_skip_mode = skip_mode_leaf;
12581+ // lane-gmaffine r2: keep the last INTER
12582+ // leaf's own filter/ref for the coarse
12583+ // 16px-wide `Neighbours` slot (see below).
12584+ // Intra leaves must not overwrite it: the
12585+ // slot is shared by all four, and an OBMC
12586+ // neighbour is chosen at mi granularity, so
12587+ // an intra LAST leaf would hand `[3, 3]` to
12588+ // `neighbour_filter` for an inter sibling.
12589+ if leaf_ref > 0 {
12590+ last_filter = leaf_filter;
12591+ last_ref = leaf_ref;
12592+ }
12505 if compound_ctx8.is_some() {12593 if compound_ctx8.is_some() {
12506 last_compound_ctx = compound_ctx8;12594 last_compound_ctx = compound_ctx8;
12507 }12595 }
12508 }12596 }
12509 if let Some((_, skip, is_inter)) = prev_leaf {12597 if let Some((_, skip, is_inter)) = prev_leaf {
12510- // corner-cut: `decode_inter_block8`'s12598+ // lane-gmaffine r2: record the LAST leaf's
12511- // leaves never read a switchable filter12599+ // real switchable-filter symbols and its
12512- // (round-3 GLOBALMV refusal already12600+ // real reference. r1 recorded `[3, 3]` (the
12513- // bounds them away from the Regular-only12601+ // "intra neighbour" sentinel) and a
12514- // gap this round closes elsewhere); `[3,12602+ // hardcoded LAST_FRAME here; `[3, 3]` made
12515- // 3]` is "no info", the same value an12603+ // `obmc_blend`'s `neighbour_filter` PANIC
12516- // intra neighbour records. Upgrade:12604+ // the moment a later block OBMC-blended one
12517- // thread `interp_fixed`/`enable_dual_filter`12605+ // of these leaves, and the fake ref
12518- // into `decode_inter_block8` once a12606+ // corrupted the next block's
12519- // straddling 8x8 SWITCHABLE stream is on12607+ // switchable_interp / ref contexts.
12520- // hand to pin against.12608+ // corner-cut: `Neighbours` is 16px-granular,
12609+ // so all four leaves collapse into one slot
12610+ // (the last one wins). Ceiling: siblings
12611+ // that choose DIFFERENT filters or refs give
12612+ // the next block one leaf's context instead
12613+ // of the bordering one's. Upgrade: mi-
12614+ // granular above_filter/above_ref arrays.
12521 neighbours.record_inter(12615 neighbours.record_inter(
12522 at16,12616 at16,
12523 SUB,12617 SUB,
12524 skip,12618 skip,
12525 is_inter,12619 is_inter,
12526- if is_inter { LAST_FRAME } else { -1 },12620+ if !is_inter {
12527- [3, 3],12621+ -1
12622+ } else if last_ref > 0 {
12623+ last_ref
12624+ } else {
12625+ LAST_FRAME
12626+ },
12627+ last_filter,
12528 last_skip_mode,12628 last_skip_mode,
12529 );12629 );
12530 if let Some((ref0, ref1, group_idx, idx)) = last_compound_ctx {12630 if let Some((ref0, ref1, group_idx, idx)) = last_compound_ctx {
@@ -12640,6 +12740,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
12640 let mut prev_leaf: Option<((usize, usize), bool, bool)> = None;12740 let mut prev_leaf: Option<((usize, usize), bool, bool)> = None;
12641 let mut last_compound_ctx: Option<(i8, i8, u8, u8)> = None;12741 let mut last_compound_ctx: Option<(i8, i8, u8, u8)> = None;
12642 let mut last_skip_mode = false;12742 let mut last_skip_mode = false;
12743+ let mut last_filter = [3u8; 2];
12744+ let mut last_ref: i8 = -1;
12643 for (mr, mc) in leaf_positions {12745 for (mr, mc) in leaf_positions {
12644 let leaf_mi = (mr as usize, mc as usize);12746 let leaf_mi = (mr as usize, mc as usize);
12645 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);12747 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);
@@ -12649,8 +12751,14 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
12649 "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)",12751 "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)",
12650 ));12752 ));
12651 }12753 }
12652- let (skip, is_inter, skip_mode_leaf, compound_ctx8) =12754+ let (
12653- decode_inter_block8(12755+ skip,
12756+ is_inter,
12757+ skip_mode_leaf,
12758+ compound_ctx8,
12759+ leaf_filter,
12760+ leaf_ref,
12761+ ) = decode_inter_block8(
12654 &mut dec,12762 &mut dec,
12655 &mut cdfs,12763 &mut cdfs,
12656 &mut neighbours,12764 &mut neighbours,
@@ -12691,29 +12799,53 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
12691 )?;12799 )?;
12692 prev_leaf = Some((leaf_mi, skip, is_inter));12800 prev_leaf = Some((leaf_mi, skip, is_inter));
12693 last_skip_mode = skip_mode_leaf;12801 last_skip_mode = skip_mode_leaf;
12802+ // lane-gmaffine r2: keep the last INTER
12803+ // leaf's own filter/ref for the coarse
12804+ // 16px-wide `Neighbours` slot (see below).
12805+ // Intra leaves must not overwrite it: the
12806+ // slot is shared by all four, and an OBMC
12807+ // neighbour is chosen at mi granularity, so
12808+ // an intra LAST leaf would hand `[3, 3]` to
12809+ // `neighbour_filter` for an inter sibling.
12810+ if leaf_ref > 0 {
12811+ last_filter = leaf_filter;
12812+ last_ref = leaf_ref;
12813+ }
12694 if compound_ctx8.is_some() {12814 if compound_ctx8.is_some() {
12695 last_compound_ctx = compound_ctx8;12815 last_compound_ctx = compound_ctx8;
12696 }12816 }
12697 }12817 }
12698 if let Some((_, skip, is_inter)) = prev_leaf {12818 if let Some((_, skip, is_inter)) = prev_leaf {
12699- // corner-cut: `decode_inter_block8`'s12819+ // lane-gmaffine r2: record the LAST leaf's
12700- // leaves never read a switchable filter12820+ // real switchable-filter symbols and its
12701- // (round-3 GLOBALMV refusal already12821+ // real reference. r1 recorded `[3, 3]` (the
12702- // bounds them away from the Regular-only12822+ // "intra neighbour" sentinel) and a
12703- // gap this round closes elsewhere); `[3,12823+ // hardcoded LAST_FRAME here; `[3, 3]` made
12704- // 3]` is "no info", the same value an12824+ // `obmc_blend`'s `neighbour_filter` PANIC
12705- // intra neighbour records. Upgrade:12825+ // the moment a later block OBMC-blended one
12706- // thread `interp_fixed`/`enable_dual_filter`12826+ // of these leaves, and the fake ref
12707- // into `decode_inter_block8` once a12827+ // corrupted the next block's
12708- // straddling 8x8 SWITCHABLE stream is on12828+ // switchable_interp / ref contexts.
12709- // hand to pin against.12829+ // corner-cut: `Neighbours` is 16px-granular,
12830+ // so all four leaves collapse into one slot
12831+ // (the last one wins). Ceiling: siblings
12832+ // that choose DIFFERENT filters or refs give
12833+ // the next block one leaf's context instead
12834+ // of the bordering one's. Upgrade: mi-
12835+ // granular above_filter/above_ref arrays.
12710 neighbours.record_inter(12836 neighbours.record_inter(
12711 at16,12837 at16,
12712 SUB,12838 SUB,
12713 skip,12839 skip,
12714 is_inter,12840 is_inter,
12715- if is_inter { LAST_FRAME } else { -1 },12841+ if !is_inter {
12716- [3, 3],12842+ -1
12843+ } else if last_ref > 0 {
12844+ last_ref
12845+ } else {
12846+ LAST_FRAME
12847+ },
12848+ last_filter,
12717 last_skip_mode,12849 last_skip_mode,
12718 );12850 );
12719 if let Some((ref0, ref1, group_idx, idx)) = last_compound_ctx {12851 if let Some((ref0, ref1, group_idx, idx)) = last_compound_ctx {
crates/ec-av1/src/mvstack.rsmodified+29 -0
@@ -177,6 +177,15 @@ pub struct MiGrid {
177 cols: usize,177 cols: usize,
178 rows: usize,178 rows: usize,
179 cells: Vec<Option<MiInfo>>,179 cells: Vec<Option<MiInfo>>,
180+ /// lane-gmaffine r2: each mi unit's own switchable-filter symbols
181+ /// (`[dir0, dir1]`, `3` = unset/intra). libaom's OBMC neighbour
182+ /// prediction (`av1_setup_build_prediction_by_{above,left}_pred`) uses the
183+ /// NEIGHBOUR mbmi's `interp_filters`, which is mi-granular; the decoder's
184+ /// `Neighbours` filter arrays are 16px-granular and are not written until
185+ /// a whole 16x16 finishes, so an 8x8 leaf OBMC-blending its own SIBLING
186+ /// leaf read the unset `[3, 3]` sentinel (a hard panic in
187+ /// `from_switchable_symbol`).
188+ filters: Vec<[u8; 2]>,
180 /// lane-tiles r6: the current tile's own mi-unit bounds (spec: an MV189 /// lane-tiles r6: the current tile's own mi-unit bounds (spec: an MV
181 /// candidate scan never reaches across a tile boundary, mirroring190 /// candidate scan never reaches across a tile boundary, mirroring
182 /// `PlaneBuf`'s `tile_x0`/`tile_x1` reach clamp for intra prediction).191 /// `PlaneBuf`'s `tile_x0`/`tile_x1` reach clamp for intra prediction).
@@ -195,6 +204,7 @@ impl MiGrid {
195 cols,204 cols,
196 rows,205 rows,
197 cells: vec![None; cols * rows],206 cells: vec![None; cols * rows],
207+ filters: vec![[3u8; 2]; cols * rows],
198 tile_row0: 0,208 tile_row0: 0,
199 tile_col0: 0,209 tile_col0: 0,
200 tile_row1: rows,210 tile_row1: rows,
@@ -202,6 +212,25 @@ impl MiGrid {
202 }212 }
203 }213 }
204 214
215+ /// Records the switchable-filter symbols of the block covering `(row,
216+ /// col)`; `[3, 3]` (the initial value) means "no filter here" -- intra, a
217+ /// fixed-filter frame, or a path that does not track one.
218+ pub fn set_filter(&mut self, row: usize, col: usize, filter: [u8; 2]) {
219+ if row < self.rows && col < self.cols {
220+ self.filters[row * self.cols + col] = filter;
221+ }
222+ }
223+
224+ /// This mi unit's recorded filter symbols, `[3, 3]` when unset.
225+ #[must_use]
226+ pub fn filter(&self, row: usize, col: usize) -> [u8; 2] {
227+ if row < self.rows && col < self.cols {
228+ self.filters[row * self.cols + col]
229+ } else {
230+ [3, 3]
231+ }
232+ }
233+
205 /// Narrows [`Self::get`]'s own read window to one tile's mi-unit span234 /// Narrows [`Self::get`]'s own read window to one tile's mi-unit span
206 /// (`row1`/`col1` exclusive) -- called once per tile, before that235 /// (`row1`/`col1` exclusive) -- called once per tile, before that
207 /// tile's own superblock walk, the same way `Neighbours::start_tile`236 /// tile's own superblock walk, the same way `Neighbours::start_tile`
crates/ec-av1/src/stream.rsmodified+10 -3
@@ -4401,8 +4401,11 @@ mod tests {
4401 );4401 );
4402 return;4402 return;
4403 }4403 }
4404- eprintln!(4404+ // lane-gmaffine r2: this gate fired for three rounds only as a SKIP
4405- "SKIP {NAME}: {never_fired} attempts decoded but never fired an 8x8 obmc block \4405+ // (gate-skips-on-its-own-failure); the 8x8 leaf is reachable now, so a
4406+ // sweep that never lands one firing pixel-exact attempt is a FAILURE.
4407+ panic!(
4408+ "{NAME}: {never_fired} attempts decoded but never fired an 8x8 obmc block \
4406 ({total_obmc8} total 8x8 obmc hits across all attempts), and every other attempt \4409 ({total_obmc8} total 8x8 obmc hits across all attempts), and every other attempt \
4407 hit a named refusal:\n{}",4410 hit a named refusal:\n{}",
4408 refusals.join("\n")4411 refusals.join("\n")
@@ -5431,6 +5434,10 @@ mod tests {
5431 for (di, depth) in [8u32, 10u32].into_iter().enumerate() {5434 for (di, depth) in [8u32, 10u32].into_iter().enumerate() {
5432 for cq in [32u32, 45, 55] {5435 for cq in [32u32, 45, 55] {
5433 let cq_arg = format!("--cq-level={cq}");5436 let cq_arg = format!("--cq-level={cq}");
5437+ let max_part_arg = format!(
5438+ "--max-partition-size={}",
5439+ std::env::var("EC_8X8_MAXPART").unwrap_or_else(|_| "8".into())
5440+ );
5434 let source = format!(5441 let source = format!(
5435 "mandelbrot=size=96x96:rate=25,rotate=a=0.12*t:c=black,\5442 "mandelbrot=size=96x96:rate=25,rotate=a=0.12*t:c=black,\
5436 scale=w='ceil(96*(1+0.03*n)/2)*2':h=96:eval=frame,crop={width}:{height}"5443 scale=w='ceil(96*(1+0.03*n)/2)*2':h=96:eval=frame,crop={width}:{height}"
@@ -5490,7 +5497,7 @@ mod tests {
5490 "--enable-tx-size-search=0",5497 "--enable-tx-size-search=0",
5491 "--enable-cdef=0",5498 "--enable-cdef=0",
5492 "--enable-restoration=0",5499 "--enable-restoration=0",
5493- "--max-partition-size=8",5500+ &max_part_arg,
5494 "--min-partition-size=8",5501 "--min-partition-size=8",
5495 "--enable-palette=0",5502 "--enable-palette=0",
5496 "--enable-intrabc=0",5503 "--enable-intrabc=0",