diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 886f8852..9861b400 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -2338,6 +2338,21 @@ pub(crate) fn obmc_pair_filter_hits() -> usize { OBMC_PAIR_FILTER_HITS.with(|c| c.get()) } +// lane-t900 r14: how many OBMC neighbour predictions run PAST the frame edge +// -- libaom's `op_mi_size` is `AOMMIN(xd->width|height, mi_step)`, the block's +// own side, so a block overhanging the bottom/right still predicts the full +// neighbour strip (the destination write is what clips). We used to shrink the +// prediction to the visible part, which at 4 chroma rows/cols also swaps the +// vertical/horizontal kernel to the 4-tap one. The gate's proof the shape fired. +thread_local! { + static OBMC_EDGE_SPAN_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// Current value of [`OBMC_EDGE_SPAN_HITS`]. +pub(crate) fn obmc_edge_span_hits() -> usize { + OBMC_EDGE_SPAN_HITS.with(|c| c.get()) +} + /// Current value of [`OBMC_HITS_8`]. pub(crate) fn obmc_hits_8() -> usize { OBMC_HITS_8.with(|c| c.get()) @@ -19597,6 +19612,9 @@ fn obmc_blend( ec_obmc_trace("above", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind); let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; let nb_scale = mc::scale_factor(ny.width, frame_width); + if mi_col + off4 + span4 > mi_cols { + OBMC_EDGE_SPAN_HITS.with(|c| c.set(c.get() + 1)); + } let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4); // lane-t900 r14: the prediction is `op_mi_size` wide (kernel choice // included); only the WRITE is clipped to this block's own buffer. @@ -19630,6 +19648,9 @@ fn obmc_blend( ec_obmc_trace("left", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind); let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; let nb_scale = mc::scale_factor(ny.width, frame_width); + if mi_row + off4 + span4 > mi_rows { + OBMC_EDGE_SPAN_HITS.with(|c| c.set(c.get() + 1)); + } let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4); let tmp_y = obmc_neighbour_pred(ny, px, py + oy, nb.mv, bw, bh, true, h_kind, v_kind, nb_scale); obmc_blend_h(pred_y, side, 0, oy, bw, bh.min(write_h - oy), &tmp_y); diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index aa935653..9d1c0b80 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -30472,10 +30472,15 @@ mod tests { // lane-t900 r10: the rect warp top-right reach (600 blocks here). let tr_before = crate::decode::tr_reach_longer_side_hits(); let i16_before = crate::decode::intra16x4_in_inter_hits(); + // lane-t900 r14: OBMC neighbour strips that run past the frame edge + // (792 luma rows = 198 mi rows, so every bottom-row 32x32 block + // overhangs) -- the shape whose prediction size used to be clamped. + let edge_before = crate::decode::obmc_edge_span_hits(); let frames = match decode_stream(&stream) { Ok(frames) => frames, Err(e) => panic!("{NAME}: decode_stream refused: {e}"), }; + let obmc_edge_span = crate::decode::obmc_edge_span_hits() - edge_before; let fired = ( crate::decode::warp_plane_suppress_hits() - before.0, crate::decode::cdef_idx_hits() - before.1, @@ -30508,6 +30513,7 @@ mod tests { ("sub8_chroma_tx_from_ref", sub8tx), ("inter_neighbour_not_smooth", notsmooth), ("tr_reach_longer_side", tr), + ("obmc_edge_span", obmc_edge_span), ] { assert!( n > 0, @@ -30534,7 +30540,7 @@ mod tests { cdef_idx={} inter_sb128_vert={} interintra_rect={} non_chroma_ref_ctx_skip={} \ intra_in_inter_txctx={} edge_filter_mi_fix={} intra16x4_in_inter={:?} \ sub8_chroma_tx_from_ref={sub8tx} inter_neighbour_not_smooth={notsmooth} \ - tr_reach_longer_side={tr}", + tr_reach_longer_side={tr} obmc_edge_span={obmc_edge_span}", fired.0, fired.1, fired.2, fired.3, fired.4, fired.5, fired.6, i16 ); }