From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- .../jpeg-xl/lib/jxl/modular/encoding/context_predict.h | 4 ++-- third_party/jpeg-xl/lib/jxl/modular/encoding/enc_ma.cc | 8 ++++---- third_party/jpeg-xl/lib/jxl/modular/encoding/encoding.cc | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'third_party/jpeg-xl/lib/jxl/modular/encoding') diff --git a/third_party/jpeg-xl/lib/jxl/modular/encoding/context_predict.h b/third_party/jpeg-xl/lib/jxl/modular/encoding/context_predict.h index 7bec5128fc..df54a9425e 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/encoding/context_predict.h +++ b/third_party/jpeg-xl/lib/jxl/modular/encoding/context_predict.h @@ -63,7 +63,7 @@ struct State { pixel_type_w pred = 0; // *before* removing the added bits. std::vector pred_errors[kNumPredictors]; std::vector error; - const Header header; + const Header &header; // Allows to approximate division by a number from 1 to 64. // for (int i = 0; i < 64; i++) divlookup[i] = (1 << 24) / (i + 1); @@ -82,7 +82,7 @@ struct State { return static_cast(x) << kPredExtraBits; } - State(Header header, size_t xsize, size_t ysize) : header(header) { + State(const Header &header, size_t xsize, size_t ysize) : header(header) { // Extra margin to avoid out-of-bounds writes. // All have space for two rows of data. for (auto &pred_error : pred_errors) { diff --git a/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_ma.cc b/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_ma.cc index de629ad038..23100bba8b 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_ma.cc +++ b/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_ma.cc @@ -197,7 +197,7 @@ void FindBestSplit(TreeSamples &tree_samples, float threshold, float rcost = std::numeric_limits::max(); Predictor lpred = Predictor::Zero; Predictor rpred = Predictor::Zero; - float Cost() { return lcost + rcost; } + float Cost() const { return lcost + rcost; } }; SplitInfo best_split_static_constant; @@ -242,14 +242,14 @@ void FindBestSplit(TreeSamples &tree_samples, float threshold, // The multiplier ranges cut halfway through the current ranges of static // properties. We do this even if the current node is not a leaf, to // minimize the number of nodes in the resulting tree. - for (size_t i = 0; i < mul_info.size(); i++) { + for (const auto &mmi : mul_info) { uint32_t axis; uint32_t val; IntersectionType t = - BoxIntersects(static_prop_range, mul_info[i].range, axis, val); + BoxIntersects(static_prop_range, mmi.range, axis, val); if (t == IntersectionType::kNone) continue; if (t == IntersectionType::kInside) { - (*tree)[pos].multiplier = mul_info[i].multiplier; + (*tree)[pos].multiplier = mmi.multiplier; break; } if (t == IntersectionType::kPartial) { diff --git a/third_party/jpeg-xl/lib/jxl/modular/encoding/encoding.cc b/third_party/jpeg-xl/lib/jxl/modular/encoding/encoding.cc index bb690b74ba..7e7aa019e3 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/encoding/encoding.cc +++ b/third_party/jpeg-xl/lib/jxl/modular/encoding/encoding.cc @@ -113,7 +113,7 @@ FlatTree FilterTree(const Tree &global_tree, } } - for (size_t j = 0; j < 2; j++) mark_property(flat.properties[j]); + for (int16_t property : flat.properties) mark_property(property); mark_property(flat.property0); output.push_back(flat); } @@ -159,9 +159,9 @@ Status DecodeModularChannelMAANS(BitReader *br, ANSSymbolReader *reader, // From here on, tree lookup returns a *clustered* context ID. // This avoids an extra memory lookup after tree traversal. - for (size_t i = 0; i < tree.size(); i++) { - if (tree[i].property0 == -1) { - tree[i].childID = context_map[tree[i].childID]; + for (auto &node : tree) { + if (node.property0 == -1) { + node.childID = context_map[node.childID]; } } @@ -538,8 +538,8 @@ Status ModularDecode(BitReader *br, Image &image, GroupHeader &header, // Don't do/undo transforms if header is incomplete. header.transforms.clear(); image.transform = header.transforms; - for (size_t c = 0; c < image.channel.size(); c++) { - ZeroFillImage(&image.channel[c].plane); + for (auto &ch : image.channel) { + ZeroFillImage(&ch.plane); } return Status(StatusCode::kNotEnoughBytes); } -- cgit v1.2.3