Skip to main content

DecodeReport

Struct DecodeReport 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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

Source

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.

Trait Implementations§

Source§

impl Clone for DecodeReport

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DecodeReport

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DecodeReport

Source§

fn default() -> Self

The report of a whole codestream: no entries, complete at reduction 0.

Source§

impl Eq for DecodeReport

Source§

impl PartialEq for DecodeReport

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DecodeReport

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.