forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on ef5832fea151ca30db92b142c8de131c5f43fc49Filtered to scripts/gen_fixtures.shClear filter

2026-08-12

✨ feat(audio): convert wide layouts and off-rate sources at import instead of refusingAhmet Kaan Gümüş · c94ba8b
✨ feat(audio): convert wide layouts and off-rate sources at import instead of refusing

An 8-channel Opus track came back "IMPORT FAILED: unsupported channel
layout: 8 channels (max stereo)" and took the picture with it, and a
48 kHz file "audio 48000 Hz 2 ch does not match the timeline's 44100 Hz
2 ch". Both strings are gone: an import converts.

Width: `fold_5_1` becomes `downmix`, a coefficient table per layout from
2.1 to 7.1 (ITU-R BS.775 — front channels keep their side, centre and
surrounds join at -3 dB, LFE dropped, both sides normalised by their own
coefficient sum so a full-scale source cannot clip). 5.1 comes out of the
table bit-identical to what it was. `vorbis_to_film_order` gains the RFC
7845 permutations for 3, 5, 7 and 8 channels beside the 6 it had, so
surround Opus at any width reaches the fold in the order the fold reads.
The AC-3 decoder's own 2.1 passthrough, which it leaves at 3, folds here
too, and a multichannel AAC track in an *mp4* now takes the `rusty_aac`
route the Matroska side already had (`aac_decoder`, one call for both).

Rate: the segment resampler a speeded clip already goes through takes the
source rate over the timeline's into its step, so the two compose into one
interpolation and 48 kHz onto a 44.1 kHz timeline keeps its pitch. All of
it is convert-on-read — per packet in the decoder, per buffer in `emit`,
after the window trim — so there is no upfront pass to show progress for
and nothing to cancel.

What is still refused is the layout alone: a mono track cannot join a
stereo timeline, in the words "audio 1 ch does not match the timeline's
2 ch". The picker's grey-out rule follows the gate rather than leading it.

Measured on a 12.9 GB 2160p AV1 remux with a real-library 7.1 Opus
track: imports, opens as a timeline, and a ten-second WAV export comes
back at RMS 0.0091 left / 0.0085 right.
🔒 chore(privacy): the tests name a key, the machine names the fileAhmet Kaan Gümüş · a893c91
🔒 chore(privacy): the tests name a key, the machine names the file

Nothing in this tree says what is in anybody's library or where it lives.
The handful of tests that are worth nothing against a fixture -- a real
HDR10 grade, a header-stripped BluRay remux, a disc's PGS tracks -- asked
for absolute paths written into their source, and the comments around them
recorded which films the measurements were taken on.

Both go. `engine::real_library::film(key)` reads `real_library.toml` at the
workspace root, which is gitignored: three logical keys named for what the
file *is* (`hevc_4k_hdr`, `h264_dual_audio`, `hevc_4k_pgs`), mapped to
wherever that machine keeps them. A missing manifest, a missing key or a
missing file each say so on stderr and the test passes, which is the
existence gate every one of these already had, in one line instead of five.
`real_library.toml.example` documents the shape and what each key must be.

The comments keep the technical fact and lose the title: a peak of 1759
cd/m^2 is still 1759, the 37 BCP-47 elements are still 37, and the Opus
pre-skip is still measured against ffmpeg -- on "a real 5.1 Opus remux"
rather than on a named one. The synthetic paths in the app's unit tests
("/films/…") were never real and are now anonymous too.
✨ feat(subtitles): as many tracks as you want, embedded in the exportAhmet Kaan Gümüş · 28e2853
✨ feat(subtitles): as many tracks as you want, embedded in the export

Subtitle tracks now work the way audio and video tracks do: add as many
as you like, remove any of them, and every track with cues on the
timeline is written into the exported file.

Add and remove
- "+ S" beside "+ V"/"+ A" imports every subtitle track in a picked
  file; each row carries its own "x". Pointer and keyboard doors share
  one implementation and refuse identically, before any chooser opens.
- Project::remove_subtitles / PlaybackSession::remove_subtitles, with
  the index fixup in one place so a removal cannot repoint the overlay.

Embedded in the output
- ExportSettings.subtitles is a list; the Matroska muxer writes N tracks
  from number 3 up, ceiling derived from the encoding (0x7F -
  SUB_TRACK_FIRST) because track 127 is the all-ones VINT our own reader
  maps to "unknown" and would silently lose.
- mp4 carries them too, as real tx3g timed text. The old "an mp4 carries
  none" was a false refusal: mp4 0.14 has MediaConfig::TtxtConfig all
  along. Samples are built from cue boundaries, so gaps are empty
  samples and the track spans the film.
- of_mp4 reads them back, so edith re-imports its own output. Verified
  against a file ffmpeg muxed, which writes mdhd in microseconds where
  we write milliseconds.
- The export set is derived from timeline_cues per call, so it cannot
  desync; the card names a track it leaves off, and counts past the
  width budget rather than eating the card.

Language and title
- SubtitleTrack carries language and name apart; the guess-them-back
  heuristic is gone. LanguageBCP47 is read and mapped to a 3-letter code
  (ffmpeg reads no BCP-47 at all, so writing it would have made the
  language invisible). A 17-track subtitle library file and a
  dual-language one no longer read "und".

Media bitrate in properties
- engine::probe_bitrate opens no decoder; all three numbers share the
  container's duration, so total >= video + audio holds by construction.
  Within 0.004% of ffprobe across the library.
- Both properties cards show it; a dual-audio file says which of how
  many. The line picks one unit off its smallest stated component, so a
  real value never renders as 0.00.

Off the render thread
- The subtitle walk moved to the background executor at every door:
  1324ms -> 0.1ms on a 3.1GB film, 234ms -> 5.0ms on a 25.4GB/35-track
  one. (The media walk is still on the render thread; separate slice.)

False refusals removed
- .mks and .mka were refused while the compiled-in Matroska reader
  parses them; is_matroska now takes the standard's closed set.
- The audio-only "sound alone" sentence was unreachable when every pick
  was a bitmap track.

Subtitle-free exports stay byte-identical: 294a8b0c (hevc mkv),
8c16b8b1 (default mp4).
🐛 fix(audio): a seek into a Matroska lands on the second it asked forAhmet Kaan Gümüş · 702501a
🐛 fix(audio): a seek into a Matroska lands on the second it asked for

A film played 1.47 s further in than the timeline said after a scrub to
600 s, 3.39 s after one to 610 s -- sound against picture, the oldest
complaint in this project, and the Matroska half of the mp4 fps truncation
that was fixed once and never swept.

One symphonia mkv seek does not land where it is asked to. It goes through
the cue table and stops at the first frame at or *past* the cue's cluster:
asking for 599.83 s on a 2h+ AV1/Opus 5.1 mkv landed the
reader at 601.487 s, asking for 609.83 s at 613.407 s, and on the new 30 s
fixture asking for 25 s lands
at 29.987 s. Samples that far behind a reader cannot be reached by any
window rule downstream, so `emit` had nothing to trim and the film simply
played from the landing while the clock counted from the request.

So the landing is read back and an overshoot is asked again from far enough
before it to swallow the overshoot, and every attempt gets a *new reader* --
symphonia's mkv seek is reliable exactly once per reader: it hands out the
frames it had already queued (they arrive carrying the old block's
timestamp) and its element iterator does not recover, so a second seek on
one reader landed back at the file's first cluster, 0.094 s, whatever it was
asked for. That is a *clip* of a film, and at HEAD the second clip of a
two-clip timeline came out with no audio at all. Opening again costs 2 ms on
a 5 GB film.

Seeking to the beginning is now not seeking: that seek is how the first
167 ms of the same film went missing at open, and 2.35 s more of it at 27 s,
where the iterator left inside a cue's cluster ran on into the wrong one.

Two smaller things the trimming needed to be right at all. A packet's own
timestamp cannot carry the decode position: the frames of one laced block
all share the block's, so the position accumulates from the decoder's count
between blocks, which is what both mp4 readers here already do. And the
pre-skip comes off a landing timestamp, because an Opus track's blocks are
timestamped for the audible stream while the decoder hands its samples back
with the pre-skip still in front of them -- 6.5 ms, measured.

Measured against an ffmpeg decode of the same window, envelope correlation,
real files. A 2h+ AV1/Opus 5.1 mkv at
600/610/1200/5400/6000 s: +1.474/+3.393/+0.094/+0.073/+0.094 s before, ≤1 ms
after. An HEVC/AAC 5.1 mkv at 610 and 1200 s: +2.054/+1.856 before, 0.000
after. An H.264/AAC mkv and an AC-3 mp4 were already exact and stay exact --
the mp4 tables never had this to get wrong. A/V skew after a seek on the AV1
mkv: -0.007 s at 600 s, -0.005 s at 5400 s. The video path was measured at
the same four positions and lands on the requested frame.
🔊 feat(audio): an Opus film is heard, not refusedAhmet Kaan Gümüş · 699950a
🔊 feat(audio): an Opus film is heard, not refused

The refusal was the bug again. `is_audio` said "no opus, ac3 or dts, for
which no pure-Rust decoder exists" while symphonia's own mkv and ogg readers
have always mapped `A_OPUS` and `OpusHead` to `CODEC_ID_OPUS`: the containers
read the format, only the decoder was missing. Symphonia genuinely has none
at any version -- its feature list stops at vorbis and there is no
`symphonia-codec-opus` crate -- so the decoder is `ruopus`, pure Rust, MIT,
no dependencies of its own, and the film plays.

Which crate is not a coin toss. A 5.1 track is four elementary Opus streams
in one packet, all but the last self-delimited (RFC 6716 App. B).
`rusty-opus 0.9.1` -- the sibling of `rusty_aac`/`rusty_mp3` already here --
hands each self-delimited slice to a decoder that parses it as an ordinary
packet, so every stream but the last reads the length prefix as payload: it
was measured on a 5.1 Opus remux as full-scale noise at -13
dBFS over a passage where the film is silent, which is exactly the failure
that "the decoder returns samples" would have shipped. `ruopus` matches
ffmpeg's decode of the same file to a correlation of 1.00000 on all six
channels.

Two things that are Opus's alone: it is stored in Vorbis channel order
(FL, FC, FR, BL, BR, LFE) and the 5.1 fold reads the film order every other
decoder here hands back, so the frame is permuted before it folds; and its
encoder delay lives in the stream (`OpusHead`'s pre-skip, 312 samples) where
neither reader drops it, so that is this track's priming -- sample-exact
against ffmpeg afterwards, 6.5 ms late before.

`.opus` and `.mka` join `is_audio`, `unsupported` asks the other reader
before naming a codec (a refusal that fires on a track which decodes is the
same defect wearing the other face), and `capability_matrix` covers Opus per
container with DTS left as the one live refusal row.
🐛 fix(decode): a film's grain is synthesized into a surface of its ownAhmet Kaan Gümüş · c52b667
🐛 fix(decode): a film's grain is synthesized into a surface of its own

An AV1 frame with `apply_grain` set is *displayed* from a second surface:
the driver writes the reconstructed picture into the render target, which
later frames reference, and the grain-synthesized one into a target the
decoder has to hand it. The vendored backend handed it none -- it passed
`VA_INVALID_SURFACE` as `current_display_picture` while still asking, in
the very same buffer, for the grain -- and radeonsi refuses that picture
outright: `vaEndPicture` answers VA_STATUS_ERROR_INVALID_SURFACE.

That is what killed the only AV1 film in the library at frame 49, its
first picture with grain; 1337 of the first 1504 have it, so AV1 playback
on real media had never worked. Every fixture that said otherwise was
grainless, which is why `test_av1_grain.mkv` is now beside them and why
its test decodes all ninety frames and then asks whether the grain
actually reached the picture -- turning `apply_grain` off would make the
decode succeed too, and would silently strip the film of its texture.

A grainy picture costs two pool frames rather than one, so a sequence
whose header admits grain gets a pool of twice the size; one that does
not is left exactly as it was, as are H.264, HEVC and VP9, which have no
such surface and read back the reconstructed one as always.
🐛 fix(demux): a codec's support is probed per container, not inferred from a neighbourAhmet Kaan Gümüş · 4f4dcb4
🐛 fix(demux): a codec's support is probed per container, not inferred from a neighbour

VP9 was decodable out of an mp4 and refused out of a .webm — `V_VP9` fell
through the Matroska track dispatch into `OtherVideo` and came back as
"V_VP9 video in a Matroska file is not supported", with the VA-API VP9
decoder wired in `engine-hw` the whole time. A browser-downloaded .mkv was one of those
files.

Both dispatches now read one table (`CODEC_IDS`), and the Matroska arm
matches on `Codec` with no wildcard, so a codec added to the enum fails
to compile until it has been routed rather than falling through to a
refusal. A cell that is deliberately absent is a row in `UNSUPPORTED`
with a reason, and the refusal quotes that reason instead of listing
what is supported and leaving the user to guess.

The mp4 video track comes out of `moov.traks` in file order, not a
`HashMap` walk of `Mp4Reader::tracks()`: a file with two video tracks
opened on a different picture from one run to the next, and a saved
.edith reopened on the other one. `audio::audio_track_ids` fixed the same
trap for sound; the naming half of `AudioSession::unsupported` had it too.

VP9 states its bit depth in no container record — an mkv `TrackEntry`
carries none and an mp4's `vpcC` is optional — so it is read off the
first keyframe's uncompressed header. Assumed 8-bit, a profile 2 stream
would decode into an NV12 pool and come back as garbage; 12-bit is
refused by name like 12-bit AV1 and HEVC.

The audio refusals said "AAC and AC-3 only" long after FLAC, MP3, Vorbis,
ALAC and PCM decoded out of a Matroska file. They name the real set now,
per container, because an mp4 video's sound never reaches symphonia and
reads fewer codecs than an mkv does.

tests/capability_matrix.rs holds all of it against real files.

2026-08-11

✨ feat(tonemap): the reference rendition converts a film at the peak the film declaresAhmet Kaan Gümüş · 27097e2
✨ feat(tonemap): the reference rendition converts a film at the peak the film declares

`Demuxer::light().peak()` -- a stream's MaxCLL, or its mastering display's
maximum -- has been read at every open and dropped on the floor. It now reaches
`ToneMapper::new` as `declared_peak`, and `Preset::master_nits_for` is the whole
composition rule: `Reference` takes the film's number (1000 stays the fallback
for a file that declared nothing), `Standard` and `Vivid` keep their fixed 400
and 250, because a picked exposure that moved per file would not be a pick.

One HDR film declares 1759 cd/m^2, so its 1000-nit highlights
land at SDR 215 instead of clipping at white, and BT.2408 diffuse white at 145
instead of 166.

Both sites that build a table have the demuxer in hand already, so nothing is
promoted through `VideoMeta`: the decode funnel reads it before the worker takes
the demuxer, and `source_rate` returns it off the header parse export already
did -- which is what keeps preview and export on one number.

A declared peak is a stranger's number and is checked before it becomes a
divisor: outside 100..=10000, or a NaN, is treated as not declared.

test_hdr_bright.mkv joins the fixtures for it -- the older HDR metadata ones all
say 1000, which no picture can tell apart from the fallback.
✨ feat(demux): a film's real peak brightness is parsed, not assumedAhmet Kaan Gümüş · 5726307
✨ feat(demux): a film's real peak brightness is parsed, not assumed

MaxCLL/MaxFALL and the mastering display's luminances, off all three
places they live: a Matroska Colour element (0x55BC/0x55BD and the
MasteringMetadata floats behind 0x55D0), an mp4 sample entry's clli and
mdcv boxes, and -- for the web rips where the container carries none of
it -- the HEVC SEI messages of the same names in the first access unit.

Carried on Demuxer::light() as ContentLight, whose peak() prefers the
measured content light over the display the grade was approved on.
Nothing reads it yet: wiring it into the tone map, which today assumes a
constant, is its own change.
✨ feat(color): an HDR film reaches the window tone-mapped, and an SDR one is untouchedAhmet Kaan Gümüş · f8dea1c
✨ feat(color): an HDR film reaches the window tone-mapped, and an SDR one is untouched

The tone map existed and nothing called it: a PQ or HLG stream was
converted with its own matrix and then shown as if its curve were SDR --
flat, grey-washed, half the brightness a player gives it. `Render` now
builds one `ToneMapper` per stream (the transfer is a property of the
file, and the LUT is float work over 9 537 nodes) and maps the source
planes into BT.709 SDR before anything else looks at them, in both
branches of the funnel: the fused passthrough conversion and the
graded-then-placed one.

The grade lands *after* the map, on the one scratch copy the placed path
already made -- a look means what it says in the SDR a viewer is shown,
not in the ten stops the file was in. An SDR stream takes neither the
copy nor the map and is byte for byte the picture it was, asserted
against hashes measured before this change (`tonemap_render`).

`MASTER_NITS` is 400, not the 1000 an HDR10 grade is mastered to. Told
1000, BT.2446 Method A puts 203-nit diffuse white on code 166, which
reads as broadcast-dark; told 400 it lands on 205, which is the
brightness mpv shows. The anchor tests carry the recomputed codes rather
than wider tolerances, and HLG's OOTF now follows the assumed peak
through BT.2100's own log term -- its relative diffuse white is 19% of
whatever peak the display has, so it comes out at 170 and no longer
agrees with PQ's absolute 203, which is the standard's behaviour and is
written down beside the assert.

Measured on the real 4K HDR10 film (`hw_decode`, existence-gated): frame
3000 saturation 34.8 -> 98.9, mean luma 107.6 -> 122.2, and 32.5
ms/frame for the map plus the conversion at 3840x1600, inside the 39 ms
budget. New fixture `test_pq.mp4`: four flat patches whose codes are
written into the planes by hand, so a test names the code it feeds and
the code it expects back.
✨ feat(colorspace): a file says which matrix and curve its numbers are in, and edith reads itAhmet Kaan Gümüş · 070ffe6
✨ feat(colorspace): a file says which matrix and curve its numbers are in, and edith reads it

Three tiers, per field: the container's own tags (Matroska `Colour`, mp4
`colr`), then the bitstream's (H.264/HEVC SPS VUI, AV1 `color_config`),
then the ffmpeg/mpv resolution rule -- 720 lines or taller is BT.709,
below it BT.601, limited either way. A code that says nothing, or says
something with no implementation here, falls to the next tier rather than
answering wrongly.

`VideoMeta` carries the answer; nothing consumes it yet. Everything still
renders through the hardcoded BT.601 it always did, which is the bug this
is the foundation for fixing.

The bit-level walks are where this can quietly go wrong: an SPS whose
scaling lists are counted wrongly lands the VUI read in the middle of a
coefficient. Both are measured -- H.264 and HEVC against hand-built
parameter sets (no encoder here writes SPS scaling lists), the rest
against fixtures tagged in the container, tagged only in the bitstream,
and tagged nowhere, plus the two real films: a 4K HDR remux that reads
BT.2020/PQ and a fully untagged 720p one that reads BT.709.
✨ feat(audio): every audio track of an mkv is a row, and the second one playsAhmet Kaan Gümüş · 264c10c
✨ feat(audio): every audio track of an mkv is a row, and the second one plays

A Matroska file was worth exactly one audio stream here -- whichever
track the readers stumbled on first -- so the second language of a
dual-audio remux was invisible and unopenable, and no mkv ever showed
what language its sound was in.

The header walk now collects every audio TrackEntry in file order with
its number, codec id, TrackLanguage and TrackName
(demux::matroska_audio_tracks), and that list is what a stream index
counts in. The index picks an entry, the entry's *track number* is what
each reader is then pointed at -- MkvAudio::open_track for the AC-3
blocks, SymTrack::open_track for symphonia, whose mkv reader keeps the
same number as its track id -- so the two readers cannot disagree about
which track a stream meant. Stream 0 is still the file's first audio
track, sample for sample.

Rows name their codec from the container rather than from symphonia's
registry: the tracks that most need naming are exactly the ones it has
no decoder for, and "opus is not supported" beats "an unsupported
format".

Fixture: test_multiaudio.mkv, two AAC tracks, eng 440/880 Hz and fra
220/330 Hz -- different tones because a mapping that drifts plays the
other language.
Merge remote-tracking branch 'origin/main' into worktree-agent-ab6959260e5ee211cAhmet Kaan Gümüş · 2eb309b
Merge remote-tracking branch 'origin/main' into worktree-agent-ab6959260e5ee211c

# Conflicts:
#	scripts/gen_fixtures.sh
Merge remote-tracking branch 'origin/main' into worktree-agent-ab6959260e5ee211cAhmet Kaan Gümüş · 0776b46
Merge remote-tracking branch 'origin/main' into worktree-agent-ab6959260e5ee211c

# Conflicts:
#	crates/engine/src/audio.rs
✨ feat(av1): 10-bit AV1 opens instead of being refusedAhmet Kaan Gümüş · 25aef8c
✨ feat(av1): 10-bit AV1 opens instead of being refused

The `av1C` record's `high_bitdepth` was an outright refusal ("10-bit AV1 is
not supported yet"), on a comment that had gone stale: the vendored decoder
takes its RT format from the stream and maps Depth10 to YUV420_10, and the
plugin's read-back pool is P010 whenever the demuxer says >8 -- which is how
HEVC Main 10 has been playing all along.

So `parse_av1c` reads the depth instead of refusing it, in both containers
(the mp4 `av1C` box and the Matroska `CodecPrivate`), and 12-bit stays
refused by name in the words HEVC's own depth check uses. Nothing else needs
the plugin any differently: AV1 has no software decoder at any depth, so a
machine without `libengine_hw.so` still refuses it as `needs_plugin` always
has.

Fixture: assets/test_av1_10.mkv (libaom, yuv420p10le), the AV1 seat of the
pair test_hevc.mkv/test_hevc10.mkv already make for HEVC.
Merge remote-tracking branch 'origin/main' into worktree-agent-ab6959260e5ee211cAhmet Kaan Gümüş · 1e8c454
Merge remote-tracking branch 'origin/main' into worktree-agent-ab6959260e5ee211c

# Conflicts:
#	crates/engine/src/audio.rs
#	crates/engine/src/demux.rs
#	crates/engine/tests/audio_decode.rs
#	scripts/gen_fixtures.sh
✨ feat(engine): subtitles come in with the film or beside itAhmet Kaan Gümüş · f4b5fd8
✨ feat(engine): subtitles come in with the film or beside it

A subtitle track was a track this engine walked past: the Matroska track
walk kept video and audio and dropped type 0x11, and a `.srt` next to the
media was a file with no door. Now both arrive as the same thing -- a
list of timed cues -- and a project keeps them.

`subtitle`: the cue model plus the two ways in. Standalone `.srt`,
`.vtt` and `.ass`/`.ssa` go through `oxideav-subtitle` and `oxideav-ass`
rather than through a fresh parser here; an embedded track carries its
timing on the block and its text in it, so each codec is put back into
the shape its own parser reads -- which is what makes an embedded track
and the file it was muxed from come back as the same cues.

What cannot be read is refused by name and still listed: the four PGS
tracks of a BluRay remux are four rows saying they are pictures, not an
empty list and not a file that would not open. A `.srt` that has gone
missing since the save is the same story, and a re-save keeps its row.

`.edith` 10 writes `subtitle <track> <path>` -- the reference only, the
cues stay in the file they came from. v9 and every older dialect load as
the projects with no subtitles that they are.
🔀 merge(A2): H.264 joins AV1 and HEVC in the Matroska gateAhmet Kaan Gümüş · ae661e4
🔀 merge(A2): H.264 joins AV1 and HEVC in the Matroska gate

Both lanes rewrote mkv_track_entry. Main's shape wins -- MkvEntry, the named
refusal, the scratch buffer, bit_depth -- and the H.264 arm is one more entry
in it: parse_avcc beside parse_hvcc, 8-bit as the whole H.264 path here
assumes. The refusal now names all three codecs it does read.
✨ feat(audio): AC-3 and E-AC-3 sound out of a Matroska fileAhmet Kaan Gümüş · a71f015
✨ feat(audio): AC-3 and E-AC-3 sound out of a Matroska file

The "(AAC only)" refusal fired on every A_AC3/A_EAC3 track in an mkv
because a Matroska file's sound reached no reader at all. The blocks of
its first audio track are now indexed beside the picture's and handed to
the oxideav-ac3 decoder the mp4 path already uses, downmix and all.
✨ feat(demux): an H.264 mkv opens like any other fileAhmet Kaan Gümüş · 87953e0
✨ feat(demux): an H.264 mkv opens like any other file

Matroska carried the codec this project decodes best and refused it at the
door: only V_AV1 had an arm. The avcC in CodecPrivate is the same record an
mp4 carries, so the parameter sets come out of it and the length-prefixed
blocks are reframed to Annex-B behind them -- the H.264 dispatch below is
untouched, and so is the AV1 path, whose blocks still go over as they lie.
🔀 merge(T3): mixed frame rates meet mkv HEVC, zero-source survival and the zoomAhmet Kaan Gümüş · 6b5fa2e
🔀 merge(T3): mixed frame rates meet mkv HEVC, zero-source survival and the zoom

`main`'s `open_project` now walks every source with the scaffold in its own
slot (T6), so the per-source `rates` table is built there frame by frame beside
`counts` -- one table in two vectors, grown and shortened together. The codec
gate T1 leans on stays; the frame-rate gate is still gone, and a Matroska file
shot at another rate imports through the very same door an mp4 does, its rate
read off the demuxer's `default_duration`.

Grafted from the losing branch, which had the better arithmetic:

* `Rate::from_fps` is exact. Built on `mux::frame_timing` -- the pair the muxer
  already counts an export's frames in -- divided by that pair and reduced, so
  24000/1001 over 30 is `800/1001` and stays it however far the timeline runs.
  The milli-fps rounding it replaces was a frame off after seven hours; that
  ponytail is gone rather than documented.
* A rate no timescale can *name* is an `Err` in `frame_timing`'s own words
  rather than a silent 1:1, and `matches_timeline` is where a file carrying one
  is refused -- it hands back the `Rate` it accepted the file at, so the number
  the refusal was decided on is the number the file plays by.
* `file_frames` and `file_rate` ask one `source_of`, so a path that names a
  length names a rate too.
* Five more tests in `tests/mixed_fps.rs`, in timeline frames: the exactness of
  the NTSC ratio, a trim of an off-rate clip to the room it was dragged to, the
  neighbouring 30 fps clip still read frame for frame, the linked sound placed
  at its picture's length, and the exported pictures measured against the
  file's own frames rather than merely counted.

...and the note the next builder needs in `copy_audio`: a lane holding a clip
at another rate stays a packet copy on purpose. A clip counts the *timeline's*
frames, so the window the copy trims a source's sound to is whole timeline
seconds and the packets are already in sync; re-encoding it would buy nothing
and cost a generation of loss. A speed is different, and still refused there.

2026-08-10

✨ feat(import): a Matroska film opens, its 10-bit picture and its 5.1 sound alikeAhmet Kaan Gümüş · b083a3b
✨ feat(import): a Matroska film opens, its 10-bit picture and its 5.1 sound alike

mkv HEVC demux (Main/Main10), a P010 pool in the hardware path read back to
I420, mkv audio through symphonia's Matroska reader with rusty_aac decoding
what symphonia's own AAC refuses (anything wider than stereo), and a BS.775
fold of 5.1 down to the stereo the output device takes.

vendor/rusty_aac is 0.5.0 with one local patch: its decoder's IMDCT caches the
cosine matrix instead of calling cos() per term, 11x faster and the difference
between playable and not.
✨ feat(timeline): a clip shot at another rate plays at the speed it was shot atAhmet Kaan Gümüş · 26af1e4
✨ feat(timeline): a clip shot at another rate plays at the speed it was shot at

A frame rate of its own is no longer a refusal at import. Every frame
number in the edit list counts the *timeline's* frames -- a clip's
in/out included -- and a file shot at another rate is converted once, at
the decoder's door: `Rate` (milli-fps rational, `Speed`'s floor/ceil
pair) says which frame of the file a timeline-rate frame is. Playback
opens its worker through it and stamps the pictures coming back through
its inverse; the export walks its span through it after the speed, so a
2x 24 fps clip on a 30 fps timeline is exactly both.

Nothing in `project.rs` changed: placement, trim, split, paste and speed
are the same arithmetic on one clock, and a single-rate project takes
the identity map everywhere it used to take nothing.

A library row now names the *file's* rate rather than the timeline's,
which was true only while every source shared it.
✨ feat(timeline): clips play at a speed of their ownAhmet Kaan Gümüş · f8effe8
✨ feat(timeline): clips play at a speed of their own

A clip gains a rate (`Speed`, thousandths of real time, 0.25x to 4x) and
every speed question is answered at the mapping seams that were already
there: `Clip::frames` is the source range divided by the rate, `end` is
built on it, and `map`/`span_at`/`composite_span_at` walk the offset
through `Speed::source_at`. `in_frame`/`out_frame` stay *source* frames,
so a trim and a split still address the file.

The picture needs no new decoder: the span says how many source frames it
reads, and `try_frame` brings the decoder's numbers back through the same
rate -- at 2x two decoded frames land on one timeline frame and the
display's drop-when-behind policy takes it from there. The sound is
resampled per segment inside the worker playback and the audio export
already share (linear interpolation, carried across packet seams), so the
pitch moves with the rate: tape, not pitch-preserve, and the card says so.
Each segment is told how much timeline it owes and pads or trims to it,
which is what keeps a run of speeded cuts from drifting.

Rounding is where a rate could break the lane, so it does not: `Speed::fit`
never hands a trim more source than its room holds, and `Speed::split_at`
refuses a cut a slow clip's rate cannot address rather than leaving two
halves that no longer add up. The fuzz sweeps set_speed in with the rest.

- card in the eq/colour pattern, on `j` and in the clip menu; a drag is one
  undo step for the whole linked group, 1.00x reachable by hand and by `r`
- clip boxes carry a "2.00x" mark, and their width, waveform and details
  row are the timeline length
- WAV/FLAC honour it; mp4 and AV1 *refuse* by name -- that path copies AAC
  packets and a resample is not a copy (ponytail names the upgrade path)
- .edith v8 carries the rate; v7 and older load at 1.00x
- `assets/test_speed_sync.mp4`: one flash, one beep, same instant. At 2x
  they still land together, to the frame.
✨ feat(timeline): still images import and place as clipsAhmet Kaan Gümüş · 30d430d
✨ feat(timeline): still images import and place as clips

A PNG, JPEG or WebP is a source like any other: it imports into the
library, drags onto a video lane, shows at the playhead, trims, saves and
exports. `engine::is_image` is the door, beside `is_audio`, and every
choice it forces is made in one place.

The decisions, spelled out:

- Extensions: png, jpg, jpeg, webp -- exactly what the `image` crate is
  built with here. Anything else is refused by the door that refuses a
  .txt.
- Length: an image has none, so it is *held to* ten minutes (600 s at the
  timeline's rate) and *placed* at five seconds. The cap is finite on
  purpose -- a u32::MAX sentinel would hand a trim drag a wall past
  anything the timeline can hold -- and it is recomputed identically at
  load, so a clip trimmed out to it reopens.
- Image-first project: its own picture is the canvas (a still *has* a
  resolution, unlike a song) at 30 fps, silent, one 5 s clip on V1. The
  A2 audio-only precedent for everything else.
- Scaling: none of its own. The still is decoded once to I420 and goes
  through the same grade, the same `Composer` and the same conversion a
  decoded picture does, so a 640x360 image on a 1280x720 canvas is
  letterboxed by its fit policy and never stretched.
- Lanes: the mirror of a song. A still goes on the video lane it was
  asked for or on V1, never on an audio one, and never as a grouped take
  -- a clip on A1 playing a PNG is a segment the audio worker cannot
  open. Hand-written projects are refused by name.
- The timeline's audio parameters are now the first source that *could*
  have any, so an image as source 0 no longer holds every later import to
  its silence.

Playback opens a still worker (one conversion, then a memcpy per frame,
as the black-gap worker does); the export's `ClipDecoder` hands the same
planes out for as long as the span runs, so a mixed video/still timeline
encodes at the cut.

tests: engine/tests/images.rs -- import registers only, placed pixels
match the file's own (top/bottom bands catch a flip, RGB order catches a
swap), trim walls at the cap, .edith round trip incl. the audio-lane
refusal, mp4 export pixel-checked at the cut, audio-lane placement lands
on V1. Fixture: scripts/gen_fixtures.sh writes assets/test_still.png.
✨ feat(import): imported files land in the library, never on the timelineAhmet Kaan Gümüş · 5cb33d8
✨ feat(import): imported files land in the library, never on the timeline

An import is not a decision about where a file plays. It registers a source,
notes its native length and stops there; the timeline changes when the user
drags the row onto a lane.

- `PlaybackSession::import`/`import_audio` probe, check and register only,
  returning the source index. No clip, no reseek, and no undo step -- a
  library row changes nothing playable, so there is nothing for `z` to take
  back, and the notice no longer pretends otherwise.
- `PlaybackSession::file_frames` is the native length of a file this session
  has taken in, so a row that has never been placed is placeable at its full
  length. `place_stream_at` takes it from there instead of a `frames`
  argument, and the app drops the clips-derived guesser that returned 0 for a
  source with no clips.
- `PlaybackSession::open_library` is the first import into an empty window:
  the file's canvas, rate and clock over an empty timeline.
- Doors: the Import button, a file dropped on the window and every argv
  argument after the first fill the library. A file *named first* at launch is
  an open, not an import, and still becomes the timeline.
- Fixture + tests: a 25 fps H.264 file, refused by name at both video doors.
🐛 fix(engine): hvc1-tagged HEVC files import tooAhmet Kaan Gümüş · 8dd1c77
🐛 fix(engine): hvc1-tagged HEVC files import too

mp4 0.14 recognises only a hev1 sample entry, so an hvc1-tagged HEVC file -- what Apple and ffmpeg's mov muxer write -- read back as no video track at all. Its sample tables parse regardless of the entry the crate dropped, so the fourcc is read out of stsd by hand and the track is taken as HEVC; the parameter sets come from hvcC either way.
✨ feat(engine): AV1 import via the VA-API pluginAhmet Kaan Gümüş · 6d3e3ba
✨ feat(engine): AV1 import via the VA-API plugin

AV1 arrives in Matroska, never in an mp4 -- `mp4 0.14` knows no `av01`
sample entry at all -- so the demuxer grows a second container:
`MkvDemuxer` walks the EBML itself, indexes every block of the AV1 track
in one header-only pass (payloads are seeked over) and hands each block
to the decoder as the temporal unit it is, with the `av1C` sequence
header re-injected ahead of every keyframe the way the H.264 parameter
sets are.

Matroska indexes neither the frame count nor the frame rate, which is why
that walk exists: the count is the blocks of the track and the rate is
`DefaultDuration` in nanoseconds (33333333 = 30 fps to seven digits,
where the millisecond block timestamps beside it would say 30.30).
Keyframe flags come out of the same pass, so a seek lands on a sync point
without a Cues element and without guessing at the bitstream.

Audio is picture-only for now: a Matroska file is a silent source and
says so by name ("A_AAC audio in a Matroska file is not wired to the
decoder yet") rather than failing in the mp4 reader's words. 10- and
12-bit AV1 are refused at open like HEVC Main 10, for the same 8-bit
read-back reason.

No new dependency: symphonia's mkv reader drops the keyframe flag and
`DefaultDuration` and offers no frame count, so it could not have done
the job. edith keeps its 7 DT_NEEDED entries.
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(engine): HEVC import via the VA-API pluginAhmet Kaan Gümüş · 85c152d
✨ feat(engine): HEVC import via the VA-API plugin

The demuxer takes a hev1 track alongside avc1 and vp09. Its parameter sets are
read out of the file by hand: mp4 0.14 reads one byte of hvcC and skips the
rest, so the VPS, SPS and PPS an HEVC decoder cannot start without are
unreachable through the crate. A small ISO-BMFF walk finds the track's hvcC and
the record gives both the parameter sets and the NAL length prefix width -- the
avcC one is now read the same way instead of assumed to be four bytes, which is
one hardcoded guess less on the H.264 path too.

Samples are repacked to Annex-B exactly as H.264's are, parameter sets ahead of
every sync sample, because a hardware decoder that joins the stream at a seek
has nothing else to configure itself from.

Main 10 is refused at open by name: the plugin's NV12 pool and its vaGetImage
read-back are 8-bit, and a 10-bit stream decoded into them would be garbage
shown as a picture rather than an honest no. Same reasoning as the software
refusal, which is now one message shared by every codec that has no software
decoder at all.

The C ABI is unchanged again: the plugin demuxes the file it is given, so an
older libengine_hw.so still loads, still decodes H.264, and simply returns null
for an HEVC path.
✨ feat(engine): common audio files import and playAhmet Kaan Gümüş · fe53979
✨ feat(engine): common audio files import and play

mp3, wav, flac, ogg-vorbis, ALAC and ADTS join a timeline as sources with
no picture: symphonia's own probe reads them, the audio lane holds them,
and the video lane refuses them by name. The mp4/AAC path is untouched --
it is still the only one that yields packets an export can copy, so a
timeline carrying anything else is refused at export with the file and its
format named rather than exported silent.

A source with no picture is as long as it plays, rounded up to whole
frames; import, load and the library row all derive its length from that.
✨ feat(engine): VP9 import via the VA-API pluginAhmet Kaan Gümüş · 03a34d3
✨ feat(engine): VP9 import via the VA-API plugin

The demuxer takes a vp09 track alongside avc1 and hands its samples through
untouched -- an mp4 VP9 sample is a self-contained superframe, so there is no
avcC repack and no parameter sets to re-inject. VideoMeta carries the codec,
and the plugin picks its cros-codecs decoder from it.

The C ABI is unchanged on purpose: the plugin demuxes the file it is given,
so the codec is a property of the container rather than of the call, and a
libengine_hw.so built before this still loads and still decodes H.264 -- it
simply returns null for a VP9 path, the same no it gives for an unsupported
profile.

There is no software VP9 decoder to fall back to, so a VP9 file the plugin
will not take is refused at open, by name, where the front-end can show it --
never a black screen, and never VP9 bytes fed to rusty_h264. One timeline
stays one codec, and export re-encodes to H.264 as before; only audio is
ever copied packet for packet.
✨ 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.
🐛 fix(engine): NTSC frame rates survive the sample tableAhmet Kaan Gümüş · 3f81ef8
🐛 fix(engine): NTSC frame rates survive the sample table

`mp4 0.14`'s `Mp4Track::frame_rate` divides the sample count by whole
milliseconds before the float cast, so 24000/1001 read back as a flat
23.0: the picture the audio-sample master clock asked for was 4 % out and
the drift grew with the film — five minutes of it by the end of a
two-hour one. The frame rate now comes off the stts totals in f64, which
is exactly `timescale / delta` for a constant table and an average for a
spread one.

The same truncation lived at the writing end (a 90 kHz clock cannot count
23.976 fps in whole ticks), so the muxer picks a timescale that can:
90 kHz wherever it divides exactly — every integer rate, so those exports
are byte for byte what they were — and `round(fps * 1001)` over 1001
ticks otherwise, which is exact for the whole NTSC family. The hardware
encoder gets that same rational instead of a rounded `fps * 1000`.

The video edit list is honoured now too, the way the audio one always
was — but only what it really trims: a `media_time` equal to the first
`ctts` offset is the B-frame composition delay, not a cut, and reading it
as one throws two real frames away.

A file whose audio we cannot decode at all (an AC-3 remux) played silent
with the reason on stderr; the session carries it now and the window says
NO AUDIO in its notice bar.
✨ feat(engine): every audio stream is listed, and any one of them opensAhmet Kaan Gümüş · dff7d84
✨ feat(engine): every audio stream is listed, and any one of them opens

A remux carries one audio track per language; the engine took whichever
AAC track a HashMap handed it first and there was no way to ask for
another.

- probe_streams() describes every audio track in file order, undecodable
  ones included (decodable: false) so a picker can grey them rather than
  hide them
- open_multi_streams() takes (path, stream) per source; the old
  open_multi_segments is a wrapper pinning stream 0, so no caller moved
- stream ids come from moov.traks, not the tracks HashMap: "stream 0" was
  a different track run to run on a multi-track file
- a named stream that is missing or not AAC is an Err; stream 0 stays the
  silent source it always was, because a file we cannot decode the audio
  of still has a picture worth editing
- assets/test_multiaudio.mp4: video + AAC stereo + AAC mono (fra) + AC-3,
  which covers the picking, the language and the greyed row

2026-08-09

🔧 chore: add A/V test fixture to gen_fixturesAhmet Kaan Gümüş · fc06b75
🔧 chore: add A/V test fixture to gen_fixtures

Stereo AAC with distinct L/R frequencies (440/880 Hz) so channel
mapping mistakes are audible; 1 Hz volume pulse makes A/V drift
visible against the burned-in frame counter.
🎉 feat: MVP decode pipeline — mp4 → H.264 → gpui previewAhmet Kaan Gümüş · 0acbf8d
🎉 feat: MVP decode pipeline — mp4 → H.264 → gpui preview

- engine: mp4 demux → Annex-B, rusty_h264 software decode, BT.601
  I420→BGRA; decode on worker thread behind a bounded channel
- engine-hw: optional VA-API decode plugin (cros-codecs) behind a
  C ABI, dlopen'd at runtime with silent software fallback; the app
  binary keeps zero libva/gbm/drm linkage so it runs on any distro
- app: gpui window, per-frame RenderImage swap + drop_image
- vendor/: cros-libva + cros-codecs with 3 LOCAL PATCH fixes (libva
  1.23 struct init, radeonsi 64x64 min context, pub surface()) —
  upstream is dormant, so vendor/ is adopted code, not a temp fork
- fixtures are gitignored; scripts/gen_fixtures.sh regenerates them