forge
Explore
Log in

Don't you dare go Hollow

Re-derive the GOLDEN_FRAME loop-filter residue, re-mask with a pin

Browse files at this commit

d02f01718ba232f8bfbfab25bd38aab0e5a81abdAhmet Kaan GümüşParent: d86dccb
  • fix
    • re-derive the GOLDEN_FRAME loop-filter residue, re-mask with a pin
Show full message
fix(av1): re-derive the GOLDEN_FRAME loop-filter residue, re-mask with a pin

Un-masked decode_inter_block's GOLDEN_FRAME arm this round and re-ran the
forwarding + golden-reference gates: two real aomenc streams mismatched
(30-run forwarding gate: 4/30 real failures, all a real aomenc GOLDEN
stream, not the documented flake). Pinned one (seed 43, frame 3 luma) as
stream::tests::pinned_golden4_stream_decodes_pixel_exact (#[ignore]d) and
traced it: 3 of 4096 luma pixels off by exactly +-1, all inside the loop
filter's edge window at a GOLDEN_FRAME/LAST_FRAME block boundary. Hand-
checked lf_level's ref_deltas/mode_deltas arithmetic against spec 7.14.4
at that edge -- it matches the default table exactly, so the residue is
still open: a narrow deblock-kernel rounding defect, or a golden-side
pixel one filter tap upstream. Re-narrowed the mask (decode_inter_block's
GOLDEN_FRAME arm refuses by name again) and reverted
a_hand_built_golden_reference_refuses_by_name to its refusal-asserting
form -- no fix proven this round, but the pinned fixture and the
narrowed-down suspect (deblock edge, not lf_level's own math) carry
forward.
crates/ec-av1/src/decode.rsmodified+26 -14
@@ -3700,8 +3700,8 @@ fn decode_inter_block(
3700 // into a `[Option<&PlaneBuf>; REFS_PER_FRAME]` addressed by the decoded3700 // into a `[Option<&PlaneBuf>; REFS_PER_FRAME]` addressed by the decoded
3701 // reference, same as the CDF/picture DPB slots `decode_stream` already3701 // reference, same as the CDF/picture DPB slots `decode_stream` already
3702 // keeps.3702 // keeps.
3703- // (round 5: parameters kept threaded but unread while the GOLDEN arm is3703+ // (round 6: parameters kept threaded but unread while the GOLDEN arm is
3704- // masked -- see the refusal below.)3704+ // masked again -- see the refusal below.)
3705 _golden_y: Option<&PlaneBuf>,3705 _golden_y: Option<&PlaneBuf>,
3706 _golden_u: Option<&PlaneBuf>,3706 _golden_u: Option<&PlaneBuf>,
3707 _golden_v: Option<&PlaneBuf>,3707 _golden_v: Option<&PlaneBuf>,
@@ -3750,22 +3750,34 @@ fn decode_inter_block(
3750 // this arm mismatched. Symbol-trace vs a patched aomdec proved one3750 // this arm mismatched. Symbol-trace vs a patched aomdec proved one
3751 // cause `LAST_FRAME`-reachable -- `lf_level`'s flat `mode_deltas[1]`3751 // cause `LAST_FRAME`-reachable -- `lf_level`'s flat `mode_deltas[1]`
3752 // on `GLOBALMV` blocks (fixed; see `Neighbours::ref_grid`'s packed3752 // on `GLOBALMV` blocks (fixed; see `Neighbours::ref_grid`'s packed
3753- // sign), previously masked because a GOLDEN block anywhere aborted3753+ // sign) -- and a second, loop-filter level/sharpness wrongly
3754- // the whole stream via `?` here -- and that fix moved the failure3754+ // forwarding from the primary ref frame instead of spec 7.20's
3755- // from seed 42 (frame 1, V) to seed 48 (frame 3, U): at least one3755+ // `ref_deltas`/`mode_deltas` (fixed, lane-av1golden3). Both fixes
3756- // more stacked defect remains on the GOLDEN-live path, so the3756+ // are `LAST_FRAME`-reachable and independent of the golden plane
3757- // refusal narrows back to `LAST_FRAME` until a real-stream gate3757+ // itself.
3758- // holds pixel-exact with GOLDEN live (the hand-built fixture below3758+ // round 6 (lane-av1golden4): un-masked again and re-masked in the
3759- // proved the symbol path and a whole-pel copy, not subpel MC off the3759+ // same round. A real aomenc stream (pinned:
3760- // golden plane -- `a_hand_built_golden_reference_refuses_by_name`3760+ // `stream::tests::pinned_golden4_stream_decodes_pixel_exact`, seed
3761- // keeps the fixture and asserts the mask instead).3761+ // 43, frame 3 luma) mismatched by exactly +-1 on 3 of 4096 pixels,
3762+ // all inside the loop filter's 14-wide edge window at the y=32
3763+ // horizontal boundary between a GOLDEN_FRAME block (ref_idx 4,
3764+ // computed level 3) and a LAST_FRAME block (ref_idx 1, level 4) --
3765+ // `edge_params`/`lf_level`'s own math checks out against spec 7.14.4
3766+ // by hand (`base=4`, `ref_deltas[4]=-1`, `mode_deltas=[0,0]` all
3767+ // match the default table), so the residue is unproven: either a
3768+ // narrow rounding/flatness-threshold defect in the wide deblock
3769+ // kernel (`filter8`/`filter14`) that any GOLDEN/LAST level split
3770+ // happens to be the first content to reach, or a golden-side pixel
3771+ // one narrow filter tap upstream of the edge. Refused again pending
3772+ // that isolation -- do not re-litigate the `lf_level` arithmetic
3773+ // itself, it was checked by hand this round.
3762 let (py_ref, pu_ref, pv_ref) = match ref_frame {3774 let (py_ref, pu_ref, pv_ref) = match ref_frame {
3763 LAST_FRAME => (ref_y, ref_u, ref_v),3775 LAST_FRAME => (ref_y, ref_u, ref_v),
3764 _ => {3776 _ => {
3765 return Err(unsupported(3777 return Err(unsupported(
3766- "a reference frame other than LAST_FRAME (round 5: GOLDEN_FRAME's decode \3778+ "a reference frame other than LAST_FRAME (round 6: GOLDEN_FRAME's decode \
3767- path exists but is masked -- a stacked defect past the GLOBALMV \3779+ path exists but is masked -- a narrow deblock-edge residue at GOLDEN/LAST \
3768- loop-filter mode-delta fix keeps real GOLDEN streams from pixel-exact)",3780+ boundaries keeps real GOLDEN streams from pixel-exact)",
3769 ));3781 ));
3770 }3782 }
3771 };3783 };
crates/ec-av1/src/stream.rsmodified+45 -6
@@ -539,12 +539,18 @@ mod tests {
539 /// of GOLDEN's picture. Round 4 asserted a pixel-exact decode against539 /// of GOLDEN's picture. Round 4 asserted a pixel-exact decode against
540 /// ffmpeg here; round 5 (lane-av1golden2) found that only proved the540 /// ffmpeg here; round 5 (lane-av1golden2) found that only proved the
541 /// symbol path plus a whole-pel copy -- the first real aomenc GOLDEN541 /// symbol path plus a whole-pel copy -- the first real aomenc GOLDEN
542- /// streams mismatch past a stacked defect (`decode.rs`'s round-5 note),542+ /// streams mismatch past a stacked defect, so the arm is masked again
543- /// so the arm is masked again and this fixture now asserts the mask:543+ /// and this fixture now asserts the mask: the stream must still reach
544- /// the stream must still reach the `GOLDEN_FRAME` `single_ref` read544+ /// the `GOLDEN_FRAME` `single_ref` read (hit counter) and must then
545- /// (hit counter) and must then refuse by name, not decode-and-be-wrong545+ /// refuse by name, not decode-and-be-wrong or misparse. Round 6
546- /// or misparse. The fixture itself is kept verbatim -- r3 flips this546+ /// (lane-av1golden4) un-masked, found the residue is now a narrow
547- /// test back to the pixel-exact form the moment the live path holds.547+ /// deblock-edge rounding defect at GOLDEN/LAST boundaries (`decode.rs`'s
548+ /// round-6 note, pinned by
549+ /// `stream::tests::pinned_golden4_stream_decodes_pixel_exact`), and
550+ /// re-masked -- this fixture proves the symbol path and a whole-pel
551+ /// copy only, not real subpel MC + deblock off the golden plane. The
552+ /// fixture itself is kept verbatim -- the next round flips this test
553+ /// back to the pixel-exact form the moment the live path holds.
548 #[test]554 #[test]
549 fn a_hand_built_golden_reference_refuses_by_name() {555 fn a_hand_built_golden_reference_refuses_by_name() {
550 use crate::cdf_state::Cdfs;556 use crate::cdf_state::Cdfs;
@@ -1825,6 +1831,39 @@ mod tests {
1825 }1831 }
1826 }1832 }
1827 1833
1834+ /// lane-av1golden4: reproduces the pinned mismatch bytes captured by
1835+ /// `EC_AV1_GATE_DUMP=$SP/golden4-pin.obu` off
1836+ /// [`a_real_aomenc_inter_sequence_with_cdf_forwarding_decodes_pixel_exact`]
1837+ /// (seed 43, frame 3 luma) the round the GOLDEN mask lifted. Deterministic
1838+ /// and static -- `#[ignore]`d, run manually.
1839+ #[test]
1840+ #[ignore = "reads a pinned fixture path outside the repo; run manually"]
1841+ fn pinned_golden4_stream_decodes_pixel_exact() {
1842+ use crate::decode::non_last_ref_hits;
1843+ let path = std::env::var("EC_AV1_GATE_DUMP_PIN").unwrap_or_else(|_| {
1844+ "/tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/\
1845+ 51b5f611-f998-43a8-b975-e64cb643a3e1/scratchpad/golden4-pin.obu"
1846+ .to_string()
1847+ });
1848+ let stream = std::fs::read(&path).expect("reading pinned stream");
1849+ if !have_ffmpeg() {
1850+ eprintln!("SKIP pinned_golden4_stream_decodes_pixel_exact: no ffmpeg");
1851+ return;
1852+ }
1853+ let before = non_last_ref_hits();
1854+ let frames = decode_stream(&stream).expect("pinned stream must decode");
1855+ eprintln!(
1856+ "non_last_ref_hits before={before} after={}",
1857+ non_last_ref_hits()
1858+ );
1859+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, 64, 64, 4);
1860+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
1861+ assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (pinned)");
1862+ assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (pinned)");
1863+ assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (pinned)");
1864+ }
1865+ }
1866+
1828 /// lane-av1refs's decisive single-non-LAST-reference gate: identical1867 /// lane-av1refs's decisive single-non-LAST-reference gate: identical
1829 /// recipe to1868 /// recipe to
1830 /// [`a_real_aomenc_inter_sequence_with_cdf_forwarding_decodes_pixel_exact`]1869 /// [`a_real_aomenc_inter_sequence_with_cdf_forwarding_decodes_pixel_exact`]