Skip to main content

J2kDecoder

Struct J2kDecoder 

Source
pub struct J2kDecoder<'a> { /* private fields */ }
Expand description

JPEG 2000 / HTJ2K decoder with WSI-shaped full-frame, ROI, and scaled output methods.

The decoder borrows compressed tile bytes and owns reusable native decode context so repeated operations can avoid reparsing backend state.

Implementations§

Source§

impl<'a> J2kDecoder<'a>

Source

pub fn inspect(input: &'a [u8]) -> Result<Info, J2kError>

Inspect JP2/J2C/HTJ2K metadata without decoding pixels.

§Errors

Returns J2kError when the input cannot be parsed or inspected as a supported JPEG 2000 / HTJ2K image.

Source

pub fn new(input: &'a [u8]) -> Result<Self, J2kError>

Create a decoder from compressed bytes.

§Errors

Returns J2kError for unsupported or malformed input.

Source

pub fn from_view(view: J2kView<'a>) -> Result<Self, J2kError>

Create a decoder from a previously parsed J2kView.

§Errors

Returns J2kError if the parsed view cannot be promoted to a decoder.

Source

pub fn info(&self) -> &Info

Header-derived image metadata.

Source

pub fn cpu_decode_parallelism(&self) -> CpuDecodeParallelism

Return the CPU decode parallelism policy for this decoder.

Source

pub fn set_cpu_decode_parallelism(&mut self, parallelism: CpuDecodeParallelism)

Set the CPU decode parallelism policy for this decoder.

Source

pub fn bytes(&self) -> &'a [u8]

Original compressed bytes backing this decoder.

Source

pub fn passthrough_candidate(&self) -> Option<PassthroughCandidate<'a>>

Return a byte-preserving passthrough candidate when the native parser classified the compressed syntax and payload shape.

Source

pub fn decode_into( &mut self, out: &mut [u8], stride: usize, fmt: PixelFormat, ) -> Result<DecodeOutcome<Infallible>, J2kError>

Decode the full image into out using stride bytes per output row.

§Errors

Returns J2kError when the format is unsupported, the output buffer is too small, or the codestream fails during decode.

Source

pub fn decode_into_with_scratch( &mut self, _pool: &mut J2kScratchPool, out: &mut [u8], stride: usize, fmt: PixelFormat, ) -> Result<DecodeOutcome<Infallible>, J2kError>

Decode the full image with caller-owned scratch.

The current native full-frame path writes directly into the caller’s output buffer; the pool is accepted to satisfy the shared codec trait and is used by reduced-resolution and row-bounded paths.

§Errors

Same as Self::decode_into.

Source

pub fn decode_region_into( &mut self, _pool: &mut J2kScratchPool, out: &mut [u8], stride: usize, fmt: PixelFormat, roi: Rect, ) -> Result<DecodeOutcome<Infallible>, J2kError>

Decode a source-coordinate region into out.

roi is expressed in full-resolution source pixels. The output buffer must hold roi.w * roi.h * fmt.bytes_per_pixel() bytes with the provided row stride.

§Errors

Returns J2kError when the region is out of bounds, the output buffer is too small, the format is unsupported, or decode fails.

Source

pub fn decode_scaled_into( &mut self, pool: &mut J2kScratchPool, out: &mut [u8], stride: usize, fmt: PixelFormat, scale: Downscale, ) -> Result<DecodeOutcome<Infallible>, J2kError>

Decode the full image at a reduced resolution.

scale uses the shared Downscale contract; Downscale::None delegates to full-resolution decode.

§Errors

Returns J2kError when the format or scale request is unsupported, the output buffer is too small, or decode fails.

Source

pub fn decode_region_scaled_into( &mut self, pool: &mut J2kScratchPool, out: &mut [u8], stride: usize, fmt: PixelFormat, roi: Rect, scale: Downscale, ) -> Result<DecodeOutcome<Infallible>, J2kError>

Decode a source-coordinate region at a reduced resolution.

roi is expressed in full-resolution source pixels. The decoded output covers roi.scaled_covering(scale) in reduced-resolution coordinates.

§Errors

Returns J2kError when the region is out of bounds, the scale or pixel format is unsupported, the output buffer is too small, or decode fails.

Source

pub fn decode_rows_u8_bounded<R: RowSink<u8>>( &mut self, sink: &mut R, options: J2kRowDecodeOptions, ) -> Result<DecodeOutcome<Infallible>, DecodeRowsError<J2kError, R::Error>>

Decode rows into a u8 row sink while bounding host output scratch to at most options.max_rows_per_stripe() rows.

§Errors

Returns a decode error for unsupported formats or malformed input, and forwards sink errors without converting them to successful decodes.

Source

pub fn decode_rows_u16_bounded<R: RowSink<u16>>( &mut self, sink: &mut R, options: J2kRowDecodeOptions, ) -> Result<DecodeOutcome<Infallible>, DecodeRowsError<J2kError, R::Error>>

Decode rows into a u16 row sink while bounding host output scratch to at most options.max_rows_per_stripe() rows.

§Errors

Returns a decode error for unsupported formats or malformed input, and forwards sink errors without converting them to successful decodes.

Trait Implementations§

Source§

impl ImageCodec for J2kDecoder<'_>

Source§

type Error = J2kError

Codec-specific error type.
Source§

type Warning = Infallible

Non-fatal warning type returned in successful decode outcomes.
Source§

type Pool = J2kScratchPool

Caller-owned scratch pool type used to reuse allocations.
Source§

impl<'a> ImageDecode<'a> for J2kDecoder<'a>

Source§

type View = J2kView<'a>

Borrowed parse product that can later construct a decoder.
Source§

fn inspect(input: &'a [u8]) -> Result<Info, Self::Error>

Inspect metadata without decoding pixels.
Source§

fn parse(input: &'a [u8]) -> Result<Self::View, Self::Error>

Parse compressed bytes into a borrowed view.
Source§

fn from_view(view: Self::View) -> Result<Self, Self::Error>

Build a decoder from a parsed view.
Source§

fn decode_into( &mut self, out: &mut [u8], stride: usize, fmt: PixelFormat, ) -> Result<DecodeOutcome<Self::Warning>, Self::Error>

Decode the full image into caller-owned output.
Source§

fn decode_into_with_scratch( &mut self, pool: &mut Self::Pool, out: &mut [u8], stride: usize, fmt: PixelFormat, ) -> Result<DecodeOutcome<Self::Warning>, Self::Error>

Decode the full image into caller-owned output with reusable scratch.
Source§

fn decode_region_into( &mut self, pool: &mut Self::Pool, out: &mut [u8], stride: usize, fmt: PixelFormat, roi: Rect, ) -> Result<DecodeOutcome<Self::Warning>, Self::Error>

Decode a source-coordinate region into caller-owned output.
Source§

fn decode_scaled_into( &mut self, pool: &mut Self::Pool, out: &mut [u8], stride: usize, fmt: PixelFormat, scale: Downscale, ) -> Result<DecodeOutcome<Self::Warning>, Self::Error>

Decode the full image at reduced resolution into caller-owned output.
Source§

fn decode_region_scaled_into( &mut self, pool: &mut Self::Pool, out: &mut [u8], stride: usize, fmt: PixelFormat, roi: Rect, scale: Downscale, ) -> Result<DecodeOutcome<Self::Warning>, Self::Error>

Decode a source-coordinate region at reduced resolution into caller-owned output.
Source§

fn decode_request_into( &mut self, pool: &mut Self::Pool, out: &mut [u8], stride: usize, fmt: PixelFormat, request: DecodeRequest, ) -> Result<DecodeOutcome<Self::Warning>, Self::Error>

Decode a normalized full/ROI/scaled request into caller-owned output.
Source§

impl<'a> ImageDecodeRows<'a, u8> for J2kDecoder<'a>

Source§

fn decode_rows<R: RowSink<u8>>( &mut self, sink: &mut R, ) -> Result<DecodeOutcome<Self::Warning>, DecodeRowsError<Self::Error, R::Error>>

Decode rows into sink without requiring one contiguous output buffer.
Source§

impl<'a> ImageDecodeRows<'a, u16> for J2kDecoder<'a>

Source§

fn decode_rows<R: RowSink<u16>>( &mut self, sink: &mut R, ) -> Result<DecodeOutcome<Self::Warning>, DecodeRowsError<Self::Error, R::Error>>

Decode rows into sink without requiring one contiguous output buffer.

Auto Trait Implementations§

§

impl<'a> Freeze for J2kDecoder<'a>

§

impl<'a> RefUnwindSafe for J2kDecoder<'a>

§

impl<'a> Send for J2kDecoder<'a>

§

impl<'a> Sync for J2kDecoder<'a>

§

impl<'a> Unpin for J2kDecoder<'a>

§

impl<'a> UnsafeUnpin for J2kDecoder<'a>

§

impl<'a> UnwindSafe for J2kDecoder<'a>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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.