/src/libjxl/lib/jxl/base/common.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) the JPEG XL Project Authors. All rights reserved. |
2 | | // |
3 | | // Use of this source code is governed by a BSD-style |
4 | | // license that can be found in the LICENSE file. |
5 | | |
6 | | #ifndef LIB_JXL_BASE_COMMON_H_ |
7 | | #define LIB_JXL_BASE_COMMON_H_ |
8 | | |
9 | | // Shared constants and helper functions. |
10 | | |
11 | | #include <array> |
12 | | #include <cstddef> |
13 | | #include <cstdint> |
14 | | #include <cstdio> |
15 | | #include <memory> |
16 | | #include <string> |
17 | | #include <type_traits> |
18 | | |
19 | | #include "lib/jxl/base/compiler_specific.h" |
20 | | |
21 | | namespace jxl { |
22 | | // Some enums and typedefs used by more than one header file. |
23 | | |
24 | | constexpr size_t kBitsPerByte = 8; // more clear than CHAR_BIT |
25 | | |
26 | 1.19k | constexpr inline size_t RoundUpBitsToByteMultiple(size_t bits) { |
27 | 1.19k | return (bits + 7) & ~static_cast<size_t>(7); |
28 | 1.19k | } |
29 | | |
30 | 952 | constexpr inline size_t RoundUpToBlockDim(size_t dim) { |
31 | 952 | return (dim + 7) & ~static_cast<size_t>(7); |
32 | 952 | } |
33 | | |
34 | | static inline bool JXL_MAYBE_UNUSED SafeAdd(const uint64_t a, const uint64_t b, |
35 | 913k | uint64_t& sum) { |
36 | 913k | sum = a + b; |
37 | 913k | return sum >= a; // no need to check b - either sum >= both or < both. |
38 | 913k | } Unexecuted instantiation: djxl_fuzzer.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: decode.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) fields.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Line | Count | Source | 35 | 913k | uint64_t& sum) { | 36 | 913k | sum = a + b; | 37 | 913k | return sum >= a; // no need to check b - either sum >= both or < both. | 38 | 913k | } |
Unexecuted instantiation: frame_header.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: headers.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: icc_codec.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: icc_codec_common.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: image_metadata.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: loop_filter.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: memory_manager_internal.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: encoding.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: modular_image.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: transform.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: quant_weights.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: quantizer.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: decode_to_jpeg.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: dec_jpeg_data.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: dec_jpeg_data_writer.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: jpeg_data.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: color_encoding_internal.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: dec_ans.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: dec_context_map.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: dec_frame.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: dec_group.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: dec_huffman.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: dec_modular.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: dec_noise.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: dec_patch_dictionary.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: dec_xyb.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: entropy_coder.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: epf.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: huffman_table.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: image.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: dec_ma.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: palette.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: rct.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: squeeze.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: opsin_params.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: passes_state.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: render_pipeline.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: simple_render_pipeline.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: stage_upsampling.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: splines.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: toc.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: ac_strategy.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: ans_common.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: blending.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: chroma_from_luma.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: coeff_order.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: compressed_dc.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: dec_cache.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: low_memory_render_pipeline.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: stage_blending.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: stage_chroma_upsampling.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: stage_cms.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: stage_epf.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: stage_from_linear.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: stage_gaborish.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: stage_noise.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: stage_patches.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: stage_splines.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: stage_spot.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: stage_to_linear.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: stage_tone_mapping.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: stage_write.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: stage_xyb.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: stage_ycbcr.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: dec_group_border.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: image_bundle.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: tracking_memory_manager.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: streaming_fuzzer.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: encode.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_jpeg_data.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_jpeg_data_reader.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_jpeg_huffman_decode.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: luminance.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_aux_out.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_bit_writer.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_fast_lossless.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_fields.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_frame.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_group.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_heuristics.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_icc_codec.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_modular.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_noise.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_patch_dictionary.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_photon_noise.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_progressive_split.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_quant_weights.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_splines.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_toc.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_xyb.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_encoding.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_ma.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_transform.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: dec_external_image.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: image_ops.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: butteraugli.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_ac_strategy.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_adaptive_quantization.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_ans.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_butteraugli_comparator.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_cache.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_chroma_from_luma.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_cluster.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_coeff_order.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_context_map.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_debug_image.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_dot_dictionary.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_entropy_coder.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_external_image.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_gaborish.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_huffman.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_huffman_tree.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_image_bundle.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_palette.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_rct.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_squeeze.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: convolve_separable5.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: convolve_slow.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: convolve_symmetric5.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_detect_dots.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_linalg.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: jxl_cms.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: color_encoding_fuzzer.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: color_description.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: rans_fuzzer.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: set_from_bytes_fuzzer.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: codec.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: packed_image_convert.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: apng.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: exr.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: jpg.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: jxl.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: pgx.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: pnm.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: gif.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: common.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: color_hints.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: mmap.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: npy.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: decode_basic_info_fuzzer.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: cjxl_fuzzer.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: test_image.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: test_utils.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: metrics.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: enc_comparator.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: decode_scan.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: huffman.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: render.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: idct.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: transforms_fuzzer.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: fields_fuzzer.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) Unexecuted instantiation: icc_codec_fuzzer.cc:jxl::SafeAdd(unsigned long, unsigned long, unsigned long&) |
39 | | |
40 | | template <typename T1, typename T2> |
41 | 137M | constexpr inline T1 DivCeil(T1 a, T2 b) { |
42 | 137M | return (a + b - 1) / b; |
43 | 137M | } unsigned long jxl::DivCeil<unsigned long, unsigned long>(unsigned long, unsigned long) Line | Count | Source | 41 | 127M | constexpr inline T1 DivCeil(T1 a, T2 b) { | 42 | 127M | return (a + b - 1) / b; | 43 | 127M | } |
unsigned long jxl::DivCeil<unsigned long, int>(unsigned long, int) Line | Count | Source | 41 | 9.09M | constexpr inline T1 DivCeil(T1 a, T2 b) { | 42 | 9.09M | return (a + b - 1) / b; | 43 | 9.09M | } |
int jxl::DivCeil<int, int>(int, int) Line | Count | Source | 41 | 596k | constexpr inline T1 DivCeil(T1 a, T2 b) { | 42 | 596k | return (a + b - 1) / b; | 43 | 596k | } |
unsigned long jxl::DivCeil<unsigned long, long>(unsigned long, long) Line | Count | Source | 41 | 450k | constexpr inline T1 DivCeil(T1 a, T2 b) { | 42 | 450k | return (a + b - 1) / b; | 43 | 450k | } |
|
44 | | |
45 | | // Works for any `align`; if a power of two, compiler emits ADD+AND. |
46 | 60.4M | constexpr inline size_t RoundUpTo(size_t what, size_t align) { |
47 | 60.4M | return DivCeil(what, align) * align; |
48 | 60.4M | } |
49 | | |
50 | | constexpr double kPi = 3.14159265358979323846264338327950288; |
51 | | |
52 | | // Reasonable default for sRGB, matches common monitors. We map white to this |
53 | | // many nits (cd/m^2) by default. Butteraugli was tuned for 250 nits, which is |
54 | | // very close. |
55 | | // NB: This constant is not very "base", but it is shared between modules. |
56 | | static constexpr float kDefaultIntensityTarget = 255; |
57 | | |
58 | | template <typename T> |
59 | | constexpr T Pi(T multiplier) { |
60 | | return static_cast<T>(multiplier * kPi); |
61 | | } |
62 | | |
63 | | // Prior to C++14 (i.e. C++11): provide our own make_unique |
64 | | #if __cplusplus < 201402L |
65 | | template <typename T, typename... Args> |
66 | | std::unique_ptr<T> make_unique(Args&&... args) { |
67 | | return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); |
68 | | } |
69 | | #else |
70 | | using std::make_unique; |
71 | | #endif |
72 | | |
73 | | typedef std::array<float, 3> Color; |
74 | | |
75 | | // Backported std::experimental::to_array |
76 | | |
77 | | template <typename T> |
78 | | using remove_cv_t = typename std::remove_cv<T>::type; |
79 | | |
80 | | template <size_t... I> |
81 | | struct index_sequence {}; |
82 | | |
83 | | template <size_t N, size_t... I> |
84 | | struct make_index_sequence : make_index_sequence<N - 1, N - 1, I...> {}; |
85 | | |
86 | | template <size_t... I> |
87 | | struct make_index_sequence<0, I...> : index_sequence<I...> {}; |
88 | | |
89 | | namespace detail { |
90 | | |
91 | | template <typename T, size_t N, size_t... I> |
92 | | constexpr auto to_array(T (&&arr)[N], index_sequence<I...> _) |
93 | 0 | -> std::array<remove_cv_t<T>, N> { |
94 | 0 | return {{std::move(arr[I])...}}; |
95 | 0 | } Unexecuted instantiation: std::__1::array<std::__1::remove_cv<int>::type, 17ul> jxl::detail::to_array<int, 17ul, 0ul, 1ul, 2ul, 3ul, 4ul, 5ul, 6ul, 7ul, 8ul, 9ul, 10ul, 11ul, 12ul, 13ul, 14ul, 15ul, 16ul>(int (&&) [17ul], jxl::index_sequence<0ul, 1ul, 2ul, 3ul, 4ul, 5ul, 6ul, 7ul, 8ul, 9ul, 10ul, 11ul, 12ul, 13ul, 14ul, 15ul, 16ul>) Unexecuted instantiation: color_description.cc:std::__1::array<std::__1::remove_cv<jxl::(anonymous namespace)::EnumName<JxlColorSpace> >::type, 4ul> jxl::detail::to_array<jxl::(anonymous namespace)::EnumName<JxlColorSpace>, 4ul, 0ul, 1ul, 2ul, 3ul>(jxl::(anonymous namespace)::EnumName<JxlColorSpace> (&&) [4ul], jxl::index_sequence<0ul, 1ul, 2ul, 3ul>) Unexecuted instantiation: color_description.cc:std::__1::array<std::__1::remove_cv<jxl::(anonymous namespace)::EnumName<JxlWhitePoint> >::type, 4ul> jxl::detail::to_array<jxl::(anonymous namespace)::EnumName<JxlWhitePoint>, 4ul, 0ul, 1ul, 2ul, 3ul>(jxl::(anonymous namespace)::EnumName<JxlWhitePoint> (&&) [4ul], jxl::index_sequence<0ul, 1ul, 2ul, 3ul>) Unexecuted instantiation: color_description.cc:std::__1::array<std::__1::remove_cv<jxl::(anonymous namespace)::EnumName<JxlPrimaries> >::type, 4ul> jxl::detail::to_array<jxl::(anonymous namespace)::EnumName<JxlPrimaries>, 4ul, 0ul, 1ul, 2ul, 3ul>(jxl::(anonymous namespace)::EnumName<JxlPrimaries> (&&) [4ul], jxl::index_sequence<0ul, 1ul, 2ul, 3ul>) Unexecuted instantiation: color_description.cc:std::__1::array<std::__1::remove_cv<jxl::(anonymous namespace)::EnumName<JxlTransferFunction> >::type, 8ul> jxl::detail::to_array<jxl::(anonymous namespace)::EnumName<JxlTransferFunction>, 8ul, 0ul, 1ul, 2ul, 3ul, 4ul, 5ul, 6ul, 7ul>(jxl::(anonymous namespace)::EnumName<JxlTransferFunction> (&&) [8ul], jxl::index_sequence<0ul, 1ul, 2ul, 3ul, 4ul, 5ul, 6ul, 7ul>) Unexecuted instantiation: color_description.cc:std::__1::array<std::__1::remove_cv<jxl::(anonymous namespace)::EnumName<JxlRenderingIntent> >::type, 4ul> jxl::detail::to_array<jxl::(anonymous namespace)::EnumName<JxlRenderingIntent>, 4ul, 0ul, 1ul, 2ul, 3ul>(jxl::(anonymous namespace)::EnumName<JxlRenderingIntent> (&&) [4ul], jxl::index_sequence<0ul, 1ul, 2ul, 3ul>) |
96 | | |
97 | | } // namespace detail |
98 | | |
99 | | template <typename T, size_t N> |
100 | 0 | constexpr auto to_array(T (&&arr)[N]) -> std::array<remove_cv_t<T>, N> { |
101 | 0 | return detail::to_array(std::move(arr), make_index_sequence<N>()); |
102 | 0 | } Unexecuted instantiation: std::__1::array<std::__1::remove_cv<int>::type, 17ul> jxl::to_array<int, 17ul>(int (&&) [17ul]) Unexecuted instantiation: color_description.cc:std::__1::array<std::__1::remove_cv<jxl::(anonymous namespace)::EnumName<JxlColorSpace> >::type, 4ul> jxl::to_array<jxl::(anonymous namespace)::EnumName<JxlColorSpace>, 4ul>(jxl::(anonymous namespace)::EnumName<JxlColorSpace> (&&) [4ul]) Unexecuted instantiation: color_description.cc:std::__1::array<std::__1::remove_cv<jxl::(anonymous namespace)::EnumName<JxlWhitePoint> >::type, 4ul> jxl::to_array<jxl::(anonymous namespace)::EnumName<JxlWhitePoint>, 4ul>(jxl::(anonymous namespace)::EnumName<JxlWhitePoint> (&&) [4ul]) Unexecuted instantiation: color_description.cc:std::__1::array<std::__1::remove_cv<jxl::(anonymous namespace)::EnumName<JxlPrimaries> >::type, 4ul> jxl::to_array<jxl::(anonymous namespace)::EnumName<JxlPrimaries>, 4ul>(jxl::(anonymous namespace)::EnumName<JxlPrimaries> (&&) [4ul]) Unexecuted instantiation: color_description.cc:std::__1::array<std::__1::remove_cv<jxl::(anonymous namespace)::EnumName<JxlTransferFunction> >::type, 8ul> jxl::to_array<jxl::(anonymous namespace)::EnumName<JxlTransferFunction>, 8ul>(jxl::(anonymous namespace)::EnumName<JxlTransferFunction> (&&) [8ul]) Unexecuted instantiation: color_description.cc:std::__1::array<std::__1::remove_cv<jxl::(anonymous namespace)::EnumName<JxlRenderingIntent> >::type, 4ul> jxl::to_array<jxl::(anonymous namespace)::EnumName<JxlRenderingIntent>, 4ul>(jxl::(anonymous namespace)::EnumName<JxlRenderingIntent> (&&) [4ul]) |
103 | | |
104 | | template <typename T> |
105 | 384M | JXL_INLINE T Clamp1(T val, T low, T hi) { |
106 | 384M | return val < low ? low : val > hi ? hi : val; |
107 | 384M | } float jxl::Clamp1<float>(float, float, float) Line | Count | Source | 105 | 149M | JXL_INLINE T Clamp1(T val, T low, T hi) { | 106 | 149M | return val < low ? low : val > hi ? hi : val; | 107 | 149M | } |
double jxl::Clamp1<double>(double, double, double) Line | Count | Source | 105 | 713k | JXL_INLINE T Clamp1(T val, T low, T hi) { | 106 | 713k | return val < low ? low : val > hi ? hi : val; | 107 | 713k | } |
int jxl::Clamp1<int>(int, int, int) Line | Count | Source | 105 | 234M | JXL_INLINE T Clamp1(T val, T low, T hi) { | 106 | 234M | return val < low ? low : val > hi ? hi : val; | 107 | 234M | } |
Unexecuted instantiation: unsigned char jxl::Clamp1<unsigned char>(unsigned char, unsigned char, unsigned char) Unexecuted instantiation: long jxl::Clamp1<long>(long, long, long) |
108 | | |
109 | | // conversion from integer to string. |
110 | | template <typename T> |
111 | 41.3k | std::string ToString(T n) { |
112 | 41.3k | char data[32] = {}; |
113 | 41.3k | if (std::is_floating_point<T>::value) { |
114 | | // float |
115 | 41.3k | snprintf(data, sizeof(data), "%g", static_cast<double>(n)); |
116 | 41.3k | } else if (std::is_unsigned<T>::value) { |
117 | | // unsigned |
118 | 0 | snprintf(data, sizeof(data), "%llu", static_cast<unsigned long long>(n)); |
119 | 0 | } else { |
120 | | // signed |
121 | 0 | snprintf(data, sizeof(data), "%lld", static_cast<long long>(n)); |
122 | 0 | } |
123 | 41.3k | return data; |
124 | 41.3k | } std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > jxl::ToString<double>(double) Line | Count | Source | 111 | 41.3k | std::string ToString(T n) { | 112 | 41.3k | char data[32] = {}; | 113 | 41.3k | if (std::is_floating_point<T>::value) { | 114 | | // float | 115 | 41.3k | snprintf(data, sizeof(data), "%g", static_cast<double>(n)); | 116 | 41.3k | } else if (std::is_unsigned<T>::value) { | 117 | | // unsigned | 118 | 0 | snprintf(data, sizeof(data), "%llu", static_cast<unsigned long long>(n)); | 119 | 0 | } else { | 120 | | // signed | 121 | 0 | snprintf(data, sizeof(data), "%lld", static_cast<long long>(n)); | 122 | 0 | } | 123 | 41.3k | return data; | 124 | 41.3k | } |
Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > jxl::ToString<int>(int) |
125 | | |
126 | | #define JXL_JOIN(x, y) JXL_DO_JOIN(x, y) |
127 | | #define JXL_DO_JOIN(x, y) x##y |
128 | | |
129 | | } // namespace jxl |
130 | | |
131 | | #endif // LIB_JXL_BASE_COMMON_H_ |