forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to crates/ec-av1/src/superres.rsClear filter

2026-09-05

2026-09-04

fix(av1): superres upscales between CDEF and loop restoration, not after LRAhmet Kaan Gümüş · 08a2542
fix(av1): superres upscales between CDEF and loop restoration, not after LR

Spec 7.16 (libaom `superres_post_decode`, called in `decodeframe.c` between
`av1_cdef_frame` and `av1_loop_restoration_filter_frame`): the horizontal
upscale runs after CDEF and BEFORE loop restoration. This decoder ran the
whole filter chain on the downscaled frame and upscaled last, in `stream.rs`,
so under superres loop restoration filtered downscaled pixels through a unit
grid sized from the downscaled width.

Three widths were wrong, all in the same class (`wrong-stage-width`: each
plane width in the filter chain is either the downscaled one -- deblock, CDEF
and the mi grid -- or the upscaled one -- everything loop restoration does):

* `RestorationGrid::new` sized its unit counts from `frame_width`; libaom
  sizes them with `av1_get_upsampled_plane_size` (upscaled width).
* `read_lr`'s unit corners divided downscaled mi columns by the unit size;
  `av1_loop_restoration_corners_in_sb` scales by `superres_denom /
  SCALE_NUMERATOR` (`mi_to_num_x`/`denom_x`) when the frame is scaled.
* The pixel filters ran on downscaled planes. Both the post-CDEF frame and
  the post-deblock frame LR substitutes at stripe boundaries are now upscaled
  first (libaom's `save_deblock_boundary_lines` runs
  `av1_upscale_normative_rows` over its saved rows when the frame is scaled).

`decode::set_superres` carries the state per frame, like `set_bit_depth`, and
the reconstruction buffer's own real columns past `frame_width` stay the
upscale's right margin -- the `take_last_frame_wide_margin` hand-off to
`stream.rs` is gone with the late upscale it fed.

Gate: `fixtures/superres_kf_cdef_lr_64x64.obu`, a real aomenc key frame with
CDEF and loop restoration under `--superres-denominator=12`, was 1873 wrong
samples (max 7) and is now byte-exact against ffmpeg.

Residual, pinned ignored: `fixtures/superres_alltools_sb128_320x180.obu` (10
frames, all tools, sb128, cpu-used=4) went from 37315 wrong samples/max 171
to 1620/max 11 -- what is left is CHROMA ONLY (luma exact in all 10 frames)
and survives `--enable-cdef=0 --enable-restoration=0`, so it is a
scaled-reference chroma prediction defect, not filtering.

2026-09-01

feat(av1): bit-depth-generic film grain synthesis and superres upscaleAhmet Kaan Gümüş · a67e457
feat(av1): bit-depth-generic film grain synthesis and superres upscale

Lifts the last two `bit_depth != 8` refusals. Film grain (spec 7.18.3 /
libaom grain_synthesis.c): grain_center = 128 << (bd-8), gauss_sec_shift =
12 - bd + grain_scale_shift, scale_LUT interpolation over the 256-entry LUT,
cb/cr offsets and clip_to_restricted_range ranges shifted by (bd-8).
Superres (spec 7.16): planes stay u16 end to end, output clamp is
(1 << bd) - 1; the filter/Round2/edge-margin path is unchanged and its three
libaom pins still hold at 8-bit.

Gated by two real-aomenc 10-bit gates (--film-grain-test=1 and
--superres-mode=1 --superres-denominator=12), both pixel-exact vs ffmpeg's
own 10-bit decode and both hard-asserting bit_depth==10 plus a firing
counter (grain_hits / superres_hits). Forcing bit_depth=8 back into either
call site fails its gate, so neither is vacuous.

Measured on his library: ReelB sets apply_grain on 25 of its first 50
frames with a real luma scaling LUT at 10 bit; neither film uses superres
(enable_superres=false in both sequence headers).

2026-08-30

Merge branch 'main' into lane-superresAhmet Kaan Gümüş · 17c9a9c
Merge branch 'main' into lane-superres

Resolves the scaled-MC conflict in decode.rs in favour of the lane's
structure, and widens predict_scaled to u16 for main's high-bit-depth
sample type (fixture included).

Lane state after the merge: 264 passed, 1 failed -- the lane's own gate
a_real_aomenc_key_and_inter_superres_sequence_decodes_pixel_exact. That
is the lane's deliverable, not merge fallout, so this does not go to
main yet.
wip(av1): lane-superres stage-3 gate in progress, committed at the 75-turn capAhmet Kaan Gümüş · 0e6258a
wip(av1): lane-superres stage-3 gate in progress, committed at the 75-turn cap

Committed verbatim by the orchestrator so the work survives the cap; state
unverified (suite not run on this tree by me).
feat(av1): superres upscaler, pinned against real libaom codeAhmet Kaan Gümüş · c262edf
feat(av1): superres upscaler, pinned against real libaom code

crates/ec-av1/src/superres.rs: spec 7.16 horizontal-only linear-filter
upscale (av1_upscale_normative_rows/upscale_normative_rect/
av1_convolve_horiz_rs_c in libaom resize.c/convolve.c), coefficient
table + constants transcribed verbatim.

Corrects the charter's anchor note: libaom's decodeframe.c calls
superres_post_decode() BETWEEN av1_cdef_frame and
av1_loop_restoration_filter_frame, not after LR -- superres runs
before loop restoration, on the frame that will then be LR-filtered
at the upscaled size. Not yet load-bearing here since this decoder
still refuses any loop_restoration.uses_lr stream outright.

Pinned against libaom's own compiled code, not a second transcription:
a standalone C harness links ~/.cache/aom-oracle/build/libaom.a and
calls the real exported av1_get_upscale_convolve_step/
av1_convolve_horiz_rs_c/av1_resize_filter_normative directly (only the
one-line static get_upscale_convolve_x0 formula is copied in both
places) -- guards the class shared-oracle-blindness. Two captured rows
(8->12, 8->16) plus a flat-row unity-gain sanity check, 3/3 green.

Not yet wired into decode_stream (stage 3 next); module currently
unused, hence the dead_code warnings.