#[must_use]
pub const fn webp_abi_is_incompatible(a: i32, b: i32) -> bool {
(a >> 8) != (b >> 8)
}
#[derive(Debug)]
pub enum PlaneStorage<'a, T> {
Internal(Vec<T>),
External(Vec<&'a mut [T]>),
Shared(Vec<&'a [T]>),
}
impl<T> Default for PlaneStorage<'_, T> {
fn default() -> Self {
Self::Internal(Vec::new())
}
}
impl<T> PlaneStorage<'_, T> {
#[must_use]
pub fn region(&self, region: usize) -> Option<&[T]> {
match self {
Self::Internal(samples) => (region == 0).then_some(samples.as_slice()),
Self::External(slices) => slices.get(region).map(|slice| &**slice),
Self::Shared(slices) => slices.get(region).copied(),
}
}
pub fn region_mut(&mut self, region: usize) -> Option<&mut [T]> {
match self {
Self::Internal(samples) => (region == 0).then_some(samples.as_mut_slice()),
Self::External(slices) => slices.get_mut(region).map(|slice| &mut **slice),
Self::Shared(_) => panic!("a shared view of a picture cannot be written"),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct PlaneOffset {
pub region: usize,
pub offset: usize,
}