diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /third_party/jpeg-xl/lib/jxl/quant_weights.h | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/jpeg-xl/lib/jxl/quant_weights.h')
-rw-r--r-- | third_party/jpeg-xl/lib/jxl/quant_weights.h | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/third_party/jpeg-xl/lib/jxl/quant_weights.h b/third_party/jpeg-xl/lib/jxl/quant_weights.h index 3004176aba..0fa23ffddb 100644 --- a/third_party/jpeg-xl/lib/jxl/quant_weights.h +++ b/third_party/jpeg-xl/lib/jxl/quant_weights.h @@ -15,6 +15,7 @@ #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" @@ -23,12 +24,6 @@ namespace jxl { -template <typename T, size_t N> -constexpr T ArraySum(T (&a)[N], size_t i = N - 1) { - static_assert(N > 0, "Trying to compute the sum of an empty array"); - return i == 0 ? a[0] : a[i] + ArraySum(a, i - 1); -} - static constexpr size_t kMaxQuantTableSize = AcStrategy::kMaxCoeffArea; static constexpr size_t kNumPredefinedTables = 1; static constexpr size_t kCeilLog2NumPredefinedTables = 0; @@ -410,25 +405,23 @@ class DequantMatrices { const std::vector<QuantEncoding>& encodings() const { return encodings_; } - static constexpr size_t required_size_x[] = {1, 1, 1, 1, 2, 4, 1, 1, 2, - 1, 1, 8, 4, 16, 8, 32, 16}; - static_assert(kNum == sizeof(required_size_x) / sizeof(*required_size_x), + static constexpr auto required_size_x = + to_array<int>({1, 1, 1, 1, 2, 4, 1, 1, 2, 1, 1, 8, 4, 16, 8, 32, 16}); + static_assert(kNum == required_size_x.size(), "Update this array when adding or removing quant tables."); - static constexpr size_t required_size_y[] = {1, 1, 1, 1, 2, 4, 2, 4, 4, - 1, 1, 8, 8, 16, 16, 32, 32}; - static_assert(kNum == sizeof(required_size_y) / sizeof(*required_size_y), + static constexpr auto required_size_y = + to_array<int>({1, 1, 1, 1, 2, 4, 2, 4, 4, 1, 1, 8, 8, 16, 16, 32, 32}); + static_assert(kNum == required_size_y.size(), "Update this array when adding or removing quant tables."); + // MUST be equal `sum(dot(required_size_x, required_size_y))`. + static constexpr size_t kSumRequiredXy = 2056; + Status EnsureComputed(uint32_t acs_mask); private: - static constexpr size_t required_size_[] = { - 1, 1, 1, 1, 4, 16, 2, 4, 8, 1, 1, 64, 32, 256, 128, 1024, 512}; - static_assert(kNum == sizeof(required_size_) / sizeof(*required_size_), - "Update this array when adding or removing quant tables."); - static constexpr size_t kTotalTableSize = - ArraySum(required_size_) * kDCTBlockSize * 3; + static constexpr size_t kTotalTableSize = kSumRequiredXy * kDCTBlockSize * 3; uint32_t computed_mask_ = 0; // kTotalTableSize entries followed by kTotalTableSize for inv_table |