Files
VoelinClient/crates
selikhovandClaude Opus 5.5 189e0ad8c1 voelin-media: GPU frames for every simulcast layer, encoded from their surfaces
The streamer's zero-copy path needs the conversion and the encoding on
different threads: the captured buffer has to go back to the compositor
at once, while each layer's encoder runs on its own thread. So split
what encode_dmabuf did in one call:

- GpuConverter (ffmpeg/gpu.rs), on the capture thread: maps an RGB
  DMA-BUF onto a VA-API surface and converts it with VA-API video
  processing into an NV12 surface per layer that is due, the whole
  picture scaled to the layer's size and cropped to its encoder's
  alignment. The surfaces come from pools of our own and travel as
  GpuFrames, which are recycled once nothing holds them, so nothing is
  allocated per frame once the pools are warm. It also reports the tiled
  modifier the driver gives its own RGB surfaces, for the portal to offer.

- VideoEncoder::gpu_alignment and encode_gpu: VA-API encoders take a
  GpuFrame's surface as it is (the encoder references it until it is
  done); every other encoder says it takes none.

encode_dmabuf's RGB path now goes through the same converter instead of
a second copy of the import and conversion in the session.

Checked on the RX 7900 GRE: h264_vaapi encodes surfaces from a pool
other than its own; the scaled 640x352 layer is 48.5 dB against the CPU
pyramid's picture and the full one 40.4 dB (Y identical, chroma within
0.7); each layer's surface decodes through OpenH264; frames come back
once released; the driver's tiled RGB modifier is 0x200000028a01f04.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 07:33:30 +03:00
..