forge
Explore
Log in

Don't you dare go Hollow

All three scaled-reference (superres) refusals lifted -- 8x8 leaf, sub-8x8, warp

Browse files at this commit

421ae92cb2d5b8475bef60673b8f3a67a9e45ae5Ahmet Kaan GümüşParent: aa49092
  • feat
    • all three scaled-reference (superres) refusals lifted -- 8x8 leaf, sub-8x8, warp
Show full message
feat(av1): all three scaled-reference (superres) refusals lifted -- 8x8 leaf, sub-8x8, warp

The 8x8-leaf guard's own comment blamed a below-8x8 desync ("a 4th symbol
out of a 3-symbol alphabet"). That premise was stale: deleting the guard
decodes the pinned --superres-denominator=12 stream straight through to the
NEXT refusal. One wrong alphabet was behind all three.

Root cause (class wrong-alphabet-same-value / branch-dropped-as-unreachable):
decode_inter_block8 read the 3-symbol motion_mode row under a SCALED
reference, where libaom motion_mode_allowed makes WARPED_CAUSAL eligible
only if (num_proj_ref >= 1 && (allow_warped_motion && !av1_is_scaled(sf))) --
so the alphabet shrinks to the 2-symbol obmc one (with OBMC off, no symbol
at all). The 16x16+ path already had `&& !ref_is_scaled`; the leaf's own
comment asked whoever lifted the refusal to add it, and nobody could reach
the code to notice. First-bad without it: 96x96 denom-12 warped stream,
decode-order frame 3, luma (15,54), 7652 samples wrong, max 155.

Lifted, each byte-exact vs ffmpeg with its own hit counter:
* "an 8x8 partition leaf under a scaled reference"
* "a sub-8x8 inter block under a scaled reference" (both sub8 readers)
* "warp prediction with a scaled reference" -- its translational fallback
  was already implemented and the refusal sat in FRONT of it (class
  refusal-short-circuits-its-own-code); the r1 mismatch that kept it alive
  was the strip chroma piece below, not the fallback.

Same-shape sweep of "every caller that computes a scaled start position":
* mc::predict_maybe_scaled -- the one dispatch the sub-8x8 luma/chroma
  callers now share instead of hardcoding the unscaled walk.
* the 16x4/4x16 strip's sub-8x8 chroma piece was SKIPPED entirely under a
  scaled reference (silent wrong pixels, no refusal); it now rebuilds from
  the PREVIOUS strip's own reference and that reference's own scale factor.
* allow_warp's scale bail-out was missing at the 8x8-leaf single-ref warp
  and at both compound warp sites (PER SLOT: one tap can be scaled while
  its sibling still warps).

Gate: real_superres_streams_with_sub8_leaf8_and_warp_decode_pixel_exact --
two 96x96 denom-12 streams, every unrelated tool off, pixel-exact vs ffmpeg;
arm A hard-asserts scaled leaf8 + sub8 hits, arm B asserts a WARPED_CAUSAL
eligibility was suppressed by scale. The r27 census now asserts none of the
three strings can come back. Inventory rows removed.
crates/ec-av1/examples/decode_probe.rsmodified+7 -0
@@ -140,6 +140,13 @@ fn main() {
140140 );
141141 // lane-t900 r12: chroma edge-filter neighbour answered from the mi-granular
142142 // uv_mode grid instead of the coarse one-slot-per-column map.
143+ println!(
144+ "scaled: leaf8={} sub8={} warpfb={} predict_scaled={}",
145+ ec_av1::decode::scaled_leaf8_hits(),
146+ ec_av1::decode::scaled_sub8_hits(),
147+ ec_av1::decode::scaled_warp_fallback_hits(),
148+ ec_av1::mc::predict_scaled_hits()
149+ );
143150 println!(
144151 "uv_mode_grid_override: {}",
145152 ec_av1::decode::uv_mode_grid_override_hits()
crates/ec-av1/src/decode.rsmodified+123 -55
@@ -2068,7 +2068,7 @@ pub(crate) fn scaled_compound_hits() -> usize {
20682068 }
20692069
20702070 /// Current value of [`SCALED_WARP_FALLBACK_HITS`].
2071-pub(crate) fn scaled_warp_fallback_hits() -> usize {
2071+pub fn scaled_warp_fallback_hits() -> usize {
20722072 SCALED_WARP_FALLBACK_HITS.with(|c| c.get())
20732073 }
20742074
@@ -2499,6 +2499,32 @@ pub(crate) fn inter_sub16_split_hits() -> usize {
24992499 INTER_SUB16_SPLIT_HITS.with(|c| c.get())
25002500 }
25012501
2502+// lane-t900 r28: how many 16x16 inter splits reached their four 8x8 leaves
2503+// while at least one reference picture was SCALED (superres) -- the counter
2504+// behind the lifted "8x8 partition leaf under a scaled reference" refusal.
2505+thread_local! {
2506+ static SCALED_LEAF8_HITS: std::cell::Cell<usize> =
2507+ const { std::cell::Cell::new(0) };
2508+}
2509+
2510+/// Current value of [`SCALED_LEAF8_HITS`].
2511+pub fn scaled_leaf8_hits() -> usize {
2512+ SCALED_LEAF8_HITS.with(|c| c.get())
2513+}
2514+
2515+// lane-t900 r28: how many sub-8x8 inter blocks (the 4x4 split and the 8x4/4x8
2516+// rect pair) were predicted from a SCALED reference -- the counter behind the
2517+// lifted "sub-8x8 inter block under a scaled reference" refusal.
2518+thread_local! {
2519+ static SCALED_SUB8_HITS: std::cell::Cell<usize> =
2520+ const { std::cell::Cell::new(0) };
2521+}
2522+
2523+/// Current value of [`SCALED_SUB8_HITS`].
2524+pub fn scaled_sub8_hits() -> usize {
2525+ SCALED_SUB8_HITS.with(|c| c.get())
2526+}
2527+
25022528 // lane-rectwire r2: how many `PARTITION_HORZ`/`VERT` strips actually decoded
25032529 // real (non-skip) coefficients through [`read_coeffs_rect`] -- proves the
25042530 // rect coefficient reader itself fired, not just the strip-level partition
@@ -21100,8 +21126,20 @@ fn decode_inter_block(
2110021126 None
2110121127 }
2110221128 };
21103- let warp0 = compound_warp(ref0, is_global_mv0);
21104- let warp1 = compound_warp(ref1, is_global_mv1);
21129+ // lane-t900 r28 (class branch-dropped-as-unreachable, swept out
21130+ // of the scaled-ref lift): libaom `allow_warp`
21131+ // (av1/common/reconinter.c:41) opens with `if (av1_is_scaled(sf))
21132+ // return 0;` PER SLOT, so a compound tap whose own reference is
21133+ // scaled (superres) is predicted translationally while its
21134+ // sibling may still warp.
21135+ let ref_unscaled = |rf: i8| {
21136+ ref_planes(rf, ref_y, ref_u, ref_v, other_refs)
21137+ .is_ok_and(|(py, _, _)| {
21138+ mc::scale_factor(py.width, frame_width) == mc::REF_NO_SCALE
21139+ })
21140+ };
21141+ let warp0 = compound_warp(ref0, is_global_mv0).filter(|_| ref_unscaled(ref0));
21142+ let warp1 = compound_warp(ref1, is_global_mv1).filter(|_| ref_unscaled(ref1));
2110521143 if warp0.is_some() || warp1.is_some() {
2110621144 COMPOUND_WARP_HITS.with(|c| c.set(c.get() + 1));
2110721145 }
@@ -22710,18 +22748,13 @@ fn decode_inter_block(
2271022748 // lane-scaledref r1: libaom `allow_warp`
2271122749 // (av1/common/reconinter.c:41) suppresses BOTH local and
2271222750 // global warp under a scaled reference and predicts
22713- // translationally instead -- that fallback is implemented
22714- // below, but the one real aomenc stream this round found
22715- // that reaches it (`--enable-warped-motion=1`,
22716- // `--superres-denominator=16`, seed 47) still mismatches
22717- // ffmpeg at frame 2 luma, so the case stays refused by name
22718- // until it has a green gate rather than shipping wrong
22719- // pixels behind a lifted refusal.
22751+ // translationally instead -- the fallback below. lane-t900
22752+ // r28 LIFTED the refusal that sat here: the mismatch r1
22753+ // measured was the 16x4/4x16 strip's sub-8x8 chroma piece,
22754+ // which this file used to SKIP under a scaled reference
22755+ // (fixed in the same commit), not the warp fallback.
2272022756 if warp_params.is_some() {
2272122757 SCALED_WARP_FALLBACK_HITS.with(|c| c.set(c.get() + 1));
22722- return Err(unsupported(
22723- "warp prediction with a scaled reference (superres, unimplemented)",
22724- ));
2272522758 }
2272622759 if obmc_selected {
2272722760 SCALED_OBMC_HITS.with(|c| c.set(c.get() + 1));
@@ -22940,19 +22973,25 @@ fn decode_inter_block(
2294022973 // through to the ordinary whole-block predictor.
2294122974 if let Some(s) = strip_chroma.filter(|s| s.has_chroma)
2294222975 && let Some((prev_ref, prev_mv, prev_h, prev_v)) = s.prev
22943- && luma_scale == mc::REF_NO_SCALE
2294422976 {
2294522977 let (piece_w, piece_h) = if s.horz { (8usize, 2usize) } else { (2usize, 8usize) };
22946- let (_, prev_u, prev_v_plane) = ref_planes(prev_ref, ref_y, ref_u, ref_v, other_refs)?;
22978+ // lane-t900 r28 (same-shape sweep of the sub-8x8 scaled-ref
22979+ // lift): this piece used to be SKIPPED when the block's
22980+ // reference was scaled, which silently left the whole-block
22981+ // prediction in place instead of refusing. It scales off the
22982+ // PREVIOUS strip's own reference, not this block's.
22983+ let (prev_y_plane, prev_u, prev_v_plane) = ref_planes(prev_ref, ref_y, ref_u, ref_v, other_refs)?;
22984+ let prev_scale = mc::scale_factor(prev_y_plane.width, frame_width);
2294722985 for (src, dst) in [(prev_u, &mut pred_u), (prev_v_plane, &mut pred_v)] {
2294822986 let mut piece = vec![0u16; piece_w * piece_h];
22949- mc::predict_with_filters(
22987+ mc::predict_maybe_scaled(
2295022988 &src.data,
2295122989 src.width,
2295222990 src.true_width,
2295322991 src.true_height,
2295422992 mv_to_q4(cpx, prev_mv.1, false),
2295522993 mv_to_q4(cpy, prev_mv.0, false),
22994+ prev_scale,
2295622995 piece_w,
2295722996 piece_h,
2295822997 prev_h,
@@ -24447,10 +24486,13 @@ fn decode_inter_sub8_split4(
2444724486 neighbours.left_ref1[rmi],
2444824487 );
2444924488 let (sref_y, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?;
24450- if mc::scale_factor(sref_y.width, frame_width) != mc::REF_NO_SCALE {
24451- return Err(unsupported(
24452- "a sub-8x8 inter block under a scaled reference (superres, unimplemented)",
24453- ));
24489+ // lane-t900 r28: refusal lifted -- this sub-block's own reference may
24490+ // be scaled (superres); spec 7.11.3.3's walk is per reference, and
24491+ // each of the group's pieces (luma and its 2x2 chroma) carries its
24492+ // OWN factor because each can name a different `ref_frame`.
24493+ let luma_scale = mc::scale_factor(sref_y.width, frame_width);
24494+ if luma_scale != mc::REF_NO_SCALE {
24495+ SCALED_SUB8_HITS.with(|c| c.set(c.get() + 1));
2445424496 }
2445524497 let gm_table = build_gm_mv_table(
2445624498 global_motion,
@@ -24612,13 +24654,14 @@ fn decode_inter_sub8_split4(
2461224654 );
2461324655 piece[i] = Some((ref_frame, mv, h_filter, v_filter));
2461424656 let mut pred_y = vec![0u16; B4 * B4];
24615- mc::predict_with_filters(
24657+ mc::predict_maybe_scaled(
2461624658 &sref_y.data,
2461724659 sref_y.width,
2461824660 sref_y.true_width,
2461924661 sref_y.true_height,
2462024662 mv_to_q4(px, mv.1, true),
2462124663 mv_to_q4(py, mv.0, true),
24664+ luma_scale,
2462224665 B4,
2462324666 B4,
2462424667 h_filter,
@@ -24711,7 +24754,9 @@ fn decode_inter_sub8_split4(
2471124754 let Some((ref_frame, mv, h_filter, v_filter)) = piece[i] else {
2471224755 continue;
2471324756 };
24714- let (_, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?;
24757+ let (piece_ref_y, sref_u, sref_v) =
24758+ ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?;
24759+ let piece_scale = mc::scale_factor(piece_ref_y.width, frame_width);
2471524760 let (ox, oy) = if mixed {
2471624761 (cpx, cpy)
2471724762 } else {
@@ -24721,13 +24766,14 @@ fn decode_inter_sub8_split4(
2472124766 let (row0, col0) = if mixed { (0, 0) } else { (dr * 2, dc * 2) };
2472224767 for (plane, dst) in [(sref_u, &mut pred_u), (sref_v, &mut pred_v)] {
2472324768 let mut buf = vec![0u16; pw * ph];
24724- mc::predict_with_filters(
24769+ mc::predict_maybe_scaled(
2472524770 &plane.data,
2472624771 plane.width,
2472724772 plane.true_width,
2472824773 plane.true_height,
2472924774 mv_to_q4(ox, mv.1, false),
2473024775 mv_to_q4(oy, mv.0, false),
24776+ piece_scale,
2473124777 pw,
2473224778 ph,
2473324779 h_filter,
@@ -25415,10 +25461,10 @@ fn decode_inter_sub8_rect2(
2541525461 neighbours.left_ref1[rmi],
2541625462 );
2541725463 let (sref_y, _, _) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?;
25418- if mc::scale_factor(sref_y.width, frame_width) != mc::REF_NO_SCALE {
25419- return Err(unsupported(
25420- "a sub-8x8 inter block under a scaled reference (superres, unimplemented)",
25421- ));
25464+ // lane-t900 r28: refusal lifted -- see the split arm above.
25465+ let luma_scale = mc::scale_factor(sref_y.width, frame_width);
25466+ if luma_scale != mc::REF_NO_SCALE {
25467+ SCALED_SUB8_HITS.with(|c| c.set(c.get() + 1));
2542225468 }
2542325469 let gm_table = build_gm_mv_table(
2542425470 global_motion,
@@ -25581,13 +25627,14 @@ fn decode_inter_sub8_rect2(
2558125627 let mut pred_y = vec![0u16; SIDE * SIDE];
2558225628 {
2558325629 let mut dense = vec![0u16; bw * bh];
25584- mc::predict_with_filters(
25630+ mc::predict_maybe_scaled(
2558525631 &sref_y.data,
2558625632 sref_y.width,
2558725633 sref_y.true_width,
2558825634 sref_y.true_height,
2558925635 mv_to_q4(px, mv.1, true),
2559025636 mv_to_q4(py, mv.0, true),
25637+ luma_scale,
2559125638 bw,
2559225639 bh,
2559325640 h_filter,
@@ -25724,7 +25771,9 @@ fn decode_inter_sub8_rect2(
2572425771 let Some((ref_frame, mv, h_filter, v_filter)) = piece[i] else {
2572525772 continue;
2572625773 };
25727- let (_, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?;
25774+ let (piece_ref_y, sref_u, sref_v) =
25775+ ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?;
25776+ let piece_scale = mc::scale_factor(piece_ref_y.width, frame_width);
2572825777 let (ox, oy) = if mixed {
2572925778 (cpx, cpy)
2573025779 } else if vert {
@@ -25741,13 +25790,14 @@ fn decode_inter_sub8_rect2(
2574125790 };
2574225791 for (plane, dst) in [(sref_u, &mut pred_u), (sref_v, &mut pred_v)] {
2574325792 let mut buf = vec![0u16; piece_w * piece_h];
25744- mc::predict_with_filters(
25793+ mc::predict_maybe_scaled(
2574525794 &plane.data,
2574625795 plane.width,
2574725796 plane.true_width,
2574825797 plane.true_height,
2574925798 mv_to_q4(ox, mv.1, false),
2575025799 mv_to_q4(oy, mv.0, false),
25800+ piece_scale,
2575125801 piece_w,
2575225802 piece_h,
2575325803 h_filter,
@@ -26394,8 +26444,18 @@ fn decode_inter_block8(
2639426444 None
2639526445 }
2639626446 };
26397- let warp0_c = leaf_compound_warp(ref0, is_global_mv0_c);
26398- let warp1_c = leaf_compound_warp(ref1, is_global_mv1_c);
26447+ // lane-t900 r28: same per-slot `allow_warp` scale bail-out as
26448+ // the 16x16-and-bigger compound path above.
26449+ let leaf_ref_unscaled = |rf: i8| {
26450+ ref_planes(rf, ref_y, ref_u, ref_v, other_refs)
26451+ .is_ok_and(|(py, _, _)| {
26452+ mc::scale_factor(py.width, frame_width) == mc::REF_NO_SCALE
26453+ })
26454+ };
26455+ let warp0_c =
26456+ leaf_compound_warp(ref0, is_global_mv0_c).filter(|_| leaf_ref_unscaled(ref0));
26457+ let warp1_c =
26458+ leaf_compound_warp(ref1, is_global_mv1_c).filter(|_| leaf_ref_unscaled(ref1));
2639926459 if warp0_c.is_some() || warp1_c.is_some() {
2640026460 COMPOUND_WARP_HITS.with(|c| c.set(c.get() + 1));
2640126461 COMPOUND_WARP_HITS_8.with(|c| c.set(c.get() + 1));
@@ -26929,8 +26989,24 @@ fn decode_inter_block8(
2692926989 // (class wrong-alphabet-same-value).
2693026990 let proj_ok =
2693126991 num_proj_ref(grid, mi_row, mi_col, 2, 2, mi_cols as usize, mi_rows as usize, ref_frame) >= 1;
26932- let warp_eligible = allow_warped_motion && !force_integer_mv && proj_ok;
26933- if allow_warped_motion && proj_ok && force_integer_mv {
26992+ // lane-t900 r28: the `&& !ref_is_scaled` the note above asked the
26993+ // lifter of the 8x8-leaf refusal to add. libaom
26994+ // `motion_mode_allowed` (blockd.h) makes WARPED_CAUSAL eligible
26995+ // only `if (mbmi->num_proj_ref >= 1 && (allow_warped_motion &&
26996+ // !av1_is_scaled(xd->block_ref_scale_factors[0])))`, so under a
26997+ // scaled reference the ALPHABET shrinks to the 2-symbol obmc one
26998+ // -- and with OBMC off no symbol is read at all (class
26999+ // wrong-alphabet-same-value: reading the 3-symbol row here
27000+ // desynced every warped-motion superres stream at its first
27001+ // eligible 8x8 leaf).
27002+ let ref_is_scaled =
27003+ mc::scale_factor(sref_y.width, frame_width) != mc::REF_NO_SCALE;
27004+ let warp_eligible =
27005+ allow_warped_motion && !ref_is_scaled && !force_integer_mv && proj_ok;
27006+ if allow_warped_motion && proj_ok && ref_is_scaled {
27007+ SCALED_WARP_SUPPRESSED_HITS.with(|c| c.set(c.get() + 1));
27008+ }
27009+ if allow_warped_motion && proj_ok && !ref_is_scaled && force_integer_mv {
2693427010 FIMV_ALPHABET_HITS.with(|c| c.set(c.get() + 1));
2693527011 }
2693627012 if warp_eligible {
@@ -27139,7 +27215,11 @@ fn decode_inter_block8(
2713927215 // lane-gmaffine r1: the warp filter REPLACES the translational
2714027216 // prediction just built (libaom builds one or the other), same as
2714127217 // the 16x16+ leaf's own call trio.
27142- if let Some(params) = &warp_params {
27218+ // lane-t900 r28: `allow_warp`'s scaled-reference bail-out, which this
27219+ // leaf was missing -- it is the defect the 8x8-leaf refusal hid (a
27220+ // warped 8x8 leaf over a superres reference; libaom predicts it
27221+ // translationally, every symbol still read).
27222+ if let Some(params) = warp_params.as_ref().filter(|_| luma_scale == mc::REF_NO_SCALE) {
2714327223 crate::warp::warp_affine(
2714427224 params, &sref_y.data, sref_y.true_width as i32, sref_y.true_height as i32,
2714527225 sref_y.width as i32, &mut pred_y, px as i32, py as i32, SIDE as i32,
@@ -29525,31 +29605,19 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2952529605 .map(|i| (mi_row0 + (i / 2) * 2, mi_col0 + (i % 2) * 2))
2952629606 .filter(|&(mr, mc)| mr < mi_rows && mc < mi_cols)
2952729607 .collect();
29528- // lane-scaledref r1: `decode_inter_block8` IS
29529- // threaded for a scaled reference now (its
29530- // single-ref, compound and OBMC MC all take
29531- // spec 7.11.3.3's scaled walk), but the one
29532- // recipe that reaches this path at all -- a
29533- // 64x72 superres fixture whose bottom 16-row
29534- // band straddles the true edge, so the
29535- // gathered split bit lands on 8x8 leaves --
29536- // DESYNCS inside the leaf itself
29537- // (`from_switchable_symbol` handed a 4th
29538- // symbol, mc.rs:200), the same
29539- // below-8x8 desync lane-sub8 r2 left open and
29540- // unrelated to scaling. So the scaled MC here
29541- // is unproven: refuse by name rather than
29542- // ship a capability claim no gate exercises.
29543- // Deleting these six lines is the whole lift
29544- // once the leaf8 desync is fixed.
29608+ // lane-t900 r28: the 8x8-leaf refusal under a
29609+ // scaled reference is LIFTED --
29610+ // `decode_inter_block8`'s single-ref,
29611+ // compound and OBMC MC all take spec
29612+ // 7.11.3.3's scaled walk. The counter is what
29613+ // proves a gate actually reached a scaled
29614+ // leaf rather than a same-size reference.
2954529615 if ref_y.width != frame_width as usize
2954629616 || ref_slots.iter().flatten().any(|(py, _, _)| {
2954729617 py.width != frame_width as usize
2954829618 })
2954929619 {
29550- return Err(unsupported(
29551- "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
29552- ));
29620+ SCALED_LEAF8_HITS.with(|c| c.set(c.get() + 1));
2955329621 }
2955429622 let mut prev_leaves: Vec<((usize, usize), bool, bool, i8, Option<i8>)> = Vec::new();
2955529623 for (mr, mc) in leaf_positions {
crates/ec-av1/src/mc.rsmodified+32 -0
@@ -874,6 +874,38 @@ pub fn predict_scaled_kern(
874874 });
875875 }
876876
877+/// [`predict_with_filters`] or [`predict_scaled`], on this reference's own
878+/// `x_scale_fp` -- the dispatch every inter path needs once a reference can be
879+/// scaled (superres). `REF_NO_SCALE` takes the ordinary stride-1 path, which
880+/// keeps [`predict_scaled_hits`] a true count of scaled predictions.
881+#[allow(clippy::too_many_arguments)]
882+pub fn predict_maybe_scaled(
883+ reference: &[u16],
884+ stride: usize,
885+ true_width: usize,
886+ true_height: usize,
887+ x_q4: i32,
888+ y_q4: i32,
889+ x_scale_fp: i64,
890+ block_w: usize,
891+ block_h: usize,
892+ h_kind: InterpFilterKind,
893+ v_kind: InterpFilterKind,
894+ dst: &mut [u16],
895+) {
896+ if x_scale_fp == REF_NO_SCALE {
897+ predict_with_filters(
898+ reference, stride, true_width, true_height, x_q4, y_q4, block_w, block_h, h_kind,
899+ v_kind, dst,
900+ );
901+ } else {
902+ predict_scaled(
903+ reference, stride, true_width, true_height, x_q4, y_q4, x_scale_fp, block_w,
904+ block_h, h_kind, v_kind, dst,
905+ );
906+ }
907+}
908+
877909 /// `InterRound1` for a compound ref (spec 7.11.3.2's `isCompound` branch,
878910 /// `COMPOUND_ROUND1_BITS` in libaom's `convolve.h`): 4 bits shallower than
879911 /// [`INTER_ROUND_1`] so the vertical pass lands in the `CONV_BUF` domain
crates/ec-av1/src/refusal_inventory.rsmodified+6 -15
@@ -32,7 +32,6 @@ const REFUSALS: &[&str] = &[
3232 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
3333 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)",
3434 "an OBMC neighbour whose switchable interp filter was never recorded",
35- "a sub-8x8 inter block under a scaled reference (superres, unimplemented)",
3635 "a rectangular inter luma transform unit whose shape has no coefficient table set here",
3736 "a rectangular inter chroma transform unit whose shape has no coefficient table set here",
3837 "a rectangular transform unit whose shape has no coefficient scan table here",
@@ -142,8 +141,6 @@ const REFUSALS: &[&str] = &[
142141 // source, and screen content in the forced bands with a NON-screen
143142 // interior.
144143 "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)",
145- "warp prediction with a scaled reference (superres, unimplemented)",
146- "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
147144 "a motion_mode symbol for a block shape with no CDF row here",
148145 ];
149146
@@ -349,18 +346,12 @@ const PROVEN: &[(&str, &str)] = &[
349346 "an OBMC neighbour whose switchable interp filter was never recorded",
350347 "every_inter_record_publishes_an_obmc_readable_filter",
351348 ),
352- // lane-t900 r27, census: this one is a REAL capability gap, and the gate
353- // proves it fires by name on real streams -- four fixed-denominator
354- // `--superres-mode=1` encodes (denoms 10/12/16, warped motion and OBMC
355- // on) all stop here, while the two `--superres-mode=3` auto encodes pick
356- // denominator 8 and carry no scaling at all. Its two siblings ("warp
357- // prediction with a scaled reference", "a sub-8x8 inter block under a
358- // scaled reference") stay UNPROVEN: this refusal sits in front of them,
359- // so nothing measures them until the 8x8-leaf gap is lifted.
360- (
361- "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
362- "a_superres_census_over_six_real_streams_records_which_scaled_refusals_fire",
363- ),
349+ // lane-t900 r28: all three scaled-reference (superres) refusals -- the
350+ // 8x8 partition leaf, the sub-8x8 inter block and warp -- are LIFTED and
351+ // gone from this inventory. The gate
352+ // `real_superres_streams_with_sub8_leaf8_and_warp_decode_pixel_exact`
353+ // decodes both lifted shapes byte-exact vs ffmpeg, and the census now
354+ // asserts none of the three strings comes back.
364355 (
365356 "a reference picture whose height does not match this frame's own true size",
366357 "an_inter_frame_shorter_than_its_reference_is_refused_by_name",
crates/ec-av1/src/stream.rsmodified+154 -4
@@ -1555,11 +1555,15 @@ mod tests {
15551555 // leaf guard is reached first. Lifting the leaf gap is what makes the
15561556 // other two measurable, so this gate pins the ORDER, not just a count.
15571557 assert!(decoded > 0, "no superres recipe decoded -- the census is vacuous");
1558- assert!(
1559- leaf8 > 0,
1560- "no fixed-denominator recipe reached the 8x8-leaf refusal any more: either the \
1561- capability landed (drop the refusal) or the recipes stopped scaling"
1558+ // lane-t900 r28: all three scaled refusals are LIFTED, so the census
1559+ // now pins the opposite shape -- every fixed-denominator recipe must
1560+ // DECODE, and none of the three strings may come back.
1561+ assert_eq!(
1562+ (warp, sub8, leaf8),
1563+ (0, 0, 0),
1564+ "a scaled-reference refusal came back (warp {warp}, sub8 {sub8}, leaf8 {leaf8})"
15621565 );
1566+ assert!(decoded > 0, "no superres recipe decoded -- the census is vacuous");
15631567 }
15641568
15651569 /// lane-t900 r25, negative gate: a `show_existing_frame` header naming a
@@ -14780,6 +14784,152 @@ mod tests {
1478014784 );
1478114785 }
1478214786
14787+ /// lane-t900 r28: the three scaled-reference (superres) refusals are
14788+ /// LIFTED -- an 8x8 partition leaf, a sub-8x8 inter block, and warp --
14789+ /// so two real `--superres-mode=1` streams whose references are all
14790+ /// scaled must decode PIXEL-EXACT vs ffmpeg.
14791+ ///
14792+ /// Arm A drives `--min-partition-size=4` so the split (4x4) and rect
14793+ /// (8x4/4x8) sub-8x8 readers and the 8x8 leaf all run over a scaled
14794+ /// reference; arm B turns `--enable-warped-motion=1` on, which is the
14795+ /// root cause this round fixed: libaom `motion_mode_allowed` drops
14796+ /// WARPED_CAUSAL eligibility when `av1_is_scaled(sf)`, so the 8x8 leaf
14797+ /// must read the 2-symbol obmc alphabet (here: no symbol at all, OBMC
14798+ /// off) instead of the 3-symbol motion_mode row.
14799+ ///
14800+ /// Each arm hard-asserts its own counter (class `gate-blind-to-feature`):
14801+ /// a pixel match with zero scaled leaves/sub-8x8 blocks/suppressed warp
14802+ /// eligibilities would prove nothing.
14803+ #[test]
14804+ fn real_superres_streams_with_sub8_leaf8_and_warp_decode_pixel_exact() {
14805+ const NAME: &str = "real_superres_streams_with_sub8_leaf8_and_warp_decode_pixel_exact";
14806+ let _gate_lock = lock_gate_counters();
14807+ if !have_ffmpeg() {
14808+ eprintln!("SKIP {NAME}: no ffmpeg");
14809+ return;
14810+ }
14811+ if !have_aomenc() {
14812+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
14813+ return;
14814+ }
14815+ // Every tool whose scaled-reference path this round does NOT touch is
14816+ // off, so a mismatch can only be the lifted paths (the same scoping
14817+ // the r10 key+inter superres gate uses).
14818+ let common: [&str; 21] = [
14819+ "--codec=av1", "--passes=1", "--end-usage=q", "--threads=1", "--row-mt=0",
14820+ "--kf-max-dist=9999", "--lag-in-frames=0", "--auto-alt-ref=0", "--cpu-used=0",
14821+ "--sb-size=64", "--superres-mode=1", "--superres-denominator=12",
14822+ "--superres-kf-denominator=12", "--enable-obmc=0", "--enable-masked-comp=0",
14823+ "--enable-interintra-comp=0", "--enable-tx-size-search=0", "--enable-cdef=0",
14824+ "--enable-restoration=0", "--enable-palette=0", "--enable-intrabc=0",
14825+ ];
14826+ struct Arm {
14827+ name: &'static str,
14828+ frames: usize,
14829+ cq: &'static str,
14830+ extra: [&'static str; 4],
14831+ }
14832+ let arms = [
14833+ Arm {
14834+ name: "sub8+leaf8",
14835+ frames: 4,
14836+ cq: "--cq-level=4",
14837+ extra: [
14838+ "--enable-warped-motion=0",
14839+ "--enable-rect-partitions=1",
14840+ "--max-partition-size=32",
14841+ "--min-partition-size=4",
14842+ ],
14843+ },
14844+ Arm {
14845+ name: "warp",
14846+ frames: 6,
14847+ cq: "--cq-level=20",
14848+ extra: [
14849+ "--enable-warped-motion=1",
14850+ "--enable-rect-partitions=1",
14851+ "--max-partition-size=32",
14852+ "--min-partition-size=8",
14853+ ],
14854+ },
14855+ ];
14856+ let (width, height) = (96usize, 96usize);
14857+ for arm in &arms {
14858+ let duration = format!("{}", arm.frames as f64 / 25.0);
14859+ let src = format!("mandelbrot=size={width}x{height}:rate=25");
14860+ let y4m = Command::new("ffmpeg")
14861+ .args([
14862+ "-v", "error", "-f", "lavfi", "-i", &src, "-t", &duration, "-pix_fmt",
14863+ "yuv420p", "-strict", "-1", "-f", "yuv4mpegpipe", "-",
14864+ ])
14865+ .stdin(Stdio::null())
14866+ .stdout(Stdio::piped())
14867+ .stderr(Stdio::piped())
14868+ .output()
14869+ .expect("ffmpeg failed to run");
14870+ assert!(y4m.status.success(), "{NAME}: ffmpeg refused the fixture");
14871+ let limit = format!("--limit={}", arm.frames);
14872+ let mut args: Vec<&str> = common.to_vec();
14873+ args.push(&limit);
14874+ args.push(arm.cq);
14875+ args.extend_from_slice(&arm.extra);
14876+ args.extend_from_slice(&["--obu", "-o", "-", "-"]);
14877+ let mut child = Command::new(aomenc_path())
14878+ .args(&args)
14879+ .stdin(Stdio::piped())
14880+ .stdout(Stdio::piped())
14881+ .stderr(Stdio::piped())
14882+ .spawn()
14883+ .expect("aomenc failed to start");
14884+ child
14885+ .stdin
14886+ .take()
14887+ .expect("aomenc stdin")
14888+ .write_all(&y4m.stdout)
14889+ .expect("writing y4m to aomenc");
14890+ let out = child.wait_with_output().expect("aomenc failed to run");
14891+ assert!(
14892+ out.status.success(),
14893+ "{NAME} {}: aomenc refused the recipe: {}",
14894+ arm.name,
14895+ String::from_utf8_lossy(&out.stderr)
14896+ );
14897+ let stream = out.stdout;
14898+ let leaf8_before = crate::decode::scaled_leaf8_hits();
14899+ let sub8_before = crate::decode::scaled_sub8_hits();
14900+ let warp_before = crate::decode::scaled_warp_suppressed_hits();
14901+ let frames = decode_stream(&stream)
14902+ .unwrap_or_else(|e| panic!("{NAME} {}: refused: {e}", arm.name));
14903+ assert_eq!(frames.len(), arm.frames, "{NAME} {}", arm.name);
14904+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, arm.frames);
14905+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
14906+ assert_eq!(got.y, want.y, "{NAME} {} frame {i} luma vs ffmpeg", arm.name);
14907+ assert_eq!(got.u, want.u, "{NAME} {} frame {i} U vs ffmpeg", arm.name);
14908+ assert_eq!(got.v, want.v, "{NAME} {} frame {i} V vs ffmpeg", arm.name);
14909+ }
14910+ let (leaf8, sub8, warp) = (
14911+ crate::decode::scaled_leaf8_hits() - leaf8_before,
14912+ crate::decode::scaled_sub8_hits() - sub8_before,
14913+ crate::decode::scaled_warp_suppressed_hits() - warp_before,
14914+ );
14915+ eprintln!(
14916+ "{NAME} {}: {} frames pixel-exact, scaled leaf8={leaf8} sub8={sub8} \
14917+ warp_suppressed={warp}",
14918+ arm.name, arm.frames
14919+ );
14920+ if arm.name == "sub8+leaf8" {
14921+ assert!(leaf8 > 0 && sub8 > 0, "{NAME} {}: the lifted paths never ran (leaf8={leaf8} sub8={sub8})", arm.name);
14922+ } else {
14923+ assert!(
14924+ warp > 0,
14925+ "{NAME} {}: no block reached WARPED_CAUSAL eligibility under a scaled \
14926+ reference, so the alphabet fix is unexercised",
14927+ arm.name
14928+ );
14929+ }
14930+ }
14931+ }
14932+
1478314933 /// lane-interintra r1: `--enable-interintra-comp=1` streams must DECODE
1478414934 /// pixel-exact -- the interintra flag/mode/wedge-flag syntax and the
1478514935 /// non-wedge smooth blend are ported. A refusal naming interintra fails