edith_codecs
Clone
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
VERDICT: WIP -- stage-3 gate closer but not green; two real fixes landed, one residual defect open
What changed (commit 85c070b, branch lane-superres)
crates/ec-av1/src/stream.rs: gatea_real_aomenc_superres_key_frame_sequence_decodes_pixel_exactgot the charter's restrictive aomenc flag set, which cleared the pre-existing "AV1 tile: partition type this encoder never writes" capability gap (confirmed pre-existing, not a superres defect, per charter).- Same gate: added
--superres-kf-denominator=12. Root cause found by tracing libaomav1/encoder/superres_scale.ccalculate_next_superres_scale: underAOM_SUPERRES_FIXED, key frames readsuperres_cfg->superres_kf_scale_denominator, non-key frames readsuperres_scale_denominator-- two separate CLI flags (--superres-denominatoronly sets the latter). This gate's fixture uses--kf-max-dist=0(every frame a key frame per its own doc comment), so without the kf flagsuperres_kf_scale_denominatorstayed at its default 8 (no scale) andheader.use_superresdecodedfalse-- confirmed with a temporary debug print, then reverted. crates/ec-av1/src/decode.rs: real decoder bug, bothdecode_key_frame_tile_with_cdfs(line ~4993) anddecode_inter_frame_tile_with_cdfs(line ~10504) cropped chroma planes tofw / 2, fh / 2(floor) whenframe_widthdiffers from the mi-aligned decode buffer width. AV1's 4:2:0 chroma-plane width isROUND_POWER_OF_TWO(fw, 1)(div_ceil), not floor -- confirmed against libaomresize.c:1124. Odd downscaled widths (43, from this superres fixture) exposed it as adebug_assert_eq!panic insuperres.rs:135(upscale_planegot a 21-wide chroma row, expected 22). Fixed both call sites -- grepped, these are the only two constructors of the croppedPicture, class swept.
What's still broken
Gate still fails: 5 of 4096 luma pixels off by exactly 1, all near the right edge (x in 59..62 of a 64-wide frame). Ruled out:
- The upscale kernel itself (
upscale_row/upscale_planeinsuperres.rs) is pinned bit-exact against real libaomav1_convolve_horiz_rs_cvia the C harness for symmetric scale cases (in8->out12, in8->out16) -- r1's work, unchanged this round. - Not a bounds bug: traced the padding math (
pad=10,base=6,UPSCALE_NORMATIVE_TAPS=8) by hand, all array indices stay in range.
Leading theory, NOT confirmed: decode.rs crops the plane to exactly
frame_width (43) before superres::upscale_picture ever sees it, so
upscale_row's right-edge padding is a synthetic replicate of column 42.
libaom runs av1_superres_upscale on the reconstructed buffer's own
border-extended margin, which may still hold a real decoded pixel at
mi-alignment column 43 rather than a replicate -- untested this round
(would need threading the pre-crop plane + real width into
upscale_picture instead of cropping to fw first). Diff pattern (only
5 isolated pixels, not a monotonic edge band) is also consistent with a
subtler rounding-phase edge case; not conclusively attributed either way.
Order of work not reached
- Full scoped suite (
EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j4) not run this round -- the target gate itself was still red, rancargo check -p ec-av1 --lib --testsonly (clean) to confirm no compile breakage from the two fixes before committing. - Stage 4 (inter-frame superres, spec 7.11.3.3) not started -- blocked on stage 3 closing first per the charter's own ordering.
Commands
cargo check -p ec-av1 --lib --tests-- clean, 85 pre-existing doc warnings only.EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib a_real_aomenc_superres_key_frame_sequence -j4 -- --nocapture-- FAILED:frame 0 luma vs ffmpeg, 5/4096 pixels off by 1 (measured via temporary debug instrumentation, reverted before commit).
Handoff for next round
- Try threading real pre-crop border pixels into
upscale_pictureinstead of edge-replicating from the already-cropped row -- needs a small API change (upscale_picturetakes the plane's real allocated width + a slice wide enough to coverUPSCALE_NORMATIVE_TAPS/2+1extra real columns) plus adecode.rschange to stop discarding that margin before calling it. - If that doesn't close it, dump per-pixel
x_qn/int_pel/filter_idxat the 5 failing output columns and hand-trace against a libaom debug build of the same fixture -- the diffs are too sparse for a formula bug, more likely a specific phase/rounding edge case.