forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 978e6857d64772912559c8d8a4e6ee7cd309bdccFiltered to crates/engine/src/demux.rsClear filter

2026-08-13

🔀 merge(engine): the stand-in decides one path, and the intra file keeps its marksAhmet Kaan Gümüş · eff035e
🔀 merge(engine): the stand-in decides one path, and the intra file keeps its marks

Lane P's proxy workflow meets a main that had taken S's persistent decode
workers, E's pipelined export and E4's zero-copy encode.

* `start_span` keeps S's reuse door and P's single substitution point at
  once: `picture_path(source)` is resolved *before* the door and handed to
  both halves of it. A worker holding the film is then asked for a span of
  the stand-in, declines on the path it already has (`Worker::reseek`),
  and `set_proxies`' seek becomes a respawn on the other file -- while a
  span that did not change files still costs no thread and no VA-API init.
  Asking the project for the path at the door, as main did, would have
  left every proxied span opening a worker from scratch.
* `Enc::encode_dma` takes P's `intra` flag, which is not symmetry: a proxy
  of a file already small enough is coded at that file's own size
  (`proxy::size_for` -- `wanted` is true for HEVC and AV1 at any size), so
  an intraframe export's decoder and encoder can agree on a surface and
  the buffer goes straight across. Marked `false` there, an all-intra
  stand-in would have carried no sync point at all, which is the exact
  bug `gop_limit` was written against, reached by the other door.
* The five other conflicts were both sides adding a field: `drop_late`
  and `proxies` next to each other, in the struct and in all three opens.
* `enc_depth` is keyed by codec, so the intra seat takes H.264's two. Said
  in its doc rather than left to be re-derived: that seat is the same
  entrypoint with every inter dependency removed, so a picture there is
  finished no later than one on the seat the two was measured on.

`nm -D libengine_hw.so` lists sixteen: P's `vh_enc_open_intra` beside
E4's `vh_next_frame_dma`, `vh_enc_dma_geometry`, `vh_enc_frame_dma` and
main's `vh_seek`. `picture_path` still has exactly one call site outside
the tests, and it is in `playback` -- an export reads the film.

The intra seat and the zero-copy path are read, not run: every test that
would reach either is hardware-gated and the GPU is wedged.
🐛 fix(engine): "no picture in it" is a header's answer, not an extension's guessAhmet Kaan Gümüş · 627d623
🐛 fix(engine): "no picture in it" is a header's answer, not an extension's guess

Two residuals of the proxy round, and the doc line that makes a hardware
run measure the code it was meant to.

The quiet answer for a file that is not a film was name-shaped: an
audio-only `.mp4`, `.mkv` or `.mov` is a video container with no video
track in it, so no extension can tell and every one of them still opened,
failed and said "NO PROXY" about a song. Only the header knows, and the
demuxer already knew -- it just said so in prose, which is the one thing
in this engine free to be reworded. `NoVideoTrack` makes it a type: the
two doors that mean *this file carries no picture at all* return it, a
front-end still shows the sentence it always showed, and the proxy takes
it as the same silent `None` a 1080p film gets. A picture in a codec
nothing here decodes is not that class and stays loud.

...and the cap was soft by exactly what it was capping: the sweep aimed
at 20 GB and then two encodes wrote gigabytes on top of it, so the disk
held the cap plus a film per encode (~43 GB worst case). It now sweeps to
`CACHE_CAP - reserve`, where the reserve is what those encodes will
really take -- the file's own bits-per-pixel arithmetic times the 1.25 the
hardware seat overshoots its asked-for rate by -- held to half the cap so
a single 4K feature cannot empty the cache to make room for itself.
`AT_ONCE` moves into the engine beside that arithmetic: how many encodes
run at once *is* how much room the sweep must leave, and two places
holding that number is one place for them to disagree.

The ignored hardware tests now say to build `-p engine-hw --release` as
its own step: `--tests` does not rebuild the cdylib, so the plugin beside
the test binary is whatever was there last time -- and a hardware claim
measured against a stale one is a claim about code nobody edited.

One commit rather than two: both fixes are in `proxy.rs`, in regions a
hunk split cannot separate cleanly (it was tried once and produced a
corrupt intermediate), so each is named here instead.
🐛 fix(import): Cancel stops the read, not only the landingAhmet Kaan Gümüş · 4d0dd2b
🐛 fix(import): Cancel stops the read, not only the landing

The Cancel beside the import line gave the window back and let the disk
carry on: a cancelled cold 24 GB remux still cost its twenty seconds, and
the notice said so rather than doing anything about it. The flag now
reaches the walk — `demux::with_cancel` installs it as the reading
thread's own, and every Matroska cluster the header index and the subtitle
pass step over checks it and gives up there, with `is_cancelled` telling an
abandoned read from a file that would not open.

Thread-scoped rather than a parameter, deliberately: a read *is* a thread
here (an import worker, an audio feeder, a decode worker), and the walk
that has to stop sits five frames under an `open` with a dozen callers,
none of which have anything to cancel.

An mp4's header stays uncancellable — it is one read inside `mp4::Mp4Reader`
with no flag to poll — so the notice and the button say the read stops
"where the container lets it" instead of promising the disk went quiet.

The feeder's own abandoned opens are NOT wired to this, and the corner-cut
in `spawn_feeder_deferred` says why: three runs of one build over 200 cold
scrub steps measured 14, 101 and 137 live workers, so that number is the
machine's and not the cancel's — and cancelling every step's walk would
stop the sidecar index from ever being written, which is the thing that
makes the second pass over a film fast.
✨ feat(engine): a big film gets a small stand-in to cut withAhmet Kaan Gümüş · 83e561d
✨ feat(engine): a big film gets a small stand-in to cut with

A proxy is the film at 1280 on its long edge, every frame an IDR, no
sound in it at all: a seek lands on the frame asked for instead of on
the nearest one a decoder can start from, and the mix stays the
original's.

Generation is the export walk given a one-clip project and a smaller
canvas, so the hardware seat, the progress and the cancel are the ones
a file export already had. Two switches were wanted for it: `intra_only`
(one frame a GOP on the H.264 pair) and `keep_source_colour`, which
carries the film's own space into the stand-in instead of converting it
-- that conversion ran on the source's full 4K, cost 48 ms a frame and
was the whole of a proxy's price, and leaving it to the screen means the
tone-map preset can still be changed after the stand-in was made.

The cache is keyed on the source's path, length and modification time,
so a re-encoded original misses rather than reading a stale stand-in.

A 4K HDR film: 2.35x realtime on the VA-API seat, against 0.59x before
the colour switch; a cancel leaves neither the file nor its .part.
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.

2026-08-12

⚡ fix(export): the sound of a feature film is measured in a minute, not in half an hourAhmet Kaan Gümüş · 3fc6753
⚡ fix(export): the sound of a feature film is measured in a minute, not in half an hour

An mkv export of a two-and-a-half-hour film wrote zero bytes for twenty-one
minutes and then failed its own test's ten-minute cap. All of it was the Opus
fidelity gate: `ruopus` is built here without its `spectrograms` feature, so its
inverse MDCT is an O(n²) DFT with a `sin_cos` per term and decodes at 0.2x real
time. Measured on a two-minute window of a real 4K film (the new
`export_audio_cost` example, and the three `export audio:` lines it reads):

    mix (E-AC-3 5.1 -> stereo)   0.7 s
    Opus encode (opus-rs)        0.3 s
    fidelity decode-back        24.2 s   <- 98.6% of the pass

So the gate now samples: twelve five-second windows spread across the track, a
warm-up per window because CELT predicts across frames, and the *worst* window
is the answer -- which is harsher than the old whole-track sum, where a ruined
minute averaged away against two good hours. What it looks for survives
sampling: OPUS_MAX_KBPS's cliff is a rate the encoder falls off, not a defect of
one bar of music. A window with no sound in it is skipped rather than scored
0.0, which is what a silent timeline used to score before falling back to AAC.

...and the export no longer decides what it is *after* paying for the sound:
CopyPlan is consulted first, so the line on screen says "copy" from the first
second, and the audio pass owns the head of the progress bar instead of leaving
it at zero for as long as it runs.

Beside them, for the card that has been predicting the wrong export in both
directions: `planned_seats` asks the export's own gates what it would open, and
`sync_points` hands a front-end the frames a cut may be placed on.

    cargo test -p engine --release --test video_copy -- --include-ignored
      7 passed in 157.6 s (was: failing the 600 s cap)
✨ feat(export): an untouched Matroska timeline leaves as its own packetsAhmet Kaan Gümüş · ada6ac5
✨ feat(export): an untouched Matroska timeline leaves as its own packets

The picture's half of what `copy_audio` already did for the sound: where a
copy says exactly what the timeline says, the coded blocks of the source are
written straight into the file and no decoder or encoder is opened at all.

The gate is the audio one's doctrine, not a looser one -- Matroska in and
Matroska out, the source's codec is the one this format carries (HEVC for
`Format::Hevc`, AV1 for `Format::Av1`), and nothing has touched a sample: no
grade, no speed, no rate conversion, no gap to fill with black, no source of
another size, no `ContentEncodings` packing to undo. Every span must begin on
a sync point and end where the next begins, which is what placing a cut on a
keyframe gives it.

All or nothing per export, and that is the interesting constraint: a copied
span and an encoded one cannot share one track, because this project's
encoders write 8-bit SDR streams with parameter sets of their own and a
container states its configuration record once -- splicing them into a Main 10
HDR source would change bit depth and colour mid-track. So the head and tail
fragments of a cut that lands mid-GOP are not re-encoded into the copy; they
are what makes the whole export fall back to the encoder it always used.

A copy keeps its source's `Colour` as well as its `CodecPrivate`: an HDR film
copied is still the HDR film, because not one of its samples was touched. The
blocks are timed by their source's own timestamps (`MkvMuxer::write_block`)
rather than by a frame counter, without which a stream with B-frames -- stored
in decode order, timestamped in display order -- would play its groups of
pictures in the order they were coded in.

An open-GOP source writes leading pictures after a sync point that are shown
before it and reference the group before it; at the start of a copied region
those references are not in the file, so they are dropped rather than written
as pictures no decoder can put back together. The region still starts at the
timeline frame it owns, so the sound never drifts.

Measured on a real-library 4K x265 HDR Matroska of 2h30m (167671 pictures),
five minutes cut out of the middle on two sync points: the export takes 162 s
and writes 10.8 GB, against a re-encode of the same timeline measured at
0.94-1.75 pictures a second -- 25 to 47 hours for the same file. Every block
sampled either side of the join is its source's own bytes, the shown order is
one unbroken frame grid, and the pictures two seconds either side of the join
decode through this project's own decoder without an error.
🐛 fix(decode): a seek lands on the frame it names in an open-GOP streamAhmet Kaan Gümüş · ea25339
🐛 fix(decode): a seek lands on the frame it names in an open-GOP stream

A picture's index everywhere above the demuxer is its rank in *display* order,
but both demuxers answered a seek with the position the sync point is *stored*
at. The two are the same number only while nothing is coded out of order -- and
an open-GOP HEVC stream, which is what x265 writes by default and so what every
film off a disc or a web rip is, stores the CRA that opens a GOP ahead of the
RASL leading pictures shown before it. In `test_hevc.mkv` the keyframe shown
30th is block 28, so scrubbing to frame 45 handed back frame 47, and to a
different frame again in a GOP carrying another number of leading pictures.
This is the film-scrub path for a 4K HEVC library.

`sync_display_order` ranks every sync point by the presentation time the
container states -- Matroska block timestamps, an mp4's `stts + ctts`
composition times -- and the seek picks and reports the keyframe at or before
the target *on screen*. The mp4 half is that and nothing else; a track with no
`ctts` box keeps the sample-id path it had, untouched.

The Matroska half has one more thing to say, because its blocks are a window
of ten seconds and a display rank is a statement about the whole film. The
`Cues` already carry that statement: a `CueTime` over the track's frame
duration is how many pictures are *shown* before that keyframe, counted by the
muxer over the file. So the window is ranked among itself by timestamp -- the
same function, the same rule -- and shifted onto the cue's own number, which
makes the two answers one answer. A file walked whole shifts by zero: its
window is the file.

Kept per window rather than per seek, so scrubbing a file that has no usable
cues -- the one case where the window is the whole walk -- ranks it once.

`the_cue_index_and_the_whole_walk_are_the_same_index` now states the claim in
display order too: the lazy window and the whole walk must name the same
picture, and it is the walk's own ranking that says which.
`hw_decode::seek_matches_linear_every_container` sweeps every fixture
container/codec pair at targets on, either side of and away from a keyframe,
plus frame 0 and the last one; it fails on the old code at `test_hevc.mkv`
frame 29.
⚡ perf(demux): the walk a Matroska file still needs is written down onceAhmet Kaan Gümüş · 8651b15
⚡ perf(demux): the walk a Matroska file still needs is written down once

The `Cues` path took the picture's open off the whole-cluster walk, but two
callers still pay it in full: a sound track, which Matroska indexes not at all
and which is walked on its own track number, and a picture whose index is
absent or caught lying. On a real 10.9 GB E-AC-3 film that is the first
contact with the file -- 9.7 s before a note is heard, and 298 ms every time
the session reopens it, which the editor does at every seek across a clip
boundary and once per export span.

That walk's answer is now written beside the user's other caches, in
`$XDG_CACHE_HOME/edith/mkvindex` (`~/.cache` where the desktop names none),
one file per track of every Matroska file walked, and read back instead of
re-walking.

Correctness first, speed second. A sidecar is valid for one file and nothing
else: its canonical path, its size, its modification time to the nanosecond,
the segment bounds and the track number are written into the record and
compared field by field on the way back. Format version in the magic, FNV-1a
over the payload, every field length-checked as it is read, nothing left over
at the end. Any mismatch at all -- absent, stale, damaged, another version, a
hash collision on the file name -- is a miss, which means the walk runs and
the file is rewritten. There is no path where a wrong index is believed.

Written atomically, temporary file then rename, so a reader sees a whole index
or none; a write that fails is a slow open rather than a failed one.

Hand-rolled little-endian records, no new dependency: a flat table of
fixed-width fields does not need a serializer, and this tree carries none.

The one thing the key does not cover is the code that filled it: a build whose
walk answers differently would believe every record written by the last one,
and only the magic's version byte stands there. It says so at the constant,
and it is bumped here for exactly that reason -- this tree's walk is not the
one the lane that first wrote this format had.
⚡ perf(demux): a Matroska file is read forward without rechecking its indexAhmet Kaan Gümüş · 8d969d0
⚡ perf(demux): a Matroska file is read forward without rechecking its index

Reading a cued file from end to end got slower than the whole-cluster walk it
replaced -- 4.8 s to 192.8 s on a 4.9 GB AV1 remux, and worse the longer the
film. The window of blocks grows by a cluster on every read and nothing
trimmed it, while both index checks scanned that window from the front: every
cue the walk had already passed was re-anchored per cluster, and every anchor
scanned to the far end of the window twice. Quadratic in the file's length, so
the numbers only looked fine on a fixture.

Each cue is now checked once. `checked` is how far that has got through the
cue list, and a cue the window jumped past is stepped over rather than
re-examined -- the cue a seek actually anchors on is checked by `jump` itself.
Both scans inside `anchor` are bounded by `REORDER`, which is what they were
describing all along: the block a cue names sits at its own index less
whatever was reordered across it, and only a cue that is not where it says it
is pays the full scan -- once, because that answer degrades to the whole walk.
The cue lookup a seek does is a binary search now, the list being sorted.

  4.9 GB AV1, 282024 blocks   walk 4810 ms -> 3927 ms   open 2654 ms -> 0.5 ms
  7.1 GB HEVC, 171432 blocks  walk 6393 ms -> 5821 ms   open 7326 ms -> 1.8 ms

against the whole-cluster walk this replaced, same access-unit hash on both
files and the same landing for every seek. Reading forward is now cheaper than
the walk instead of 40x it, and the open the cue index bought stays.

A read error while rebuilding the window is no longer dropped on the floor:
answering a seek off a window that belongs to another part of the file is a
landing nobody asked for, so the fallback is named -- the whole walk, the one
index that does not depend on the window.

`a_cue_that_lies_about_its_time_degrades_to_the_walk` is the other half: a real
fixture with one `CueTime` moved a tick, which is a well-formed index naming a
block that does not exist. The walk takes over where the read meets it, every
frame still comes back, and every seek lands where the honest file's does.
⚡ perf(demux): open a Matroska file off its Cues, not off every clusterAhmet Kaan Gümüş · 84ee43f
⚡ perf(demux): open a Matroska file off its Cues, not off every cluster

Opening a Matroska file walked the whole segment -- every cluster header
of every gigabyte -- because Matroska carries no sample table and the
frame count and the sync points had to come from somewhere. That is
seconds of disk per open, and an open happens on every seek, every clip
span and every export source, not once per file.

Matroska has an index of its own and nothing here read it: `Cues`, one
entry per keyframe, written at the far end of the segment and found
through the `SeekHead` in kilobytes. Now the open parses that, and the
clusters are walked only where a caller asks to read -- one cue interval
at a time, ten seconds of film.

Measured, cold (page cache dropped per file) and warm, on the library:

  file                       open cold      open warm     bytes read
  4.9 GB AV1 remux         4027 -> 26 ms   469 -> 0.6 ms  9.9 MB -> 99 KB
  12.1 GB 2160p HEVC       9508 -> 54 ms   958 -> 8.6 ms  13.2 MB -> 1.3 MB
  1.4 GB 720p H.264 (ep)    395 -> 1.8 ms   64 -> 0.2 ms  1.5 MB -> 20 KB

Same answers, not similar ones
- The frame count stays exact at open: the last cue's index plus the
  blocks after it, counted by walking from that cue to the end of the
  segment. No duration-times-rate estimate, nothing corrected under the
  UI later.
- A cue states a *timestamp*, and a stream with B-frames does not store
  its blocks in that order: `anchor` counts the blocks written after a
  cue and shown before it, which is the difference between the frames
  shown before it and its place in the file. Without that a 60-frame
  HEVC fixture reports 62 and every seek lands two frames late.
- `cues_agree` checks that arithmetic against the file's own blocks
  wherever a walk meets a cue. A file that disagrees -- variable rate,
  cue times naming no block -- falls back to the whole walk rather than
  seeking to the wrong frame. So do files with no `Cues` at all, and
  tracks with no `DefaultDuration` (nothing to turn a cue time into a
  frame number with).
- `probe_bitrate` completes the index first: it adds block lengths up
  and wants the file, so it pays the walk it always paid.
- The `Cues` element is read whole and parsed in memory. Element by
  element through the file, a 2160p film's ten thousand cue points cost
  a `pread` apiece: 118 ms of open against 8.6.

Checks
- `demux::tests::the_cue_index_and_the_whole_walk_are_the_same_index`:
  for all 20 Matroska fixtures, the cue index and the whole walk agree
  on the block list, the frame count, and where every frame of the file
  seeks to -- asserted per frame, forwards and backwards.
- `a_file_with_no_cues_is_the_walk_it_always_was`: a fixture with its
  `Cues` id and `SeekHead` pointer overwritten (no muxer here writes a
  file without an index) opens, counts and seeks identically.
- `examples/mkv_open_cost.rs`: open ms, bytes through the read syscalls,
  seek landings and a hash of every access unit. Run against the build
  before this change, the three library files above agree line for line
  on every landing and every hash.

Approach referenced from `matroska-demuxer 0.8.1` (hasenbanck), which
resolves a seek the same way; the parsing is this file's own EBML
reader, no dependency added.
🔒 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(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.
🐛 fix(decode): a 4K wavefront HEVC is 33 entry points, not 32Ahmet Kaan Gümüş · 65ea910
🐛 fix(decode): a 4K wavefront HEVC is 33 entry points, not 32

A 4K wavefront HEVC film (3840x2160, CTB 64,
entropy_coding_sync) writes num_entry_point_offsets = 33 in every slice
header -- exactly
PicHeightInCtbsY - 1, which is what ITU-T H.265 §7.4.7.1 allows -- and the
vendored parser kept them in a [u32; 32]. The 33rd panicked, the plugin edge
caught it, and the user got a black picture and an instant eof.

The list is now sized by the stream. Same shape swept through the rest of the
h265 parser, where a parsed count could outrun a fixed array: tile columns/rows
(the CTB grid allows far more than the 19/21 the VA-API picture parameter
holds), the long-term ref pic block, and sps/vps_max_sub_layers_minus1, which
u(3) can read as 7 into 7-long arrays. Those refuse by name instead.

And the door now asks the plugin for one picture before it lets a file in: a
session that opens and then decodes nothing was the black screen with no
explanation, so it is refused in its own words rather than in the missing-plugin
ones.

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(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(subtitles): a PGS cue is a picture the timeline carriesAhmet Kaan Gümüş · 1bee319
🔀 merge(subtitles): a PGS cue is a picture the timeline carries

Conflicts, both in the demux lane's territory:
- matroska_subtitles wanted-track filter: PGS joins S_TEXT, and both
  still skip a track whose ContentEncoding the demuxer cannot undo.
- mkv_subtitle_blocks: the demux lane's laced walk stands; A's
  single-payload read and its refusal of lacing are dropped. A laced
  block's cues share a start, so end_of's strict > still finds the
  next real block.
- cues_of: A's &mut signature and PGS doc, with the demux lane's
  unsupported early return that is the source of the refusal text.
✨ feat(demux): a header-stripped or laced Matroska track plays instead of refusingAhmet Kaan Gümüş · 5d028c2
✨ feat(demux): a header-stripped or laced Matroska track plays instead of refusing

Two features every disc rip and streaming remux carries and this demuxer had no
reader for:

- `ContentEncodings`: header stripping (`ContentCompAlgo` 3) puts the bytes the
  muxer cut off the front of every frame back, and zlib (algo 0) inflates.
  bzlib, lzo1x, an unknown algorithm and encryption are refused *by name*, and
  per track -- a film whose sound cannot be read still shows its picture, and a
  subtitle track that cannot be read is listed with the reason like a bitmap
  one.
- Lacing: all three headers (Xiph, fixed, EBML) read into one `Block` per
  frame. The frames of a lace get a timestamp each, interpolated across the gap
  to the block after, because six E-AC-3 frames stacked on one instant is a
  sound track that walks away from the picture inside a cluster.

The two films this was cut for: a BluRay remux whose H.264 track is stripped of
one zero byte per block (no picture at all before this), and a WEB remux whose
every E-AC-3 block is fixed-laced (no sound at all before this). Both are
existence-gated tests beside the hand-built EBML fixtures.

zlib is `miniz_oxide`, which `image` already pulls into this build through
`png`: no new crate tree and nothing new to compile.
✨ feat(subtitles): a PGS cue is a picture the timeline carries, not a row that says noAhmet Kaan Gümüş · c45b18e
✨ feat(subtitles): a PGS cue is a picture the timeline carries, not a row that says no

The four S_HDMV/PGS tracks of a BluRay remux were listed and greyed: pictures,
and nothing here could draw one. Now the cue IR carries a picture beside its
text -- `Cue::image`, a `CueImage` holding the display set the Matroska block
held -- and the rows are rows a click can pick.

The decoding is `oxideav-sub-image`: the run-length walk, the palette, the
YCbCr and the object fragmentation are not this project's to re-derive. What is
written here is the framing between the two -- a Matroska block is a `.sup`'s
segments with the `PG` magic and the timestamps taken off, so they go back on --
and the pairing PGS needs and text does not: half the blocks compose nothing,
which is the disc clearing the screen, and that is where the cue before them
ends. `BlockDuration` is zero on every one of them, so `end_of` now reads a zero
the way it reads a missing one.

Kept encoded, decoded when something is about to draw it: this film's canvas is
8 MB of RGBA and its four tracks carry eleven thousand display sets, so the IR
holds the thirty megabytes the file already spends and the front-end keeps one
decoded picture for as long as its cue is up.

An export still writes a text track, so a track of pictures writes none and the
card says "drawn, not written" before the button. A `.edith` is unchanged: it
held a file and a track number and never a cue, which is why a bitmap track
round-trips without the format knowing it exists.
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.
✨ feat(export): every video format carries sound, AV1 picks its box, MP3 is a rowAhmet Kaan Gümüş · 5ebd3ac
✨ feat(export): every video format carries sound, AV1 picks its box, MP3 is a row

Three asks, one seam — the export's audio path was a packet copy, and everything
it could not copy was a refusal.

- MkvMuxer gains an A_AAC track (CodecPrivate = AudioSpecificConfig, CodecDelay
  one packet) and interleaves it into the clusters: an AV1 export carries the
  timeline's sound instead of naming it as left out.
- Mp4Muxer::create_av1 writes AV1 into an mp4 — the `av01` + `av1C` sample entry
  `mp4 0.14` cannot spell is patched into the finished moov (layout cribbed from
  OxideAV's oxideav-mp4, MIT); Mp4Demuxer reads that entry back.
- Format::Mp3 through `rusty_mp3` at 256 kbps CBR, and Format::Av1Mp4 beside
  Format::Av1: the export card has a row and a key for each.
- copy_audio lifts every "cannot copy" refusal into a route to encode_audio —
  a second audio lane, a speeded clip, a Matroska source, an mp3 or a png
  timeline. A copy nothing forces stays a bit-exact copy.

Round trips per container, through this project's own readers: mkv + mp4 AV1
with a tone (mux unit tests), an AV1 export in either box (tests/av1.rs), a
still under a song as an mp4 with sound and an MP3 of the timeline
(tests/audio_export.rs), two lanes summed into an mp4 (tests/lanes.rs), a
speeded lane resampled into one (tests/speed.rs).

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.
🐛 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.
✨ 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): 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.
🐛 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.

2026-08-09

✨ feat(engine): seek primitives — video open_at, ao_flush, audio open_atAhmet Kaan Gümüş · 96ae365
✨ feat(engine): seek primitives — video open_at, ao_flush, audio open_at

Lane 1 of the seek slice; PlaybackSession orchestration comes next.

- demux/decode: stss sync lookup, DecodeSession::open_at decodes from
  the keyframe and discards to the target; Frame.index stays absolute.
  HW plugin ABI: vh_open renamed vh_open_at(path, target) — discards
  skip the vaGetImage readback; measured seek cost 65ms HW / 222ms SW
- engine-audio: ao_flush drains the ring consumer-side in the RT
  callback (one-shot atomic), stale PCM unplayable even when paused;
  played-position atomics untouched so clock math survives
- audio: open_at walks stts, 2-packet AAC pre-roll (MDCT overlap
  reconstructed exactly — verified 0-diff before the first PNS band),
  sample-exact trim; priming skip and seek discard unified. AAC seek
  is deliberately not bit-exact: symphonia's PNS noise LCG state
  depends on packet history; bounded <1e-3 by test instead
🎉 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