FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
Merge main into #886 (docs)
Brandon Thomasfdf43f440f24
diff --cc docs/gaps.mdindex 956d03a2b,e2fbe1482..9249b9096--- a/docs/gaps.md+++ b/docs/gaps.md@@@ -219,14 -221,12 +221,16 @@@ platforms** G4, G9, G17; **performance*## G16. Performance reports on 0.5.0- **Missing:** steady UI under load. Constant lag after 0.4 → 0.5 (#525), ~100% CPU (#523). AV1- software decode is ~4 fps at 1080p single-threaded; 8K is not real time.+ software decode of a single-tile stream is bound by its serial tile decode (65–80 % of a+ frame; no row-level frame threading, references are waited for as whole frames); 8K is not+ real time.- **Done:** Render (Effects) In to Out renders only the frames between In and Out, as partialpreviews named by segment hash and relative frames, instead of every segment In/Out touches- (#424); Render Audio still renders whole audio segments. VP9 software decode loop-filters a- frame as a wavefront over superblock rows on the decoder's pool instead of on one thread,- bit-identical, 1.2–1.5× faster with 16 threads (#980).+ (#424); Render Audio still renders whole audio segments. AV1 software decode runs deblocking,+ CDEF and loop restoration in parallel 64-row bands, bit-exact (#847; 1080p GOP 1.16–1.30×,- low delay 1.28×, 2160p 1.14× at 16 threads).++ low delay 1.28×, 2160p 1.14× at 16 threads). VP9 software decode loop-filters a frame as a++ wavefront over superblock rows on the decoder's pool instead of on one thread, bit-identical,++ 1.2–1.5× faster with 16 threads (#980).- **Estimate:** 30–60 h. Doc: [performance.md](performance.md).## G17. Audio device and playback reliabilitydiff --cc docs/performance.mdindex 4b2c588b1,c3891fd74..3549cbcb9--- a/docs/performance.md+++ b/docs/performance.md@@@ -518,49 -518,36 +518,79 @@@ decode, and the UI-thread present (uploblended layers) stays at 9–10 ms p50, as for `stack3`. Before, every frame was composited on theCPU (≈ 2 cores more at 23.976 fps) and Full resolution could not keep up at this load.+## Results (#847: AV1 in-loop filters in parallel row bands, before → after)++The AV1 decoder ran deblocking, CDEF and loop restoration on one thread per frame. A single-tile+stream (what SVT-AV1 and most encoders write by default) has no other parallelism inside a+frame, and a frame's references are waited for as whole frames, so this serial tail sat on the+critical path of every frame that references it. The three filters now run in bands of 64 luma+rows on the decoder's rayon pool, one join per filter per frame (the loop filter recomputes the+8 rows above each band rather than splitting into two passes, because every join costs a worker+wake-up, which is slow on a busy machine). Output is bit-exact with the single-threaded path and+with libdav1d (all oracle and conformance tests, plus new 4:2:2 / 4:4:4 libaom fixtures); with+one thread the code path is the old one.++Linux, AMD Ryzen 7 7800X3D (8 cores / 16 threads), 2026-10-11, shared with other agents' builds;+base = `2ff3f5e`, after = this change, 16 decoder threads, SVT-AV1 preset 8 fixtures from+`crates/av1/tests/perf.rs` (`perf_1080p_lowdelay` and `perf_2160p_gop` are new there).++`av1dec` example (`AV1_LOOPS=2 AV1_THREADS=16`), 8 rounds alternating base / after per fixture,+load average 11–27; speed-up = base wall time / after wall time of the adjacent pair:++| fixture | fps base → after (median) | paired speed-up, median (range) | after faster | CPU ms / frame (all threads) |+|---|---|---|---|---|+| `perf_1080p_lowdelay` (each frame refs the last) | 31.0 → **39.9** | 1.28 (0.85–1.48) | 6 / 8 | 44.2 → 55.0 |+| `perf_1080p_gop` (crf 30) | 74.8 → **97.7** | 1.30 (1.06–1.41) | 8 / 8 | 30.2 → 35.9 |+| `perf_1080p_gop_hq` (crf 18) | 32.0 → **37.5** | 1.16 (1.04–1.29) | 8 / 8 | 66.9 → 77.1 |+| `perf_2160p_gop` (one tile) | 23.0 → **25.3** | 1.14 (1.08–1.41) | 8 / 8 | 103.1 → 115.5 |+| `perf_1080p_intra` (10 key frames) | 121.3 → 138.1 | 1.03 (0.92–1.21) | 4 / 8 | 40.8 → 45.5 |++Per-stage wall time on the frame worker (`tests/perf.rs`, 16 threads, ms per frame, median of 2+alternating rounds at load average 8–11):++| fixture | 16 threads fps | deblock | CDEF | restoration |+|---|---|---|---|---|+| `perf_1080p_lowdelay` | 31.8 → **48.7** | 2.03 → 0.63 | 5.16 → 1.62 | 5.81 → 1.40 |+| `perf_2160p_gop` | 24.0 → **31.9** | 2.78 → 0.81 | 7.38 → 3.74 | 7.84 → 2.70 |+| `perf_1080p_gop_hq` | 34.8 → 33.6 | 1.10 → 0.55 | 6.53 → 3.08 | 4.94 → 1.65 |++One thread is unchanged (`perf_1080p_lowdelay`, 8 pairs: 2.19–2.20 s both). The extra CPU time+is mostly rayon workers spinning briefly before they sleep after each join, plus the loop+filter's recomputed margin rows. Key-frame-only streams gain little: their frames are+independent, so frame threads already keep every core busy. What remains is the tile decode+itself (entropy decoding and reconstruction of a single tile, 65–80 % of a frame), which only+row-level frame threading (waiting for reference rows instead of whole frames) can overlap.++ ## Results (VP9 loop filter wavefront, #980, before → after)++ The VP9 post stage of a frame (band assembly, loop filter, publication) ran on one thread, and+ later frames wait per band for their references, so the loop filter (about 30 % of the decode+ profile) set the pace of every inter frame: with 16 threads the tile columns spent most of their+ time waiting for the previous frame's bands. The loop filter now runs as a wavefront over+ superblock rows (row r two superblocks behind row r - 1, which is what the raster order of 8.8.1+ allows), the post thread and helpers on the decoder's pool each taking a row. No lock is held+ while a superblock is filtered: rows exchange copies of the 8 rows the filter reaches across a+ band boundary. Output is bit-identical (the conformance tests compare 1, 2, 3, 5 and 16 threads+ with ffmpeg).++ AMD Ryzen 7 7800X3D (8 cores / 16 threads), shared with other agents' builds, 2026-10-11.+ `vp9dec` example, 16 threads, runs alternating base / after; paired speed-up = base wall time /+ after wall time per pair:++ | fixture | load | paired speed-up, median (range) | after faster | CPU ms/frame |+ |---|---|---|---|---|+ | `bench_1080p` (4 tile columns) | 15–18 | 1.39 (1.20–2.09) | 6/6 | 13.5 → 15.3 |+ | `bench_4k` (8 tile columns) | 15–18 | 1.52 (1.49–1.59) | 6/6 | 48.0 → 57.8 |+ | 1080p30 realtime, noisy (6 Mb/s) | 15–18 | 1.56 (1.27–1.72) | 6/6 | 15.3 → 20.8 |+ | `bench_1080p` | 25–33 | 1.17 (0.91–1.65) | 4/6 | 15.7 → 17.9 |+ | `bench_4k` | 25–33 | 1.29 (0.99–2.03) | 5/6 | 56.9 → 63.1 |+ | 1080p30 realtime, noisy | 25–33 | 1.53 (1.40–1.94) | 6/6 | 22.5 → 25.4 |++ With one thread the rows run one after the other: 31.12 → 31.28 G user instructions for the noisy+ 1080p clip (+0.5 %, `perf stat`). The extra CPU with threads is mostly rayon workers spinning+ before they sleep. With the machine oversubscribed (load above 16) the wavefront gains less, as+ every row waits for the one above.+## Results (M4.10: 4K VP9, AV1 and HEVC, before → after)Baseline = commit `a814ff6` (decoders unchanged since M4.8); after = M4.10. Interleaved runs on