Struct zune_core::options::DecoderOptions
source · pub struct DecoderOptions { /* private fields */ }
Expand description
Decoder options
Not all options are respected by decoders all decoders
Implementations§
source§impl DecoderOptions
impl DecoderOptions
Initializers
sourcepub fn new_safe() -> DecoderOptions
pub fn new_safe() -> DecoderOptions
Create the decoder with options setting most configurable options to be their safe counterparts
This is the same as default
option as default initializes
options to the safe variant.
Note, decoders running on this will be slower as it disables platform specific intrinsics
sourcepub fn new_fast() -> DecoderOptions
pub fn new_fast() -> DecoderOptions
Create the decoder with options setting the configurable options to the fast counterparts
This enables platform specific code paths and enable use of unsafe
sourcepub fn new_cmd() -> DecoderOptions
pub fn new_cmd() -> DecoderOptions
Create the decoder options with the following characteristics
- Use unsafe paths.
- Ignore error checksuming, e.g in png we do not confirm adler and crc in this mode
- Enable fast intrinsics paths
source§impl DecoderOptions
impl DecoderOptions
Global options respected by all decoders
sourcepub const fn get_max_width(&self) -> usize
pub const fn get_max_width(&self) -> usize
Get maximum width configured for which the decoder should not try to decode images greater than this width
sourcepub const fn get_max_height(&self) -> usize
pub const fn get_max_height(&self) -> usize
Get maximum height configured for which the decoder should not try to decode images greater than this height
sourcepub fn get_strict_mode(&self) -> bool
pub fn get_strict_mode(&self) -> bool
Return true whether the decoder should be in strict mode And reject most errors
sourcepub const fn get_use_unsafe(&self) -> bool
pub const fn get_use_unsafe(&self) -> bool
Return true if the decoder should use unsafe routines where possible
sourcepub fn set_max_width(self, width: usize) -> Self
pub fn set_max_width(self, width: usize) -> Self
Set maximum width for which the decoder should not try decoding images greater than that width
Arguments
width
: The maximum width allowed
returns: DecoderOptions
sourcepub fn set_max_height(self, height: usize) -> Self
pub fn set_max_height(self, height: usize) -> Self
Set maximum height for which the decoder should not try decoding images greater than that height
Arguments
height
: The maximum height allowed
returns: DecoderOptions
sourcepub fn set_use_unsafe(self, yes: bool) -> Self
pub fn set_use_unsafe(self, yes: bool) -> Self
Whether the routines can use unsafe platform specific intrinsics when necessary
Platform intrinsics are implemented for operations which the compiler can’t auto-vectorize, or we can do a marginably better job at it
All decoders with unsafe routines respect it.
Treat this with caution, disabling it will cause slowdowns but it’s provided for mainly for debugging use.
- Respected by:
png
andjpeg
(decoders with unsafe routines)
sourcepub fn set_strict_mode(self, yes: bool) -> Self
pub fn set_strict_mode(self, yes: bool) -> Self
Set whether the decoder should be in standards conforming/ strict mode
This reduces the error tolerance level for the decoders and invalid samples will be rejected by the decoder
Arguments
yes
:
returns: DecoderOptions
sourcepub fn set_byte_endian(self, endian: ByteEndian) -> Self
pub fn set_byte_endian(self, endian: ByteEndian) -> Self
Set the byte endian for which raw samples will be stored in in case a single pixel sample spans more than a byte.
The default is usually native endian hence big endian values will be converted to little endian on little endian systems,
and little endian values will be converted to big endian on big endian systems
Arguments
endian
: The endianness to which to set the bytes to
returns: DecoderOptions
sourcepub const fn get_byte_endian(&self) -> ByteEndian
pub const fn get_byte_endian(&self) -> ByteEndian
Get the byte endian for which samples that span more than one byte will be treated
source§impl DecoderOptions
impl DecoderOptions
PNG specific options
sourcepub const fn inflate_get_confirm_adler(&self) -> bool
pub const fn inflate_get_confirm_adler(&self) -> bool
Whether the inflate decoder should confirm adler checksums
sourcepub fn inflate_set_confirm_adler(self, yes: bool) -> Self
pub fn inflate_set_confirm_adler(self, yes: bool) -> Self
Set whether the inflate decoder should confirm adler checksums
sourcepub const fn inflate_get_limit(&self) -> usize
pub const fn inflate_get_limit(&self) -> usize
Get default inflate limit for which the decoder will not try to decompress further
sourcepub fn inflate_set_limit(self, limit: usize) -> Self
pub fn inflate_set_limit(self, limit: usize) -> Self
Set the default inflate limit for which decompressors relying on inflate won’t surpass this limit
sourcepub const fn png_get_confirm_crc(&self) -> bool
pub const fn png_get_confirm_crc(&self) -> bool
Whether the inflate decoder should confirm crc 32 checksums
sourcepub fn png_set_confirm_crc(self, yes: bool) -> Self
pub fn png_set_confirm_crc(self, yes: bool) -> Self
Set whether the png decoder should confirm CRC 32 checksums
sourcepub fn png_set_add_alpha_channel(self, yes: bool) -> Self
pub fn png_set_add_alpha_channel(self, yes: bool) -> Self
Set whether the png decoder should add an alpha channel to images where possible.
For Luma images, it converts it to Luma+Alpha
For RGB images it converts it to RGB+Alpha
sourcepub const fn png_get_add_alpha_channel(&self) -> bool
pub const fn png_get_add_alpha_channel(&self) -> bool
Return true whether the png decoder should add an alpha channel to images where possible
sourcepub fn png_set_strip_to_8bit(self, yes: bool) -> Self
pub fn png_set_strip_to_8bit(self, yes: bool) -> Self
Whether the png decoder should reduce 16 bit images to 8 bit images implicitly.
Equivalent to png::Transformations::STRIP_16
sourcepub const fn png_get_strip_to_8bit(&self) -> bool
pub const fn png_get_strip_to_8bit(&self) -> bool
Return a boolean indicating whether the png decoder should reduce 16 bit images to 8 bit images implicitly
sourcepub const fn png_decode_animated(&self) -> bool
pub const fn png_decode_animated(&self) -> bool
Return whether zune-image
should decode animated images or
whether we should just decode the first frame only
sourcepub const fn png_set_decode_animated(self, yes: bool) -> Self
pub const fn png_set_decode_animated(self, yes: bool) -> Self
Set whether zune-image
should decode animated images or
whether we should just decode the first frame only
source§impl DecoderOptions
impl DecoderOptions
JPEG specific options
sourcepub const fn jpeg_get_max_scans(&self) -> usize
pub const fn jpeg_get_max_scans(&self) -> usize
Get maximum scans for which the jpeg decoder should not go above for progressive images
sourcepub fn jpeg_set_max_scans(self, max_scans: usize) -> Self
pub fn jpeg_set_max_scans(self, max_scans: usize) -> Self
Set maximum scans for which the jpeg decoder should not exceed when reconstructing images.
sourcepub const fn jpeg_get_out_colorspace(&self) -> ColorSpace
pub const fn jpeg_get_out_colorspace(&self) -> ColorSpace
Get expected output colorspace set by the user for which the image is expected to be reconstructed into.
This may be different from the
sourcepub fn jpeg_set_out_colorspace(self, colorspace: ColorSpace) -> Self
pub fn jpeg_set_out_colorspace(self, colorspace: ColorSpace) -> Self
Set expected colorspace for which the jpeg output is expected to be in
This is mainly provided as is, we do not guarantee the decoder can convert to all colorspaces and the decoder can change it internally when it sees fit.
source§impl DecoderOptions
impl DecoderOptions
Intrinsics support
These routines are compiled depending
on the platform they are used, if compiled for a platform
it doesn’t support,(e.g avx2 on Arm), it will always return false
sourcepub fn use_sse2(&self) -> bool
pub fn use_sse2(&self) -> bool
Use SSE 2 code paths where possible
This checks for existence of SSE2 first and returns false if it’s not present
sourcepub fn use_sse3(&self) -> bool
pub fn use_sse3(&self) -> bool
Use SSE 3 paths where possible
This also checks for SSE3 support and returns false if it’s not present
sourcepub fn use_sse41(&self) -> bool
pub fn use_sse41(&self) -> bool
Use SSE4 paths where possible
This also checks for sse 4.1 support and returns false if it is not present
sourcepub fn use_avx(&self) -> bool
pub fn use_avx(&self) -> bool
Use AVX paths where possible
This also checks for AVX support and returns false if it’s not present
sourcepub fn use_avx2(&self) -> bool
pub fn use_avx2(&self) -> bool
Use avx2 paths where possible
This also checks for AVX2 support and returns false if it’s not present
pub fn use_neon(&self) -> bool
source§impl DecoderOptions
impl DecoderOptions
JPEG_XL specific options
sourcepub const fn jxl_decode_animated(&self) -> bool
pub const fn jxl_decode_animated(&self) -> bool
Return whether zune-image
should decode animated images or
whether we should just decode the first frame only
sourcepub const fn jxl_set_decode_animated(self, yes: bool) -> Self
pub const fn jxl_set_decode_animated(self, yes: bool) -> Self
Set whether zune-image
should decode animated images or
whether we should just decode the first frame only
Trait Implementations§
source§impl Clone for DecoderOptions
impl Clone for DecoderOptions
source§fn clone(&self) -> DecoderOptions
fn clone(&self) -> DecoderOptions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more