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 comes first, then separate U and V planes or one interleaved UV plane, each
ceil(width / 2^chroma_shift_x) by ceil(height / 2^chroma_shift_y). Samples over eight
bits are little-endian u16. With alpha, a straight full-range alpha plane
at luma size and depth follows.
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 samples sit in the high bits of their u16 (P010) rather than the low bits
(yuv420p10le).
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 subsampling of at most four per axis, and high alignment only below 16 bits.
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, alpha included.
Sourcepub const fn color_plane_count(self) -> usize
pub const fn color_plane_count(self) -> usize
Number of luma and chroma planes; the alpha plane, if any, follows them.