#[non_exhaustive]pub enum PixelFormat {
I420,
I422,
I444,
Nv12,
P010,
Rgba8,
Bgra8,
}Expand description
How the samples are laid out.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
I420
Planar Y, U, V with chroma at half width and half height. What almost every consumer video decodes to.
I422
Planar, chroma at half width and full height.
I444
Planar, chroma at full resolution.
Nv12
Y plane then interleaved UV, half width and half height. What the hardware decoders hand back.
P010
NV12 at 10 bits, each sample in the top bits of a 16-bit word.
Rgba8
Packed 8-bit RGBA. Still images, and anything already converted.
Bgra8
Packed 8-bit BGRA, which is what several platform surfaces want.
Implementations§
Source§impl PixelFormat
impl PixelFormat
Sourcepub fn plane_count(self) -> usize
pub fn plane_count(self) -> usize
How many separately-addressed planes there are.
Sourcepub fn bytes_per_sample(self) -> usize
pub fn bytes_per_sample(self) -> usize
Bytes each sample occupies, which is not the same as its bit depth: a 10-bit sample is stored in two bytes.
Sourcepub fn chroma_shift(self) -> (u32, u32)
pub fn chroma_shift(self) -> (u32, u32)
How far chroma is subsampled, as right-shifts of the luma dimensions.
(1, 1) for 4:2:0 — half width, half height. (0, 0) for anything with
full-resolution colour.
Sourcepub fn plane_dimensions(
self,
plane: usize,
width: u32,
height: u32,
) -> Option<(u32, u32)>
pub fn plane_dimensions( self, plane: usize, width: u32, height: u32, ) -> Option<(u32, u32)>
The size of one plane in samples, for a picture of this size.
Chroma dimensions round up: a 1921-pixel-wide 4:2:0 picture has 961 chroma columns, not 960, and rounding down loses the last one.
Sourcepub fn samples_per_pixel(self, plane: usize) -> usize
pub fn samples_per_pixel(self, plane: usize) -> usize
Samples per pixel within one plane: 4 for packed RGBA, 2 for NV12’s interleaved chroma, 1 for a planar plane.
Sourcepub fn tight_stride(self, plane: usize, width: u32) -> usize
pub fn tight_stride(self, plane: usize, width: u32) -> usize
The tightest stride for a plane — no padding at all.