// 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.
Status GroupDecCache::InitOnce(JxlMemoryManager* memory_manager,
size_t num_passes, size_t used_acs) { for (size_t i = 0; i < num_passes; i++) { if (num_nzeroes[i].xsize() == 0) { // Allocate enough for a whole group - partial groups on the // right/bottom border just use a subset. The valid size is passed via // Rect.
// Initialize the decoder state after all of DC is decoded.
Status PassesDecoderState::InitForAC(size_t num_passes, ThreadPool* pool) {
shared_storage.coeff_order_size = 0; for (uint8_t o = 0; o < AcStrategy::kNumValidStrategies; ++o) { if (((1 << o) & used_acs) == 0) continue;
uint8_t ord = kStrategyOrder[o];
shared_storage.coeff_order_size =
std::max(kCoeffOrderOffset[3 * (ord + 1)] * kDCTBlockSize,
shared_storage.coeff_order_size);
}
size_t sz = num_passes * shared_storage.coeff_order_size; if (sz > shared_storage.coeff_orders.size()) {
shared_storage.coeff_orders.resize(sz);
} returntrue;
}
if (frame_header.CanBeReferenced()) { // Necessary so that SetInputSizes() can allocate output buffers as needed.
frame_storage_for_referencing = ImageBundle(memory_manager, metadata);
}
if (frame_header.upsampling != 1) {
size_t nb_channels =
3 +
(late_ec_upsample ? frame_header.extra_channel_upsampling.size() : 0); for (size_t c = 0; c < nb_channels; c++) {
JXL_RETURN_IF_ERROR(builder.AddStage(GetUpsamplingStage(
frame_header.nonserialized_metadata->transform_data, c,
CeilLog2Nonzero(frame_header.upsampling))));
}
} if (render_noise) {
JXL_RETURN_IF_ERROR(builder.AddStage(GetConvolveNoiseStage(num_c)));
JXL_RETURN_IF_ERROR(builder.AddStage(GetAddNoiseStage(
shared->image_features.noise_params, shared->cmap.base(), num_c)));
} if (frame_header.dc_level != 0) {
JXL_RETURN_IF_ERROR(builder.AddStage(GetWriteToImage3FStage(
memory_manager, &shared_storage.dc_frames[frame_header.dc_level - 1])));
}
if (frame_header.CanBeReferenced() &&
frame_header.save_before_color_transform) {
JXL_RETURN_IF_ERROR(builder.AddStage(GetWriteToImageBundleStage(
&frame_storage_for_referencing, output_encoding_info)));
}
bool has_alpha = false;
size_t alpha_c = 0; for (size_t i = 0; i < metadata->extra_channel_info.size(); i++) { if (metadata->extra_channel_info[i].type == ExtraChannel::kAlpha) {
has_alpha = true;
alpha_c = 3 + i; break;
}
}
if (fast_xyb_srgb8_conversion) { #if !JXL_HIGH_PRECISION
JXL_ENSURE(!NeedsBlending(frame_header));
JXL_ENSURE(!frame_header.CanBeReferenced() ||
frame_header.save_before_color_transform);
JXL_ENSURE(!options.render_spotcolors ||
!metadata->Find(ExtraChannel::kSpotColor)); bool is_rgba = (main_output.format.num_channels == 4);
uint8_t* rgb_output = reinterpret_cast<uint8_t*>(main_output.buffer);
JXL_RETURN_IF_ERROR(builder.AddStage(
GetFastXYBTosRGB8Stage(rgb_output, main_output.stride, width, height,
is_rgba, has_alpha, alpha_c))); #endif
} else { bool linear = false; if (frame_header.color_transform == ColorTransform::kYCbCr) {
JXL_RETURN_IF_ERROR(builder.AddStage(GetYCbCrStage()));
} elseif (frame_header.color_transform == ColorTransform::kXYB) {
JXL_RETURN_IF_ERROR(builder.AddStage(GetXYBStage(output_encoding_info))); if (output_encoding_info.color_encoding.GetColorSpace() !=
ColorSpace::kXYB) {
linear = true;
}
} // Nothing to do for kNone.
if (options.coalescing && NeedsBlending(frame_header)) { if (linear) {
JXL_RETURN_IF_ERROR(
builder.AddStage(GetFromLinearStage(output_encoding_info)));
linear = false;
}
JXL_RETURN_IF_ERROR(builder.AddStage(GetBlendingStage(
frame_header, this, output_encoding_info.color_encoding)));
}
if (options.coalescing && frame_header.CanBeReferenced() &&
!frame_header.save_before_color_transform) { if (linear) {
JXL_RETURN_IF_ERROR(
builder.AddStage(GetFromLinearStage(output_encoding_info)));
linear = false;
}
JXL_RETURN_IF_ERROR(builder.AddStage(GetWriteToImageBundleStage(
&frame_storage_for_referencing, output_encoding_info)));
}
if (options.render_spotcolors &&
frame_header.nonserialized_metadata->m.Find(ExtraChannel::kSpotColor)) { for (size_t i = 0; i < metadata->extra_channel_info.size(); i++) { // Don't use Find() because there may be multiple spot color channels. const ExtraChannelInfo& eci = metadata->extra_channel_info[i]; if (eci.type == ExtraChannel::kSpotColor) {
JXL_RETURN_IF_ERROR(
builder.AddStage(GetSpotColorStage(i, eci.spot_color)));
}
}
}
auto tone_mapping_stage = GetToneMappingStage(output_encoding_info); if (tone_mapping_stage) { if (!linear) { auto to_linear_stage = GetToLinearStage(output_encoding_info); if (!to_linear_stage) { if (!output_encoding_info.cms_set) { return JXL_FAILURE("Cannot tonemap this colorspace without a CMS");
} auto cms_stage = GetCmsStage(output_encoding_info); if (cms_stage) {
JXL_RETURN_IF_ERROR(builder.AddStage(std::move(cms_stage)));
}
} else {
JXL_RETURN_IF_ERROR(builder.AddStage(std::move(to_linear_stage)));
}
linear = true;
}
JXL_RETURN_IF_ERROR(builder.AddStage(std::move(tone_mapping_stage)));
}
if (linear) { const size_t channels_src =
(output_encoding_info.orig_color_encoding.IsCMYK()
? 4
: output_encoding_info.orig_color_encoding.Channels()); const size_t channels_dst =
output_encoding_info.color_encoding.Channels(); bool mixing_color_and_grey = (channels_dst != channels_src); if ((output_encoding_info.color_encoding_is_original) ||
(!output_encoding_info.cms_set) || mixing_color_and_grey) { // in those cases we only need a linear stage in other cases we attempt // to obtain a cms stage: the cases are // - output_encoding_info.color_encoding_is_original: no cms stage // needed because it would be a no-op // - !output_encoding_info.cms_set: can't use the cms, so no point in // trying to add a cms stage // - mixing_color_and_grey: cms stage can't handle that // TODO(firsching): remove "mixing_color_and_grey" condition after // adding support for greyscale to cms stage.
JXL_RETURN_IF_ERROR(
builder.AddStage(GetFromLinearStage(output_encoding_info)));
} else { if (!output_encoding_info.linear_color_encoding.CreateICC()) { return JXL_FAILURE("Failed to create ICC");
} auto cms_stage = GetCmsStage(output_encoding_info); if (cms_stage) {
JXL_RETURN_IF_ERROR(builder.AddStage(std::move(cms_stage)));
}
}
linear = false;
}
(void)linear;
¤ 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.0.11Bemerkung:
(vorverarbeitet)
¤
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.