forge
Explore
Log in

Don't you dare go Hollow

report(av1): superres stage-3 WIP status, handoff for the edge-pixel residue

Browse files at this commit

018d9911af0d2c9eedf562df5a095aae1fc6e679Ahmet Kaan GümüşParent: e9f1fa8
lanes/superres.report.mdadded+78 -0
@@ -0,0 +1,78 @@
1+VERDICT: WIP -- stage-3 gate closer but not green; two real fixes landed, one residual defect open
2+
3+## What changed (commit 85c070b, branch lane-superres)
4+- `crates/ec-av1/src/stream.rs`: gate
5+ `a_real_aomenc_superres_key_frame_sequence_decodes_pixel_exact` got the
6+ charter's restrictive aomenc flag set, which cleared the pre-existing
7+ "AV1 tile: partition type this encoder never writes" capability gap
8+ (confirmed pre-existing, not a superres defect, per charter).
9+- Same gate: added `--superres-kf-denominator=12`. Root cause found by
10+ tracing libaom `av1/encoder/superres_scale.c` `calculate_next_superres_scale`:
11+ under `AOM_SUPERRES_FIXED`, key frames read
12+ `superres_cfg->superres_kf_scale_denominator`, non-key frames read
13+ `superres_scale_denominator` -- two separate CLI flags
14+ (`--superres-denominator` only sets the latter). This gate's fixture uses
15+ `--kf-max-dist=0` (every frame a key frame per its own doc comment), so
16+ without the kf flag `superres_kf_scale_denominator` stayed at its default
17+ 8 (no scale) and `header.use_superres` decoded `false` -- confirmed with a
18+ temporary debug print, then reverted.
19+- `crates/ec-av1/src/decode.rs`: real decoder bug, both
20+ `decode_key_frame_tile_with_cdfs` (line ~4993) and
21+ `decode_inter_frame_tile_with_cdfs` (line ~10504) cropped chroma planes
22+ to `fw / 2, fh / 2` (floor) when `frame_width` differs from the
23+ mi-aligned decode buffer width. AV1's 4:2:0 chroma-plane width is
24+ `ROUND_POWER_OF_TWO(fw, 1)` (div_ceil), not floor -- confirmed against
25+ libaom `resize.c:1124`. Odd downscaled widths (43, from this superres
26+ fixture) exposed it as a `debug_assert_eq!` panic in `superres.rs:135`
27+ (`upscale_plane` got a 21-wide chroma row, expected 22). Fixed both call
28+ sites -- grepped, these are the only two constructors of the cropped
29+ `Picture`, class swept.
30+
31+## What's still broken
32+Gate still fails: 5 of 4096 luma pixels off by exactly 1, all near the
33+right edge (x in 59..62 of a 64-wide frame). Ruled out:
34+- The upscale kernel itself (`upscale_row`/`upscale_plane` in
35+ `superres.rs`) is pinned bit-exact against real libaom
36+ `av1_convolve_horiz_rs_c` via the C harness for symmetric scale cases
37+ (in8->out12, in8->out16) -- r1's work, unchanged this round.
38+- Not a bounds bug: traced the padding math (`pad=10`, `base=6`,
39+ `UPSCALE_NORMATIVE_TAPS=8`) by hand, all array indices stay in range.
40+
41+Leading theory, NOT confirmed: `decode.rs` crops the plane to exactly
42+`frame_width` (43) before `superres::upscale_picture` ever sees it, so
43+`upscale_row`'s right-edge padding is a synthetic replicate of column 42.
44+libaom runs `av1_superres_upscale` on the reconstructed buffer's own
45+border-extended margin, which may still hold a real decoded pixel at
46+mi-alignment column 43 rather than a replicate -- untested this round
47+(would need threading the pre-crop plane + real width into
48+`upscale_picture` instead of cropping to `fw` first). Diff pattern (only
49+5 isolated pixels, not a monotonic edge band) is also consistent with a
50+subtler rounding-phase edge case; not conclusively attributed either way.
51+
52+## Order of work not reached
53+- Full scoped suite (`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib
54+ -j4`) not run this round -- the target gate itself was still red, ran
55+ `cargo check -p ec-av1 --lib --tests` only (clean) to confirm no
56+ compile breakage from the two fixes before committing.
57+- Stage 4 (inter-frame superres, spec 7.11.3.3) not started -- blocked on
58+ stage 3 closing first per the charter's own ordering.
59+
60+## Commands
61+- `cargo check -p ec-av1 --lib --tests` -- clean, 85 pre-existing doc
62+ warnings only.
63+- `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib
64+ a_real_aomenc_superres_key_frame_sequence -j4 -- --nocapture` --
65+ FAILED: `frame 0 luma vs ffmpeg`, 5/4096 pixels off by 1 (measured via
66+ temporary debug instrumentation, reverted before commit).
67+
68+## Handoff for next round
69+1. Try threading real pre-crop border pixels into `upscale_picture`
70+ instead of edge-replicating from the already-cropped row -- needs a
71+ small API change (`upscale_picture` takes the plane's real allocated
72+ width + a slice wide enough to cover `UPSCALE_NORMATIVE_TAPS/2+1`
73+ extra real columns) plus a `decode.rs` change to stop discarding that
74+ margin before calling it.
75+2. If that doesn't close it, dump per-pixel `x_qn`/`int_pel`/`filter_idx`
76+ at the 5 failing output columns and hand-trace against a libaom debug
77+ build of the same fixture -- the diffs are too sparse for a formula
78+ bug, more likely a specific phase/rounding edge case.