alpha2_native_gpu/import.rs
1//! Platform-neutral descriptions used while importing native image planes.
2
3/// Supported decoded plane organizations.
4#[derive(Copy, Clone, Debug, Eq, PartialEq)]
5pub enum NativePlaneLayout {
6 /// Three independent 8-bit R8 images.
7 I420,
8 /// 8-bit R8 luma plus one interleaved RG8 chroma image.
9 Nv12,
10 /// 10-bit R16 luma plus one interleaved RG16 chroma image, left-aligned in 16-bit
11 /// containers.
12 P010,
13}
14
15impl NativePlaneLayout {
16 /// Significant bits per component.
17 #[must_use]
18 pub const fn bit_depth(self) -> u8 {
19 match self {
20 Self::I420 | Self::Nv12 => 8,
21 Self::P010 => 10,
22 }
23 }
24
25 /// Bytes per coded pixel across all planes, as a numerator over 2.
26 #[must_use]
27 pub const fn bytes_per_pixel_numerator(self) -> u64 {
28 match self {
29 // 4:2:0 stores 1.5 samples per pixel; 10-bit doubles the container.
30 Self::I420 | Self::Nv12 => 3,
31 Self::P010 => 6,
32 }
33 }
34}
35
36/// One opaque native plane before it is wrapped by the active GPU backend.
37#[derive(Copy, Clone, Debug, Eq, PartialEq)]
38pub struct ImportedPlaneDescriptor {
39 /// Backend-native image handle.
40 pub image: u64,
41 /// Backend-native image format.
42 pub format: u32,
43 /// Plane width in samples.
44 pub width: u32,
45 /// Plane height in samples.
46 pub height: u32,
47}