forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on fbc29d12fa2e194b105dd2344342fc50da4e90cdFiltered to crates/engine/src/waveform.rsClear filter

2026-09-24

🐛 fix(engine): the counter claims hold under a parallel runnerAhmet Kaan Gümüş · 60c5322
🐛 fix(engine): the counter claims hold under a parallel runner

W1: `a_summary_pass_folds_the_file_once` -- and the parent revision's
`an_envelope_over_the_ceiling_is_not_held` -- asserted on process-wide counter
deltas, so under `cargo test`'s parallel default a sibling test's pass landed
inside the delta. Reproduced here before the fix: `cargo test -p engine --lib --
waveform::` (default threads) -> 2 failed of 18, both counter tests, both green
serially. Two mechanisms, one per kind of interference:

- `MEMO_DECODES` is keyed by the ask now (`memo_decodes(path, stream, bps)`): it
  is the one counter another *module* moves (the playback seat test opens a
  visualizer seat on a short fixture, which is a whole-envelope ask), and a keyed
  count makes a test's claim about *its* source -- which is always a private copy
  of a fixture, so the key is the test's alone.
- the module's tests take `counters_serial()`, because `VIZ_DECODES` and
  `VIZ_FOLDED` are still process-wide and a test that *decodes* moves what a
  reading test measures. The lock is documented with its upgrade path (keying
  those two as well) and with why it is module-wide rather than reader-only.

Evidence: three parallel `cargo test -p engine --lib -- waveform:: playback::`
runs and one serial run -> 33 passed, 0 failed, every time. FAIL-BEFORE (default
runner, before this commit): 2 failed -- `a_summary_pass_folds_the_file_once`
(`folded 1440000 frames of a 960000-frame file, 1.50x over`) and
`an_envelope_over_the_ceiling_is_not_held`.

W2: the seat test's doc now says what the parent revision actually did -- a
1920x1 canvas died in the *painter* (`decode.rs`'s zero line clamped with
`max = -1`, `min > max`) and a 321x181 one died in the conversion on the
*canvas's* chroma plane (`len is 14400 but the index is 14400`, a full plane and
not an empty one) -- and says plainly that the test is a guard, not a
reproduction: a frame still arrives on the parent, which is why the masking is
the fix.

W3: the whole-envelope painter test's comment no longer claims the painter
hard-codes `VIZ_BUCKETS_PER_SEC`; a view carries its own rate and the painter
indexes by it.

Class sweep: the other process-global counter in this crate is
`ao.rs:22 DEVICES_OPENED`, asserted absolutely by `ao.rs:362`
(`AoSession::devices_opened() == 0`) -- the same class, one file this lane does
not own, so it is named rather than fixed. The `NTH` counters in `demux.rs:3385`
and `scratch.rs:38` only generate names and are not read as claims.
🐛 fix(engine): a window starts at the bucket the decode was asked forAhmet Kaan Gümüş · e5f0b93
🐛 fix(engine): a window starts at the bucket the decode was asked for

RW1, and it is the real one: `viz_window` opens the file at the bucket it is
handed, `fold_window` indexes the slice from there, so `peaks[0]` *is* absolute
bucket `first`. `view_at` labelled it `first - seek` and served the margin --
so every `view.at(abs)` of a windowed frame read the envelope's bucket
`abs + 12000`: +3 s at 4000 buckets a second, the file's tail painted silence
(slice exhausted), and a preview frame at a window grid line was not the frame
export paints from the whole envelope. The fix is the label: ask from
`first.saturating_sub(seek)` and serve what comes back, which is what the margin
was always for.

Two of my own fixtures could not see it, and that is the lesson worth writing
down: a five-second clip's first window starts at bucket 0 (where the label is a
no-op) and the 40-minute FLAC was a 440 Hz sine at 8 kHz, whose 3 s shift is
1320 whole periods -- every bucket identical. The new test is *noise* in FLAC:
buckets must be *equal*, not merely close, at the file's head, its middle, both
sides of a 30 s grid line and its last window, and the frame at each has to be
the frame `visualizer_i420` paints for the same time. FAIL-BEFORE, this tree:
`t=30.5: 8002 of 8002 windowed buckets are not the envelope's, 0 out of reach`;
PASS-AFTER: 18 waveform tests green.

RW3: the summary pass folded the ask's whole-file probe and then re-decoded the
same sound in the windows it spawned -- 1.875x a file at the eight-window
ceiling, serial, on the first look edit's critical path. The first window now
stops at the joint the next was told to start at, exactly as the envelope's own
split stops it, so the windows partition the file and a pass reads it once.
FAIL-BEFORE: `folded 1440000 frames of a 960000-frame file, 1.50x over`;
PASS-AFTER: the same test asserts within 5% of 1.00x, and the peak/length
equalities against the whole envelope still hold (`viz_summary`'s stop samples
now mirror `peaks_over`'s, so it folds the same sample set).

RW5: `VizView` carries `per_sec`, the rate its envelope was drawn at, and the
painter reads it instead of hard-coding `VIZ_BUCKETS_PER_SEC` -- the invariant is
structural now (an ask at another rate is painted at that rate) rather than
accidental. `VizView::whole` is the one place the visualizer's rate is named.

RW4b: the seat now declares the canvas masked to even dimensions and floored at
two, which is what the painter returns -- an odd `resolution 1921 1081` line used
to declare a size the planes never had. Kept as an invariant, *not* claimed as a
reproduced fix: the witness (canvases 1920x1, 1921x1081, 320x1, 321x181 through
`PlaybackSession::set_resolution` + `try_frame`) passes with the mask reverted as
well, so I could not reproduce the panic on this tree and say so in the test's
own doc. RW4a is refuted: the even-dimension mask lives in the shared painting
body (`visualizer_window_i420`, decode.rs:2199-2200), which both entry points go
through; `visualizer_i420` is a one-line wrapper over it.

Also honest-doc fixes from the same review: RW2's notice doc no longer implies a
front-end shows a mid-session death (it is fetchable through
`audio_disabled_reason`, which the app reads where a notice is *built*); and a
failed window's comment now matches the code (the seat latches it, the memo does
not).
📝 docs(engine): the seat remembers a window that would not open, the memo does notAhmet Kaan Gümüş · 7cb30bf
📝 docs(engine): the seat remembers a window that would not open, the memo does not

The comment claimed the opposite of what the code does: a window that fails to
decode is latched in the seat's own handle -- as an empty slice, for as long as
it paints in that window -- precisely so a file that is not there is not asked
thirty times a second. The memo still keeps successes only, so the next window
and the next seek ask again. Comment only; no behaviour changed.
⚡️ perf(engine): a film's visualizer reads a window of its envelope, not the whole fileAhmet Kaan Gümüş · 0cf7335
⚡️ perf(engine): a film's visualizer reads a window of its envelope, not the whole file

A look drag re-opens the visualizer seat once per pointer sample, and the seat
asks for the clip's whole envelope: two hours at the visualizer's 4000 buckets a
second is 230 MB, past `PEAKS_MEMO_BUCKETS`, so the memo refuses to hold it and
every one of those asks decoded the whole file again -- six channels through
`ec-aac`, ~7 s of four cores, per pointer sample, for a picture that shows two
seconds of sound. The cap is not the bug: one entry that size is not a memo.

The seat's ask is now the shape of what it paints. `viz_envelope` answers with
the memo's own whole-file handle when it holds one, and otherwise with a
*window* of the file's envelope about each frame's own time -- 30 s of buckets,
decoded once per window per process, held under a 4M-bucket ceiling
(VIZ_WINDOW_MEMO_BUCKETS, 32 MB, ~34 windows for every source in the session).
A window is 1.5% of the film's envelope and a drag re-asks the one it is in.

Two scalars of the whole file are still needed to draw any frame of it: the
file's loudest bucket, which every column is scaled by, and its exact length,
which is where "past the end of the file" is measured. `viz_summary` reads both
off one pass that keeps no buckets -- the same windows, threads and opens
`peaks_over` decodes an envelope with, so the peak is the envelope's own -- and
the summary is kept per stream, sixteen bytes rather than 230 MB. Both routes
are memoized; a failed ask still is not.

`VizView` is what a painter is handed: either the whole envelope
(`visualizer_i420`, unchanged for export and the tests) or a window with the
file's own `total` and `peak`. A view that is a window cannot derive either from
itself, which is why they travel with it.

Also guards the sample rate that becomes samples-per-bucket: `per_bucket_of`
floors the rate at one both ways, because `sample / 0.0` is infinite, `as usize`
saturates and the fold's `resize(bucket + 1)` is then a length that does not
exist -- a panic in debug, a wrap and an out-of-bounds index in release. The
window arithmetic is written in buckets *per second* off the same helper.

Evidence (`cargo test -p engine --lib -- --test-threads=1 waveform::`):
16 passed, including a 40-minute FLAC whose envelope is 9.6M buckets (past the
real ceiling): a window's buckets are the envelope's bucket for bucket and its
frame is byte for byte the frame the whole envelope paints, the first ask decodes
a window, and the three asks after it -- a drag, a new seat each time -- decode
nothing at all.

2026-09-17

⚡ perf(audio): the envelope memo answers a trackless source tooAhmet Kaan Gümüş · 98fe25f
⚡ perf(audio): the envelope memo answers a trackless source too

peaks_shared returned early on Ok(None) and on Err, so a visualizer clip on
a source with no audio track re-opened its container on every picture
rebuild -- the per-rebuild cost the memo exists to remove. The map now holds
NoTrack as well as an envelope, and the two arithmetic paths (an envelope
over the ceiling is never held; a replaced entry's buckets come off the
count) are pinned by tests, mutation-checked against the three regressions.

2026-09-16

⚡ perf(audio): the visualizer reads its envelope from a process memoAhmet Kaan Gümüş · dc551d7
⚡ perf(audio): the visualizer reads its envelope from a process memo

A picture rebuild called `open_visualizer`, which decoded the whole file's
audio envelope again -- ~51 ms of CPU, 598k buckets for a 150 s song -- so
every look edit, and every sample of a wheel drag, paid a whole-file decode
for an answer that had not changed. `waveform::peaks_shared` memoises it by
the file's own stat (path, stream, buckets, length, mtime), bounded in
buckets; the envelope fed to the painter is the same value as before.

The user's "dragging causes frame drop" was that decode on the frame path:
rebuild latency p50 68 -> 6-18 ms, playing frame interval p95 80 -> 48 ms,
frames over 50 ms 32/438 -> 1/496. The wheel's own 720-polygon repaint
measured ~0.9 ms and the engine write's UI-thread share ~42 us, so neither
was touched.

2026-09-12

✨ feat(engine): the multichannel AAC decode seat is an ec-aac native — rusty_aac stays encoder-onlyAhmet Kaan Gümüş · fc0891f
✨ feat(engine): the multichannel AAC decode seat is an ec-aac native — rusty_aac stays encoder-only

- the >2-channel seat (a film's 5.1/7.1 track, symphonia refusing anything
  wider than stereo) now decodes with the family's own ec-aac; the same
  construction and decode call sites, the same seat shape, the same film
  channel order FL FR FC LFE BL BR the downmix folds
- witness: fold correlation +1.00000 against the retired rusty_aac decoder on
  2000 identical AUs of a 5.1 film remux (max|diff| 5.96e-8,
  RMS ratio 1.0000, channel matrix diagonal-dominant); stereo fixture
  +1.00000 / 5.46e-4 (PNS noise seed differs); new ffmpeg-correlated film
  witness a_seek_into_real_five_one_aac_film... scores 0.929/0.858/0.922
  landing on the asked second (threshold 0.5)
- perf: 12.0-13.2 Msamples/s (250-275x realtime) vs rusty 2.8-3.6 (58-75x) at
  5.1 on identical packets; 26-32 Msamples/s (580-719x) vs 6.7-7.7 (151-174x)
  on the stereo fixture -- ~3.5x the retired decoder, bar was >=0.9x
- known behaviour delta, honest in both directions: HE-AAC v1 (SBR) now
  reconstructs at the extension rate where rusty band-limited everything to
  the core Nyquist; PS streams decode core-only at the core rate in BOTH

2026-08-13

chore: rename ponytail: comment marker to corner-cut:Ahmet Kaan Gümüş · 9ba8e0a
chore: rename ponytail: comment marker to corner-cut:

Marker convention renamed after uninstalling the ponytail plugin;
semantics unchanged (deliberate corner-cut, known ceiling + upgrade path).
Token-only rename, 81 comment lines, no code change.
⚡ perf(waveform): a film's envelope is read by several handsAhmet Kaan Gümüş · 50e3988
⚡ perf(waveform): a film's envelope is read by several hands

Importing a source decodes its whole audio track for the lane's waveform, and
on a film that is the longest thing an import waits for: 22.7 s of one core for
a 2 h 39 m 5.1 E-AC-3 mkv, 3.8 s for a 2 h stereo AAC mp4. It is linear in
length and nothing about it was parallel, though `open_multi_streams` has
always taken a window per call and seeked to it.

So a source long enough to pay for the extra opens is cut into windows -- one
per minute, capped at the machine's cores and at eight -- decoded side by side
and stitched. The first window is the session that was opened to learn the
length, so a split costs `jobs - 1` opens and not `jobs`. Joining is safe
because the fold is min/max into absolutely-numbered buckets: the chunk that
straddles a joint is folded into both windows and cannot be double-counted.

The 2 h 39 m mkv's 22.7 s becomes 4.6 s and the 2 h mp4's 3.8 s becomes 1.2 s,
bucket count identical either way. A clip under two minutes is read exactly as
it was, on the calling thread. `bench waveform <file>` is the metric.

2026-08-11

✨ fix(waveform): a film in an mkv paints its wave, and a failure says soAhmet Kaan Gümüş · ffb3105
✨ fix(waveform): a film in an mkv paints its wave, and a failure says so

A 5.1 AAC track decodes through rusty_aac, whose IMDCT ran as an 8 MB
cosine matrix -- 88% of decode time and 2x realtime, so a two-hour film
needed an hour of background decode before its lane had anything to
draw. The same file has an N/4-point FFT already, for the encoder: the
IMDCT is a DCT-IV read at an offset, so both directions now share
dsp::dct4. 40x on the fixture, 141 s for the film.

And a decode that fails is no longer a silent file: peaks() errors reach
the lane as Wave::Failed with a band that says "audio unreadable", the
reason goes to the log, and the Matroska opener logs what it swallows.

2026-08-10

Merge S5a audio-file import into stream-picker mainAhmet Kaan Gümüş · 1bb8ee2
Merge S5a audio-file import into stream-picker main

Both sides taught `audio` a new axis and they meet on one type: S5a made
`Track` an enum over the mp4/AAC reader and symphonia's, main gave every
reader a `(path, stream)` address. The merged `Track::open(path, stream)`
keeps both -- the stream index lives inside `AacTrack::open`, and a
standalone audio file, which has exactly one track by construction, refuses
any stream above 0 rather than quietly serving the only one it has.

- `AudioProbe` is S5a's `{sample_rate, channels}`: equality is playability,
  so an mp3 may share a timeline with mp4s. Copyability is a separate
  refusal, at export, and stays AAC-only through `copy_track`.
- `probe_streams` reads a standalone file through symphonia instead of
  walking it as an mp4 -- an ALAC .m4a parses as an mp4 whose only audio
  track is not AAC, so the mp4 walk would call it undecodable where
  symphonia decodes it.
- Which lane a source lands on is decided once, in `place_stream_at`: a
  file with no picture is placed on the audio lane alone, everything else
  is pasted as a grouped take. The front-end only owes the refusal notice.
- `unsupported()` and the NTSC/VP9 work are untouched; `is_audio` files
  never reach the former, since a song cannot open a timeline at all.
✨ feat(library): every audio stream is a row, and the picked one plays and exportsAhmet Kaan Gümüş · ecb5e06
✨ feat(library): every audio stream is a row, and the picked one plays and exports

A file with one audio track per language is one row per track now, not one row
per file. The engine carries the pick end to end: a source is a (file, audio
stream) pair, .edith v3 writes the stream on the source line, playback opens it
and — the trap this closes — the export copies *that* stream's packets rather
than always stream 0.

Streams that cannot go on the timeline are listed greyed with the reason
instead of hidden: a codec we cannot read, or a rate/layout that cannot share
one output device and one copied AAC track with the rest of the timeline (there
is no resampler here and no AAC encoder to write a join with). place_stream_at
is the one door a row goes through, and it refuses those in the engine's own
words.

- v2 and v1 files still load: no stream field means stream 0, which is all
  those dialects could play; saving either writes v3.
- Waveform peaks are keyed by file *and* stream, so two tracks of one file
  cannot draw each other's envelope.
- Library swatches and clip tints follow the *file*, so a file's streams share
  one colour in the panel and on the lanes.
- assets/test_multilang.mp4: two AAC 44.1k stereo streams (und, fra), the shape
  real multi-language media has and the one where a second stream is placeable.

2026-08-09