#[non_exhaustive]pub enum Scale {
Eighth,
Quarter,
Half,
Full,
}Expand description
How much of an image a decode produces, as eighths of full size.
§What it buys
A downsampled block can be produced directly from its coefficients, so a thumbnail never materializes the full-resolution image for the rest of the pipeline to carry: at 1/8 the resize, colour conversion and every later op see one sixty-fourth of the pixels. The reduced transform is also cheaper than the full one at 1/8 and 1/4, though at 1/2 it is not — it folds all sixty-four coefficients into sixteen outputs. The saving that matters is downstream, not in the transform.
This is a resolution reduction, not random access: rows still arrive top
to bottom, and every coefficient is still entropy-decoded. A scaled decode
is therefore a decoder configuration rather than a
DecodeCapability.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Eighth
1/8 scale: the DC coefficient alone.
Quarter
1/4 scale.
Half
1/2 scale.
Full
Full resolution.
Implementations§
Source§impl Scale
impl Scale
Sourcepub const fn block_size(self) -> u32
pub const fn block_size(self) -> u32
The side of the block this scale produces, in samples: M of M/8.
Sourcepub const fn apply(self, source: u32) -> u32
pub const fn apply(self, source: u32) -> u32
The size source decodes to at this scale.
Rounded up, as the format requires: an image 61 pixels wide is 8 blocks across, and at 1/8 scale those 8 blocks are 8 samples.
Sourcepub fn fitting(source: (u32, u32), target: (u32, u32)) -> Scale
pub fn fitting(source: (u32, u32), target: (u32, u32)) -> Scale
The coarsest scale still at least target in both axes.
Never returns a scale that would decode below the target: enlarging afterwards would throw away detail and then invent it back, which is worse than decoding one step larger and shrinking properly.