pub struct I420 { /* private fields */ }Expand description
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).
Implementations§
Source§impl I420
impl I420
Sourcepub fn new(size: Size, data: Vec<u8>) -> Result<Self, Error>
pub fn new(size: Size, data: Vec<u8>) -> Result<Self, Error>
Wrap tightly-packed I420 planes: Y (width * height), then U, then V
(width/2 * height/2 each), no row padding.
Both dimensions must be even and non-zero (4:2:0 chroma is 2x2), and data
must be exactly I420::len bytes. Checked here so a short buffer can’t
reach a plane split and panic downstream.
Sourcepub fn color(&self) -> Option<Color>
pub fn color(&self) -> Option<Color>
The color space these samples are in, or None when the crate does not
know: the pixels came out of a decoder or a camera, and the bitstream’s
color description did not travel with them.
Anything converting these samples to RGB needs an answer either way, so
treat None as “fall back to Color::infer” rather than “does not
matter”. Use with_color if you know better.
Sourcepub fn with_color(self, color: Color) -> Self
pub fn with_color(self, color: Color) -> Self
Declare the color space of these samples, for a caller who knows it (the stream’s VUI, a camera’s documented output) where the crate cannot.