Expand description
Thin VA-API H.264 encoder built on the vendored libva binding.
Reuses the backend-agnostic bitstream layer (crate::codec::h264) from
discord/cros-codecs (BSD-3-Clause) for SPS/PPS/slice synthesis, and drives
libva directly for surface upload + slice submission, rather than vendoring
cros-codecs’s generic multi-backend encoder framework. The per-frame VA
buffer population is ported from cros-codecs’s encoder/stateless/h264/vaapi.rs.
Low-latency only: IPPP (no B-frames), one reference frame, matching the VideoToolbox / Media Foundation / NVENC backends in moq-video.
Three ways in, cheapest first:
Encoder::encode_dmabufwith an NV12 DMA-BUF at the encoder’s size encodes the producer’s memory in place.Encoder::encode_dmabufwith any other importable DMA-BUF (packed RGB from a screen capture, YUYV from a camera, NV12 at another size) converts and scales it into the encoder’s own surface with the video processor, on the GPU.Encoder::encode_nv12uploads CPU pixels.
Checked on Intel Meteor Lake with the iHD driver by decoding with ffmpeg’s software decoder: CPU and DMA-BUF input come back above 35 dB luma PSNR, and BGRX converts to BT.601 and BT.709 with every channel within 6 code values of the reference. The low-power entrypoint is untested, since that device exposes the full one.
Structs§
- Config
- H.264 encoder configuration. Dimensions must be even (4:2:0 chroma).
- Encoder
- A VA-API H.264 encoder. Built once, fed NV12 frames, emits Annex-B H.264.
Enums§
- IsReference
- Whether a frame is used as a reference, and for how long. (Vendored from discord/cros-codecs, BSD-3-Clause; used by the slice synthesizer.)
Constants§
- RATE_
CONTROL_ WINDOW_ MS - Window over which libva’s rate controller targets the configured bitrate.
Functions§
- probe
- Checks that
display’s driver can encode H.264, which is whatEncoder::newneeds of a render node.