Commits
Commits on
2c8e3aa151eb0ab655f319f6cdc69a4f66f2b3ff2026-08-12
✨ feat(ui): the floor, the notices and the silent refusalsAhmet Kaan Gümüş · 2c8e3aa
✨ feat(ui): the floor, the notices and the silent refusals The transient bars hang off the bottom of the picture instead of taking a row of the column -- a notice arriving used to push the transport, the toolbar and the timeline down by its own height, which is every control below it moving with state. At 640x360 the timeline takes at most its share of the window and its lanes scroll inside it, the library tabs wrap rather than hanging off the panel, and the level's bar stands down while its button and its keys stay. A class refusal (esc with nothing exporting) is silent; a state refusal speaks.
✨ feat(ui): library tabs, accent primary action, redesign guardsAhmet Kaan Gümüş · 2171351
✨ feat(ui): library tabs, accent primary action, redesign guards Media/Audio/Text tabs over the media pool (the giants' split), the Export button as the one accented control in the window, and three guards: no colour outside the theme, no settings card drawn from the root, and a reserved rect for every button whose label changes with its state.
✨ feat(ui): four regions, one oracle, one token tableAhmet Kaan Gümüş · 2ae5c26
✨ feat(ui): four regions, one oracle, one token table Library left, picture centre with its own transport strip, inspector right, timeline full width along the bottom with the edit toolbar directly above it -- the arrangement Movavi and CapCut share. The settings cards are docked in the inspector, so adjusting a clip no longer hides the clip. Every button asks the one availability oracle, and so does act(): with no file open the toolbar used to be dim and dead to the pointer while the very same actions still fired from the keyboard. Snap, mute and the volume keys answer with nothing open, in both doors, and everything else dims with the oracle's own reason in its tooltip. Clips are painted by kind (video blue, audio green, still teal, cues purple) on a near-black ground with one cyan accent, and every stateful button keeps a rect that does not change with its state.
♻️ refactor(ui): extract the UI out of main.rs into ui/ modulesAhmet Kaan Gümüş · d8bffff
♻️ refactor(ui): extract the UI out of main.rs into ui/ modules The whole window was one 19,916-line file with one Render impl in it, which is why every colour sweep so far lost to instance patches: there was no seam to sweep. One module per region, and one theme module every paint reads a token from -- no 0x literal survives outside it.
🚀 perf(import): the container walk goes to the worker, not the render threadAhmet Kaan Gümüş · 0e88697
🚀 perf(import): the container walk goes to the worker, not the render thread The Import door read the file twice: once on a worker to warm the page cache, and once on the UI thread to actually parse it. The second one is what a person sees -- 2.5-6 s of frozen window opening a 24 GB 4K HEVC remux, and 0.8-8.9 s importing one beside a timeline that is already up. The subtitle half of this door was split across the hop a while ago (`parse_subtitles` walks, `add_subtitle_tracks` pushes); this is the container half, and it is the same split. The engine grows the two doors the front-end needed: `probe_import` -- the header, the decoder this machine would open it with, and the audio check, all with no session in reach, so a worker can run it -- and `import_probed`, which registers what came back and touches no disk. The gate they are decided against (`import_gate`) is two clones off the timeline, so the UI thread hands it over and goes on painting. A timeline that moved while the worker read is noticed rather than trusted: a stale probe falls back to the slow door and lands the same row. A file arriving at a window with no timeline to import into is opened whole on the worker instead (`open_whole`), which is where the 2.5-6 s went, and every `.edith` -- dropped, picked or named on the command line -- now goes through the one queue as well, so its open is a worker's too and the line above the panel names it while it runs. Measured on a real-library 4K HEVC remux (24 GB): the header walk is 21.4 s cold and 429 ms warm, and probing the timeline's own first source is another 1-4 s. None of it is the render thread's any more. ...and the line that says so grows a Cancel, because a read that long needs a way out. The read in flight is not stopped -- a demuxer walk polls nothing -- so the window is given back at the click, the file does not land, the queue behind it is dropped, and the notice says exactly that rather than promising the disk went quiet.
✅ test(audio): the mkv seek landing is measured on a real film, not only the fixtureAhmet Kaan Gümüş · 1501d34
✅ test(audio): the mkv seek landing is measured on a real film, not only the fixture
P7 asked for a fix to a seek that lands ±1.5 s off in content on a
real-library AV1/Opus remux. It does not land off any more: `fix(audio): a
seek into a Matroska
lands on the second it asked for` (90e5ed2, four hours before this)
already reopens the reader and re-asks from far enough back to swallow the
cue table's overshoot. Measured here rather than taken on trust — the same
`seek_dump` example, correlated against ffmpeg's decode of the same window:
600 s 610 s 3600 s
before +1.473 s +3.394 s +0.014 s
after -0.000 s +0.000 s -0.001 s
("before" is that commit's parent checked out over this tree, so both rows
are this machine, this file, this hour.)
What was missing is the guard. `audio_seek.rs` proved the rule on a 30 s
synthetic chirp with one cluster layout, and the failure it exists for was
found on a 5 GB film with a cue table — so the film is what the test now
seeks into, at 600, 610 and 3600 s, locating each landing by normalised
cross-correlation against ffmpeg (coarse over a decimated ±5 s window, then
refined at full rate) and holding it to 50 ms.
Verified to fail on the code it is about: with 90e5ed2's parent audio.rs in
place it reports "asked 600s, heard 601.473s -- +1.473s of sound against
picture" and passes on HEAD. Skipped, never falsely green, on a machine
without the film or without ffmpeg.✨ 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.
🔊 feat(export): an edited Opus source leaves an mkv as OpusAhmet Kaan Gümüş · 76ede8e
🔊 feat(export): an edited Opus source leaves an mkv as Opus Opus could be read here since `ruopus` landed and could not be written at all, so every cut of an Opus film came out as AAC in a Matroska file: a codec downgrade nobody asked for, paid on every edit. `opus-rs 0.1.26` is the encoder half -- a pure-Rust port of libopus 1.6, BSD-3, no `build.rs`, not one `.c` in the crate and no dependencies at all (checked, not read off the README) -- and a Matroska export now writes `A_OPUS` with an `OpusHead` in its `CodecPrivate`, `CodecDelay` and the codec's fixed 80 ms `SeekPreRoll` beside it. An mp4 still says AAC and the mp4 writer now refuses an Opus track by name rather than declaring `mp4a` over it. Only where an *encode* was going to happen anyway. An untouched timeline still copies its packets, bit for bit, into the same container: Opus is what an edit costs, never what a passthrough costs. The envelope is measured and it is narrow, which is the whole story of this crate. On three one-second spans of a 5.1 Opus film, encoded here and decoded with `ruopus` -- not the suspect, it reads ffmpeg's libopus at 256 kbps back at correlation 1.00000 -- the encoder is usable to 128 kbps (0.937/0.989/0.994) and ruined by 136 (0.452/0.697/0.951), against libopus at 0.997/0.998 on the same material. Pure-tone fixtures put that cliff at 165 kbps, so its edge moves with the content and no constant is safe on its own: the cap is 128 kbps *and* every track is decoded again and correlated with the mix before it is written. Below 0.95 the export writes AAC instead, and the encoder line the export publishes says AAC, so the fallback is visible rather than silent. Mono keeps AAC outright -- this encoder mis-codes it at every rate asked for here -- and so does any timeline that is not 48 kHz, since Opus has one rate and resampling a whole timeline to reach it is a bigger change to the sound than the codec is. Two delays, both measured rather than hoped for. The pre-skip is 1080 samples: the encoder's 2.5 ms lookahead plus one warm-up frame, because a cold first frame comes out ramped and out of phase (the head of the fixture went 0.9788 -> 0.988 correlated once it was fed its own first 20 ms first), and one silent frame is pushed in at the end so the last 2.5 ms leave the encoder instead of ending the track short under a picture that is not. ffmpeg's decode of the file agrees with this project's own reader sample for sample, which is what says the header describes the stream. `tests/opus_export.rs` exports a cut and reads it back through symphonia's mkv reader and `ruopus` -- 0.9948 left and 0.9825 right against the source, 0.997/0.993 past the first frame -- proves the AAC copy still wins where it applies and that a mono mix takes the AAC path, and, with `EDITH_OPUS_FILM` pointing at a real-library Opus mkv, cuts a span out of the film itself: correlation 0.9914 at a lag of one sample. The unit test in `export.rs` pins the 256 kbps failure, so the day the crate fixes it this suite fails and the cap can be raised.
✨ 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.
🔍 chore(engine): what a Matroska sound track's open costs, as an exampleAhmet Kaan Gümüş · 1acf384
🔍 chore(engine): what a Matroska sound track's open costs, as an example The picture's open has `mkv_open_cost` and the sound had nothing, which is the half the sidecar index exists for -- Matroska indexes no audio samples, so a sound track is walked whole every time it is opened. This is the number that claim is made of, on files too big to keep as fixtures.
🐛 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.
⬆️ deps(h264): the software decoder now agrees with ffmpeg, picture for pictureAhmet Kaan Gümüş · 1d9b2f4
⬆️ deps(h264): the software decoder now agrees with ffmpeg, picture for picture `rusty_h264` 0.8 was not bit-exact. Across a 1080p High and a 720p Main clip -- 750 pictures, both with B-frames -- it reproduced ffmpeg's own decode byte-for-byte on 26 of them and drifted on the other 724, worst case 69.8 dB PSNR. That is invisible on a monitor and still wrong: it is the picture a grade is measured on, the picture a still is exported from, and the picture a software export re-encodes. 0.9.1 matches ffmpeg on all 750, which is the property the manifest already demands of `ruopus` and `oxideav-ac3` and had never actually checked here. Pinned exactly for the same reason they are. It is faster by the same stroke: 247 Mpx/s against 171 decoding the 1080p clip, 256 against 176 on the 720p one -- 1.44x, single-threaded, min of 20 interleaved rounds on a loaded box (a second binary built from the same 0.9.1 sources came within 1%, which is what the interleaving is for). Software encode is a wash at 1.04x and 0.97x, so nothing about an export's speed changes; what changes is what it encodes *from*. The challenger measured against it, `rust_h264` 0.4.0 (MIT/Apache-2, pure Rust, decode only), does not take the seat on either axis: 1.00x and 0.88x of 0.8's decode rate, so 0.69x of this crate's, and it is not bit-exact either -- 256 of the same 750 pictures, worst 39.2 dB, and the mismatches are pixels ffmpeg never emitted rather than a reordering. The gate wanted 1.25x and no correctness regression; it returned neither. `default-features = false` stays, and keeps the vendored openh264 SIMD kernels (`asm`, `nasm` at build time) out of a build this project promises needs no tools. It does not keep out `rusty_alloc`: the facade pulls its sub-crates with their own defaults and `rusty_h264-common` installs that allocator process-wide for the whole app. Nothing downstream can switch it off. Measured at 0.104 s against glibc's 0.142 s on 2M mixed allocations, so it is a gift rather than a tax -- but it is a gift nobody asked for, and the manifest now says so.
🐛 fix(decode): a tiled HEVC counts its entry points past a u8Ahmet Kaan Gümüş · 907dae0
🐛 fix(decode): a tiled HEVC counts its entry points past a u8 §7.4.7.1 bounds num_entry_point_offsets for a tiles-without-wavefront stream by (num_tile_columns) * (num_tile_rows) - 1, and this parser accepts up to 20 columns by 22 rows -- 440, which it computed in u8 because both counts are u8. Release wrapped it to 183, so a conformant stream's 184th entry point onward was refused and the picture never arrived; a debug build panicked on the multiply. Widened before the multiply, where the spec does the arithmetic. Sibling of fbd4a24 (a real-library 4K wavefront HEVC HDR film's 33 entry points in a [u32; 32]), found by sweeping that fix's own line pair for the same shape.
🔒 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(ui): a menu offers what applies, fits the window, and nothing paints over itAhmet Kaan Gümüş · 8a2e813
🖱️ fix(ui): a menu offers what applies, fits the window, and nothing paints over it A right-click on an audio clip listed a grade and a fit policy, and the one row the user named -- "Detach the sound from the picture" -- read as a video item on a waveform. Both menus take their rows from an oracle now and from nothing else: `menu_items` filters the action registry through `enable`, and `row_items` does the same for a library row through `row_enable`, so an item cannot appear where it does not apply by being added to a list alone. The detach is worded from neither half, because it takes the pair apart. The clip menu was capped at twelve rows whatever the window, so a menu opened low in a 720 px window put everything past the fit policy behind a scroll nobody was told about. `menu_rows_h` gives the list the room the window has, and the card is placed by the very height it is drawn to. A tooltip already on screen when a menu opens stays on screen in gpui -- occluding the surface under it does not take it back (`div.rs`, its own TODO) -- so the tip stands aside instead: one flag, read by every hover label in the window. The scrims occlude as well, which is what stops a new one appearing. The actions card was 320 px wide with labels that were not: "Remove the last video track (it must be empty)" printed straight over the stroke beside it. It is 480 now, its labels truncate rather than overprint, and the list scrolls under a rule instead of against the search line.
🐛 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(ui): a card closes and a short clip is hittable without the keyboardAhmet Kaan Gümüş · 8e2a297
🖱️ fix(ui): a card closes and a short clip is hittable without the keyboard Seven modal cards swallowed the press on their scrim, so esc was the only way out of any of them -- the same "reachable by stroke alone" complaint, said about the way out instead of the way in. The scrims now close the card the way the menus already do (`close_card`, one list, read off `modal` by the guard so a card added there cannot be born pointer-less), and each card body swallows its own presses so a button never closes the card under its own click. Every card says "a click away or esc closes". And a clip box is drawn no narrower than HIT_MIN (`clip_width`): zoomed far out a short take was worth a fraction of a pixel and could not be selected, dragged or given a menu at all. The trim strips are still asked of the clip's own width, so a padded box keeps all of itself as a body.
🐛 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(ui): four defect classes made impossible instead of testedAhmet Kaan Gümüş · 5909fc9
🛡️ fix(ui): four defect classes made impossible instead of tested The action list is one list now: a `macro_rules!` writes the enum and `ActionId::ALL` from the same names, so a variant added with `ALL` untouched -- which compiled, passed and dropped the action off the keys card -- cannot be written any more. The reachability guard reads `keymap::FIXED` too: every card-local stroke names the element a pointer presses instead, or says in the type (`Reach::Gesture`) that there is nothing to press. `g` and `r` on the export card were keyboard-only while the card advertised them, and are rows of their own now. Trim strips are suppressed under three handles of clip: a jumpcut's short clips were 100% handle, so nothing could select or drag them. The codec row's chord comes off `FORMATS` (it said six keys for the seven codecs its label named -- OGG's `o` was invisible), and the panel's button row carries a pinned door beside the scrolling part, since "it scrolls" is not "it can be found" at the 640x360 floor.
⚡ perf(playback): a seek opens the sound on the feeder, not on the hand that seekedAhmet Kaan Gümüş · 46e8379
⚡ perf(playback): a seek opens the sound on the feeder, not on the hand that seeked The picture's open moved onto its worker last week; the sound's stayed on the caller. `AudioSession::open_mixed_streams_live` opens every track a segment names -- one `pread` per track, seconds off a cold cache on a 25 GB film -- and `PlaybackSession::seek` ran it on whoever called it, which in the editor is the thread that paints. Measured at the seat, cold: one ruler click froze the window 13.5 s, a 300-step scrub burst froze it 22 s. The line written for exactly that wait (`seek_line`, "the window is not frozen") was unreachable, because the thread that would have painted it was inside the open. `Audio::spawn_feeder_deferred` gives the feeder the open as well as the drain, mirroring `DecodeSession::open_worker_deferred`: the caller pays a thread spawn (2.09 ms cold on the film, was 9.27 s) and the sound arrives when it arrives. The epoch is captured at the seek rather than when the open returns, so a scrub that abandons twenty opens leaves twenty *stale* feeders, every one of them refused at the same lock the flush is taken under. The clock is untouched by the wait, which is what makes the wait safe: it holds where the seek put it until the first real sample is queued (`content_at`), so 8.7 s of cold open put the timeline 22 ms past its target rather than 8.7 s past it. `fed` is now re-based at that same first sample instead of at the seek -- the open's seconds are device time nobody fed, and counting them handed the timeline to wall time that far before the sound really ran out. There is no synchronous answer to "will anything play" any more, so `start_audio` returns whether a feeder took the job and the callers hand the clock to audio on it; a timeline with nothing to play ends its feeder at once, and `fed_all` hands the clock straight back, continuously. Whether there is a *mixer* to talk to is decided from the lists the open is about to be handed (`AudioSession::is_mixed`, the one definition, shared with the opener) rather than read off the handle afterwards -- a fader on the single-lane flat path still rebuilds the stream. Cold, playing, the device now runs through the open with an empty ring: audibly the same silence, counted as 1721 underruns where it was 5. Named at `resume` with its upgrade path. A warm session is unchanged (46 -> 53 across the suite).
🐛 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
⚡ perf(launch): the window is up before the film is read, and says which filmAhmet Kaan Gümüş · 544d97b
⚡ perf(launch): the window is up before the film is read, and says which film `edith <25 GB film>` on a cold cache showed nothing at all for twelve seconds: the window was only created after argv[1] had been opened, and a window that does not exist cannot say what it is waiting for. argv is now sorted, not read: every file it names -- the first one included -- goes into the queue a drop uses, and the window comes up empty in 47 ms with the file's name in the title and an OPENING line under the panel naming the read that is running. The first file is the one queued file that is not an import, so its worker *opens* it outright and hands the session over whole (`open_ahead` -> `Landed::Media`/`Project` -> `install_media`/ `install_project`), which is also what keeps a warm launch paying for one header walk instead of two. Everything derived from the file -- canvas, fps, title, export and save paths, subtitle tracks -- is set where it always was, one repaint later; a refused file now says OPEN FAILED in the notice bar instead of exiting before the window. Measured (harness, timestamped sway-IPC + app log): cold 29.6 GB remux, exec -> window 12.95 s / 18.73 s -> 0.047 s, exec -> timeline unchanged (12.9 s -> 12.8 s); warm 2.9 GB film, window 0.73 s -> 0.048 s, timeline 0.68 s -> 0.71 s. The window resizes and repaints throughout the read.
⚡ perf(subtitle): a project naming many tracks of one file walks it onceAhmet Kaan Gümüş · 95fb78d
⚡ perf(subtitle): a project naming many tracks of one file walks it once A saved subtitle row was read by walking its whole Matroska file and keeping one track of it, so a film whose project names thirty-five of them was thirty-five walks of a 25 GB file -- 7.5 s with the window stopped, since a project opens on the UI thread. open_all reads every saved row at once: one walk per distinct file, every row picked out of it, and the rows handed back in the order they were saved in -- a subtitle is picked by its place in that list, so a reordering would silently repoint what the user had picked. open now delegates to it, which keeps the refusal wording in one place.
🩹 fix(test): the subtitle round-trip reads the version the writer writesAhmet Kaan Gümüş · c109992
🩹 fix(test): the subtitle round-trip reads the version the writer writes The tone-map preset bumped .edith to v11; this assertion still named v10 and went red on main.
Merge branch 'worktree-agent-ad755bbe2a8af9c0c'Ahmet Kaan Gümüş · 610e3b6
Merge branch 'worktree-agent-ad755bbe2a8af9c0c' # Conflicts: # crates/app/src/main.rs
⚡ perf(silence): the card is up on the next frame and reads the film behind itAhmet Kaan Gümüş · a2e4154
⚡ perf(silence): the card is up on the next frame and reads the film behind it Pressing Silence decoded the whole audio track on the render thread -- 51 s of dead window on a 25 GB film, with the card marked open and nothing drawn. The decode is a worker now: the card paints at once and says where the read has got to, out of what the header claims the track is, with the import line's two clocks and its stall wording when the mark stops moving. Closing the card, or opening it on another source, cancels the read at its next chunk; a cancelled scan is never cached, since half a track is not an answer. The levels cache is keyed per source and stream instead of holding the last one only, so two films on a timeline stop paying each other's decode -- A, B, A again is one decode of A. What a scan finds is unchanged: 1393 silences at the shipped defaults on the same film, and the nudges after it lands are the arithmetic they always were.
Merge remote-tracking branch 'origin/main' into worktree-agent-abbe2993ca29e3482Ahmet Kaan Gümüş · 1609d29Browse files
⚡ perf(playback): a seek costs the UI thread a thread spawn, not a demuxAhmet Kaan Gümüş · 74a068e
⚡ perf(playback): a seek costs the UI thread a thread spawn, not a demux Playback opened every span's file on the caller's thread: 300 ms warm on a 25 GB film (measured), seconds off a cold cache, and a scrub paid it per seek. `DecodeSession::open_worker_deferred` moves the demux onto the worker -- there is no metadata to hand back on that path anyway, `start_span` discarded it -- so the caller pays a `thread::spawn` and the picture arrives when it arrives, which is what `try_frame`'s `None` has always meant. The four callers that need the refusal at the door (the public `open`, a session open, a project load, an import) keep the sync opener, so a file this machine cannot decode is still named to the user where it is chosen. A file that fails to open *at a span* drops its sender, and the disconnected receiver walks the session on to the next span exactly as the dead receiver installed here did. Both openers now share one worker body (`decode_span`), so hardware fallback, the codec refusal, the tone map's declared peak and the range clamp cannot drift apart between them. Measured on the film: seek returns in 52-68 us (was ~300 ms), first frame 380-620 ms later. The remaining wait is the container walk on the worker; a per-source parsed-index cache is the follow-up, not this diff.
⚡ perf(color): a slider drag pays for the frames it shows, not for every step it crossesAhmet Kaan Gümüş · e4b04bf
⚡ perf(color): a slider drag pays for the frames it shows, not for every step it crosses Colour and speed drags wrote a live grade per snapped step, and each write reopens the decoder: on a big film that is 550-750 ms a step, so a bar-wide sweep froze the window for the sum of forty of them. Samples crossed while the worker still owes a frame are now held instead of written, and the frame that lands writes the last one -- the gate is delivered work, never a timer. The press still takes the undo step and the release still lands exactly where the hand let go. A seek that stands past two seconds says so in the import bar's words rather than looking like a hang.
🐛 fix(project): the undo stack stops at 100 steps and an export clones the timeline, not the sessionAhmet Kaan Gümüş · 2504de7
🐛 fix(project): the undo stack stops at 100 steps and an export clones the timeline, not the session snapshot() drops the oldest step at the cap: one gesture is one step, so 100 is past any chain walked back by hand, and a 1394-clip jumpcut timeline's history is a bounded ~10 MB instead of one that grows for as long as the session lasts. export_to_with hands export::start a Project::export_snapshot() -- lanes and sources with the history left behind. The clone is taken on the UI thread and an export never walks the history back; the written bytes are unchanged.
✨ feat(import): a 25 GB film reads on a worker, and the window says so while it doesAhmet Kaan Gümüş · a2d201d
✨ feat(import): a 25 GB film reads on a worker, and the window says so while it does The freeze was one call: `Demuxer::open` on a cold 29 GB remux is 11 s (measured), and it ran on the UI thread at every import door. Nothing else came close -- the subtitle walk is 200 ms, and the two reads that really are slow (probe_streams 3 s, waveform 55 s) were already off the render thread. So a queued worker reads what the import is about to read and throws it away: the second read costs 150 ms because the pages are warm. The timeline keeps playing through the eleven seconds, and a line above the panel names the file, the stage and an elapsed clock -- and, past five seconds in one stage, says outright that the wait is the file's and not the window's. No percentage anywhere: neither read reports where in the file it has come to, and a bar that invented one would be the lie the freeze already tells. The rest of argv goes through the same door now. Three films on the command line used to be half a minute of no window at all, and a window that has not opened cannot say why.
🐛 fix(zoom): the far stop is the timeline's own length, so a five hour edit has an endAhmet Kaan Gümüş · 69ff17e
🐛 fix(zoom): the far stop is the timeline's own length, so a five hour edit has an end Two 2:30:00 clips are five hours of timeline and the stop was four, so the end of the second one could not be brought on screen by any zoom. The far stop is the whole timeline on the bed plus a sliver now, and short of a pixel to the second (PPS_MIN) the length is not worth widening to -- so a short import still zooms out and the resting scale is still nobody's content. The zoom pill counts hours once there are hours to count.
✨ 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(tonemap): the HDR rendition is a row you pick, not a constant someone chose for youAhmet Kaan Gümüş · 09671f7
✨ feat(tonemap): the HDR rendition is a row you pick, not a constant someone chose for you BT.2446 Method A's assumed mastering peak was a constant in the module: 400 cd/m^2, one exposure decided for everybody. It is a matter of taste, not of correctness -- a reference rendition and a vivid one are both honest pictures of the same film -- so it becomes a project setting with three renditions through the very same curve, which is what keeps the hues right whichever is picked: Reference 1000 nits, chroma 1.0 the published conversion (diffuse white 166) Standard 400 nits, chroma 1.0 display-referred, as bright as a player Vivid 250 nits, chroma 1.10 brightest, and a tenth more colour The chroma gain is a scale about 128 in the SDR codes, after the map and clamped to the legal range: a grey stays exactly grey at any gain, and at 1.0 it is a clamp the maths cannot reach, so the other two presets are byte for byte what Method A produced. HLG's OOTF gain is guarded at black -- below a 1000 cd/m^2 peak the system gamma is under 1, and the 0 * inf that follows byte-cast to 0 and put a hole where black belongs. The preset lives on the Project beside the limiter (a setting, not an undo step), reaches the decode workers and the export through the same value, and is saved as a `tonemap` line in edith 11 -- left out when it is the default, so a project holding no HDR media is the bytes it was, and a v10 file loads as the reference rendition, which is the only one it ever had. Picking one rebuilds the picture under the playhead the way a resize does; an SDR project is unmoved. The panel names it beside the resolution and the rate -- the third thing that is the project's rather than the media's -- and a click opens the three renditions with the one in force marked. No stroke: this is a list to look at.
Merge branch 'worktree-agent-a292c399d416157b0'Ahmet Kaan Gümüş · 7744ff1
Merge branch 'worktree-agent-a292c399d416157b0' # Conflicts: # crates/engine/src/export.rs
✨ 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(export): an HDR source is tone-mapped into the file's SDR, once, before the gradeAhmet Kaan Gümüş · f390c37
✨ feat(export): an HDR source is tone-mapped into the file's SDR, once, before the grade The export path read a PQ or HLG source's tags, wrote an SDR file and left the pixels on their HDR curve: a washed-out, flat picture in a file that says BT.709. `engine::tonemap` existed and nothing called it. One `ToneMapper` per source stream -- the 9 537-node table is built beside the per-source rate and colour, not per span -- and one call per frame, into the grade scratch the path already owns, ahead of `apply_yuv`. That order is playback's: the grade is a decision made against the SDR picture on the canvas, so applying it to HDR codes would export a picture nobody saw. The matrix remap that used to be the whole of the answer now asks `remap_into`, which knows the tone map hands back BT.709 whatever the source was coded as: an HDR clip is never *also* given the 2020 matrix treatment, and one on a canvas below 720 lines still takes its 709 -> 601 step. An SDR project is byte-identical: no table is built, no branch is taken.
🐛 fix(color): the bitstream says which matrix it is, and a grade happens where the preview grades itAhmet Kaan Gümüş · 86c11d8
🐛 fix(color): the bitstream says which matrix it is, and a grade happens where the preview grades it Two faults the container-level tests could not see. An HEVC export carried its colour in the file's tags and nowhere in the stream, and a decoder reads the stream first: libavcodec inferred "unspecified", which is BT.601, and rendered a 709 export from the wrong matrix (9.78 mean codes off the right render against 2.27 off the wrong one). The vendored encoder now writes a §E.2.1 VUI carrying the colour description, from the same `ColorDescription::output` rule the muxers tag with, so the two halves of a file cannot drift apart. rav1e gets the same signalling for the same reason; `rusty_h264` has no VUI knob at all (`vui_parameters_present_flag` is hardcoded 0), and H.264 only ever ships here inside an mp4 whose `colr` box rescues it. ...and an export remapped a clip into the file's space before grading it, while playback grades in the source's own space and converts for the screen -- so a graded 601 clip on a 709 canvas came out 21.04 mean codes away from the picture the canvas had shown. The grade goes first now, which is the order `Decoded::frame` renders in. Measured, on the frame-0 rig: preview vs export 21.04 -> 0.15, and `ffprobe -show_frames` on the raw HEVC and AV1 elementary streams reads bt709 where it read unknown. An ungraded same-space export is byte-identical to before.