spdl.io.nv12_to_rgb¶
- nv12_to_rgb(buffers: list[CUDABuffer], *, device_config: CUDAConfig, coeff: int = 1, sync: bool = False) CUDABuffer[source]¶
Given CUDA buffers of NV12 images, batch and convert them to (interleaved) 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
Mcan be changed with the argumentcoeff. By default, it uses BT709 conversion.- Parameters:
buffers – A list of buffers. The size of images must be same. Since it’s NV12 format, the expected input size is
(H + H/2, W).device_config – Secifies 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: FCC5: BT4706: BT6017: SMPTE240M8: YCgCo9: BT202010: 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
(batch, height, width, color=3).