Commits
2026-10-23
Restore edith_codecs after local data loss (2026-10-23)Ahmet Kaan Gümüş · b7434a2
Restore edith_codecs after local data loss (2026-10-23) On 2026-10-23 an automated agent ran `rm -rf $HOME` and deleted the local repository with all of its history. This commit restores the working tree from the newest surviving copy, the host-c server lane mirror. That mirror matches local main as of the testcut Phase 2 reports, including the tool cache, the nextest fast profile and changed-crates.sh. The history before this commit was not recovered.
2026-09-07
fix(av1): temporal MV candidates ignored force_integer_mvAhmet Kaan Gümüş · 0c17efc
fix(av1): temporal MV candidates ignored force_integer_mv `lower_mv_precision` implemented only its `is_integer == false` half, on a comment claiming no reachable stream sets `force_integer_mv` because `allow_screen_content_tools` is refused at the stream level. Neither half of that claim holds: libaom turns screen-content tools on for dark, smooth FILM (`av1_set_screen_content_options` counts near-flat 16x16 blocks) and then sets `force_integer_mv` on the frames its hash test calls static, and this decoder parses such streams without refusing anything. The consequence was invisible to the parse: every temporal MV candidate came out at eighth-pel where libaom rounds it to full pel, so the mv stack held values libaom never produced. The stack still had the right shape for a while, so the frame decoded "successfully" into a whole-frame prediction mismatch, and the entropy desync that followed surfaced as the unrelated refusal "a Golomb tail longer than this decoder reads" (class `refusal-names-a-correlate`). First divergence, measured against the instrumented libaom oracle: film-B gate clip, `-cpu-used 6 -crf 35 -g 12`, decode-order frame 3 (order_hint 1, the one inter frame with `force_integer_mv == 1`), block mi(0,0), the NEWMV predictor -- identical `EC_TPL` field cells and identical range in both decoders, aomdec's stack `(16,0)w16 (16,-8)w12 (8,-40)w4` against ours `(14,-4)w16 (12,-2)w8 (12,-38)w4 (16,-4)w4`. Class: `branch-dropped-as-unreachable` -- a spec branch deleted on an unreachability note that a capability change (screen-content streams no longer refused) silently invalidated. All four libaom film-B ladder points at 48 frames now decode sample-exact against ffmpeg/libdav1d except crf 5, which desyncs on the KEY frame at mi(184,344) (base_q 9) -- a separate, still-open defect.
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
perf(av1): inline the temporal-MV probe and shrink the tpl cell, -0.4% parse instructionsAhmet Kaan Gümüş · ac23155
perf(av1): inline the temporal-MV probe and shrink the tpl cell, -0.4% parse instructions
The mv-stack builders' temporal-MV sample was a closure LLVM would not
inline into either builder (both far past its size threshold), so it was
emitted as a real function -- find_mv_stack_with_sign_bias::{closure#1}
and find_mv_stack_compound::{closure#1}, together 3.5% of the parse
thread -- and every one of the up-to-19 probes per inter block paid a
call plus the argument shuffle. Making it an #[inline(always)] free
function with the EC_TRACE_TPL dump split off #[cold] removes both
symbols (-0.26% instructions).
motion_field_projection re-derived two of libaom's three pos_valid terms
for every one of a 4K field's 129600 cells per direction although
neither depends on the cell; they are now one early return and one
per-ref table, and the cell walk reads contiguous row slices instead of
a bounds-checked accessor (-0.13%).
The projected tpl cell dropped its Option tag: the projection only ever
stores a strictly positive ref_frame_offset, so 0 already is libaom's
own 'never projected' marker, and the tag cost 8 bytes per cell (20 vs
12) over a field that is 2.6 MB at 4K.
Byte-exact: 12/12 gate hashes at 1, 4 and 16 threads.perf(av1): the saved motion field builds off the frame thread, one other-side table per frameAhmet Kaan Gümüş · 259f3b7
perf(av1): the saved motion field builds off the frame thread, one other-side table per frame `build_motion_field` (libaom `av1_copy_frame_mvs`) was a serial whole-frame 4x4-unit pass on the frame thread that re-evaluated the `other_side` order-hint comparison for every reference slot of every inter unit. Two changes, both output-identical: * the per-reference `other_side` answer is a `[bool; 8]` computed once per frame instead of two `get_relative_dist` calls per inter unit; * the pass is split into cell-row bands over the filter pool with the existing `par::bands`/`Shared`/`run_bands` pattern. An 8x8 motion-field cell lives entirely in one cell row, so a band owns `cells[r0 * cols..r1 * cols]` and no two bands ever touch the same cell -- the write order inside a band is unchanged, so the "last qualifying slot wins" and "clear-then-maybe-write" semantics are preserved exactly. The field is consumed only by LATER frames, never by this frame's entropy decode; it is published as part of `SlotValue` at `SlotPromise::fulfil`, so it cannot be deferred past the fulfil without splitting that publication. seg4k, 4dc14f52 -> here: instructions:u 412.358 -> 410.565 G at 1 thread (-0.44%, the hoist alone -- bands collapse to 1 at FILTER_THREADS=1) and 421.45 -> 419.13 G at (16,4,2) (-0.55%). All 12 gate hashes unchanged at 1, 4 and 16 threads.
perf(av1): hoist the temporal-MV probe out of the per-sample loop, thread-local the mvstack gate countersAhmet Kaan Gümüş · e08e4e4
perf(av1): hoist the temporal-MV probe out of the per-sample loop, thread-local the mvstack gate counters `add_tpl_ref_mv` re-derived the parity, the field bounds and the row base on every one of the (up to 19) 8x8 probes a query block makes. Those are per-BLOCK quantities: `row8 = mi_row + blk_row + (mi_row even)` means the cell index is `(mi_row + 1 - (mi_row & 1) + blk_row) >> 1`, and an arithmetic shift keeps the spec's `row8 < 0` rejection exact. `TplProbe` holds the two bases plus the cell slice, so a probe is an add, a shift and a bounds check; the compound stack reads the cell ONCE and projects it to both sides instead of walking the field twice. `EC_TRACE_TPL`'s per-sample dump is unchanged: the flag is read once per block and the traced path still goes through `add_tpl_ref_mv` itself. The four mvstack firing counters (`TMV_HITS` per inter block, `STACK_FULL_DROPS` per candidate insertion, `COMP_GM_FILL_HITS`, `TILE_REACH_CLIPS`) were process-global atomics: one shared cache line bumped by 16 frame threads on the parse critical path. They are now thread-local `Cell`s, the form every other gate counter in the crate already uses; the gates that read them decode on their own thread. -0.21% instructions on the 4K segment at 1 thread (443.29 vs 444.24 G); the counter step is flat there and inside the box's noise at 16 threads. Byte-exact: all 12 gate hashes unchanged at 1/4/16 threads.
2026-09-04
Merge branch 'lane-thread3' (f4946b69): dependency-aware frame scheduling with per-slot promises; every non-key frame decodes on a worker waiting only on its reference slots; show_existing output dispatched; byte-exact at 1, 2 and 4 threads; 4K 8.0 to 14.6 fps at 6 threads, 1080p 29 to 41 fpsAhmet Kaan Gümüş · a5126caBrowse files
chore(av1): clear the ec-av1 compiler warnings (300 -> 0 on the release lib)Ahmet Kaan Gümüş · 16efbd9
chore(av1): clear the ec-av1 compiler warnings (300 -> 0 on the release lib) No arithmetic, control flow or public signature changes; the four perf6 decode hashes are byte-identical. - gate-counter accessors and other test-only items carry `#[allow(dead_code)]` with the reason on the line (they are read from the `#[cfg(test)]` gates, which the plain lib build cannot see); - `///` blocks sitting on `thread_local!`/macro invocations become `//` (rustc never attached them to anything); - `cdf.rs` tables and the `InterpFilterKind` variants get a one-line doc; - unused locals/params prefixed `_` where the value is genuinely unused; dead initializers dropped where the compiler proves every read is preceded by an assignment; - `decode_key_frame_tile` import is now `#[cfg(test)]` (its only user). Left standing on purpose, as findings rather than hidden warnings: `stream.rs` census counters `other` and `rect_residual_refusals` are incremented and never read back by their gates.
feat(av1): dependency-aware frame scheduling -- every non-key frame decodes on a workerAhmet Kaan Gümüş · fcddd9c
feat(av1): dependency-aware frame scheduling -- every non-key frame decodes on a worker lane-thread2 could only dispatch LEAVES of the reference graph (shown, non-key, refresh_frame_flags == 0), which on an aomenc pyramid stream is almost nothing: seg1080 has 1 dispatchable frame in 299. Each of the 8 reference slots now holds a `SlotPromise` instead of a value when `threads > 1`: the parsing thread installs a frame's promise into every slot its `refresh_frame_flags` names at DISPATCH time, in decode order, so the next frame's dependencies are known without waiting for the previous one to finish. A worker waits on exactly the promises of the slots its frame reads (its `ref_frame_idx` entries -- references, primary CDFs, previous segment map, reference order hints and spec 7.9's motion-field projection all come from those), then decodes, publishes its clean picture/CDFs/motion field/segment map, and only then synthesises film grain. `setup_motion_field` therefore runs on the DECODING thread, inside `RefSnapshot::take`, after those waits (it takes borrowed slots now, so no motion field is copied to hand it over). Deadlock argument, spelled out at `SlotPromise`: every wait points from a later coded frame to an earlier one, so the wait graph is the reference DAG; the parsing thread waits only for a `show_existing_frame` output and at the in-flight bound (threads + 2), where the earliest in-flight frame always has its producers already finished. A frame that errors or panics marks its promise Failed, so no consumer waits for a value that never arrives. Key frames and `show_existing_frame` headers stay inline. `threads == 1` is untouched: no promise is ever created and the owned bank is the same one. `leaf_frames_dispatched` -> `frames_dispatched`. The 1-vs-4-thread gate now dispatches 39 of reelb_arf_witness's 40 coded frames (was 18) and 14 of palette_screen_witness's 15 (was 0), and asserts more than half the shown frames really ran on a worker.
perf(av1): snapshot the remaining per-pixel EC_* env readsAhmet Kaan Gümüş · 2baca5a
perf(av1): snapshot the remaining per-pixel EC_* env reads `restoration.rs`'s three `EC_LR_CALL_DUMP` guards sit inside the sgrproj per-pixel loops (`compute_ab`, the combine tap) and `warp.rs`'s `EC_MC_TRACE` on the per-MC-call warp entry; each was a live `getenv` + `strlen` + `CStr` validation, 17.75% of `decode_probe`'s self time at 4K. Same predicates, served by `envflags::env_flag!` (one `LazyLock<bool>` per call site). `motion_field.rs`'s two `EC_TRACE_TPL` reads move with them. `tile.rs`'s two sites stay: :34 already caches into an atomic and :3002 is test-only. Byte-exact on seg1080/seg4k/seg4k_lr/palette; 4K 55.31 s -> 48.53 s (interleaved medians of 3), 1080p 10.54 s -> 9.83 s.
2026-09-02
fix(av1): the saved motion field kept only the LAST tile's columns -- av1_copy_frame_mvs read the mi grid through the per-tile reach clampAhmet Kaan Gümüş · ba5351f
fix(av1): the saved motion field kept only the LAST tile's columns -- av1_copy_frame_mvs read the mi grid through the per-tile reach clamp `build_motion_field` (this crate's `av1_copy_frame_mvs`) walks the whole frame's mi grid AFTER the tile loop has finished, when `MiGrid`'s tile window is still narrowed to the last tile. `MiGrid::get` returns `None` outside that window, so every tile but the last saved no motion vectors at all: on the pinned 192x68 2-tile-column stream the saved field held only mi_col 32..47, and the next frame's temporal (MFMV) candidates over the whole left two thirds silently vanished from the MV stack. The entropy stream still matched symbol for symbol -- a missing weight-2 temporal vote only reorders the stack -- so a NEW_NEWMV block at mi(0,24) took stack[1] = (36,0) (the compound extension's zero-fill) instead of libaom's (0,0), predicting 32 px off and leaving a 32-px-wide wrong column band. New `MiGrid::get_frame` is the unclamped frame-level read; only `build_motion_field` uses it. Rungs added with it: `EC_TPL` (per frame: use_ref_frame_mvs + filled projected cells) and `EC_TRACE_TPL`'s new `EC_TPL_SAVED` occupancy map of the saved field, which is what showed the 16-column hole. Pre-filter reconstruction of all 6 decode-order frames of the pinned stream goes 1306/3358/5027/6622 wrong luma px (frames 2..5) -> 0.
fix(av1): compound MV stack zero-filled the comp_list tail libaom fills with global motionAhmet Kaan Gümüş · e2010ef
fix(av1): compound MV stack zero-filled the comp_list tail libaom fills with global motion The compound extension pass (`combine_compound_candidates`, mvstack.rs) filled the `comp_list` slots left over after `ref_id`/`ref_diff` with `(0, 0)`. libaom fills them with that side's GLOBAL MOTION vector (`setup_ref_mv_list`, av1/common/mvref_common.c:729: `for (; comp_idx < MAX_MV_REF_CANDIDATES; ++comp_idx) comp_list[comp_idx][idx] = gm_mv_candidates[idx];`). The zero fill was only right under IDENTITY global motion, the module's original reduction; aomenc has --enable-global-motion on by default. A compound block with no usable neighbour pair (frame top row, an intra block to its left, an empty temporal field) then took a (0, 0) predictor where libaom took the frame's translation -- mv0 (-1,2) vs (128,-16) on the first such block, 32890/39907 wrong luma samples on decode-order frame 2 of a 10-bit cq58/cq61 stream, with the entropy stream still in sync (180/180 TU all_zero ranges identical to aomdec). Also this round: - the no-CFL uv_mode gate's source becomes the half-random fixture, so BOTH the 8-bit and the 10-bit arm carry >=1 intra-above-32x32 block per compared attempt (the flat half made aomenc code the right-hand superblocks skip at 8 bit: 0 hits). - EC_AV1_PREFILT_DUMP16 is indexed by decode-order picture (it overwrote .f0 every frame, so a mid-sequence divergence could not be read out). - setup_motion_field prints an EC_TPL_FIELD occupancy map under the existing EC_TRACE_TPL rung. Probe grid after the fix (192x128, 6 frames, half-random geq), pixel diffs vs ffmpeg: 8-bit cq52/58/61 = 0/0/0 (5/2/3 hits), 10-bit cq52/58/61 = 0/0/0 (6/7/7 hits); was 0/0/0 and 0/32890/39907.
fix(av1): motion_field_projection returns 0 for a key/intra start frame, so a forward key frame no longer spends a ref_stamp slot; av1_copy_frame_mvs clear portedAhmet Kaan Gümüş · 718eaba
fix(av1): motion_field_projection returns 0 for a key/intra start frame, so a forward key frame no longer spends a ref_stamp slot; av1_copy_frame_mvs clear ported
fix(av1): the saved motion field stored a compound block's FIRST reference, not its secondAhmet Kaan Gümüş · 72cffab
fix(av1): the saved motion field stored a compound block's FIRST reference, not its second libaom `av1_copy_frame_mvs` walks BOTH of an inter block's reference slots and the LAST qualifying one wins, skipping a slot whose reference is on the other side (`av1_calculate_ref_frame_side`: OrderHint ahead of, or equal to, this frame's) or whose mv exceeds `REFMVS_LIMIT`. `build_motion_field` kept slot 0 unconditionally, so every compound block's 8x8 motion-field cell carried the wrong (mv, reference) pair; the next frame's `add_tpl_ref_mv` then projected it with the wrong reference distance and a NEARESTMV block took a wrong temporal candidate -- entropy exact, pixels wrong. Pinned instance (lane-inter4 r2's open "decodes fully, still mismatches"): 192x128 rect-partition inter stream, cq 34, decode-order frame 5, the 32x32 block at mi(24,40) -- ours mv0=(0,72) from mfmv0=(0,24) rfo=1, aomdec mv0=(0,-230) from mfmv0=(0,-230) rfo=3. 646 luma pixels, max delta 39. Gate: a_real_aomenc_inter_sequence_with_temporal_mv_candidates_decodes_pixel_exact (8-bit + 10-bit, every fully decoded attempt compared to ffmpeg, temporal-MV counter asserted >0: 66/67 blocks). Reverting the fix reddens it at frame 5. Class saved-field-keeps-slot-0: a per-frame summary of a multi-slot field must replay the reference's slot walk (order + skips), not keep slot 0. Instruments: EC_MODE_VAL/EC_STACK on our single-ref path, EC_TPL per add_tpl_ref_mv probe (oracle side patched to match).
2026-08-28
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.