pub struct YuvUploadNode {
pub format: YuvFormat,
pub width: u32,
pub height: u32,
/* private fields */
}Expand description
Upload raw YUV plane buffers to the GPU and convert to RGBA in a fragment
shader, bypassing CPU-side sws_scale.
The node has input_count() = 0; it sources all pixel data from the plane
buffers set via YuvUploadNode::set_planes. Call set_planes once per
frame before the graph processes it.
Fields§
§format: YuvFormatPixel sub-sampling format.
width: u32Frame width in pixels.
height: u32Frame height in pixels.
Implementations§
Source§impl YuvUploadNode
impl YuvUploadNode
Sourcepub fn new(format: YuvFormat, width: u32, height: u32) -> Self
pub fn new(format: YuvFormat, width: u32, height: u32) -> Self
Create a new 8-bit node. Plane buffers are initialised to neutral values (Y = 0, Cb = Cr = 128).
Sourcepub fn new_high_bit_depth(format: YuvFormat, width: u32, height: u32) -> Self
pub fn new_high_bit_depth(format: YuvFormat, width: u32, height: u32) -> Self
Create a new 10-bit planar node. Plane buffers hold little-endian u16
samples (values 0..=1023) and render to an Rgba16Float target, so
10-bit precision survives the upload. Neutral init: Y = 0, Cb = Cr = 512.
Sourcepub fn new_p010(width: u32, height: u32) -> Self
pub fn new_p010(width: u32, height: u32) -> Self
Create a new 10-bit semi-planar (P010le) node: a full-resolution luma
plane plus one plane of interleaved Cb/Cr, both little-endian u16.
P010 is always 4:2:0, so there is no YuvFormat to choose. Its samples
are MSB-aligned — the 10 significant bits sit in the high bits of each
16-bit sample, with the low 6 zeroed — unlike
new_high_bit_depth, whose planes hold
0..=1023 in the low bits. Renders to an Rgba16Float target.
Neutral init: Y = 0, Cb = Cr = 512 (MSB-aligned).
Sourcepub fn set_planes(&mut self, y: Vec<u8>, cb: Vec<u8>, cr: Vec<u8>)
pub fn set_planes(&mut self, y: Vec<u8>, cb: Vec<u8>, cr: Vec<u8>)
Replace the stored plane buffers of a planar node (new or
new_high_bit_depth).
A semi-planar node (new_p010) reads neither cb nor
cr, and its interleaved plane keeps the neutral chroma the constructor
gave it — which is correctly sized, so no length check catches the
mistake and the frame renders greyscale rather than failing. Use
set_planes_semi_planar there.
Expected sizes for width × height at format, per sample:
- 8-bit: 1 byte; 10-bit (
new_high_bit_depth): 2 bytes (little-endianu16) y:width × heightsamplescb,cr:chroma_w × chroma_hsamples (sub-sampled perYuvFormat)
Sourcepub fn set_planes_semi_planar(&mut self, y: Vec<u8>, uv: Vec<u8>)
pub fn set_planes_semi_planar(&mut self, y: Vec<u8>, uv: Vec<u8>)
Replace the stored planes of a semi-planar node
(new_p010).
Both planes hold little-endian u16 samples (2 bytes each):
y:width × heightsamplesuv:chroma_w × chroma_h × 2samples — Cb and Cr interleaved, one pair per chroma pixel, souvholds twice as many samples as a single planar chroma plane would. This is the layoutff-formatgivesP010le(uv_stride = width × 2bytes overheight / 2rows).
Planes are expected dense (no row padding). A plane too short for the node’s dimensions is refused with a warning rather than read past its end.
The mirror of the trap in set_planes: a planar node
never reads uv, so calling this on one updates only the luma and leaves
the chroma at its neutral init, silently.
Trait Implementations§
Source§impl Default for YuvUploadNode
impl Default for YuvUploadNode
Source§impl RenderNode for YuvUploadNode
Available on crate feature wgpu only.
impl RenderNode for YuvUploadNode
wgpu only.