1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright (c) the JPEG XL Project Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//! A JPEG XL decoder in safe Rust.
//!
//! `zenjxl-decoder` is a pure-Rust decoder for the JPEG XL bitstream format
//! (ISO/IEC 18181). It is a fork of the upstream
//! [`libjxl/jxl-rs`](https://github.com/libjxl/jxl-rs) reference decoder,
//! which in turn tracks the C++ [`libjxl`](https://github.com/libjxl/libjxl)
//! implementation. Upstream remains the source of truth for codec behaviour;
//! this fork adds resource limits, cooperative cancellation, parallel decode,
//! and a handful of bug fixes and hardening changes on top.
//!
//! # Crate layout
//!
//! Most users only need the [`api`] module:
//!
//! ```no_run
//! use zenjxl_decoder::api::decode;
//!
//! let bytes = std::fs::read("image.jxl").unwrap();
//! let image = decode(&bytes).unwrap();
//! ```
//!
//! Pass [`api::JxlDecoderOptions`] to [`api::decode_with`] to configure
//! resource limits, cancellation, or colour conversion.
//!
//! # SIMD
//!
//! Multi-architecture SIMD (SSE4.2, AVX2, AVX-512, NEON, WASM128) lives in
//! the companion [`zenjxl-decoder-simd`](https://crates.io/crates/zenjxl-decoder-simd)
//! crate and is enabled via the `all-simd` feature (or per-ISA features such
//! as `avx`, `neon`, `wasm128`). Dispatch is runtime, via
//! [`archmage`](https://crates.io/crates/archmage).
//!
//! # Safety
//!
//! The main `jxl` crate is `#![forbid(unsafe_code)]` by default. Enabling the
//! `allow-unsafe` feature opts into a small set of `unsafe` fast paths guarded
//! by safe fallbacks.
//!
//! # Features
//!
//! - `threads` -- rayon-based parallel group decode and render.
//! - `cms` -- [`moxcms`](https://crates.io/crates/moxcms) ICC profile transforms
//! (required for CMYK input).
//! - `jpeg` -- lossless JPEG reconstruction from JXL containers.
//! - `all-simd` / `sse42` / `avx` / `avx512` / `neon` / `wasm128` -- SIMD backends.
//! - `allow-unsafe` -- opt in to `unsafe` fast paths.
//!
//! # License
//!
//! BSD-3-Clause, matching upstream [`libjxl/jxl-rs`](https://github.com/libjxl/jxl-rs).
pub use ;
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
// TODO: Move these to a more appropriate location.
const GROUP_DIM: usize = 256;
const BLOCK_DIM: usize = 8;
const BLOCK_SIZE: usize = BLOCK_DIM * BLOCK_DIM;
const MIN_SIGMA: f32 = -3.90524291751269967465540850526868;