forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on cc667e6819d96fdfa32fc2debfcf76352e10da4cFiltered to crates/engine-hw/src/lib.rsClear filter

2026-08-11

✨ feat(av1): 10-bit AV1 opens instead of being refusedAhmet Kaan Gümüş · 25aef8c
✨ feat(av1): 10-bit AV1 opens instead of being refused

The `av1C` record's `high_bitdepth` was an outright refusal ("10-bit AV1 is
not supported yet"), on a comment that had gone stale: the vendored decoder
takes its RT format from the stream and maps Depth10 to YUV420_10, and the
plugin's read-back pool is P010 whenever the demuxer says >8 -- which is how
HEVC Main 10 has been playing all along.

So `parse_av1c` reads the depth instead of refusing it, in both containers
(the mp4 `av1C` box and the Matroska `CodecPrivate`), and 12-bit stays
refused by name in the words HEVC's own depth check uses. Nothing else needs
the plugin any differently: AV1 has no software decoder at any depth, so a
machine without `libengine_hw.so` still refuses it as `needs_plugin` always
has.

Fixture: assets/test_av1_10.mkv (libaom, yuv420p10le), the AV1 seat of the
pair test_hevc.mkv/test_hevc10.mkv already make for HEVC.
✨ feat(caps): the card says what this machine and this build can really doAhmet Kaan Gümüş · 0f37a18
✨ feat(caps): the card says what this machine and this build can really do

The hardware half was never asked for: the plugin decoded what it was
handed and the front-end had nothing to show before a file arrived. Now
an optional `vh_caps` symbol asks the driver -- profiles, entrypoints and
whether a P010 image exists for a 10-bit read-back -- and intersects that
with the codecs the plugin actually implements, so a GPU with an HEVC
encode entrypoint is not reported as an HEVC encoder edith can reach.

Optional exactly as `vh_enc_av1_open` is: a plugin built before this
still loads and still decodes, and the listing degrades to "none" for it,
for a missing plugin and for a machine with no driver alike.

The software half is a table -- what this build was compiled with is a
question the manifest already answered -- and both halves land at the
foot of the export card, where a user asks them.

2026-08-10

✨ feat(import): a Matroska film opens, its 10-bit picture and its 5.1 sound alikeAhmet Kaan Gümüş · b083a3b
✨ feat(import): a Matroska film opens, its 10-bit picture and its 5.1 sound alike

mkv HEVC demux (Main/Main10), a P010 pool in the hardware path read back to
I420, mkv audio through symphonia's Matroska reader with rusty_aac decoding
what symphonia's own AAC refuses (anything wider than stereo), and a BS.775
fold of 5.1 down to the stereo the output device takes.

vendor/rusty_aac is 0.5.0 with one local patch: its decoder's IMDCT caches the
cosine matrix instead of calling cos() per term, 11x faster and the difference
between playable and not.
✨ feat(export): AV1 comes back out, in a Matroska file this editor reopensAhmet Kaan Gümüş · dd3a2a8
✨ feat(export): AV1 comes back out, in a Matroska file this editor reopens

The export card's second picture format. AV1 already *arrives* here as
Matroska (`mp4 0.14` has no `av01` sample entry at all, so `demux` walks
the EBML by hand); it now leaves the same way, through an `MkvMuxer`
written beside the mp4 one -- EBML header, `Info`, one `V_AV1` track whose
`CodecPrivate` is a real `av1C` record built from the first keyframe's
sequence header OBU, then clusters that open on every keyframe. The
segment size and the duration are the only two fields patched at `finish`.
Matroska rather than AV1-in-mp4 because the reader for it already exists:
the round trip closes against this project's own `Demuxer`.

Picture only, and said so on the row before a destination is picked ("AV1
picture in .mkv — no sound: export WAV or FLAC for that"). Matroska
carries no sound this project can *write* -- no AAC or Opus encoder here
-- and an AAC track copied in would be one this engine's own reader leaves
silent (`AudioSession::open` refuses Matroska audio). A silent track
written anyway is the one failure a user would not notice.

The encoder pair mirrors H.264's: `rav1e` in software, the plugin's new
`vh_enc_av1_open` on the GPU. The hardware seat is wired, tested and
**opt-in** (`VE_HW_AV1=1`): the vendored cros-codecs AV1 encoder took the
radeonsi box this was written on into an amdgpu hard recovery, and a
driver reset is not an export. `rav1e` is not a new dependency at all --
`ravif` already locks the same 0.8.1 -- and is built with `asm` off (no
`nasm` in this build) and `threading` on: 39 s for the 5 s 720p fixture,
progress reported the whole way.

HEVC and VP9 are rows too, refused by name: no encoder in this stack and
patent-encumbered, and superseded by the AV1 row above.
✨ 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