Skip to main content

Module frame

Module frame 

Source
Expand description

Frame: one raw picture, and Surface: its pixels and where they live.

Representations chosen so the common path stays zero-copy:

  • Surface::PixelBuffer is an Apple CVPixelBuffer (IOSurface-backed NV12). Capture and the VideoToolbox decoder both produce it, and the VideoToolbox encoder consumes it directly, no copy and no color conversion.
  • Surface::Texture is a Windows Direct3D11 NV12 texture, produced by Media Foundation capture/decode and Windows.Graphics.Capture, one GPU blit removed from their pools (which they recycle, so a frame has to be lifted out of them), and consumed by the hardware encoder MFT on the same device with no copy at all, so a camera or a decoder reaches an encoder without touching the CPU. Drawing one still goes through into_i420, since the render module imports a PixelBuffer but has no Direct3D11 path yet.
  • Surface::DmaBuf is a Linux DRM allocation, produced by PipeWire capture. The Vulkan renderer imports supported packed formats directly, while CPU consumers map linear allocations only.
  • Surface::Vulkan is an external Linux Vulkan image with an explicit timeline semaphore. Encoders import and convert it on its device, with no CPU download fallback, then return its producer slot after GPU completion.
  • Surface::HardwareBuffer is an Android AHardwareBuffer, produced by the MediaCodec decoder rendering into an ImageReader. A GPU consumer imports it as a GL or Vulkan image; into_i420 reads the planes back instead.
  • Surface::I420 is CPU-resident planar I420, for the CPU encode path and platforms without a zero-copy capture.

A backend that consumes a GPU surface takes the frame as-is; a CPU encoder asks for I420 via Surface::into_i420, which downloads GPU frames that permit readback. External Vulkan surfaces intentionally refuse that fallback.

Modules§

cuda
Linux CUDA device memory: the NV12 Frame behind Surface::Cuda, which NVDEC or a Converter produces and NVENC scales into its own input on the GPU.
vulkan
External Vulkan images and their producer-owned reuse slots.

Structs§

DmaBuf
A Linux DMA-BUF surface with an on-demand exported descriptor.
DmaBufExport
An exported Linux DMA-BUF descriptor and its producer lease.
DmaBufPlane
One plane within a Linux DMA-BUF allocation.
DrmFormat
A DRM pixel format code carried by a Linux DMA-BUF.
Frame
One raw (uncompressed) video frame: the pixels plus when they are shown.
I420
A raw video frame in planar I420 (YUV 4:2:0), tightly packed (no padding), at the encoder resolution. Width and height are even (chroma is 2x2).

Enums§

Surface
Where a frame’s pixels currently live.