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
//! UltraHDR support for jpegli.
//!
//! This module provides integration with [`ultrahdr_core`] for HDR gain map
//! encoding and decoding. UltraHDR images contain an SDR base JPEG plus a
//! secondary gain map JPEG that allows reconstruction of HDR content on
//! capable displays while remaining compatible with SDR viewers.
//!
//! # Overview
//!
//! - **Encoding**: Tonemap HDR → compute gain map → encode base+gainmap → assemble
//! - **Decoding**: Decode base → extract gain map → apply boost → reconstruct HDR
//!
//! # Example: Encode UltraHDR from HDR source
//!
//! ```rust,ignore
//! use jpegli::ultrahdr::{
//! encode_ultrahdr, GainMapConfig, ToneMapConfig, UhdrRawImage, Unstoppable,
//! };
//! use jpegli::encoder::{EncoderConfig, ChromaSubsampling};
//!
//! // Load HDR image (e.g., from OpenEXR, HDR photo, etc.)
//! let hdr = UhdrRawImage::from_data(
//! width, height, PixelFormat::Rgba32F, gamut, transfer, data,
//! )?;
//!
//! // Encode with default settings
//! let jpeg = encode_ultrahdr(
//! &hdr,
//! &GainMapConfig::default(),
//! &ToneMapConfig::default(),
//! &EncoderConfig::ycbcr(85, ChromaSubsampling::Quarter),
//! 75.0, // gain map quality
//! Unstoppable,
//! )?;
//! ```
//!
//! # Example: Decode and reconstruct HDR
//!
//! ```rust,ignore
//! use jpegli::decoder::Decoder;
//! use jpegli::ultrahdr::{reconstruct_hdr, HdrOutputFormat, UltraHdrExtras, Unstoppable};
//!
//! let decoded = Decoder::new().decode(&jpeg_data)?;
//!
//! // Check if it's UltraHDR
//! if let Some(extras) = decoded.extras() {
//! if extras.is_ultrahdr() {
//! let hdr = reconstruct_hdr(
//! decoded.pixels(),
//! decoded.width(),
//! decoded.height(),
//! extras,
//! 4.0, // display boost (1.0=SDR, 4.0=typical HDR)
//! HdrOutputFormat::LinearFloat,
//! Unstoppable,
//! )?;
//! }
//! }
//! ```
// Re-export the main workflow functions
pub use ;
pub use ;
// Re-export core types from ultrahdr-core (aliased to avoid collisions)
pub use ;
// Re-export the Stop trait from enough (same one used by jpegli)
pub use Stop;