Commits
Commits on
2b647ea0d8fa918193ee7424f4a366dffabf4b02Filtered to crates/engine/src/decode.rsClear filter2026-08-11
✨ 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