Skip to main content

PlanarBuf

Struct PlanarBuf 

Source
pub struct PlanarBuf { /* private fields */ }
Expand description

Full re-export of zenpixels core types (zero module name collisions!). Multi-plane image (YCbCr 4:2:0/4:2:2/4:4:4, NV12, P010, planar RGB+A, planar CMYKA, JXL/TIFF extra planes).

Implementations§

Source§

impl PlanarBuf

Source

pub const MAX_PLANES: usize = 64

Maximum plane count (64) supported in a single PlanarBuf.

Source

pub fn try_clone(&self) -> Result<PlanarBuf, At<BufferError>>

Fallibly clone this multi-plane buffer, preserving sample alignment on every plane.

Source

pub fn new( width: u32, height: u32, plane_formats: &[PlaneFormat], ) -> Result<PlanarBuf, At<BufferError>>

Fallibly allocate a zero-filled multi-plane buffer for plane_formats (1..=64 planes).

Source

pub fn new_aligned( width: u32, height: u32, plane_formats: &[PlaneFormat], align: RowAlign, ) -> Result<PlanarBuf, At<BufferError>>

Fallibly allocate a zero-filled multi-plane buffer for plane_formats (1..=64 planes) with explicit per-plane RowAlign (Tight, Cache64, PixelCache64, Samples(n)).

Source

pub fn from_planes( width: u32, height: u32, planes: Vec<PlaneBuf>, ) -> Result<PlanarBuf, At<BufferError>>

Construct a validated PlanarBuf adopting caller-owned planes zero-copy (1..=64 planes).

Color, chroma, and alpha planes must match plane_dimensions_for_frame(width, height); auxiliary planes (PlaneRole::is_auxiliary: GainMap, Depth, Matte, Thermal, Extra) may carry arbitrary independent positive dimensions.

Source

pub const fn width(&self) -> u32

Frame width in pixels.

Source

pub const fn height(&self) -> u32

Frame height in rows.

Source

pub const fn chroma_siting(&self) -> ChromaSiting

Chroma sample siting for subsampled planes.

Source

pub const fn with_chroma_siting(self, siting: ChromaSiting) -> PlanarBuf

Set chroma sample siting for subsampled planes.

Source

pub fn color(&self) -> Option<&ColorSpace>

Optional color interpretation (target RGB/Gray/CMYK/ICC color space of these planes).

Source

pub fn with_color(self, color: ColorSpace) -> PlanarBuf

Attach color interpretation (primaries, transfer, range, alpha) to this planar buffer.

Source

pub const fn matrix_coefficients(&self) -> Option<MatrixCoefficients>

Optional ITU-T H.273 MatrixCoefficients (BT709, BT601, BT2020_NCL, IDENTITY, etc.).

Source

pub const fn with_matrix_coefficients( self, matrix: MatrixCoefficients, ) -> PlanarBuf

Attach ITU-T H.273 MatrixCoefficients for YCbCr/GBR planes.

Source

pub const fn range_override(&self) -> Option<SignalRange>

Explicit signal range override (Full or Narrow), if set separately from color.

Prefer effective_range when reading the active range.

Source

pub fn effective_range(&self) -> Option<SignalRange>

Effective signal range, checking range_override first and falling back to color’s range.

Source

pub const fn with_range_override(self, range: SignalRange) -> PlanarBuf

Attach an explicit signal range override (Full or Narrow).

Source

pub const fn alpha_override(&self) -> Option<AlphaMode>

Explicit alpha association override for an attached alpha plane, if set separately from color.

Prefer effective_alpha when reading the active alpha mode.

Source

pub fn effective_alpha(&self) -> Option<AlphaMode>

Plane-aware effective alpha association mode.

Returns None when no PlaneRole::Alpha (or PlaneRole::Packed) plane is present. Otherwise checks alpha_override first and falls back to color’s alpha mode, ignoring AlphaMode::None / AlphaMode::Undefined.

Source

pub const fn with_alpha_override(self, alpha: AlphaMode) -> PlanarBuf

Attach an explicit alpha association override (e.g. AlphaMode::Straight or AlphaMode::Premultiplied).

Source

pub fn planes(&self) -> &[PlaneBuf]

Immutable slice of planes.

Source

pub fn into_planes(self) -> Vec<PlaneBuf>

Consume this planar buffer and return its owned planes zero-copy.

Source

pub fn plane_view_mut(&mut self, index: usize) -> Option<PlaneViewMut<'_>>

Borrow plane index mutably as a PlaneViewMut without allowing structural replacement.

Source

pub fn plane_by_role(&self, role: PlaneRole) -> Option<&PlaneBuf>

Look up the first owned plane matching role (e.g. PlaneRole::Y, PlaneRole::CbCr).

Source

pub fn plane_view_by_role(&self, role: PlaneRole) -> Option<PlaneView<'_>>

Borrow the first plane matching role as an immutable PlaneView.

Source

pub fn plane_view_mut_by_role( &mut self, role: PlaneRole, ) -> Option<PlaneViewMut<'_>>

Borrow the first plane matching role mutably as a PlaneViewMut.

Source

pub fn hdr(&self) -> HdrMetadata

Descriptive HDR metadata.

Source

pub fn hdr_ref(&self) -> Option<&HdrMetadata>

Zero-copy reference to attached non-empty HDR metadata (None if empty/unset).

Source

pub fn with_hdr(self, hdr: HdrMetadata) -> PlanarBuf

Attach descriptive HDR metadata.

Source

pub fn origin(&self) -> &ColorOrigin

Original container provenance.

Source

pub fn with_origin(self, origin: ColorOrigin) -> PlanarBuf

Attach original container provenance.

Source

pub const fn orientation(&self) -> Orientation

Pending EXIF display orientation attached to this planar buffer.

Source

pub const fn display_dimensions(&self) -> (u32, u32)

Display-oriented (width, height) after applying orientation.

Source

pub const fn with_orientation(self, orientation: Orientation) -> PlanarBuf

Replace pending EXIF display orientation.

Source

pub fn set_orientation(&mut self, orientation: Orientation)

Set pending EXIF display orientation in place.

Source

pub const fn compose_orientation(self, delta: Orientation) -> PlanarBuf

Compose an additional display transform onto pending orientation in O(1).

Source§

impl PlanarBuf

Source

pub fn as_view(&self) -> PlanarView<'_>

Borrow all planes as a PlanarView (zero-allocation for <= 4 planes).

Source

pub fn try_as_view(&self) -> Result<PlanarView<'_>, At<BufferError>>

Fallibly borrow all planes as a PlanarView (zero-allocation for <= 4 planes).

Source

pub fn crop_view( &self, rect: PixelRect, ) -> Result<PlanarView<'_>, At<BufferError>>

Borrow a zero-copy rectangular crop of all planes preserving exact parent-frame chroma phase (zero heap allocation for <= 4 planes).

Source

pub fn as_view_mut(&mut self) -> PlanarViewMut<'_>

Borrow all planes mutably as a PlanarViewMut (zero-allocation for <= 4 planes).

Source

pub fn try_cow_view_mut(&mut self) -> Result<PlanarViewMut<'_>, At<BufferError>>

Fallibly borrow all planes mutably as a PlanarViewMut, performing active-extent copy-on-write promotion on immutable external planes without panicking on OOM (zero heap allocation for <= 4 owned/mutable planes).

Source

pub fn crop_view_mut( &mut self, rect: PixelRect, ) -> Result<PlanarViewMut<'_>, At<BufferError>>

Borrow a zero-copy mutable rectangular crop of all planes preserving exact parent-frame chroma phase, fallibly copy-on-write promoting immutable external planes if needed (zero heap allocation for <= 4 planes).

Source§

impl PlanarBuf

Source

pub fn hash_with(&self, inclusions: HashInclusions) -> u64

Compute a portable, endian- and stride-independent XXH3 fingerprint of this planar buffer.

Trait Implementations§

Source§

impl Clone for PlanarBuf

Source§

fn clone(&self) -> PlanarBuf

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 Debug for PlanarBuf

Source§

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

Formats the value using the given formatter. Read more

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, 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.