summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/jxl/modular/encoding
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/jpeg-xl/lib/jxl/modular/encoding')
-rw-r--r--third_party/jpeg-xl/lib/jxl/modular/encoding/context_predict.h4
-rw-r--r--third_party/jpeg-xl/lib/jxl/modular/encoding/enc_ma.cc8
-rw-r--r--third_party/jpeg-xl/lib/jxl/modular/encoding/encoding.cc12
3 files changed, 12 insertions, 12 deletions
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<uint32_t> pred_errors[kNumPredictors];
std::vector<int32_t> 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<uint64_t>(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<float>::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);
}