pub struct PlaneBuf { /* private fields */ }Expand description
Owned single plane inside a PlanarBuf with validated geometry invariants.
Implementations§
Source§impl PlaneBuf
impl PlaneBuf
Sourcepub fn try_clone(&self) -> Result<PlaneBuf, At<BufferError>>
pub fn try_clone(&self) -> Result<PlaneBuf, At<BufferError>>
Fallibly clone this plane, preserving sample alignment even under odd-byte allocators.
Sourcepub fn from_storage(
storage: PixelStorage,
width: u32,
height: u32,
stride_bytes: usize,
format: PlaneFormat,
) -> Result<PlaneBuf, At<BufferError>>
pub fn from_storage( storage: PixelStorage, width: u32, height: u32, stride_bytes: usize, format: PlaneFormat, ) -> Result<PlaneBuf, At<BufferError>>
Construct a validated owned plane adopting caller-provided PixelStorage zero-copy.
Sourcepub fn from_storage_with_byte_offset(
storage: PixelStorage,
byte_offset: usize,
width: u32,
height: u32,
stride_bytes: usize,
format: PlaneFormat,
) -> Result<PlaneBuf, At<BufferError>>
pub fn from_storage_with_byte_offset( storage: PixelStorage, byte_offset: usize, width: u32, height: u32, stride_bytes: usize, format: PlaneFormat, ) -> Result<PlaneBuf, At<BufferError>>
Construct a validated owned plane adopting caller-provided PixelStorage starting at
byte_offset bytes zero-copy.
Sourcepub fn from_external<S>(
storage: S,
width: u32,
height: u32,
stride_bytes: usize,
format: PlaneFormat,
) -> Result<PlaneBuf, (At<BufferError>, S)>
pub fn from_external<S>( storage: S, width: u32, height: u32, stride_bytes: usize, format: PlaneFormat, ) -> Result<PlaneBuf, (At<BufferError>, S)>
Construct a validated owned plane adopting an immutable external owner (Arc<[u8]>,
Arc<[u16]>, mmap, etc.) zero-copy. Returns Err((err, storage)) untouched on failure.
Sourcepub fn from_external_with_byte_offset<S>(
storage: S,
byte_offset: usize,
width: u32,
height: u32,
stride_bytes: usize,
format: PlaneFormat,
) -> Result<PlaneBuf, (At<BufferError>, S)>
pub fn from_external_with_byte_offset<S>( storage: S, byte_offset: usize, width: u32, height: u32, stride_bytes: usize, format: PlaneFormat, ) -> Result<PlaneBuf, (At<BufferError>, S)>
Construct a validated owned plane adopting an immutable external owner starting at
byte_offset bytes zero-copy. Returns Err((err, storage)) untouched on failure.
Sourcepub fn from_external_mut<S>(
storage: S,
width: u32,
height: u32,
stride_bytes: usize,
format: PlaneFormat,
) -> Result<PlaneBuf, (At<BufferError>, S)>
pub fn from_external_mut<S>( storage: S, width: u32, height: u32, stride_bytes: usize, format: PlaneFormat, ) -> Result<PlaneBuf, (At<BufferError>, S)>
Construct a validated owned plane adopting a mutable external owner (Box<[T]>,
custom allocator, pool lease, etc.) zero-copy. Returns Err((err, storage)) untouched on failure.
Sourcepub fn from_external_mut_with_byte_offset<S>(
storage: S,
byte_offset: usize,
width: u32,
height: u32,
stride_bytes: usize,
format: PlaneFormat,
) -> Result<PlaneBuf, (At<BufferError>, S)>
pub fn from_external_mut_with_byte_offset<S>( storage: S, byte_offset: usize, width: u32, height: u32, stride_bytes: usize, format: PlaneFormat, ) -> Result<PlaneBuf, (At<BufferError>, S)>
Construct a validated owned plane adopting a mutable external owner starting at
byte_offset bytes zero-copy. Returns Err((err, storage)) untouched on failure.
Sourcepub const fn byte_offset(&self) -> usize
pub const fn byte_offset(&self) -> usize
Byte offset of row 0 inside backing storage.
Sourcepub fn into_storage(self) -> PixelStorage
pub fn into_storage(self) -> PixelStorage
Consume this plane and return its backing PixelStorage.
Sourcepub fn into_external<S>(self) -> Result<S, PlaneBuf>where
S: 'static,
pub fn into_external<S>(self) -> Result<S, PlaneBuf>where
S: 'static,
Recover an immutable external owner S zero-copy; returns Err(self) untouched otherwise.
Sourcepub fn into_external_mut<S>(self) -> Result<S, PlaneBuf>where
S: 'static,
pub fn into_external_mut<S>(self) -> Result<S, PlaneBuf>where
S: 'static,
Recover a mutable external owner S zero-copy; returns Err(self) untouched otherwise.
Sourcepub fn make_mut(&mut self) -> Result<(), At<BufferError>>
pub fn make_mut(&mut self) -> Result<(), At<BufferError>>
Ensure backing storage is mutable in place, fallibly promoting immutable external
storage (PixelStorage::External) via copy-on-write into properly aligned owned storage
covering only the active plane extent (never copying an entire external slab).
No-op (zero copy, zero allocation) for native Vec, Aligned64, and ExternalMut planes.
Sourcepub fn try_cow_view_mut(&mut self) -> Result<PlaneViewMut<'_>, At<BufferError>>
pub fn try_cow_view_mut(&mut self) -> Result<PlaneViewMut<'_>, At<BufferError>>
Fallibly borrow as a mutable PlaneViewMut, performing active-extent copy-on-write
promotion of immutable external storage without panicking on OOM.
Sourcepub const fn format(&self) -> PlaneFormat
pub const fn format(&self) -> PlaneFormat
Plane specification.
Sourcepub const fn stride_bytes(&self) -> usize
pub const fn stride_bytes(&self) -> usize
Row stride in bytes.
Sourcepub fn storage(&self) -> &PixelStorage
pub fn storage(&self) -> &PixelStorage
Backing storage reference.
Sourcepub fn as_view_mut(&mut self) -> PlaneViewMut<'_>
pub fn as_view_mut(&mut self) -> PlaneViewMut<'_>
Borrow as a mutable PlaneViewMut, copy-on-write promoting immutable external storage
covering only the active plane extent.
Sourcepub fn from_samples<S>(
samples: Vec<S>,
width: u32,
height: u32,
format: PlaneFormat,
) -> Result<PlaneBuf, At<BufferError>>where
S: StorageSample,
pub fn from_samples<S>(
samples: Vec<S>,
width: u32,
height: u32,
format: PlaneFormat,
) -> Result<PlaneBuf, At<BufferError>>where
S: StorageSample,
Construct a validated owned plane adopting a tightly packed typed Vec<S> (Vec<u8>,
Vec<u16>, Vec<f32>, etc.) zero-copy.
Row stride is derived automatically as width * format.components() samples (e.g. width
for luma Y, width * 2 for semi-planar CbCr). For padded row strides, use
from_samples_strided.
Sourcepub fn from_samples_strided<S>(
samples: Vec<S>,
width: u32,
height: u32,
stride: SampleStride,
format: PlaneFormat,
) -> Result<PlaneBuf, At<BufferError>>where
S: StorageSample,
pub fn from_samples_strided<S>(
samples: Vec<S>,
width: u32,
height: u32,
stride: SampleStride,
format: PlaneFormat,
) -> Result<PlaneBuf, At<BufferError>>where
S: StorageSample,
Construct a validated owned plane adopting a strided typed Vec<S> (Vec<u8>,
Vec<u16>, Vec<f32>, etc.) zero-copy with an explicit SampleStride
measured in S elements (NOT bytes).
Sourcepub fn crop_view(
&self,
rect: PixelRect,
) -> Result<PlaneView<'_>, At<BufferError>>
pub fn crop_view( &self, rect: PixelRect, ) -> Result<PlaneView<'_>, At<BufferError>>
Borrow a zero-copy rectangular crop of this single plane.
Sourcepub fn crop_view_mut(
&mut self,
rect: PixelRect,
) -> Result<PlaneViewMut<'_>, At<BufferError>>
pub fn crop_view_mut( &mut self, rect: PixelRect, ) -> Result<PlaneViewMut<'_>, At<BufferError>>
Borrow a zero-copy mutable rectangular crop of this single plane, fallibly copy-on-write promoting immutable external storage if needed.
Sourcepub fn row_as<S>(&self, y: u32) -> Result<&[S], At<BufferError>>where
S: StorageSample,
pub fn row_as<S>(&self, y: u32) -> Result<&[S], At<BufferError>>where
S: StorageSample,
Zero-copy typed slice view of row y (e.g. plane.row_as::<u16>(y)).
Sourcepub fn row_as_mut<S>(&mut self, y: u32) -> Result<&mut [S], At<BufferError>>where
S: StorageSample,
pub fn row_as_mut<S>(&mut self, y: u32) -> Result<&mut [S], At<BufferError>>where
S: StorageSample,
Zero-copy mutable typed slice view of row y (e.g. plane.row_as_mut::<u16>(y)).
Sourcepub fn code_u32(&self, x: u32, y: u32, component: usize) -> Option<u32>
pub fn code_u32(&self, x: u32, y: u32, component: usize) -> Option<u32>
Extract the unpacked integer code for (x, y, component) respecting BitPacking.
component is the 0-based channel index within this plane: pass 0 for single-channel
planes (Y, Cb, Cr, R, G, B, Alpha), or 0/1 for interleaved CbCr.
Trait Implementations§
Source§impl Clone for PlaneBuf
impl Clone for PlaneBuf
Source§fn clone(&self) -> PlaneBuf
fn clone(&self) -> PlaneBuf
Clone this plane, preserving sample alignment even under odd-byte allocators.
§Panics
Panics on allocation failure when repacking misaligned backing storage; use
PlaneBuf::try_clone for fallible cloning.
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more