Struct png::decoder::unfiltering_buffer::UnfilteringBuffer

source ·
pub(crate) struct UnfilteringBuffer {
    data_stream: Vec<u8>,
    prev_start: usize,
    current_start: usize,
}

Fields§

§data_stream: Vec<u8>

Vec containing the uncompressed image data currently being processed.

§prev_start: usize

Index in data_stream where the previous row starts. This excludes the filter type byte - it points at the first byte of actual pixel data. The pixel data is already-unfilter-ed. If prev_start == current_start then it means that there is no previous row.

§current_start: usize

Index in data_stream where the current row starts. This points at the filter type byte of the current row (i.e. the actual pixel data starts at current_start + 1) The pixel data is not-yet-unfilter-ed.

Implementations§

source§

impl UnfilteringBuffer

source

fn debug_assert_invariants(&self)

Asserts in debug builds that all the invariants hold. No-op in release builds. Intended to be called after creating or mutating self to ensure that the final state preserves the invariants.

source

pub fn new() -> Self

source

pub fn reset_prev_row(&mut self)

Called to indicate that there is no previous row (e.g. when the current row is the first scanline of a given Adam7 pass).

source

pub fn prev_row(&self) -> &[u8]

Returns the previous (already unfilter-ed) row.

source

pub fn curr_row_len(&self) -> usize

Returns how many bytes of the current row are present in the buffer.

source

pub fn as_mut_vec(&mut self) -> &mut Vec<u8>

Returns a &mut Vec<u8> suitable for passing to ReadDecoder.decode_image_data or StreamingDecoder.update.

Invariants of self depend on the assumption that the caller will only append new bytes to the returned vector (which is indeed the behavior of ReadDecoder and StreamingDecoder). TODO: Consider protecting the invariants by returning an append-only view of the vector (FnMut(&[u8])??? or maybe std::io::Write???).

source

pub fn unfilter_curr_row( &mut self, rowlen: usize, bpp: BytesPerPixel, ) -> Result<(), DecodingError>

Runs unfilter on the current row, and then shifts rows so that the current row becomes the previous row.

Will panic if self.curr_row_len() < rowlen.

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