diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
commit | fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch) | |
tree | 4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.cc | |
parent | Releasing progress-linux version 124.0.1-1~progress7.99u1. (diff) | |
download | firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.cc')
-rw-r--r-- | third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.cc | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.cc b/third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.cc index 0ae2223252..120a977ca7 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.cc +++ b/third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.cc @@ -10,26 +10,16 @@ #include <sys/types.h> #include <algorithm> -#include <string> -#include <tuple> #include <utility> #include <vector> -#include "lib/jxl/ans_params.h" -#include "lib/jxl/base/compiler_specific.h" -#include "lib/jxl/base/override.h" #include "lib/jxl/base/printf_macros.h" #include "lib/jxl/base/status.h" #include "lib/jxl/blending.h" -#include "lib/jxl/chroma_from_luma.h" #include "lib/jxl/common.h" // kMaxNumReferenceFrames #include "lib/jxl/dec_ans.h" -#include "lib/jxl/dec_frame.h" -#include "lib/jxl/entropy_coder.h" -#include "lib/jxl/frame_header.h" #include "lib/jxl/image.h" #include "lib/jxl/image_bundle.h" -#include "lib/jxl/image_ops.h" #include "lib/jxl/pack_signed.h" #include "lib/jxl/patch_dictionary_internal.h" @@ -138,7 +128,8 @@ Status PatchDictionary::Decode(BitReader* br, size_t xsize, size_t ysize, } for (size_t j = 0; j < num_ec + 1; j++) { uint32_t blend_mode = read_num(kPatchBlendModeContext); - if (blend_mode >= uint32_t(PatchBlendMode::kNumBlendModes)) { + if (blend_mode >= + static_cast<uint32_t>(PatchBlendMode::kNumBlendModes)) { return JXL_FAILURE("Invalid patch blend mode: %u", blend_mode); } PatchBlending info; @@ -157,21 +148,22 @@ Status PatchDictionary::Decode(BitReader* br, size_t xsize, size_t ysize, return JXL_FAILURE( "Invalid alpha channel for blending: %u out of %u\n", info.alpha_channel, - (uint32_t)shared_->metadata->m.extra_channel_info.size()); + static_cast<uint32_t>( + shared_->metadata->m.extra_channel_info.size())); } } else { info.alpha_channel = 0; } if (UsesClamp(info.mode)) { - info.clamp = read_num(kPatchClampContext); + info.clamp = static_cast<bool>(read_num(kPatchClampContext)); } else { info.clamp = false; } blendings_.push_back(info); } - positions_.push_back(std::move(pos)); + positions_.emplace_back(pos); } - ref_positions_.emplace_back(std::move(ref_pos)); + ref_positions_.emplace_back(ref_pos); } positions_.shrink_to_fit(); @@ -185,8 +177,8 @@ Status PatchDictionary::Decode(BitReader* br, size_t xsize, size_t ysize, int PatchDictionary::GetReferences() const { int result = 0; - for (size_t i = 0; i < ref_positions_.size(); ++i) { - result |= (1 << static_cast<int>(ref_positions_[i].ref)); + for (const auto& ref_pos : ref_positions_) { + result |= (1 << static_cast<int>(ref_pos.ref)); } return result; } @@ -263,11 +255,11 @@ void PatchDictionary::ComputePatchTree() { node.start = sorted_patches_y0_.size(); for (ssize_t i = static_cast<ssize_t>(right_start) - 1; i >= static_cast<ssize_t>(left_end); --i) { - sorted_patches_y1_.push_back({intervals[i].y1, intervals[i].idx}); + sorted_patches_y1_.emplace_back(intervals[i].y1, intervals[i].idx); } sort_by_y0(left_end, right_start); for (size_t i = left_end; i < right_start; ++i) { - sorted_patches_y0_.push_back({intervals[i].y0, intervals[i].idx}); + sorted_patches_y0_.emplace_back(intervals[i].y0, intervals[i].idx); } // Create the left and right nodes (if not empty). node.left_child = node.right_child = -1; @@ -294,7 +286,7 @@ std::vector<size_t> PatchDictionary::GetPatchesForRow(size_t y) const { if (y < num_patches_.size() && num_patches_[y] > 0) { result.reserve(num_patches_[y]); for (ssize_t tree_idx = 0; tree_idx != -1;) { - JXL_DASSERT(tree_idx < (ssize_t)patch_tree_.size()); + JXL_DASSERT(tree_idx < static_cast<ssize_t>(patch_tree_.size())); const auto& node = patch_tree_[tree_idx]; if (y <= node.y_center) { for (size_t i = 0; i < node.num; ++i) { @@ -322,8 +314,8 @@ std::vector<size_t> PatchDictionary::GetPatchesForRow(size_t y) const { // Adds patches to a segment of `xsize` pixels, starting at `inout`, assumed // to be located at position (x0, y) in the frame. -void PatchDictionary::AddOneRow(float* const* inout, size_t y, size_t x0, - size_t xsize) const { +Status PatchDictionary::AddOneRow(float* const* inout, size_t y, size_t x0, + size_t xsize) const { size_t num_ec = shared_->metadata->m.num_extra_channels; std::vector<const float*> fg_ptrs(3 + num_ec); for (size_t pos_idx : GetPatchesForRow(y)) { @@ -352,10 +344,11 @@ void PatchDictionary::AddOneRow(float* const* inout, size_t y, size_t x0, ref_pos.y0 + iy) + ref_pos.x0 + x0 - bx; } - PerformBlending(inout, fg_ptrs.data(), inout, patch_x0 - x0, - patch_x1 - patch_x0, blendings_[blending_idx], - blendings_.data() + blending_idx + 1, - shared_->metadata->m.extra_channel_info); + JXL_RETURN_IF_ERROR(PerformBlending( + inout, fg_ptrs.data(), inout, patch_x0 - x0, patch_x1 - patch_x0, + blendings_[blending_idx], blendings_.data() + blending_idx + 1, + shared_->metadata->m.extra_channel_info)); } + return true; } } // namespace jxl |