Skip to main content

j2k_core/
scale.rs

1// SPDX-License-Identifier: Apache-2.0
2
3/// Power-of-two downscale requested during decode.
4#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
5#[non_exhaustive]
6pub enum Downscale {
7    /// Full-resolution output.
8    #[default]
9    None,
10    /// Half-resolution output.
11    Half,
12    /// Quarter-resolution output.
13    Quarter,
14    /// Eighth-resolution output.
15    Eighth,
16}
17
18impl Downscale {
19    /// Return the integer scale denominator.
20    pub const fn denominator(self) -> u32 {
21        match self {
22            Self::None => 1,
23            Self::Half => 2,
24            Self::Quarter => 4,
25            Self::Eighth => 8,
26        }
27    }
28
29    /// Return the decoded DCT block dimension after scaling.
30    pub const fn output_block_size(self) -> u32 {
31        match self {
32            Self::None => 8,
33            Self::Half => 4,
34            Self::Quarter => 2,
35            Self::Eighth => 1,
36        }
37    }
38}