pub struct PlanarBuf { /* private fields */ }Expand description
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
impl PlanarBuf
Sourcepub const MAX_PLANES: usize = 64
pub const MAX_PLANES: usize = 64
Maximum plane count (64) supported in a single PlanarBuf.
Sourcepub fn try_clone(&self) -> Result<PlanarBuf, At<BufferError>>
pub fn try_clone(&self) -> Result<PlanarBuf, At<BufferError>>
Fallibly clone this multi-plane buffer, preserving sample alignment on every plane.
Sourcepub fn new(
width: u32,
height: u32,
plane_formats: &[PlaneFormat],
) -> Result<PlanarBuf, At<BufferError>>
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).
Sourcepub fn new_aligned(
width: u32,
height: u32,
plane_formats: &[PlaneFormat],
align: RowAlign,
) -> Result<PlanarBuf, At<BufferError>>
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)).
Sourcepub fn from_planes(
width: u32,
height: u32,
planes: Vec<PlaneBuf>,
) -> Result<PlanarBuf, At<BufferError>>
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.
Sourcepub const fn chroma_siting(&self) -> ChromaSiting
pub const fn chroma_siting(&self) -> ChromaSiting
Chroma sample siting for subsampled planes.
Sourcepub const fn with_chroma_siting(self, siting: ChromaSiting) -> PlanarBuf
pub const fn with_chroma_siting(self, siting: ChromaSiting) -> PlanarBuf
Set chroma sample siting for subsampled planes.
Sourcepub fn color(&self) -> Option<&ColorSpace>
pub fn color(&self) -> Option<&ColorSpace>
Optional color interpretation (target RGB/Gray/CMYK/ICC color space of these planes).
Sourcepub fn with_color(self, color: ColorSpace) -> PlanarBuf
pub fn with_color(self, color: ColorSpace) -> PlanarBuf
Attach color interpretation (primaries, transfer, range, alpha) to this planar buffer.
Sourcepub const fn matrix_coefficients(&self) -> Option<MatrixCoefficients>
pub const fn matrix_coefficients(&self) -> Option<MatrixCoefficients>
Optional ITU-T H.273 MatrixCoefficients (BT709, BT601, BT2020_NCL, IDENTITY, etc.).
Sourcepub const fn with_matrix_coefficients(
self,
matrix: MatrixCoefficients,
) -> PlanarBuf
pub const fn with_matrix_coefficients( self, matrix: MatrixCoefficients, ) -> PlanarBuf
Attach ITU-T H.273 MatrixCoefficients for YCbCr/GBR planes.
Sourcepub const fn range_override(&self) -> Option<SignalRange>
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.
Sourcepub fn effective_range(&self) -> Option<SignalRange>
pub fn effective_range(&self) -> Option<SignalRange>
Effective signal range, checking range_override first and falling
back to color’s range.
Sourcepub const fn with_range_override(self, range: SignalRange) -> PlanarBuf
pub const fn with_range_override(self, range: SignalRange) -> PlanarBuf
Attach an explicit signal range override (Full or Narrow).
Sourcepub const fn alpha_override(&self) -> Option<AlphaMode>
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.
Sourcepub fn effective_alpha(&self) -> Option<AlphaMode>
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.
Sourcepub const fn with_alpha_override(self, alpha: AlphaMode) -> PlanarBuf
pub const fn with_alpha_override(self, alpha: AlphaMode) -> PlanarBuf
Attach an explicit alpha association override (e.g. AlphaMode::Straight or AlphaMode::Premultiplied).
Sourcepub fn into_planes(self) -> Vec<PlaneBuf>
pub fn into_planes(self) -> Vec<PlaneBuf>
Consume this planar buffer and return its owned planes zero-copy.
Sourcepub fn plane_view_mut(&mut self, index: usize) -> Option<PlaneViewMut<'_>>
pub fn plane_view_mut(&mut self, index: usize) -> Option<PlaneViewMut<'_>>
Borrow plane index mutably as a PlaneViewMut without allowing structural replacement.
Sourcepub fn plane_by_role(&self, role: PlaneRole) -> Option<&PlaneBuf>
pub fn plane_by_role(&self, role: PlaneRole) -> Option<&PlaneBuf>
Look up the first owned plane matching role (e.g. PlaneRole::Y, PlaneRole::CbCr).
Sourcepub fn plane_view_by_role(&self, role: PlaneRole) -> Option<PlaneView<'_>>
pub fn plane_view_by_role(&self, role: PlaneRole) -> Option<PlaneView<'_>>
Borrow the first plane matching role as an immutable PlaneView.
Sourcepub fn plane_view_mut_by_role(
&mut self,
role: PlaneRole,
) -> Option<PlaneViewMut<'_>>
pub fn plane_view_mut_by_role( &mut self, role: PlaneRole, ) -> Option<PlaneViewMut<'_>>
Borrow the first plane matching role mutably as a PlaneViewMut.
Sourcepub fn hdr(&self) -> HdrMetadata
pub fn hdr(&self) -> HdrMetadata
Descriptive HDR metadata.
Sourcepub fn hdr_ref(&self) -> Option<&HdrMetadata>
pub fn hdr_ref(&self) -> Option<&HdrMetadata>
Zero-copy reference to attached non-empty HDR metadata (None if empty/unset).
Sourcepub fn with_hdr(self, hdr: HdrMetadata) -> PlanarBuf
pub fn with_hdr(self, hdr: HdrMetadata) -> PlanarBuf
Attach descriptive HDR metadata.
Sourcepub fn origin(&self) -> &ColorOrigin
pub fn origin(&self) -> &ColorOrigin
Original container provenance.
Sourcepub fn with_origin(self, origin: ColorOrigin) -> PlanarBuf
pub fn with_origin(self, origin: ColorOrigin) -> PlanarBuf
Attach original container provenance.
Sourcepub const fn orientation(&self) -> Orientation
pub const fn orientation(&self) -> Orientation
Pending EXIF display orientation attached to this planar buffer.
Sourcepub const fn display_dimensions(&self) -> (u32, u32)
pub const fn display_dimensions(&self) -> (u32, u32)
Display-oriented (width, height) after applying orientation.
Sourcepub const fn with_orientation(self, orientation: Orientation) -> PlanarBuf
pub const fn with_orientation(self, orientation: Orientation) -> PlanarBuf
Replace pending EXIF display orientation.
Sourcepub fn set_orientation(&mut self, orientation: Orientation)
pub fn set_orientation(&mut self, orientation: Orientation)
Set pending EXIF display orientation in place.
Sourcepub const fn compose_orientation(self, delta: Orientation) -> PlanarBuf
pub const fn compose_orientation(self, delta: Orientation) -> PlanarBuf
Compose an additional display transform onto pending orientation in O(1).
Source§impl PlanarBuf
impl PlanarBuf
Sourcepub fn as_view(&self) -> PlanarView<'_>
pub fn as_view(&self) -> PlanarView<'_>
Borrow all planes as a PlanarView (zero-allocation for <= 4 planes).
Sourcepub fn try_as_view(&self) -> Result<PlanarView<'_>, At<BufferError>>
pub fn try_as_view(&self) -> Result<PlanarView<'_>, At<BufferError>>
Fallibly borrow all planes as a PlanarView (zero-allocation for <= 4 planes).
Sourcepub fn crop_view(
&self,
rect: PixelRect,
) -> Result<PlanarView<'_>, At<BufferError>>
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).
Sourcepub fn as_view_mut(&mut self) -> PlanarViewMut<'_>
pub fn as_view_mut(&mut self) -> PlanarViewMut<'_>
Borrow all planes mutably as a PlanarViewMut (zero-allocation for <= 4 planes).
Sourcepub fn try_cow_view_mut(&mut self) -> Result<PlanarViewMut<'_>, At<BufferError>>
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).
Sourcepub fn crop_view_mut(
&mut self,
rect: PixelRect,
) -> Result<PlanarViewMut<'_>, At<BufferError>>
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).