Skip to main content

PlaneDescriptor

Struct PlaneDescriptor 

Source
pub struct PlaneDescriptor {
    pub semantic: PlaneSemantic,
    pub channel_type: ChannelType,
    pub h_subsample: u8,
    pub v_subsample: u8,
}
Expand description

Metadata describing a single plane in a multi-plane image.

This is a pure descriptor — no pixel data, no heap allocation. Subsample factors are explicit per-plane rather than inferred from dimension ratios, because strip-based pipelines don’t carry global image dimensions.

§Examples

use zenpixels::{PlaneDescriptor, PlaneSemantic, ChannelType};

let luma = PlaneDescriptor::new(PlaneSemantic::Luma, ChannelType::F32);
assert!(!luma.is_subsampled());
assert_eq!(luma.plane_width(1920), 1920);

let chroma = PlaneDescriptor::new(PlaneSemantic::ChromaCb, ChannelType::F32)
    .with_subsampling(2, 2); // 4:2:0
assert!(chroma.is_subsampled());
assert_eq!(chroma.plane_width(1920), 960);
assert_eq!(chroma.plane_height(1080), 540);

Fields§

§semantic: PlaneSemantic

What this plane represents.

§channel_type: ChannelType

Storage type for each sample in this plane.

§h_subsample: u8

Horizontal subsampling factor (1 = full resolution, 2 = half, 4 = quarter).

§v_subsample: u8

Vertical subsampling factor (1 = full resolution, 2 = half).

Implementations§

Source§

impl PlaneDescriptor

Source

pub const fn new( semantic: PlaneSemantic, channel_type: ChannelType, ) -> PlaneDescriptor

Create a full-resolution plane descriptor (no subsampling).

Source

pub const fn with_subsampling(self, h: u8, v: u8) -> PlaneDescriptor

Builder: set subsampling factors.

§Panics

Debug-asserts that h and v are non-zero powers of two.

Source

pub const fn plane_width(&self, ref_width: u32) -> u32

Compute the width of this plane given a reference (luma) width.

Uses ceiling division so subsampled planes always cover the full image.

Robustness: h_subsample is a public field, so a struct-literal write or a codec mapping an out-of-range subsampling code to factor 0 can leave the divisor at 0 — which would panic the div_ceil in release. We saturate the divisor at 1 here so production servers never see a divide-by-zero abort; the with_subsampling builder’s debug_assert! still catches the misuse in dev/test.

Source

pub const fn plane_height(&self, ref_height: u32) -> u32

Compute the height of this plane given a reference (luma) height.

Uses ceiling division so subsampled planes always cover the full image.

Robustness: see plane_width — same div-by-zero guard for v_subsample.

Source

pub const fn is_subsampled(&self) -> bool

Whether this plane is subsampled (either axis).

Source

pub const fn bytes_per_sample(&self) -> usize

Bytes per sample in this plane.

Trait Implementations§

Source§

impl Clone for PlaneDescriptor

Source§

fn clone(&self) -> PlaneDescriptor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PlaneDescriptor

Source§

impl Debug for PlaneDescriptor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for PlaneDescriptor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for PlaneDescriptor

Source§

impl Hash for PlaneDescriptor

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for PlaneDescriptor

Source§

fn eq(&self, other: &PlaneDescriptor) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PlaneDescriptor

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.