Mv-stack single-ref predictor falls back to global motion, not zero
Browse files at this commit43e5d8c984a48c1be0035791d50c554444db542aParent: 42d6aa0- fix
- mv-stack single-ref predictor falls back to global motion, not zero
2 changed files +41 -31
- crates/ec-av1/src/mvstack.rs +20 -7
- crates/ec-av1/src/stream.rs +21 -24
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_mv | 1008 | + // 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.c | 1024 | // 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 real | 1025 | // ~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 round | 262 | + // lane-gm r4/r5/r6: r4 found a NEW mismatch on frames with two |
| 263 | - // fixed and NOT explained by `reference_select`/compound (traced | 263 | + // concurrently active ROTZOOM/AFFINE ref slots (GOLDEN + BWDREF) and |
| 264 | - // live: the mismatched frame of the seed-43 pin has | 264 | + // refused the shape by name rather than guess-fix it. r5 localized |
| 265 | - // `reference_select == false`) -- localized instead to the one | 265 | + // the mismatch to an ordinary NEWMV/GOLDEN block, not the new |
| 266 | - // property that DOES distinguish it from every frame that already | 266 | + // 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-verified | 268 | + // against aomdec's `EC_TRACE_MODE` (identical `rng` before/after |
| 269 | - // fix (frame 1) only ever exercised a single active non-identity | 269 | + // mode info -- symbol consumption bit-exact) and found the real |
| 270 | - // slot (`LAST_FRAME` alone). Root cause not yet found within this | 270 | + // defect in `mvstack.rs`'s single-reference predictor fallback: |
| 271 | - // round's budget (do not guess-fix): refuse the untested shape by | 271 | + // 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::Key | 274 | + // 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 | - > 1 | 279 | + // 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 read | 283 | // 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 blocks | 285 | // header bit is set (spec 5.11.25), and refuse by name the blocks |