forge
Explore
Log in

Don't you dare go Hollow

Mv-stack single-ref predictor falls back to global motion, not zero

Browse files at this commit

43e5d8c984a48c1be0035791d50c554444db542aAhmet Kaan GümüşParent: 42d6aa0
  • fix
    • mv-stack single-ref predictor falls back to global motion, not zero
Show full message
fix(av1): mv-stack single-ref predictor falls back to global motion, not zero

Root cause of lane-gm r4/r5's "more than one concurrently active
ROTZOOM/AFFINE ref slot" refusal, found by range-laddering the r5 pin
against a new aomdec EC_TRACE_MODE instrument: libaom's
setup_ref_mv_list fills any mv_ref_list slot the neighbour scan left
short with gm_get_motion_vector for that block's own ref, not zero.
Our find_mv_stack_with_sign_bias used (0, 0) -- invisible whenever the
live ref's global motion is itself identity/translation, wrong the
moment it's a real ROTZOOM/AFFINE and a block's own stack (e.g. the
very first block of a frame, no neighbours) comes up short. Symbol
consumption was already bit-exact (rng matched aomdec before/after
mode info); only the predictor value was wrong.

Fixed at the fallback (nearest_mv/near_mv now default to gm_mv(gm,
ref_frame)); the r5/r6 pin decodes all 24 frames byte-exact through
the unmodified decode_stream. The multi-slot refusal that was masking
this is lifted (AFFINE-on-single-ref refusal stays). Wedge gate:
10/40 matches -> 33/40 (7 remaining refusals are all an unrelated
screen-content-tools capability gap).

Full ec-av1 --lib suite: 230/231 green (1 filter_intra gate flake,
confirmed non-regression by standalone rerun -- ok).
crates/ec-av1/src/mvstack.rsmodified+20 -7
@@ -1000,13 +1000,26 @@ pub fn find_mv_stack_with_sign_bias(
1000 for e in candidates.iter_mut() {1000 for e in candidates.iter_mut() {
1001 e.mv = clamp(e.mv);1001 e.mv = clamp(e.mv);
1002 }1002 }
1003- let nearest_mv = candidates.first().map_or((0, 0), |e| clamp(e.mv));1003+ // libaom `setup_ref_mv_list`'s single-reference-extension tail
1004- let near_mv = candidates.get(1).map_or((0, 0), |e| clamp(e.mv));1004+ // (mvref_common.c ~778-780): once the real scan/extension passes are
1005- let pred_mv = if candidates.is_empty() {1005+ // done, every `mv_ref_list` slot still empty (`idx >= refmv_count`, up
1006- (0, 0)1006+ // to `MAX_MV_REF_CANDIDATES`=2) is filled with `gm_mv_candidates[0]` --
1007- } else {1007+ // this query block's OWN global motion vector for `ref_frame`, not a
1008- nearest_mv1008+ // zero fallback -- and that fill is UNclamped (only the real
1009- };1009+ // `ref_mv_stack` entries go through `clamp_mv_ref` above). r6: this was
1010+ // `(0, 0)` here, invisible whenever a live ref's global motion is
1011+ // itself translation/identity (an unclamped gm mv of exactly (0,0)),
1012+ // and wrong the moment a ref carries a real ROTZOOM/AFFINE model and a
1013+ // query block's stack comes up short -- e.g. the very first block of a
1014+ // frame (mi=(0,0), no neighbours at all, `nearest_match`/`ref_match_count`
1015+ // both 0) coded NEWMV against a ROTZOOM-global ref: range-ladder against
1016+ // aomdec's `EC_TRACE_MODE` confirmed identical symbol consumption (same
1017+ // `rng` before/after mode info) with a different final mv purely from
1018+ // this predictor gap.
1019+ let gm_fallback = gm_mv(gm, ref_frame);
1020+ let nearest_mv = candidates.first().map_or(gm_fallback, |e| clamp(e.mv));
1021+ let near_mv = candidates.get(1).map_or(gm_fallback, |e| clamp(e.mv));
1022+ let pred_mv = nearest_mv;
1010 1023
1011 // Exact port of the `mode_context[ref_frame]` switch (mvref_common.c1024 // Exact port of the `mode_context[ref_frame]` switch (mvref_common.c
1012 // ~line 619-643). `new_mv_ctx` depends on `nearest_match` and the real1025 // ~line 619-643). `new_mv_ctx` depends on `nearest_match` and the real
crates/ec-av1/src/stream.rsmodified+21 -24
@@ -259,30 +259,27 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
259 "an inter frame whose global motion for a single-reference frame is AFFINE (unverified this round; ROTZOOM/TRANSLATION/IDENTITY are proven)",259 "an inter frame whose global motion for a single-reference frame is AFFINE (unverified this round; ROTZOOM/TRANSLATION/IDENTITY are proven)",
260 ));260 ));
261 }261 }
262- // lane-gm r4: a NEW mismatch, distinct from the one this round262+ // lane-gm r4/r5/r6: r4 found a NEW mismatch on frames with two
263- // fixed and NOT explained by `reference_select`/compound (traced263+ // concurrently active ROTZOOM/AFFINE ref slots (GOLDEN + BWDREF) and
264- // live: the mismatched frame of the seed-43 pin has264+ // refused the shape by name rather than guess-fix it. r5 localized
265- // `reference_select == false`) -- localized instead to the one265+ // the mismatch to an ordinary NEWMV/GOLDEN block, not the new
266- // property that DOES distinguish it from every frame that already266+ // global-warp branch at all -- proving "two active slots" was a
267- // matches: TWO different ref slots (`GOLDEN_FRAME`, `BWDREF_FRAME`)267+ // correlated symptom, not the cause. r6 range-laddered that block
268- // carry a non-translation model AT THE SAME TIME. The pin-verified268+ // against aomdec's `EC_TRACE_MODE` (identical `rng` before/after
269- // fix (frame 1) only ever exercised a single active non-identity269+ // mode info -- symbol consumption bit-exact) and found the real
270- // slot (`LAST_FRAME` alone). Root cause not yet found within this270+ // defect in `mvstack.rs`'s single-reference predictor fallback:
271- // round's budget (do not guess-fix): refuse the untested shape by271+ // libaom's `setup_ref_mv_list` fills any `mv_ref_list` slot the real
272- // name -- more than one concurrently active ROTZOOM/AFFINE ref --272+ // neighbour scan left short with this block's OWN global motion
273- // rather than ship it silently wrong.273+ // vector for its ref (`gm_get_motion_vector`), not zero -- invisible
274- if header.frame_type != FrameType::Key274+ // whenever the live ref's global motion is itself
275- && header.global_motion[..7]275+ // identity/translation, wrong the moment it's a real ROTZOOM/AFFINE
276- .iter()276+ // and the querying block's own stack comes up short (frame 14's
277- .filter(|gm| gm.model != WarpModel::Identity && gm.model != WarpModel::Translation)277+ // mi=(0,0), the very first block decoded, has no neighbours at
278- .count()278+ // all). Fixed at the predictor fallback; the refusal above (single
279- > 1279+ // untested shape: AFFINE on a single-ref frame) stays, but the
280- {280+ // *multi-slot* refusal this comment used to guard is lifted -- the
281- return Err(Error::unsupported(281+ // r5/r6 pin (seed-43 wedge-gate mismatch) now decodes all 24 frames
282- "AV1 decode_stream",282+ // byte-exact with it gone.
283- "an inter frame with more than one concurrently active ROTZOOM/AFFINE global-motion ref slot (single-active-slot ROTZOOM is pin-verified; this shape is not)",
284- ));
285- }
286 // lane-av1comp: `decode_inter_block`/`decode_inter_block8` now read283 // lane-av1comp: `decode_inter_block`/`decode_inter_block8` now read
287 // `comp_mode` per block whenever this frame's own `reference_select`284 // `comp_mode` per block whenever this frame's own `reference_select`
288 // header bit is set (spec 5.11.25), and refuse by name the blocks285 // header bit is set (spec 5.11.25), and refuse by name the blocks