#[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 = include_bytes!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/tests/fixtures/jpeg2000_regular_latlon.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.
The list is bounded by the input: at most five entries per tile-part
the codestream carries, plus two. A run of missing tiles is one
ReportEntry::MissingTiles entry, however many tiles it spans.
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. 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 leave it true.