pub struct Decoder<'a> { /* private fields */ }Expand description
A borrowed view of a JPEG stream ready to decode. Constructed via
Decoder::new or Decoder::from_view. Decoder<'a>: Send + Sync.
Implementations§
Source§impl Decoder<'_>
impl Decoder<'_>
Sourcepub fn decode_request(
&self,
request: DecodeRequest,
) -> Result<(Vec<u8>, DecodeOutcome), JpegError>
pub fn decode_request( &self, request: DecodeRequest, ) -> Result<(Vec<u8>, DecodeOutcome), JpegError>
Decode into a freshly allocated tightly packed buffer using a request object instead of a method-name cross-product.
§Errors
Returns an output-geometry, unsupported-format, or scan decode error.
Source§impl Decoder<'_>
impl Decoder<'_>
Sourcepub fn decode_into(
&self,
out: &mut [u8],
stride: usize,
fmt: PixelFormat,
) -> Result<DecodeOutcome, JpegError>
pub fn decode_into( &self, out: &mut [u8], stride: usize, fmt: PixelFormat, ) -> Result<DecodeOutcome, JpegError>
Decode the full image into the caller’s buffer.
§Errors
JpegError::OutputBufferTooSmallorJpegError::InvalidStrideif the provided buffer/stride cannot hold the image atfmt.JpegError::NotImplementediffmtrequests a raw output the current release does not emit (e.g.RawYCbCr8).- Any entropy- or structural-decode error from the scan walker.
Sourcepub fn decode_scaled_into(
&self,
out: &mut [u8],
stride: usize,
fmt: PixelFormat,
scale: Downscale,
) -> Result<DecodeOutcome, JpegError>
pub fn decode_scaled_into( &self, out: &mut [u8], stride: usize, fmt: PixelFormat, scale: Downscale, ) -> Result<DecodeOutcome, JpegError>
Decode the full image into the caller’s buffer using the core
PixelFormat + Downscale contract.
§Errors
Returns an output-buffer, unsupported-format, or scan decode error.
Sourcepub fn decode_into_with_scratch(
&self,
pool: &mut ScratchPool,
out: &mut [u8],
stride: usize,
fmt: PixelFormat,
) -> Result<DecodeOutcome, JpegError>
pub fn decode_into_with_scratch( &self, pool: &mut ScratchPool, out: &mut [u8], stride: usize, fmt: PixelFormat, ) -> Result<DecodeOutcome, JpegError>
Decode the full image into the caller’s buffer, reusing the supplied
ScratchPool. On a long-running tile batch this eliminates the
per-tile allocation of stripe buffers, the DC predictor, and the
chroma upsample rows — the realistic WSI reader shape. The first
call against a fresh pool does the allocation; subsequent calls at
the same-or-smaller shape reuse the underlying Vecs.
§Errors
Identical to Self::decode_into.
Sourcepub fn decode_scaled_into_with_scratch(
&self,
pool: &mut ScratchPool,
out: &mut [u8],
stride: usize,
fmt: PixelFormat,
scale: Downscale,
) -> Result<DecodeOutcome, JpegError>
pub fn decode_scaled_into_with_scratch( &self, pool: &mut ScratchPool, out: &mut [u8], stride: usize, fmt: PixelFormat, scale: Downscale, ) -> Result<DecodeOutcome, JpegError>
Self::decode_scaled_into with caller-owned scratch.
§Errors
Returns an output-buffer, unsupported-format, or scan decode error.
Sourcepub fn decode_region_into(
&self,
out: &mut [u8],
stride: usize,
fmt: PixelFormat,
roi: Rect,
) -> Result<DecodeOutcome, JpegError>
pub fn decode_region_into( &self, out: &mut [u8], stride: usize, fmt: PixelFormat, roi: Rect, ) -> Result<DecodeOutcome, JpegError>
Decode a rectangular region of the image into the caller’s buffer.
roi is expressed in source-image coordinates. If fmt requests a
downscaled output, the written pixels cover the corresponding bounding
box in the scaled image grid.
§Errors
Returns an invalid-region, output-buffer, unsupported-format, or scan decode error.
Sourcepub fn decode_region_scaled_into(
&self,
out: &mut [u8],
stride: usize,
fmt: PixelFormat,
roi: Rect,
scale: Downscale,
) -> Result<DecodeOutcome, JpegError>
pub fn decode_region_scaled_into( &self, out: &mut [u8], stride: usize, fmt: PixelFormat, roi: Rect, scale: Downscale, ) -> Result<DecodeOutcome, JpegError>
Decode roi into the caller’s buffer using the core PixelFormat +
Downscale contract.
§Errors
Returns an invalid-region, output-buffer, unsupported-format, or scan decode error.
Sourcepub fn decode_region_scaled_into_with_scratch(
&self,
pool: &mut ScratchPool,
out: &mut [u8],
stride: usize,
fmt: PixelFormat,
roi: Rect,
scale: Downscale,
) -> Result<DecodeOutcome, JpegError>
pub fn decode_region_scaled_into_with_scratch( &self, pool: &mut ScratchPool, out: &mut [u8], stride: usize, fmt: PixelFormat, roi: Rect, scale: Downscale, ) -> Result<DecodeOutcome, JpegError>
Self::decode_region_scaled_into with caller-owned scratch.
§Errors
Returns an invalid-region, output-buffer, unsupported-format, or scan decode error.
Source§impl Decoder<'_>
impl Decoder<'_>
Sourcepub fn decode_rows<S>(&self, sink: &mut S) -> Result<DecodeOutcome, JpegError>
pub fn decode_rows<S>(&self, sink: &mut S) -> Result<DecodeOutcome, JpegError>
Decode the full image into rows delivered to sink.
DCT-backed and 8-bit lossless color paths emit interleaved RGB8 rows. Lossless 16-bit grayscale SOF3 emits little-endian Gray16 rows, and supported lossless 16-bit color SOF3 emits little-endian Rgb16 rows.
§Errors
Returns a scan decode error or an error reported by sink.
Sourcepub fn decode_rows_with_scratch<S>(
&self,
pool: &mut ScratchPool,
sink: &mut S,
) -> Result<DecodeOutcome, JpegError>
pub fn decode_rows_with_scratch<S>( &self, pool: &mut ScratchPool, sink: &mut S, ) -> Result<DecodeOutcome, JpegError>
Self::decode_rows with caller-owned scratch. See
Self::decode_into_with_scratch for the reuse contract.
§Errors
Returns a scan decode error or an error reported by sink.
Sourcepub fn decode_component_rows_with_scratch<W>(
&self,
pool: &mut ScratchPool,
writer: &mut W,
) -> Result<DecodeOutcome, JpegError>where
W: ComponentRowWriter,
pub fn decode_component_rows_with_scratch<W>(
&self,
pool: &mut ScratchPool,
writer: &mut W,
) -> Result<DecodeOutcome, JpegError>where
W: ComponentRowWriter,
Decode the full image into component rows.
§Errors
Returns a scan decode error or an error reported by writer.
Sourcepub fn decode_region_component_rows_with_scratch<W>(
&self,
pool: &mut ScratchPool,
writer: &mut W,
roi: Rect,
scale: Downscale,
) -> Result<DecodeOutcome, JpegError>where
W: ComponentRowWriter,
pub fn decode_region_component_rows_with_scratch<W>(
&self,
pool: &mut ScratchPool,
writer: &mut W,
roi: Rect,
scale: Downscale,
) -> Result<DecodeOutcome, JpegError>where
W: ComponentRowWriter,
Decode roi into component rows, optionally at a reduced scale.
§Errors
Returns an invalid-region or scan error, or an error reported by
writer.
Source§impl<'a> Decoder<'a>
impl<'a> Decoder<'a>
Sourcepub fn inspect(input: &'a [u8]) -> Result<Info, JpegError>
pub fn inspect(input: &'a [u8]) -> Result<Info, JpegError>
Parse the headers without decoding pixels. The parser walks headers up
to the first SOS and then performs a lightweight marker scan so
Info::scan_count reflects all scans in the file.
§Errors
Returns any structural, unsupported-SOF, or sanity-check error
encountered before the Start-of-Scan marker. See JpegError.
Sourcepub fn new(input: &'a [u8]) -> Result<Self, JpegError>
pub fn new(input: &'a [u8]) -> Result<Self, JpegError>
Build a decoder ready for decode_into. Parses the full header, pre-
builds every referenced Huffman table, and validates that the stream is
one of the SOFs this release implements.
§Errors
- Any parse error encountered before SOS (see
Self::inspect). JpegError::NotImplementedfor SOFs that parse but are not yet decodable for the requested shape (for example Progressive12 or unsupported Lossless predictors).JpegError::MissingHuffmanTableif the scan references a DC/AC table slot that was never defined by a DHT segment.
Sourcepub fn from_view_in_context(
view: JpegView<'a>,
ctx: &mut DecoderContext,
) -> Result<Self, JpegError>
pub fn from_view_in_context( view: JpegView<'a>, ctx: &mut DecoderContext, ) -> Result<Self, JpegError>
Trait Implementations§
Auto Trait Implementations§
impl<'a> !Freeze for Decoder<'a>
impl<'a> RefUnwindSafe for Decoder<'a>
impl<'a> Send for Decoder<'a>
impl<'a> Sync for Decoder<'a>
impl<'a> Unpin for Decoder<'a>
impl<'a> UnsafeUnpin for Decoder<'a>
impl<'a> UnwindSafe for Decoder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more