summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/jxl/enc_cluster.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /third_party/jpeg-xl/lib/jxl/enc_cluster.cc
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-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/enc_cluster.cc')
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_cluster.cc19
1 files changed, 9 insertions, 10 deletions
diff --git a/third_party/jpeg-xl/lib/jxl/enc_cluster.cc b/third_party/jpeg-xl/lib/jxl/enc_cluster.cc
index df1b31ddf7..f7284331d9 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_cluster.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_cluster.cc
@@ -236,7 +236,7 @@ void HistogramReindex(std::vector<Histogram>* out, size_t prev_histograms,
// Clusters similar histograms in 'in' together, the selected histograms are
// placed in 'out', and for each index in 'in', *histogram_symbols will
// indicate which of the 'out' histograms is the best approximation.
-void ClusterHistograms(const HistogramParams params,
+void ClusterHistograms(const HistogramParams& params,
const std::vector<Histogram>& in, size_t max_histograms,
std::vector<Histogram>* out,
std::vector<uint32_t>* histogram_symbols) {
@@ -252,9 +252,9 @@ void ClusterHistograms(const HistogramParams params,
if (prev_histograms == 0 &&
params.clustering == HistogramParams::ClusteringType::kBest) {
- for (size_t i = 0; i < out->size(); i++) {
- (*out)[i].entropy_ =
- ANSPopulationCost((*out)[i].data_.data(), (*out)[i].data_.size());
+ for (auto& histo : *out) {
+ histo.entropy_ =
+ ANSPopulationCost(histo.data_.data(), histo.data_.size());
}
uint32_t next_version = 2;
std::vector<uint32_t> version(out->size(), 1);
@@ -308,9 +308,9 @@ void ClusterHistograms(const HistogramParams params,
(*out)[first].AddHistogram((*out)[second]);
(*out)[first].entropy_ = ANSPopulationCost((*out)[first].data_.data(),
(*out)[first].data_.size());
- for (size_t i = 0; i < renumbering.size(); i++) {
- if (renumbering[i] == second) {
- renumbering[i] = first;
+ for (uint32_t& item : renumbering) {
+ if (item == second) {
+ item = first;
}
}
version[second] = 0;
@@ -338,9 +338,8 @@ void ClusterHistograms(const HistogramParams params,
reverse_renumbering[i] = num_alive - 1;
}
out->resize(num_alive);
- for (size_t i = 0; i < histogram_symbols->size(); i++) {
- (*histogram_symbols)[i] =
- reverse_renumbering[renumbering[(*histogram_symbols)[i]]];
+ for (uint32_t& item : *histogram_symbols) {
+ item = reverse_renumbering[renumbering[item]];
}
}