#[non_exhaustive]pub struct DecodeReport {
pub entries: Vec<ReportEntry>,
pub complete_reduction: Option<u8>,
/* private fields */
}Expand description
What a decode left out, and how far the data reached.
A strict decode (the default) returns an image only when nothing is
missing, so its report is always the complete one: no entries and a
complete_reduction of Some(0). That is also
DecodeReport::default. With
strict off, the decode returns the image
it could make and says here what it left out.
use rust_j2k::{DecodeOptions, decode_with, read_header};
let bytes = std::fs::read("image.j2k")?;
// Only the first part of the codestream has arrived.
let prefix = &bytes[..bytes.len() * 3 / 4];
let options = DecodeOptions::default().with_strict(false);
let image = decode_with(prefix, &options).expect("the main header is there");
let report = &image.report;
if !report.is_complete() {
for entry in &report.entries {
println!("{entry}");
}
// The finest level the data already holds in full, if any, and if a
// decode may ask for it.
let max = read_header(prefix).expect("the main header is there").max_reduction;
if let Some(reduction) = report.complete_reduction.filter(|&r| r <= max) {
let options = options.with_resolution_reduction(reduction);
let coarse = decode_with(prefix, &options).expect("decodes");
assert!(coarse.report.is_complete());
}
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.entries: Vec<ReportEntry>What was missing, skipped or irregular, in the order the decoder met
them. Empty when the codestream was whole. Under a
region of a window or a tile, only
the tiles the decode reads are reported, and a run of missing tiles is split into the runs of it
the decode reads. Under a window or
components, only the packets
the returned samples need are reported missing (see
ReportEntry::MissingPackets).
The list is bounded by the input: at most five entries per tile-part
the codestream carries, plus two, and under a window one more per row
of missing tiles it reads. A run of missing tiles is one
ReportEntry::MissingTiles entry, however many tiles it spans, or
under a window one per row of tiles it reads.
complete_reduction: Option<u8>The smallest resolution_reduction
at which every tile has every packet: a decode at this reduction, or
any larger one the file allows, gives the same samples as a decode of
the whole codestream. Under a window or a tile
(region) or
components, only the packets the
same decode returns samples from count: those of the tiles it reads,
the components it reconstructs, and the code-blocks the window’s
samples depend on at that reduction. Under a
max_quality_layers cap,
only the packets of the layers it keeps count, and the decode compared
against has the same cap. It is counted over all of the data, whatever
reduction this decode used, so one cheap decode at a coarse level says
which finer level the data can already give. It can be larger than
Header::max_reduction, the largest
reduction a decode may ask for.
None when no reduction is complete: even the coarsest resolution has
a packet missing, a tile is missing, or a tile has bytes left over (see
ReportEntry::LeftoverBytes).
Implementations§
Source§impl DecodeReport
impl DecodeReport
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Whether the samples are what the whole codestream gives at the reduction this decode used.
That holds when complete_reduction is at
most that reduction, no tile is missing and no tile has bytes left
over. A missing EOC marker, a tile-part count that disagrees with the
parts found (ReportEntry::TilePartCountMismatch), and packets
missing only from the resolutions the reduction drops, or from the
layers past the
max_quality_layers cap,
leave it true.