// Copyright (c) the JPEG XL Project Authors. All rights reserved. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file.
use std::{collections::BTreeSet, sync::Arc};
usecrate::{
api::JxlDecoderOptions,
entropy_coding::decode::Histograms,
error::Result,
features::{noise::Noise, patches::PatchesDictionary, spline::Splines},
headers::{
FileHeader,
extra_channels::ExtraChannelInfo,
frame_header::{Encoding, FrameHeader, FrameType},
permutation::Permutation,
toc::Toc,
},
image::Image,
util::tracing_wrappers::*,
}; use adaptive_lf_smoothing::adaptive_lf_smoothing; use block_context_map::BlockContextMap; use color_correlation_map::ColorCorrelationParams; use modular::{FullModularImage, Tree}; use quant_weights::DequantMatrices; use quantizer::{LfQuantFactors, QuantizerParams};
mod adaptive_lf_smoothing; mod block_context_map; mod coeff_order; pubmod color_correlation_map; pubmod decode; mod group; pubmod lf_preview; pubmod modular; mod quant_weights; pubmod quantizer; pubmod render;
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] pubenum RenderUnit { /// VarDCT data
VarDCT, /// Modular channel with the given index
Modular(usize),
}
pubstruct Frame {
header: FrameHeader,
toc: Toc,
color_channels: usize,
lf_global: Option<LfGlobalState>,
hf_global: Option<HfGlobalState>,
lf_image: Option<[Image<f32>; 3]>,
quant_lf: Image<u8>,
hf_meta: Option<HfMetadata>,
decoder_state: DecoderState, #[cfg(test)]
use_simple_pipeline: bool, #[cfg(test)]
render_pipeline: Option<Box<dyn std::any::Any>>, #[cfg(not(test))]
render_pipeline: Option<Box<crate::render::LowMemoryRenderPipeline>>,
reference_frame_data: Option<Vec<Image<f32>>>,
lf_frame_data: Option<[Image<f32>; 3]>,
was_flushed_once: bool, /// Reusable buffers for VarDCT group decoding.
vardct_buffers: Option<group::VarDctBuffers>, // Last pass rendered so far for each HF group.
last_rendered_pass: Vec<Option<usize>>, // Groups that should be rendered on the next call to flush().
groups_to_flush: BTreeSet<usize>,
changed_since_last_flush: BTreeSet<(usize, RenderUnit)>,
incomplete_groups: usize,
patches: Arc<AtomicRefCell<PatchesDictionary>>,
splines: Arc<AtomicRefCell<Splines>>,
noise: Arc<AtomicRefCell<Noise>>,
lf_quant: Arc<AtomicRefCell<LfQuantFactors>>,
color_correlation_params: Arc<AtomicRefCell<ColorCorrelationParams>>,
epf_sigma: Arc<AtomicRefCell<SigmaSource>>,
}
pubfn finalize(mutself) -> Result<Option<DecoderState>> { // First, drop the render pipeline to ensure that no other references to the reference // frames are around. self.render_pipeline = None; // Save reference frame if this frame can be referenced and was actually decoded. // If reference_frame_data is None (frame was skipped), we don't save it. // Subsequent frames referencing this slot may fail. ifself.header.can_be_referenced
&& let Some(frame_data) = self.reference_frame_data
{
info!("Saving frame in slot {}", self.header.save_as_reference); let rf = Arc::get_mut(&mutself.decoder_state.reference_frames)
.expect("remaining references to reference_frames");
rf[self.header.save_as_reference as usize] = Some(ReferenceFrame {
frame: frame_data,
saved_before_color_transform: self.header.save_before_ct,
});
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.