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
//! Stage-neutral pipeline data models.
//!
//! These types flow *between* stages, so they live apart from any one stage
//! that happens to produce them. The coefficient pyramid ([`Band`],
//! [`DetailBands`], [`Bands`], [`SubbandCoeffs`]) is produced by a block coder
//! and consumed by dequant and the inverse DWT; keeping it here lets a future
//! HT block decoder produce it without depending on the EBCOT module purely for
//! its types. [`Samples`] carries one component's reconstructed values from the
//! inverse DWT through the color transform to image assembly.
/// One subband (or the coarsest LL): a row-major coefficient grid plus its
/// tile-component origin. `data.len() == width * height`, addressed as
/// `data[y * width + x]`.
///
/// `origin` is the `(x, y)` tile-component coordinate of the top-left sample —
/// the band's `tbx0`/`tby0` (ISO Eq. B-15), not an offset within the tile. The
/// inverse DWT reads the interleave parity straight off it (see [`crate::dwt`]),
/// so it is load-bearing, not bookkeeping: a tile away from the canvas origin,
/// or a sub-sampled component, puts a band at an odd origin, and a band at an
/// odd origin starts on a high-pass sample.
/// The three detail subbands added at one resolution level (ISO xob/yob from
/// Table F.1): `hl` is high-pass horizontally / low-pass vertically, `lh` the
/// reverse, `hh` high-pass in both.
/// All subbands of one tile-component: the coarsest `ll` plus the detail bands
/// added at each resolution level, **coarsest first**. `levels.len()` equals the
/// COD decomposition-level count; an empty `levels` means no transform was
/// applied and `ll` is the image itself.
/// Wavelet coefficients flowing Tier-1 → inverse DWT. The
/// reversible (5/3) path stays integer so it can reconstruct bit-exactly; the
/// irreversible (9/7) path arrives dequantized from Tier-1 and is
/// real-valued, so it carries `f32`. The arm matches the COD transform.
/// One component's reconstructed samples, still on the arithmetic the wavelet
/// used. Reversible 5/3 reconstructs in exact integers; irreversible 9/7
/// reconstructs in `f32` and is *not* rounded here.
///
/// The rounding is deferred to [`crate::image::assemble`] so that it happens
/// exactly once, after the inverse color transform. ICT mixes the first three
/// components arithmetically (Annex G.3), and rounding each of them beforehand
/// would inject up to half a unit of error into that mix. OpenJPEG defers it the
/// same way: `opj_tcd_mct_decode` runs on `OPJ_FLOAT32*`, and
/// `opj_tcd_dc_level_shift_decode` is what calls `opj_lrintf`.