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
//! 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 zenjpeg::ultrahdr::{
//! encode_ultrahdr, GainMapConfig, ToneMapConfig, UhdrRawImage, Unstoppable,
//! };
//! use zenjpeg::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 (streaming)
//!
//! ```rust,ignore
//! use zenjpeg::ultrahdr::{create_hdr_reconstructor, UltraHdrExtras};
//!
//! // Use UltraHdrReader for streaming decode
//! let mut reader = UltraHdrReader::new(&jpeg_data, config)?;
//!
//! // Or with separate decoder + reconstructor:
//! // Note: streaming APIs now work with linear f32 RGB. The caller must convert
//! // sRGB u8 to linear f32 before feeding rows to the reconstructor.
//! let reconstructor = create_hdr_reconstructor(
//! width, height, &extras, 4.0,
//! )?;
//!
//! // Process rows (input: linear f32 RGB, output: linear f32 RGBA)
//! let hdr_batch = reconstructor.process_rows(&sdr_linear_f32, batch_height as u32)?;
//! ```
// 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;
// Re-export streaming UltraHDR reader types from decode module
pub use crate;