spdl.io.nv12_to_rgb

nv12_to_rgb(buffers: CUDABuffer, *, device_config: CUDAConfig, coeff: int = 1, sync: bool = False) CUDABuffer[source]

Given a batched CUDA buffer of NV12 images, convert them to (planar) RGB.

The pixel values are converted with the following formula;

┌ R ┐   ┌     ┐   ┌ Y - 16  ┐
│ G │ = │  M  │ * │ U - 128 │
└ B ┘   └     ┘   └ V - 128 ┘

The value of 3x3 matrix M can be changed with the argument coeff. By default, it uses BT709 conversion.

Parameters:
  • buffers – A batched buffer with shape [num_frames, H*1.5, W] where H*1.5 accounts for NV12 format.

  • device_config – Specifies the target CUDA device, and stream to use.

  • coeff

    Select the matrix coefficient used for color conversion. The following values are supported.

    • 1: BT709 (default)

    • 4: FCC

    • 5: BT470

    • 6: BT601

    • 7: SMPTE240M

    • 8: YCgCo

    • 9: BT2020

    • 10: BT2020C

    If other values are provided, they are silently mapped to 1.

  • sync – If True, the function waits for the completion after launching the kernel.

Returns:

A CUDA buffer object with the shape (num_frames, 3, height, width).