Commits
Commits on
8841aa8c913dddf0dcfe6ca20ef00fcf45a3337d2026-09-05
perf(av1): coefficient reading -- buffered msac bit window, static scan tables, no per-block level allocationAhmet Kaan Gümüş · 8841aa8
perf(av1): coefficient reading -- buffered msac bit window, static scan tables, no per-block level allocation The frame thread's coefficient path paid four avoidable costs per transform block, all bit-exact to remove: * every symbol's renormalisation assembled five bytes out of the payload and shifted twice; `SymbolDecoder` now keeps a 64-bit window refilled once per eight bytes (`bulk_bit_reads_match_the_per_bit_form` still pins `f(n)` against the per-bit form, through the new `seek_bits`); * `symbol_fixed`/`symbol`/`f`/`update_cdf` were out-of-line across codegen units, and the CDF walk indexed a slice the bounds checker could not see the end of -- inlined, and the walk iterates instead; * `default_scan` allocated a `Vec` and regenerated the whole anti-diagonal walk on every block: one table per side (4/8/16/32), built once; * `read_coeffs` divided by the transform side per coefficient (always a power of two) and allocated its level buffer per block. instructions:u on the 4K segment at one thread: 570.76 G -> 559.11 G (-2.0%). All 12 gate hashes unchanged at 1/4/16 threads; lib suite 500 passed, 27 ignored.
Merge branch 'lane-copy' (2bbf188c): output crop is a truncation of the owned padded buffer when the width is SB-aligned; LR deblocked snapshot copies only the 4 rows per stripe boundary it can read; byte-exact. Also: grain row wrappers kept for the kernel-vs-scalar tests are cfg(test) (4 dead_code warnings from ab320fac)Ahmet Kaan Gümüş · 5a5f194Browse files
Merge branch 'lane-alloc' (ac8f45db): per-block allocation cut (debug format! strings behind env flags, intra Edges 4 vecs -> 2, OBMC neighbour buffer caller-held, mv stacks reserve their cap) + alloc_probe tracking-allocator instrument; byte-exact, -0.39% instructions on the 4K segmentAhmet Kaan Gümüş · 95d7cebBrowse files
perf(av1): the output crop and the post-deblock snapshot stop copying whole planesAhmet Kaan Gümüş · 36f0c53
perf(av1): the output crop and the post-deblock snapshot stop copying whole planes Two bulk copies on the frame thread's serial tail, both of them avoidable: * The output crop rebuilt every plane row by row whenever the padded coding surface was bigger than the visible frame. A 4K 3840x1608 frame is superblock-aligned in WIDTH and padded only in HEIGHT, so its padded buffer's stride already equals the visible width and the "crop" is a pure truncation of the buffer we already own. `crop_owned` takes the plane by value and truncates in that case, falling back to the old row-by-row copy for a genuinely narrower plane. * The post-deblock snapshot loop restoration reads cloned all three planes. Spec 7.17.2's stripe boundary substitution only ever reads the two rows above and the two below each interior stripe boundary (`restoration::lr_src_row` resolves every out-of-stripe row to `stripe_v_start-1/-2` or `stripe_v_end/+1`), and stripes are `64 >> ss_y` rows offset by `RESTORATION_UNIT_OFFSET`, so the snapshot now copies 4 rows in 64 into a pooled buffer whose other rows keep a previous frame's samples -- initialised values no reader reaches. Byte-exact: seg1080/seg4k/seg4k_lr/palette hashes unchanged at 1, 4 and 16 frame threads (the last with 4 filter + 2 recon threads).
Merge branch 'lane-grain' (643c1001): film grain noise kernels take the whole block (row loop inside, 4-wide tail step) -- per-row AVX2 on 15-wide chroma blocks paid the prologue per row and sent half the samples to the scalar tail; byte-exact, -2.7% instructions on the 4K segmentAhmet Kaan Gümüş · 9346288Browse files
perf(av1): remove four per-block allocation sites from the parse pathAhmet Kaan Gümüş · d4c852e
perf(av1): remove four per-block allocation sites from the parse path
lane-alloc. A tracking global allocator (new `alloc_probe` example: size
histogram plus a sampled backtrace per 512 allocations, with line numbers)
ranked the decoder's allocation sites on the 4K segment -- 83.6 M
allocations over 272 frames. Four of the top sites are removed here:
* `find_samples` built a `String` per warp block (`format!("{mi_row},
{mi_col}")` plus the env snapshot's own `String` clone) to compare against
an unset debug flag; the OBMC blend did the same for `EC_MCB`. Both now
sit behind the per-call-site `env_flag!` load.
* `Edges::build` allocated four vectors per intra prediction (collect,
grow, then a second buffer to prepend the corner); it builds each edge
once, corner first. `directional`'s two working buffers were a copy of
those same vectors, so it takes the `Edges` by value instead.
* `obmc_neighbour_pred` allocated its prediction buffer per neighbour per
plane; the caller now keeps one buffer per plane for the whole block.
* The MV stacks and the OBMC neighbour lists are capped (8 entries /
`max_neighbors`), so they reserve once rather than growing and memcpying
up to four times.
seg4k at one thread: 601.657 -> 599.329 G instructions:u (-0.39%, perf stat
-r 3). Reverting only the reserve step measured 600.014 G, so it stays
despite raising the raw allocation COUNT (an empty stack now allocates):
the saved reallocation memcpys outweigh the extra tcache hits.
Byte-exact: sha6t hashes equal the reference for all four streams at
threads 1, 4 and 16 (the last with FILTER_THREADS=4 RECON_THREADS=2).Merge branch 'lane-sgr' (55600639): sgrproj compute_ab box sums over a contiguous edge-replicated row in i32, (A,B) map as an AVX2 row pass; byte-exact, -0.86% instructions on the LR segmentAhmet Kaan Gümüş · 184abb3Browse files
perf(av1): film grain noise rows take the whole block in one AVX2 callAhmet Kaan Gümüş · 4786458
perf(av1): film grain noise rows take the whole block in one AVX2 call The 32x32 grain block is 30 luma / 15 chroma samples wide once the 2-column overlap is cut off, so the per-row AVX2 kernels paid their 10-broadcast prologue once per row and handed the `30 % 8 == 6` / `15 % 8 == 7` remainder to the scalar loop -- half of every chroma row. That is why `chroma_noise_row_scalar` outweighed the AVX2 kernel it was supposed to be the fallback of. The row loop moves inside the kernels (`luma_noise_rows` / `chroma_noise_rows`, strides and a row count), so the prologue is paid once per block, and the remainder takes a 4-wide SSE step before the at most 3 scalar samples. The row-level entry points stay as thin wrappers for the tests that pin them against the scalar reference. seg4k at one thread: 601.754 G -> 585.462 G instructions:u (-2.7% of the whole decode, a quarter of film grain's 65 G). Byte-exact: all four gate hashes unchanged at 1 and 4 threads.
perf(av1): sgrproj box sums in i32 over a contiguous row, (A,B) map under AVX2Ahmet Kaan Gümüş · 9c6f09f
perf(av1): sgrproj box sums in i32 over a contiguous row, (A,B) map under AVX2 `compute_ab` fetched every window sample through `lr_sample` -- a stripe-boundary decision plus a column clamp per element -- and carried both box sums as `i64`. A sample is at most `2^bd - 1 <= 4095`, so the widest window sum of squares is `25 * 4095^2 == 419M`: the sums fit `i32` with room to spare, and the column clamp is a pure function of the column, so one contiguous per-row copy with the plane edge replicated serves the whole accumulate pass branch-free. On top of that the per-grid-point `(A[k], B[k])` map -- the part a previous lane measured as the real cost -- becomes a straight-line pass over two row arrays, so it runs eight points at a time under AVX2: lane-wise the same arithmetic, with the only two products that exceed 32 bits (`p * s` and `(256 - A) * one_by_x * b`) formed in 64-bit even/odd halves and packed back after their rounding shift, and `av1_x_by_xplus1` read by gather. `ab_point` stays the scalar reference for the tail and for every non-AVX2 target. Byte-exact: all four gate streams hash identically to the parent at 1 and 4 threads. instructions:u on the 4K restoration segment 602.650 G -> 597.501 G (-0.86%; -0.29% from the sums, -0.57% from the AVX2 map).
Merge branch 'lane-wave5' (83a87ee2): reconstruction wavefront takes jobs from per-superblock-row queues (one raster FIFO had serialised workers on one row); EC_AV1_WAVE_STATS instrument; byte-exact at all settings; 4K 32.1 fps at (16,4,2), 1080p 75 fpsAhmet Kaan Gümüş · 8cdbcf4Browse files
perf(av1): recon workers pick per superblock ROW, not raster orderAhmet Kaan Gümüş · bdf81cd
perf(av1): recon workers pick per superblock ROW, not raster order At EC_AV1_RECON_THREADS > 1 the wavefront handed out jobs from one FIFO in raster order, so N workers popped N CONSECUTIVE superblocks of the SAME row -- which the wavefront rule serialises (a job waits on its own left neighbour). The workers then all blocked on one dependency chain and the tile ran near-serial: 4 workers, 155% CPU, 1.23x. The queue is now per superblock row and a worker takes the lowest row whose front job's dependencies are met, which is the only job of that row that can be runnable; deadlock-freedom is unchanged (the globally oldest job is always runnable once no worker is active). EC_AV1_WAVE_STATS=1 dumps the per-worker busy/wait/jobs accounting, the parse-thread time between submits and the barrier/drain waits, cumulatively, on every tile. seg4k (frame,filter,recon)=(1,1,4): 24.43 s -> 22.90 s, the parse-side barrier wait 1917 ms -> 123 ms over the same 6712 barriers. All 12 sha6t hashes exact at (1,1,1), (1,1,4) and (16,2,2).
Merge branch 'lane-t900' (196962d8): worker threads named by class (frame/recon/filter), dead wavefront helpers deleted, last warning cleared; byte-exactAhmet Kaan Gümüş · f37b756Browse files
refactor(av1): name the pool worker threads by submitting class; drop two dead recordersAhmet Kaan Gümüş · 9a4d798
refactor(av1): name the pool worker threads by submitting class; drop two dead recorders The persistent pool is thread-local and shared by every class a thread submits, so a worker's name is the class that grew the pool for it: `ec-av1-frame` (stream.rs), `ec-av1-recon` (the tile wavefront) and `ec-av1-filter` (par::run_bands), plus its index. The test-only ffmpeg and aomenc stdin writers in decode.rs/stream.rs get names too. Also deletes `push_intra_owned`/`push_mc_rect_owned`, dead since the wavefront lanes, and replaces a `drop` of a `Copy` `Shared` in film_grain.rs with `let _ =`, which was the last ec-av1 warning. Byte-exact: the four perf6 inputs hash unchanged at default and at (6,2,4) threads.
Merge branch 'lane-pool1' (3362287c): persistent per-thread worker pools replace per-frame and per-tile thread spawns; DPB slots, reorder queue and outputs carry Arc<Picture> instead of copies; byte-exact at every thread setting on four inputs; 4K reaches real time from 12 frame threads (16,2,2 = 27.5 fps)Ahmet Kaan Gümüş · 2504addBrowse files
perf(av1): the reference bank and the output queue share the pictureAhmet Kaan Gümüş · 900cf2d
perf(av1): the reference bank and the output queue share the picture A decoded frame's picture was copied once per reference slot it refreshes and once more to leave the worker (`Arc::try_unwrap` never succeeded -- the slot promise holds the other handle), 24 MB per copy at 4K 10-bit. `ref_slots`, `Reorder` and the worker reply now carry `Arc<Picture>`: the sink still takes `&Picture`, so no public signature moves, and grain (which must not be stored in the bank) still allocates its own output. seg4k, all 12 sha6t hashes unchanged at (1,1,1), (6,2,4), (1,1,4). Single thread: 30.39 s -> 29.71 s, page faults 397 k -> 111 k, instructions:u 599.40 -> 600.57 G (+0.20%). Composed (6,2,4) best-of-2 interleaved: 12.58 s base -> 12.08 s, page faults 3.77 M -> 0.85 M.
perf(av1): persistent worker pools instead of per-frame and per-tile threadsAhmet Kaan Gümüş · a02c7bd
perf(av1): persistent worker pools instead of per-frame and per-tile threads Every threaded stage spawned its threads per unit of work: one `thread::scope` per filter stage per frame, `EC_AV1_RECON_THREADS` workers per tile, one frame worker per coded frame -- 2363 distinct threads in a 13 s 4K decode. What died with each of them was the `thread_local!` decode scratch (planes, rows, dq, mc, wiener, sgr), re-allocated and re-faulted on every new thread. `par::Batch` submits jobs to a pool owned by the submitting thread (thread-local, joined at thread exit), growing to `busy + queued` so a job never queues behind a blocking one -- the recon wavefront's workers block on their own dependencies. `Batch`'s drop waits every job out and re-raises the first panic, which is `thread::scope`'s contract minus the spawns, so the three call sites keep their borrows. Byte-exact: all 12 sha6t hashes at (frame, filter, recon) = (1,1,1), (6,2,4) and (1,1,4). seg4k (6,2,4) best-of-2 interleaved: 13.02 s -> 12.24 s.
Merge branch 'lane-wave1' (4c9f7f81): inter prediction of both decode_inter_block arms deferred to the reconstruction worker as a closure op; interintra blend on the worker; byte-exact at recon 1, 4 and the composed setting; 11% faster at recon-only settings, neutral at the composed bestAhmet Kaan Gümüş · 33312b9Browse files
perf(av1): a deferred transform unit takes its window on the worker, not a strided residualAhmet Kaan Gümüş · 3d6af60
perf(av1): a deferred transform unit takes its window on the worker, not a strided residual lane-wave4: recording a unit's prediction as an offset into the block made the worker lay its residual out at the block's stride again (a 4x4 unit of a 64-wide block meant a 64x64 i32 grid). The residual stays dense and the worker copies the w x h window out of the block prediction instead -- the copy the parsing thread used to make. Byte-exact, wall unchanged.
perf(av1): a compound inter block predicts on the worker tooAhmet Kaan Gümüş · 52da7db
perf(av1): a compound inter block predicts on the worker too lane-wave4: the compound arm's whole prediction -- both references, the wedge/diffwtd/distance blend, all three planes -- becomes the same deferred closure the single-reference arm got. A compound block reads neither motion_mode nor interintra, so its build has nothing that must stay on the parsing thread.
perf(av1): a single-reference inter block predicts on the worker that reconstructs itAhmet Kaan Gümüş · 4a7d65a
perf(av1): a single-reference inter block predicts on the worker that reconstructs it lane-wave4: the whole-block prediction of `decode_inter_block`'s single-reference arm (motion compensation + warp + the interintra blend) is now a closure instead of a buffer. At one reconstruction thread the parse thread runs it at the same point as before; at EC_AV1_RECON_THREADS > 1 it is pushed as a `ReconOp::Pred` and runs on the wavefront worker, whose transform units then read their windows out of it -- so mc no longer runs on the parsing thread there. The interintra blend goes with it, which retires that arm's `flush_recon` barrier: the wavefront rule already guarantees the block's own edges. OBMC and the sub-8x8 chroma piece still build inline (both can fail, and a recorded op cannot report it). Also fixes the inline path stage 1 broke: a window handed over at the block's stride was reconstructed against a dense residual.
refactor(av1): a recorded inter write names where its prediction comes fromAhmet Kaan Gümüş · 8aa7db1
refactor(av1): a recorded inter write names where its prediction comes from lane-wave4 step 1: `ReconOp::Mc` carries a `PredSrc` (an owned window, or an offset into the block prediction a worker builds) and the inter readers take a `Pred` instead of a slice, so a prediction can be deferred without touching every call site again. No deferral yet: every site passes `Pred::dense`, which is the same window copy as before.
Merge branch 'lane-wave1' (22e1ab44): dequantisation and inverse transform run on the reconstruction workers from recorded coefficients; Mc ops carry only their transform-unit window; byte-exact at recon 1, 4 and the composed setting; 4K 21.3 fps at (6,2,4)Ahmet Kaan Gümüş · 11ef8caBrowse files
Merge branch 'lane-perf11' (2f7fcb64): CDEF band body as a real function with reference parameters (alias facts restored); byte-exact at 1 and 4 filter threads, 0.9% fewer instructions at 4KAhmet Kaan Gümüş · f97a50bBrowse files
perf(av1): a recorded inter write carries its own transform unit, not the blockAhmet Kaan Gümüş · 89f1aa3
perf(av1): a recorded inter write carries its own transform unit, not the block reconstruct_mc_rect reads exactly rows 0..h and columns 0..w of the two buffers, so recording the whole block prediction copied 64*64 samples on the parsing thread for a 4x4 unit. The record now holds that window densely at stride w, and the deferred residual is produced dense to match (TxParams::stride = 0) -- the same numbers in the same places. Byte-exact at recon 4 on all four probe inputs.
perf(av1): the inverse transform travels with the recorded write, not its resultAhmet Kaan Gümüş · c027c27
perf(av1): the inverse transform travels with the recorded write, not its result
A recorded reconstruction carried the already-transformed residual, so the
parsing thread ran the dequantization and the inverse transform for every
transform unit before a recon worker ever saw it. The three fused
coefficient readers now record TxParams + the coded grid instead
(ReconOp::{Intra,Mc}.residual is a Residual: Done or Coeffs), and
TxParams::run is the single copy of the produce-the-residual code both
paths call -- so at EC_AV1_RECON_THREADS=1 it still runs at the push site,
unchanged, and above 1 it runs on the worker.
Byte-exact at recon 1 and 4 on all four probe inputs (seg1080 c2d4ef66,
seg4k 3ac25ee5, seg4k_lr d197dbe0, palette 2bfb6839).Merge branch 'lane-wave1' (384ed8e6): reconstruction recorded as replayable ops with an inline fast path at one recon thread; superblock-row wavefront workers behind EC_AV1_RECON_THREADS (default 1, measured no gain yet: parse still builds predictions); byte-exact at all thread settings, default path 0.6% fewer instructionsAhmet Kaan Gümüş · 34a3d01Browse files
test(av1): the direct-call NEARMV gate replays its own recorded writesAhmet Kaan Gümüş · c28f320
test(av1): the direct-call NEARMV gate replays its own recorded writes Left red by step (i) (ace5dcb9), which this lane inherited: the gate calls the inter block decoder itself and reads the luma plane back, but a direct caller records its writes now -- only the tile decoder replays them -- so it compared an untouched plane against the reference prediction. It is the one test in `ec-av1 --lib` in that shape (499 passed, this one failed).
perf(av1): reconstruction on a superblock-row wavefront (EC_AV1_RECON_THREADS)Ahmet Kaan Gümüş · f7306dd
perf(av1): reconstruction on a superblock-row wavefront (EC_AV1_RECON_THREADS) lane-wave1 step (ii). Above one reconstruction thread the parser keeps parsing and never writes the planes: each superblock's drained `Vec<ReconOp>` becomes one job (one per 128x128 superblock when `sb128`, since a 128 block writes across its four 64x64 visits), and N scoped-per- tile workers reconstruct them in wavefront order -- job `(r, c)` starts once `(r - 1, min(c + 1, last_col))` and `(r, c - 1)` are complete, which covers every pixel an intra predictor can reach and every CfL AC read. Jobs are handed out in raster order, so the oldest outstanding one always has its dependencies met; a `WaveGuard` joins every worker on each exit from the tile decoder, including the `?` ones. The two parse-time pixel READS (the intrabc source fetch, the interintra intra predictor) keep their `flush_recon`, which now waits the wavefront out first and replays the current superblock inline -- so an intrabc block serialises the tile at that point instead of trusting the spec's 256-px delay against our lag, and stays byte-exact. MEASURED and it does not pay: seg4k 31.8 s at (frame, filter, recon) = (1,1,1) vs 31.9 s at (1,1,4) with CPU 99% -> 117%, seg1080 9.4 -> 9.9 s; with frame threading it is a loss (seg4k 13.5 s at (6,2,1) vs 14.5 s at (6,2,4)). Recording the ops copies the residual and the MC prediction on the PARSE thread, which cancels what the workers take off it. Default stays 1 (inline), where nothing is recorded at all. Byte-exact: sha6 on seg1080/seg4k/seg4k_lr/palette at recon 1, at recon 4, and at EC_AV1_THREADS=6 EC_AV1_FILTER_THREADS=2 EC_AV1_RECON_THREADS=4; new gate `a_real_stream_reconstructs_identically_with_one_and_four_recon_threads` on reelb_arf_witness (hidden ARF, 10-bit) and both palette/intrabc screen witnesses.
perf(av1): CDEF band body as a real function, so its plane writes are noaliasAhmet Kaan Gümüş · 065f637
perf(av1): CDEF band body as a real function, so its plane writes are noalias The CDEF row band ran as the body of the `run_bands` closure, where the three destination planes are `&mut PlaneBuf` derived from a `par::Shared` raw pointer in the same scope as the `src_*` pre-CDEF snapshot reads. LLVM cannot tell those apart, so every tap re-loaded plane fields and snapshot samples it had just read. Lifting the band into `cdef_band`, whose planes and snapshots arrive as distinct reference parameters, restores the alias facts; the strength lookup moves in with it (the grid arrives as `&[u8]`). Pure restructuring -- same walk, same order, same arithmetic. seg4k instructions:u 607.187 G -> 601.987 G (-0.86%), wall median of 3 30.50 s -> 30.27 s; seg1080 189.813 G -> 189.790 G, wall 9.23 s -> 9.28 s (noise). Byte-exact: all four gate streams hash identically at EC_AV1_FILTER_THREADS=1 and =4.
perf(av1): recorded writes run inline at one reconstruction threadAhmet Kaan Gümüş · 9258b06
perf(av1): recorded writes run inline at one reconstruction thread lane-wave1 step (ii), first half. Step (i) deferred every recorded `ReconOp` to the end of its superblock, which cost +1.2% instructions and +4.5% wall on 4K: the residual is written at parse and read back cache-cold at replay. `EC_AV1_RECON_THREADS` (default 1) now decides. At 1 the tile decoder registers its three planes (`ReconInline`, dropped on every exit from the tile including `?`) and every `push_*` performs its write on the spot, with the residual still borrowed -- no record built, no queue, no `to_vec`. Above 1 the queue behaves exactly as step (i) left it, for the wavefront workers to come. Measured against 69e1e50e, interleaved, same box: seg4k 607.12 -> 603.33 G instructions:u (-0.62%), seg1080 189.81 -> 188.83 G (-0.52%); wall inside the run-to-run noise on both (seg4k 30.5 vs 30.0-30.9 s, seg1080 9.2 vs 9.1-9.7 s). sha6 byte-exact on seg1080/seg4k/seg4k_lr/palette.
perf(av1): the recorded residual moves, and the record queue keeps its capacityAhmet Kaan Gümüş · d5fa0c1
perf(av1): the recorded residual moves, and the record queue keeps its capacity Two costs the plain record/replay split paid for nothing: the three fused coefficient readers copied a residual that is dead the instant it is recorded (now moved through `push_intra_owned`/`push_mc_rect_owned`), and `flush_recon` dropped the whole queue's allocation every superblock, so the next one regrew it from zero (now swapped through `recon_spare`). seg4k instructions:u 616.06 G -> 614.25 G, seg1080 193.18 G -> 192.37 G. Byte-exact on all four gate inputs, unchanged.
2026-09-04
refactor(av1): entropy parse split from reconstruction inside the tile decoderAhmet Kaan Gümüş · 1499973
refactor(av1): entropy parse split from reconstruction inside the tile decoder Step (i) of the decode-speed wavefront: a superblock's parsing no longer writes (or reads) the frame's own planes. Every `PlaneBuf::reconstruct*` call is recorded as a `ReconOp` on `FrameCtx::recon_ops` -- the resolved argument tuple of the call it replaces -- and `flush_recon` replays the queue, in push order, at the top of each superblock visit and at the end of each tile. Same thread, same order, so the output is byte-identical, and step (ii) can hand the replay to a superblock-row worker. Three pixel dependencies that used to sit in the middle of parsing moved with it: - the CfL AC signal is no longer read at parse time (it wanted this block's own luma, which is now still queued); parse records the luma window as a `CflSrc` and the replay reads it back off the luma it has just written; - the palette/intrabc prediction override no longer crosses into reconstruction through `FrameCtx::palette_pred` -- the push site takes it, in parse order, and carries it in the record, so `reconstruct`/ `reconstruct_rect` take it as a parameter; - `reconstruct_mc` folded into `reconstruct_mc_rect`, its only body. Two parse-time pixel READS survive and flush ahead of themselves instead: the intrabc source fetch and the interintra intra predictor. They are what step (ii) still has to move, and naming them is the point of doing it this way. Byte-exact at 1 thread on seg1080/seg4k/seg4k_lr/palette_screen_witness.
Merge branch 'lane-perf10' (6316b059): reference planes borrowed instead of copied nine times per inter frame (PlaneBuf data as Cow), DC-only column broadcast in the inverse transform, DCT network on fixed arrays; conflict with the banded deblock resolved by forcing the output plane owned once before banding; byte-exact at 1 and 4 filter threads on four inputsAhmet Kaan Gümüş · 1a45793Browse files
Merge branch 'lane-filt1' (616629c3): in-frame filter bands on scoped worker threads for deblock, CDEF, loop restoration and film grain (EC_AV1_FILTER_THREADS, default 1); byte-exact at 1 and 4 filter threads on four inputs; 4K 34.4 s to 28.4 s at four filter threadsAhmet Kaan Gümüş · 1325edfBrowse files
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): run the inverse DCT network on a fixed-size scratch arrayAhmet Kaan Gümüş · e428d82
perf(av1): run the inverse DCT network on a fixed-size scratch array Every butterfly, Hadamard and permutation of the spec's DCT network indexes the 64-entry scratch with a computed index, and on a `&mut [i32]` each one carried its own bounds check against a length the optimiser could not see. The network now runs on `&mut [i32; 64]`, which discharges them against the constant length; `inverse_dct` keeps its slice-taking signature as a wrapper for callers outside the 2D driver, and `inverse_1d` calls the fixed-size body directly. Byte-exact on seg1080/seg4k/seg4k_lr/palette_screen_witness. seg1080 189.06 G instructions (was 190.19 G, -0.59%); seg4k 599.04 G (was 602.71 G, -0.61%).
perf(av1): broadcast the column transform when the row pass leaves one constant rowAhmet Kaan Gümüş · 7086b91
perf(av1): broadcast the column transform when the row pass leaves one constant row The dominant inter residual is DC-only: the row pass then writes a single non-zero row that is constant along its length, and the column pass runs the same `inverse_1d` on the same input vector once per column, `w` times over. `inverse_transform_2d_typed_wh` now counts the non-zero rows the row pass produced and whether the first of them is constant. When there is at most one such row, one column transform is run and its output broadcast across each output row -- byte-identical to the `w` transforms it replaces (`inverse_1d` is a pure function of its input), and the per-column gather goes with them. Byte-exact on seg1080/seg4k/seg4k_lr/palette_screen_witness. seg1080 190.19 G instructions (was 193.75 G, -1.84%); seg4k 602.71 G (was 604.37 G, -0.28%).
Merge branch 'lane-t900' (05619ce6): the two gate counters that were never read now print and assert (rect-residual refusals == 0 in the 1:4 sweep; superres census reports unknown strings before failing)Ahmet Kaan Gümüş · 88512b4Browse files
perf(av1): reference planes borrow the DPB picture instead of copying itAhmet Kaan Gümüş · c42b240
perf(av1): reference planes borrow the DPB picture instead of copying it `decode_inter_frame_tile_with_cdfs` built a `PlaneBuf` for the LAST reference and for each of the eight `ref_frame_idx` slots by collecting the picture's `u16` planes into fresh `Vec`s -- nine full-frame copies per inter frame (about 166 MB per 4K frame), and 72% of the tile function's own self time in a `perf annotate` of a 1080p decode. `Picture`'s planes are already `u16`, so the `map(|&s| s as u16)` was a memcpy with extra steps. `PlaneBuf::data` becomes `Cow<'a, [u16]>`: the reference planes borrow, everything the decoder writes to stays `Cow::Owned` (`to_mut()` at the fourteen mutating sites is free on an owned buffer). Mutable plane parameters take `PlaneBuf<'static>` so the `&mut` invariance never forces two output planes' lifetimes to unify. Byte-exact on seg1080/seg4k/seg4k_lr/palette_screen_witness. seg4k 604.37 G instructions (was 607.45 G), 39.5 s wall (was 44.0 s); seg1080 193.75 G (was 194.50 G), 12.4 s (was 13.5 s).
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
test(av1): two gate counters incremented and never read now report and assertAhmet Kaan Gümüş · 9c001a3
test(av1): two gate counters incremented and never read now report and assert class [[gate-blind-to-feature]], two instances in stream.rs `mod tests`: - the 16x16 1:4-partition gate's `rect_residual_refusals` counted attempts stopping on "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding" and never printed or asserted it. The refusal string still exists in decode.rs but is narrowed past this shape: the sweep now reaches it ZERO times at either depth (attempt 1, the recipe r5 recorded stopping there, decodes). Reported in the summary and pinned at 0. - the superres census's `other` was incremented and then panicked on in the same arm, so the CENSUS line -- the gate's whole output -- never printed when an unknown refusal fired. Unknown strings are collected instead, counted in the summary, and asserted empty after it.
Merge branch 'lane-t900' (2af10b5d): ec-av1 release build warnings 300 to 0 (gate-counter accessors allowed with reasons, table docs, dead initialisers dropped); byte-exact on four inputsAhmet Kaan Gümüş · d6f9cd4Browse files
perf(av1): a show_existing_frame output no longer stalls the parsing threadAhmet Kaan Gümüş · fada71e
perf(av1): a show_existing_frame output no longer stalls the parsing thread The parser waited for the named slot's promise before emitting the picture, and that wait was where the whole decode went: 7.9 s of an 8.8 s 1080p decode and 18.9 s of a 23.3 s 4K one, measured with a counter around the wait. A stalled parser dispatches nothing, so every worker drained behind it. The output job now runs on a worker too (wait for the slot, synthesise grain, send): the parser only copies the promise into the slots the header refreshes, which needs no value at all. The wait still points at an earlier coded frame, so the deadlock argument at `SlotPromise` is unchanged. Frame decodes and output jobs are bounded separately (`threads + 2` each): an output job is a wait plus a memcpy, so letting it hold a decode's budget just idles a core (4K 18.7 s at 244% CPU sharing one bound, 17.7 s at 287% not). seg4k 272 frames: 35.7 s at 1 thread -> 18.7 s at 4 (was 24.2 s before this commit); seg1080 299 frames: 10.5 s -> 8.0 s (was 9.4 s). All twelve gate hashes unchanged at 1, 2 and 4 threads.
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.
Merge branch 'lane-t900' (f90d83a1): intrabc under 128x128 superblocks (fallback DV keyed on the sequence SB size) and palette blocks with residual on superblock-level strips (chroma palette override on the non-skip arm); both refusals lifted and gatedAhmet Kaan Gümüş · 16ae97fBrowse files
fix(av1): a non-skip palette block on a superblock-level strip lost its UV predictionAhmet Kaan Gümüş · 3a302e7
fix(av1): a non-skip palette block on a superblock-level strip lost its UV prediction
`decode_block_rect64` built the UV-palette prediction buffers and
installed them into the PALETTE_PRED slot only in its `skip` arm. The
non-skip arm reconstructed both chroma planes straight from
`reconstruct_rect`'s edge prediction, so a palette block with a real
residual on a 64x32/32x64 strip decoded its luma exactly and both
chroma planes wrong -- which is why the shape was refused by name
("corner-cropped luma coefficients not ported for palette", a
misattribution: the corner crop was never the defect).
FIRST BAD: testsrc2 128x128 10-bit cq55 `--tune-content=screen
--enable-palette=1 --min-partition-size=8 --sb-size=64 --tile-columns=1
--enable-tx-size-search=0`, the 32x64 strip at px=96: luma byte-exact,
U/V each 512 samples wrong over the block's 16x32 chroma footprint.
Installing the per-plane override right before each chroma
`reconstruct_rect`, exactly as the `skip` arm does, makes the frame
byte-exact against ffmpeg.
Class: an override slot installed on one arm of a skip/non-skip split.
Swept every palette+residual reconstruct path in decode.rs (rect, rect4,
rect_split, leaf_rect, leaf8, block, inter_block, inter_block8): this
was the only site missing the install.
The gate that documented the refusal now asserts zero refusals and a
non-zero superblock-strip palette count; inventory row deleted.feat(av1): intrabc under a 128x128 superblock decodes by defaultAhmet Kaan Gümüş · c4ca926
feat(av1): intrabc under a 128x128 superblock decodes by default `av1_find_ref_dv` (mvref_common.c) takes `mib_size` -- the sequence's superblock size in mi units -- so under `use_128x128_superblock` the fallback block vector is one 128-px superblock up, or 128 + INTRABC_DELAY_PIXELS to the left on the tile's first superblock row. `read_intrabc_dv` hardcoded the 64-px superblock, which is why the frame-header refusal "intrabc under a 128x128 superblock" existed. Reading it off `sb_mi_cur` lifts the refusal: all four arms of r33's census (`--sb-size=128 --tune-content=screen --enable-intrabc=1`, both `--enable-tx-size-search` settings, cq 30/45, 2x2-tiled 128x96 bars at 256x192) now decode pixel-exact against ffmpeg, so the r33 census is replaced by the un-ignored witness it pinned, which additionally asserts a non-zero decoded-intrabc-block count so a stream that stopped using intrabc cannot make it vacuous. Inventory row deleted.
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.
Merge branch 'lane-t900' (89195e5c): refusal inventory closed, 35 of 35 proven by enumeration, census or negative gate; dead palette guards deleted; sb128 intrabc gap pinned with a waiting witnessAhmet Kaan Gümüş · e5de66dBrowse files
test(av1): census the last three unproven refusals; pin the sb128-intrabc gapAhmet Kaan Gümüş · da8c1a6
test(av1): census the last three unproven refusals; pin the sb128-intrabc gap The three intrabc refusals are the inventory's residue, and all three are now measured against real aomenc streams rather than asserted: * sb128 + intrabc is REACHED -- all four `--sb-size=128` exact-repetition screen arms code `use_128x128_superblock && allow_intrabc` and every one of them refuses by name. A capability gap, pinned with its first-bad recipe and a waiting (ignored) pixel-exact witness; * a sub-8x8 leaf's `use_intrabc` symbol is read 38 times over two `--min-partition-size=4` arms and comes back 0 every time, frames exact; * the intrabc var-tx tree is read for 5 blocks over four quantisers, every one resolving to a uniform leaf size, frames exact. refusal inventory: 35 refusals / 32 proven -> 35 refusals / 35 proven.