j2k_types/transform/quantization.rs
1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3//! Irreversible quantization values and per-subband job contracts.
4
5/// Subband quantization job.
6#[derive(Debug, Clone, Copy)]
7pub struct J2kQuantizeSubbandJob<'a> {
8 /// Source subband coefficients in row-major order.
9 pub coefficients: &'a [f32],
10 /// Quantization step-size exponent.
11 pub step_exponent: u16,
12 /// Quantization step-size mantissa.
13 pub step_mantissa: u16,
14 /// Nominal range bits for this subband.
15 pub range_bits: u8,
16 /// Whether to use reversible integer quantization.
17 pub reversible: bool,
18}
19
20/// Multipliers applied to irreversible 9/7 quantization step sizes by subband.
21#[derive(Debug, Clone, Copy, PartialEq)]
22pub struct IrreversibleQuantizationSubbandScales {
23 /// Multiplier for the LL subband.
24 pub low_low: f32,
25 /// Multiplier for HL subbands.
26 pub high_low: f32,
27 /// Multiplier for LH subbands.
28 pub low_high: f32,
29 /// Multiplier for HH subbands.
30 pub high_high: f32,
31}
32
33impl Default for IrreversibleQuantizationSubbandScales {
34 fn default() -> Self {
35 Self {
36 low_low: 1.0,
37 high_low: 1.0,
38 low_high: 1.0,
39 high_high: 1.0,
40 }
41 }
42}
43
44/// Public JPEG 2000 irreversible quantization step-size tuple.
45#[derive(Debug, Clone, Copy, PartialEq, Eq)]
46pub struct IrreversibleQuantizationStep {
47 /// Quantization step-size exponent.
48 pub exponent: u8,
49 /// Quantization step-size mantissa.
50 pub mantissa: u16,
51}