j2k_types/tier1/htj2k.rs
1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3//! HTJ2K Tier-1 coding values.
4
5use alloc::vec::Vec;
6
7/// Encoded HTJ2K cleanup/refinement code-block payload.
8#[derive(Debug)]
9pub struct EncodedHtJ2kCodeBlock {
10 /// Combined cleanup/refinement bytes for this code block.
11 pub data: Vec<u8>,
12 /// Cleanup segment length in bytes.
13 pub cleanup_length: u32,
14 /// Refinement segment length in bytes.
15 pub refinement_length: u32,
16 /// Number of coding passes present for this code block.
17 pub num_coding_passes: u8,
18 /// Number of zero most-significant bitplanes before first inclusion.
19 pub num_zero_bitplanes: u8,
20}
21
22/// Encoded payload and exact pass boundaries for one expert HT set candidate.
23#[doc(hidden)]
24#[derive(Debug)]
25pub struct EncodedHtJ2kCodeBlockSet {
26 /// Combined cleanup, `SigProp`, and `MagRef` bytes.
27 pub data: Vec<u8>,
28 /// Cleanup segment length in bytes.
29 pub cleanup_length: u32,
30 /// `SigProp` prefix length within the refinement segment.
31 pub sigprop_length: u32,
32 /// `MagRef` suffix length within the refinement segment.
33 pub magref_length: u32,
34 /// Number of passes present from this set.
35 pub num_coding_passes: u8,
36 /// Missing most-significant planes for this cleanup pass.
37 pub num_zero_bitplanes: u8,
38}
39
40/// HTJ2K code-block encode job.
41#[derive(Debug, Clone, Copy)]
42pub struct J2kHtCodeBlockEncodeJob<'a> {
43 /// Quantized coefficients in row-major order.
44 pub coefficients: &'a [i32],
45 /// Code-block width in samples.
46 pub width: u32,
47 /// Code-block height in samples.
48 pub height: u32,
49 /// Total bitplanes for this subband/code block.
50 pub total_bitplanes: u8,
51 /// Requested HT coding passes for this contribution.
52 ///
53 /// `1` is cleanup-only. `2` requests cleanup plus significance-propagation
54 /// refinement on the native CPU path. `3` additionally requests one
55 /// magnitude-refinement pass. Higher values require an accelerator and
56 /// must not be silently reduced by CPU fallback.
57 pub target_coding_passes: u8,
58}
59
60/// Expert HTJ2K job that selects one exact cleanup/refinement set.
61///
62/// This is used by bounded FBCOT candidate generation. Ordinary callers
63/// should use [`J2kHtCodeBlockEncodeJob`].
64#[doc(hidden)]
65#[derive(Debug, Clone, Copy)]
66pub struct J2kHtCodeBlockSetEncodeJob<'a> {
67 /// Quantized coefficients in row-major order.
68 pub coefficients: &'a [i32],
69 /// Code-block width in samples.
70 pub width: u32,
71 /// Code-block height in samples.
72 pub height: u32,
73 /// Total bitplanes for this subband/code block.
74 pub total_bitplanes: u8,
75 /// Least-significant magnitude bitplane represented by the cleanup pass.
76 pub cleanup_bitplane: u8,
77 /// Number of passes from this set to encode, in the range 1 through 3.
78 pub target_coding_passes: u8,
79}
80
81/// HTJ2K cleanup/refinement encode job for one unquantized subband.
82#[derive(Debug, Clone, Copy)]
83pub struct J2kHtSubbandEncodeJob<'a> {
84 /// Source subband coefficients in row-major order.
85 pub coefficients: &'a [f32],
86 /// Subband width in samples.
87 pub width: u32,
88 /// Subband height in samples.
89 pub height: u32,
90 /// Quantization step-size exponent.
91 pub step_exponent: u16,
92 /// Quantization step-size mantissa.
93 pub step_mantissa: u16,
94 /// Nominal range bits for this subband.
95 pub range_bits: u8,
96 /// Whether to use reversible integer quantization.
97 pub reversible: bool,
98 /// Code-block width in samples.
99 pub code_block_width: u32,
100 /// Code-block height in samples.
101 pub code_block_height: u32,
102 /// Total coded bitplanes for this subband.
103 pub total_bitplanes: u8,
104}
105
106crate::move_only::assert_move_only!(EncodedHtJ2kCodeBlock);
107crate::move_only::assert_move_only!(EncodedHtJ2kCodeBlockSet);