Skip to main content

Neighbors

Struct Neighbors 

Source
pub struct Neighbors {
    pub n: i32,
    pub w: i32,
    pub nw: i32,
    pub ne: i32,
    pub nn: i32,
    pub ww: i32,
}
Expand description

Neighbor values for prediction.

Fields§

§n: i32

North (top) neighbor.

§w: i32

West (left) neighbor.

§nw: i32

Northwest (top-left) neighbor.

§ne: i32

Northeast (top-right) neighbor.

§nn: i32

North-north (2 pixels above) neighbor.

§ww: i32

West-west (2 pixels left) neighbor.

Implementations§

Source§

impl Neighbors

Source

pub fn gather(channel: &Channel, x: usize, y: usize) -> Self

Gathers neighbor values from a channel, matching the JXL spec’s edge handling.

Edge clamping rules (from jxl-rs PredictionData::get_rows):

  • left: x>0 ? row[x-1] : (y>0 ? top_row[0] : 0)
  • top: y>0 ? top_row[x] : left
  • topleft: x>0 && y>0 ? top_row[x-1] : left
  • topright: x+1 < width && y>0 ? top_row[x+1] : top
  • leftleft: x>1 ? row[x-2] : left
  • toptop: y>1 ? toptop_row[x] : top
Source

pub fn gather_fast( row: &[i32], prev_row: Option<&[i32]>, prev_prev_row: Option<&[i32]>, x: usize, _width: usize, ) -> Self

Gathers neighbors with explicit row pointers for speed, matching JXL spec edge handling.

Trait Implementations§

Source§

impl Clone for Neighbors

Source§

fn clone(&self) -> Neighbors

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Neighbors

Source§

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

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

impl Default for Neighbors

Source§

fn default() -> Neighbors

Returns the “default value” for a type. Read more
Source§

impl Copy for Neighbors

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.