Re-derive the GOLDEN_FRAME loop-filter residue, re-mask with a pin
Browse files at this commitd02f01718ba232f8bfbfab25bd38aab0e5a81abdParent: d86dccb- fix
- re-derive the GOLDEN_FRAME loop-filter residue, re-mask with a pin
2 changed files +71 -20
- crates/ec-av1/src/decode.rs +26 -14
- crates/ec-av1/src/stream.rs +45 -6
crates/ec-av1/src/decode.rsmodified+26 -14
| @@ -3700,8 +3700,8 @@ fn decode_inter_block( | ||
| 3700 | 3700 | // into a `[Option<&PlaneBuf>; REFS_PER_FRAME]` addressed by the decoded |
| 3701 | 3701 | // reference, same as the CDF/picture DPB slots `decode_stream` already |
| 3702 | 3702 | // keeps. |
| 3703 | - // (round 5: parameters kept threaded but unread while the GOLDEN arm is | |
| 3704 | - // masked -- see the refusal below.) | |
| 3703 | + // (round 6: parameters kept threaded but unread while the GOLDEN arm is | |
| 3704 | + // masked again -- see the refusal below.) | |
| 3705 | 3705 | _golden_y: Option<&PlaneBuf>, |
| 3706 | 3706 | _golden_u: Option<&PlaneBuf>, |
| 3707 | 3707 | _golden_v: Option<&PlaneBuf>, |
| @@ -3750,22 +3750,34 @@ fn decode_inter_block( | ||
| 3750 | 3750 | // this arm mismatched. Symbol-trace vs a patched aomdec proved one |
| 3751 | 3751 | // cause `LAST_FRAME`-reachable -- `lf_level`'s flat `mode_deltas[1]` |
| 3752 | 3752 | // on `GLOBALMV` blocks (fixed; see `Neighbours::ref_grid`'s packed |
| 3753 | - // sign), previously masked because a GOLDEN block anywhere aborted | |
| 3754 | - // the whole stream via `?` here -- and that fix moved the failure | |
| 3755 | - // from seed 42 (frame 1, V) to seed 48 (frame 3, U): at least one | |
| 3756 | - // more stacked defect remains on the GOLDEN-live path, so the | |
| 3757 | - // refusal narrows back to `LAST_FRAME` until a real-stream gate | |
| 3758 | - // holds pixel-exact with GOLDEN live (the hand-built fixture below | |
| 3759 | - // proved the symbol path and a whole-pel copy, not subpel MC off the | |
| 3760 | - // golden plane -- `a_hand_built_golden_reference_refuses_by_name` | |
| 3761 | - // keeps the fixture and asserts the mask instead). | |
| 3753 | + // sign) -- and a second, loop-filter level/sharpness wrongly | |
| 3754 | + // forwarding from the primary ref frame instead of spec 7.20's | |
| 3755 | + // `ref_deltas`/`mode_deltas` (fixed, lane-av1golden3). Both fixes | |
| 3756 | + // are `LAST_FRAME`-reachable and independent of the golden plane | |
| 3757 | + // itself. | |
| 3758 | + // round 6 (lane-av1golden4): un-masked again and re-masked in the | |
| 3759 | + // same round. A real aomenc stream (pinned: | |
| 3760 | + // `stream::tests::pinned_golden4_stream_decodes_pixel_exact`, seed | |
| 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 | 3774 | let (py_ref, pu_ref, pv_ref) = match ref_frame { |
| 3763 | 3775 | LAST_FRAME => (ref_y, ref_u, ref_v), |
| 3764 | 3776 | _ => { |
| 3765 | 3777 | return Err(unsupported( |
| 3766 | - "a reference frame other than LAST_FRAME (round 5: GOLDEN_FRAME's decode \ | |
| 3767 | - path exists but is masked -- a stacked defect past the GLOBALMV \ | |
| 3768 | - loop-filter mode-delta fix keeps real GOLDEN streams from pixel-exact)", | |
| 3778 | + "a reference frame other than LAST_FRAME (round 6: GOLDEN_FRAME's decode \ | |
| 3779 | + path exists but is masked -- a narrow deblock-edge residue at GOLDEN/LAST \ | |
| 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 | 539 | /// of GOLDEN's picture. Round 4 asserted a pixel-exact decode against |
| 540 | 540 | /// ffmpeg here; round 5 (lane-av1golden2) found that only proved the |
| 541 | 541 | /// 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), | |
| 543 | - /// so the arm is masked again and this fixture now asserts the mask: | |
| 544 | - /// the stream must still reach the `GOLDEN_FRAME` `single_ref` read | |
| 545 | - /// (hit counter) and must then refuse by name, not decode-and-be-wrong | |
| 546 | - /// or misparse. The fixture itself is kept verbatim -- r3 flips this | |
| 547 | - /// test back to the pixel-exact form the moment the live path holds. | |
| 542 | + /// streams mismatch past a stacked defect, so the arm is masked again | |
| 543 | + /// and this fixture now asserts the mask: the stream must still reach | |
| 544 | + /// the `GOLDEN_FRAME` `single_ref` read (hit counter) and must then | |
| 545 | + /// refuse by name, not decode-and-be-wrong or misparse. Round 6 | |
| 546 | + /// (lane-av1golden4) un-masked, found the residue is now a narrow | |
| 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 | 554 | #[test] |
| 549 | 555 | fn a_hand_built_golden_reference_refuses_by_name() { |
| 550 | 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 | 1867 | /// lane-av1refs's decisive single-non-LAST-reference gate: identical |
| 1829 | 1868 | /// recipe to |
| 1830 | 1869 | /// [`a_real_aomenc_inter_sequence_with_cdf_forwarding_decodes_pixel_exact`] |