summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/jxl/jpeg
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /third_party/jpeg-xl/lib/jxl/jpeg
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/jpeg-xl/lib/jxl/jpeg')
-rw-r--r--third_party/jpeg-xl/lib/jxl/jpeg/dec_jpeg_data.cc7
-rw-r--r--third_party/jpeg-xl/lib/jxl/jpeg/dec_jpeg_data_writer.cc4
-rw-r--r--third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data.cc19
-rw-r--r--third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data_reader.cc37
-rw-r--r--third_party/jpeg-xl/lib/jxl/jpeg/jpeg_data.cc18
5 files changed, 40 insertions, 45 deletions
diff --git a/third_party/jpeg-xl/lib/jxl/jpeg/dec_jpeg_data.cc b/third_party/jpeg-xl/lib/jxl/jpeg/dec_jpeg_data.cc
index 9763786453..a971eb3dcc 100644
--- a/third_party/jpeg-xl/lib/jxl/jpeg/dec_jpeg_data.cc
+++ b/third_party/jpeg-xl/lib/jxl/jpeg/dec_jpeg_data.cc
@@ -106,15 +106,14 @@ Status DecodeJPEGData(Span<const uint8_t> encoded, JPEGData* jpeg_data) {
}
}
// TODO(eustas): actually inject ICC profile and check it fits perfectly.
- for (size_t i = 0; i < jpeg_data->com_data.size(); i++) {
- auto& marker = jpeg_data->com_data[i];
+ for (auto& marker : jpeg_data->com_data) {
JXL_RETURN_IF_ERROR(br_read(marker));
if (marker[1] * 256u + marker[2] + 1u != marker.size()) {
return JXL_FAILURE("Incorrect marker size");
}
}
- for (size_t i = 0; i < jpeg_data->inter_marker_data.size(); i++) {
- JXL_RETURN_IF_ERROR(br_read(jpeg_data->inter_marker_data[i]));
+ for (auto& data : jpeg_data->inter_marker_data) {
+ JXL_RETURN_IF_ERROR(br_read(data));
}
JXL_RETURN_IF_ERROR(br_read(jpeg_data->tail_data));
diff --git a/third_party/jpeg-xl/lib/jxl/jpeg/dec_jpeg_data_writer.cc b/third_party/jpeg-xl/lib/jxl/jpeg/dec_jpeg_data_writer.cc
index 31bb2dda23..77c8b885e1 100644
--- a/third_party/jpeg-xl/lib/jxl/jpeg/dec_jpeg_data_writer.cc
+++ b/third_party/jpeg-xl/lib/jxl/jpeg/dec_jpeg_data_writer.cc
@@ -385,8 +385,8 @@ bool EncodeDHT(const JPEGData& jpg, SerializationState* state) {
for (size_t i = state->dht_index; i < huffman_code.size(); ++i) {
const JPEGHuffmanCode& huff = huffman_code[i];
marker_len += kJpegHuffmanMaxBitLength;
- for (size_t j = 0; j < huff.counts.size(); ++j) {
- marker_len += huff.counts[j];
+ for (uint32_t count : huff.counts) {
+ marker_len += count;
}
if (huff.is_last) break;
}
diff --git a/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data.cc b/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data.cc
index d311908415..d7c6c2ad78 100644
--- a/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data.cc
+++ b/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data.cc
@@ -173,8 +173,7 @@ Status ParseChunkedMarker(const jpeg::JPEGData& src, uint8_t marker_type,
}
Status SetBlobsFromJpegData(const jpeg::JPEGData& jpeg_data, Blobs* blobs) {
- for (size_t i = 0; i < jpeg_data.app_data.size(); i++) {
- const auto& marker = jpeg_data.app_data[i];
+ for (const auto& marker : jpeg_data.app_data) {
if (marker.empty() || marker[0] != kApp1) {
continue;
}
@@ -318,11 +317,11 @@ Status EncodeJPEGData(JPEGData& jpeg_data, std::vector<uint8_t>* bytes,
}
total_data += jpeg_data.app_data[i].size();
}
- for (size_t i = 0; i < jpeg_data.com_data.size(); i++) {
- total_data += jpeg_data.com_data[i].size();
+ for (const auto& data : jpeg_data.com_data) {
+ total_data += data.size();
}
- for (size_t i = 0; i < jpeg_data.inter_marker_data.size(); i++) {
- total_data += jpeg_data.inter_marker_data[i].size();
+ for (const auto& data : jpeg_data.inter_marker_data) {
+ total_data += data.size();
}
total_data += jpeg_data.tail_data.size();
size_t brotli_capacity = BrotliEncoderMaxCompressedSize(total_data);
@@ -365,11 +364,11 @@ Status EncodeJPEGData(JPEGData& jpeg_data, std::vector<uint8_t>* bytes,
}
br_append(jpeg_data.app_data[i], /*last=*/false);
}
- for (size_t i = 0; i < jpeg_data.com_data.size(); i++) {
- br_append(jpeg_data.com_data[i], /*last=*/false);
+ for (const auto& data : jpeg_data.com_data) {
+ br_append(data, /*last=*/false);
}
- for (size_t i = 0; i < jpeg_data.inter_marker_data.size(); i++) {
- br_append(jpeg_data.inter_marker_data[i], /*last=*/false);
+ for (const auto& data : jpeg_data.inter_marker_data) {
+ br_append(data, /*last=*/false);
}
br_append(jpeg_data.tail_data, /*last=*/true);
BrotliEncoderDestroyInstance(brotli_enc);
diff --git a/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data_reader.cc b/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data_reader.cc
index d1e8476db6..8208bba675 100644
--- a/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data_reader.cc
+++ b/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data_reader.cc
@@ -92,21 +92,21 @@ bool ProcessSOF(const uint8_t* data, const size_t len, JpegReadMode mode,
std::vector<bool> ids_seen(256, false);
int max_h_samp_factor = 1;
int max_v_samp_factor = 1;
- for (size_t i = 0; i < jpg->components.size(); ++i) {
+ for (auto& component : jpg->components) {
const int id = ReadUint8(data, pos);
if (ids_seen[id]) { // (cf. section B.2.2, syntax of Ci)
return JXL_FAILURE("Duplicate ID %d in SOF.", id);
}
ids_seen[id] = true;
- jpg->components[i].id = id;
+ component.id = id;
int factor = ReadUint8(data, pos);
int h_samp_factor = factor >> 4;
int v_samp_factor = factor & 0xf;
JXL_JPEG_VERIFY_INPUT(h_samp_factor, 1, kBrunsliMaxSampling, SAMP_FACTOR);
JXL_JPEG_VERIFY_INPUT(v_samp_factor, 1, kBrunsliMaxSampling, SAMP_FACTOR);
- jpg->components[i].h_samp_factor = h_samp_factor;
- jpg->components[i].v_samp_factor = v_samp_factor;
- jpg->components[i].quant_idx = ReadUint8(data, pos);
+ component.h_samp_factor = h_samp_factor;
+ component.v_samp_factor = v_samp_factor;
+ component.quant_idx = ReadUint8(data, pos);
max_h_samp_factor = std::max(max_h_samp_factor, h_samp_factor);
max_v_samp_factor = std::max(max_v_samp_factor, v_samp_factor);
}
@@ -116,18 +116,17 @@ bool ProcessSOF(const uint8_t* data, const size_t len, JpegReadMode mode,
int MCU_rows = DivCeil(jpg->height, max_v_samp_factor * 8);
int MCU_cols = DivCeil(jpg->width, max_h_samp_factor * 8);
// Compute the block dimensions for each component.
- for (size_t i = 0; i < jpg->components.size(); ++i) {
- JPEGComponent* c = &jpg->components[i];
- if (max_h_samp_factor % c->h_samp_factor != 0 ||
- max_v_samp_factor % c->v_samp_factor != 0) {
+ for (JPEGComponent& c : jpg->components) {
+ if (max_h_samp_factor % c.h_samp_factor != 0 ||
+ max_v_samp_factor % c.v_samp_factor != 0) {
return JXL_FAILURE("Non-integral subsampling ratios.");
}
- c->width_in_blocks = MCU_cols * c->h_samp_factor;
- c->height_in_blocks = MCU_rows * c->v_samp_factor;
+ c.width_in_blocks = MCU_cols * c.h_samp_factor;
+ c.height_in_blocks = MCU_rows * c.v_samp_factor;
const uint64_t num_blocks =
- static_cast<uint64_t>(c->width_in_blocks) * c->height_in_blocks;
+ static_cast<uint64_t>(c.width_in_blocks) * c.height_in_blocks;
if (mode == JpegReadMode::kReadAll) {
- c->coeffs.resize(num_blocks * kDCTBlockSize);
+ c.coeffs.resize(num_blocks * kDCTBlockSize);
}
}
JXL_JPEG_VERIFY_MARKER_END();
@@ -192,8 +191,8 @@ bool ProcessSOS(const uint8_t* data, const size_t len, size_t* pos,
for (size_t i = 0; i < comps_in_scan; ++i) {
bool found_dc_table = false;
bool found_ac_table = false;
- for (size_t j = 0; j < jpg->huffman_code.size(); ++j) {
- uint32_t slot_id = jpg->huffman_code[j].slot_id;
+ for (const auto& code : jpg->huffman_code) {
+ uint32_t slot_id = code.slot_id;
if (slot_id == scan_info.components[i].dc_tbl_idx) {
found_dc_table = true;
} else if (slot_id == scan_info.components[i].ac_tbl_idx + 16) {
@@ -757,11 +756,9 @@ bool ProcessScan(const uint8_t* data, const size_t len,
bool is_interleaved = (scan_info->num_components > 1);
int max_h_samp_factor = 1;
int max_v_samp_factor = 1;
- for (size_t i = 0; i < jpg->components.size(); ++i) {
- max_h_samp_factor =
- std::max(max_h_samp_factor, jpg->components[i].h_samp_factor);
- max_v_samp_factor =
- std::max(max_v_samp_factor, jpg->components[i].v_samp_factor);
+ for (const auto& component : jpg->components) {
+ max_h_samp_factor = std::max(max_h_samp_factor, component.h_samp_factor);
+ max_v_samp_factor = std::max(max_v_samp_factor, component.v_samp_factor);
}
int MCU_rows = DivCeil(jpg->height, max_v_samp_factor * 8);
diff --git a/third_party/jpeg-xl/lib/jxl/jpeg/jpeg_data.cc b/third_party/jpeg-xl/lib/jxl/jpeg/jpeg_data.cc
index aeb9914cca..3217115acb 100644
--- a/third_party/jpeg-xl/lib/jxl/jpeg/jpeg_data.cc
+++ b/third_party/jpeg-xl/lib/jxl/jpeg/jpeg_data.cc
@@ -78,8 +78,8 @@ Status JPEGData::VisitFields(Visitor* visitor) {
if (marker_order.size() > 16384) {
return JXL_FAILURE("Too many markers: %" PRIuS "\n", marker_order.size());
}
- for (size_t i = 0; i < marker_order.size(); i++) {
- JXL_RETURN_IF_ERROR(VisitMarker(&marker_order[i], visitor, &info));
+ for (uint8_t& marker : marker_order) {
+ JXL_RETURN_IF_ERROR(VisitMarker(&marker, visitor, &info));
}
if (!marker_order.empty()) {
// Last marker should always be EOI marker.
@@ -175,8 +175,8 @@ Status JPEGData::VisitFields(Visitor* visitor) {
components.resize(num_components);
}
if (component_type == JPEGComponentType::kCustom) {
- for (size_t i = 0; i < components.size(); i++) {
- JXL_RETURN_IF_ERROR(visitor->Bits(8, 0, &components[i].id));
+ for (auto& component : components) {
+ JXL_RETURN_IF_ERROR(visitor->Bits(8, 0, &component.id));
}
} else if (component_type == JPEGComponentType::kGray) {
components[0].id = 1;
@@ -322,11 +322,11 @@ Status JPEGData::VisitFields(Visitor* visitor) {
scan.extra_zero_runs.resize(num_extra_zero_runs);
}
last_block_idx = -1;
- for (size_t i = 0; i < scan.extra_zero_runs.size(); ++i) {
- uint32_t& block_idx = scan.extra_zero_runs[i].block_idx;
- JXL_RETURN_IF_ERROR(visitor->U32(
- Val(1), BitsOffset(2, 2), BitsOffset(4, 5), BitsOffset(8, 20), 1,
- &scan.extra_zero_runs[i].num_extra_zero_runs));
+ for (auto& extra_zero_run : scan.extra_zero_runs) {
+ uint32_t& block_idx = extra_zero_run.block_idx;
+ JXL_RETURN_IF_ERROR(visitor->U32(Val(1), BitsOffset(2, 2),
+ BitsOffset(4, 5), BitsOffset(8, 20), 1,
+ &extra_zero_run.num_extra_zero_runs));
block_idx -= last_block_idx + 1;
JXL_RETURN_IF_ERROR(visitor->U32(Val(0), BitsOffset(3, 1),
BitsOffset(5, 9), BitsOffset(28, 41), 0,