From 6d40ad2ab0595253f08c922407e4b5b598d14c71 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 5 Nov 2026 22:28:53 -0800 Subject: [PATCH 1/6] chore(quest): claim quest/m1/video-vaapi.md Quest-Claim: ed4c876dd66e04ae From 31fbeb3c9bbab4d342f959b47e98158b9df6b1f0 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 6 Nov 2026 01:16:54 -0800 Subject: [PATCH 2/6] feat(moq-video): VAAPI H.265 encode and decode, on by default Wire moq-video's VAAPI backends to the moq-vaapi changes in moq-dev/vaapi#8 through #11: H.265 Main encode and decode beside H.264, Surface::resize through the processor's pooled output surfaces, and checked-in libva bindings. With no bindgen left, `vaapi` is on by default in moq-video, moq-transcode, and moq-cli, and moq-c's Nix build drops its bindgen hook. Needs the moq-vaapi release carrying those PRs; the workspace bump follows it. The quest is rewritten to that remaining work. Co-Authored-By: Claude Opus 5.5 --- Cargo.toml | 4 +- doc/lib/rs/moq-video.md | 8 +- nix/overlay.nix | 5 -- quest/m1/video-vaapi.md | 64 +++++----------- rs/moq-c/Cargo.toml | 4 +- rs/moq-cli/Cargo.toml | 10 +-- rs/moq-ffi/Cargo.toml | 3 +- rs/moq-transcode/Cargo.toml | 18 ++--- rs/moq-video/Cargo.toml | 34 ++++----- rs/moq-video/DESIGN-native-codecs.md | 9 ++- rs/moq-video/README.md | 20 ++--- rs/moq-video/src/decode/backend/mod.rs | 2 +- rs/moq-video/src/decode/backend/vaapi.rs | 95 +++++++++++++++--------- rs/moq-video/src/decode/decoder.rs | 23 ++++++ rs/moq-video/src/encode/backend/mod.rs | 2 +- rs/moq-video/src/encode/backend/vaapi.rs | 79 ++++++++++++++++++-- rs/moq-video/src/frame/vaapi.rs | 31 ++++---- 17 files changed, 240 insertions(+), 171 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 68db74e417a..2efd636e6fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -155,8 +155,8 @@ moq-tokio = { version = "0.19.23", path = "rs/moq-tokio", default-features = fal # Default features off on moq-transcode and moq-video so each workspace consumer # chooses native codecs and rendering explicitly. OpenH264 is opt-in everywhere: # each consumer forwards an `openh264` feature that release builds turn on. -# VAAPI is opt-in everywhere; its decoder is hardware-validated, while its -# encoder is not yet. +# NVIDIA and VAAPI dlopen their drivers and need nothing on the build host, so +# the consumers that build video turn both on. moq-transcode = { version = "0.1.10", path = "rs/moq-transcode", default-features = false } # default-features off (the `quic` backend) so the consumer opts into the QUIC # stack the io_uring path compiles; cargo features are additive, so a default-on diff --git a/doc/lib/rs/moq-video.md b/doc/lib/rs/moq-video.md index 0faed2db33e..a0b04f09e30 100644 --- a/doc/lib/rs/moq-video.md +++ b/doc/lib/rs/moq-video.md @@ -40,10 +40,10 @@ change bitrate live follow the connection's send estimate while someone watches, and return to the configured bitrate while nobody does. Where the platform allows it, frames stay on the GPU between capture, decode, encode, and render. -Opt-in features: `capture`, `vaapi` (Intel and AMD on Linux; the build needs -libclang), `v4l2` (ARM SoC codecs such as a Raspberry Pi's), `pipewire` (Linux -portal capture and PipeWire cameras; links libpipewire), and `vpx` (links -libvpx). +Opt-in features: `capture`, `v4l2` (ARM SoC codecs such as a Raspberry Pi's), +`pipewire` (Linux portal capture and PipeWire cameras; links libpipewire), and +`vpx` (links libvpx). `vaapi` (Intel and AMD on Linux) is on by default beside +`nvidia`, since neither needs anything on the build host. On Wayland, the `pipewire` feature lets Rust callers request a screen or window through the system picker with `capture::Source::Portal`. Keep the diff --git a/nix/overlay.nix b/nix/overlay.nix index a6520c13628..70d94c7d543 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -142,11 +142,6 @@ let cargoExtraArgs = "-p moq-c --features openh264"; nativeBuildInputs = with final; [ pkg-config - # moq-c is the only nix-built package that pulls moq-video, and its `vaapi` - # feature brings moq-vaapi, whose build.rs runs bindgen over its vendored - # libva headers. Sets LIBCLANG_PATH + BINDGEN_EXTRA_CLANG_ARGS so it finds - # libclang and the libc headers, same as the devShell in flake.nix. - rustPlatform.bindgenHook ]; # moq-c is a staticlib; crane's default install phase only handles diff --git a/quest/m1/video-vaapi.md b/quest/m1/video-vaapi.md index e501d00777f..77df6784a1a 100644 --- a/quest/m1/video-vaapi.md +++ b/quest/m1/video-vaapi.md @@ -1,4 +1,4 @@ -# [L] VAAPI encode and decode +# [S] VAAPI encode and decode ## Goal @@ -9,56 +9,28 @@ surfaces. ## Plan -Decided in the 2026-09-30 audit: moved from m4, and the "gated on a -`moq-dev/vaapi` release" blocker is gone. That crate is our own repo (last -release 0.1.1 on 2026-11-04), so this quest includes the crate work (HEVC -encode, H.265 decode, pre-generated bindings, the resize pool) and cutting the -release, then bumping the workspace requirement here. The resize-pool quest -folds in for the same reason. +The crate work is in four moq-dev/vaapi PRs: -**Decode.** The H.264 decoder landed (`decode/backend/vaapi.rs`; the workspace pins moq-vaapi 0.1.1), -with the default `decode::Config::output` of `Output::Native` handing out -DMA-BUF surfaces the renderer imports without a download. H.265 decode is still missing, so a Linux box -without NVDEC has no hardware path for it. +- [moq-dev/vaapi#8](https://github.com/moq-dev/vaapi/pull/8): checked-in libva bindings, so no build script and no libclang. +- [moq-dev/vaapi#9](https://github.com/moq-dev/vaapi/pull/9): `Processor::resize` into output surfaces pooled per size. +- [moq-dev/vaapi#10](https://github.com/moq-dev/vaapi/pull/10): H.265 Main encode beside H.264. +- [moq-dev/vaapi#11](https://github.com/moq-dev/vaapi/pull/11): H.265 Main decode beside H.264, stacked on #9. -**The encoder.** H.264 is done. `moq-vaapi` imports DMA-BUFs and scales and -converts them through VPP (`dmabuf`, `vpp`, `Encoder::encode_dmabuf`, -`Encoder::set_bitrate`); `encode/backend/vaapi.rs` encodes a `Surface::DmaBuf` -without a download, and `Surface::resize` scales one through VPP. Validated on -Intel Meteor Lake. `just rs gpu` also runs the ignored -`vaapi_1080p_ladder_stays_on_the_gpu` proof on Intel: 1080p decode to DMA-BUFs, -VPP to 720p/480p/360p, GPU encode of every frame, and decoded output sizes and -counts. What is left is H.265, below. +The moq side is on this quest's branch: `vaapi` on by default in moq-video, +moq-transcode, and moq-cli, H.265 encode and decode in moq-video's VAAPI +backends, `Surface::resize` through the pool, and no bindgen hook in moq-c's +Nix build. -**H.265.** The VAAPI backend advertises H.264 only. `moq-vaapi` 0.1.1 vendors -the HEVC buffer types (`src/buffer/hevc.rs`) but its `Encoder` is hardcoded to -`VAProfileH264Main` (with `VAEntrypointEncSlice`, or the low-power entrypoint -where that is all a device has), so exposing an HEVC encoder is a -change to that crate, not a flag here. +What remains is the release and the bump. The four PRs together break the +crate's API (`encode::probe` and `decode::probe` take a codec, both `Config`s +gain a `codec` field, and `Processor::process` goes private), so the release is +0.2.0. Then bump `moq-vaapi` in the workspace `Cargo.toml` and `Cargo.lock` on +this quest's branch and rerun its checks; until then the branch does not build +against 0.1.1. -**Build cost.** `moq-vaapi` dlopens libva (no `DT_NEEDED`), so a -libva-less host starts and `backend::open` falls through to the next encoder. -What remains is the build side: its build script runs bindgen over the -vendored libva headers, so every consumer needs libclang on the build host. -That is why `vaapi` is off by default while `nvidia` is on. Commit the -generated bindings to the crate and drop the build script and the bindgen -dependency, as `moq-nvenc` does: the output is portable (layout tests off, -fixed-width types, `c_char` left symbolic), so one checked-in file serves -every Linux target, as `moq-v4l` already does for `videodev2.h`. Then the -feature can return to default-on here. +## Waiting -**Resize pool.** moq-vaapi's `Processor` allocates the blit output with -`ExportedFrame::from_surface` on every resize. Keep one surface per output -size; when the exported frame drops, the surface returns for the next blit of -that size. A frame the consumer still holds is not overwritten; the processor -allocates another. Keep at most one free surface per size and destroy any -returned past that, the decoder pool's rule. `Surface::resize` stays the same -call. The reuse test belongs in moq-vaapi; here, confirm a resize still returns -an NV12 DMA-BUF. - -Note what is already fine: a host with libva present but no usable VA driver -already falls back cleanly, since `Encoder::new` returns `Err` and -`backend::open` drops to openh264. +- Maintainer: merge moq-dev/vaapi#8 through #11 and publish the moq-vaapi release, since agents do not cut releases. Check with `cargo search moq-vaapi`. ## Related diff --git a/rs/moq-c/Cargo.toml b/rs/moq-c/Cargo.toml index ab9f4a20424..ae81527e410 100644 --- a/rs/moq-c/Cargo.toml +++ b/rs/moq-c/Cargo.toml @@ -33,8 +33,8 @@ moq-mux = { workspace = true, features = ["async"] } moq-net = { workspace = true } moq-tokio = { workspace = true, features = ["quic", "websocket", "tcp", "uds"] } # Select the NVIDIA and VAAPI hardware codecs explicitly because workspace -# defaults are off. The hardware backends dlopen their driver; `vaapi` also runs -# bindgen, so Linux builds need libclang. The software fallback is `openh264`. +# defaults are off. The hardware backends dlopen their driver, so neither needs +# anything on the build host. The software fallback is `openh264`. moq-video = { workspace = true, features = ["nvidia", "vaapi"] } # Blocking on `encode::Sink` from the synchronous C entry points; see # `video::block_on` for why not a tokio helper. diff --git a/rs/moq-cli/Cargo.toml b/rs/moq-cli/Cargo.toml index 740a9d9586b..fd43612d48d 100644 --- a/rs/moq-cli/Cargo.toml +++ b/rs/moq-cli/Cargo.toml @@ -26,7 +26,7 @@ path = "src/main.rs" doc = false [features] -default = ["cluster-lan", "quic", "websocket", "nvidia", "s3", "gcs", "azure"] +default = ["cluster-lan", "quic", "websocket", "nvidia", "vaapi", "s3", "gcs", "azure"] # LAN discovery and meshing (`--cluster-lan`). cluster-lan = ["moq-relay/cluster-lan"] jemalloc = ["moq-tokio/jemalloc"] @@ -72,10 +72,10 @@ nvidia = ["moq-video?/nvidia", "moq-transcode?/nvidia"] # feature it turns on. Only bites when `capture`, `transcode`, or `play` pulls in # moq-video. openh264 = ["moq-video?/openh264", "moq-transcode?/openh264"] -# Intel/AMD VAAPI hardware encoding (Linux), opt-in like the moq-video feature -# it turns on: libva is dlopen'd at runtime, but moq-vaapi's bindgen needs -# libclang on the build host. Only bites when `capture`, `transcode`, or `play` -# pulls in moq-video. +# Intel/AMD VAAPI hardware codecs (Linux), on by default like the moq-video +# feature it turns on: libva is dlopen'd at runtime and moq-vaapi checks its +# bindings in, so nothing is needed on the build host. Only bites when +# `capture`, `transcode`, or `play` pulls in moq-video. vaapi = ["moq-video?/vaapi", "moq-transcode?/vaapi"] # The V4L2 M2M codecs of an ARM SoC (a Raspberry Pi's VideoCore and the like), # opt-in like the moq-video feature it turns on. Costs the build nothing: moq-v4l diff --git a/rs/moq-ffi/Cargo.toml b/rs/moq-ffi/Cargo.toml index 7bb722bca7b..46350b28d85 100644 --- a/rs/moq-ffi/Cargo.toml +++ b/rs/moq-ffi/Cargo.toml @@ -52,8 +52,7 @@ moq-tokio = { workspace = true, default-features = true } # cudarc / moq-nvenc / libloading / moq-vaapi sit behind # `cfg(target_os = "linux")` and Android is `target_os = "android"`. On Linux # both dlopen the driver, so the wrappers still link GPU-less and start -# driverless; `vaapi` alone costs the build something, since moq-vaapi's bindgen -# needs libclang (the dev shell carries it). +# driverless, and neither needs anything on the build host. moq-video = { workspace = true, optional = true, features = ["nvidia", "vaapi"] } # Blocking on `encode::Sink` from the synchronous producer exports; see # `video::block_on` for why not a tokio helper. diff --git a/rs/moq-transcode/Cargo.toml b/rs/moq-transcode/Cargo.toml index a2fe4db53ae..70b66307606 100644 --- a/rs/moq-transcode/Cargo.toml +++ b/rs/moq-transcode/Cargo.toml @@ -13,20 +13,20 @@ keywords = ["quic", "http3", "webtransport", "media", "video"] categories = ["multimedia", "multimedia::video", "multimedia::encoding"] [features] -# NVIDIA is on by default, mirroring moq-video: NVDEC -> NVENC is the zero-copy -# GPU pipeline, and it dlopens its driver so it needs nothing on the build host. -# OpenH264, the software H.264 fallback, is vendored C++ and opt-in like -# moq-video's: release builds enable it. `vaapi` stays opt-in because its -# bindgen needs libclang; `v4l2` mirrors moq-video's opt-in too, though it costs -# the build nothing. -default = ["nvidia"] +# NVIDIA and VAAPI are on by default, mirroring moq-video: each is a zero-copy +# GPU pipeline (NVDEC -> NVENC, or VA decode -> VPP -> VA encode), and each +# dlopens its driver, so neither needs anything on the build host. OpenH264, the +# software H.264 fallback, is vendored C++ and opt-in like moq-video's: release +# builds enable it. `v4l2` mirrors moq-video's opt-in too, though it costs the +# build nothing. +default = ["nvidia", "vaapi"] # NVENC + NVDEC (Linux, dlopen'd at runtime; a no-op elsewhere). nvidia = ["moq-video/nvidia"] # Software H.264 encode/decode through moq-video's vendored OpenH264 backend. # Off by default; enable it in release builds. openh264 = ["moq-video/openh264"] -# Intel/AMD VAAPI hardware encoder (Linux; libva dlopen'd at runtime, but -# moq-vaapi's bindgen needs libclang at build time). +# Intel/AMD VAAPI hardware codecs (Linux; libva dlopen'd at runtime, and +# moq-vaapi checks its bindings in, so nothing is needed on the build host). vaapi = ["moq-video/vaapi"] # The V4L2 M2M codecs of an ARM SoC (Linux; moq-v4l checks its bindings in, so # nothing is needed on the build host). diff --git a/rs/moq-video/Cargo.toml b/rs/moq-video/Cargo.toml index 8745fcd9b5f..f481901b928 100644 --- a/rs/moq-video/Cargo.toml +++ b/rs/moq-video/Cargo.toml @@ -16,10 +16,10 @@ categories = ["multimedia", "multimedia::video", "multimedia::encoding"] # On by default: everything that costs the build nothing beyond cargo. Off by # default: every feature that needs libclang or a system library on the build # host, however cheap it is on other platforms, since a default is one setting -# for every host. `vaapi` runs bindgen over its vendored libva headers and -# `pipewire` links libpipewire; a consumer whose build host has those turns them -# on. `capture` and `v4l2` no longer cost anything on Linux (moq-v4l checks its -# bindings in) and stay opt-in only until every distribution ships them. The features exist so a consumer can pick what it wants, not to hide code +# for every host. `pipewire` links libpipewire; a consumer whose build host has +# it turns it on. `capture` and `v4l2` no longer cost anything on Linux (moq-v4l +# checks its bindings in) and stay opt-in only until every distribution ships +# them. The features exist so a consumer can pick what it wants, not to hide code # from the default compile (`just check` lints default features only, so the # opt-in ones are compiled by nightly's `just rs features` and platform.yml's # `just rs macos`). @@ -28,7 +28,7 @@ categories = ["multimedia", "multimedia::video", "multimedia::encoding"] # explicitly. Workspace consumers opt out at the root manifest # (`default-features = false`) and pick per crate, so the relay and the language # bindings never build device or rendering stacks. -default = ["mediacodec", "nvidia"] +default = ["mediacodec", "nvidia", "vaapi"] # Native camera and screen capture. Costs the build nothing on any platform: # Linux goes through moq-v4l (bindings checked in), macOS and Windows use OS # frameworks (Windows display/window capture requires Windows 10 2004+ WGC). @@ -57,12 +57,12 @@ openh264 = ["dep:openh264", "dep:openh264-sys2"] # libvpx.so, which is what the Nix dev shell does. Decodes 8-bit 4:2:0 only (VP8, # and VP9 profile 0); anything else is refused rather than converted. vpx = ["dep:libvpx-native-sys"] -# Intel/AMD VAAPI hardware codecs (Linux): the H.264 encoder and decoder. Off by -# default because moq-vaapi's build script runs bindgen over its vendored libva -# headers, so the build host needs libclang. At runtime libva is dlopen'd: the -# binary carries no NEEDED libva and still starts on a libva-less host, where -# automatic backend selection falls back to the next candidate. Both are -# validated on Intel Meteor Lake. +# Intel/AMD VAAPI hardware codecs (Linux): the H.264 and H.265 encoders and +# decoders, and the GPU resize between them. On by default, like `nvidia`: +# moq-vaapi checks its libva bindings in, so the build needs nothing beyond +# cargo, and libva is dlopen'd at runtime, so the binary carries no NEEDED libva +# and still starts on a libva-less host, where automatic backend selection falls +# back to the next candidate. vaapi = ["dmabuf", "dep:moq-vaapi"] # The V4L2 stateful memory-to-memory hardware codecs on Linux: the H.264 encoder # and decoder most ARM SoCs expose (a Raspberry Pi's VideoCore, and the @@ -207,12 +207,12 @@ moq-nvenc = { workspace = true, optional = true } # videodev2.h structs, `moq_v4l::v4l2::vidioc` for the request codes) rather # than a second V4L2 crate, so no ioctl struct is hand-rolled. moq-v4l = { workspace = true, optional = true } -# Intel/AMD VAAPI hardware H.264 encoder and decoder, behind the opt-in `vaapi` -# feature. As of moq-vaapi 0.0.3 libva is dlopen'd at runtime, so the binary carries -# no NEEDED libva: the build needs no libva-dev (its build script's bindgen still -# needs libclang), and a libva-less host still loads. Automatic backend selection -# then falls back to the next candidate instead of failing at load, matching the -# NVENC and NVDEC backends. +# Intel/AMD VAAPI hardware H.264 and H.265 encoder and decoder, behind the +# default `vaapi` feature. libva is dlopen'd at runtime, so the binary carries no +# NEEDED libva, and the bindings are checked in, so the build needs neither +# libva-dev nor libclang. A libva-less host still loads: automatic backend +# selection then falls back to the next candidate instead of failing at load, +# matching the NVENC and NVDEC backends. moq-vaapi = { workspace = true, optional = true } # PipeWire video stream for a portal's node or a camera node, behind the # `pipewire` feature. diff --git a/rs/moq-video/DESIGN-native-codecs.md b/rs/moq-video/DESIGN-native-codecs.md index 47b8f3096e8..56410f79087 100644 --- a/rs/moq-video/DESIGN-native-codecs.md +++ b/rs/moq-video/DESIGN-native-codecs.md @@ -224,7 +224,7 @@ objc2-core-media = "..." objc2-core-video = "..." [target.'cfg(target_os = "linux")'.dependencies] -# NVENC rides the default-on `nvidia` feature and VAAPI the opt-in `vaapi` +# NVENC rides the default-on `nvidia` feature and VAAPI the default-on `vaapi` # feature. Both dlopen their drivers at runtime, so they link on a GPU-less builder. moq-nvenc = { path = "../moq-nvenc", optional = true } # in-tree fork, dlopen-only moq-vaapi = { version = "0.0.2", optional = true } # standalone; vendored cros-libva + cros-codecs @@ -235,7 +235,7 @@ openh264 = { version = "...", optional = true } # default software fallback Hardware encoders are cfg-gated on macOS, iOS, and Windows (VideoToolbox, Media Foundation) and feature-gated on Linux (NVENC behind the default-on `nvidia`, -VAAPI behind the opt-in `vaapi`); the runtime fallback chain skips whichever +VAAPI behind the default-on `vaapi`); the runtime fallback chain skips whichever driver is absent. None is a build-time hard dep on the driver, so the binary still builds and runs on a box with no GPU. The default `openh264` feature provides the software fallback, so a GPU-less box still encodes (it's also what @@ -409,8 +409,9 @@ links on a libva-less builder and loads on a libva-less machine, falling back to software (see `backend::open`). > **Status: realized in moq-vaapi 0.0.3** (#1837, bumped in #2465). It dlopens -> libva and vendors the libva headers its bindgen reads, so VAAPI costs the build -> nothing: no libva-dev, no `NEEDED libva.so.2`, no entry in the nix devShell. +> libva and vendors the libva headers. Since moq-dev/vaapi#8 it also checks its +> bindings in, so VAAPI costs the build nothing: no libva-dev, no libclang, no +> `NEEDED libva.so.2`, no entry in the nix devShell. **Input: DMA-BUFs stay on the GPU, CPU frames are uploaded.** A `Surface::DmaBuf` is encoded without a download. An NV12 buffer at the encoder's diff --git a/rs/moq-video/README.md b/rs/moq-video/README.md index c38a4f02fb7..06a19e614a4 100644 --- a/rs/moq-video/README.md +++ b/rs/moq-video/README.md @@ -99,7 +99,7 @@ choice (`Auto` / `Hardware` / `Software` / a named backend). | Codec | Software | macOS | Windows | Linux | Android | |---|---|---|---|---|---| | H.264 | OpenH264 (feature `openh264`) | VideoToolbox | Media Foundation | NVENC (feature `nvidia`), VAAPI (feature `vaapi`) | MediaCodec (feature `mediacodec`, API 26+) | -| H.265 | none | VideoToolbox | Media Foundation | NVENC (feature `nvidia`) | MediaCodec (feature `mediacodec`, API 26+) | +| H.265 | none | VideoToolbox | Media Foundation | NVENC (feature `nvidia`), VAAPI (feature `vaapi`) | MediaCodec (feature `mediacodec`, API 26+) | Every backend emits Annex-B with in-band parameter sets (SPS/PPS, plus VPS for H.265), so the matching `moq_mux::codec` importer handles framing and catalog @@ -134,12 +134,12 @@ Public entry points: - `encode::Producer` publishes frames you encoded yourself (`publish(&[Encoded])`), handling the catalog and framing. Each is published at its own timestamp. -The default features are `nvidia` and `mediacodec`, so a default build has no -software encoder. `openh264` adds the software H.264 fallback, the only H.264 -encoder on a GPU-less host, at the cost of compiling vendored C++; enable it -wherever that fallback is expected. `nvidia` is Linux-only, `dlopen`s the -driver at runtime, and needs no build-time toolkit. `vaapi` is opt-in because -its bindgen needs libclang on the build host, while `v4l2` is opt-in only by +The default features are `nvidia`, `vaapi`, and `mediacodec`, so a default +build has no software encoder. `openh264` adds the software H.264 fallback, the +only H.264 encoder on a GPU-less host, at the cost of compiling vendored C++; +enable it wherever that fallback is expected. `nvidia` and `vaapi` are +Linux-only, `dlopen` their drivers at runtime, and need no build-time toolkit +(`moq-vaapi` checks its libva bindings in). `v4l2` is opt-in only by convention, since `moq-v4l` checks its bindings in. `vpx` is opt-in because libvpx comes from the build host through pkg-config (set `VPX_STATIC=1` to link the archive, as the Nix dev shell does). `render` is also opt-in so codec-only @@ -205,7 +205,7 @@ Backends are tried hardware-first, like encode: | Codec | Software | macOS | Windows | Linux | Android | |---|---|---|---|---|---| | H.264 | OpenH264 (feature `openh264`) | VideoToolbox | Media Foundation (DXVA) | NVDEC (feature `nvidia`), VAAPI (feature `vaapi`) | MediaCodec (feature `mediacodec`, API 26+) | -| H.265 | none | VideoToolbox | Media Foundation (DXVA) | NVDEC (feature `nvidia`) | MediaCodec (feature `mediacodec`, API 26+) | +| H.265 | none | VideoToolbox | Media Foundation (DXVA) | NVDEC (feature `nvidia`), VAAPI (feature `vaapi`) | MediaCodec (feature `mediacodec`, API 26+) | | AV1 | none | none | none | NVDEC (feature `nvidia`) | MediaCodec (feature `mediacodec`, when the device provides it) | | VP8, VP9 | libvpx (feature `vpx`) | none | none | none | none | @@ -217,8 +217,8 @@ Direct3D11 device bound to it, so the decode happens on the GPU through DXVA no software decoder, so it needs the GPU path (on Windows, an HEVC decoder MFT: the inbox HEVC Video Extensions or a vendor one). On Linux, NVDEC decodes H.264, H.265, and 8-bit 4:2:0 AV1 to CUDA NV12 frames; AV1 is decode-only and is useful -for AV1 source to H.264/H.265 transcode rungs. VAAPI decodes H.264 to DMA-BUF -surfaces the renderer imports without a download. libvpx decodes VP8 and VP9 +for AV1 source to H.264/H.265 transcode rungs. VAAPI decodes H.264 and H.265 +Main to DMA-BUF surfaces the renderer imports without a download. libvpx decodes VP8 and VP9 profile 0 to CPU I420 on every platform; other VP9 profiles (4:4:4, 10-bit) are refused rather than narrowed to 8-bit 4:2:0. Any other rendition yields `Error::UnsupportedCodec`. diff --git a/rs/moq-video/src/decode/backend/mod.rs b/rs/moq-video/src/decode/backend/mod.rs index 6c66a3340f1..25fba7c66cb 100644 --- a/rs/moq-video/src/decode/backend/mod.rs +++ b/rs/moq-video/src/decode/backend/mod.rs @@ -209,7 +209,7 @@ const HARDWARE: &[Candidate] = &[ #[cfg(all(target_os = "linux", feature = "vaapi"))] Candidate { name: vaapi::NAME, - supports: |c| matches!(c, Codec::H264), + supports: |c| matches!(c, Codec::H264 | Codec::H265), open: vaapi::Vaapi::open, }, // Last of the Linux hardware decoders, for the same reason as its encode diff --git a/rs/moq-video/src/decode/backend/vaapi.rs b/rs/moq-video/src/decode/backend/vaapi.rs index 29025d4ee1e..22d60658aa9 100644 --- a/rs/moq-video/src/decode/backend/vaapi.rs +++ b/rs/moq-video/src/decode/backend/vaapi.rs @@ -1,34 +1,39 @@ -//! Intel/AMD VAAPI hardware H.264 decode via the opt-in `moq-vaapi` crate on Linux. +//! Intel/AMD VAAPI hardware H.264 and H.265 decode via the `moq-vaapi` crate on Linux. //! //! The decode half of [`encode::backend::vaapi`](crate::encode). `moq-vaapi` is a -//! focused VA-API H.264 codec vendored and trimmed from cros-libva + +//! focused VA-API H.264 and H.265 codec vendored and trimmed from cros-libva + //! discord/cros-codecs. Its decoder takes one Annex-B access unit with the //! parameter sets inline and hands back tightly-packed NV12, which this //! deinterleaves to the CPU I420 the rest of the crate speaks. //! //! libva is `dlopen`'d at runtime, so a VAAPI-enabled build needs no libva at //! build time and the binary carries no `NEEDED libva`. A libva-less host, a -//! missing render node, or a driver with no H.264 decode entrypoint makes -//! `Decoder::new` return an error; under automatic selection +//! missing render node, or a driver with no decode entrypoint for the codec +//! makes `Decoder::new` return an error; under automatic selection //! [`backend::open`](super::open) then moves on to the next candidate, like the //! NVDEC backend. When every render node's driver answers that it has no decode -//! entrypoint for the profile the catalog declares, that is a refusal of the -//! stream rather than a fault. The render node is the one the encoder and the GPU resize +//! entrypoint for the profile the catalog declares, or for H.265 Main at all, +//! that is a refusal of the stream rather than a fault. For H.265, which has no +//! software decoder behind this one, that refusal is what lets a player pick +//! another rendition. The render node is the one the encoder and the GPU resize //! share, which `MOQ_VAAPI_DEVICE` can name; see `frame::vaapi::device`. //! //! Progressive 8-bit 4:2:0 only, which is everything a browser's `VideoEncoder`, -//! WebRTC, or this crate's own encoders emit. The decoder rejects an interlaced or -//! high-bit-depth sequence at its first SPS, which surfaces here as a decode -//! error rather than wrong pixels. Left and top cropping are also rejected. +//! WebRTC, or this crate's own encoders emit; H.265 is the Main profile. The +//! decoder rejects an interlaced or high-bit-depth sequence at its first SPS, +//! which surfaces here as a decode error rather than wrong pixels. Left and top +//! cropping are also rejected. //! -//! Unlike NVDEC, which cuvid lets us pin to zero display delay, output trails the -//! input even without B-frames: H.264's DPB releases a picture only once a later -//! one needs its slot, and the slot count comes from the sequence's reference and -//! reorder limits rather than the reorder depth actually used. A stream coded with -//! three reference frames therefore keeps three pictures in hand, which is why -//! this backend implements [`Backend::flush`] and the layers above call it when -//! the track ends. The decoded frames carry their own timestamps, so the delay -//! itself needs nothing downstream. +//! Unlike NVDEC, which cuvid lets us pin to zero display delay, H.264 output +//! trails the input even without B-frames: its DPB releases a picture only once a +//! later one needs its slot, and the slot count comes from the sequence's +//! reference and reorder limits rather than the reorder depth actually used. A +//! stream coded with three reference frames therefore keeps three pictures in +//! hand, which is why this backend implements [`Backend::flush`] and the layers +//! above call it when the track ends. H.265 releases a picture as soon as the +//! SPS's reorder limit allows, so a stream without B-frames comes out as it +//! decodes. The decoded frames carry their own timestamps, so the delay itself +//! needs nothing downstream. //! //! Under [`Output::Native`](crate::Output::Native) each picture comes back as //! the zero-copy [`Surface::DmaBuf`] the hardware decoded it into. Measured on @@ -76,32 +81,43 @@ pub(crate) struct Vaapi { } impl Vaapi { - /// VA-API H.265 and AV1 decode exist but are not wired up in `moq-vaapi`, so - /// this handles H.264 only. `config` carries no hardware scaler request we can + /// VA-API AV1 decode exists but is not wired up in `moq-vaapi`, so this + /// handles H.264 and H.265. `config` carries no hardware scaler request we can /// honor: VA-API's scaler is a separate VPP pipeline, so callers scale the /// frames themselves. pub(crate) fn open(stream: &Stream, config: &Config) -> Result, Error> { - let codec = stream.codec; - if codec != Codec::H264 { - return Err(Error::Codec(anyhow::anyhow!("VAAPI cannot decode {}", codec.label()))); - } - - if let Some(profile_idc) = stream.h264_profile { - // `moq-vaapi` fails a profile it has no mapping for at the first SPS, - // whatever the driver offers, so a declared one is refused here. - let Some(profile) = va_profile(profile_idc) else { - return Err(Error::UnsupportedCodec(format!( - "VA-API decodes no H.264 profile_idc {profile_idc}" - ))); - }; - if offered(profile) == Some(false) { - return Err(Error::UnsupportedCodec(format!( - "no VA-API driver here decodes H.264 profile_idc {profile_idc}" - ))); + let (codec, required) = match stream.codec { + Codec::H264 => { + let required = match stream.h264_profile { + // `moq-vaapi` fails a profile it has no mapping for at the first + // SPS, whatever the driver offers, so a declared one is refused + // here. + Some(profile_idc) => match va_profile(profile_idc) { + Some(profile) => Some((profile, format!("H.264 profile_idc {profile_idc}"))), + None => { + return Err(Error::UnsupportedCodec(format!( + "VA-API decodes no H.264 profile_idc {profile_idc}" + ))); + } + }, + None => None, + }; + (moq_vaapi::Codec::H264, required) } + Codec::H265 => ( + moq_vaapi::Codec::H265, + Some((VAProfile::VAProfileHEVCMain, "H.265 Main".to_owned())), + ), + other => return Err(Error::Codec(anyhow::anyhow!("VAAPI cannot decode {}", other.label()))), + }; + if let Some((profile, name)) = required + && offered(profile) == Some(false) + { + return Err(Error::UnsupportedCodec(format!("no VA-API driver here decodes {name}"))); } let vaapi = VaapiConfig { + codec, device: vaapi::device().map(Path::to_path_buf), }; let decoder = Decoder::new(vaapi).map_err(|e| Error::Codec(anyhow::anyhow!("VAAPI decoder init: {e:?}")))?; @@ -113,7 +129,12 @@ impl Vaapi { Output::Cpu => false, Output::Render => cfg!(feature = "render"), }; - tracing::info!(decoder = NAME, exporting, "opened H.264 decoder"); + tracing::info!( + decoder = NAME, + codec = stream.codec.label(), + exporting, + "opened decoder" + ); Ok(Box::new(Self { decoder, exporting, diff --git a/rs/moq-video/src/decode/decoder.rs b/rs/moq-video/src/decode/decoder.rs index 0c922deb14c..c7bfe4bc073 100644 --- a/rs/moq-video/src/decode/decoder.rs +++ b/rs/moq-video/src/decode/decoder.rs @@ -1126,6 +1126,29 @@ mod tests { round_trip(encoder, decoder, "videotoolbox"); } + /// The same over VA-API: HEVC encode emitting hev1 and HEVC decode, both on + /// the render node the two share. Skips without a VA-API H.265 encoder, which + /// includes radeonsi at this size (its H.265 minimum width is 384). + #[cfg(all(target_os = "linux", feature = "vaapi"))] + #[test] + fn vaapi_hevc_round_trip() { + let encoder = match Encoder::new(&EncodeConfig { + kind: EncodeKind::Named("vaapi".into()), + codec: crate::encode::Codec::H265, + ..EncodeConfig::new(320, 240, crate::FrameRate::new(30, 1).unwrap()) + }) { + Ok(encoder) => encoder, + // No H.265 encoder, or none this small: AMD's VCN 5 starts at 384 wide. + Err(err) => { + eprintln!("skipping: no VA-API H.265 encoder at 320x240: {err}"); + return; + } + }; + let decoder = backend::open(&Codec::H265.into(), &decode_config(super::Kind::Named("vaapi".into()))) + .expect("a VA-API H.265 decoder beside the encoder"); + round_trip(encoder, decoder, "vaapi"); + } + #[cfg(all(target_os = "windows", feature = "openh264"))] #[test] fn mediafoundation_round_trip() { diff --git a/rs/moq-video/src/encode/backend/mod.rs b/rs/moq-video/src/encode/backend/mod.rs index 5f26a522e8d..1abfec14d21 100644 --- a/rs/moq-video/src/encode/backend/mod.rs +++ b/rs/moq-video/src/encode/backend/mod.rs @@ -240,7 +240,7 @@ const HARDWARE: &[Candidate] = &[ #[cfg(all(target_os = "linux", feature = "vaapi"))] Candidate { name: vaapi::NAME, - codecs: &[Codec::H264], + codecs: &[Codec::H264, Codec::H265], open: vaapi::Vaapi::open, cuts: true, #[cfg(target_os = "linux")] diff --git a/rs/moq-video/src/encode/backend/vaapi.rs b/rs/moq-video/src/encode/backend/vaapi.rs index da17177c435..4107e01ecfb 100644 --- a/rs/moq-video/src/encode/backend/vaapi.rs +++ b/rs/moq-video/src/encode/backend/vaapi.rs @@ -1,8 +1,9 @@ //! Intel/AMD VAAPI hardware backend via the `moq-vaapi` crate on Linux. //! -//! `moq-vaapi` is a focused VA-API H.264 encoder vendored and trimmed from -//! cros-libva + discord/cros-codecs. It emits an Annex-B elementary stream with -//! in-band SPS/PPS, matching avc3 mode, and labels the color space in the VUI. +//! `moq-vaapi` is a focused VA-API H.264 and H.265 encoder vendored and trimmed +//! from cros-libva + discord/cros-codecs. It emits an Annex-B elementary stream +//! with the parameter sets in band, matching avc3 and hev1, and labels the color +//! space in the VUI. H.265 is the Main profile. //! //! As of moq-vaapi 0.0.3 libva is `dlopen`'d at runtime, so a VAAPI-enabled build //! needs no libva at build time and the binary carries no `NEEDED libva`. A @@ -14,8 +15,9 @@ //! //! A [`Surface::DmaBuf`] is encoded without touching the CPU. An NV12 buffer at //! the encoder's size (a VA-API decode, or one [`Surface::resize`] already -//! scaled on the GPU) is imported and encoded in place when its size is a -//! whole number of macroblocks. Anything else the driver imports, packed RGB +//! scaled on the GPU) is imported and encoded in place when the encoder codes +//! exactly that size, with no padding to whole coding blocks. Anything else the +//! driver imports, packed RGB //! from a PipeWire screen capture above all, goes through the video processor //! into the encoder's own surface first. RGB and YUV labelled with another //! space are converted into the stream's; unlabelled YUV is taken to be in it. @@ -31,7 +33,9 @@ //! Validated on Intel Meteor Lake with iHD 26.1.5: the tests below encode CPU //! frames, VA-API decodes handed over as DMA-BUFs, and packed RGB buffers at //! and above the encoder's size, decode each stream with openh264, and compare -//! pixels. They skip on a machine without a VA-API device. +//! pixels. The H.265 case decodes with the VA-API decoder, since there is no +//! software one, and was validated on Intel Arrow Lake (iHD 26.1.2). They skip +//! on a machine without a VA-API device. use std::collections::HashSet; use std::path::Path; @@ -49,6 +53,7 @@ pub(crate) const NAME: &str = "vaapi"; pub(crate) struct Vaapi { encoder: Encoder, + codec: Codec, /// Buffer layouts the driver refused to encode, by format and modifier, so /// each costs one failed attempt rather than one per frame. refused: HashSet<(DrmFormat, u64)>, @@ -82,6 +87,10 @@ impl Vaapi { let vaapi = VaapiConfig { device: vaapi::device().map(Path::to_path_buf), color: vaapi::color(color)?, + codec: match config.codec { + Codec::H264 => moq_vaapi::Codec::H264, + Codec::H265 => moq_vaapi::Codec::H265, + }, ..VaapiConfig::new( config.width, config.height, @@ -94,13 +103,15 @@ impl Vaapi { tracing::info!( encoder = NAME, + codec = ?config.codec, device = ?encoder.config().device, width = config.width, height = config.height, - "opened H.264 encoder" + "opened encoder" ); Ok(Self { encoder, + codec: config.codec, refused: HashSet::new(), nv12: Vec::new(), #[cfg(test)] @@ -172,7 +183,7 @@ impl Backend for Vaapi { Vec::new() } else { // moq-vaapi places the IDRs but reports only the bytes. - let keyframe = keyframe_annexb(Codec::H264, &annexb); + let keyframe = keyframe_annexb(self.codec, &annexb); vec![Encoded::new(Bytes::from(annexb), frame.timestamp, keyframe)] }) } @@ -478,6 +489,58 @@ mod tests { assert_close(&decoded[0], &expected, 10); } + /// H.265 takes the same GPU path: a packed RGB DMA-BUF is converted on the + /// GPU and encoded from there, and the VA-API decoder, the H.265 decoder a + /// Linux box without NVIDIA has, gets the picture back. + #[test] + fn an_rgb_dmabuf_is_encoded_as_h265_on_the_gpu() { + // radeonsi encodes H.265 no narrower than 384. + let size = Size::new(640, 480); + let Ok(mut backend) = Vaapi::new(&Config { + kind: EncodeKind::Named(NAME.into()), + codec: Codec::H265, + ..Config::new(size.width, size.height, FrameRate::new(30, 1).unwrap()) + }) else { + eprintln!("skipping: no VA-API H.265 encoder"); + return; + }; + let rgba = gradient_rgba(size); + let expected = I420::from_rgba(&rgba, size.width * 4, size).unwrap(); + let mut frames = Vec::new(); + for i in 0..3 { + let Some(buffer) = vaapi::testing::bgrx_dmabuf(&rgba, size) else { + eprintln!("skipping: no VA-API device to allocate a BGRX surface on"); + return; + }; + frames.push(Frame::new(Surface::DmaBuf(buffer), at(i))); + } + let config = DecodeConfig { + kind: DecodeKind::Named(NAME.into()), + output: Output::Cpu, + ..DecodeConfig::new() + }; + let mut hardware = decode_backend::open(&DecodeCodec::H265.into(), &config).expect("the VA-API H.265 decoder"); + + let mut decoded = Vec::new(); + for (index, frame) in frames.iter().enumerate() { + for encoded in backend.encode(frame, index == 0).expect("encode") { + assert_eq!(encoded.keyframe, index == 0, "picture {index} keyframe flag"); + decoded.extend( + hardware + .decode(encoded.payload, encoded.timestamp, encoded.keyframe) + .expect("decode"), + ); + } + } + decoded.extend(hardware.flush().expect("flush")); + assert_eq!(backend.gpu_frames, 3, "the encoder fell back to the CPU"); + assert!(backend.refused.is_empty()); + assert_eq!(decoded.len(), frames.len(), "pictures went missing"); + for frame in decoded { + assert_close(&frame, &expected, 10); + } + } + /// A bitrate change reaches the encoder instead of being refused. #[test] fn the_bitrate_can_change_mid_stream() { diff --git a/rs/moq-video/src/frame/vaapi.rs b/rs/moq-video/src/frame/vaapi.rs index 2188d8c33c3..b871e8ac8a8 100644 --- a/rs/moq-video/src/frame/vaapi.rs +++ b/rs/moq-video/src/frame/vaapi.rs @@ -13,7 +13,8 @@ //! surface is exported as a new DMA-BUF, which the VAAPI encoder then imports //! in turn. A simulcast publisher resizing one captured frame into several //! renditions pays one blit per rendition instead of a download and a CPU -//! scale each. +//! scale each, and no allocation once the first frame of each size has been +//! let go: its surface is the next one written at that size. use std::cell::RefCell; use std::collections::HashSet; @@ -24,7 +25,7 @@ use std::sync::{Arc, Mutex, OnceLock}; use moq_vaapi::decode::ExportedFrame; use moq_vaapi::dmabuf::{DmaBuf as VaapiDmaBuf, Plane}; use moq_vaapi::vpp::Processor; -use moq_vaapi::{Matrix, VA_FOURCC_NV12}; +use moq_vaapi::{Codec, Matrix}; use super::{DmaBuf, DmaBufExport, DmaBufFrame, DmaBufLayout, DmaBufPlane, DrmFormat, I420}; use crate::color::{self, Color}; @@ -55,8 +56,8 @@ pub(crate) fn device() -> Option<&'static Path> { } let node = moq_vaapi::DrmDeviceIterator::default().find(|node| { moq_vaapi::Display::open_drm_display(node).is_ok_and(|display| { - moq_vaapi::encode::probe(&display).is_ok() - && moq_vaapi::decode::probe(&display).is_ok() + moq_vaapi::encode::probe(&display, Codec::H264).is_ok() + && moq_vaapi::decode::probe(&display, Codec::H264).is_ok() && moq_vaapi::vpp::probe(&display).is_ok() }) }); @@ -188,22 +189,16 @@ pub(crate) fn resize(buffer: &DmaBuf, size: Size) -> Result { .as_ref() .map_err(|e| Error::Unsupported(format!("no VA-API video processor: {e}")))?; let (descriptor, lease) = import(buffer)?; - let processed = processor.import(descriptor).and_then(|input| { - processor.process( - &input, - VA_FOURCC_NV12, - (size.width, size.height), - input_space, - output_space, - ) - }); + // Into a surface the processor recycles once the frame drops. + let resized = processor + .import(descriptor) + .and_then(|input| processor.resize(&input, (size.width, size.height), input_space, output_space)); // The blit has synced, so the producer's buffer is free to go back. drop(lease); - let output = processed.map_err(|e| { + resized.map_err(|e| { REFUSED.with(|refused| refused.borrow_mut().insert(key)); Error::Codec(e.context("scale a DMA-BUF with the VA-API video processor")) - })?; - ExportedFrame::from_surface(output, 0).map_err(Error::Codec) + }) })?; adopt(exported, label).map_err(Error::Codec) } @@ -337,8 +332,8 @@ mod tests { return; }; let display = moq_vaapi::Display::open_drm_display(node).expect("reopen the shared node"); - moq_vaapi::encode::probe(&display).expect("the shared node encodes H.264"); - moq_vaapi::decode::probe(&display).expect("the shared node decodes H.264"); + moq_vaapi::encode::probe(&display, Codec::H264).expect("the shared node encodes H.264"); + moq_vaapi::decode::probe(&display, Codec::H264).expect("the shared node decodes H.264"); moq_vaapi::vpp::probe(&display).expect("the shared node scales"); } } From f184f2cee322fc753f0d5bbb51da26d42da321c8 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 6 Nov 2026 01:23:31 -0800 Subject: [PATCH 3/6] fix(moq-video): share a VA-API node that does H.265 too The shared render node was the first that encodes, decodes, and scales H.264, so on two GPUs where only the second does H.265 the H.265 encoder failed and the decoder refused the stream on the first. Prefer a node that also encodes and decodes H.265, and let an H.265 codec open its own node when the shared one cannot do it. MOQ_VAAPI_DEVICE still names the node outright. Co-Authored-By: Claude Opus 5.5 --- rs/moq-video/src/decode/backend/vaapi.rs | 13 +-- rs/moq-video/src/encode/backend/vaapi.rs | 16 ++-- rs/moq-video/src/frame/vaapi.rs | 105 +++++++++++++++++------ 3 files changed, 95 insertions(+), 39 deletions(-) diff --git a/rs/moq-video/src/decode/backend/vaapi.rs b/rs/moq-video/src/decode/backend/vaapi.rs index 22d60658aa9..3fe12428bc6 100644 --- a/rs/moq-video/src/decode/backend/vaapi.rs +++ b/rs/moq-video/src/decode/backend/vaapi.rs @@ -16,7 +16,8 @@ //! that is a refusal of the stream rather than a fault. For H.265, which has no //! software decoder behind this one, that refusal is what lets a player pick //! another rendition. The render node is the one the encoder and the GPU resize -//! share, which `MOQ_VAAPI_DEVICE` can name; see `frame::vaapi::device`. +//! share, unless that one cannot decode H.265, and `MOQ_VAAPI_DEVICE` can name +//! it; see `frame::vaapi::device`. //! //! Progressive 8-bit 4:2:0 only, which is everything a browser's `VideoEncoder`, //! WebRTC, or this crate's own encoders emit; H.265 is the Main profile. The @@ -111,14 +112,14 @@ impl Vaapi { other => return Err(Error::Codec(anyhow::anyhow!("VAAPI cannot decode {}", other.label()))), }; if let Some((profile, name)) = required - && offered(profile) == Some(false) + && offered(codec, profile) == Some(false) { return Err(Error::UnsupportedCodec(format!("no VA-API driver here decodes {name}"))); } let vaapi = VaapiConfig { codec, - device: vaapi::device().map(Path::to_path_buf), + device: vaapi::device(codec).map(Path::to_path_buf), }; let decoder = Decoder::new(vaapi).map_err(|e| Error::Codec(anyhow::anyhow!("VAAPI decoder init: {e:?}")))?; @@ -244,14 +245,14 @@ fn va_profile(profile_idc: u8) -> Option { } } -/// Whether a render node the decoder could open offers VLD decode for +/// Whether a render node a `codec` decoder could open offers VLD decode for /// `profile`. /// /// `Some(false)` only when every node answered and none does. A node that can't /// be asked, such as one whose VA driver is missing, leaves the answer unknown, /// since a missing driver is a fault rather than the device's refusal. -fn offered(profile: VAProfile::Type) -> Option { - let nodes: Vec = match vaapi::device() { +fn offered(codec: moq_vaapi::Codec, profile: VAProfile::Type) -> Option { + let nodes: Vec = match vaapi::device(codec) { Some(node) => vec![node.to_path_buf()], None => DrmDeviceIterator::default().collect(), }; diff --git a/rs/moq-video/src/encode/backend/vaapi.rs b/rs/moq-video/src/encode/backend/vaapi.rs index 4107e01ecfb..55e8da379a0 100644 --- a/rs/moq-video/src/encode/backend/vaapi.rs +++ b/rs/moq-video/src/encode/backend/vaapi.rs @@ -10,8 +10,9 @@ //! libva-less host, or a present-but-unusable VA stack (no render node, no usable //! driver), makes `Encoder::new` return an error; under automatic selection //! [`backend::open`](super::open) then moves on to openh264, like the NVENC backend. -//! The render node is the one the decoder and the GPU resize share, which -//! `MOQ_VAAPI_DEVICE` can name; see `frame::vaapi::device`. +//! The render node is the one the decoder and the GPU resize share, unless that +//! one cannot encode H.265, and `MOQ_VAAPI_DEVICE` can name it; see +//! `frame::vaapi::device`. //! //! A [`Surface::DmaBuf`] is encoded without touching the CPU. An NV12 buffer at //! the encoder's size (a VA-API decode, or one [`Surface::resize`] already @@ -84,13 +85,14 @@ impl Vaapi { if color != paired.with_range(color.range) { return Err(Error::Unsupported(format!("VA-API cannot signal {color:?}"))); } + let codec = match config.codec { + Codec::H264 => moq_vaapi::Codec::H264, + Codec::H265 => moq_vaapi::Codec::H265, + }; let vaapi = VaapiConfig { - device: vaapi::device().map(Path::to_path_buf), + device: vaapi::device(codec).map(Path::to_path_buf), color: vaapi::color(color)?, - codec: match config.codec { - Codec::H264 => moq_vaapi::Codec::H264, - Codec::H265 => moq_vaapi::Codec::H265, - }, + codec, ..VaapiConfig::new( config.width, config.height, diff --git a/rs/moq-video/src/frame/vaapi.rs b/rs/moq-video/src/frame/vaapi.rs index b871e8ac8a8..38b93949111 100644 --- a/rs/moq-video/src/frame/vaapi.rs +++ b/rs/moq-video/src/frame/vaapi.rs @@ -31,43 +31,75 @@ use super::{DmaBuf, DmaBufExport, DmaBufFrame, DmaBufLayout, DmaBufPlane, DrmFor use crate::color::{self, Color}; use crate::{Error, Size}; -/// Environment variable naming the render node, such as `/dev/dri/renderD129`, that [`device`] returns. +/// Environment variable naming the render node, such as `/dev/dri/renderD129`, the VA-API codecs and resize share. const DEVICE_ENV: &str = "MOQ_VAAPI_DEVICE"; -/// Returns the render node the VA-API encoder, decoder, and resize open, or `None` for each to find its own. +/// The render node the VA-API encoders, decoders, and resize share. +struct Shared { + node: PathBuf, + /// Whether it also encodes and decodes H.265, which not every node that does H.264 can. + h265: bool, +} + +/// Returns the node shared by the VA-API codecs and resize, or `None` for each to find its own. /// /// [`DEVICE_ENV`] names one outright, and a named node is used even when it /// fails to open, so a typo is an error rather than a silent fallback. /// Otherwise this is the first node whose driver encodes and decodes H.264 and -/// post-processes video. Sharing one node is what lets a DMA-BUF move from the -/// decoder through a resize into the encoder without a copy; on a machine with -/// two GPUs, the first node that decodes need not be one that encodes. Where no -/// node offers all three, each opens the first node that offers what it needs. +/// post-processes video, preferring one that also encodes and decodes H.265. +/// Sharing one node is what lets a DMA-BUF move from the decoder through a +/// resize into the encoder without a copy; on a machine with two GPUs, the first +/// node that decodes need not be one that encodes. Where no node offers all +/// three, each opens the first node that offers what it needs. /// /// Resolved once per process, since finding it opens every render node. -pub(crate) fn device() -> Option<&'static Path> { - static DEVICE: OnceLock> = OnceLock::new(); - DEVICE +fn shared() -> Option<&'static Shared> { + static SHARED: OnceLock> = OnceLock::new(); + SHARED .get_or_init(|| { if let Some(node) = std::env::var_os(DEVICE_ENV) { let node = PathBuf::from(node); tracing::info!(device = %node.display(), "using the VA-API render node {DEVICE_ENV} names"); - return Some(node); + return Some(Shared { node, h265: true }); } - let node = moq_vaapi::DrmDeviceIterator::default().find(|node| { - moq_vaapi::Display::open_drm_display(node).is_ok_and(|display| { - moq_vaapi::encode::probe(&display, Codec::H264).is_ok() - && moq_vaapi::decode::probe(&display, Codec::H264).is_ok() - && moq_vaapi::vpp::probe(&display).is_ok() + let shared = choose(moq_vaapi::DrmDeviceIterator::default().filter_map(|node| { + let display = moq_vaapi::Display::open_drm_display(&node).ok()?; + let codes = |codec| { + moq_vaapi::encode::probe(&display, codec).is_ok() + && moq_vaapi::decode::probe(&display, codec).is_ok() + }; + let shareable = codes(Codec::H264) && moq_vaapi::vpp::probe(&display).is_ok(); + shareable.then(|| Shared { + h265: codes(Codec::H265), + node, }) - }); - match &node { - Some(node) => tracing::debug!(device = %node.display(), "VA-API render node"), + })); + match &shared { + Some(shared) => tracing::debug!(device = %shared.node.display(), shared.h265, "VA-API render node"), None => tracing::debug!("no VA-API render node encodes, decodes, and scales; each opens its own"), } - node + shared }) - .as_deref() + .as_ref() +} + +/// Returns the first of `candidates` that does H.265 too, or else the first. +fn choose(mut candidates: impl Iterator) -> Option { + let first = candidates.next()?; + if first.h265 { + return Some(first); + } + Some(candidates.find(|candidate| candidate.h265).unwrap_or(first)) +} + +/// Returns the render node a VA-API `codec` encoder or decoder opens, or `None` for it to find its own. +/// +/// The shared node, unless it does not do H.265: an H.265 codec then opens the +/// first node that offers it, rather than failing on one that cannot. +pub(crate) fn device(codec: Codec) -> Option<&'static Path> { + shared() + .filter(|shared| codec == Codec::H264 || shared.h265) + .map(|shared| shared.node.as_path()) } /// Describes `buffer` for a VA-API import, returning the producer lease to hold until the import is done with. @@ -180,8 +212,8 @@ pub(crate) fn resize(buffer: &DmaBuf, size: Size) -> Result { // fence wait and a descriptor duplicate on every frame to learn it again. let processor = slot .get_or_insert_with(|| { - match device() { - Some(node) => Processor::new(node), + match shared() { + Some(shared) => Processor::new(&shared.node), None => Processor::open(), } .map_err(|e| format!("{e:#}")) @@ -327,14 +359,35 @@ mod tests { eprintln!("skipping: {DEVICE_ENV} names the node"); return; } - let Some(node) = device() else { + let Some(shared) = shared() else { eprintln!("skipping: no render node encodes, decodes, and scales"); return; }; - let display = moq_vaapi::Display::open_drm_display(node).expect("reopen the shared node"); + let display = moq_vaapi::Display::open_drm_display(&shared.node).expect("reopen the shared node"); moq_vaapi::encode::probe(&display, Codec::H264).expect("the shared node encodes H.264"); moq_vaapi::decode::probe(&display, Codec::H264).expect("the shared node decodes H.264"); moq_vaapi::vpp::probe(&display).expect("the shared node scales"); + let h265 = moq_vaapi::encode::probe(&display, Codec::H265).is_ok() + && moq_vaapi::decode::probe(&display, Codec::H265).is_ok(); + assert_eq!(shared.h265, h265, "whether the shared node does H.265"); + } + + /// On two GPUs where only the second does H.265, the second is shared, so + /// neither codec is pinned to a node that cannot do it. + #[test] + fn a_node_that_does_h265_too_is_shared_first() { + let node = |name: &str, h265| Shared { + node: PathBuf::from(name), + h265, + }; + let chosen = |nodes: Vec| choose(nodes.into_iter()).map(|shared| (shared.node, shared.h265)); + + let later = chosen(vec![node("first", false), node("second", true)]); + assert_eq!(later, Some((PathBuf::from("second"), true))); + // Without one, H.264 still shares the first, and H.265 finds its own. + let none = chosen(vec![node("first", false), node("second", false)]); + assert_eq!(none, Some((PathBuf::from("first"), false))); + assert_eq!(chosen(Vec::new()), None); } } @@ -403,8 +456,8 @@ pub(crate) mod testing { pub(crate) fn bgrx_dmabuf(rgba: &[u8], size: Size) -> Option { // The same node resize and the encoder open. On two GPUs `Display::open` // can be a different device, and the processor then refuses the import. - let display = match super::device() { - Some(node) => Display::open_drm_display(node).ok()?, + let display = match super::shared() { + Some(shared) => Display::open_drm_display(&shared.node).ok()?, None => Display::open()?, }; let (width, height) = (size.width, size.height); From 6065310cdd69c2b6655563b6c6838f4153491d02 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 6 Nov 2026 15:16:26 -0800 Subject: [PATCH 4/6] feat(moq-video): build against published moq-vaapi 0.2.0 Bump moq-vaapi to 0.2.0, which carries the checked-in bindings, pooled resize, and H.265 encode and decode. bindgen leaves the lock. This completes quest/m1/video-vaapi.md, so delete it; its ignored GPU ladder test moves to the GPU CI quest beside the other just rs gpu tests. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 36 ++++++------------------------- Cargo.toml | 2 +- quest/m1/README.md | 3 +-- quest/m1/video-vaapi.md | 37 -------------------------------- quest/m3/obs-moq-video/README.md | 1 - quest/m3/vaapi-vulkan-import.md | 3 +-- quest/m5/obs-decode-linux.md | 4 ---- quest/m5/obs-linux-gpu.md | 1 - quest/m5/video-codec-coverage.md | 1 - sh/gh/test-inventory.allow | 2 +- 10 files changed, 11 insertions(+), 79 deletions(-) delete mode 100644 quest/m1/video-vaapi.md diff --git a/Cargo.lock b/Cargo.lock index efa810525e3..07227e0eeaa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -702,26 +702,6 @@ dependencies = [ "workspace-hack", ] -[[package]] -name = "bindgen" -version = "0.70.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f" -dependencies = [ - "bitflags 2.13.2", - "cexpr", - "clang-sys", - "itertools 0.10.5", - "log", - "prettyplease", - "proc-macro2", - "quote", - "regex", - "rustc-hash 1.1.0", - "shlex 1.3.0", - "syn 2.0.119", -] - [[package]] name = "bindgen" version = "0.72.1" @@ -732,7 +712,7 @@ dependencies = [ "bitflags 2.13.2", "cexpr", "clang-sys", - "itertools 0.10.5", + "itertools 0.13.0", "log", "prettyplease", "proc-macro2", @@ -1578,7 +1558,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "035c801dc4b418e1d857a6536dc88b4d1929c7a1fd163389766e18d322d34a84" dependencies = [ - "bindgen 0.72.1", + "bindgen", "cc", "pkg-config", "rustversion", @@ -4043,7 +4023,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b6e17bdaf63ed0d5e4144022624032b41fd9733112e8c74ac26fc9bf1291924" dependencies = [ - "bindgen 0.72.1", + "bindgen", "cc", "system-deps 7.0.8", ] @@ -5279,16 +5259,14 @@ dependencies = [ [[package]] name = "moq-vaapi" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb08b9dab1b19b21fe0e909755a9c17601d6dcb0ced2b325fda0f0a8ba594cb8" +checksum = "7b175d0632ae90ceaa88ff0c2a6ad949ae227f39d35ea1dd5019beff278d967f" dependencies = [ "anyhow", - "bindgen 0.70.1", "bitflags 2.13.2", "libloading 0.8.9", "log", - "regex", "thiserror 1.0.69", ] @@ -6662,7 +6640,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce653f53e63e5b93853218092ee9a8906a5d082c92f3f1db26316955dd63ce0" dependencies = [ - "bindgen 0.72.1", + "bindgen", "libspa-sys", "system-deps 7.0.8", ] @@ -9080,7 +9058,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.3.4", + "getrandom 0.4.3", "once_cell", "rustix 1.1.6", "windows-sys 0.61.2", diff --git a/Cargo.toml b/Cargo.toml index 2efd636e6fe..f6e30344d0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -168,7 +168,7 @@ moq-uring = { version = "0.0.12", path = "rs/moq-uring", default-features = fals moq-v4l = { version = "0.1.0", path = "rs/moq-v4l" } # Standalone crate (moq-dev/vaapi); vendored from cros-libva + cros-codecs. # dlopen's libva at runtime (no libva-dev at build, no NEEDED libva in the binary). -moq-vaapi = "0.1.1" +moq-vaapi = "0.2.0" # `default-features = false` is here for `capture` (V4L2, libclang), which the # cross-compiled Python, Swift, Kotlin, and Go builds have no use for: adding # `features = ["capture"]` to a consumer that ships in those bindings pulls the diff --git a/quest/m1/README.md b/quest/m1/README.md index 66c3452e9c0..d3dc1db9406 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -19,7 +19,7 @@ Placements decided in the re-cut: read-backfill (a JS fix that matches Rust), buffered-ascending (lite-07 already carries the order field), webrtc-vendor (internal, though it requires the m2 rename), and the crates.io trusted publisher and OIDC quests (setup after the cut's first publishes) are -additive. [video-vaapi](/quest/m1/video-vaapi.md) moved up from later work +additive. video-vaapi moved up from later work because a downstream iGPU transcode trial needs it now. Held here by open claims: a quest's branch is its path, so a claimed quest @@ -53,7 +53,6 @@ moves what remains of them once their claims merge. - [Session policy lives in moq-net](/quest/m1/session-policy/README.md) - accept and connect deadlines, admission, window widening and reconnect live once in moq-net; moq-tokio and moq-relay's io_uring path call them - [Vendor and trim the WebRTC stack](/quest/m1/webrtc-vendor.md) - str0m, dimpl, `is`, and sctp-proto live in moq-webrtc with unused code removed, so moq-rtc can take rind - [MoQ on rind](/quest/m1/rind/README.md) - every MoQ crate takes its crypto from rind, a pure-Rust graviola fork, so no build compiles C crypto -- [VAAPI encode and decode](/quest/m1/video-vaapi.md) - H.265 encode and decode, pre-generated bindings, and pooled resize surfaces, including the moq-dev/vaapi release that carries them - [Read a texture back without an encoder](/quest/m1/video-readback.md) - moq-video copies a wgpu texture into packed RGBA with no encoder probe, for the studio's Linux virtual camera - [The over-limit PUBLISH refusal invites a retry](/quest/m1/retry-interval-overload.md) - `EXCESSIVE_LOAD` sends the may-pass retry interval, not 0 - [A relay forwards an upstream refusal's retry interval](/quest/m1/retry-interval-forward.md) - a forwarded SUBSCRIBE refusal keeps the upstream's retry interval diff --git a/quest/m1/video-vaapi.md b/quest/m1/video-vaapi.md deleted file mode 100644 index 77df6784a1a..00000000000 --- a/quest/m1/video-vaapi.md +++ /dev/null @@ -1,37 +0,0 @@ -# [S] VAAPI encode and decode - -## Goal - -VAAPI encodes H.264 and H.265 from a DMA-BUF without a download, decodes -H.265 as well as H.264, and the `vaapi` feature costs a consumer nothing at -build time so it can return to default-on. A resize reuses its output -surfaces. - -## Plan - -The crate work is in four moq-dev/vaapi PRs: - -- [moq-dev/vaapi#8](https://github.com/moq-dev/vaapi/pull/8): checked-in libva bindings, so no build script and no libclang. -- [moq-dev/vaapi#9](https://github.com/moq-dev/vaapi/pull/9): `Processor::resize` into output surfaces pooled per size. -- [moq-dev/vaapi#10](https://github.com/moq-dev/vaapi/pull/10): H.265 Main encode beside H.264. -- [moq-dev/vaapi#11](https://github.com/moq-dev/vaapi/pull/11): H.265 Main decode beside H.264, stacked on #9. - -The moq side is on this quest's branch: `vaapi` on by default in moq-video, -moq-transcode, and moq-cli, H.265 encode and decode in moq-video's VAAPI -backends, `Surface::resize` through the pool, and no bindgen hook in moq-c's -Nix build. - -What remains is the release and the bump. The four PRs together break the -crate's API (`encode::probe` and `decode::probe` take a codec, both `Config`s -gain a `codec` field, and `Processor::process` goes private), so the release is -0.2.0. Then bump `moq-vaapi` in the workspace `Cargo.toml` and `Cargo.lock` on -this quest's branch and rerun its checks; until then the branch does not build -against 0.1.1. - -## Waiting - -- Maintainer: merge moq-dev/vaapi#8 through #11 and publish the moq-vaapi release, since agents do not cut releases. Check with `cargo search moq-vaapi`. - -## Related - -- [VA-API encodes an external Vulkan image](/quest/m3/vaapi-vulkan-import.md) - explicit-sync DMA-BUF input and render-node selection by device, H.264 only diff --git a/quest/m3/obs-moq-video/README.md b/quest/m3/obs-moq-video/README.md index 9c7c2438b9b..88c28e60b47 100644 --- a/quest/m3/obs-moq-video/README.md +++ b/quest/m3/obs-moq-video/README.md @@ -35,4 +35,3 @@ Decided in the 2026-09-30 audit: the Windows and Linux GPU decode paths and the - [AudioToolbox decode](/quest/m3/audio-decode-audiotoolbox.md) - HE-AAC and multichannel AAC reach the OBS source on macOS through moq-ffi - [AudioToolbox encode](/quest/m5/audio-encode-audiotoolbox.md) - native AAC encode reaches the OBS encoder adapter on macOS through moq-ffi - [Linux GPU input](/quest/m5/obs-linux-gpu.md) - allocation-export feasibility and its dependent implementation are deferred -- [VAAPI encode and decode](/quest/m1/video-vaapi.md) - owns Linux backend decode/import capabilities; reconcile its older dependency assumptions against current code diff --git a/quest/m3/vaapi-vulkan-import.md b/quest/m3/vaapi-vulkan-import.md index 7caf67364ed..dcd39630ac3 100644 --- a/quest/m3/vaapi-vulkan-import.md +++ b/quest/m3/vaapi-vulkan-import.md @@ -19,7 +19,7 @@ the same type reaches CUDA, Vulkan Video, and VA-API. Decided 2026-10-05 in a `/quest-plan` interview (paper trail in the PR that added this quest): Intel uses VA-API, since ANV on Arrow Lake has no Vulkan encode on Mesa 26.0.8 (it is in 26.2 behind `ANV_DEBUG`). H.264 is enough for -the proof; H.265 on VA-API belongs to [VAAPI encode and decode](/quest/m1/video-vaapi.md). +the proof; H.265 on VA-API is already on main. Today the VA-API encoder takes a `Surface::DmaBuf` and waits for the producer through an implicit-fence poll with a 500 ms timeout (`DMA_BUF_FENCE_TIMEOUT` @@ -70,7 +70,6 @@ Public API: none; the surface landed in #4975. Wire: none. ## Related - [Vulkan Video encode on AMD](/quest/m3/vulkan-encode.md) - the AMD half of the same proof -- [VAAPI encode and decode](/quest/m1/video-vaapi.md) - H.265 encode on the same backend - [GPU capacity and health](/quest/m3/gpu-health.md) - reports per device keyed by the same render node `dev_t` - [Linux OBS GPU input](/quest/m5/obs-linux-gpu.md) - a DMA-BUF producer that needs the same explicit sync - [Video hardware validation](/quest/m5/video-hardware.md) - VA-API so far ran only on Meteor Lake diff --git a/quest/m5/obs-decode-linux.md b/quest/m5/obs-decode-linux.md index dd6c627e3c5..b610c865d28 100644 --- a/quest/m5/obs-decode-linux.md +++ b/quest/m5/obs-decode-linux.md @@ -14,7 +14,3 @@ At least one supported Linux hardware decoder delivers frames to OBS without CPU ## Required - [Video source replacement](/quest/m3/obs-moq-video/source.md) - native frame contract and fallback lifecycle - -## Related - -- [VAAPI encode and decode](/quest/m1/video-vaapi.md) - owns remaining VAAPI decode and native surface gaps; avoid a duplicate backend implementation diff --git a/quest/m5/obs-linux-gpu.md b/quest/m5/obs-linux-gpu.md index e5901d4ed37..547cd2402ec 100644 --- a/quest/m5/obs-linux-gpu.md +++ b/quest/m5/obs-linux-gpu.md @@ -24,4 +24,3 @@ the bottleneck. - [Video hardware validation](/quest/m5/video-hardware.md) - native input and encoder acceptance need hardware evidence - [VA-API encodes an external Vulkan image](/quest/m3/vaapi-vulkan-import.md) - explicit sync for an external DMA-BUF, and the public `DmaBuf` constructor from #4975 -- [VAAPI encode and decode](/quest/m1/video-vaapi.md) - H.265 and checked-in bindings. The DMA-BUF encoder import this quest needs is already on main (moq-vaapi 0.1.1). diff --git a/quest/m5/video-codec-coverage.md b/quest/m5/video-codec-coverage.md index 9867f75936d..4b46c55fba8 100644 --- a/quest/m5/video-codec-coverage.md +++ b/quest/m5/video-codec-coverage.md @@ -32,5 +32,4 @@ Decided 2026-10-08: moved to m3. No consumer has asked for a missing codec. ## Related - [NVIDIA formats](/quest/m5/2147-moq-video-10-bit-hevc-and-av1-support-in-the-nvidia-codec.md) - 10-bit HEVC scope; AV1 encode moved to [NVENC AV1](/quest/m5/nvenc-av1.md) -- [VAAPI](/quest/m1/video-vaapi.md) - existing Linux codec expansion - [VP8/VP9 in OBS](/quest/m3/obs-moq-video/vpx-obs.md) - the software decoder reaching the OBS source diff --git a/sh/gh/test-inventory.allow b/sh/gh/test-inventory.allow index 6c56be00373..3a1012652fd 100644 --- a/sh/gh/test-inventory.allow +++ b/sh/gh/test-inventory.allow @@ -9,7 +9,7 @@ ignore moq-ffi::test::concurrent_ready_calls_all_wake /quest/m0/test-flakes-2/ff ignore moq-carla-bridge::gpu_video_reaches_the_worker /quest/m5/carla-bridge.md recipe carla::bridge-gpu /quest/m5/carla-bridge.md recipe rs::gpu /quest/m3/gpu-ci.md -ignore moq-video::encode::backend::vaapi::hardware_tests::vaapi_1080p_ladder_stays_on_the_gpu /quest/m1/video-vaapi.md +ignore moq-video::encode::backend::vaapi::hardware_tests::vaapi_1080p_ladder_stays_on_the_gpu /quest/m3/gpu-ci.md ignore moq-video::frame::vulkan::tests::vulkan_gpu_device /quest/m3/gpu-ci.md ignore moq-video::frame::vulkan::tests::vulkan_cuda_slot_reuse_and_teardown /quest/m3/gpu-ci.md ignore moq-video::frame::cuda::tests::vulkan_cuda_auto_external_encode /quest/m3/gpu-ci.md From 8eceefabf3d413238b2caf50f89033f822070ebd Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 6 Nov 2026 15:32:28 -0800 Subject: [PATCH 5/6] chore(rs): regenerate the workspace-hack without bindgen Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 3 +-- rs/workspace-hack/Cargo.toml | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 07227e0eeaa..45f7ce42b14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11018,7 +11018,6 @@ dependencies = [ "futures-sink", "futures-task", "futures-util", - "getrandom 0.3.4", "getrandom 0.4.3", "half", "hashbrown 0.17.1", @@ -11029,6 +11028,7 @@ dependencies = [ "hyper-rustls", "hyper-util", "indexmap 2.14.2", + "itertools 0.13.0", "jsonwebtoken", "lazy_static", "libc", @@ -11075,7 +11075,6 @@ dependencies = [ "regex-automata", "regex-syntax", "reqwest", - "rustc-hash 1.1.0", "rustix 1.1.6", "rustls", "rustls-pki-types", diff --git a/rs/workspace-hack/Cargo.toml b/rs/workspace-hack/Cargo.toml index ccb8acf9985..b30edc8658f 100644 --- a/rs/workspace-hack/Cargo.toml +++ b/rs/workspace-hack/Cargo.toml @@ -256,7 +256,7 @@ crossbeam-epoch = { version = "0.9" } dispatch2 = { version = "0.3" } errno = { version = "0.3" } flate2 = { version = "1", features = ["zlib-rs"] } -getrandom-468e82937335b1c9 = { package = "getrandom", version = "0.3", default-features = false, features = ["std"] } +getrandom = { version = "0.4", default-features = false, features = ["std", "sys_rng"] } half = { version = "2", default-features = false, features = ["num-traits"] } hyper-rustls = { version = "0.27", default-features = false, features = ["aws-lc-rs", "http1", "http2", "tls12"] } hyper-util = { version = "0.1", default-features = false, features = ["client-legacy", "client-proxy"] } @@ -288,7 +288,7 @@ crossbeam-epoch = { version = "0.9" } dispatch2 = { version = "0.3" } errno = { version = "0.3" } flate2 = { version = "1", features = ["zlib-rs"] } -getrandom-468e82937335b1c9 = { package = "getrandom", version = "0.3", default-features = false, features = ["std"] } +getrandom = { version = "0.4", default-features = false, features = ["std", "sys_rng"] } half = { version = "2", default-features = false, features = ["num-traits"] } hyper-rustls = { version = "0.27", default-features = false, features = ["aws-lc-rs", "http1", "http2", "tls12"] } hyper-util = { version = "0.1", default-features = false, features = ["client-legacy", "client-proxy"] } @@ -322,10 +322,11 @@ event-listener = { version = "5" } event-listener-strategy = { version = "0.5" } flate2 = { version = "1", features = ["zlib-rs"] } futures-io = { version = "0.3" } -getrandom-468e82937335b1c9 = { package = "getrandom", version = "0.3", default-features = false, features = ["std"] } +getrandom = { version = "0.4", default-features = false, features = ["std", "sys_rng"] } half = { version = "2", default-features = false, features = ["num-traits"] } hyper-rustls = { version = "0.27", default-features = false, features = ["aws-lc-rs", "http1", "http2", "tls12"] } hyper-util = { version = "0.1", default-features = false, features = ["client-legacy", "client-proxy"] } +itertools = { version = "0.13" } libc = { version = "0.2", features = ["extra_traits"] } linux-raw-sys = { version = "0.12", features = ["auxvec", "elf", "if_ether", "ioctl", "net", "netlink", "no_std", "prctl", "system", "xdp"] } nix = { version = "0.31", features = ["net", "uio"] } @@ -334,7 +335,6 @@ proc-macro2 = { version = "1" } quick-xml = { version = "0.41", features = ["overlapped-lists", "serialize"] } quote = { version = "1" } regex = { version = "1" } -rustc-hash = { version = "1" } rustix = { version = "1", features = ["event", "net", "param", "pipe", "process", "shm", "system", "termios", "thread", "time"] } rustls = { version = "0.23", default-features = false, features = ["aws-lc-rs", "aws_lc_rs"] } rustls-webpki = { version = "0.103", default-features = false, features = ["aws-lc-rs", "std"] } @@ -355,17 +355,17 @@ event-listener = { version = "5" } event-listener-strategy = { version = "0.5" } flate2 = { version = "1", features = ["zlib-rs"] } futures-io = { version = "0.3" } -getrandom-468e82937335b1c9 = { package = "getrandom", version = "0.3", default-features = false, features = ["std"] } +getrandom = { version = "0.4", default-features = false, features = ["std", "sys_rng"] } half = { version = "2", default-features = false, features = ["num-traits"] } hyper-rustls = { version = "0.27", default-features = false, features = ["aws-lc-rs", "http1", "http2", "tls12"] } hyper-util = { version = "0.1", default-features = false, features = ["client-legacy", "client-proxy"] } +itertools = { version = "0.13" } libc = { version = "0.2", features = ["extra_traits"] } linux-raw-sys = { version = "0.12", features = ["auxvec", "elf", "if_ether", "ioctl", "net", "netlink", "no_std", "prctl", "system", "xdp"] } nix = { version = "0.31", features = ["net", "uio"] } nom-15128469a54ed75a = { package = "nom", version = "7" } quick-xml = { version = "0.41", features = ["overlapped-lists", "serialize"] } regex = { version = "1" } -rustc-hash = { version = "1" } rustix = { version = "1", features = ["event", "net", "param", "pipe", "process", "shm", "system", "termios", "thread", "time"] } rustls = { version = "0.23", default-features = false, features = ["aws-lc-rs", "aws_lc_rs"] } rustls-webpki = { version = "0.103", default-features = false, features = ["aws-lc-rs", "std"] } @@ -379,8 +379,7 @@ zerocopy = { version = "0.8", default-features = false, features = ["derive", "s [target.x86_64-pc-windows-msvc.dependencies] crossbeam-epoch = { version = "0.9" } flate2 = { version = "1", features = ["zlib-rs"] } -getrandom-468e82937335b1c9 = { package = "getrandom", version = "0.3", default-features = false, features = ["std"] } -getrandom-9fbad63c4bcf4a8f = { package = "getrandom", version = "0.4", default-features = false, features = ["std", "sys_rng"] } +getrandom = { version = "0.4", default-features = false, features = ["std", "sys_rng"] } half = { version = "2", default-features = false, features = ["num-traits"] } hyper-rustls = { version = "0.27", default-features = false, features = ["aws-lc-rs", "http1", "http2", "tls12"] } hyper-util = { version = "0.1", default-features = false, features = ["client-legacy", "client-proxy"] } @@ -400,8 +399,7 @@ zerocopy = { version = "0.8", default-features = false, features = ["derive", "s [target.x86_64-pc-windows-msvc.build-dependencies] crossbeam-epoch = { version = "0.9" } flate2 = { version = "1", features = ["zlib-rs"] } -getrandom-468e82937335b1c9 = { package = "getrandom", version = "0.3", default-features = false, features = ["std"] } -getrandom-9fbad63c4bcf4a8f = { package = "getrandom", version = "0.4", default-features = false, features = ["std", "sys_rng"] } +getrandom = { version = "0.4", default-features = false, features = ["std", "sys_rng"] } half = { version = "2", default-features = false, features = ["num-traits"] } hyper-rustls = { version = "0.27", default-features = false, features = ["aws-lc-rs", "http1", "http2", "tls12"] } hyper-util = { version = "0.1", default-features = false, features = ["client-legacy", "client-proxy"] } @@ -427,10 +425,11 @@ event-listener = { version = "5" } event-listener-strategy = { version = "0.5" } flate2 = { version = "1", features = ["zlib-rs"] } futures-io = { version = "0.3" } -getrandom-468e82937335b1c9 = { package = "getrandom", version = "0.3", default-features = false, features = ["std"] } +getrandom = { version = "0.4", default-features = false, features = ["std", "sys_rng"] } half = { version = "2", default-features = false, features = ["num-traits"] } hyper-rustls = { version = "0.27", default-features = false, features = ["aws-lc-rs", "http1", "http2", "tls12"] } hyper-util = { version = "0.1", default-features = false, features = ["client-legacy", "client-proxy"] } +itertools = { version = "0.13" } libc = { version = "0.2", features = ["extra_traits"] } linux-raw-sys = { version = "0.12", features = ["auxvec", "elf", "if_ether", "ioctl", "net", "netlink", "no_std", "prctl", "system", "xdp"] } nix = { version = "0.31", features = ["net", "uio"] } @@ -439,7 +438,6 @@ proc-macro2 = { version = "1" } quick-xml = { version = "0.41", features = ["overlapped-lists", "serialize"] } quote = { version = "1" } regex = { version = "1" } -rustc-hash = { version = "1" } rustix = { version = "1", features = ["event", "net", "param", "pipe", "process", "shm", "system", "termios", "thread", "time"] } rustls = { version = "0.23", default-features = false, features = ["aws-lc-rs", "aws_lc_rs"] } rustls-webpki = { version = "0.103", default-features = false, features = ["aws-lc-rs", "std"] } @@ -460,17 +458,17 @@ event-listener = { version = "5" } event-listener-strategy = { version = "0.5" } flate2 = { version = "1", features = ["zlib-rs"] } futures-io = { version = "0.3" } -getrandom-468e82937335b1c9 = { package = "getrandom", version = "0.3", default-features = false, features = ["std"] } +getrandom = { version = "0.4", default-features = false, features = ["std", "sys_rng"] } half = { version = "2", default-features = false, features = ["num-traits"] } hyper-rustls = { version = "0.27", default-features = false, features = ["aws-lc-rs", "http1", "http2", "tls12"] } hyper-util = { version = "0.1", default-features = false, features = ["client-legacy", "client-proxy"] } +itertools = { version = "0.13" } libc = { version = "0.2", features = ["extra_traits"] } linux-raw-sys = { version = "0.12", features = ["auxvec", "elf", "if_ether", "ioctl", "net", "netlink", "no_std", "prctl", "system", "xdp"] } nix = { version = "0.31", features = ["net", "uio"] } nom-15128469a54ed75a = { package = "nom", version = "7" } quick-xml = { version = "0.41", features = ["overlapped-lists", "serialize"] } regex = { version = "1" } -rustc-hash = { version = "1" } rustix = { version = "1", features = ["event", "net", "param", "pipe", "process", "shm", "system", "termios", "thread", "time"] } rustls = { version = "0.23", default-features = false, features = ["aws-lc-rs", "aws_lc_rs"] } rustls-webpki = { version = "0.103", default-features = false, features = ["aws-lc-rs", "std"] } From 66dcd076a5088db59974f609941b21cf02e5f839 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 7 Nov 2026 06:59:56 -0800 Subject: [PATCH 6/6] docs(quest): give the VA-API ladder test and VA-API codec gaps their owners Co-Authored-By: Claude Opus 5.5 --- quest/m4/vaapi-render-tests.md | 2 ++ quest/m5/video-codec-coverage.md | 4 ++-- sh/gh/test-inventory.allow | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/quest/m4/vaapi-render-tests.md b/quest/m4/vaapi-render-tests.md index 407e8a29cff..35d6fb69a41 100644 --- a/quest/m4/vaapi-render-tests.md +++ b/quest/m4/vaapi-render-tests.md @@ -13,6 +13,8 @@ return early without a device today (`vaapi_h264_round_trip` and `native_frames_still_answer_into_i420` in `rs/moq-video/src/decode/backend/vaapi.rs`) and moq-transcode's `vaapi_decoder_available` tests, which hosted CI reports as passed. +The ignored `vaapi_1080p_ladder_stays_on_the_gpu` encode test in +`rs/moq-video/src/encode/backend/vaapi.rs` runs there too. ## Plan diff --git a/quest/m5/video-codec-coverage.md b/quest/m5/video-codec-coverage.md index 4b46c55fba8..04d47db3ccf 100644 --- a/quest/m5/video-codec-coverage.md +++ b/quest/m5/video-codec-coverage.md @@ -13,8 +13,8 @@ and a portable software AV1 fallback such as OS, extension, hardware, format, and fixture requirements; a browser playing a codec is not proof that our native backend can open it. -NVIDIA AV1 encode/10-bit and VAAPI expansion already have quests. Keep those -owners. Software VP8/VP9 decode is libvpx behind moq-video's `vpx` feature; +NVIDIA AV1 encode/10-bit already has quests; keep those owners. VA-API gaps, +such as HEVC Main 10 decode, have no owner and are in scope here. Software VP8/VP9 decode is libvpx behind moq-video's `vpx` feature; hardware VP8/VP9 decode is in scope here. Windows NVIDIA support needs a demonstrated advantage over the existing native path. If revisiting software AV1 encoding, measure the target real-time workload and build cost rather than assuming all presets or diff --git a/sh/gh/test-inventory.allow b/sh/gh/test-inventory.allow index 4f9af5fcf4e..8564c5eb671 100644 --- a/sh/gh/test-inventory.allow +++ b/sh/gh/test-inventory.allow @@ -6,7 +6,7 @@ ignore moq-carla-bridge::gpu_video_reaches_the_worker /quest/m5/carla-bridge.md recipe carla::bridge-gpu /quest/m5/carla-bridge.md recipe rs::gpu /quest/m3/gpu-ci.md -ignore moq-video::encode::backend::vaapi::hardware_tests::vaapi_1080p_ladder_stays_on_the_gpu /quest/m3/gpu-ci.md +ignore moq-video::encode::backend::vaapi::hardware_tests::vaapi_1080p_ladder_stays_on_the_gpu /quest/m4/vaapi-render-tests.md ignore moq-video::frame::vulkan::tests::vulkan_gpu_device /quest/m3/gpu-ci.md ignore moq-video::frame::vulkan::tests::vulkan_cuda_slot_reuse_and_teardown /quest/m3/gpu-ci.md ignore moq-video::frame::cuda::tests::vulkan_cuda_auto_external_encode /quest/m3/gpu-ci.md