Skip to main content

YuvUploadNode

Struct YuvUploadNode 

Source
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: YuvFormat

Pixel sub-sampling format.

§width: u32

Frame width in pixels.

§height: u32

Frame height in pixels.

Implementations§

Source§

impl YuvUploadNode

Source

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).

Source

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.

Source

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).

Source

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-endian u16)
  • y: width × height samples
  • cb, cr: chroma_w × chroma_h samples (sub-sampled per YuvFormat)
Source

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 × height samples
  • uv: chroma_w × chroma_h × 2 samples — Cb and Cr interleaved, one pair per chroma pixel, so uv holds twice as many samples as a single planar chroma plane would. This is the layout ff-format gives P010le (uv_stride = width × 2 bytes over height / 2 rows).

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

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl RenderNode for YuvUploadNode

Available on crate feature wgpu only.
Source§

fn input_count(&self) -> usize

Number of input textures required by this node (default: 1).
Source§

fn process( &self, _inputs: &[&Texture], outputs: &[&Texture], ctx: &RenderContext, )

Run the GPU render pass. Read more
Source§

fn pass_count(&self) -> usize

Number of render passes (default: 1). Multi-pass nodes (e.g. gaussian blur) return 2 or more.
Source§

fn output_dimensions(&self, in_w: u32, in_h: u32) -> (u32, u32)

Output dimensions this node produces given its input dimensions. Read more
Source§

fn set_param(&self, _param: NodeParam) -> bool

Applies param to this node in place, returning whether it was taken. Read more
Source§

impl RenderNodeCpu for YuvUploadNode

Source§

fn process_cpu(&self, rgba: &mut [u8], w: u32, h: u32)

Process rgba in-place. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,