Merge branch 'lane-t900' (f6bdfef0): scaled-reference (superres) prediction for 8x8 leaves, sub-8x8 blocks and warp fallback; motion_mode alphabet shrinks under a scaled reference; all three superres refusals lifted and gated
Browse files at this commit5 changed files +322 -74
- crates/ec-av1/examples/decode_probe.rs +7 -0
- crates/ec-av1/src/decode.rs +123 -55
- crates/ec-av1/src/mc.rs +32 -0
- crates/ec-av1/src/refusal_inventory.rs +6 -15
- crates/ec-av1/src/stream.rs +154 -4
crates/ec-av1/examples/decode_probe.rsmodified+7 -0
| @@ -140,6 +140,13 @@ fn main() { | ||
| 140 | 140 | ); |
| 141 | 141 | // lane-t900 r12: chroma edge-filter neighbour answered from the mi-granular |
| 142 | 142 | // 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 | + ); | |
| 143 | 150 | println!( |
| 144 | 151 | "uv_mode_grid_override: {}", |
| 145 | 152 | 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 { | ||
| 2068 | 2068 | } |
| 2069 | 2069 | |
| 2070 | 2070 | /// Current value of [`SCALED_WARP_FALLBACK_HITS`]. |
| 2071 | -pub(crate) fn scaled_warp_fallback_hits() -> usize { | |
| 2071 | +pub fn scaled_warp_fallback_hits() -> usize { | |
| 2072 | 2072 | SCALED_WARP_FALLBACK_HITS.with(|c| c.get()) |
| 2073 | 2073 | } |
| 2074 | 2074 | |
| @@ -2499,6 +2499,32 @@ pub(crate) fn inter_sub16_split_hits() -> usize { | ||
| 2499 | 2499 | INTER_SUB16_SPLIT_HITS.with(|c| c.get()) |
| 2500 | 2500 | } |
| 2501 | 2501 | |
| 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 | + | |
| 2502 | 2528 | // lane-rectwire r2: how many `PARTITION_HORZ`/`VERT` strips actually decoded |
| 2503 | 2529 | // real (non-skip) coefficients through [`read_coeffs_rect`] -- proves the |
| 2504 | 2530 | // rect coefficient reader itself fired, not just the strip-level partition |
| @@ -21100,8 +21126,20 @@ fn decode_inter_block( | ||
| 21100 | 21126 | None |
| 21101 | 21127 | } |
| 21102 | 21128 | }; |
| 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)); | |
| 21105 | 21143 | if warp0.is_some() || warp1.is_some() { |
| 21106 | 21144 | COMPOUND_WARP_HITS.with(|c| c.set(c.get() + 1)); |
| 21107 | 21145 | } |
| @@ -22710,18 +22748,13 @@ fn decode_inter_block( | ||
| 22710 | 22748 | // lane-scaledref r1: libaom `allow_warp` |
| 22711 | 22749 | // (av1/common/reconinter.c:41) suppresses BOTH local and |
| 22712 | 22750 | // 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. | |
| 22720 | 22756 | if warp_params.is_some() { |
| 22721 | 22757 | 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 | - )); | |
| 22725 | 22758 | } |
| 22726 | 22759 | if obmc_selected { |
| 22727 | 22760 | SCALED_OBMC_HITS.with(|c| c.set(c.get() + 1)); |
| @@ -22940,19 +22973,25 @@ fn decode_inter_block( | ||
| 22940 | 22973 | // through to the ordinary whole-block predictor. |
| 22941 | 22974 | if let Some(s) = strip_chroma.filter(|s| s.has_chroma) |
| 22942 | 22975 | && let Some((prev_ref, prev_mv, prev_h, prev_v)) = s.prev |
| 22943 | - && luma_scale == mc::REF_NO_SCALE | |
| 22944 | 22976 | { |
| 22945 | 22977 | 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); | |
| 22947 | 22985 | for (src, dst) in [(prev_u, &mut pred_u), (prev_v_plane, &mut pred_v)] { |
| 22948 | 22986 | let mut piece = vec![0u16; piece_w * piece_h]; |
| 22949 | - mc::predict_with_filters( | |
| 22987 | + mc::predict_maybe_scaled( | |
| 22950 | 22988 | &src.data, |
| 22951 | 22989 | src.width, |
| 22952 | 22990 | src.true_width, |
| 22953 | 22991 | src.true_height, |
| 22954 | 22992 | mv_to_q4(cpx, prev_mv.1, false), |
| 22955 | 22993 | mv_to_q4(cpy, prev_mv.0, false), |
| 22994 | + prev_scale, | |
| 22956 | 22995 | piece_w, |
| 22957 | 22996 | piece_h, |
| 22958 | 22997 | prev_h, |
| @@ -24447,10 +24486,13 @@ fn decode_inter_sub8_split4( | ||
| 24447 | 24486 | neighbours.left_ref1[rmi], |
| 24448 | 24487 | ); |
| 24449 | 24488 | 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)); | |
| 24454 | 24496 | } |
| 24455 | 24497 | let gm_table = build_gm_mv_table( |
| 24456 | 24498 | global_motion, |
| @@ -24612,13 +24654,14 @@ fn decode_inter_sub8_split4( | ||
| 24612 | 24654 | ); |
| 24613 | 24655 | piece[i] = Some((ref_frame, mv, h_filter, v_filter)); |
| 24614 | 24656 | let mut pred_y = vec![0u16; B4 * B4]; |
| 24615 | - mc::predict_with_filters( | |
| 24657 | + mc::predict_maybe_scaled( | |
| 24616 | 24658 | &sref_y.data, |
| 24617 | 24659 | sref_y.width, |
| 24618 | 24660 | sref_y.true_width, |
| 24619 | 24661 | sref_y.true_height, |
| 24620 | 24662 | mv_to_q4(px, mv.1, true), |
| 24621 | 24663 | mv_to_q4(py, mv.0, true), |
| 24664 | + luma_scale, | |
| 24622 | 24665 | B4, |
| 24623 | 24666 | B4, |
| 24624 | 24667 | h_filter, |
| @@ -24711,7 +24754,9 @@ fn decode_inter_sub8_split4( | ||
| 24711 | 24754 | let Some((ref_frame, mv, h_filter, v_filter)) = piece[i] else { |
| 24712 | 24755 | continue; |
| 24713 | 24756 | }; |
| 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); | |
| 24715 | 24760 | let (ox, oy) = if mixed { |
| 24716 | 24761 | (cpx, cpy) |
| 24717 | 24762 | } else { |
| @@ -24721,13 +24766,14 @@ fn decode_inter_sub8_split4( | ||
| 24721 | 24766 | let (row0, col0) = if mixed { (0, 0) } else { (dr * 2, dc * 2) }; |
| 24722 | 24767 | for (plane, dst) in [(sref_u, &mut pred_u), (sref_v, &mut pred_v)] { |
| 24723 | 24768 | let mut buf = vec![0u16; pw * ph]; |
| 24724 | - mc::predict_with_filters( | |
| 24769 | + mc::predict_maybe_scaled( | |
| 24725 | 24770 | &plane.data, |
| 24726 | 24771 | plane.width, |
| 24727 | 24772 | plane.true_width, |
| 24728 | 24773 | plane.true_height, |
| 24729 | 24774 | mv_to_q4(ox, mv.1, false), |
| 24730 | 24775 | mv_to_q4(oy, mv.0, false), |
| 24776 | + piece_scale, | |
| 24731 | 24777 | pw, |
| 24732 | 24778 | ph, |
| 24733 | 24779 | h_filter, |
| @@ -25415,10 +25461,10 @@ fn decode_inter_sub8_rect2( | ||
| 25415 | 25461 | neighbours.left_ref1[rmi], |
| 25416 | 25462 | ); |
| 25417 | 25463 | 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)); | |
| 25422 | 25468 | } |
| 25423 | 25469 | let gm_table = build_gm_mv_table( |
| 25424 | 25470 | global_motion, |
| @@ -25581,13 +25627,14 @@ fn decode_inter_sub8_rect2( | ||
| 25581 | 25627 | let mut pred_y = vec![0u16; SIDE * SIDE]; |
| 25582 | 25628 | { |
| 25583 | 25629 | let mut dense = vec![0u16; bw * bh]; |
| 25584 | - mc::predict_with_filters( | |
| 25630 | + mc::predict_maybe_scaled( | |
| 25585 | 25631 | &sref_y.data, |
| 25586 | 25632 | sref_y.width, |
| 25587 | 25633 | sref_y.true_width, |
| 25588 | 25634 | sref_y.true_height, |
| 25589 | 25635 | mv_to_q4(px, mv.1, true), |
| 25590 | 25636 | mv_to_q4(py, mv.0, true), |
| 25637 | + luma_scale, | |
| 25591 | 25638 | bw, |
| 25592 | 25639 | bh, |
| 25593 | 25640 | h_filter, |
| @@ -25724,7 +25771,9 @@ fn decode_inter_sub8_rect2( | ||
| 25724 | 25771 | let Some((ref_frame, mv, h_filter, v_filter)) = piece[i] else { |
| 25725 | 25772 | continue; |
| 25726 | 25773 | }; |
| 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); | |
| 25728 | 25777 | let (ox, oy) = if mixed { |
| 25729 | 25778 | (cpx, cpy) |
| 25730 | 25779 | } else if vert { |
| @@ -25741,13 +25790,14 @@ fn decode_inter_sub8_rect2( | ||
| 25741 | 25790 | }; |
| 25742 | 25791 | for (plane, dst) in [(sref_u, &mut pred_u), (sref_v, &mut pred_v)] { |
| 25743 | 25792 | let mut buf = vec![0u16; piece_w * piece_h]; |
| 25744 | - mc::predict_with_filters( | |
| 25793 | + mc::predict_maybe_scaled( | |
| 25745 | 25794 | &plane.data, |
| 25746 | 25795 | plane.width, |
| 25747 | 25796 | plane.true_width, |
| 25748 | 25797 | plane.true_height, |
| 25749 | 25798 | mv_to_q4(ox, mv.1, false), |
| 25750 | 25799 | mv_to_q4(oy, mv.0, false), |
| 25800 | + piece_scale, | |
| 25751 | 25801 | piece_w, |
| 25752 | 25802 | piece_h, |
| 25753 | 25803 | h_filter, |
| @@ -26394,8 +26444,18 @@ fn decode_inter_block8( | ||
| 26394 | 26444 | None |
| 26395 | 26445 | } |
| 26396 | 26446 | }; |
| 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)); | |
| 26399 | 26459 | if warp0_c.is_some() || warp1_c.is_some() { |
| 26400 | 26460 | COMPOUND_WARP_HITS.with(|c| c.set(c.get() + 1)); |
| 26401 | 26461 | COMPOUND_WARP_HITS_8.with(|c| c.set(c.get() + 1)); |
| @@ -26929,8 +26989,24 @@ fn decode_inter_block8( | ||
| 26929 | 26989 | // (class wrong-alphabet-same-value). |
| 26930 | 26990 | let proj_ok = |
| 26931 | 26991 | 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 { | |
| 26934 | 27010 | FIMV_ALPHABET_HITS.with(|c| c.set(c.get() + 1)); |
| 26935 | 27011 | } |
| 26936 | 27012 | if warp_eligible { |
| @@ -27139,7 +27215,11 @@ fn decode_inter_block8( | ||
| 27139 | 27215 | // lane-gmaffine r1: the warp filter REPLACES the translational |
| 27140 | 27216 | // prediction just built (libaom builds one or the other), same as |
| 27141 | 27217 | // 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) { | |
| 27143 | 27223 | crate::warp::warp_affine( |
| 27144 | 27224 | params, &sref_y.data, sref_y.true_width as i32, sref_y.true_height as i32, |
| 27145 | 27225 | 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( | ||
| 29525 | 29605 | .map(|i| (mi_row0 + (i / 2) * 2, mi_col0 + (i % 2) * 2)) |
| 29526 | 29606 | .filter(|&(mr, mc)| mr < mi_rows && mc < mi_cols) |
| 29527 | 29607 | .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. | |
| 29545 | 29615 | if ref_y.width != frame_width as usize |
| 29546 | 29616 | || ref_slots.iter().flatten().any(|(py, _, _)| { |
| 29547 | 29617 | py.width != frame_width as usize |
| 29548 | 29618 | }) |
| 29549 | 29619 | { |
| 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)); | |
| 29553 | 29621 | } |
| 29554 | 29622 | let mut prev_leaves: Vec<((usize, usize), bool, bool, i8, Option<i8>)> = Vec::new(); |
| 29555 | 29623 | for (mr, mc) in leaf_positions { |
crates/ec-av1/src/mc.rsmodified+32 -0
| @@ -874,6 +874,38 @@ pub fn predict_scaled_kern( | ||
| 874 | 874 | }); |
| 875 | 875 | } |
| 876 | 876 | |
| 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 | + | |
| 877 | 909 | /// `InterRound1` for a compound ref (spec 7.11.3.2's `isCompound` branch, |
| 878 | 910 | /// `COMPOUND_ROUND1_BITS` in libaom's `convolve.h`): 4 bits shallower than |
| 879 | 911 | /// [`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] = &[ | ||
| 32 | 32 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", |
| 33 | 33 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)", |
| 34 | 34 | "an OBMC neighbour whose switchable interp filter was never recorded", |
| 35 | - "a sub-8x8 inter block under a scaled reference (superres, unimplemented)", | |
| 36 | 35 | "a rectangular inter luma transform unit whose shape has no coefficient table set here", |
| 37 | 36 | "a rectangular inter chroma transform unit whose shape has no coefficient table set here", |
| 38 | 37 | "a rectangular transform unit whose shape has no coefficient scan table here", |
| @@ -142,8 +141,6 @@ const REFUSALS: &[&str] = &[ | ||
| 142 | 141 | // source, and screen content in the forced bands with a NON-screen |
| 143 | 142 | // interior. |
| 144 | 143 | "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)", | |
| 147 | 144 | "a motion_mode symbol for a block shape with no CDF row here", |
| 148 | 145 | ]; |
| 149 | 146 | |
| @@ -349,18 +346,12 @@ const PROVEN: &[(&str, &str)] = &[ | ||
| 349 | 346 | "an OBMC neighbour whose switchable interp filter was never recorded", |
| 350 | 347 | "every_inter_record_publishes_an_obmc_readable_filter", |
| 351 | 348 | ), |
| 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. | |
| 364 | 355 | ( |
| 365 | 356 | "a reference picture whose height does not match this frame's own true size", |
| 366 | 357 | "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 { | ||
| 1555 | 1555 | // leaf guard is reached first. Lifting the leaf gap is what makes the |
| 1556 | 1556 | // other two measurable, so this gate pins the ORDER, not just a count. |
| 1557 | 1557 | 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})" | |
| 1562 | 1565 | ); |
| 1566 | + assert!(decoded > 0, "no superres recipe decoded -- the census is vacuous"); | |
| 1563 | 1567 | } |
| 1564 | 1568 | |
| 1565 | 1569 | /// lane-t900 r25, negative gate: a `show_existing_frame` header naming a |
| @@ -14780,6 +14784,152 @@ mod tests { | ||
| 14780 | 14784 | ); |
| 14781 | 14785 | } |
| 14782 | 14786 | |
| 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 | + | |
| 14783 | 14933 | /// lane-interintra r1: `--enable-interintra-comp=1` streams must DECODE |
| 14784 | 14934 | /// pixel-exact -- the interintra flag/mode/wedge-flag syntax and the |
| 14785 | 14935 | /// non-wedge smooth blend are ported. A refusal naming interintra fails |