summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/jxl
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/jpeg-xl/lib/jxl')
-rw-r--r--third_party/jpeg-xl/lib/jxl/ac_context.h11
-rw-r--r--third_party/jpeg-xl/lib/jxl/ac_strategy.h3
-rw-r--r--third_party/jpeg-xl/lib/jxl/ac_strategy_test.cc8
-rw-r--r--third_party/jpeg-xl/lib/jxl/ans_common.h11
-rw-r--r--third_party/jpeg-xl/lib/jxl/ans_test.cc3
-rw-r--r--third_party/jpeg-xl/lib/jxl/base/compiler_specific.h10
-rw-r--r--third_party/jpeg-xl/lib/jxl/base/exif.h6
-rw-r--r--third_party/jpeg-xl/lib/jxl/base/include_jpeglib.h20
-rw-r--r--third_party/jpeg-xl/lib/jxl/base/matrix_ops.h6
-rw-r--r--third_party/jpeg-xl/lib/jxl/base/rect.h194
-rw-r--r--third_party/jpeg-xl/lib/jxl/base/span.h7
-rw-r--r--third_party/jpeg-xl/lib/jxl/bit_reader_test.cc1
-rw-r--r--third_party/jpeg-xl/lib/jxl/bits_test.cc3
-rw-r--r--third_party/jpeg-xl/lib/jxl/blending.cc9
-rw-r--r--third_party/jpeg-xl/lib/jxl/blending.h2
-rw-r--r--third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.cc10
-rw-r--r--third_party/jpeg-xl/lib/jxl/cache_aligned.h2
-rw-r--r--third_party/jpeg-xl/lib/jxl/chroma_from_luma.h7
-rw-r--r--third_party/jpeg-xl/lib/jxl/cms/jxl_cms_internal.h16
-rw-r--r--third_party/jpeg-xl/lib/jxl/cms/opsin_params.h3
-rw-r--r--third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h1
-rw-r--r--third_party/jpeg-xl/lib/jxl/coeff_order.h17
-rw-r--r--third_party/jpeg-xl/lib/jxl/coeff_order_fwd.h4
-rw-r--r--third_party/jpeg-xl/lib/jxl/color_encoding_internal.h1
-rw-r--r--third_party/jpeg-xl/lib/jxl/color_management_test.cc4
-rw-r--r--third_party/jpeg-xl/lib/jxl/compressed_dc.cc1
-rw-r--r--third_party/jpeg-xl/lib/jxl/compressed_dc.h5
-rw-r--r--third_party/jpeg-xl/lib/jxl/convolve-inl.h2
-rw-r--r--third_party/jpeg-xl/lib/jxl/convolve.h1
-rw-r--r--third_party/jpeg-xl/lib/jxl/convolve_separable5.cc1
-rw-r--r--third_party/jpeg-xl/lib/jxl/convolve_slow.cc4
-rw-r--r--third_party/jpeg-xl/lib/jxl/convolve_symmetric3.cc1
-rw-r--r--third_party/jpeg-xl/lib/jxl/convolve_symmetric5.cc1
-rw-r--r--third_party/jpeg-xl/lib/jxl/convolve_test.cc3
-rw-r--r--third_party/jpeg-xl/lib/jxl/dct_for_test.h3
-rw-r--r--third_party/jpeg-xl/lib/jxl/dct_util.h5
-rw-r--r--third_party/jpeg-xl/lib/jxl/dec_ans.h7
-rw-r--r--third_party/jpeg-xl/lib/jxl/dec_frame.cc1
-rw-r--r--third_party/jpeg-xl/lib/jxl/dec_group.cc6
-rw-r--r--third_party/jpeg-xl/lib/jxl/dec_group_border.cc7
-rw-r--r--third_party/jpeg-xl/lib/jxl/dec_group_border.h9
-rw-r--r--third_party/jpeg-xl/lib/jxl/dec_modular.cc4
-rw-r--r--third_party/jpeg-xl/lib/jxl/dec_modular.h11
-rw-r--r--third_party/jpeg-xl/lib/jxl/dec_noise.cc13
-rw-r--r--third_party/jpeg-xl/lib/jxl/dec_noise.h6
-rw-r--r--third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.h6
-rw-r--r--third_party/jpeg-xl/lib/jxl/dec_transforms-inl.h4
-rw-r--r--third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.cc1
-rw-r--r--third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.h3
-rw-r--r--third_party/jpeg-xl/lib/jxl/dec_xyb.cc5
-rw-r--r--third_party/jpeg-xl/lib/jxl/dec_xyb.h2
-rw-r--r--third_party/jpeg-xl/lib/jxl/decode_test.cc4
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_ac_strategy.cc6
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_ac_strategy.h3
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.cc3
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.h3
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_ar_control_field.cc6
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_ar_control_field.h5
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_cache.cc6
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_cache.h5
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.cc6
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.h2
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_cluster.h8
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_coeff_order.cc4
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_coeff_order.h10
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_comparator.h2
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_debug_image.cc5
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_debug_image.h4
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_detect_dots.cc4
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_detect_dots.h7
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.cc6
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.h4
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_entropy_coder.cc12
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_entropy_coder.h11
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_fast_lossless.cc3
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_fields.cc2
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_frame.cc22
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_gaborish.cc5
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_gaborish.h1
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_gaborish_test.cc1
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_group.cc2
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_group.h3
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_heuristics.cc5
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_heuristics.h2
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_image_bundle.cc1
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_image_bundle.h1
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_linalg_test.cc2
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_modular.cc9
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_modular.h1
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_optimize_test.cc4
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.cc5
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.h8
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_photon_noise.h4
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_photon_noise_test.cc1
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_quant_weights.h2
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_xyb.cc1
-rw-r--r--third_party/jpeg-xl/lib/jxl/encode_internal.h2
-rw-r--r--third_party/jpeg-xl/lib/jxl/encode_test.cc6
-rw-r--r--third_party/jpeg-xl/lib/jxl/epf.cc18
-rw-r--r--third_party/jpeg-xl/lib/jxl/epf.h2
-rw-r--r--third_party/jpeg-xl/lib/jxl/fake_parallel_runner_testonly.h2
-rw-r--r--third_party/jpeg-xl/lib/jxl/fields.cc2
-rw-r--r--third_party/jpeg-xl/lib/jxl/fields.h3
-rw-r--r--third_party/jpeg-xl/lib/jxl/fields_test.cc11
-rw-r--r--third_party/jpeg-xl/lib/jxl/frame_dimensions.h2
-rw-r--r--third_party/jpeg-xl/lib/jxl/frame_header.h10
-rw-r--r--third_party/jpeg-xl/lib/jxl/icc_codec.h2
-rw-r--r--third_party/jpeg-xl/lib/jxl/image.h184
-rw-r--r--third_party/jpeg-xl/lib/jxl/image_bundle.h5
-rw-r--r--third_party/jpeg-xl/lib/jxl/image_metadata.h1
-rw-r--r--third_party/jpeg-xl/lib/jxl/image_ops.h1
-rw-r--r--third_party/jpeg-xl/lib/jxl/image_ops_test.cc6
-rw-r--r--third_party/jpeg-xl/lib/jxl/image_test_utils.h8
-rw-r--r--third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data.cc2
-rw-r--r--third_party/jpeg-xl/lib/jxl/jxl_test.cc78
-rw-r--r--third_party/jpeg-xl/lib/jxl/lehmer_code_test.cc7
-rw-r--r--third_party/jpeg-xl/lib/jxl/modular/encoding/context_predict.h10
-rw-r--r--third_party/jpeg-xl/lib/jxl/modular/encoding/enc_debug_tree.cc3
-rw-r--r--third_party/jpeg-xl/lib/jxl/modular/options.h4
-rw-r--r--third_party/jpeg-xl/lib/jxl/modular/transform/enc_palette.cc1
-rw-r--r--third_party/jpeg-xl/lib/jxl/modular/transform/palette.cc4
-rw-r--r--third_party/jpeg-xl/lib/jxl/modular/transform/palette.h8
-rw-r--r--third_party/jpeg-xl/lib/jxl/modular/transform/squeeze.h4
-rw-r--r--third_party/jpeg-xl/lib/jxl/modular/transform/transform.cc2
-rw-r--r--third_party/jpeg-xl/lib/jxl/modular/transform/transform.h6
-rw-r--r--third_party/jpeg-xl/lib/jxl/opsin_image_test.cc2
-rw-r--r--third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc2
-rw-r--r--third_party/jpeg-xl/lib/jxl/passes_test.cc5
-rw-r--r--third_party/jpeg-xl/lib/jxl/preview_test.cc2
-rw-r--r--third_party/jpeg-xl/lib/jxl/quant_weights.h4
-rw-r--r--third_party/jpeg-xl/lib/jxl/quant_weights_test.cc7
-rw-r--r--third_party/jpeg-xl/lib/jxl/quantizer.cc4
-rw-r--r--third_party/jpeg-xl/lib/jxl/quantizer.h14
-rw-r--r--third_party/jpeg-xl/lib/jxl/quantizer_test.cc8
-rw-r--r--third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.cc7
-rw-r--r--third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.h9
-rw-r--r--third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.cc4
-rw-r--r--third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.h12
-rw-r--r--third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_stage.h4
-rw-r--r--third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_test.cc2
-rw-r--r--third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.cc6
-rw-r--r--third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.h7
-rw-r--r--third_party/jpeg-xl/lib/jxl/render_pipeline/stage_noise.h11
-rw-r--r--third_party/jpeg-xl/lib/jxl/render_pipeline/stage_splines.cc8
-rw-r--r--third_party/jpeg-xl/lib/jxl/render_pipeline/stage_write.h6
-rw-r--r--third_party/jpeg-xl/lib/jxl/render_pipeline/test_render_pipeline_stages.h6
-rw-r--r--third_party/jpeg-xl/lib/jxl/roundtrip_test.cc3
-rw-r--r--third_party/jpeg-xl/lib/jxl/sanitizers.h8
-rw-r--r--third_party/jpeg-xl/lib/jxl/speed_tier_test.cc2
-rw-r--r--third_party/jpeg-xl/lib/jxl/splines.cc3
-rw-r--r--third_party/jpeg-xl/lib/jxl/splines.h1
-rw-r--r--third_party/jpeg-xl/lib/jxl/splines_gbench.cc5
-rw-r--r--third_party/jpeg-xl/lib/jxl/splines_test.cc1
-rw-r--r--third_party/jpeg-xl/lib/jxl/test_image.cc3
-rw-r--r--third_party/jpeg-xl/lib/jxl/test_image.h3
-rw-r--r--third_party/jpeg-xl/lib/jxl/test_utils.h12
-rw-r--r--third_party/jpeg-xl/lib/jxl/xorshift128plus-inl.h4
157 files changed, 762 insertions, 489 deletions
diff --git a/third_party/jpeg-xl/lib/jxl/ac_context.h b/third_party/jpeg-xl/lib/jxl/ac_context.h
index a2b9e046d1..6529a9bb88 100644
--- a/third_party/jpeg-xl/lib/jxl/ac_context.h
+++ b/third_party/jpeg-xl/lib/jxl/ac_context.h
@@ -62,7 +62,8 @@ static JXL_INLINE size_t ZeroDensityContext(size_t nonzeros_left, size_t k,
size_t covered_blocks,
size_t log2_covered_blocks,
size_t prev) {
- JXL_DASSERT((1u << log2_covered_blocks) == covered_blocks);
+ JXL_DASSERT((static_cast<size_t>(1) << log2_covered_blocks) ==
+ covered_blocks);
nonzeros_left = (nonzeros_left + covered_blocks - 1) >> log2_covered_blocks;
k >>= log2_covered_blocks;
JXL_DASSERT(k > 0);
@@ -109,7 +110,8 @@ struct BlockCtxMap {
// Non-zero context is based on number of non-zeros and block context.
// For better clustering, contexts with same number of non-zeros are grouped.
constexpr uint32_t ZeroDensityContextsOffset(uint32_t block_ctx) const {
- return num_ctxs * kNonZeroBuckets + kZeroDensityContextCount * block_ctx;
+ return static_cast<uint32_t>(num_ctxs * kNonZeroBuckets +
+ kZeroDensityContextCount * block_ctx);
}
// Context map for AC coefficients consists of 2 blocks:
@@ -121,7 +123,8 @@ struct BlockCtxMap {
// number of non-zeros left and
// index in scan order
constexpr uint32_t NumACContexts() const {
- return num_ctxs * (kNonZeroBuckets + kZeroDensityContextCount);
+ return static_cast<uint32_t>(num_ctxs *
+ (kNonZeroBuckets + kZeroDensityContextCount));
}
// Non-zero context is based on number of non-zeros and block context.
@@ -134,7 +137,7 @@ struct BlockCtxMap {
} else {
ctx = 4 + non_zeros / 2;
}
- return ctx * num_ctxs + block_ctx;
+ return static_cast<uint32_t>(ctx * num_ctxs + block_ctx);
}
BlockCtxMap() {
diff --git a/third_party/jpeg-xl/lib/jxl/ac_strategy.h b/third_party/jpeg-xl/lib/jxl/ac_strategy.h
index 9e5917ff1b..fd40b0ced8 100644
--- a/third_party/jpeg-xl/lib/jxl/ac_strategy.h
+++ b/third_party/jpeg-xl/lib/jxl/ac_strategy.h
@@ -11,9 +11,12 @@
#include <hwy/base.h> // kMaxVectorSize
+#include "lib/jxl/base/compiler_specific.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/coeff_order_fwd.h"
#include "lib/jxl/frame_dimensions.h"
+#include "lib/jxl/image.h"
#include "lib/jxl/image_ops.h"
// Defines the different kinds of transforms, and heuristics to choose between
diff --git a/third_party/jpeg-xl/lib/jxl/ac_strategy_test.cc b/third_party/jpeg-xl/lib/jxl/ac_strategy_test.cc
index b1d9103466..dc25c89898 100644
--- a/third_party/jpeg-xl/lib/jxl/ac_strategy_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/ac_strategy_test.cc
@@ -5,16 +5,14 @@
#include "lib/jxl/ac_strategy.h"
-#include <string.h>
-
-#include <cmath>
+#include <algorithm>
+#include <cstring>
#include <hwy/aligned_allocator.h>
#include <hwy/base.h> // HWY_ALIGN_MAX
#include <hwy/tests/hwy_gtest.h>
-#include <utility>
#include "lib/jxl/base/random.h"
-#include "lib/jxl/dct_scales.h"
+#include "lib/jxl/coeff_order_fwd.h"
#include "lib/jxl/dec_transforms_testonly.h"
#include "lib/jxl/enc_transforms.h"
#include "lib/jxl/simd_util.h"
diff --git a/third_party/jpeg-xl/lib/jxl/ans_common.h b/third_party/jpeg-xl/lib/jxl/ans_common.h
index 44b8e3fba1..8236bb20ec 100644
--- a/third_party/jpeg-xl/lib/jxl/ans_common.h
+++ b/third_party/jpeg-xl/lib/jxl/ans_common.h
@@ -6,23 +6,24 @@
#ifndef LIB_JXL_ANS_COMMON_H_
#define LIB_JXL_ANS_COMMON_H_
-#include <stdint.h>
-
#include <algorithm>
+#include <cstddef>
+#include <cstdint>
+#include <cstring>
+#include <hwy/base.h>
#include <hwy/cache_control.h> // Prefetch
#include <vector>
#include "lib/jxl/ans_params.h"
#include "lib/jxl/base/byte_order.h"
#include "lib/jxl/base/compiler_specific.h"
-#include "lib/jxl/base/status.h"
namespace jxl {
// Returns the precision (number of bits) that should be used to store
// a histogram count such that Log2Floor(count) == logcount.
-static JXL_INLINE uint32_t GetPopulationCountPrecision(uint32_t logcount,
- uint32_t shift) {
+static JXL_MAYBE_UNUSED JXL_INLINE uint32_t
+GetPopulationCountPrecision(uint32_t logcount, uint32_t shift) {
int32_t r = std::min<int>(
logcount, static_cast<int>(shift) -
static_cast<int>((ANS_LOG_TAB_SIZE - logcount) >> 1));
diff --git a/third_party/jpeg-xl/lib/jxl/ans_test.cc b/third_party/jpeg-xl/lib/jxl/ans_test.cc
index 5d6a5ef090..83a2e732f8 100644
--- a/third_party/jpeg-xl/lib/jxl/ans_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/ans_test.cc
@@ -10,11 +10,10 @@
#include "lib/jxl/ans_params.h"
#include "lib/jxl/base/random.h"
-#include "lib/jxl/base/span.h"
+#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_ans.h"
#include "lib/jxl/dec_bit_reader.h"
#include "lib/jxl/enc_ans.h"
-#include "lib/jxl/enc_aux_out.h"
#include "lib/jxl/enc_bit_writer.h"
#include "lib/jxl/testing.h"
diff --git a/third_party/jpeg-xl/lib/jxl/base/compiler_specific.h b/third_party/jpeg-xl/lib/jxl/base/compiler_specific.h
index 702ff8e058..52f88c50f8 100644
--- a/third_party/jpeg-xl/lib/jxl/base/compiler_specific.h
+++ b/third_party/jpeg-xl/lib/jxl/base/compiler_specific.h
@@ -8,7 +8,6 @@
// Macros for compiler version + nonstandard keywords, e.g. __builtin_expect.
-#include <stdint.h>
#include <sys/types.h>
#include "lib/jxl/base/sanitizer_definitions.h"
@@ -97,6 +96,11 @@
#define JXL_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
#endif
+#if JXL_COMPILER_MSVC
+#include <stdint.h>
+using ssize_t = intptr_t;
+#endif
+
// Returns a void* pointer which the compiler then assumes is N-byte aligned.
// Example: float* JXL_RESTRICT aligned = (float*)JXL_ASSUME_ALIGNED(in, 32);
//
@@ -150,8 +154,4 @@
#define JXL_FORMAT(idx_fmt, idx_arg)
#endif
-#if JXL_COMPILER_MSVC
-using ssize_t = intptr_t;
-#endif
-
#endif // LIB_JXL_BASE_COMPILER_SPECIFIC_H_
diff --git a/third_party/jpeg-xl/lib/jxl/base/exif.h b/third_party/jpeg-xl/lib/jxl/base/exif.h
index a3574a16ff..acaa1a1ce4 100644
--- a/third_party/jpeg-xl/lib/jxl/base/exif.h
+++ b/third_party/jpeg-xl/lib/jxl/base/exif.h
@@ -3,8 +3,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#ifndef LIB_JXL_EXIF_H_
-#define LIB_JXL_EXIF_H_
+#ifndef LIB_JXL_BASE_EXIF_H_
+#define LIB_JXL_BASE_EXIF_H_
// Basic parsing of Exif (just enough for the render-impacting things
// like orientation)
@@ -87,4 +87,4 @@ JXL_INLINE void InterpretExif(const std::vector<uint8_t>& exif,
} // namespace jxl
-#endif // LIB_JXL_EXIF_H_
+#endif // LIB_JXL_BASE_EXIF_H_
diff --git a/third_party/jpeg-xl/lib/jxl/base/include_jpeglib.h b/third_party/jpeg-xl/lib/jxl/base/include_jpeglib.h
new file mode 100644
index 0000000000..f72d13d04b
--- /dev/null
+++ b/third_party/jpeg-xl/lib/jxl/base/include_jpeglib.h
@@ -0,0 +1,20 @@
+// Copyright (c) the JPEG XL Project Authors. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#ifndef LIB_JXL_BASE_INCLUDE_JPEGLIB_H_
+#define LIB_JXL_BASE_INCLUDE_JPEGLIB_H_
+
+// Using this header ensures that includes go in the right order,
+// not alphabetically sorted.
+
+// NOLINTBEGIN
+/* clang-format off */
+#include <stdio.h> // IWYU pragma: keep
+#include <jpeglib.h> // IWYU pragma: keep
+#include <setjmp.h> // IWYU pragma: keep
+/* clang-format on */
+// NOLINTEND
+
+#endif // LIB_JXL_BASE_INCLUDE_JPEGLIB_H_
diff --git a/third_party/jpeg-xl/lib/jxl/base/matrix_ops.h b/third_party/jpeg-xl/lib/jxl/base/matrix_ops.h
index cde6a64b1e..e1f8753932 100644
--- a/third_party/jpeg-xl/lib/jxl/base/matrix_ops.h
+++ b/third_party/jpeg-xl/lib/jxl/base/matrix_ops.h
@@ -3,8 +3,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#ifndef LIB_JXL_MATRIX_OPS_H_
-#define LIB_JXL_MATRIX_OPS_H_
+#ifndef LIB_JXL_BASE_MATRIX_OPS_H_
+#define LIB_JXL_BASE_MATRIX_OPS_H_
// 3x3 matrix operations.
@@ -83,4 +83,4 @@ Status Inv3x3Matrix(Matrix& matrix) {
} // namespace jxl
-#endif // LIB_JXL_MATRIX_OPS_H_
+#endif // LIB_JXL_BASE_MATRIX_OPS_H_
diff --git a/third_party/jpeg-xl/lib/jxl/base/rect.h b/third_party/jpeg-xl/lib/jxl/base/rect.h
new file mode 100644
index 0000000000..666c3d73ec
--- /dev/null
+++ b/third_party/jpeg-xl/lib/jxl/base/rect.h
@@ -0,0 +1,194 @@
+// Copyright (c) the JPEG XL Project Authors. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#ifndef LIB_JXL_BASE_RECT_H_
+#define LIB_JXL_BASE_RECT_H_
+
+#include <algorithm>
+#include <cstddef>
+#include <cstdint>
+#include <cstring>
+#include <sstream>
+#include <string>
+#include <utility> // std::move
+
+#include "lib/jxl/base/compiler_specific.h"
+#include "lib/jxl/base/status.h"
+
+namespace jxl {
+
+// Rectangular region in image(s). Factoring this out of Image instead of
+// shifting the pointer by x0/y0 allows this to apply to multiple images with
+// different resolutions (e.g. color transform and quantization field).
+// Can compare using SameSize(rect1, rect2).
+template <typename T>
+class RectT {
+ public:
+ // Most windows are xsize_max * ysize_max, except those on the borders where
+ // begin + size_max > end.
+ constexpr RectT(T xbegin, T ybegin, size_t xsize_max, size_t ysize_max,
+ T xend, T yend)
+ : x0_(xbegin),
+ y0_(ybegin),
+ xsize_(ClampedSize(xbegin, xsize_max, xend)),
+ ysize_(ClampedSize(ybegin, ysize_max, yend)) {}
+
+ // Construct with origin and known size (typically from another Rect).
+ constexpr RectT(T xbegin, T ybegin, size_t xsize, size_t ysize)
+ : x0_(xbegin), y0_(ybegin), xsize_(xsize), ysize_(ysize) {}
+
+ // Construct a rect that covers a whole image/plane/ImageBundle etc.
+ template <typename ImageT>
+ explicit RectT(const ImageT& image)
+ : RectT(0, 0, image.xsize(), image.ysize()) {}
+
+ RectT() : RectT(0, 0, 0, 0) {}
+
+ RectT(const RectT&) = default;
+ RectT& operator=(const RectT&) = default;
+
+ // Construct a subrect that resides in an image/plane/ImageBundle etc.
+ template <typename ImageT>
+ RectT Crop(const ImageT& image) const {
+ return Intersection(RectT(image));
+ }
+
+ // Construct a subrect that resides in the [0, ysize) x [0, xsize) region of
+ // the current rect.
+ RectT Crop(size_t area_xsize, size_t area_ysize) const {
+ return Intersection(RectT(0, 0, area_xsize, area_ysize));
+ }
+
+ // Returns a rect that only contains `num` lines with offset `y` from `y0()`.
+ RectT Lines(size_t y, size_t num) const {
+ JXL_DASSERT(y + num <= ysize_);
+ return RectT(x0_, y0_ + y, xsize_, num);
+ }
+
+ RectT Line(size_t y) const { return Lines(y, 1); }
+
+ JXL_MUST_USE_RESULT RectT Intersection(const RectT& other) const {
+ return RectT(std::max(x0_, other.x0_), std::max(y0_, other.y0_), xsize_,
+ ysize_, std::min(x1(), other.x1()),
+ std::min(y1(), other.y1()));
+ }
+
+ JXL_MUST_USE_RESULT RectT Translate(int64_t x_offset,
+ int64_t y_offset) const {
+ return RectT(x0_ + x_offset, y0_ + y_offset, xsize_, ysize_);
+ }
+
+ template <template <class> class P, typename V>
+ V* Row(P<V>* image, size_t y) const {
+ JXL_DASSERT(y + y0_ >= 0);
+ return image->Row(y + y0_) + x0_;
+ }
+
+ template <template <class> class P, typename V>
+ const V* Row(const P<V>* image, size_t y) const {
+ JXL_DASSERT(y + y0_ >= 0);
+ return image->Row(y + y0_) + x0_;
+ }
+
+ template <template <class> class MP, typename V>
+ V* PlaneRow(MP<V>* image, const size_t c, size_t y) const {
+ JXL_DASSERT(y + y0_ >= 0);
+ return image->PlaneRow(c, y + y0_) + x0_;
+ }
+
+ template <template <class> class P, typename V>
+ const V* ConstRow(const P<V>& image, size_t y) const {
+ JXL_DASSERT(y + y0_ >= 0);
+ return image.ConstRow(y + y0_) + x0_;
+ }
+
+ template <template <class> class MP, typename V>
+ const V* ConstPlaneRow(const MP<V>& image, size_t c, size_t y) const {
+ JXL_DASSERT(y + y0_ >= 0);
+ return image.ConstPlaneRow(c, y + y0_) + x0_;
+ }
+
+ bool IsInside(const RectT& other) const {
+ return x0_ >= other.x0() && x1() <= other.x1() && y0_ >= other.y0() &&
+ y1() <= other.y1();
+ }
+
+ // Returns true if this Rect fully resides in the given image. ImageT could be
+ // Plane<T> or Image3<T>; however if ImageT is Rect, results are nonsensical.
+ template <class ImageT>
+ bool IsInside(const ImageT& image) const {
+ return IsInside(RectT(image));
+ }
+
+ T x0() const { return x0_; }
+ T y0() const { return y0_; }
+ size_t xsize() const { return xsize_; }
+ size_t ysize() const { return ysize_; }
+ T x1() const { return x0_ + xsize_; }
+ T y1() const { return y0_ + ysize_; }
+
+ RectT<T> ShiftLeft(size_t shiftx, size_t shifty) const {
+ return RectT<T>(x0_ * (1 << shiftx), y0_ * (1 << shifty), xsize_ << shiftx,
+ ysize_ << shifty);
+ }
+ RectT<T> ShiftLeft(size_t shift) const { return ShiftLeft(shift, shift); }
+
+ // Requires x0(), y0() to be multiples of 1<<shiftx, 1<<shifty.
+ RectT<T> CeilShiftRight(size_t shiftx, size_t shifty) const {
+ JXL_ASSERT(x0_ % (1 << shiftx) == 0);
+ JXL_ASSERT(y0_ % (1 << shifty) == 0);
+ return RectT<T>(x0_ / (1 << shiftx), y0_ / (1 << shifty),
+ DivCeil(xsize_, T{1} << shiftx),
+ DivCeil(ysize_, T{1} << shifty));
+ }
+ RectT<T> CeilShiftRight(std::pair<size_t, size_t> shift) const {
+ return CeilShiftRight(shift.first, shift.second);
+ }
+ RectT<T> CeilShiftRight(size_t shift) const {
+ return CeilShiftRight(shift, shift);
+ }
+
+ RectT<T> Extend(T border, RectT<T> parent) const {
+ T new_x0 = x0() > parent.x0() + border ? x0() - border : parent.x0();
+ T new_y0 = y0() > parent.y0() + border ? y0() - border : parent.y0();
+ T new_x1 = x1() + border > parent.x1() ? parent.x1() : x1() + border;
+ T new_y1 = y1() + border > parent.y1() ? parent.y1() : y1() + border;
+ return RectT<T>(new_x0, new_y0, new_x1 - new_x0, new_y1 - new_y0);
+ }
+
+ template <typename U>
+ RectT<U> As() const {
+ return RectT<U>(static_cast<U>(x0_), static_cast<U>(y0_),
+ static_cast<U>(xsize_), static_cast<U>(ysize_));
+ }
+
+ private:
+ // Returns size_max, or whatever is left in [begin, end).
+ static constexpr size_t ClampedSize(T begin, size_t size_max, T end) {
+ return (static_cast<T>(begin + size_max) <= end)
+ ? size_max
+ : (end > begin ? end - begin : 0);
+ }
+
+ T x0_;
+ T y0_;
+
+ size_t xsize_;
+ size_t ysize_;
+};
+
+template <typename T>
+std::string Description(RectT<T> r) {
+ std::ostringstream os;
+ os << "[" << r.x0() << ".." << r.x1() << ")x"
+ << "[" << r.y0() << ".." << r.y1() << ")";
+ return os.str();
+}
+
+using Rect = RectT<size_t>;
+
+} // namespace jxl
+
+#endif // LIB_JXL_BASE_RECT_H_
diff --git a/third_party/jpeg-xl/lib/jxl/base/span.h b/third_party/jpeg-xl/lib/jxl/base/span.h
index ba09d62316..7515b7b1ef 100644
--- a/third_party/jpeg-xl/lib/jxl/base/span.h
+++ b/third_party/jpeg-xl/lib/jxl/base/span.h
@@ -11,6 +11,7 @@
#include <cstddef>
#include <cstdint>
+#include <type_traits>
#include <vector>
#include "lib/jxl/base/status.h"
@@ -41,6 +42,8 @@ class Span {
"Incompatible type of source.");
}
+ using NCT = typename std::remove_const<T>::type;
+
constexpr T* data() const noexcept { return ptr_; }
constexpr size_t size() const noexcept { return len_; }
@@ -62,12 +65,12 @@ class Span {
len_ -= n;
}
- // NCT == non-const-T; compiler will complain if NCT is not compatible with T.
- template <typename NCT>
void AppendTo(std::vector<NCT>& dst) const {
dst.insert(dst.end(), begin(), end());
}
+ std::vector<NCT> Copy() const { return std::vector<NCT>(begin(), end()); }
+
private:
T* ptr_;
size_t len_;
diff --git a/third_party/jpeg-xl/lib/jxl/bit_reader_test.cc b/third_party/jpeg-xl/lib/jxl/bit_reader_test.cc
index 802da855fa..b2d5773d15 100644
--- a/third_party/jpeg-xl/lib/jxl/bit_reader_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/bit_reader_test.cc
@@ -7,6 +7,7 @@
#include <stdint.h>
#include <array>
+#include <utility>
#include <vector>
#include "lib/jxl/base/common.h"
diff --git a/third_party/jpeg-xl/lib/jxl/bits_test.cc b/third_party/jpeg-xl/lib/jxl/bits_test.cc
index 45db8c0d6e..8340db5a38 100644
--- a/third_party/jpeg-xl/lib/jxl/bits_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/bits_test.cc
@@ -5,6 +5,9 @@
#include "lib/jxl/base/bits.h"
+#include <cstddef>
+#include <cstdint>
+
#include "lib/jxl/testing.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/blending.cc b/third_party/jpeg-xl/lib/jxl/blending.cc
index 7575ec6e4a..0e26980816 100644
--- a/third_party/jpeg-xl/lib/jxl/blending.cc
+++ b/third_party/jpeg-xl/lib/jxl/blending.cc
@@ -5,7 +5,16 @@
#include "lib/jxl/blending.h"
+#include <cstddef>
+#include <cstring>
+#include <vector>
+
#include "lib/jxl/alpha.h"
+#include "lib/jxl/base/status.h"
+#include "lib/jxl/dec_patch_dictionary.h"
+#include "lib/jxl/frame_header.h"
+#include "lib/jxl/image.h"
+#include "lib/jxl/image_metadata.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/blending.h b/third_party/jpeg-xl/lib/jxl/blending.h
index 94bead8dd6..6ed862ac1c 100644
--- a/third_party/jpeg-xl/lib/jxl/blending.h
+++ b/third_party/jpeg-xl/lib/jxl/blending.h
@@ -6,8 +6,10 @@
#ifndef LIB_JXL_BLENDING_H_
#define LIB_JXL_BLENDING_H_
+#include <cstddef>
#include <vector>
+#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_patch_dictionary.h"
#include "lib/jxl/frame_header.h"
#include "lib/jxl/image_metadata.h"
diff --git a/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.cc b/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.cc
index 2e06d79eba..4e49f18df8 100644
--- a/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.cc
+++ b/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.cc
@@ -22,13 +22,12 @@
#include "lib/jxl/butteraugli/butteraugli.h"
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include <algorithm>
#include <cmath>
+#include <cstdint>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <memory>
#include <vector>
@@ -40,6 +39,7 @@
#include "lib/jxl/base/fast_math-inl.h"
#include "lib/jxl/base/printf_macros.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/convolve.h"
#include "lib/jxl/image_ops.h"
diff --git a/third_party/jpeg-xl/lib/jxl/cache_aligned.h b/third_party/jpeg-xl/lib/jxl/cache_aligned.h
index 8480471e5c..c9cac17339 100644
--- a/third_party/jpeg-xl/lib/jxl/cache_aligned.h
+++ b/third_party/jpeg-xl/lib/jxl/cache_aligned.h
@@ -13,8 +13,6 @@
#include <memory>
-#include "lib/jxl/base/compiler_specific.h"
-
namespace jxl {
// Functions that depend on the cache line size.
diff --git a/third_party/jpeg-xl/lib/jxl/chroma_from_luma.h b/third_party/jpeg-xl/lib/jxl/chroma_from_luma.h
index 1f2353d9af..090d95165c 100644
--- a/third_party/jpeg-xl/lib/jxl/chroma_from_luma.h
+++ b/third_party/jpeg-xl/lib/jxl/chroma_from_luma.h
@@ -9,11 +9,12 @@
// Chroma-from-luma, computed using heuristics to determine the best linear
// model for the X and B channels from the Y channel.
-#include <stddef.h>
-#include <stdint.h>
-
+#include <cmath>
+#include <cstddef>
+#include <cstdint>
#include <limits>
+#include "lib/jxl/base/common.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/cms/opsin_params.h"
#include "lib/jxl/dec_bit_reader.h"
diff --git a/third_party/jpeg-xl/lib/jxl/cms/jxl_cms_internal.h b/third_party/jpeg-xl/lib/jxl/cms/jxl_cms_internal.h
index a787bd11d8..69a5dc434e 100644
--- a/third_party/jpeg-xl/lib/jxl/cms/jxl_cms_internal.h
+++ b/third_party/jpeg-xl/lib/jxl/cms/jxl_cms_internal.h
@@ -405,7 +405,7 @@ static Status WriteICCS15Fixed16(float value, size_t pos,
// Even the first value works well,...
bool ok = (-32767.995f <= value) && (value <= 32767.995f);
if (!ok) return JXL_FAILURE("ICC value is out of range / NaN");
- int32_t i = value * 65536.0f + 0.5f;
+ int32_t i = static_cast<int32_t>(std::lround(value * 65536.0f));
// Use two's complement
uint32_t u = static_cast<uint32_t>(i);
WriteICCUint32(u, pos, icc);
@@ -849,6 +849,20 @@ static std::string ToString(JxlRenderingIntent rendering_intent) {
}
static std::string ColorEncodingDescriptionImpl(const JxlColorEncoding& c) {
+ if (c.color_space == JXL_COLOR_SPACE_RGB &&
+ c.white_point == JXL_WHITE_POINT_D65) {
+ if (c.rendering_intent == JXL_RENDERING_INTENT_PERCEPTUAL &&
+ c.transfer_function == JXL_TRANSFER_FUNCTION_SRGB) {
+ if (c.primaries == JXL_PRIMARIES_SRGB) return "sRGB";
+ if (c.primaries == JXL_PRIMARIES_P3) return "DisplayP3";
+ }
+ if (c.rendering_intent == JXL_RENDERING_INTENT_RELATIVE &&
+ c.primaries == JXL_PRIMARIES_2100) {
+ if (c.transfer_function == JXL_TRANSFER_FUNCTION_PQ) return "Rec2100PQ";
+ if (c.transfer_function == JXL_TRANSFER_FUNCTION_HLG) return "Rec2100HLG";
+ }
+ }
+
std::string d = ToString(c.color_space);
bool explicit_wp_tf = (c.color_space != JXL_COLOR_SPACE_XYB);
diff --git a/third_party/jpeg-xl/lib/jxl/cms/opsin_params.h b/third_party/jpeg-xl/lib/jxl/cms/opsin_params.h
index 69dcd0b512..0af852c745 100644
--- a/third_party/jpeg-xl/lib/jxl/cms/opsin_params.h
+++ b/third_party/jpeg-xl/lib/jxl/cms/opsin_params.h
@@ -6,6 +6,9 @@
#ifndef LIB_JXL_CMS_OPSIN_PARAMS_H_
#define LIB_JXL_CMS_OPSIN_PARAMS_H_
+#include <array>
+#include <cstddef>
+
#include "lib/jxl/base/matrix_ops.h"
// Constants that define the XYB color space.
diff --git a/third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h b/third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h
index 1f85dcca41..c1f43f4d31 100644
--- a/third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h
+++ b/third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h
@@ -8,6 +8,7 @@
#include <algorithm>
#include <cmath>
+#include <cstddef>
#include <utility>
#include "lib/jxl/base/common.h"
diff --git a/third_party/jpeg-xl/lib/jxl/coeff_order.h b/third_party/jpeg-xl/lib/jxl/coeff_order.h
index 79c0c976c9..395e296642 100644
--- a/third_party/jpeg-xl/lib/jxl/coeff_order.h
+++ b/third_party/jpeg-xl/lib/jxl/coeff_order.h
@@ -6,11 +6,11 @@
#ifndef LIB_JXL_COEFF_ORDER_H_
#define LIB_JXL_COEFF_ORDER_H_
-#include <stddef.h>
-#include <stdint.h>
+#include <array>
+#include <cstddef>
+#include <cstdint>
#include "lib/jxl/ac_strategy.h"
-#include "lib/jxl/base/common.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/coeff_order_fwd.h"
@@ -24,11 +24,12 @@ class BitReader;
static constexpr size_t kCoeffOrderLimit = 6156;
-static constexpr std::array<size_t, 3 * kNumOrders + 1> kCoeffOrderOffset = {
- 0, 1, 2, 3, 4, 5, 6, 10, 14, 18,
- 34, 50, 66, 68, 70, 72, 76, 80, 84, 92,
- 100, 108, 172, 236, 300, 332, 364, 396, 652, 908,
- 1164, 1292, 1420, 1548, 2572, 3596, 4620, 5132, 5644, kCoeffOrderLimit};
+static constexpr std::array<size_t, 3 * kNumOrders + 1> JXL_MAYBE_UNUSED
+ kCoeffOrderOffset = {
+ 0, 1, 2, 3, 4, 5, 6, 10, 14, 18,
+ 34, 50, 66, 68, 70, 72, 76, 80, 84, 92,
+ 100, 108, 172, 236, 300, 332, 364, 396, 652, 908,
+ 1164, 1292, 1420, 1548, 2572, 3596, 4620, 5132, 5644, kCoeffOrderLimit};
// TODO(eustas): rollback to constexpr once modern C++ becomes reuired.
#define CoeffOrderOffset(O, C) \
diff --git a/third_party/jpeg-xl/lib/jxl/coeff_order_fwd.h b/third_party/jpeg-xl/lib/jxl/coeff_order_fwd.h
index 26306575c1..e5e72a4913 100644
--- a/third_party/jpeg-xl/lib/jxl/coeff_order_fwd.h
+++ b/third_party/jpeg-xl/lib/jxl/coeff_order_fwd.h
@@ -8,8 +8,8 @@
// Breaks circular dependency between ac_strategy and coeff_order.
-#include <stddef.h>
-#include <stdint.h>
+#include <cstddef>
+#include <cstdint>
#include "lib/jxl/base/compiler_specific.h"
diff --git a/third_party/jpeg-xl/lib/jxl/color_encoding_internal.h b/third_party/jpeg-xl/lib/jxl/color_encoding_internal.h
index 61e4628dbd..afcd5a4c1c 100644
--- a/third_party/jpeg-xl/lib/jxl/color_encoding_internal.h
+++ b/third_party/jpeg-xl/lib/jxl/color_encoding_internal.h
@@ -10,6 +10,7 @@
#include <jxl/cms_interface.h>
#include <jxl/color_encoding.h>
+#include <jxl/types.h>
#include <stddef.h>
#include <stdint.h>
diff --git a/third_party/jpeg-xl/lib/jxl/color_management_test.cc b/third_party/jpeg-xl/lib/jxl/color_management_test.cc
index 77cbe56926..b6a45b0a85 100644
--- a/third_party/jpeg-xl/lib/jxl/color_management_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/color_management_test.cc
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <algorithm>
+#include <cmath>
#include <cstddef>
#include <cstdint>
#include <cstdio>
@@ -20,6 +21,7 @@
#include "lib/jxl/base/common.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/span.h"
+#include "lib/jxl/base/status.h"
#include "lib/jxl/cms/color_encoding_cms.h"
#include "lib/jxl/cms/opsin_params.h"
#include "lib/jxl/color_encoding_internal.h"
@@ -417,7 +419,7 @@ TEST_F(ColorManagementTest, XYBProfile) {
}
}
}
- static float kMaxError[3] = {9e-4, 4e-4, 5e-4};
+ static float kMaxError[3] = {8.7e-4, 4.4e-4, 5.2e-4};
printf("Maximum errors:\n");
for (size_t c = 0; c < 3; ++c) {
debug_print_color(max_err_i[c]);
diff --git a/third_party/jpeg-xl/lib/jxl/compressed_dc.cc b/third_party/jpeg-xl/lib/jxl/compressed_dc.cc
index 250be9e9a6..ec78afbd41 100644
--- a/third_party/jpeg-xl/lib/jxl/compressed_dc.cc
+++ b/third_party/jpeg-xl/lib/jxl/compressed_dc.cc
@@ -20,6 +20,7 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/image.h"
HWY_BEFORE_NAMESPACE();
diff --git a/third_party/jpeg-xl/lib/jxl/compressed_dc.h b/third_party/jpeg-xl/lib/jxl/compressed_dc.h
index 30259ebd56..d8846a8f04 100644
--- a/third_party/jpeg-xl/lib/jxl/compressed_dc.h
+++ b/third_party/jpeg-xl/lib/jxl/compressed_dc.h
@@ -6,11 +6,10 @@
#ifndef LIB_JXL_COMPRESSED_DC_H_
#define LIB_JXL_COMPRESSED_DC_H_
-#include <stddef.h>
-#include <stdint.h>
-
#include "lib/jxl/ac_context.h"
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
+#include "lib/jxl/base/status.h"
#include "lib/jxl/frame_header.h"
#include "lib/jxl/image.h"
#include "lib/jxl/modular/modular_image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/convolve-inl.h b/third_party/jpeg-xl/lib/jxl/convolve-inl.h
index 949fd8ad67..3efd8f6335 100644
--- a/third_party/jpeg-xl/lib/jxl/convolve-inl.h
+++ b/third_party/jpeg-xl/lib/jxl/convolve-inl.h
@@ -12,6 +12,8 @@
#include <hwy/highway.h>
+#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/image_ops.h"
diff --git a/third_party/jpeg-xl/lib/jxl/convolve.h b/third_party/jpeg-xl/lib/jxl/convolve.h
index 5231ae2640..da7cab6ffb 100644
--- a/third_party/jpeg-xl/lib/jxl/convolve.h
+++ b/third_party/jpeg-xl/lib/jxl/convolve.h
@@ -12,6 +12,7 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/image.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/convolve_separable5.cc b/third_party/jpeg-xl/lib/jxl/convolve_separable5.cc
index ae618b9990..d6b388698c 100644
--- a/third_party/jpeg-xl/lib/jxl/convolve_separable5.cc
+++ b/third_party/jpeg-xl/lib/jxl/convolve_separable5.cc
@@ -10,6 +10,7 @@
#include <hwy/foreach_target.h>
#include <hwy/highway.h>
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/convolve-inl.h"
HWY_BEFORE_NAMESPACE();
diff --git a/third_party/jpeg-xl/lib/jxl/convolve_slow.cc b/third_party/jpeg-xl/lib/jxl/convolve_slow.cc
index 655e040885..aa4c07f60b 100644
--- a/third_party/jpeg-xl/lib/jxl/convolve_slow.cc
+++ b/third_party/jpeg-xl/lib/jxl/convolve_slow.cc
@@ -3,9 +3,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#include "lib/jxl/convolve.h"
-
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/convolve-inl.h"
+#include "lib/jxl/convolve.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/convolve_symmetric3.cc b/third_party/jpeg-xl/lib/jxl/convolve_symmetric3.cc
index 618ad03a86..012a9be97e 100644
--- a/third_party/jpeg-xl/lib/jxl/convolve_symmetric3.cc
+++ b/third_party/jpeg-xl/lib/jxl/convolve_symmetric3.cc
@@ -10,6 +10,7 @@
#include <hwy/foreach_target.h>
#include <hwy/highway.h>
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/convolve-inl.h"
HWY_BEFORE_NAMESPACE();
diff --git a/third_party/jpeg-xl/lib/jxl/convolve_symmetric5.cc b/third_party/jpeg-xl/lib/jxl/convolve_symmetric5.cc
index 7ed384894e..4c8451f847 100644
--- a/third_party/jpeg-xl/lib/jxl/convolve_symmetric5.cc
+++ b/third_party/jpeg-xl/lib/jxl/convolve_symmetric5.cc
@@ -11,6 +11,7 @@
#include <hwy/highway.h>
#include "lib/jxl/base/common.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/convolve-inl.h"
HWY_BEFORE_NAMESPACE();
diff --git a/third_party/jpeg-xl/lib/jxl/convolve_test.cc b/third_party/jpeg-xl/lib/jxl/convolve_test.cc
index 084398c5e1..5ba36b33fe 100644
--- a/third_party/jpeg-xl/lib/jxl/convolve_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/convolve_test.cc
@@ -8,6 +8,8 @@
#include <jxl/types.h>
#include <time.h>
+#include <cinttypes> // PRIx64
+
#undef HWY_TARGET_INCLUDE
#define HWY_TARGET_INCLUDE "lib/jxl/convolve_test.cc"
#include <hwy/foreach_target.h>
@@ -20,6 +22,7 @@
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/printf_macros.h"
#include "lib/jxl/base/random.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/image_ops.h"
#include "lib/jxl/image_test_utils.h"
#include "lib/jxl/test_utils.h"
diff --git a/third_party/jpeg-xl/lib/jxl/dct_for_test.h b/third_party/jpeg-xl/lib/jxl/dct_for_test.h
index b0cbffacad..29c189261d 100644
--- a/third_party/jpeg-xl/lib/jxl/dct_for_test.h
+++ b/third_party/jpeg-xl/lib/jxl/dct_for_test.h
@@ -8,9 +8,8 @@
// Unoptimized DCT only for use in tests.
-#include <string.h> // memcpy
-
#include <cmath>
+#include <cstring> // memcpy
#include <vector>
#include "lib/jxl/base/common.h"
diff --git a/third_party/jpeg-xl/lib/jxl/dct_util.h b/third_party/jpeg-xl/lib/jxl/dct_util.h
index 90a02658af..077c17bd77 100644
--- a/third_party/jpeg-xl/lib/jxl/dct_util.h
+++ b/third_party/jpeg-xl/lib/jxl/dct_util.h
@@ -6,9 +6,10 @@
#ifndef LIB_JXL_DCT_UTIL_H_
#define LIB_JXL_DCT_UTIL_H_
-#include <stddef.h>
-
+#include <cstddef>
+#include <cstdint>
#include <memory>
+#include <type_traits>
#include "lib/jxl/base/common.h"
#include "lib/jxl/base/status.h"
diff --git a/third_party/jpeg-xl/lib/jxl/dec_ans.h b/third_party/jpeg-xl/lib/jxl/dec_ans.h
index cbff1deebe..dc56df1216 100644
--- a/third_party/jpeg-xl/lib/jxl/dec_ans.h
+++ b/third_party/jpeg-xl/lib/jxl/dec_ans.h
@@ -10,17 +10,18 @@
// decoding table from them.
#include <jxl/types.h>
-#include <stddef.h>
-#include <stdint.h>
+#include <algorithm>
+#include <cstddef>
+#include <cstdint>
#include <cstring>
#include <vector>
#include "lib/jxl/ans_common.h"
#include "lib/jxl/ans_params.h"
#include "lib/jxl/base/bits.h"
-#include "lib/jxl/base/byte_order.h"
#include "lib/jxl/base/compiler_specific.h"
+#include "lib/jxl/base/status.h"
#include "lib/jxl/cache_aligned.h"
#include "lib/jxl/dec_bit_reader.h"
#include "lib/jxl/dec_huffman.h"
diff --git a/third_party/jpeg-xl/lib/jxl/dec_frame.cc b/third_party/jpeg-xl/lib/jxl/dec_frame.cc
index a2a82ad1fb..ab51c1841f 100644
--- a/third_party/jpeg-xl/lib/jxl/dec_frame.cc
+++ b/third_party/jpeg-xl/lib/jxl/dec_frame.cc
@@ -23,6 +23,7 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/printf_macros.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/chroma_from_luma.h"
#include "lib/jxl/coeff_order.h"
diff --git a/third_party/jpeg-xl/lib/jxl/dec_group.cc b/third_party/jpeg-xl/lib/jxl/dec_group.cc
index 7dc4772eba..d1b03969c8 100644
--- a/third_party/jpeg-xl/lib/jxl/dec_group.cc
+++ b/third_party/jpeg-xl/lib/jxl/dec_group.cc
@@ -5,10 +5,9 @@
#include "lib/jxl/dec_group.h"
-#include <stdint.h>
-#include <string.h>
-
#include <algorithm>
+#include <cstdint>
+#include <cstring>
#include <memory>
#include <utility>
@@ -24,6 +23,7 @@
#include "lib/jxl/base/bits.h"
#include "lib/jxl/base/common.h"
#include "lib/jxl/base/printf_macros.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/coeff_order.h"
#include "lib/jxl/common.h" // kMaxNumPasses
diff --git a/third_party/jpeg-xl/lib/jxl/dec_group_border.cc b/third_party/jpeg-xl/lib/jxl/dec_group_border.cc
index 4bee3ae6ef..0f55a4053f 100644
--- a/third_party/jpeg-xl/lib/jxl/dec_group_border.cc
+++ b/third_party/jpeg-xl/lib/jxl/dec_group_border.cc
@@ -6,6 +6,13 @@
#include "lib/jxl/dec_group_border.h"
#include <atomic>
+#include <cstddef>
+#include <cstdint>
+#include <utility>
+
+#include "lib/jxl/base/rect.h"
+#include "lib/jxl/base/status.h"
+#include "lib/jxl/frame_dimensions.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/dec_group_border.h b/third_party/jpeg-xl/lib/jxl/dec_group_border.h
index cb3ecbefae..829f513d16 100644
--- a/third_party/jpeg-xl/lib/jxl/dec_group_border.h
+++ b/third_party/jpeg-xl/lib/jxl/dec_group_border.h
@@ -6,14 +6,13 @@
#ifndef LIB_JXL_DEC_GROUP_BORDER_H_
#define LIB_JXL_DEC_GROUP_BORDER_H_
-#include <stddef.h>
-
#include <atomic>
+#include <cstddef>
+#include <cstdint>
+#include <memory>
-#include "lib/jxl/base/arch_macros.h"
-#include "lib/jxl/base/status.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/frame_dimensions.h"
-#include "lib/jxl/image.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/dec_modular.cc b/third_party/jpeg-xl/lib/jxl/dec_modular.cc
index 80cc9d1360..049d6e4f91 100644
--- a/third_party/jpeg-xl/lib/jxl/dec_modular.cc
+++ b/third_party/jpeg-xl/lib/jxl/dec_modular.cc
@@ -5,9 +5,8 @@
#include "lib/jxl/dec_modular.h"
-#include <stdint.h>
-
#include <atomic>
+#include <cstdint>
#include <vector>
#include "lib/jxl/frame_header.h"
@@ -19,6 +18,7 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/printf_macros.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/compressed_dc.h"
#include "lib/jxl/epf.h"
diff --git a/third_party/jpeg-xl/lib/jxl/dec_modular.h b/third_party/jpeg-xl/lib/jxl/dec_modular.h
index 23caad0c16..70eab8af89 100644
--- a/third_party/jpeg-xl/lib/jxl/dec_modular.h
+++ b/third_party/jpeg-xl/lib/jxl/dec_modular.h
@@ -6,18 +6,23 @@
#ifndef LIB_JXL_DEC_MODULAR_H_
#define LIB_JXL_DEC_MODULAR_H_
-#include <stddef.h>
-
+#include <cstddef>
+#include <cstdint>
#include <string>
+#include <vector>
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_bit_reader.h"
#include "lib/jxl/dec_cache.h"
+#include "lib/jxl/frame_dimensions.h"
#include "lib/jxl/frame_header.h"
-#include "lib/jxl/image.h"
+#include "lib/jxl/modular/encoding/dec_ma.h"
#include "lib/jxl/modular/encoding/encoding.h"
#include "lib/jxl/modular/modular_image.h"
+#include "lib/jxl/quant_weights.h"
+#include "lib/jxl/render_pipeline/render_pipeline.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/dec_noise.cc b/third_party/jpeg-xl/lib/jxl/dec_noise.cc
index 24f0136490..ed5668f26b 100644
--- a/third_party/jpeg-xl/lib/jxl/dec_noise.cc
+++ b/third_party/jpeg-xl/lib/jxl/dec_noise.cc
@@ -5,11 +5,8 @@
#include "lib/jxl/dec_noise.h"
-#include <stdint.h>
-#include <stdlib.h>
-
-#include <algorithm>
-#include <numeric>
+#include <cstdint>
+#include <cstdlib>
#include <utility>
#undef HWY_TARGET_INCLUDE
@@ -18,10 +15,10 @@
#include <hwy/highway.h>
#include "lib/jxl/base/compiler_specific.h"
-#include "lib/jxl/chroma_from_luma.h"
-#include "lib/jxl/image_ops.h"
-#include "lib/jxl/sanitizers.h"
+#include "lib/jxl/base/rect.h"
+#include "lib/jxl/frame_dimensions.h"
#include "lib/jxl/xorshift128plus-inl.h"
+
HWY_BEFORE_NAMESPACE();
namespace jxl {
namespace HWY_NAMESPACE {
diff --git a/third_party/jpeg-xl/lib/jxl/dec_noise.h b/third_party/jpeg-xl/lib/jxl/dec_noise.h
index ac05866470..39a3a8b8e3 100644
--- a/third_party/jpeg-xl/lib/jxl/dec_noise.h
+++ b/third_party/jpeg-xl/lib/jxl/dec_noise.h
@@ -8,11 +8,11 @@
// Noise synthesis. Currently disabled.
-#include <stddef.h>
-#include <stdint.h>
+#include <cstddef>
+#include <utility>
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
-#include "lib/jxl/chroma_from_luma.h"
#include "lib/jxl/dec_bit_reader.h"
#include "lib/jxl/image.h"
#include "lib/jxl/noise.h"
diff --git a/third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.h b/third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.h
index 72dca8f057..ad0f5d6a04 100644
--- a/third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.h
+++ b/third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.h
@@ -8,10 +8,12 @@
// Chooses reference patches, and avoids encoding them once per occurrence.
-#include <stddef.h>
-#include <string.h>
#include <sys/types.h>
+#include <cstddef>
+#include <cstdint>
+#include <cstring>
+#include <utility>
#include <vector>
#include "lib/jxl/base/status.h"
diff --git a/third_party/jpeg-xl/lib/jxl/dec_transforms-inl.h b/third_party/jpeg-xl/lib/jxl/dec_transforms-inl.h
index 9c90550625..51b0c80727 100644
--- a/third_party/jpeg-xl/lib/jxl/dec_transforms-inl.h
+++ b/third_party/jpeg-xl/lib/jxl/dec_transforms-inl.h
@@ -10,12 +10,10 @@
#define LIB_JXL_DEC_TRANSFORMS_INL_H_
#endif
-#include <stddef.h>
-
+#include <cstddef>
#include <hwy/highway.h>
#include "lib/jxl/ac_strategy.h"
-#include "lib/jxl/coeff_order_fwd.h"
#include "lib/jxl/dct-inl.h"
#include "lib/jxl/dct_scales.h"
HWY_BEFORE_NAMESPACE();
diff --git a/third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.cc b/third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.cc
index 6451c41f6d..294d10f504 100644
--- a/third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.cc
+++ b/third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.cc
@@ -10,7 +10,6 @@
#include <hwy/foreach_target.h>
#include <hwy/highway.h>
-#include "lib/jxl/dct_scales.h"
#include "lib/jxl/dec_transforms-inl.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.h b/third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.h
index 2cbf6bd5f6..b7f3e8825d 100644
--- a/third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.h
+++ b/third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.h
@@ -8,8 +8,7 @@
// Facade for (non-inlined) inverse integral transforms.
-#include <stddef.h>
-#include <stdint.h>
+#include <cstddef>
#include "lib/jxl/ac_strategy.h"
#include "lib/jxl/base/compiler_specific.h"
diff --git a/third_party/jpeg-xl/lib/jxl/dec_xyb.cc b/third_party/jpeg-xl/lib/jxl/dec_xyb.cc
index a719b3eb8c..009c078fae 100644
--- a/third_party/jpeg-xl/lib/jxl/dec_xyb.cc
+++ b/third_party/jpeg-xl/lib/jxl/dec_xyb.cc
@@ -5,7 +5,7 @@
#include "lib/jxl/dec_xyb.h"
-#include <string.h>
+#include <cstring>
#undef HWY_TARGET_INCLUDE
#define HWY_TARGET_INCLUDE "lib/jxl/dec_xyb.cc"
@@ -14,13 +14,12 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/matrix_ops.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/cms/jxl_cms_internal.h"
#include "lib/jxl/cms/opsin_params.h"
#include "lib/jxl/color_encoding_internal.h"
-#include "lib/jxl/dec_group_border.h"
#include "lib/jxl/dec_xyb-inl.h"
-#include "lib/jxl/fields.h"
#include "lib/jxl/image.h"
#include "lib/jxl/opsin_params.h"
#include "lib/jxl/quantizer.h"
diff --git a/third_party/jpeg-xl/lib/jxl/dec_xyb.h b/third_party/jpeg-xl/lib/jxl/dec_xyb.h
index 65317f2f54..13692456f8 100644
--- a/third_party/jpeg-xl/lib/jxl/dec_xyb.h
+++ b/third_party/jpeg-xl/lib/jxl/dec_xyb.h
@@ -15,6 +15,8 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/matrix_ops.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/color_encoding_internal.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/decode_test.cc b/third_party/jpeg-xl/lib/jxl/decode_test.cc
index 99b5871ccd..bf6723016f 100644
--- a/third_party/jpeg-xl/lib/jxl/decode_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/decode_test.cc
@@ -1701,7 +1701,7 @@ TEST(DecodeTest, PixelTestWithICCProfileLossy) {
EXPECT_SLIGHTLY_BELOW(
ButteraugliDistance(io0.frames, io1.frames, ba, *JxlGetDefaultCms(),
/*distmap=*/nullptr, nullptr),
- 0.56f);
+ 0.58f);
JxlDecoderDestroy(dec);
}
@@ -2151,7 +2151,7 @@ TEST(DecodeTest, PixelTestOpaqueSrgbLossyNoise) {
EXPECT_SLIGHTLY_BELOW(
ButteraugliDistance(io0.frames, io1.frames, ba, *JxlGetDefaultCms(),
/*distmap=*/nullptr, nullptr),
- 1.3f);
+ 1.9f);
JxlDecoderDestroy(dec);
}
diff --git a/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.cc b/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.cc
index 4aafd7a5e5..0be7cdb882 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.cc
@@ -5,12 +5,11 @@
#include "lib/jxl/enc_ac_strategy.h"
-#include <stdint.h>
-#include <string.h>
-
#include <algorithm>
#include <cmath>
+#include <cstdint>
#include <cstdio>
+#include <cstring>
#undef HWY_TARGET_INCLUDE
#define HWY_TARGET_INCLUDE "lib/jxl/enc_ac_strategy.cc"
@@ -21,6 +20,7 @@
#include "lib/jxl/base/bits.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/fast_math-inl.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_transforms-inl.h"
#include "lib/jxl/enc_aux_out.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.h b/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.h
index 31eb73c6a0..05103e78ab 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.h
@@ -7,9 +7,12 @@
#define LIB_JXL_ENC_AC_STRATEGY_H_
#include <cstddef>
+#include <cstdint>
+#include <hwy/aligned_allocator.h>
#include "lib/jxl/ac_strategy.h"
#include "lib/jxl/base/compiler_specific.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/chroma_from_luma.h"
#include "lib/jxl/enc_cache.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.cc b/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.cc
index 4c2ddba95b..fa0570d937 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.cc
@@ -24,6 +24,7 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/fast_math-inl.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/butteraugli/butteraugli.h"
#include "lib/jxl/cms/opsin_params.h"
@@ -765,7 +766,7 @@ StatusOr<ImageF> TileDistMap(const ImageF& distmap, int tile_size, int margin,
const float kDcQuantPow = 0.83f;
const float kDcQuant = 1.095924047623553f;
-const float kAcQuant = 0.7381485255235064f;
+const float kAcQuant = 0.725f;
// Computes the decoded image for a given set of compression parameters.
StatusOr<ImageBundle> RoundtripImage(const FrameHeader& frame_header,
diff --git a/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.h b/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.h
index 26ed3f26ca..30849dba4e 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.h
@@ -7,10 +7,11 @@
#define LIB_JXL_ENC_ADAPTIVE_QUANTIZATION_H_
#include <jxl/cms_interface.h>
-#include <stddef.h>
#include "lib/jxl/ac_strategy.h"
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
+#include "lib/jxl/base/status.h"
#include "lib/jxl/enc_cache.h"
#include "lib/jxl/frame_header.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.cc b/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.cc
index 4f1d2dadb5..c323dc68bb 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.cc
@@ -5,10 +5,9 @@
#include "lib/jxl/enc_ar_control_field.h"
-#include <stdint.h>
-#include <stdlib.h>
-
#include <algorithm>
+#include <cstdint>
+#include <cstdlib>
#undef HWY_TARGET_INCLUDE
#define HWY_TARGET_INCLUDE "lib/jxl/enc_ar_control_field.cc"
@@ -17,6 +16,7 @@
#include "lib/jxl/ac_strategy.h"
#include "lib/jxl/base/compiler_specific.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/enc_params.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.h b/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.h
index f3c5a97a1b..fef5a51d05 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.h
@@ -6,11 +6,12 @@
#ifndef LIB_JXL_ENC_AR_CONTROL_FIELD_H_
#define LIB_JXL_ENC_AR_CONTROL_FIELD_H_
-#include <stddef.h>
-
+#include <cstddef>
#include <vector>
#include "lib/jxl/ac_strategy.h"
+#include "lib/jxl/base/rect.h"
+#include "lib/jxl/base/status.h"
#include "lib/jxl/enc_params.h"
#include "lib/jxl/frame_header.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_cache.cc b/third_party/jpeg-xl/lib/jxl/enc_cache.cc
index 200ec83b65..91d0046c29 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_cache.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_cache.cc
@@ -5,13 +5,13 @@
#include "lib/jxl/enc_cache.h"
-#include <stddef.h>
-#include <stdint.h>
-
+#include <cstddef>
+#include <cstdint>
#include <memory>
#include "lib/jxl/base/common.h"
#include "lib/jxl/base/compiler_specific.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/span.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/color_encoding_internal.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_cache.h b/third_party/jpeg-xl/lib/jxl/enc_cache.h
index 43ee7bc9c8..76b7e3ddae 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_cache.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_cache.h
@@ -7,13 +7,14 @@
#define LIB_JXL_ENC_CACHE_H_
#include <jxl/cms_interface.h>
-#include <stddef.h>
-#include <stdint.h>
+#include <cstddef>
+#include <cstdint>
#include <memory>
#include <vector>
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/dct_util.h"
#include "lib/jxl/enc_ans.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.cc b/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.cc
index 4039da2858..d45899936b 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.cc
@@ -5,11 +5,10 @@
#include "lib/jxl/enc_chroma_from_luma.h"
-#include <float.h>
-#include <stdlib.h>
-
#include <algorithm>
+#include <cfloat>
#include <cmath>
+#include <cstdlib>
#undef HWY_TARGET_INCLUDE
#define HWY_TARGET_INCLUDE "lib/jxl/enc_chroma_from_luma.cc"
@@ -18,6 +17,7 @@
#include <hwy/highway.h>
#include "lib/jxl/base/common.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/cms/opsin_params.h"
#include "lib/jxl/dec_transforms-inl.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.h b/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.h
index c6481a0ec9..514202bf8b 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.h
@@ -13,6 +13,8 @@
#include <hwy/aligned_allocator.h>
#include "lib/jxl/ac_strategy.h"
+#include "lib/jxl/base/rect.h"
+#include "lib/jxl/base/status.h"
#include "lib/jxl/chroma_from_luma.h"
#include "lib/jxl/enc_bit_writer.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_cluster.h b/third_party/jpeg-xl/lib/jxl/enc_cluster.h
index 7ddc003cf2..3b157c9c9d 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_cluster.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_cluster.h
@@ -8,13 +8,11 @@
#ifndef LIB_JXL_ENC_CLUSTER_H_
#define LIB_JXL_ENC_CLUSTER_H_
-#include <stddef.h>
-#include <stdint.h>
-#include <string.h>
-
+#include <cstddef>
+#include <cstdint>
+#include <cstring>
#include <vector>
-#include "lib/jxl/ans_params.h"
#include "lib/jxl/base/common.h"
#include "lib/jxl/enc_ans_params.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_coeff_order.cc b/third_party/jpeg-xl/lib/jxl/enc_coeff_order.cc
index 49129f5d9e..abe404ce9e 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_coeff_order.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_coeff_order.cc
@@ -3,13 +3,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#include <stdint.h>
-
#include <algorithm>
#include <cmath>
+#include <cstdint>
#include <hwy/aligned_allocator.h>
#include <vector>
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/coeff_order.h"
#include "lib/jxl/coeff_order_fwd.h"
#include "lib/jxl/dct_util.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_coeff_order.h b/third_party/jpeg-xl/lib/jxl/enc_coeff_order.h
index 25e0f17a8d..65f497e882 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_coeff_order.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_coeff_order.h
@@ -6,18 +6,16 @@
#ifndef LIB_JXL_ENC_COEFF_ORDER_H_
#define LIB_JXL_ENC_COEFF_ORDER_H_
-#include <stddef.h>
-#include <stdint.h>
+#include <cstddef>
+#include <cstdint>
#include "lib/jxl/ac_strategy.h"
#include "lib/jxl/base/compiler_specific.h"
-#include "lib/jxl/base/status.h"
-#include "lib/jxl/coeff_order.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/coeff_order_fwd.h"
+#include "lib/jxl/common.h"
#include "lib/jxl/dct_util.h"
-#include "lib/jxl/dec_bit_reader.h"
#include "lib/jxl/enc_bit_writer.h"
-#include "lib/jxl/enc_params.h"
#include "lib/jxl/frame_dimensions.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/enc_comparator.h b/third_party/jpeg-xl/lib/jxl/enc_comparator.h
index ee62ab6f28..6ae6913abe 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_comparator.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_comparator.h
@@ -6,6 +6,8 @@
#ifndef LIB_JXL_ENC_COMPARATOR_H_
#define LIB_JXL_ENC_COMPARATOR_H_
+#include <jxl/cms_interface.h>
+
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_debug_image.cc b/third_party/jpeg-xl/lib/jxl/enc_debug_image.cc
index d67ab7db46..6b4d115e7f 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_debug_image.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_debug_image.cc
@@ -5,9 +5,10 @@
#include "lib/jxl/enc_debug_image.h"
-#include <stddef.h>
-#include <stdint.h>
+#include <cstddef>
+#include <cstdint>
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/color_encoding_internal.h"
#include "lib/jxl/dec_external_image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_debug_image.h b/third_party/jpeg-xl/lib/jxl/enc_debug_image.h
index 428293f8bc..98d27e705c 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_debug_image.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_debug_image.h
@@ -8,9 +8,9 @@
// Optional output images for debugging.
-#include <stddef.h>
-#include <stdint.h>
+#include <cstdint>
+#include "lib/jxl/base/status.h"
#include "lib/jxl/enc_params.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_detect_dots.cc b/third_party/jpeg-xl/lib/jxl/enc_detect_dots.cc
index 94e6fefb61..81dd2f2b67 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_detect_dots.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_detect_dots.cc
@@ -5,11 +5,10 @@
#include "lib/jxl/enc_detect_dots.h"
-#include <stdint.h>
-
#include <algorithm>
#include <array>
#include <cmath>
+#include <cstdint>
#include <cstdio>
#include <utility>
#include <vector>
@@ -23,6 +22,7 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/printf_macros.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/convolve.h"
#include "lib/jxl/enc_linalg.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_detect_dots.h b/third_party/jpeg-xl/lib/jxl/enc_detect_dots.h
index 59def59f8f..91174463f7 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_detect_dots.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_detect_dots.h
@@ -7,13 +7,14 @@
#ifndef LIB_JXL_ENC_DETECT_DOTS_H_
#define LIB_JXL_ENC_DETECT_DOTS_H_
-#include <stddef.h>
-#include <stdint.h>
-
#include <array>
+#include <cstddef>
+#include <cstdint>
#include <vector>
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
+#include "lib/jxl/base/status.h"
#include "lib/jxl/enc_patch_dictionary.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.cc b/third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.cc
index 7d76ba9002..bf9c15ef4e 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.cc
@@ -5,12 +5,12 @@
#include "lib/jxl/enc_dot_dictionary.h"
-#include <stddef.h>
-#include <string.h>
-
#include <array>
+#include <cstddef>
+#include <cstring>
#include "lib/jxl/base/override.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/chroma_from_luma.h"
#include "lib/jxl/enc_detect_dots.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.h b/third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.h
index d348fb73b8..cd7691e202 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.h
@@ -9,10 +9,10 @@
// Dots are stored in a dictionary to avoid storing similar dots multiple
// times.
-#include <stddef.h>
-
#include <vector>
+#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/chroma_from_luma.h"
#include "lib/jxl/enc_params.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_entropy_coder.cc b/third_party/jpeg-xl/lib/jxl/enc_entropy_coder.cc
index b71bb07bc9..461713058c 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_entropy_coder.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_entropy_coder.cc
@@ -5,11 +5,8 @@
#include "lib/jxl/enc_entropy_coder.h"
-#include <stddef.h>
-#include <stdint.h>
-
-#include <algorithm>
-#include <utility>
+#include <cstddef>
+#include <cstdint>
#include <vector>
#undef HWY_TARGET_INCLUDE
@@ -24,13 +21,8 @@
#include "lib/jxl/base/status.h"
#include "lib/jxl/coeff_order.h"
#include "lib/jxl/coeff_order_fwd.h"
-#include "lib/jxl/dec_ans.h"
-#include "lib/jxl/dec_bit_reader.h"
-#include "lib/jxl/dec_context_map.h"
#include "lib/jxl/entropy_coder.h"
-#include "lib/jxl/epf.h"
#include "lib/jxl/image.h"
-#include "lib/jxl/image_ops.h"
#include "lib/jxl/pack_signed.h"
HWY_BEFORE_NAMESPACE();
diff --git a/third_party/jpeg-xl/lib/jxl/enc_entropy_coder.h b/third_party/jpeg-xl/lib/jxl/enc_entropy_coder.h
index 6df3e8e770..2321a1d831 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_entropy_coder.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_entropy_coder.h
@@ -6,20 +6,17 @@
#ifndef LIB_JXL_ENC_ENTROPY_CODER_H_
#define LIB_JXL_ENC_ENTROPY_CODER_H_
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
#include <sys/types.h>
-#include <memory>
-#include <utility>
+#include <cstdint>
#include <vector>
#include "lib/jxl/ac_context.h" // BlockCtxMap
#include "lib/jxl/ac_strategy.h"
+#include "lib/jxl/base/compiler_specific.h"
+#include "lib/jxl/base/rect.h"
+#include "lib/jxl/coeff_order_fwd.h"
#include "lib/jxl/enc_ans.h"
-#include "lib/jxl/field_encodings.h"
#include "lib/jxl/frame_header.h" // YCbCrChromaSubsampling
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_fast_lossless.cc b/third_party/jpeg-xl/lib/jxl/enc_fast_lossless.cc
index 1797139428..a5884301b6 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_fast_lossless.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_fast_lossless.cc
@@ -3612,7 +3612,8 @@ bool detect_palette(const unsigned char* r, size_t width,
size_t x = 0;
bool collided = false;
// this is just an unrolling of the next loop
- for (; x + 7 < width; x += 8) {
+ size_t look_ahead = 7 + ((nb_chans == 1) ? 3 : ((nb_chans < 4) ? 1 : 0));
+ for (; x + look_ahead < width; x += 8) {
uint32_t p[8] = {}, index[8];
for (int i = 0; i < 8; i++) memcpy(&p[i], r + (x + i) * nb_chans, 4);
for (int i = 0; i < 8; i++) p[i] &= ((1llu << (8 * nb_chans)) - 1);
diff --git a/third_party/jpeg-xl/lib/jxl/enc_fields.cc b/third_party/jpeg-xl/lib/jxl/enc_fields.cc
index fa513297fd..e1bf9d2ad8 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_fields.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_fields.cc
@@ -5,7 +5,7 @@
#include "lib/jxl/enc_fields.h"
-#include <cinttypes>
+#include <cinttypes> // PRIu64
#include "lib/jxl/enc_aux_out.h"
#include "lib/jxl/fields.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_frame.cc b/third_party/jpeg-xl/lib/jxl/enc_frame.cc
index 2a3389921b..ec0af1e8e5 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_frame.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_frame.cc
@@ -5,13 +5,12 @@
#include "lib/jxl/enc_frame.h"
-#include <stddef.h>
-#include <stdint.h>
-
#include <algorithm>
#include <array>
#include <atomic>
#include <cmath>
+#include <cstddef>
+#include <cstdint>
#include <memory>
#include <numeric>
#include <utility>
@@ -25,6 +24,7 @@
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/override.h"
#include "lib/jxl/base/printf_macros.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/chroma_from_luma.h"
#include "lib/jxl/coeff_order.h"
@@ -583,10 +583,13 @@ struct PixelStatsForChromacityAdjustment {
CalcExposedBlue(&opsin->Plane(1), &opsin->Plane(2), rect);
}
int HowMuchIsXChannelPixelized() const {
- if (dx >= 0.03) {
+ if (dx >= 0.026) {
+ return 3;
+ }
+ if (dx >= 0.022) {
return 2;
}
- if (dx >= 0.017) {
+ if (dx >= 0.015) {
return 1;
}
return 0;
@@ -614,18 +617,13 @@ void ComputeChromacityAdjustments(const CompressParams& cparams,
return;
}
// 1) Distance based approach for chromacity adjustment:
- float x_qm_scale_steps[4] = {1.25f, 7.0f, 15.0f, 24.0f};
- frame_header->x_qm_scale = 2;
+ float x_qm_scale_steps[3] = {2.5f, 5.5f, 9.5f};
+ frame_header->x_qm_scale = 3;
for (float x_qm_scale_step : x_qm_scale_steps) {
if (cparams.original_butteraugli_distance > x_qm_scale_step) {
frame_header->x_qm_scale++;
}
}
- if (cparams.butteraugli_distance < 0.299f) {
- // Favor chromacity preservation for making images appear more
- // faithful to original even with extreme (5-10x) zooming.
- frame_header->x_qm_scale++;
- }
// 2) Pixel-based approach for chromacity adjustment:
// look at the individual pixels and make a guess how difficult
// the image would be based on the worst case pixel.
diff --git a/third_party/jpeg-xl/lib/jxl/enc_gaborish.cc b/third_party/jpeg-xl/lib/jxl/enc_gaborish.cc
index 7467a4d669..ba1181e285 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_gaborish.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_gaborish.cc
@@ -5,12 +5,13 @@
#include "lib/jxl/enc_gaborish.h"
-#include <stddef.h>
-
#include <hwy/base.h>
+#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/convolve.h"
+#include "lib/jxl/image.h"
#include "lib/jxl/image_ops.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/enc_gaborish.h b/third_party/jpeg-xl/lib/jxl/enc_gaborish.h
index 041edcec96..ce1c211ffa 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_gaborish.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_gaborish.h
@@ -9,6 +9,7 @@
// Linear smoothing (3x3 convolution) for deblocking without too much blur.
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_gaborish_test.cc b/third_party/jpeg-xl/lib/jxl/enc_gaborish_test.cc
index 0d173c5eb8..074c547287 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_gaborish_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_gaborish_test.cc
@@ -11,6 +11,7 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/convolve.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_group.cc b/third_party/jpeg-xl/lib/jxl/enc_group.cc
index 2b60643e7c..6e4e05335a 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_group.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_group.cc
@@ -6,7 +6,6 @@
#include "lib/jxl/enc_group.h"
#include <hwy/aligned_allocator.h>
-#include <utility>
#undef HWY_TARGET_INCLUDE
#define HWY_TARGET_INCLUDE "lib/jxl/enc_group.cc"
@@ -16,6 +15,7 @@
#include "lib/jxl/ac_strategy.h"
#include "lib/jxl/base/bits.h"
#include "lib/jxl/base/compiler_specific.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/common.h" // kMaxNumPasses
#include "lib/jxl/dct_util.h"
#include "lib/jxl/dec_transforms-inl.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_group.h b/third_party/jpeg-xl/lib/jxl/enc_group.h
index 78484c2e9b..c9c4b77a5b 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_group.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_group.h
@@ -6,8 +6,9 @@
#ifndef LIB_JXL_ENC_GROUP_H_
#define LIB_JXL_ENC_GROUP_H_
-#include <stddef.h>
+#include <cstddef>
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/enc_bit_writer.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_heuristics.cc b/third_party/jpeg-xl/lib/jxl/enc_heuristics.cc
index 685558ac7c..152468255f 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_heuristics.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_heuristics.cc
@@ -6,10 +6,10 @@
#include "lib/jxl/enc_heuristics.h"
#include <jxl/cms_interface.h>
-#include <stddef.h>
-#include <stdint.h>
#include <algorithm>
+#include <cstddef>
+#include <cstdint>
#include <cstdlib>
#include <limits>
#include <memory>
@@ -24,6 +24,7 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/override.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/butteraugli/butteraugli.h"
#include "lib/jxl/chroma_from_luma.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_heuristics.h b/third_party/jpeg-xl/lib/jxl/enc_heuristics.h
index 0dd93e4288..75a196748c 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_heuristics.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_heuristics.h
@@ -9,9 +9,9 @@
// Hook for custom encoder heuristics (VarDCT only for now).
#include <jxl/cms_interface.h>
-#include <stddef.h>
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/frame_header.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_image_bundle.cc b/third_party/jpeg-xl/lib/jxl/enc_image_bundle.cc
index 044f763363..db3c497cde 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_image_bundle.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_image_bundle.cc
@@ -10,6 +10,7 @@
#include <atomic>
#include <utility>
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/color_encoding_internal.h"
#include "lib/jxl/image_bundle.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_image_bundle.h b/third_party/jpeg-xl/lib/jxl/enc_image_bundle.h
index 38536c8c7a..c1180a6da8 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_image_bundle.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_image_bundle.h
@@ -9,6 +9,7 @@
#include <jxl/cms_interface.h>
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/color_encoding_internal.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_linalg_test.cc b/third_party/jpeg-xl/lib/jxl/enc_linalg_test.cc
index c02f009ca7..1056c4f06c 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_linalg_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_linalg_test.cc
@@ -5,6 +5,8 @@
#include "lib/jxl/enc_linalg.h"
+#include <cstddef>
+
#include "lib/jxl/base/random.h"
#include "lib/jxl/testing.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_modular.cc b/third_party/jpeg-xl/lib/jxl/enc_modular.cc
index 35fac3c827..25464737b8 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_modular.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_modular.cc
@@ -5,11 +5,9 @@
#include "lib/jxl/enc_modular.h"
-#include <stddef.h>
-#include <stdint.h>
-
#include <array>
#include <atomic>
+#include <cstddef>
#include <cstdint>
#include <limits>
#include <utility>
@@ -17,6 +15,7 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/printf_macros.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/compressed_dc.h"
#include "lib/jxl/dec_ans.h"
@@ -998,7 +997,9 @@ Status ModularFrameEncoder::ComputeEncodingData(
pool, 0, stream_params_.size(), ThreadPool::NoInit,
[&](const uint32_t i, size_t /* thread */) {
size_t stream = stream_params_[i].id.ID(frame_dim_);
- stream_options_[stream] = stream_options_[0];
+ if (stream != 0) {
+ stream_options_[stream] = stream_options_[0];
+ }
JXL_CHECK(PrepareStreamParams(
stream_params_[i].rect, cparams_, stream_params_[i].minShift,
stream_params_[i].maxShift, stream_params_[i].id, do_color,
diff --git a/third_party/jpeg-xl/lib/jxl/enc_modular.h b/third_party/jpeg-xl/lib/jxl/enc_modular.h
index c7a8421982..cac6483a00 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_modular.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_modular.h
@@ -14,6 +14,7 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_modular.h"
#include "lib/jxl/enc_ans.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_optimize_test.cc b/third_party/jpeg-xl/lib/jxl/enc_optimize_test.cc
index 9184765be2..4270116ee8 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_optimize_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_optimize_test.cc
@@ -5,6 +5,10 @@
#include "lib/jxl/enc_optimize.h"
+#include <cmath>
+#include <cstddef>
+#include <vector>
+
#include "lib/jxl/testing.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.cc b/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.cc
index 6fc5f7f49e..2586692c4e 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.cc
@@ -6,12 +6,12 @@
#include "lib/jxl/enc_patch_dictionary.h"
#include <jxl/types.h>
-#include <stdint.h>
-#include <stdlib.h>
#include <sys/types.h>
#include <algorithm>
#include <atomic>
+#include <cstdint>
+#include <cstdlib>
#include <utility>
#include <vector>
@@ -20,6 +20,7 @@
#include "lib/jxl/base/override.h"
#include "lib/jxl/base/printf_macros.h"
#include "lib/jxl/base/random.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_cache.h"
#include "lib/jxl/dec_frame.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.h b/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.h
index ac236d7f17..ba2e3ba6b2 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.h
@@ -8,12 +8,16 @@
// Chooses reference patches, and avoids encoding them once per occurrence.
-#include <stddef.h>
-#include <string.h>
+#include <jxl/cms_interface.h>
#include <sys/types.h>
+#include <cstddef>
+#include <cstdint>
+#include <cstring>
+#include <utility>
#include <vector>
+#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_patch_dictionary.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_photon_noise.h b/third_party/jpeg-xl/lib/jxl/enc_photon_noise.h
index f43e14d560..d3c6d843af 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_photon_noise.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_photon_noise.h
@@ -6,8 +6,8 @@
#ifndef LIB_JXL_ENC_PHOTON_NOISE_H_
#define LIB_JXL_ENC_PHOTON_NOISE_H_
-#include "lib/jxl/dec_xyb.h"
-#include "lib/jxl/image.h"
+#include <cstddef>
+
#include "lib/jxl/noise.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/enc_photon_noise_test.cc b/third_party/jpeg-xl/lib/jxl/enc_photon_noise_test.cc
index 2e10dd5457..db172fb699 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_photon_noise_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_photon_noise_test.cc
@@ -5,7 +5,6 @@
#include "lib/jxl/enc_photon_noise.h"
-#include "lib/jxl/base/common.h"
#include "lib/jxl/noise.h"
#include "lib/jxl/testing.h"
diff --git a/third_party/jpeg-xl/lib/jxl/enc_quant_weights.h b/third_party/jpeg-xl/lib/jxl/enc_quant_weights.h
index 82d8278b72..897ace6c7e 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_quant_weights.h
+++ b/third_party/jpeg-xl/lib/jxl/enc_quant_weights.h
@@ -7,7 +7,9 @@
#define LIB_JXL_ENC_QUANT_WEIGHTS_H_
#include <cstddef>
+#include <vector>
+#include "lib/jxl/base/status.h"
#include "lib/jxl/quant_weights.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/enc_xyb.cc b/third_party/jpeg-xl/lib/jxl/enc_xyb.cc
index 9fc68d8474..89bb4de37c 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_xyb.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_xyb.cc
@@ -17,6 +17,7 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/fast_math-inl.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/cms/opsin_params.h"
#include "lib/jxl/cms/transfer_functions-inl.h"
diff --git a/third_party/jpeg-xl/lib/jxl/encode_internal.h b/third_party/jpeg-xl/lib/jxl/encode_internal.h
index 001df5fed5..8030c8314a 100644
--- a/third_party/jpeg-xl/lib/jxl/encode_internal.h
+++ b/third_party/jpeg-xl/lib/jxl/encode_internal.h
@@ -214,7 +214,7 @@ class JxlEncoderChunkedFrameAdapter {
}
// TODO(szabadka) Move instead of copy.
- void SetJPEGData(const jpeg::JPEGData jpeg_data) {
+ void SetJPEGData(const jpeg::JPEGData& jpeg_data) {
jpeg_data_ = jpeg_data;
has_jpeg_data_ = true;
}
diff --git a/third_party/jpeg-xl/lib/jxl/encode_test.cc b/third_party/jpeg-xl/lib/jxl/encode_test.cc
index 0aef5f8aff..7400b237de 100644
--- a/third_party/jpeg-xl/lib/jxl/encode_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/encode_test.cc
@@ -233,7 +233,7 @@ void VerifyFrameEncoding(size_t xsize, size_t ysize, JxlEncoder* enc,
static constexpr double kMaxButteraugli =
#if JXL_HIGH_PRECISION
- 1.84;
+ 3.2;
#else
8.7;
#endif
@@ -461,7 +461,7 @@ TEST(EncodeTest, FrameSettingsTest) {
JxlEncoderFrameSettings* frame_settings =
JxlEncoderFrameSettingsCreate(enc.get(), nullptr);
EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetFrameDistance(frame_settings, 0.5));
- VerifyFrameEncoding(63, 129, enc.get(), frame_settings, 3130, false);
+ VerifyFrameEncoding(63, 129, enc.get(), frame_settings, 3200, false);
EXPECT_EQ(0.5, enc->last_used_cparams.butteraugli_distance);
}
@@ -1888,7 +1888,7 @@ TEST_P(EncoderStreamingTest, OutputCallback) {
p.color_includes_alpha(), p.is_lossless());
std::vector<uint8_t> compressed = std::vector<uint8_t>(64);
- // without sreaming
+ // without streaming
{
JxlEncoderPtr enc = JxlEncoderMake(nullptr);
ASSERT_NE(nullptr, enc.get());
diff --git a/third_party/jpeg-xl/lib/jxl/epf.cc b/third_party/jpeg-xl/lib/jxl/epf.cc
index 78ef38bfd5..042aa8c591 100644
--- a/third_party/jpeg-xl/lib/jxl/epf.cc
+++ b/third_party/jpeg-xl/lib/jxl/epf.cc
@@ -7,27 +7,17 @@
#include "lib/jxl/epf.h"
-#include <math.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-
#include <algorithm>
-#include <atomic>
-#include <numeric> // std::accumulate
-#include <vector>
+#include <cstddef>
+#include <cstdint>
+#include <cstring>
#include "lib/jxl/ac_strategy.h"
#include "lib/jxl/base/compiler_specific.h"
-#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
-#include "lib/jxl/convolve.h"
#include "lib/jxl/dec_cache.h"
-#include "lib/jxl/image.h"
-#include "lib/jxl/image_bundle.h"
-#include "lib/jxl/image_ops.h"
#include "lib/jxl/loop_filter.h"
-#include "lib/jxl/quant_weights.h"
#include "lib/jxl/quantizer.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/epf.h b/third_party/jpeg-xl/lib/jxl/epf.h
index 808dde10dc..e372deaa6b 100644
--- a/third_party/jpeg-xl/lib/jxl/epf.h
+++ b/third_party/jpeg-xl/lib/jxl/epf.h
@@ -8,8 +8,8 @@
// Fast SIMD "in-loop" edge preserving filter (adaptive, nonlinear).
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/dec_cache.h"
-#include "lib/jxl/image.h"
#include "lib/jxl/loop_filter.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/fake_parallel_runner_testonly.h b/third_party/jpeg-xl/lib/jxl/fake_parallel_runner_testonly.h
index 508d808cc5..4ca422e9a4 100644
--- a/third_party/jpeg-xl/lib/jxl/fake_parallel_runner_testonly.h
+++ b/third_party/jpeg-xl/lib/jxl/fake_parallel_runner_testonly.h
@@ -7,8 +7,8 @@
#define LIB_JXL_FAKE_PARALLEL_RUNNER_TESTONLY_H_
#include <jxl/parallel_runner.h>
-#include <stdint.h>
+#include <cstdint>
#include <vector>
#include "lib/jxl/base/compiler_specific.h"
diff --git a/third_party/jpeg-xl/lib/jxl/fields.cc b/third_party/jpeg-xl/lib/jxl/fields.cc
index 6bb5eae25d..e11166877b 100644
--- a/third_party/jpeg-xl/lib/jxl/fields.cc
+++ b/third_party/jpeg-xl/lib/jxl/fields.cc
@@ -6,7 +6,7 @@
#include "lib/jxl/fields.h"
#include <algorithm>
-#include <cinttypes>
+#include <cinttypes> // PRIu64
#include <cmath>
#include <cstddef>
#include <hwy/base.h>
diff --git a/third_party/jpeg-xl/lib/jxl/fields.h b/third_party/jpeg-xl/lib/jxl/fields.h
index a8d8d8671a..cb9554213a 100644
--- a/third_party/jpeg-xl/lib/jxl/fields.h
+++ b/third_party/jpeg-xl/lib/jxl/fields.h
@@ -8,14 +8,11 @@
// Forward/backward-compatible 'bundles' with auto-serialized 'fields'.
-#include <cmath> // abs
-#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstring>
-#include "lib/jxl/base/bits.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_bit_reader.h"
diff --git a/third_party/jpeg-xl/lib/jxl/fields_test.cc b/third_party/jpeg-xl/lib/jxl/fields_test.cc
index 0584458d07..5af68d2d5f 100644
--- a/third_party/jpeg-xl/lib/jxl/fields_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/fields_test.cc
@@ -5,18 +5,21 @@
#include "lib/jxl/fields.h"
-#include <stddef.h>
-#include <stdint.h>
-
#include <array>
-#include <utility>
+#include <cstddef>
+#include <cstdint>
#include "lib/jxl/base/common.h"
+#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/span.h"
+#include "lib/jxl/base/status.h"
+#include "lib/jxl/dec_bit_reader.h"
#include "lib/jxl/enc_aux_out.h"
#include "lib/jxl/enc_fields.h"
+#include "lib/jxl/field_encodings.h"
#include "lib/jxl/frame_header.h"
#include "lib/jxl/headers.h"
+#include "lib/jxl/image_metadata.h"
#include "lib/jxl/testing.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/frame_dimensions.h b/third_party/jpeg-xl/lib/jxl/frame_dimensions.h
index 8440a95463..f7493f88b2 100644
--- a/third_party/jpeg-xl/lib/jxl/frame_dimensions.h
+++ b/third_party/jpeg-xl/lib/jxl/frame_dimensions.h
@@ -11,7 +11,7 @@
#include <cstddef>
#include "lib/jxl/base/common.h"
-#include "lib/jxl/image.h"
+#include "lib/jxl/base/rect.h"
namespace jxl {
// Some enums and typedefs used by more than one header file.
diff --git a/third_party/jpeg-xl/lib/jxl/frame_header.h b/third_party/jpeg-xl/lib/jxl/frame_header.h
index 30c62d5f27..68c4684a58 100644
--- a/third_party/jpeg-xl/lib/jxl/frame_header.h
+++ b/third_party/jpeg-xl/lib/jxl/frame_header.h
@@ -9,18 +9,20 @@
// Frame header with backward and forward-compatible extension capability and
// compressed integer fields.
-#include <stddef.h>
-#include <stdint.h>
-
#include <algorithm>
+#include <array>
+#include <cstddef>
+#include <cstdint>
#include <string>
+#include <vector>
+#include "lib/jxl/base/common.h"
#include "lib/jxl/base/compiler_specific.h"
-#include "lib/jxl/base/override.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/coeff_order_fwd.h"
#include "lib/jxl/common.h" // kMaxNumPasses
#include "lib/jxl/dec_bit_reader.h"
+#include "lib/jxl/field_encodings.h"
#include "lib/jxl/fields.h"
#include "lib/jxl/frame_dimensions.h"
#include "lib/jxl/image_metadata.h"
diff --git a/third_party/jpeg-xl/lib/jxl/icc_codec.h b/third_party/jpeg-xl/lib/jxl/icc_codec.h
index 3b0b0c041b..e57018b4c3 100644
--- a/third_party/jpeg-xl/lib/jxl/icc_codec.h
+++ b/third_party/jpeg-xl/lib/jxl/icc_codec.h
@@ -10,8 +10,8 @@
#include <cstddef>
#include <cstdint>
+#include <vector>
-#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_ans.h"
#include "lib/jxl/dec_bit_reader.h"
diff --git a/third_party/jpeg-xl/lib/jxl/image.h b/third_party/jpeg-xl/lib/jxl/image.h
index be97b929e3..347e070336 100644
--- a/third_party/jpeg-xl/lib/jxl/image.h
+++ b/third_party/jpeg-xl/lib/jxl/image.h
@@ -10,16 +10,13 @@
#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
defined(THREAD_SANITIZER)
-#include <inttypes.h>
+#include <cinttypes> // PRIu64
#endif
-#include <stddef.h>
-#include <stdint.h>
-#include <string.h>
-
#include <algorithm>
-#include <sstream>
-#include <string>
+#include <cstddef>
+#include <cstdint>
+#include <cstring>
#include <utility> // std::move
#include "lib/jxl/base/compiler_specific.h"
@@ -184,179 +181,6 @@ using ImageI = Plane<int32_t>;
using ImageF = Plane<float>;
using ImageD = Plane<double>;
-template <typename T>
-class Image3;
-
-// Rectangular region in image(s). Factoring this out of Image instead of
-// shifting the pointer by x0/y0 allows this to apply to multiple images with
-// different resolutions (e.g. color transform and quantization field).
-// Can compare using SameSize(rect1, rect2).
-template <typename T>
-class RectT {
- public:
- // Most windows are xsize_max * ysize_max, except those on the borders where
- // begin + size_max > end.
- constexpr RectT(T xbegin, T ybegin, size_t xsize_max, size_t ysize_max,
- T xend, T yend)
- : x0_(xbegin),
- y0_(ybegin),
- xsize_(ClampedSize(xbegin, xsize_max, xend)),
- ysize_(ClampedSize(ybegin, ysize_max, yend)) {}
-
- // Construct with origin and known size (typically from another Rect).
- constexpr RectT(T xbegin, T ybegin, size_t xsize, size_t ysize)
- : x0_(xbegin), y0_(ybegin), xsize_(xsize), ysize_(ysize) {}
-
- // Construct a rect that covers a whole image/plane/ImageBundle etc.
- template <typename ImageT>
- explicit RectT(const ImageT& image)
- : RectT(0, 0, image.xsize(), image.ysize()) {}
-
- RectT() : RectT(0, 0, 0, 0) {}
-
- RectT(const RectT&) = default;
- RectT& operator=(const RectT&) = default;
-
- // Construct a subrect that resides in an image/plane/ImageBundle etc.
- template <typename ImageT>
- RectT Crop(const ImageT& image) const {
- return Intersection(RectT(image));
- }
-
- // Construct a subrect that resides in the [0, ysize) x [0, xsize) region of
- // the current rect.
- RectT Crop(size_t area_xsize, size_t area_ysize) const {
- return Intersection(RectT(0, 0, area_xsize, area_ysize));
- }
-
- // Returns a rect that only contains `num` lines with offset `y` from `y0()`.
- RectT Lines(size_t y, size_t num) const {
- JXL_DASSERT(y + num <= ysize_);
- return RectT(x0_, y0_ + y, xsize_, num);
- }
-
- RectT Line(size_t y) const { return Lines(y, 1); }
-
- JXL_MUST_USE_RESULT RectT Intersection(const RectT& other) const {
- return RectT(std::max(x0_, other.x0_), std::max(y0_, other.y0_), xsize_,
- ysize_, std::min(x1(), other.x1()),
- std::min(y1(), other.y1()));
- }
-
- JXL_MUST_USE_RESULT RectT Translate(int64_t x_offset,
- int64_t y_offset) const {
- return RectT(x0_ + x_offset, y0_ + y_offset, xsize_, ysize_);
- }
-
- template <typename V>
- V* Row(Plane<V>* image, size_t y) const {
- JXL_DASSERT(y + y0_ >= 0);
- return image->Row(y + y0_) + x0_;
- }
-
- template <typename V>
- const V* Row(const Plane<V>* image, size_t y) const {
- JXL_DASSERT(y + y0_ >= 0);
- return image->Row(y + y0_) + x0_;
- }
-
- template <typename V>
- V* PlaneRow(Image3<V>* image, const size_t c, size_t y) const {
- JXL_DASSERT(y + y0_ >= 0);
- return image->PlaneRow(c, y + y0_) + x0_;
- }
-
- template <typename V>
- const V* ConstRow(const Plane<V>& image, size_t y) const {
- JXL_DASSERT(y + y0_ >= 0);
- return image.ConstRow(y + y0_) + x0_;
- }
-
- template <typename V>
- const V* ConstPlaneRow(const Image3<V>& image, size_t c, size_t y) const {
- JXL_DASSERT(y + y0_ >= 0);
- return image.ConstPlaneRow(c, y + y0_) + x0_;
- }
-
- bool IsInside(const RectT& other) const {
- return x0_ >= other.x0() && x1() <= other.x1() && y0_ >= other.y0() &&
- y1() <= other.y1();
- }
-
- // Returns true if this Rect fully resides in the given image. ImageT could be
- // Plane<T> or Image3<T>; however if ImageT is Rect, results are nonsensical.
- template <class ImageT>
- bool IsInside(const ImageT& image) const {
- return IsInside(RectT(image));
- }
-
- T x0() const { return x0_; }
- T y0() const { return y0_; }
- size_t xsize() const { return xsize_; }
- size_t ysize() const { return ysize_; }
- T x1() const { return x0_ + xsize_; }
- T y1() const { return y0_ + ysize_; }
-
- RectT<T> ShiftLeft(size_t shiftx, size_t shifty) const {
- return RectT<T>(x0_ * (1 << shiftx), y0_ * (1 << shifty), xsize_ << shiftx,
- ysize_ << shifty);
- }
- RectT<T> ShiftLeft(size_t shift) const { return ShiftLeft(shift, shift); }
-
- // Requires x0(), y0() to be multiples of 1<<shiftx, 1<<shifty.
- RectT<T> CeilShiftRight(size_t shiftx, size_t shifty) const {
- JXL_ASSERT(x0_ % (1 << shiftx) == 0);
- JXL_ASSERT(y0_ % (1 << shifty) == 0);
- return RectT<T>(x0_ / (1 << shiftx), y0_ / (1 << shifty),
- DivCeil(xsize_, T{1} << shiftx),
- DivCeil(ysize_, T{1} << shifty));
- }
- RectT<T> CeilShiftRight(std::pair<size_t, size_t> shift) const {
- return CeilShiftRight(shift.first, shift.second);
- }
- RectT<T> CeilShiftRight(size_t shift) const {
- return CeilShiftRight(shift, shift);
- }
-
- RectT<T> Extend(T border, RectT<T> parent) const {
- T new_x0 = x0() > parent.x0() + border ? x0() - border : parent.x0();
- T new_y0 = y0() > parent.y0() + border ? y0() - border : parent.y0();
- T new_x1 = x1() + border > parent.x1() ? parent.x1() : x1() + border;
- T new_y1 = y1() + border > parent.y1() ? parent.y1() : y1() + border;
- return RectT<T>(new_x0, new_y0, new_x1 - new_x0, new_y1 - new_y0);
- }
-
- template <typename U>
- RectT<U> As() const {
- return RectT<U>(static_cast<U>(x0_), static_cast<U>(y0_),
- static_cast<U>(xsize_), static_cast<U>(ysize_));
- }
-
- private:
- // Returns size_max, or whatever is left in [begin, end).
- static constexpr size_t ClampedSize(T begin, size_t size_max, T end) {
- return (static_cast<T>(begin + size_max) <= end)
- ? size_max
- : (end > begin ? end - begin : 0);
- }
-
- T x0_;
- T y0_;
-
- size_t xsize_;
- size_t ysize_;
-};
-
-template <typename T>
-std::string Description(RectT<T> r) {
- std::ostringstream os;
- os << "[" << r.x0() << ".." << r.x1() << ")x"
- << "[" << r.y0() << ".." << r.y1() << ")";
- return os.str();
-}
-
-using Rect = RectT<size_t>;
-
// Currently, we abuse Image to either refer to an image that owns its storage
// or one that doesn't. In similar vein, we abuse Image* function parameters to
// either mean "assign to me" or "fill the provided image with data".
diff --git a/third_party/jpeg-xl/lib/jxl/image_bundle.h b/third_party/jpeg-xl/lib/jxl/image_bundle.h
index c8a76a9f59..00f1eb81bd 100644
--- a/third_party/jpeg-xl/lib/jxl/image_bundle.h
+++ b/third_party/jpeg-xl/lib/jxl/image_bundle.h
@@ -9,9 +9,9 @@
// The main image or frame consists of a bundle of associated images.
#include <jxl/cms_interface.h>
-#include <stddef.h>
-#include <stdint.h>
+#include <cstddef>
+#include <cstdint>
#include <memory>
#include <string>
#include <utility>
@@ -19,6 +19,7 @@
#include "lib/jxl/base/common.h"
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/color_encoding_internal.h"
#include "lib/jxl/common.h" // JPEGXL_ENABLE_TRANSCODE_JPEG
diff --git a/third_party/jpeg-xl/lib/jxl/image_metadata.h b/third_party/jpeg-xl/lib/jxl/image_metadata.h
index 2b647cfa30..37b5aedcfa 100644
--- a/third_party/jpeg-xl/lib/jxl/image_metadata.h
+++ b/third_party/jpeg-xl/lib/jxl/image_metadata.h
@@ -17,6 +17,7 @@
#include <vector>
#include "lib/jxl/base/compiler_specific.h"
+#include "lib/jxl/base/matrix_ops.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/color_encoding_internal.h"
#include "lib/jxl/dec_bit_reader.h"
diff --git a/third_party/jpeg-xl/lib/jxl/image_ops.h b/third_party/jpeg-xl/lib/jxl/image_ops.h
index 84cf7dad76..bee4eb56bd 100644
--- a/third_party/jpeg-xl/lib/jxl/image_ops.h
+++ b/third_party/jpeg-xl/lib/jxl/image_ops.h
@@ -14,6 +14,7 @@
#include <limits>
#include "lib/jxl/base/compiler_specific.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/frame_dimensions.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/image_ops_test.cc b/third_party/jpeg-xl/lib/jxl/image_ops_test.cc
index 6b308baab4..0d16864282 100644
--- a/third_party/jpeg-xl/lib/jxl/image_ops_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/image_ops_test.cc
@@ -5,14 +5,14 @@
#include "lib/jxl/image_ops.h"
-#include <stdint.h>
-#include <stdlib.h>
-
+#include <cstdint>
+#include <cstdlib>
#include <cstring>
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/printf_macros.h"
#include "lib/jxl/base/random.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/cache_aligned.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/image_test_utils.h b/third_party/jpeg-xl/lib/jxl/image_test_utils.h
index 7bb146866e..0b8b79a7dd 100644
--- a/third_party/jpeg-xl/lib/jxl/image_test_utils.h
+++ b/third_party/jpeg-xl/lib/jxl/image_test_utils.h
@@ -6,17 +6,15 @@
#ifndef LIB_JXL_IMAGE_TEST_UTILS_H_
#define LIB_JXL_IMAGE_TEST_UTILS_H_
-#include <inttypes.h>
-#include <stddef.h>
-#include <stdint.h>
-
#include <cmath>
+#include <cstddef>
+#include <cstdint>
#include <limits>
#include <sstream>
#include "lib/jxl/base/compiler_specific.h"
-#include "lib/jxl/base/printf_macros.h"
#include "lib/jxl/base/random.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/image.h"
namespace jxl {
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 d7c6c2ad78..d4a5e1d577 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
@@ -88,7 +88,7 @@ Status DetectBlobs(jpeg::JPEGData& jpeg_data) {
// Something is wrong with this marker; does not care.
continue;
}
- if (!have_exif && payload.size() >= sizeof kExifTag &&
+ if (!have_exif && payload.size() > sizeof kExifTag &&
!memcmp(payload.data(), kExifTag, sizeof kExifTag)) {
jpeg_data.app_marker_type[i] = AppMarkerType::kExif;
have_exif = true;
diff --git a/third_party/jpeg-xl/lib/jxl/jxl_test.cc b/third_party/jpeg-xl/lib/jxl/jxl_test.cc
index cf9857f462..be43d5a237 100644
--- a/third_party/jpeg-xl/lib/jxl/jxl_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/jxl_test.cc
@@ -120,7 +120,7 @@ TEST(JxlTest, RoundtripSmallD1) {
{
PackedPixelFile ppf_out;
EXPECT_NEAR(Roundtrip(t.ppf(), {}, {}, pool, &ppf_out), 916, 40);
- EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 0.888);
+ EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 0.92);
}
// With a lower intensity target than the default, the bitrate should be
@@ -179,7 +179,7 @@ TEST(JxlTest, RoundtripResample2MT) {
cparams.AddOption(JXL_ENC_FRAME_SETTING_EFFORT, 3); // kFalcon
PackedPixelFile ppf_out;
- EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool.get(), &ppf_out), 203300,
+ EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool.get(), &ppf_out), 206917,
2000);
EXPECT_SLIGHTLY_BELOW(ComputeDistance2(t.ppf(), ppf_out), 340);
}
@@ -201,7 +201,7 @@ TEST(JxlTest, RoundtripOutOfOrderProcessing) {
cparams.AddOption(JXL_ENC_FRAME_SETTING_EPF, 3);
PackedPixelFile ppf_out;
- EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, &pool, &ppf_out), 27444, 400);
+ EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, &pool, &ppf_out), 26933, 400);
EXPECT_LE(ButteraugliDistance(t.ppf(), ppf_out), 1.35);
}
@@ -221,7 +221,7 @@ TEST(JxlTest, RoundtripOutOfOrderProcessingBorder) {
cparams.AddOption(JXL_ENC_FRAME_SETTING_RESAMPLING, 2);
PackedPixelFile ppf_out;
- EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, &pool, &ppf_out), 10065, 200);
+ EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, &pool, &ppf_out), 9747, 200);
EXPECT_LE(ButteraugliDistance(t.ppf(), ppf_out), 2.9);
}
@@ -236,7 +236,7 @@ TEST(JxlTest, RoundtripResample4) {
cparams.AddOption(JXL_ENC_FRAME_SETTING_RESAMPLING, 4);
PackedPixelFile ppf_out;
- EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 5758, 100);
+ EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 5888, 100);
EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 22);
}
@@ -296,7 +296,7 @@ TEST(JxlTest, RoundtripMultiGroup) {
auto run_kitten = std::async(std::launch::async, test, SpeedTier::kKitten,
1.0f, 63624u, 8.5);
auto run_wombat = std::async(std::launch::async, test, SpeedTier::kWombat,
- 2.0f, 39620u, 15.5);
+ 2.0f, 38536u, 15.7);
}
TEST(JxlTest, RoundtripRGBToGrayscale) {
@@ -505,7 +505,7 @@ TEST(JxlTest, RoundtripSmallNL) {
PackedPixelFile ppf_out;
EXPECT_NEAR(Roundtrip(t.ppf(), {}, {}, pool, &ppf_out), 916, 45);
- EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 0.82);
+ EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 0.92);
}
TEST(JxlTest, RoundtripNoGaborishNoAR) {
@@ -539,7 +539,7 @@ TEST(JxlTest, RoundtripSmallNoGaborish) {
PackedPixelFile ppf_out;
EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 1006, 20);
- EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 1.1);
+ EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 1.2);
}
TEST(JxlTest, RoundtripSmallPatchesAlpha) {
@@ -895,7 +895,7 @@ TEST(JxlTest, RoundtripAlphaPremultiplied) {
ButteraugliDistance(io_nopremul.frames, io2.frames,
ButteraugliParams(), *JxlGetDefaultCms(),
/*distmap=*/nullptr),
- 1.0);
+ 1.1);
}
}
}
@@ -936,7 +936,7 @@ TEST(JxlTest, RoundtripAlphaResamplingOnlyAlpha) {
cparams.AddOption(JXL_ENC_FRAME_SETTING_EXTRA_CHANNEL_RESAMPLING, 2);
PackedPixelFile ppf_out;
- EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 32000, 1000);
+ EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 33179, 1000);
EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 1.52);
}
@@ -1316,8 +1316,13 @@ size_t RoundtripJpeg(const std::vector<uint8_t>& jpeg_in, ThreadPool* pool) {
&compressed));
jxl::JXLDecompressParams dparams;
- test::DefaultAcceptedFormats(dparams);
test::SetThreadParallelRunner(dparams, pool);
+ {
+ std::vector<uint8_t> out;
+ jxl::PackedPixelFile ppf;
+ EXPECT_FALSE(DecodeImageJXL(compressed.data(), compressed.size() - 1,
+ dparams, nullptr, &ppf, &out));
+ }
std::vector<uint8_t> out;
jxl::PackedPixelFile ppf;
EXPECT_TRUE(DecodeImageJXL(compressed.data(), compressed.size(), dparams,
@@ -1504,6 +1509,57 @@ JXL_TRANSCODE_JPEG_TEST(JxlTest, RoundtripJpegRecompressionMetadata) {
EXPECT_NEAR(RoundtripJpeg(orig, pool.get()), 1334u, 100);
}
+JXL_TRANSCODE_JPEG_TEST(JxlTest, RoundtripJpegRecompressionEmptyExif) {
+ ThreadPoolForTests pool(8);
+ const std::vector<uint8_t> orig = {
+ // SOI
+ 0xff, 0xd8, //
+ // APP1
+ 0xff, 0xe1, 0x00, 0x08, 0x45, 0x78, 0x69, 0x66, 0x00, 0x00, //
+ // DQT
+ 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x03, 0x02, //
+ 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x03, 0x03, 0x04, 0x05, //
+ 0x08, 0x05, 0x05, 0x04, 0x04, 0x05, 0x0a, 0x07, 0x07, 0x06, //
+ 0x08, 0x0c, 0x0a, 0x0c, 0x0c, 0x0b, 0x0a, 0x0b, 0x0b, 0x0d, //
+ 0x0e, 0x12, 0x10, 0x0d, 0x0e, 0x11, 0x0e, 0x0b, 0x0b, 0x10, //
+ 0x16, 0x10, 0x11, 0x13, 0x14, 0x15, 0x15, 0x15, 0x0c, 0x0f, //
+ 0x17, 0x18, 0x16, 0x14, 0x18, 0x12, 0x14, 0x15, 0x14, //
+ // SOF
+ 0xff, 0xc0, 0x00, 0x0b, 0x08, 0x00, 0x01, 0x00, 0x01, 0x01, //
+ 0x01, 0x11, 0x00, //
+ // DHT
+ 0xff, 0xc4, 0x00, 0xd2, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, //
+ 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
+ 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, //
+ 0x09, 0x0a, 0x0b, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, //
+ 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, //
+ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, //
+ 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, //
+ 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, //
+ 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, //
+ 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, //
+ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, //
+ 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, //
+ 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, //
+ 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, //
+ 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, //
+ 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, //
+ 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, //
+ 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, //
+ 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, //
+ 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, //
+ 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, //
+ 0xf9, 0xfa, //
+ // SOS
+ 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, //
+ // entropy coded data
+ 0xfc, 0xaa, 0xaf, //
+ // EOI
+ 0xff, 0xd9, //
+ };
+ EXPECT_NEAR(RoundtripJpeg(orig, pool.get()), 466u, 100);
+}
+
JXL_TRANSCODE_JPEG_TEST(JxlTest, RoundtripJpegRecompressionRestarts) {
ThreadPoolForTests pool(8);
const std::vector<uint8_t> orig =
diff --git a/third_party/jpeg-xl/lib/jxl/lehmer_code_test.cc b/third_party/jpeg-xl/lib/jxl/lehmer_code_test.cc
index c7752d8cfc..ba4651430f 100644
--- a/third_party/jpeg-xl/lib/jxl/lehmer_code_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/lehmer_code_test.cc
@@ -5,16 +5,15 @@
#include "lib/jxl/lehmer_code.h"
-#include <stdint.h>
-#include <string.h>
-
-#include <algorithm>
+#include <cstdint>
+#include <cstring>
#include <numeric>
#include <vector>
#include "lib/jxl/base/bits.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/random.h"
+#include "lib/jxl/base/status.h"
#include "lib/jxl/test_utils.h"
#include "lib/jxl/testing.h"
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 df54a9425e..0a71bec24f 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
@@ -6,9 +6,17 @@
#ifndef LIB_JXL_MODULAR_ENCODING_CONTEXT_PREDICT_H_
#define LIB_JXL_MODULAR_ENCODING_CONTEXT_PREDICT_H_
-#include <utility>
+#include <algorithm>
+#include <array>
+#include <cmath>
+#include <cstddef>
+#include <cstdint>
#include <vector>
+#include "lib/jxl/base/bits.h"
+#include "lib/jxl/base/compiler_specific.h"
+#include "lib/jxl/base/status.h"
+#include "lib/jxl/field_encodings.h"
#include "lib/jxl/fields.h"
#include "lib/jxl/image_ops.h"
#include "lib/jxl/modular/modular_image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_debug_tree.cc b/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_debug_tree.cc
index f863823629..04f8812750 100644
--- a/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_debug_tree.cc
+++ b/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_debug_tree.cc
@@ -5,8 +5,7 @@
#include "lib/jxl/modular/encoding/enc_debug_tree.h"
-#include <cinttypes>
-#include <cstdint>
+#include <cinttypes> // PRId64
#include <cstdlib>
#include "lib/jxl/base/os_macros.h"
diff --git a/third_party/jpeg-xl/lib/jxl/modular/options.h b/third_party/jpeg-xl/lib/jxl/modular/options.h
index 6613b513de..5b08236ff2 100644
--- a/third_party/jpeg-xl/lib/jxl/modular/options.h
+++ b/third_party/jpeg-xl/lib/jxl/modular/options.h
@@ -6,9 +6,9 @@
#ifndef LIB_JXL_MODULAR_OPTIONS_H_
#define LIB_JXL_MODULAR_OPTIONS_H_
-#include <stdint.h>
-
#include <array>
+#include <cstddef>
+#include <cstdint>
#include <vector>
#include "lib/jxl/enc_ans_params.h"
diff --git a/third_party/jpeg-xl/lib/jxl/modular/transform/enc_palette.cc b/third_party/jpeg-xl/lib/jxl/modular/transform/enc_palette.cc
index 7f9399d3c4..86d161e891 100644
--- a/third_party/jpeg-xl/lib/jxl/modular/transform/enc_palette.cc
+++ b/third_party/jpeg-xl/lib/jxl/modular/transform/enc_palette.cc
@@ -170,6 +170,7 @@ Status FwdPaletteIteration(Image &input, uint32_t begin_c, uint32_t end_c,
size_t w = input.channel[begin_c].w;
size_t h = input.channel[begin_c].h;
+ if (input.bitdepth >= 32) return false;
if (!lossy && nb_colors < 2) return false;
if (!lossy && nb == 1) {
diff --git a/third_party/jpeg-xl/lib/jxl/modular/transform/palette.cc b/third_party/jpeg-xl/lib/jxl/modular/transform/palette.cc
index 1ab499ccf6..7726fd8ff3 100644
--- a/third_party/jpeg-xl/lib/jxl/modular/transform/palette.cc
+++ b/third_party/jpeg-xl/lib/jxl/modular/transform/palette.cc
@@ -5,6 +5,10 @@
#include "lib/jxl/modular/transform/palette.h"
+#include <atomic>
+
+#include "lib/jxl/modular/transform/transform.h" // CheckEqualChannels
+
namespace jxl {
Status InvPalette(Image &input, uint32_t begin_c, uint32_t nb_colors,
diff --git a/third_party/jpeg-xl/lib/jxl/modular/transform/palette.h b/third_party/jpeg-xl/lib/jxl/modular/transform/palette.h
index 2a9e5c71f4..ee51d4c556 100644
--- a/third_party/jpeg-xl/lib/jxl/modular/transform/palette.h
+++ b/third_party/jpeg-xl/lib/jxl/modular/transform/palette.h
@@ -6,13 +6,17 @@
#ifndef LIB_JXL_MODULAR_TRANSFORM_PALETTE_H_
#define LIB_JXL_MODULAR_TRANSFORM_PALETTE_H_
-#include <atomic>
+#include <algorithm>
+#include <array>
+#include <cstddef>
+#include <cstdint>
+#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/modular/encoding/context_predict.h"
#include "lib/jxl/modular/modular_image.h"
-#include "lib/jxl/modular/transform/transform.h" // CheckEqualChannels
+#include "lib/jxl/modular/options.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/modular/transform/squeeze.h b/third_party/jpeg-xl/lib/jxl/modular/transform/squeeze.h
index f0333da6fd..f56d6dd7e9 100644
--- a/third_party/jpeg-xl/lib/jxl/modular/transform/squeeze.h
+++ b/third_party/jpeg-xl/lib/jxl/modular/transform/squeeze.h
@@ -23,9 +23,11 @@
// wavelet transform", IEEE Transactions on Image Processing, vol. 1, no. 2, pp.
// 205-220, April 1992, doi: 10.1109/83.136597.
-#include <stdlib.h>
+#include <cstdlib>
+#include <vector>
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/status.h"
#include "lib/jxl/modular/modular_image.h"
#include "lib/jxl/modular/transform/transform.h"
diff --git a/third_party/jpeg-xl/lib/jxl/modular/transform/transform.cc b/third_party/jpeg-xl/lib/jxl/modular/transform/transform.cc
index a609cfb3fb..05a18215d1 100644
--- a/third_party/jpeg-xl/lib/jxl/modular/transform/transform.cc
+++ b/third_party/jpeg-xl/lib/jxl/modular/transform/transform.cc
@@ -5,7 +5,7 @@
#include "lib/jxl/modular/transform/transform.h"
-#include <cinttypes>
+#include <cinttypes> // PRIu32
#include "lib/jxl/base/printf_macros.h"
#include "lib/jxl/fields.h"
diff --git a/third_party/jpeg-xl/lib/jxl/modular/transform/transform.h b/third_party/jpeg-xl/lib/jxl/modular/transform/transform.h
index 70c383834a..cb46d0888f 100644
--- a/third_party/jpeg-xl/lib/jxl/modular/transform/transform.h
+++ b/third_party/jpeg-xl/lib/jxl/modular/transform/transform.h
@@ -6,13 +6,17 @@
#ifndef LIB_JXL_MODULAR_TRANSFORM_TRANSFORM_H_
#define LIB_JXL_MODULAR_TRANSFORM_TRANSFORM_H_
+#include <cstddef>
#include <cstdint>
-#include <string>
#include <vector>
+#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/status.h"
+#include "lib/jxl/field_encodings.h"
#include "lib/jxl/fields.h"
#include "lib/jxl/modular/encoding/context_predict.h"
+#include "lib/jxl/modular/modular_image.h"
#include "lib/jxl/modular/options.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/opsin_image_test.cc b/third_party/jpeg-xl/lib/jxl/opsin_image_test.cc
index b8ea839b9e..dff257f9bc 100644
--- a/third_party/jpeg-xl/lib/jxl/opsin_image_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/opsin_image_test.cc
@@ -10,6 +10,8 @@
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/matrix_ops.h"
+#include "lib/jxl/base/rect.h"
+#include "lib/jxl/base/status.h"
#include "lib/jxl/cms/opsin_params.h"
#include "lib/jxl/dec_xyb.h"
#include "lib/jxl/enc_xyb.h"
diff --git a/third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc b/third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc
index b8f9aa13df..4407658ddf 100644
--- a/third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc
@@ -8,6 +8,8 @@
#include <utility>
#include "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/base/rect.h"
+#include "lib/jxl/base/status.h"
#include "lib/jxl/codec_in_out.h"
#include "lib/jxl/color_encoding_internal.h"
#include "lib/jxl/dec_xyb.h"
diff --git a/third_party/jpeg-xl/lib/jxl/passes_test.cc b/third_party/jpeg-xl/lib/jxl/passes_test.cc
index e7a7547a0c..a525987018 100644
--- a/third_party/jpeg-xl/lib/jxl/passes_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/passes_test.cc
@@ -4,8 +4,8 @@
// license that can be found in the LICENSE file.
#include <jxl/cms.h>
-#include <stddef.h>
+#include <cstddef>
#include <cstdint>
#include <future>
#include <string>
@@ -16,6 +16,7 @@
#include "lib/extras/dec/jxl.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/override.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/span.h"
#include "lib/jxl/enc_params.h"
#include "lib/jxl/image.h"
@@ -51,7 +52,7 @@ TEST(PassesTest, RoundtripSmallPasses) {
ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(),
*JxlGetDefaultCms(),
/*distmap=*/nullptr),
- 0.8222);
+ 1.0);
}
TEST(PassesTest, RoundtripUnalignedPasses) {
diff --git a/third_party/jpeg-xl/lib/jxl/preview_test.cc b/third_party/jpeg-xl/lib/jxl/preview_test.cc
index c482db9fd8..fab8943e10 100644
--- a/third_party/jpeg-xl/lib/jxl/preview_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/preview_test.cc
@@ -12,7 +12,9 @@
#include "lib/extras/codec.h"
#include "lib/jxl/base/span.h"
+#include "lib/jxl/base/status.h"
#include "lib/jxl/codec_in_out.h"
+#include "lib/jxl/common.h"
#include "lib/jxl/enc_params.h"
#include "lib/jxl/headers.h"
#include "lib/jxl/image_bundle.h"
diff --git a/third_party/jpeg-xl/lib/jxl/quant_weights.h b/third_party/jpeg-xl/lib/jxl/quant_weights.h
index 0fa23ffddb..8192f71443 100644
--- a/third_party/jpeg-xl/lib/jxl/quant_weights.h
+++ b/third_party/jpeg-xl/lib/jxl/quant_weights.h
@@ -11,16 +11,14 @@
#include <array>
#include <hwy/aligned_allocator.h>
-#include <utility>
#include <vector>
#include "lib/jxl/ac_strategy.h"
#include "lib/jxl/base/common.h"
#include "lib/jxl/base/compiler_specific.h"
-#include "lib/jxl/base/span.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_bit_reader.h"
-#include "lib/jxl/image.h"
+#include "lib/jxl/frame_dimensions.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/quant_weights_test.cc b/third_party/jpeg-xl/lib/jxl/quant_weights_test.cc
index 776a1c776d..61c812d620 100644
--- a/third_party/jpeg-xl/lib/jxl/quant_weights_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/quant_weights_test.cc
@@ -10,14 +10,21 @@
#include <cmath>
#include <hwy/base.h> // HWY_ALIGN_MAX
#include <hwy/tests/hwy_gtest.h>
+#include <iterator>
#include <numeric>
+#include <vector>
+#include "lib/jxl/ac_strategy.h"
#include "lib/jxl/base/random.h"
+#include "lib/jxl/base/status.h"
#include "lib/jxl/dct_for_test.h"
#include "lib/jxl/dec_transforms_testonly.h"
#include "lib/jxl/enc_modular.h"
+#include "lib/jxl/enc_params.h"
#include "lib/jxl/enc_quant_weights.h"
#include "lib/jxl/enc_transforms.h"
+#include "lib/jxl/frame_header.h"
+#include "lib/jxl/image_metadata.h"
#include "lib/jxl/testing.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/quantizer.cc b/third_party/jpeg-xl/lib/jxl/quantizer.cc
index b9ea43e0d6..f63c6a589d 100644
--- a/third_party/jpeg-xl/lib/jxl/quantizer.cc
+++ b/third_party/jpeg-xl/lib/jxl/quantizer.cc
@@ -5,11 +5,11 @@
#include "lib/jxl/quantizer.h"
-#include <string.h>
-
#include <algorithm>
+#include <cstring>
#include "lib/jxl/base/compiler_specific.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/field_encodings.h"
#include "lib/jxl/fields.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/quantizer.h b/third_party/jpeg-xl/lib/jxl/quantizer.h
index 602d12bdfa..b61c8acde6 100644
--- a/third_party/jpeg-xl/lib/jxl/quantizer.h
+++ b/third_party/jpeg-xl/lib/jxl/quantizer.h
@@ -6,21 +6,17 @@
#ifndef LIB_JXL_QUANTIZER_H_
#define LIB_JXL_QUANTIZER_H_
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-
#include <algorithm>
#include <cmath>
-#include <utility>
-#include <vector>
+#include <cstddef>
+#include <cstdint>
+#include <cstdlib>
-#include "lib/jxl/ac_strategy.h"
-#include "lib/jxl/base/bits.h"
#include "lib/jxl/base/compiler_specific.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
-#include "lib/jxl/dct_util.h"
#include "lib/jxl/dec_bit_reader.h"
+#include "lib/jxl/field_encodings.h"
#include "lib/jxl/fields.h"
#include "lib/jxl/image.h"
#include "lib/jxl/quant_weights.h"
diff --git a/third_party/jpeg-xl/lib/jxl/quantizer_test.cc b/third_party/jpeg-xl/lib/jxl/quantizer_test.cc
index eeaac9ba53..5b965b78ca 100644
--- a/third_party/jpeg-xl/lib/jxl/quantizer_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/quantizer_test.cc
@@ -5,9 +5,17 @@
#include "lib/jxl/quantizer.h"
+#include <cstddef>
+#include <cstdint>
+
+#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_bit_reader.h"
+#include "lib/jxl/enc_bit_writer.h"
#include "lib/jxl/enc_fields.h"
+#include "lib/jxl/fields.h"
+#include "lib/jxl/image.h"
#include "lib/jxl/image_test_utils.h"
+#include "lib/jxl/quant_weights.h"
#include "lib/jxl/testing.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.cc
index 27718e6413..f95237dea5 100644
--- a/third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.cc
+++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.cc
@@ -6,9 +6,16 @@
#include "lib/jxl/render_pipeline/low_memory_render_pipeline.h"
#include <algorithm>
+#include <cstddef>
+#include <cstdint>
+#include <utility>
+#include <vector>
#include "lib/jxl/base/arch_macros.h"
+#include "lib/jxl/base/common.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
+#include "lib/jxl/image.h"
#include "lib/jxl/image_ops.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.h b/third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.h
index f0b21d3dca..5f88a34b5e 100644
--- a/third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.h
+++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.h
@@ -6,9 +6,16 @@
#ifndef LIB_JXL_RENDER_PIPELINE_LOW_MEMORY_RENDER_PIPELINE_H_
#define LIB_JXL_RENDER_PIPELINE_LOW_MEMORY_RENDER_PIPELINE_H_
-#include <stdint.h>
+#include <cstddef>
+#include <cstdint>
+#include <utility>
+#include <vector>
+#include "lib/jxl/base/rect.h"
+#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_group_border.h"
+#include "lib/jxl/frame_header.h"
+#include "lib/jxl/image.h"
#include "lib/jxl/render_pipeline/render_pipeline.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.cc
index 09e3dbab76..ed27a2efa0 100644
--- a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.cc
+++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.cc
@@ -5,6 +5,10 @@
#include "lib/jxl/render_pipeline/render_pipeline.h"
+#include <memory>
+#include <utility>
+
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/render_pipeline/low_memory_render_pipeline.h"
#include "lib/jxl/render_pipeline/simple_render_pipeline.h"
diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.h b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.h
index c61420be4b..fa7a1e58c4 100644
--- a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.h
+++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.h
@@ -6,8 +6,16 @@
#ifndef LIB_JXL_RENDER_PIPELINE_RENDER_PIPELINE_H_
#define LIB_JXL_RENDER_PIPELINE_RENDER_PIPELINE_H_
-#include <stdint.h>
-
+#include <algorithm>
+#include <cstddef>
+#include <cstdint>
+#include <memory>
+#include <utility>
+#include <vector>
+
+#include "lib/jxl/base/rect.h"
+#include "lib/jxl/base/status.h"
+#include "lib/jxl/frame_dimensions.h"
#include "lib/jxl/image.h"
#include "lib/jxl/render_pipeline/render_pipeline_stage.h"
diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_stage.h b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_stage.h
index d054027ba7..3c9b83addd 100644
--- a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_stage.h
+++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_stage.h
@@ -6,7 +6,9 @@
#ifndef LIB_JXL_RENDER_PIPELINE_RENDER_PIPELINE_STAGE_H_
#define LIB_JXL_RENDER_PIPELINE_RENDER_PIPELINE_STAGE_H_
-#include <stdint.h>
+#include <cstddef>
+#include <utility>
+#include <vector>
#include "lib/jxl/base/arch_macros.h"
#include "lib/jxl/base/status.h"
diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_test.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_test.cc
index e9cb913983..f5d7635206 100644
--- a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_test.cc
@@ -247,7 +247,7 @@ TEST_P(RenderPipelineTestParam, PipelineTest) {
ASSERT_EQ(io_default.frames.size(), io_slow_pipeline.frames.size());
for (size_t i = 0; i < io_default.frames.size(); i++) {
#if JXL_HIGH_PRECISION
- constexpr float kMaxError = 5e-5;
+ constexpr float kMaxError = 2e-4;
#else
constexpr float kMaxError = 5e-4;
#endif
diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.cc
index 77ddb3d430..88cc04ed0c 100644
--- a/third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.cc
+++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.cc
@@ -5,8 +5,14 @@
#include "lib/jxl/render_pipeline/simple_render_pipeline.h"
+#include <algorithm>
+#include <cstddef>
+#include <cstdint>
#include <hwy/base.h>
+#include <utility>
+#include <vector>
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/image_ops.h"
#include "lib/jxl/render_pipeline/render_pipeline_stage.h"
diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.h b/third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.h
index 1240b9fa46..4fd81755f3 100644
--- a/third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.h
+++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.h
@@ -6,8 +6,13 @@
#ifndef LIB_JXL_RENDER_PIPELINE_SIMPLE_RENDER_PIPELINE_H_
#define LIB_JXL_RENDER_PIPELINE_SIMPLE_RENDER_PIPELINE_H_
-#include <stdint.h>
+#include <cstddef>
+#include <utility>
+#include <vector>
+#include "lib/jxl/base/rect.h"
+#include "lib/jxl/base/status.h"
+#include "lib/jxl/image.h"
#include "lib/jxl/render_pipeline/render_pipeline.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_noise.h b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_noise.h
index bd7797f991..ebdc9be992 100644
--- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_noise.h
+++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_noise.h
@@ -5,15 +5,12 @@
#ifndef LIB_JXL_RENDER_PIPELINE_STAGE_NOISE_H_
#define LIB_JXL_RENDER_PIPELINE_STAGE_NOISE_H_
-#include <math.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <algorithm>
-#include <utility>
-#include <vector>
+#include <cstddef>
+#include <memory>
-#include "lib/jxl/dec_noise.h"
+#include "lib/jxl/chroma_from_luma.h"
+#include "lib/jxl/noise.h"
#include "lib/jxl/render_pipeline/render_pipeline_stage.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_splines.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_splines.cc
index 92a13090a7..9473ff3dbe 100644
--- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_splines.cc
+++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_splines.cc
@@ -5,11 +5,19 @@
#include "lib/jxl/render_pipeline/stage_splines.h"
+#include <cstddef>
+#include <memory>
+
#undef HWY_TARGET_INCLUDE
#define HWY_TARGET_INCLUDE "lib/jxl/render_pipeline/stage_splines.cc"
#include <hwy/foreach_target.h>
#include <hwy/highway.h>
+#include "lib/jxl/base/rect.h"
+#include "lib/jxl/base/status.h"
+#include "lib/jxl/render_pipeline/render_pipeline_stage.h"
+#include "lib/jxl/splines.h"
+
HWY_BEFORE_NAMESPACE();
namespace jxl {
namespace HWY_NAMESPACE {
diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_write.h b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_write.h
index ba2c51ee97..32e5fba932 100644
--- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_write.h
+++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_write.h
@@ -6,11 +6,15 @@
#ifndef LIB_JXL_RENDER_PIPELINE_STAGE_WRITE_H_
#define LIB_JXL_RENDER_PIPELINE_STAGE_WRITE_H_
-#include <functional>
+#include <cstddef>
+#include <memory>
+#include <vector>
#include "lib/jxl/dec_cache.h"
#include "lib/jxl/dec_xyb.h"
+#include "lib/jxl/image.h"
#include "lib/jxl/image_bundle.h"
+#include "lib/jxl/image_metadata.h"
#include "lib/jxl/render_pipeline/render_pipeline_stage.h"
namespace jxl {
diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/test_render_pipeline_stages.h b/third_party/jpeg-xl/lib/jxl/render_pipeline/test_render_pipeline_stages.h
index c2c25c46c3..54d40671d6 100644
--- a/third_party/jpeg-xl/lib/jxl/render_pipeline/test_render_pipeline_stages.h
+++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/test_render_pipeline_stages.h
@@ -3,9 +3,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#include <math.h>
-#include <stdint.h>
-#include <stdio.h>
+#include <cmath>
+#include <cstdint>
+#include <cstdio>
#include "lib/jxl/base/status.h"
#include "lib/jxl/render_pipeline/render_pipeline_stage.h"
diff --git a/third_party/jpeg-xl/lib/jxl/roundtrip_test.cc b/third_party/jpeg-xl/lib/jxl/roundtrip_test.cc
index 07e43e4ddf..fa23956995 100644
--- a/third_party/jpeg-xl/lib/jxl/roundtrip_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/roundtrip_test.cc
@@ -23,6 +23,7 @@
#include "lib/extras/codec.h"
#include "lib/jxl/base/common.h"
#include "lib/jxl/base/span.h"
+#include "lib/jxl/base/status.h"
#include "lib/jxl/butteraugli/butteraugli.h"
#include "lib/jxl/color_encoding_internal.h"
#include "lib/jxl/dec_bit_reader.h"
@@ -432,7 +433,7 @@ void VerifyRoundtripCompression(
float butteraugli_score = ButteraugliDistance(
original_io.frames, decoded_io.frames, ba, *JxlGetDefaultCms(),
/*distmap=*/nullptr, nullptr);
- float target_score = 1.3f;
+ float target_score = 1.4f;
// upsampling mode 1 (unlike default and NN) does not downscale back to the
// already downsampled image
if (upsampling_mode == 1 && resampling >= 4 && already_downsampled)
diff --git a/third_party/jpeg-xl/lib/jxl/sanitizers.h b/third_party/jpeg-xl/lib/jxl/sanitizers.h
index bb133e9203..e05f79737b 100644
--- a/third_party/jpeg-xl/lib/jxl/sanitizers.h
+++ b/third_party/jpeg-xl/lib/jxl/sanitizers.h
@@ -6,20 +6,20 @@
#ifndef LIB_JXL_SANITIZERS_H_
#define LIB_JXL_SANITIZERS_H_
-#include <stddef.h>
+#include <cstddef>
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/sanitizer_definitions.h"
#include "lib/jxl/image.h"
#if JXL_MEMORY_SANITIZER
-#include <inttypes.h>
-#include <stdio.h>
-
#include <algorithm>
+#include <cinttypes> // PRId64
+#include <cstdio>
#include <string>
#include <vector>
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "sanitizer/msan_interface.h"
#endif
diff --git a/third_party/jpeg-xl/lib/jxl/speed_tier_test.cc b/third_party/jpeg-xl/lib/jxl/speed_tier_test.cc
index 8783faec8f..aefbbc559e 100644
--- a/third_party/jpeg-xl/lib/jxl/speed_tier_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/speed_tier_test.cc
@@ -15,7 +15,7 @@
#include "lib/extras/dec/jxl.h"
#include "lib/extras/enc/jxl.h"
-#include "lib/jxl/enc_params.h"
+#include "lib/jxl/common.h"
#include "lib/jxl/test_image.h"
#include "lib/jxl/test_utils.h"
#include "lib/jxl/testing.h"
diff --git a/third_party/jpeg-xl/lib/jxl/splines.cc b/third_party/jpeg-xl/lib/jxl/splines.cc
index 2df2160d76..fd68c15493 100644
--- a/third_party/jpeg-xl/lib/jxl/splines.cc
+++ b/third_party/jpeg-xl/lib/jxl/splines.cc
@@ -6,12 +6,13 @@
#include "lib/jxl/splines.h"
#include <algorithm>
-#include <cinttypes>
+#include <cinttypes> // PRIu64
#include <cmath>
#include <limits>
#include "lib/jxl/base/common.h"
#include "lib/jxl/base/printf_macros.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/chroma_from_luma.h"
#include "lib/jxl/common.h" // JXL_HIGH_PRECISION
diff --git a/third_party/jpeg-xl/lib/jxl/splines.h b/third_party/jpeg-xl/lib/jxl/splines.h
index af51ec937e..b292d6952b 100644
--- a/third_party/jpeg-xl/lib/jxl/splines.h
+++ b/third_party/jpeg-xl/lib/jxl/splines.h
@@ -14,6 +14,7 @@
#include <vector>
#include "lib/jxl/base/compiler_specific.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/chroma_from_luma.h"
#include "lib/jxl/image.h"
diff --git a/third_party/jpeg-xl/lib/jxl/splines_gbench.cc b/third_party/jpeg-xl/lib/jxl/splines_gbench.cc
index 903c5b6328..95f890e3ce 100644
--- a/third_party/jpeg-xl/lib/jxl/splines_gbench.cc
+++ b/third_party/jpeg-xl/lib/jxl/splines_gbench.cc
@@ -3,9 +3,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#include <array>
+#include <cstddef>
+#include <vector>
#include "benchmark/benchmark.h"
+#include "lib/jxl/base/rect.h"
+#include "lib/jxl/chroma_from_luma.h"
#include "lib/jxl/image_ops.h"
#include "lib/jxl/splines.h"
diff --git a/third_party/jpeg-xl/lib/jxl/splines_test.cc b/third_party/jpeg-xl/lib/jxl/splines_test.cc
index 83cc524234..56f2344b4a 100644
--- a/third_party/jpeg-xl/lib/jxl/splines_test.cc
+++ b/third_party/jpeg-xl/lib/jxl/splines_test.cc
@@ -18,6 +18,7 @@
#include "lib/jxl/base/common.h"
#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/printf_macros.h"
+#include "lib/jxl/base/rect.h"
#include "lib/jxl/base/span.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/chroma_from_luma.h"
diff --git a/third_party/jpeg-xl/lib/jxl/test_image.cc b/third_party/jpeg-xl/lib/jxl/test_image.cc
index d2e17c6ab0..eab5ccca14 100644
--- a/third_party/jpeg-xl/lib/jxl/test_image.cc
+++ b/third_party/jpeg-xl/lib/jxl/test_image.cc
@@ -8,8 +8,11 @@
#include <jxl/encode.h>
#include <algorithm>
+#include <cstddef>
+#include <cstdint>
#include <cstring>
#include <utility>
+#include <vector>
#include "lib/extras/dec/color_description.h"
#include "lib/extras/dec/color_hints.h"
diff --git a/third_party/jpeg-xl/lib/jxl/test_image.h b/third_party/jpeg-xl/lib/jxl/test_image.h
index 13d0806ec8..ae62047052 100644
--- a/third_party/jpeg-xl/lib/jxl/test_image.h
+++ b/third_party/jpeg-xl/lib/jxl/test_image.h
@@ -8,14 +8,13 @@
#include <jxl/codestream_header.h>
#include <jxl/types.h>
-#include <stddef.h>
+#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>
#include "lib/extras/packed_image.h"
-#include "lib/jxl/base/span.h"
namespace jxl {
namespace test {
diff --git a/third_party/jpeg-xl/lib/jxl/test_utils.h b/third_party/jpeg-xl/lib/jxl/test_utils.h
index dc50490174..0d0d8004c1 100644
--- a/third_party/jpeg-xl/lib/jxl/test_utils.h
+++ b/third_party/jpeg-xl/lib/jxl/test_utils.h
@@ -21,6 +21,7 @@
#include "lib/extras/dec/jxl.h"
#include "lib/extras/enc/jxl.h"
#include "lib/extras/packed_image.h"
+#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/data_parallel.h"
#include "lib/jxl/base/span.h"
#include "lib/jxl/base/status.h"
@@ -210,4 +211,15 @@ bool operator!=(const jxl::Bytes& a, const jxl::Bytes& b);
} // namespace jxl
+#if !defined(FUZZ_TEST)
+struct FuzzTestSink {
+ template <typename F>
+ FuzzTestSink WithSeeds(F) {
+ return *this;
+ }
+};
+#define FUZZ_TEST(A, B) \
+ const JXL_MAYBE_UNUSED FuzzTestSink unused##A##B = FuzzTestSink()
+#endif
+
#endif // LIB_JXL_TEST_UTILS_H_
diff --git a/third_party/jpeg-xl/lib/jxl/xorshift128plus-inl.h b/third_party/jpeg-xl/lib/jxl/xorshift128plus-inl.h
index a473d591f2..f7967655df 100644
--- a/third_party/jpeg-xl/lib/jxl/xorshift128plus-inl.h
+++ b/third_party/jpeg-xl/lib/jxl/xorshift128plus-inl.h
@@ -12,8 +12,8 @@
#define LIB_JXL_XORSHIFT128PLUS_INL_H_
#endif
-#include <stddef.h>
-
+#include <cstddef>
+#include <cstdint>
#include <hwy/highway.h>
HWY_BEFORE_NAMESPACE();
namespace jxl {