forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 0563cbfec08046b75ca933b5b9909fd656d3ea9fFiltered to crates/engine/src/decode.rsClear filter

2026-08-20

🐛 fix(engine): a picture edit reuses the decoder instead of reopening the fileAhmet Kaan Gümüş · 91e6316
🐛 fix(engine): a picture edit reuses the decoder instead of reopening the file

The session's first worker was seeded with the raw caller path while
the project canonicalizes every source, so Worker::reseek's textual
path check failed and every colour or transform nudge paid a full
thread + demux + VA-API reopen (~11s on a big file) instead of a seek.
open_stream canonicalizes once, and the idle teardown stretches 2s→8s
so think-time between nudges keeps the hardware session warm.

2026-08-19

🐛 fix(engine): the deferred-open test stops racing a thread spawnAhmet Kaan Gümüş · 77c6364
🐛 fix(engine): the deferred-open test stops racing a thread spawn

Under a loaded machine the spawn a deferred open pays can cost more
wall clock than a sync demux of a small fixture; the remaining two
asserts pin the deferral invariant without the race. Flaked 1-in-3
during parallel builds.
🐛 fix(engine): the late-drop escape valve survives the speed skipAhmet Kaan Gümüş · 43ff2f2
🐛 fix(engine): the late-drop escape valve survives the speed skip

run() and run_hw() checked abort.late(due) && skipped < LATE_RUN as one
condition, so once LATE_RUN pictures in a row had been dropped for
lateness, the branch fell through to skip_for_speed -- and if that also
said skip (which it does on every other frame at >1x), the escape valve
that is supposed to guarantee one picture in LATE_RUN reaches the screen
never fired. A machine falling behind at speed could go fully silent.

Reordered so lateness is decided first and completely: still-within-run
skips for being late, past-run sends unconditionally (skipped=0), and
skip_for_speed only gets a say once lateness has already said "send".

Measured with a throwaway probe (deleted) against two real files, SW
decode (this box has no HW decode path), 15s per run, same machine
before/after:

  a large 4K H.264 mp4 (the falling-behind, worst-case class the
  escape valve exists for):
    1.0x  219->322 shown,  5->2 resyncs,  p99  1131.8ms->75.8ms
    1.5x  173->165 shown,  7->7 resyncs,  p99  1049.6ms->1113.4ms (noise)
    2.0x  134->141 shown,  7->7 resyncs,  p99  1055.7ms->970.6ms

  a small screen-recording mp4 (keeps up, never hits abort.late): 0
  resyncs before and after at all three speeds, numbers unchanged --
  the reorder does not touch a file that was never late.

Net: better or a wash everywhere measured, no regression on the class
the bug actually bites.

Adds a deterministic unit test for skip_for_speed's alternation at 2x
and its never-skip guarantee on a span's last frame.

2026-08-13

🐛 fix(decode): the queue a file opens with, and the driver a parked worker holdsAhmet Kaan Gümüş · 7985bd5
🐛 fix(decode): the queue a file opens with, and the driver a parked worker holds

Five findings from the lane's verification, in the order they bite.

DEPTH NEVER ENGAGED ON THE PRIMARY PATH. Every session opens its first
worker pass-through -- a freshly opened file *is* the project resolution
-- and a pass-through canvas cannot say how big the pictures will be, so
it answered 2: the bound this engine had before there was any
decode-ahead. A whole file played at that depth until the first seek
built a real canvas. The depth now comes from the stream the sync opener
already read (`scale::queue_depth`), and a paused burst off a freshly
opened 720p file is 17 pictures where it was 3.

A PARKED WORKER NO LONGER HOLDS THE DRIVER. The thread that outlives its
span used to park on its command channel with the VA-API session open,
which widened the Mesa `atexit` window from "quit during a decode" to
"quit any time after opening a file". The wait is in two halves now: the
fast one keeps everything, so a seek, a scrub step and a clip boundary
still find the decoder where they left it, and past two seconds idle the
hardware session is closed. The demuxer stays -- it is a file handle and
an index, not driver state, and it is what costs seconds to rebuild.

DENSITY IS BOUNDED AGAIN. The suite's pump had been weakened to "indices
increase", which a one-in-N delivery regression passes. It asserts
contiguity again -- every session there is a pull consumer, owed every
frame -- and a new test holds a *watched* session to the same contiguity
plus a density floor whenever the decoder is measurably keeping up.

The queue-depth doc now states the measured numbers (16 at 720p, 12 at
1080p, 3 at 3840x2160, 2 at 4096x2160; a burst is depth + 1), and two
comments that still said "cancelled" for what a seek now abandons, and
claimed the drop replaced the front-end's resync, are corrected: both
mechanisms are live and the drop is the first line.
⚡ perf(decode): the queue runs deeper and stops carrying pictures nobody can seeAhmet Kaan Gümüş · fffcda0
⚡ perf(decode): the queue runs deeper and stops carrying pictures nobody can see

Two frames of decode-ahead was the whole buffer, so any hiccup emptied it
and the decoder could never build a lead. The bound is now a budget in
bytes (~96 MB: eleven 1080p pictures, two 4K ones), which is what makes
the second half safe: a deeper queue full of stale pictures would be
worse than a shallow one, so the worker is told where the playhead
stands and stops paying the conversion and the queue slot for anything
already behind it.

The policy has a floor of its own. A machine that cannot decode in real
time is late on every picture, and dropping every picture is a black
screen rather than a stutter, so one in nine is handed over regardless --
roughly what the front-end's restart-every-two-seconds produced, without
the VA-API init each restart cost.

Off unless a caller says it is watching in real time: an export, the
file-level API and a test draining as fast as it can each asked for a
range of frames and are owed every one of them. The window turns it on,
where `Player::pump` was already taking those pictures off the channel
and throwing them away one repaint later.

The playback suite's own pump asserted contiguous indices; it now asserts
increasing ones, which is the invariant that survives a drop -- nothing
out of order, nothing twice.
⚡ perf(decode): the worker that decoded a span stays for the next oneAhmet Kaan Gümüş · bbdd4d6
⚡ perf(decode): the worker that decoded a span stays for the next one

A seek used to cost a thread, a container parse and a VA-API
initialisation (98 ms measured worst case) before it could decode a
single picture, because every span opened a decoder of its own and threw
it away again. The worker now outlives its span: it parks on a command
channel, and a seek onto the file it already has open reaches it through
Worker::reseek -- a demuxer seek and a decoder flush, 1-4 ms measured
against a 28-37 ms open of the same file warm.

The plugin learns the same trick from the other side: vh_seek
repositions an open session exactly as vh_open_at positions a new one,
and it is an optional symbol, so a plugin built before it still decodes
and its caller simply opens a session per seek as it always did.

Cancelling and abandoning become two different things: a seek abandons
the span (the thread, the file and the decoder stay), a replacement
cancels the worker (the thread ends, and the command channel goes with
it, so nothing parks in recv past the session that owns it and no VA-API
session meets Mesa's atexit).
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.
🐛 fix(decode): a seek into an open GOP is hardware's to finishAhmet Kaan Gümüş · 7652ada
🐛 fix(decode): a seek into an open GOP is hardware's to finish

A Blu-ray remux codes its GOPs open: the I picture that opens one is stored
ahead of the leading pictures that are *shown* before it, and those reference
the GOP before. Restart decoding at that random access point -- which is what
every seek, scrub and clip boundary does -- and the leading pictures have
references nobody decoded, so the plugin failed its first frame, playback fell
back to `rusty_h264`, and that decoder died on the file's I_PCM macroblocks.
Seventeen of twenty scrub steps on a 5.27 GB AVC remux ended with no picture
at all, and the three that survived cost 482 ms each in software.

The pictures are not ours to show, so they are dropped and the decode walks on
(bounded by `LEADING_LIMIT`, and only for a session that was positioned
somewhere other than the file's own start). The refusal that the tolerance
would otherwise swallow is kept at both ends: a stream read from frame 0 is
still refused the moment its first picture will not decode, and the plugin
probe now counts an immediate end of stream as a refusal rather than a pass --
a session that hands back no picture is the black-frame-and-instant-eof the
probe exists to catch.

The vendored H.264 decoder's own refusal goes with it: it failed a `frame_num`
gap outright unless the stream declared gaps allowed, which is exactly the
wrong reading here -- the gap is the editor's, made by starting in the middle
of a film, and §8.2.5.2's non-existing frames are what stands in for it. The
loop that builds them was already there, behind that flag.

Twenty of twenty scrub steps on the remux now decode in hardware, 77 ms
median against 482 ms; `seek_matches_linear_every_container` holds for every
container, and `dump_frame <file> <n> <out> seek` is what a picture reached by
a seek can be compared with the same picture reached by decoding from the
start.

2026-08-12

🐛 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(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.
✨ 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(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.
✨ feat(color): an HDR film reaches the window tone-mapped, and an SDR one is untouchedAhmet Kaan Gümüş · f8dea1c
✨ feat(color): an HDR film reaches the window tone-mapped, and an SDR one is untouched

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

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

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

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

Every displayed frame went through one hardcoded integer matrix -- BT.601
limited, 298/409/-100/-208/516 -- whatever the stream said it was. An HD or
UHD file read that way shifts: BT.709's red weight is 0.2126 against 0.601's
0.299, which is a visible cast on faces and saturated colour.

The two converters now take the `ColorDescription` the demuxers already
resolved, and derive their 8.8 coefficients from that matrix's two luma
weights and its range once per frame, so the pixel loop is the same
multiply-and-shift it was. BT.601 limited rounds to exactly the integers that
were hardcoded, so SD material is byte for byte the picture it always was.

Stills keep BT.601 on purpose: `rgb_to_i420` writes them in it, and the pair
round-trips. Transfer curves are untouched -- a PQ or HLG stream gets the
BT.2020 matrix and is still shown as SDR, with the seam marked.
✨ feat(engine): an edit rebuilds what it dirtied, and nothing elseAhmet Kaan Gümüş · c2e62a3
✨ feat(engine): an edit rebuilds what it dirtied, and nothing else

Every param change went through one funnel -- edit() -> seek() -- which
flushed the audio ring, reopened every track, respawned the feeder and
rebuilt the video decoder. Dragging a colour slider therefore cut the
sound ~40 times across one gesture, and every restart re-anchored the
clock onto an empty ring, so the silence of the restart was counted as
timeline time: a permanent A/V offset, re-rolled by every edit made
while playing (the resolution-change desync).

Edits are classified by what they dirty now. A grade, a fit policy and
the project resolution rebuild the picture where it stands and never
touch a sample. An equalizer rebuilds the sound and never touches the
picture. A fader and the master ceiling rebuild nothing at all: they
live at the mix sum, so the running mixer picks them up between two
blocks (MixControls), and the limiter is retuned rather than restarted
so its delay line -- and the sample count the master clock is made of --
keeps running. Only a structural edit still reseeks both halves.

And a restart no longer costs an offset: the feeder stamps the device
position its first real sample was queued at, and the clock anchors
there instead of on the first poll after the seek, so the silence before
the content is never timeline time.

Also: a span whose source will not open no longer presents the old
channel's frames under the new mapping, and the feeder stops parking
10 ms on a ring that is merely waiting out a flush.
✨ feat(backends): the decoder and the encoder say which one is runningAhmet Kaan Gümüş · bdcc2fb
✨ feat(backends): the decoder and the encoder say which one is running

A source names its decoder in the library row before anything plays, the
transport line names the running one while it does, and the export card
names the encoders it would open before the button — the progress line
naming the ones it did.

Every answer is measured, never promised: `decode::probe` picks a seat by
the very rules `open_worker` picks one, the worker publishes what it
actually opened (so a hardware session that falls back to software says
so), and `export::planned_video` opens the very VA-API encoder the export
would and closes it again. `hw_seat` is now the single place that choice
is made, so a card and a running job cannot drift apart.

2026-08-10

🐛 fix(timeline): a pasted still never lands on the audio laneAhmet Kaan Gümüş · b586b85
🐛 fix(timeline): a pasted still never lands on the audio lane

`Project::paste` routed by `is_audio` alone, so a *copied* still clip --
the one door that does not go through `place_stream_at` -- was pasted as
a grouped take across `V1` and `A1`. The A1 half is a PNG the audio
worker demuxes: "file contains a box with a larger size than it", which
silences the whole session rather than that clip, and the save it writes
is one `open_project` then refuses by name. An `is_image` arm mirrors the
audio-only one.

Same-shape sweep of every clip-level door that routes by source kind:
- `Project::paste` (project.rs) -- this defect, fixed.
- `PlaybackSession::place_stream_at` -- already routed, image arm returns
  on the video lane before the audio fork.
- `PlaybackSession::open`/`open_project` -- both directions refused by
  name at load.
- `Project::move_to_lane` -- refuses a move across kinds, so no clip can
  cross by drag. Clean.
- `Project::place`, `split`, `regroup`, `lift`, `delete_in`, `trim` --
  the caller names the lane or the lane never changes. Clean, and the
  loader is the backstop for a hand-written file either way.
- `Player::insert_source` (app) -- guarded both ways already.

Falsification: with the `(_, true) => &[LaneKind::Video]` arm removed the
new test fails at the lane count (A1 1 -> 2), and with that assertion
lifted it fails on the WAV export with the demux error above -- the two
consequences the test names, both reachable.

Two doc corrections found with it: `Still::open` now says alpha is
dropped by `to_rgb8` (a transparent PNG lands opaque, with the blend as
the ponytail), and `first_audio_of` no longer implies an image-first
timeline accepts a later audio import -- it widens which source is
asked, not what "the timeline is silent" means.

tests: images 7/7 (new `pasting_a_copied_still_never_reaches_the_audio_lane`
asserts no A1 clip, no audio clip from a picture, the WAV export still
carries the sound, and the save reopens), engine lib 155, saveload 12,
audio_files 16, lanes 5 (serial), bin 56.
✨ feat(timeline): still images import and place as clipsAhmet Kaan Gümüş · 30d430d
✨ feat(timeline): still images import and place as clips

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

The decisions, spelled out:

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

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

tests: engine/tests/images.rs -- import registers only, placed pixels
match the file's own (top/bottom bands catch a flip, RGB order catches a
swap), trim walls at the cap, .edith round trip incl. the audio-lane
refusal, mp4 export pixel-checked at the cut, audio-lane placement lands
on V1. Fixture: scripts/gen_fixtures.sh writes assets/test_still.png.
✨ feat(engine): project resolution stands apart from media resolutionAhmet Kaan Gümüş · 19e294a
✨ feat(engine): project resolution stands apart from media resolution

A timeline had one resolution because its first source did: import refused
anything else by name, and there was nowhere to say otherwise. A project now
carries its own picture size and every clip is composed onto it, so media of
different resolutions share a timeline the way they do in any editor.

* scale::Composer is the one definition of that composition -- fit_rect,
  scale_i420, compose_i420 onto a black canvas -- and both playback and export
  call it, so what is written is what was watched. A canvas of the picture's
  own size is a pass-through that allocates nothing and touches no byte.
* Grade first, place second: a grade belongs to the clip's pixels at the
  resolution they were shot at, and the letterbox bars are not the clip.
* Per-clip fit policy (fit/fill/stretch/centre), one byte inline in Clip -- it
  lands in padding the clip already had.
* .edith v7: a `resolution <w> <h>` line and a fit word per clip line. v6..v1
  still load, defaulting to source 0's picture and Fit, which is what those
  projects always meant.
* The fps refusal stays: mixing frame rates is resampling the timeline, a
  different problem, and a refusal is the honest answer until it is solved.
* UI: `p` cycles the fit policy of the clip on screen (and a clip-menu item),
  ctrl+r cycles the project resolution through the usual sizes with the media's
  own among them, and the export card says which size it writes.
✨ feat(video): per-clip color grade is live in render and exportAhmet Kaan Gümüş · bd89527
✨ feat(video): per-clip color grade is live in render and export

The grade a clip carries now reaches the picture. `Project::composite_clip_at`
names the clip the composite shows at a frame and `composite_color_at` its
grade, so playback's decode worker (folded into `i420_to_bgra_with`, free in
the loop that was reading those samples anyway) and the export's encoder (onto
per-span scratch, since the planes are borrowed) grade from one answer.

`PlaybackSession::set_color` is an edit like any other, so it reseeks -- which
is what repaints the frame already on screen, paused or playing.

The card: `k` (or the clip menu's Colour…) opens four sliders on the selected
video clip, or on the clip under the playhead when nothing is selected, so it
is reachable with no pointer at all. Arrows pick and move a slider, r resets,
esc closes; a slider walked back to the middle takes the grade off, which keeps
an ungraded project byte-identical -- verified: the same two-clip export before
and after this slice is md5 98522c19cefac2f7851b51de6416a493 both times.
✨ 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.
🐛 fix(engine): a refused project load cannot hang on its own decoderAhmet Kaan Gümüş · 771cd4a
🐛 fix(engine): a refused project load cannot hang on its own decoder

`open_project` starts decoding source 0 before it validates anything, so
by the time a later source is refused that worker has filled the
two-frame channel and parked in `send`. The receiver and the worker were
two locals, and locals drop in reverse order of declaration: the worker
joined a decode thread that only the receiver beside it could ever wake.
The app froze on a bad project file instead of showing the error.

The two are one value now. `FrameStream` holds the receiver first and
the worker second, and Rust drops fields in declaration order, so the
disconnect always precedes the join -- in an early return, on an unwind,
and in call sites not written yet. Nothing on the seek path changes:
`start_span` still installs the new receiver and parks the old worker in
the retire list without ever joining.

The device moves below the validation for the same reason. Its feeder
thread outlives the `Audio` value and only a session's `drop` retires
it, so a refusal above that line left a PipeWire stream and a thread
behind for a project that never opened.

Tests: dropping a stream whose frames nobody took returns instead of
hanging (10 s bound; hangs if the two fields are swapped), and the
refusal path itself with enough sources that the park is certain -- 60 s
hang before the fix, 0.04 s after.
✨ feat(engine): video+audio lanes with offset-placed clips, gaps, .edith v2Ahmet Kaan Gümüş · 59eb78e
✨ feat(engine): video+audio lanes with offset-placed clips, gaps, .edith v2

Project gains two lanes; a Clip now carries `start` (its timeline
placement) and `link` (group id), so a gap is simply the absence of a
placement rather than an object anyone has to keep in sync. Moves and
trims become arithmetic on start/in_frame; the lane invariant (sorted,
non-overlapping) is checked in from_parts, at the .edith parser, and
asserted after every mutation.

split cuts every lane and hands the two sides fresh group ids; regroup
is its exact inverse. delete still ripples both lanes (the app keeps its
behaviour), lift removes one placement and leaves a hole, place is the
per-lane overwrite that can make one.

A video gap plays as black frames from a worker that opens no file --
same channel, backpressure, cancel and retire path as a decoder -- and
exports as encoded black. An audio gap is synthesised zero chunks, real
ones, so the master clock keeps counting through it; on the export side
it is spent as stts duration on the packet beside it, since there is no
AAC encoder to make silence with.

.edith v2 writes one line per placement per lane; v1 files still load,
as fully-grouped gapless lanes, and save as v2.

2026-08-09

⚡ perf(playback): retire cancelled workers off the seek pathAhmet Kaan Gümüş · 3adbaf7
⚡ perf(playback): retire cancelled workers off the seek path

Joining the outgoing decode worker inline made a seek pay whatever VA-API
init that worker was still inside -- 98.4 ms worst case against 1.6 ms
before the join landed, i.e. a scrub capped at ~10 seeks/s with a visible
hitch per step.

Cancelled workers now go into a retire list instead. Every seek sweeps it,
dropping only the ones whose thread has already returned (`is_finished`,
never a wait), and the session's drop joins whatever is left along with the
running worker -- so the exit guarantee is untouched: no decode worker
outlives its session, and none can be inside libva when Mesa's atexit
handlers run.

Worst seek back to 4.7-6.1 ms over three drill runs. Open+drop stays at
~13.5 ms, which is the same join as before and a session drops rarely.
Retire list peaked at 16 under a back-to-back 20-seek loop -- a UI scrub
leaves far more time between steps.
🐛 fix(decode): join workers on drop — Mesa atexit race killed exiting processesAhmet Kaan Gümüş · 9276137
🐛 fix(decode): join workers on drop — Mesa atexit race killed exiting processes

A decode worker was spawned detached and nothing ever waited for it, so a
process could exit while a worker sat inside `vaInitialize`. Mesa frees its
process name from an `atexit` handler and the worker then reads it back
NULL: SIGSEGV at exit, 9 runs in 20 of the saveload suite.

`DecodeSession::open_worker` now hands the caller a `Worker` that owns the
`JoinHandle`; dropping or replacing one cancels and joins. `PlaybackSession`
holds one, so a seek, a clip boundary and the session's own drop all wait
for the worker they abandon. The worker also checks the cancel flag before
and after opening the hardware session, so a cancelled one never enters
VA-API init at all. Public `open`/`open_at`/`open_range` are unchanged.
✨ feat(engine): clips primitives — edit-list model, bounded decode, segmented audioAhmet Kaan Gümüş · e75a7ba
✨ feat(engine): clips primitives — edit-list model, bounded decode, segmented audio

Lane 1 of the clips slice; PlaybackSession traversal comes next.

- project.rs: Clip/Project — cut (metadata-only, refuses no-op
  splits), delete (closes gap, keeps ≥1 clip), undo snapshots,
  timeline↔source mapping with boundary sweep tests
- decode: open_range(start, end) — both backends stop after end-1,
  empty/inverted ranges disconnect cleanly without spawning a worker
- audio: open_segments — one worker walks the edit list; segments
  bit-exact vs equivalent seeks, joins gapless by contiguity assert,
  head+tail trim inside a single AAC packet handled
✨ 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