Commits
Commits on
8c7bf808ae19e1655737ac07a94de22b5002565fFiltered to crates/engine-hw/src/lib.rsClear filter2026-08-10
✨ feat(engine): AV1 import via the VA-API pluginAhmet Kaan Gümüş · 6d3e3ba
✨ feat(engine): AV1 import via the VA-API plugin
AV1 arrives in Matroska, never in an mp4 -- `mp4 0.14` knows no `av01`
sample entry at all -- so the demuxer grows a second container:
`MkvDemuxer` walks the EBML itself, indexes every block of the AV1 track
in one header-only pass (payloads are seeked over) and hands each block
to the decoder as the temporal unit it is, with the `av1C` sequence
header re-injected ahead of every keyframe the way the H.264 parameter
sets are.
Matroska indexes neither the frame count nor the frame rate, which is why
that walk exists: the count is the blocks of the track and the rate is
`DefaultDuration` in nanoseconds (33333333 = 30 fps to seven digits,
where the millisecond block timestamps beside it would say 30.30).
Keyframe flags come out of the same pass, so a seek lands on a sync point
without a Cues element and without guessing at the bitstream.
Audio is picture-only for now: a Matroska file is a silent source and
says so by name ("A_AAC audio in a Matroska file is not wired to the
decoder yet") rather than failing in the mp4 reader's words. 10- and
12-bit AV1 are refused at open like HEVC Main 10, for the same 8-bit
read-back reason.
No new dependency: symphonia's mkv reader drops the keyframe flag and
`DefaultDuration` and offers no frame count, so it could not have done
the job. edith keeps its 7 DT_NEEDED entries.✨ feat(engine): HEVC import via the VA-API pluginAhmet Kaan Gümüş · 85c152d
✨ feat(engine): HEVC import via the VA-API plugin The demuxer takes a hev1 track alongside avc1 and vp09. Its parameter sets are read out of the file by hand: mp4 0.14 reads one byte of hvcC and skips the rest, so the VPS, SPS and PPS an HEVC decoder cannot start without are unreachable through the crate. A small ISO-BMFF walk finds the track's hvcC and the record gives both the parameter sets and the NAL length prefix width -- the avcC one is now read the same way instead of assumed to be four bytes, which is one hardcoded guess less on the H.264 path too. Samples are repacked to Annex-B exactly as H.264's are, parameter sets ahead of every sync sample, because a hardware decoder that joins the stream at a seek has nothing else to configure itself from. Main 10 is refused at open by name: the plugin's NV12 pool and its vaGetImage read-back are 8-bit, and a 10-bit stream decoded into them would be garbage shown as a picture rather than an honest no. Same reasoning as the software refusal, which is now one message shared by every codec that has no software decoder at all. The C ABI is unchanged again: the plugin demuxes the file it is given, so an older libengine_hw.so still loads, still decodes H.264, and simply returns null for an HEVC path.
✨ feat(engine): VP9 import via the VA-API pluginAhmet Kaan Gümüş · 03a34d3
✨ feat(engine): VP9 import via the VA-API plugin The demuxer takes a vp09 track alongside avc1 and hands its samples through untouched -- an mp4 VP9 sample is a self-contained superframe, so there is no avcC repack and no parameter sets to re-inject. VideoMeta carries the codec, and the plugin picks its cros-codecs decoder from it. The C ABI is unchanged on purpose: the plugin demuxes the file it is given, so the codec is a property of the container rather than of the call, and a libengine_hw.so built before this still loads and still decodes H.264 -- it simply returns null for a VP9 path, the same no it gives for an unsupported profile. There is no software VP9 decoder to fall back to, so a VP9 file the plugin will not take is refused at open, by name, where the front-end can show it -- never a black screen, and never VP9 bytes fed to rusty_h264. One timeline stays one codec, and export re-encodes to H.264 as before; only audio is ever copied packet for packet.
🐛 fix(engine): NTSC frame rates survive the sample tableAhmet Kaan Gümüş · 3f81ef8
🐛 fix(engine): NTSC frame rates survive the sample table `mp4 0.14`'s `Mp4Track::frame_rate` divides the sample count by whole milliseconds before the float cast, so 24000/1001 read back as a flat 23.0: the picture the audio-sample master clock asked for was 4 % out and the drift grew with the film — five minutes of it by the end of a two-hour one. The frame rate now comes off the stts totals in f64, which is exactly `timescale / delta` for a constant table and an average for a spread one. The same truncation lived at the writing end (a 90 kHz clock cannot count 23.976 fps in whole ticks), so the muxer picks a timescale that can: 90 kHz wherever it divides exactly — every integer rate, so those exports are byte for byte what they were — and `round(fps * 1001)` over 1001 ticks otherwise, which is exact for the whole NTSC family. The hardware encoder gets that same rational instead of a rounded `fps * 1000`. The video edit list is honoured now too, the way the audio one always was — but only what it really trims: a `media_time` equal to the first `ctts` offset is the B-frame composition delay, not a cut, and reading it as one throws two real frames away. A file whose audio we cannot decode at all (an AC-3 remux) played silent with the reason on stderr; the session carries it now and the window says NO AUDIO in its notice bar.
2026-08-09
✨ feat(engine-hw): vh_enc_* — VA-API H.264 encode with Mesa slice-header fixupAhmet Kaan Gümüş · b75c83e
✨ feat(engine-hw): vh_enc_* — VA-API H.264 encode with Mesa slice-header fixup The plugin grows an encode half beside the decode one: vh_enc_open/vh_enc_frame/vh_enc_drain/vh_enc_close, and engine::hw gains HwEncoder behind a SEPARATE symbol table. That separation is the point -- a libengine_hw.so predating this commit must keep decoding, so the four new symbols must not join the decode Plugin struct where a missing one would take decode down with them. Absent symbols just mean HwEncoder::open returns None and the caller falls back to the rusty_h264 software encoder. Measured on radeonsi (Mesa 26.1.5): 3.98 ms/frame at 1280x720 CBR 4 Mbps including the I420->NV12 upload, against 25.6 ms/frame for rusty_h264 Fast at the same size -- 6.4x. Profile Main, level 4, LowDelay so there are no B-frames and coded order is display order; radeonsi exposes no VAEntrypointEncSliceLP for H.264 so low_power stays off. One reusable DMA-BUF frame carries every picture because BlockingMode::Blocking plus a poll() in each entry point syncs the coded and recon promises before returning. Non-16-aligned sizes allocate aligned surfaces, carry the true size in the SPS crop, and replicate the edge pixel into the padding rather than shipping gbm garbage there. The one ugly part is fix_slice_nal_headers. cros-codecs supplies no VAEncPackedHeaderH264_Slice, and Mesa fills forbidden_zero_bit / nal_ref_idc / nal_unit_type only from a packed slice header, so every slice NAL leaves the encoder with a 0x00 header byte and both ffmpeg and rusty_h264 refuse the stream. Patching that single byte per slice makes both decode it fully. An all-zero header byte is never valid H.264, so the rewrite is a no-op on drivers that write it properly (Intel iHD, which cros-codecs was built against). Marked ponytail; the real fix is a packed slice header in vendor/cros-codecs.
✨ 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