Skip to main content

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/// HTJ2K code-block encode job.
23#[derive(Debug, Clone, Copy)]
24pub struct J2kHtCodeBlockEncodeJob<'a> {
25    /// Quantized coefficients in row-major order.
26    pub coefficients: &'a [i32],
27    /// Code-block width in samples.
28    pub width: u32,
29    /// Code-block height in samples.
30    pub height: u32,
31    /// Total bitplanes for this subband/code block.
32    pub total_bitplanes: u8,
33    /// Requested HT coding passes for this contribution.
34    ///
35    /// `1` is cleanup-only. `2` requests cleanup plus significance-propagation
36    /// refinement on the native CPU path. `3` additionally requests one
37    /// magnitude-refinement pass. Higher values require an accelerator and
38    /// must not be silently reduced by CPU fallback.
39    pub target_coding_passes: u8,
40}
41
42/// HTJ2K cleanup/refinement encode job for one unquantized subband.
43#[derive(Debug, Clone, Copy)]
44pub struct J2kHtSubbandEncodeJob<'a> {
45    /// Source subband coefficients in row-major order.
46    pub coefficients: &'a [f32],
47    /// Subband width in samples.
48    pub width: u32,
49    /// Subband height in samples.
50    pub height: u32,
51    /// Quantization step-size exponent.
52    pub step_exponent: u16,
53    /// Quantization step-size mantissa.
54    pub step_mantissa: u16,
55    /// Nominal range bits for this subband.
56    pub range_bits: u8,
57    /// Whether to use reversible integer quantization.
58    pub reversible: bool,
59    /// Code-block width in samples.
60    pub code_block_width: u32,
61    /// Code-block height in samples.
62    pub code_block_height: u32,
63    /// Total coded bitplanes for this subband.
64    pub total_bitplanes: u8,
65}
66
67crate::move_only::assert_move_only!(EncodedHtJ2kCodeBlock);