pub struct YuvFormat {
pub chroma_shift_x: u8,
pub chroma_shift_y: u8,
pub bit_depth: u8,
pub interleaved_chroma: bool,
pub msb_aligned: bool,
pub alpha: bool,
}Expand description
How a planar or semi-planar YCbCr frame stores its samples.
Luma is always the first plane. Chroma follows as separate U and V planes,
or as one plane of interleaved U, V pairs. Each chroma plane covers
ceil(width / 2^chroma_shift_x) by ceil(height / 2^chroma_shift_y)
samples. A sample of more than eight bits is a little-endian u16. A
format with alpha stores one more plane after the
chroma: straight, full-range alpha at the luma’s size and depth.
Fields§
§chroma_shift_x: u8Log2 of the horizontal chroma subsampling: 0 for 4:4:4, 1 for 4:2:x.
chroma_shift_y: u8Log2 of the vertical chroma subsampling: 1 for 4:2:0, 0 otherwise.
bit_depth: u8Significant bits per sample, 8 through 16.
interleaved_chroma: boolWhether U and V interleave in one plane, as NV12 and P010 do.
msb_aligned: boolWhether a sample of fewer than 16 bits sits in the high bits of its
u16, as P010’s do, rather than the low bits, as yuv420p10le’s do.
alpha: boolWhether an alpha plane follows the chroma, as yuva444p16le’s does.
Implementations§
Source§impl YuvFormat
impl YuvFormat
Sourcepub const fn planar(
chroma_shift_x: u8,
chroma_shift_y: u8,
bit_depth: u8,
) -> Self
pub const fn planar( chroma_shift_x: u8, chroma_shift_y: u8, bit_depth: u8, ) -> Self
Planar YCbCr with low-aligned samples.
Sourcepub const fn with_alpha(self) -> Self
pub const fn with_alpha(self) -> Self
The same format with an alpha plane after the chroma.
Sourcepub const fn is_supported(self) -> bool
pub const fn is_supported(self) -> bool
Whether the renderer can sample this format: 8 to 16 bits, chroma subsampled by at most four on either axis, and high alignment only where there are spare bits to align in.
Sourcepub const fn bytes_per_sample(self) -> u32
pub const fn bytes_per_sample(self) -> u32
Bytes each stored sample takes: one up to 8 bits, two above.
Sourcepub const fn plane_count(self) -> usize
pub const fn plane_count(self) -> usize
Number of stored planes: luma and chroma (three, or two with interleaved chroma), then alpha when the format has it.
Sourcepub const fn color_plane_count(self) -> usize
pub const fn color_plane_count(self) -> usize
Number of planes that hold luma and chroma: three, or two with interleaved chroma. The alpha plane, if any, is the one after them.