From fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:14:29 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- third_party/jpeg-xl/lib/jxl/quant_weights_test.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'third_party/jpeg-xl/lib/jxl/quant_weights_test.cc') 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 2dd513804c..e92cbf2151 100644 --- a/third_party/jpeg-xl/lib/jxl/quant_weights_test.cc +++ b/third_party/jpeg-xl/lib/jxl/quant_weights_test.cc @@ -23,6 +23,18 @@ namespace jxl { namespace { +// This should have been static assert; not compiling though with C++<17. +TEST(QuantWeightsTest, Invariant) { + size_t sum = 0; + ASSERT_EQ(DequantMatrices::required_size_x.size(), + DequantMatrices::required_size_y.size()); + for (size_t i = 0; i < DequantMatrices::required_size_x.size(); ++i) { + sum += DequantMatrices::required_size_x[i] * + DequantMatrices::required_size_y[i]; + } + ASSERT_EQ(DequantMatrices::kSumRequiredXy, sum); +} + template void CheckSimilar(T a, T b) { EXPECT_EQ(a, b); @@ -50,8 +62,8 @@ void RoundtripMatrices(const std::vector& encodings) { DequantMatrices mat; CodecMetadata metadata; FrameHeader frame_header(&metadata); - ModularFrameEncoder encoder(frame_header, CompressParams{}); - DequantMatricesSetCustom(&mat, encodings, &encoder); + ModularFrameEncoder encoder(frame_header, CompressParams{}, false); + JXL_CHECK(DequantMatricesSetCustom(&mat, encodings, &encoder)); const std::vector& encodings_dec = mat.encodings(); for (size_t i = 0; i < encodings.size(); i++) { const QuantEncoding& e = encodings[i]; @@ -172,8 +184,8 @@ TEST_P(QuantWeightsTargetTest, DCTUniform) { DequantMatrices dequant_matrices; CodecMetadata metadata; FrameHeader frame_header(&metadata); - ModularFrameEncoder encoder(frame_header, CompressParams{}); - DequantMatricesSetCustom(&dequant_matrices, encodings, &encoder); + ModularFrameEncoder encoder(frame_header, CompressParams{}, false); + JXL_CHECK(DequantMatricesSetCustom(&dequant_matrices, encodings, &encoder)); JXL_CHECK(dequant_matrices.EnsureComputed(~0u)); const float dc_quant[3] = {1.0f / kUniformQuant, 1.0f / kUniformQuant, -- cgit v1.2.3