forge
Explore
Log in

Don't you dare go Hollow

Commits

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

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