#[non_exhaustive]#[repr(u16)]pub enum PixelFormat {
Show 41 variants
Yuv420P = 0,
Yuv422P = 1,
Yuv444P = 2,
Rgb24 = 3,
Rgba = 4,
Gray8 = 5,
Pal8 = 6,
Bgr24 = 7,
Bgra = 8,
Argb = 9,
Abgr = 10,
Rgb48Le = 11,
Rgba64Le = 12,
Gray16Le = 13,
Gray10Le = 14,
Gray12Le = 15,
Yuv420P10Le = 16,
Yuv422P10Le = 17,
Yuv444P10Le = 18,
Yuv420P12Le = 19,
Yuv422P12Le = 20,
Yuv444P12Le = 21,
YuvJ420P = 22,
YuvJ422P = 23,
YuvJ444P = 24,
Nv12 = 25,
Nv21 = 26,
Ya8 = 27,
Yuva420P = 28,
MonoBlack = 29,
MonoWhite = 30,
Yuyv422 = 31,
Uyvy422 = 32,
Cmyk = 33,
Yuv411P = 34,
Gbrp10Le = 35,
Gbrap10Le = 36,
Gbrp12Le = 37,
Gbrap12Le = 38,
Gbrp14Le = 39,
Gbrap14Le = 40,
}Expand description
Video pixel format.
Variants carry stable explicit discriminants — the integer value
of PixelFormat::Yuv420P as u16 is part of the public ABI. Add new
variants only at the end with a fresh number; never reorder, renumber,
or remove. #[non_exhaustive] lets the enum grow without breaking
downstream match statements; pinned discriminants additionally let
the format round-trip through any byte-stable serialization
(config files, capability blobs, IPC, on-disk caches) without losing
meaning across crate versions, and prevent inserts in the middle of
the enum from shifting every later variant’s number (which
cargo-semver-checks rightly flags as a breaking change).
The first six variants (Yuv420P through Gray8) are the original
formats produced by the early codec crates. Everything beyond that
is additional surface handled by oxideav-pixfmt and the still-image
codecs (PNG, GIF, still-JPEG).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Yuv420P = 0
8-bit YUV 4:2:0, planar (Y, U, V).
Yuv422P = 1
8-bit YUV 4:2:2, planar.
Yuv444P = 2
8-bit YUV 4:4:4, planar.
Rgb24 = 3
Packed 8-bit RGB, 3 bytes/pixel.
Rgba = 4
Packed 8-bit RGBA, 4 bytes/pixel.
Gray8 = 5
Packed 8-bit grayscale.
Pal8 = 6
8-bit palette indices — companion palette carried out of band.
Bgr24 = 7
Packed 8-bit BGR, 3 bytes/pixel.
Bgra = 8
Packed 8-bit BGRA, 4 bytes/pixel.
Argb = 9
Packed 8-bit ARGB, 4 bytes/pixel (alpha first).
Abgr = 10
Packed 8-bit ABGR, 4 bytes/pixel.
Rgb48Le = 11
Packed 16-bit-per-channel RGB, little-endian, 6 bytes/pixel.
Rgba64Le = 12
Packed 16-bit-per-channel RGBA, little-endian, 8 bytes/pixel.
Gray16Le = 13
16-bit little-endian grayscale.
Gray10Le = 14
10-bit grayscale in a 16-bit little-endian word.
Gray12Le = 15
12-bit grayscale in a 16-bit little-endian word.
Yuv420P10Le = 16
10-bit YUV 4:2:0 planar, little-endian 16-bit storage.
Yuv422P10Le = 17
10-bit YUV 4:2:2 planar, little-endian 16-bit storage.
Yuv444P10Le = 18
10-bit YUV 4:4:4 planar, little-endian 16-bit storage.
Yuv420P12Le = 19
12-bit YUV 4:2:0 planar, little-endian 16-bit storage.
Yuv422P12Le = 20
12-bit YUV 4:2:2 planar, little-endian 16-bit storage.
Yuv444P12Le = 21
12-bit YUV 4:4:4 planar, little-endian 16-bit storage.
YuvJ420P = 22
JPEG/full-range YUV 4:2:0 planar.
YuvJ422P = 23
JPEG/full-range YUV 4:2:2 planar.
YuvJ444P = 24
JPEG/full-range YUV 4:4:4 planar.
Nv12 = 25
YUV 4:2:0, planar Y + interleaved UV (NV12).
Nv21 = 26
YUV 4:2:0, planar Y + interleaved VU (NV21).
Ya8 = 27
Packed grayscale + alpha, 2 bytes/pixel (Y, A).
Yuva420P = 28
Yuv420P with an additional full-resolution alpha plane.
MonoBlack = 29
1 bit per pixel, packed MSB-first, 0 = black.
MonoWhite = 30
1 bit per pixel, packed MSB-first, 0 = white.
Yuyv422 = 31
Packed 4:2:2, byte order Y0 U0 Y1 V0.
Uyvy422 = 32
Packed 4:2:2, byte order U0 Y0 V0 Y1.
Cmyk = 33
Packed 8-bit CMYK, 4 bytes/pixel in byte order C, M, Y, K.
“Regular” convention: C=0 means no cyan ink (white), C=255 means
full cyan. Used by JPEG 4-component scans from non-Adobe encoders
and by many print-side image toolchains. Adobe Photoshop’s
inverted CMYK (where 0 = full ink) is a separate variant reserved
for a future CmykInverted.
Yuv411P = 34
8-bit YUV 4:1:1, planar (Y, U, V). Luma at full resolution; chroma horizontally subsampled by 4 (each chroma sample covers a 4×1 luma block), no vertical subsampling. Native sampling of NTSC DV-25 and a legal JPEG sampling layout (luma H=4, V=1; chroma H=V=1) emitted by some real-world JPEG corpora.
Gbrp10Le = 35
10-bit planar GBR, little-endian 16-bit storage. 3 planes ordered G, B, R; each sample uses the low 10 bits of a 16-bit word.
Gbrap10Le = 36
10-bit planar GBR + alpha, little-endian 16-bit storage. 4 planes ordered G, B, R, A; each sample uses the low 10 bits of a 16-bit word.
Gbrp12Le = 37
12-bit planar GBR, little-endian 16-bit storage. 3 planes ordered G, B, R; each sample uses the low 12 bits of a 16-bit word.
Gbrap12Le = 38
12-bit planar GBR + alpha, little-endian 16-bit storage. 4 planes ordered G, B, R, A; each sample uses the low 12 bits of a 16-bit word.
Gbrp14Le = 39
14-bit planar GBR, little-endian 16-bit storage. 3 planes ordered G, B, R; each sample uses the low 14 bits of a 16-bit word.
Gbrap14Le = 40
14-bit planar GBR + alpha, little-endian 16-bit storage. 4 planes ordered G, B, R, A; each sample uses the low 14 bits of a 16-bit word.
Implementations§
Source§impl PixelFormat
impl PixelFormat
Sourcepub fn is_palette(&self) -> bool
pub fn is_palette(&self) -> bool
True if the format is a palette index format (Pal8).
Sourcepub fn plane_count(&self) -> usize
pub fn plane_count(&self) -> usize
Number of planes in the stored layout. Packed and palette formats
return 1; NV12/NV21 return 2; planar YUV without alpha and the
Gbrp* variants return 3; YuvA and Gbrap* variants return 4.
Sourcepub fn bits_per_pixel_approx(&self) -> u32
pub fn bits_per_pixel_approx(&self) -> u32
Rough bits-per-pixel estimate, useful for buffer sizing. Not exact for chroma-subsampled YUV — intended for worst-case preallocation rather than wire-accurate accounting.
Trait Implementations§
Source§impl Clone for PixelFormat
impl Clone for PixelFormat
Source§fn clone(&self) -> PixelFormat
fn clone(&self) -> PixelFormat
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PixelFormat
Source§impl Debug for PixelFormat
impl Debug for PixelFormat
impl Eq for PixelFormat
Source§impl Hash for PixelFormat
impl Hash for PixelFormat
Source§impl PartialEq for PixelFormat
impl PartialEq for PixelFormat
Source§fn eq(&self, other: &PixelFormat) -> bool
fn eq(&self, other: &PixelFormat) -> bool
self and other values to be equal, and is used by ==.