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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//! A pure-Rust decoder for HEIC and HEIF still images.
//!
//! No C, no `unsafe`, one optional dependency, and a `no_std` core that
//! builds for `wasm32-unknown-unknown` with no dependencies at all.
//!
//! # Status
//!
//! Complete and self-contained: boxes, `ftyp`, `meta` and its children, item
//! properties, `grid` derivation and tile compositing, transforms, EXIF and
//! ICC extraction, YCbCr to RGB conversion, and the HEVC still-picture intra
//! decoder in [`hevc`]. [`decode()`] turns a HEIC file into pixels with no C
//! and no `unsafe` anywhere in the chain.
//!
//! # The rule this crate is built on
//!
//! Business logic performs no I/O. [`decode()`] and [`probe()`] take `&[u8]`
//! and return values; nothing beneath them opens a file, reads the environment
//! or touches the network. Filesystem convenience lives in [`io`], behind the
//! default-on `std` feature, and nowhere else. That separation is what lets
//! the core be `no_std`, what makes it build for the browser, and what makes
//! every parser in it testable against a byte array written by hand.
//!
//! # Reading a file
//!
//! ```no_run
//! # fn main() -> Result<(), heic_rs::Error> {
//! let bytes = std::fs::read("photo.heic").unwrap_or_default();
//!
//! // Ask what the file is, without decoding it.
//! let info = heic_rs::probe(&bytes)?;
//! println!("{}x{}, {} bit", info.width, info.height, info.bit_depth);
//!
//! // Decode it.
//! let options = heic_rs::DecodeOptions::default();
//! let image = heic_rs::decode(&bytes, &options)?;
//! assert_eq!(image.data.len(), image.row_bytes() * image.height as usize);
//! # Ok(())
//! # }
//! ```
//!
//! # Untrusted input
//!
//! HEIF files are untrusted input. Every parser here is bounds-checked and
//! returns an error rather than panicking, and
//! [`DecodeOptions::max_pixels`] — [`DEFAULT_MAX_PIXELS`], 256 megapixels —
//! stops a small file from asking for an enormous allocation.
//!
//! # Features
//!
//! - `std` (default): the [`io`] module, and `std::error::Error` for
//! [`Error`]. Turn it off for `no_std` and for wasm.
//! - `parallel` (default): decode grid tiles and convert colour on a `rayon`
//! pool. Implies `std`, and is absent from the `no_std` and wasm builds.
//! The output is identical either way; see [`DecodeOptions::threads`] for
//! the knob and for what happens inside a caller's own pool.
extern crate alloc;
extern crate std;
pub use crate;
pub use crate;
pub use crateBrand;
pub use crateGrid;
pub use crateChromaFormat;
pub use crate;
pub use crate;
pub use crateTransform;
pub use crate;
pub use crate;
/// The images of a HEIF file that are meant to be shown, as item ids for
/// [`decode_image`] and [`probe_image`]. The primary image comes first; a file
/// with one image gives one id.