Commits
2026-09-29
ec-av1: the clip gates stop skipping green on an absent fixture rootAhmet Kaan Gümüş · 1f91edd
ec-av1: the clip gates stop skipping green on an absent fixture root The 1080p multi-tile gate printed 'SKIP the 1080p tile round trip: no fixture' and libtest reported ok on any tree without the gitignored root fixtures/ -- which is every linked worktree. Eleven clip gates had that shape, and none of them had an env that made the absence RED, so EC_AV1_REQUIRE_FFMPEG=1 (a batch saying 'this gate must run') did not help. New crates/ec-av1/src/library_fixture.rs owns the real-library fixture root and the one presence probe. It resolves EC_FIXTURES FIRST, which is the root scripts/verify-fixture-library.sh validates: the preflight and the gates used to read two different directories, so pointing EC_FIXTURES at a library elsewhere printed 'resolve 0 missing' and GREEN while every clip gate skipped. It fails under EC_REQUIRE_FIXTURES / EC_AV1_REQUIRE_FFMPEG / EC_AV1_REQUIRE_AOMENC and otherwise prints exactly one SKIP line naming the resolved path and the three ways out. Every clip gate now routes through it, the per-clip 'missing' drops in the BD-rate and TPL probes included, and the preflight's last word is GREEN-WITH-FINDINGS rather than a bare GREEN over a reported mode-(i) finding. gen-fixture-library.sh learns the resolver's library-relative literal so RESOLVE keeps checking the clip rows instead of losing them the moment a gate stops spelling ../../fixtures.
2026-09-24
2026-09-07
fix(av1): the probe armed a window film B does not haveAhmet Kaan Gümüş · 2ebcc2c
fix(av1): the probe armed a window film B does not have `examples/enc_probe` was handed its crop by hand, and every long-GOP census so far passed `crop=1920:1024:960:568` -- the centre of a 3840x2160 frame. Film B is coded 3840x1608, so the gate's own window is `crop=1920:1024:960:292`: the instrument measured different pixels than the gate it reported on (60466 B vs the gate's 90674 B at q=150), and the probe also had no `-ss`, so on any clip it read from frame 0 instead of the gate's pinned seek. One definition of the arming now serves both: `ec_av1::probe::source` (the loader, with the seek) and `ec_av1::probe::gate_crop` (the superblock-aligned centre window, from ffprobe), called by the probe and by `encode::tests`' `clip_frames_vf`/`native_bd_arm`. The probe takes `gate` as its width argument to ask for that window, and `EC_ENC_SS` for the seek. In gate mode the probe now codes 90674 bytes on film B at q=150 -- byte-exact with `bd_rate_film_long_gop`'s own ladder point. `lanes/census-longgop-v2.md` re-takes the per-level census on the real window; the v1 shares were off (ARF 49.3% -> 53.8%, key 25.6% -> 21.6%).
feat(av1): a decode-side syntax census, and the film B vs rav1e table it producedAhmet Kaan Gümüş · 373b6a2
feat(av1): a decode-side syntax census, and the film B vs rav1e table it produced The BD gate says our stream is bigger; it never says which syntax it is bigger in. This adds a per-CDF-table bit accountant to the symbol decoder (EC_AV1_BITCENSUS=1, one relaxed load per symbol when off) plus block, tx, mv, mode and frame-header funnels, and an examples/syntax_census.rs that prints one table per stream -- so our stream and rav1e's are measured by the same reader. lanes/census-filmB.md holds the answer for film B at matched PSNR: the whole gap is in the inter frames (our key frame is the smaller and the worse one), 75% of it in the leaves, and the three mechanisms are the flat pyramid q ladder, the missing 64x64 blocks and transforms, and a 52.5% vs 84.8% skip share.
feat(av1): a speed preset axis (0..=10), preset 0 the search we shipAhmet Kaan Gümüş · 597c1a3
feat(av1): a speed preset axis (0..=10), preset 0 the search we ship
Every search lever this crate already has an EC_AV1_* knob for reads its
default from a per-speed table in the new `speed` module, indexed by one
process-global preset (`Av1Encoder::with_speed`, `EC_AV1_SPEED`). Index 0
of every table IS the shipped constant, so preset 0 is byte-identical by
construction; `speed::levers` names what each preset switches off, and
ec-bench codes one row per preset {0,3,6,10}.2026-09-06
feat(av1): encoder picks per-frame deblocking levels by re-decoding its own tileAhmet Kaan Gümüş · 873a1fb
feat(av1): encoder picks per-frame deblocking levels by re-decoding its own tile The encoder runs no loop filter of its own: filter_search hands the coded tile back to this crate's decoder under each candidate loop_filter_level and keeps the winning picture as the reconstruction, so the reference frame stays identical to what a decoder produces. Encoded now carries the chosen LoopFilterParams and every test that decodes Encoded::tile takes them from there (class: test asserts against a stale header).
2026-09-05
perf(av1): route every gate counter through hit!/hit_do! behind a default-on gate-counters featureAhmet Kaan Gümüş · 04187f1Browse files
feat(av1): EC_AV1_TIMELINE -- per-frame decode timeline + critical-path reportAhmet Kaan Gümüş · 9cdd364
feat(av1): EC_AV1_TIMELINE -- per-frame decode timeline + critical-path report Two lanes pipelined the loop filters per superblock row and recovered 2.3% wall although the filters were 19% of frame-thread time; nobody had measured the actual critical path. `EC_AV1_TIMELINE=1` records ~10 timestamps per coded frame on one monotonic clock -- submit, worker start, each reference slot wait (with the producing frame, so the DAG has real edges), header setup, tile parse, wavefront drain, filters, slot publish, grain, output -- plus every block of the dispatcher at the in-flight bound, and dumps them as TSV at stream end. `scripts/av1-timeline-report.py` reports phase medians, the reference waits, the work-weighted critical path through the DAG, concurrency at 10 ms ticks (in-flight vs actually RUNNING) and the cap waits. Measured at (16,4,2) on the 4K segment, 3 runs: wall 5.44 s, of which the measured dependency chain is 4.96 s = 91%, and 90.8% of that chain is parse. Only 2.9 frames are runnable at any instant while 18 are in flight, so the dispatcher cap is never the bound (48 threads on the 1080p cut: 4.0 running, no wall gain). The filters are 5.0% of the chain -- which is exactly the 2.3% the pipelining lanes could recover. Off, this is one `LazyLock<bool>` load per event at frame granularity: eight gate hashes byte-identical at 1 and 16 threads, instructions:u +0.056% (gate 0.05%, wall -0.5%).
2026-09-04
perf(av1): parallelise the in-frame filter chain (deblock, CDEF, LR, film grain)Ahmet Kaan Gümüş · 63e598c
perf(av1): parallelise the in-frame filter chain (deblock, CDEF, LR, film grain) `EC_AV1_FILTER_THREADS` (default 1, so the shipped behaviour is unchanged) splits every post-decode filter stage across `std:🧵:scope` workers, each along an axis whose writes are disjoint: * deblock: 16-row bands for the vertical-edge pass (a vertical edge writes columns x0-7..x0+5 of its OWN 4 rows) and 16-column bands for the horizontal one (rows y0-7..y0+6 of its own 4 columns); the horizontal pass still runs after the whole vertical pass of that plane, spec 7.14 order. * CDEF: mi ROW bands. Every unit reads only the pre-CDEF snapshots and writes its own 8x8 luma / 4x4 chroma square. * loop restoration: restoration-unit row bands. The RU row walk is resolved into a row list first (a short remainder is swallowed by the previous row), and row `r`'s write range starts where row `r-1`'s ended. * film grain: 32-pixel block rows. A row's noise comes from `Rng::line(y * 2, seed)` alone, and the one carry across rows -- the line buffers -- is rebuilt by replaying exactly ONE preceding row with its pixel writes suppressed. `FrameCtx` stays `!Sync`; a worker gets `filter_ctx_copy`'s copy of the fields the filter chain reads (bit depth, segmentation, superres, grain bit depth). The aliasing that the band arithmetic proves and the borrow checker cannot is confined to `par::Shared` (one `#[allow(unsafe_code)]` module). Gated byte-exact: the new `a_real_stream_filters_identically_with_one_and_four_filter_threads` compares every output plane of a 10-bit CDEF+LR stream and of a film-grain stream at 1 vs 4 filter threads, with per-stage firing counters asserted; the four perf6 stream hashes are equal at 1 and at 4 filter threads. seg4k 272 frames: 34.99 s -> 31.33 s (7.77 -> 8.68 fps), seg4k_lr 32.13 s -> 27.31 s at 4 filter threads (interleaved medians of 3, 12-core box under load 6.5). Single-threaded cost: +1.6% instructions (607.34 G -> 617.18 G on seg4k), mostly CDEF losing alias facts through the raw-pointer-derived `&mut`.
perf(av1): explicit SIMD for both motion-compensation passesAhmet Kaan Gümüş · 66498f4
perf(av1): explicit SIMD for both motion-compensation passes The two separable-filter inner loops were 18.7% of a 1080p decode's self time after lane-perf4 (`vpass_row` 10.4%, `horizontal_pass_unscaled` 8.3%). Both are now hand-vectorised with `std::arch::x86_64` intrinsics behind a level detected once per process (`OnceLock`): AVX2 where the CPU has it, SSE4.1 otherwise, and the existing scalar loops everywhere else -- they stay the reference implementation, not a dead fallback. The horizontal pass's `_mm*_madd_epi16` sums two taps of one output per lane, so even and odd output columns accumulate separately and are interleaved back into order (`unpack` + `permute2x128`); 16 outputs per AVX2 iteration, 8 per SSE2 one, a 4-column tail scalar. The vertical pass stays i32 (`mullo_epi32` + `add_epi32`), as 12-bit needs. Rounding is unchanged in both: the same `Round2` add-then-arithmetic-shift. This is why the crate is now `deny(unsafe_code)` rather than `forbid`: intrinsics are unsafe by signature. The exception is confined to `mc`'s `simd` module and its two dispatch sites, each with its own `#[allow(unsafe_code)]` and documented in the crate header, and every kernel is pinned lane-for-lane against the scalar function it replaces over all widths, all 16 phases, both tables of all four filter kinds and the 8/10/12-bit ranges. Interleaved medians, 1080p: 11.07 s -> 10.51 s (horizontal pass alone was 11.37 -> 11.24; the vertical pass is where the win is). 4K 57.59 -> 57.12. Byte-exact on all three probe inputs.
perf(av1): read every EC_* debug flag once instead of per blockAhmet Kaan Gümüş · ba458d2
perf(av1): read every EC_* debug flag once instead of per block `std::env::var*` is a getenv + strlen + CStr validation on every call, and this crate reads its trace flags from per-block, per-TU and per-MC-call paths -- 11.6% of a 1080p10 decode's self time went to that, with the two worst sites inside the motion-compensation kernels themselves. Nothing in the crate or its tests calls `set_var`, so each name is a process constant. New `envflags` module: `env_flag!(NAME)` keeps one `LazyLock<bool>` per CALL SITE (atomic load after the first call, no hashing), `envflags::var` serves the value sites from a single snapshot of the environment. Semantics are unchanged at every site -- `is_some()`, `is_none()` and the `Result<String, VarError>` shape are preserved -- and the decoder's output is byte-identical. 160 sites in decode.rs, 2 in mc.rs. Header/tool-lookup sites that run once per stream are left alone. 1080p10 299-frame segment, interleaved medians of 3: 24.47 s -> 22.03 s (12.2 -> 13.6 fps), output byte-exact. (cherry picked from commit 318e0cce54fe7697a2d23c02d3b0d385f0e1401a)
2026-08-30
Merge branch 'main' into lane-lr; LR gate is GREEN after the SGR table fixAhmet Kaan Gümüş · aadcbfd
Merge branch 'main' into lane-lr; LR gate is GREEN after the SGR table fix r9 resolved every conflict and hit its turn cap before compiling. I finished it: three of main's newer gate call sites were missing this branch's LoopRestorationParams argument (git merged the text cleanly and the result did not compile -- same semantic-conflict shape as the delta_q merge), and main's "a frame with loop restoration enabled" refusal is retired by this branch, so refusal_inventory drops it. The result: a_real_aomenc_stream_with_restoration_reads_lr_symbols_correctly PASSES. The one-pixel SGR gap that survived rounds 5, 6 and 7 was 7ad6d77's mistranscribed SGR_X_BY_XPLUS1 entries, not a sampling or stripe-boundary defect. Suite 260 passed / 0 failed.
Merge branch 'lane-superres': key-frame superres decodes pixel-exact (3/3 frames, superres_hits=3)Ahmet Kaan Gümüş · eb818a1
Merge branch 'lane-superres': key-frame superres decodes pixel-exact (3/3 frames, superres_hits=3) Root cause was deblocking the mi-alignment margin: libaom's set_lpf_parameters early-returns TX_4X4 once x >= dst.width or y >= dst.height -- the CODED frame dimensions, not the mi-grid-padded extent our true_width/true_height used. That early return is also why r6's two oracle trace points never fired. Two guard adjustments the merge forced, both tightening rather than relaxing: - refusal_inventory gains the lane's new inter-frame superres refusal. - gate_coverage now closes a coverage hole only on POSITIVE evidence -- some gate passing . It used to retire an entry as soon as a gate merely left the flag off its command line, which this merge would have done to palette and intrabc: aomenc's default for both is content-dependent, so 'defaulted' means unknown, not exercised. Negative-checked: flipping one gate's --enable-palette to =1 fails the test by name. Suite 255 passed / 0 failed.
test(av1): pin the decode path's refusals, and the claims they makeAhmet Kaan Gümüş · 093155e
test(av1): pin the decode path's refusals, and the claims they make Two things this decoder keeps relearning. A refusal string is a claim: 'this encoder never writes one' asserts something about the world, and one such string was disproved by the very gate that carried it. And refusals accumulate silently -- each one is the right call for the lane that adds it (refuse by name rather than desync), but the total is the distance to decoding a default-settings stream, and nothing printed the total. refusal_inventory derives every unsupported(...) reason reachable on the decode path -- decode.rs and stream.rs, both call shapes -- and pins it: 39 distinct refusals, of which 7 are phrased as claims about what an encoder emits and are now declared in their own list rather than scattered. Adding, renaming or removing a refusal fails until the inventory is updated, so the diff of this file is the decoder's capability delta in English. A new claim-shaped refusal fails separately, with the reason it needs evidence. Negative-checked: dropping one entry fails both tests naming that exact string. Suite 236 passed / 0 failed.
feat(av1): msac-flavoured LR subexp/recenter port + Wiener/SGR read_lr_unit primitives (unwired)Ahmet Kaan Gümüş · 4c75e5c
feat(av1): msac-flavoured LR subexp/recenter port + Wiener/SGR read_lr_unit primitives (unwired) Ports decode_subexp/decode_unsigned_subexp_with_ref/decode_signed_subexp_with_ref to the msac SymbolDecoder (k is a per-tap parameter here, not global motion's fixed 3), plus read_wiener_filter/read_sgrproj_filter and the SGR params table, all from libaom decodeframe.c/restoration.c. Pinned via roundtrip against a hand-written encode-side mirror (SymbolEncoder has no LR writer of its own). Not yet called from decode.rs -- stream.rs's whole-frame refusal is unchanged.
test(av1): pin the coding tools no real-aomenc gate exercisesAhmet Kaan Gümüş · 21b2356
test(av1): pin the coding tools no real-aomenc gate exercises lane-chroma r1 found reconstruct()'s `smooth_neighbor` hardcoded false -- wrong whenever a directional block neighbours a smooth-mode one -- and it had survived twenty real-aomenc gates because every one of them passes --enable-smooth-intra=0. The corner-cut was not hidden by a weak assert; it was hidden by the gates' encoder recipes, which no assert had ever looked at. gate_coverage derives, from the gate source itself, the set of aomenc tools switched off in all 20 gates and on in none -- provably never exercised by a real stream -- and pins it: cdef, intrabc, paeth-intra, palette, smooth-intra. An unlisted tool joining that set fails the test, and so does an entry the gates have since started enabling, so a lane closing a hole must delete its line. Negative-checked: dropping the enable-cdef entry fails with exactly that name. Suite 234 passed / 0 failed.
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.
2026-08-28
wip(av1): wedge mask codebook (square 8x8/16x16/32x32), checksum-verified vs independent C dumpAhmet Kaan Gümüş · 99ff391Browse files
wip(av1): affine warp estimation + filter ported, wired into leaf16 -- COMPILING WIPAhmet Kaan Gümüş · efe3e65
wip(av1): affine warp estimation + filter ported, wired into leaf16 -- COMPILING WIP lane-warp round 2, budget-capped stop. Step 0 (verify r1's alphabet- selection change) ran clean first: warp/obmc(x2)/deblocking gates all green on e886150 before touching anything -- no desync from r1's num_proj_ref-gated 3-symbol motion_mode_cdf read. Ported this round (new module crates/ec-av1/src/warp.rs): - av1_findSamples in full: decode.rs's num_proj_ref (count-only) replaced by find_samples, which now also records each sample's own (pts1, pts2) 1/8-pel coordinates (record_samples, mvref_common.c) -- num_proj_ref is now find_samples(..).len(), a pure refactor kept bit-identical (verified: both OBMC gates + the warp refuse-or-match gate still green after it). - av1_selectSamples: MV-diff threshold filter (thresh = clamp(max(bw,bh), 16, 112)), run only when num_proj_ref > 1, matching decodemv.c's own gate. - find_affine_int + av1_get_shear_params -> find_projection: the full least-squares affine fit (LS_SQUARE/LS_PRODUCT1/LS_PRODUCT2, the 64-bit divisor-resolution div_lut, get_mult_shift_diag/ndiag) plus the shear decomposition/validity check (alpha/beta/gamma/delta, WARP_PARAM_REDUCE_ BITS, is_affine_shear_allowed). Returns None on a singular fit or non-representable shear -- both spec fallback cases collapse to "use the block's own translational MV" at the call site, matching libaom's own wm_params.invalid handling (reconinter.c allow_warp: global warp is never the fallback here since this decoder's global motion is always IDENTITY). - av1_warp_affine_c: the 8x8-tile, two-pass 8-tap affine filter (av1_warped_filter, 193 rows, transcribed verbatim from warped_motion.c), 8-bit non-compound only (this decoder's warp arm only ever reaches a single-ref, non-skip-mode block, so conv_params->is_compound is always false on this path -- the compound/highbd branches are dropped). Wired into decode_inter_block (the 16x16+ leaf) only: motion_mode == 2 no longer refuses by name. It computes samples via find_samples + select_samples, calls find_projection, and when Some(params) overrides the block's already-computed translational-MV prediction (pred_y/u/v) with warp_affine's own output (luma subsampling 0/0, chroma 1/1, 4:2:0) before the OBMC blend check (mutually exclusive with motion_mode==1). When find_projection returns None, the existing translational-MV prediction is left untouched -- exactly the spec's own invalid-warp fallback. NOT ported/wired this round (steps 5-6 remaining): - decode_inter_block8 (the 8x8 leaf): STILL refuses motion_mode == 2 by name unconditionally -- warp.rs's functions are leaf16-only so far. - The a_real_aomenc_stream_with_warped_motion_refuses_or_matches gate (stream.rs ~3255, "gradients" lavfi content, default aomenc flags) still reads "40 named refusals, 0 pixel-exact matches out of 40" after this round's wiring -- unchanged from before. NOT diagnosed within budget whether that's because (a) the gate's own content/encoder flags never actually reach a WARPED_CAUSAL-coded block on this decoder's supported path (matches the documented never-fired-gate class: gradients content + default flags is a different recipe from the charter's own --auto-alt-ref=1 --lag-in-frames=16 --enable-fwd-kf=0 --enable-ref-frame-mvs=0), or (b) it does reach one and either find_projection legitimately returns None every time (falls back to translational, no visible difference), or hits some OTHER named refusal first (interintra, screen-content-tools, sub-16 partition -- all seen in the OBMC gate's own refusal list on identical content). WARP_SELECTED_HITS was not read back this round to disambiguate -- next round's first move. - Gate itself not flipped to require pixel-exact + no self-pin added (step 6) -- premature until the above is diagnosed with real fire evidence. cargo check -p ec-av1 --lib: clean, 0 errors. Verified green this round: both OBMC gates (a_real_aomenc_stream_with_obmc_decodes_pixel_exact + _obmc_8x8), a_real_aomenc_stream_with_warped_motion_refuses_or_matches (still legally refuse-or-match, unchanged pass/fail shape). Deblocking gate verified green at step 0 before any edit this round (unaffected by this round's changes -- warp.rs is dead code on that path). NEXT: read WARP_SELECTED_HITS after a run against the charter's own aomenc flags (--auto-alt-ref=1 --lag-in-frames=16 --enable-fwd-kf=0 --enable-ref-frame-mvs=0, dims mult of 64) to get a real fire count before touching leaf8 or the gate; wire decode_inter_block8 the same way find_samples/select_samples/find_projection/warp_affine already support (the bw4/bw/bh plumbing is generic, only the call site inside decode_inter_block8's own motion_mode match needs the same three-call sequence copied over).
feat(av1): compound CONV_BUF blend + distance-weight assign, not wired yetAhmet Kaan Gümüş · 181a784
feat(av1): compound CONV_BUF blend + distance-weight assign, not wired yet mc.rs: predict_compound_intermediate (round_1=7, no clip, mirrors libaom's COMPOUND_ROUND1_BITS path) and combine_compound (spec 7.11.3.15 weighted average, shift = InterPostRound + DIST_PRECISION_BITS) -- pinned against a whole-pel identity case that round-trips exactly through both stages. compound.rs (new): dist_wtd_comp_weight_assign, a pure port of libaom's av1_dist_wtd_comp_weight_assign (quant_dist_weight/quant_dist_lookup_table search), tested standalone against hand-worked order-hint cases. Neither is wired into decode.rs yet -- comp_group_idx/compound_idx reads, Neighbours compound_idx tracking, and the reconstruction call sites are still open (see HANDOFF).
wip(av1): temporal MV projection math (spec 7.9/7.10.2.8), not yet wiredAhmet Kaan Gümüş · 916263c
wip(av1): temporal MV projection math (spec 7.9/7.10.2.8), not yet wired New crate::motion_field module: MotionField (per-frame saved 8x8 MV grid + order-hint bookkeeping), setup_motion_field (av1_setup_motion_field's LAST/BWDREF/ALTREF2/ALTREF/LAST2 selection + motion_field_projection's distance-scaled projection into a TplField), and add_tpl_ref_mv (the per-query-block second projection). All ported from libaom av1/common/mvref_common.c, unit-tested against hand-checked distance/ projection arithmetic. mvstack::find_mv_stack_with_sign_bias gains an Option<TplArgs> parameter: when Some, folds temporal candidates into the stack at libaom's real insertion point (after the row/col/top-right REF_CAT_LEVEL boost, before the corner probe) and derives zero_mv_ctx (GLOBALMV_OFFSET) from them; None (every existing caller today) reproduces the prior always-0 exact behaviour bit for bit -- all 13 existing mvstack unit tests still pass unmodified. NOT DONE: decode_inter_block's only call site still passes tpl: None (see its own TODO), and nothing in decode_inter_frame_tile_with_cdfs or stream::decode_stream builds a per-DPB-slot MotionField or calls setup_motion_field -- so decode::tmv_hits() reads 0 against any real stream, and no temporal-MV gate exists yet. See ledger DELTA for the precise remaining wiring.
feat(av1): implement spec 7.18.3 film grain synthesis, flip the refusalAhmet Kaan Gümüş · 84e41d9
feat(av1): implement spec 7.18.3 film grain synthesis, flip the refusal Port the AR-filtered grain template generation, piecewise-linear scaling LUT, and 32x32/16x16 tiled overlap-blend application from libaom's reference synthesis (crates/ec-av1/src/film_grain.rs), wired into decode_stream's frame-finalize path so the reference bank keeps the clean pre-grain decode (spec 7.18.3.1) while only the caller's output picture carries grain. Header parsing (ec-av1-syntax FilmGrainParams, load_grain_params ref-slot forwarding) was already spec-complete -- no changes needed there. Replaces the apply_grain refusal with a pixel-exact gate against ffmpeg's own AV1 decoder on the pinned aomenc fixture (frame 0, the span the original mismatch was traced to; later frames in that fixture hit an unrelated pre-existing GOLDEN_FRAME MC gap, out of this lane's scope), plus an aomenc multi-seed sweep gate that skips gracefully when aomenc is unavailable.
2026-08-27
feat(av1dec): public decode_stream OBU walker, bench decode row, NEARMV liftAhmet Kaan Gümüş · 16b0ce0
feat(av1dec): public decode_stream OBU walker, bench decode row, NEARMV lift decode_stream(&[u8]) walks a raw AV1 stream via ec-av1-syntax's Av1Parser, extracts each Frame OBU's header + tile payload and dispatches to the existing decode_key_frame_tile/decode_inter_frame_tile, threading a single-slot DPB -- the first real entry point that does not need Encoded's pub(crate) fields. ec-bench's av1 row now times decode_stream instead of reporting "no decoder present". decode_inter_block also reconstructs NEARMV (mvstack already carries the second stack candidate), tested by hand-driving a symbol stream since this crate's own encoder never chooses that mode.
feat(av1): begin a software key-frame decoder (round 1)Ahmet Kaan Gümüş · e6eadb9
feat(av1): begin a software key-frame decoder (round 1) Promotes msac's test-only SymbolDecoder to a real, non-test decoder (the inverse of SymbolEncoder, already spec-derived and roundtrip tested), and adds crates/ec-av1/src/decode.rs: a from-spec reader that mirrors tile.rs's sb_coeff_key_frame_tile symbol order (partition tree through 64x64/32x32/16x16, coefficient base/base-range/EOB/Golomb/sign syntax, CDF adaptation) without importing from tile.rs, which a sibling lane is editing concurrently. Round 1 scope: key frames only, DC_PRED blocks only, unskipped, and frames a whole number of 64x64 superblocks -- everything else refuses with a named error rather than miscoding. Within that scope, real encoder output (encode_key_frame_with_modes forced to DC_PRED, two sizes, real quantised AC/DC residual) decodes byte-exact against the encoder's own reconstruction. Encoded gains three pub(crate) fields (tile, mi_cols, mi_rows, base_q_idx) so a decoder test can reach the raw tile payload without re-deriving it from the OBU stream. Deferred to round 2: non-DC_PRED intra modes (needs the directional edge-reach plumbing), inter frames, skipped blocks, and the partial-superblock/gathered-CDF true-edge path.
2026-08-26
feat(av1): streaming encoder facade with configurable colour (I11)Ahmet Kaan Gümüş · f421d98
feat(av1): streaming encoder facade with configurable colour (I11)
Av1Encoder is the one-in-one-out surface edith_replica's engine will call
in place of rav1e: EncoderConfig{width,height,base_q_idx,gop,colour} in,
encode(&Picture) -> Packet{data,key,order} out, gop-cadenced key frames
predicting inter frames from the previous reconstruction like
encode_sequence already did. encode_key_frame_inner/encode_inter_frame
are now shared (pub(crate)) between encode_sequence and the facade
instead of being duplicated. The sequence header's colour_config is wired
to Colour::{Bt709Limited,Bt601Limited,Unspecified} (spec 5.5.2's CICP
triple + range), replacing the hardcoded "unspecified" -- verified against
ffprobe.feat(av1): diamond/log integer + half/quarter-pel motion searchAhmet Kaan Gümüş · 5986059
feat(av1): diamond/log integer + half/quarter-pel motion search Adds crates/ec-av1/src/motion.rs: a log/diamond integer-pel search over one reference plane through mc::predict, refined by one half-pel then one quarter-pel round. Cost is SAD + lambda * mv_bits, where mv_bits prices the MV residual (joint/class/bit/fraction/hp) by interval-narrowing through encode::symbol_bits against the cdf::MV_* tables, matching the tile writer's own convention rather than a per-entry probability lookup. SEARCH_INITIAL_STEP_PEL=8 landed from a three-way sweep (4/8/16) recorded in motion.rs's own inline test. SAD chosen over SSE per a doc-comment measurement.
Merge branch 'lane-av1-mvstack': spec-7.10.2 MV stack, single-ref reductionAhmet Kaan Gümüş · 402402fBrowse files
feat(av1): MV prediction stack (spec 7.10.2, single-ref reduction)Ahmet Kaan Gümüş · ec98d16
feat(av1): MV prediction stack (spec 7.10.2, single-ref reduction) find_mv_stack scans row-above/col-left/top-right neighbours over a block's whole 4x4-mi span, dedupes into a weighted RefStackMv, and derives NearestMv/NearMv/PredMv plus NewMv/RefMv/ZeroMv/DRL contexts. Compound refs, temporal MV projection and bit-exact context tables are deliberately out of scope until a consumer needs them.
feat(av1): sub-pel motion compensation (spec 7.11.3, EIGHTTAP regular)Ahmet Kaan Gümüş · 082d993
feat(av1): sub-pel motion compensation (spec 7.11.3, EIGHTTAP regular) Two-stage separable 8-tap filter, InterRound0=3/InterRound1=11 for 8-bit non-compound per spec 7.11.3.2, edge samples clamped rather than read out of range. Not yet wired into encode.rs (later lane).
feat(av1): the tile adapts its CDFs as it writesAhmet Kaan Gümüş · 8a54f53
feat(av1): the tile adapts its CDFs as it writes AV1's symbol decoder updates every non-literal CDF it reads, so an encoder that leaves `disable_cdf_update` off has to keep the same state and update it in the same order. This adds that state and writes the key frame's tile through it. Tables the decoder keeps one copy of are one copy here too: a 64x64 luma transform reads the 32x32 base-range rows, both luma sets share one DC sign and one 1024-position end-of-block table, and both chroma sets share their own sign table. The gathered partition CDF an edge superblock reads is built for the read and thrown away, so nothing adapts there. The coefficient rate term still prices against the defaults: the mode search runs before the tile is written, so the adapted state does not exist yet. BD-rate against the same encoder with adaptation off, over a three-point ladder: -3.52% on a 1080p film frame, -5.63% on a screen capture, -11.25% on the test card. The ffmpeg/dav1d roundtrips are the gate -- a decoder adapting its own tables desyncs the moment the order or the sharing differs.
2026-08-25
feat(av1): seven intra modes, picked per block by rate-distortionAhmet Kaan Gümüş · 4331d17
feat(av1): seven intra modes, picked per block by rate-distortion The predictors of spec 7.11.2 that read no further than the row above and the column left of a block -- DC, V, H, SMOOTH, SMOOTH_V, SMOOTH_H and PAETH -- with the edge construction that fills a missing side from the side that exists. Each 32x32 luma block now codes under all seven and keeps the one whose squared error and estimated rate come out cheapest; chroma stays DC, which is the mode the tile writer codes for it. The weight on rate was swept over three real clips and two synthetic pictures at six values; 0.05 step-squared per bit is the best point on every one. Against DC alone it saves 11.5% of the rate on screen capture, 7.8% on the test card and 59.5% on a picture that runs one way. Against libaom the gap at matched size on a film frame narrows from 2.4 dB to 2.0 dB. Every mode is gated forced over a whole picture, with ffmpeg's reconstruction equal sample for sample, and striped pictures gate the search on picking the direction the picture runs -- a transposed predictor passes every symmetric test.
feat(av1): encode a key-frame pictureAhmet Kaan Gümüş · a4fb030
feat(av1): encode a key-frame picture DC intra prediction over the reconstruction, the forward transform and quantizer, and the tile writer, joined into an encoder that takes a planar 4:2:0 picture and produces a stream. Blocks are 32x32 luma and 16x16 chroma, coded in the order a decoder walks a superblock's quadrants. The gate is an equality: ffmpeg's decode of the stream matches the encoder's own reconstruction sample for sample, on every plane, for test cards at three sizes and for a frame of real video. Prediction reads the reconstruction, so a single sample of drift would spread through every block below and to the right of it. At q_idx 100 a 640x352 film frame costs 32 366 bytes at 39.26 dB, which is about 2.4 dB behind libaom at the same rate -- the size of what is not implemented yet: one block size, one transform type, DC prediction only, no rate-distortion decision, no CDF adaptation.
feat(av1): dequantization and the inverse DCTAhmet Kaan Gümüş · 6a83833
feat(av1): dequantization and the inverse DCT An encoder that cannot say what the decoder will show cannot choose coefficients by what they cost against what they are worth. This adds the decode-side arithmetic to ec-av1: the dequantizer of spec 7.12.3 and the inverse DCT of 7.13, written from the specification's own butterfly stage list so that one network serves every size from 4 to 64. The gate is agreement with a real decoder, sample for sample: two key frames whose first block carries coefficients from DC to the far corner decode under ffmpeg to exactly 128 plus the residual this code computes, over all 1024 and 4096 samples. Beneath that sit the two tables of decoder-pinned DC residuals the tile tests already carried, all 28 levels of each, plus structural gates for the transpose, the sign rounding, and the row shifts of the four sizes the frame syntax cannot reach. Mutation-checked: a cosine table entry off by one, and an 8x8 row shift off by one, each fail a named test.
feat(av1): first frame that a real decoder decodesAhmet Kaan Gümüş · 304ec65
feat(av1): first frame that a real decoder decodes A tile payload writer for the one block coding the encoder can produce so far: a key frame whose every superblock is one skipped 64x64 DC-predicted block. Four symbols per superblock — the partition, the skip flag and the two intra modes — with the frame header turning off everything that would add syntax the writer does not code yet (CDEF, loop restoration, filter intra, screen content tools, transform size selection, CDF adaptation). The default CDF tables of spec section 9.4 arrive with it, in the same orientation the symbol coder reads: the partition, skip, key-frame luma mode and CFL-free chroma mode tables, which is what this syntax touches. Gated end to end rather than by roundtrip: the stream is handed to ffmpeg and every sample of the decoded frame must be 128, which is what a DC prediction with no neighbours and no residual produces. Any desync between our arithmetic coder and dav1d's shows up as a decode failure or a sample that is not mid-grey, with no metric in between to hide it. Frames that are not a whole number of superblocks are refused by name: a partial superblock forces the partition syntax down the block tree.
feat(av1): symbol coder for tile payloadsAhmet Kaan Gümüş · a580965
feat(av1): symbol coder for tile payloads AV1 specifies only the decoding process for its multi-symbol arithmetic coder, so the writer is derived as the inverse of section 8.2: it narrows the same interval decode_symbol tracks and flushes the shortest prefix that pins the interval down whatever bytes follow. CDF adaptation follows section 8.3.2, and CDFs are stored in the specification's own orientation (cumulative, 1 << 15 total, counter in the last entry) so the code reads against the spec text rather than against a decoder's internal complement. Covers the adaptive multi-symbol write, the fixed-CDF write, and L(n) literals; the flush handles carry propagation through the precarry buffer. Gated by a decoder written separately from the section 8.2 pseudocode: alphabets of 2..=16 symbols roundtrip over 4000 adaptive symbols each, 2000 mixed-width literals roundtrip, a 3000-item interleaving of both roundtrips, and a 1-in-256 stream is asserted to cost under a quarter bit per symbol so a backwards interval narrowing cannot pass. This is the primitive every AV1 tile payload is written through; the OBU writers so far cover only the headers around it.
feat(av1): write the key-frame header OBUAhmet Kaan Gümüş · e203345
feat(av1): write the key-frame header OBU The inverse of `ec_av1_syntax`'s `parse_uncompressed_header`, for the subset a stateless encoder emits: a shown key frame in a sequence with no decoder model, no frame id numbers and no still-picture shortcut. It covers tile info (uniform spacing), quantization, segmentation, delta q and delta lf, loop filter, CDEF, loop restoration, transform mode and the reduced transform set, plus `frame_obu` to carry the header and a tile group in one OBU. Two of the codings are not the value they look like and are spelled out here: the restoration type is remapped (None 0, Switchable 1, Wiener 2, Sgrproj 3, not the enum's discriminant) and a CDEF secondary strength of 4 is coded as 3. Everything outside the subset is refused by name rather than written wrong: a superres denominator other than 8, film grain synthesis, frame id numbers, decoder model timing, `show_existing_frame`, any non-key or hidden frame, and non-uniform tile spacing. The tests parse back every stream they write through `Av1Parser` and compare the whole `FrameHeader`, including the derived fields the format never codes (the header's own bit length, the tile start ramps, the segmentation id range), across a one-tile frame, a four-tile-column frame, a segmented frame with delta q and delta lf, and a frame using loop restoration.
2026-08-24
feat(ec-av1): OBU header/framing writer + sequence-header writerAhmet Kaan Gümüş · 4cb83b2
feat(ec-av1): OBU header/framing writer + sequence-header writer Bit-exact inverse writers of the parsers in ec-av1-syntax: obu.rs: - obu_type_code: ObuType -> 4-bit code (inverse of ObuType::from_code) - write_obu_header: writes OBU header (spec 5.3.2), forbidden/reserved bits 0 - wrap_obu: frames payload as low-overhead OBU (header + leb128 size + payload) - temporal_delimiter: the two-byte 0x12 0x00 temporal-unit marker sequence.rs: - write_sequence_header: full sequence-header payload (spec 5.5.1) - write_color_config: color_config() inverse (spec 5.5.2) - sequence_header_obu: wraps the payload as a SequenceHeader OBU Supported subset only (unsupported configs return Error::unsupported): - reduced_still_picture_header == false (still-image header not implemented) - no timing_info - no decoder_model_info - exactly one operating point Roundtrip tests: write -> parse back -> assert equality for both OBU headers (plain + extension) and sequence headers; wrapped OBU leb128 size asserted to match payload length; temporal delimiter asserted to be [0x12, 0x00]. Gates: cargo test --release -p ec-av1 (13 passed), cargo clippy --release -p ec-av1 --all-targets (clean), cargo fmt.