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/enc_quant_weights.cc | |
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/enc_quant_weights.cc')
-rw-r--r-- | third_party/jpeg-xl/lib/jxl/enc_quant_weights.cc | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/third_party/jpeg-xl/lib/jxl/enc_quant_weights.cc b/third_party/jpeg-xl/lib/jxl/enc_quant_weights.cc index 236ddaacfd..35e49d5993 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_quant_weights.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_quant_weights.cc @@ -5,24 +5,18 @@ #include "lib/jxl/enc_quant_weights.h" +#include <jxl/types.h> #include <stdlib.h> -#include <algorithm> #include <cmath> -#include <limits> -#include <utility> -#include "lib/jxl/base/bits.h" #include "lib/jxl/base/common.h" #include "lib/jxl/base/status.h" -#include "lib/jxl/dct_scales.h" #include "lib/jxl/enc_aux_out.h" #include "lib/jxl/enc_bit_writer.h" #include "lib/jxl/enc_modular.h" #include "lib/jxl/fields.h" -#include "lib/jxl/image.h" #include "lib/jxl/modular/encoding/encoding.h" -#include "lib/jxl/modular/options.h" namespace jxl { @@ -95,8 +89,8 @@ Status EncodeQuant(const QuantEncoding& encoding, size_t idx, size_t size_x, break; } case QuantEncoding::kQuantModeRAW: { - ModularFrameEncoder::EncodeQuantTable(size_x, size_y, writer, encoding, - idx, modular_frame_encoder); + JXL_RETURN_IF_ERROR(ModularFrameEncoder::EncodeQuantTable( + size_x, size_y, writer, encoding, idx, modular_frame_encoder)); break; } case QuantEncoding::kQuantModeAFV: { @@ -130,7 +124,7 @@ Status DequantMatricesEncode(const DequantMatrices& matrices, BitWriter* writer, } // TODO(janwas): better bound BitWriter::Allotment allotment(writer, 512 * 1024); - writer->Write(1, all_default); + writer->Write(1, TO_JXL_BOOL(all_default)); if (!all_default) { for (size_t i = 0; i < encodings.size(); i++) { JXL_RETURN_IF_ERROR(EncodeQuant( @@ -153,7 +147,7 @@ Status DequantMatricesEncodeDC(const DequantMatrices& matrices, } } BitWriter::Allotment allotment(writer, 1 + sizeof(float) * kBitsPerByte * 3); - writer->Write(1, all_default); + writer->Write(1, TO_JXL_BOOL(all_default)); if (!all_default) { for (size_t c = 0; c < 3; c++) { JXL_RETURN_IF_ERROR(F16Coder::Write(dc_quant[c] * 128.0f, writer)); @@ -195,19 +189,20 @@ void DequantMatricesRoundtrip(DequantMatrices* matrices) { JXL_CHECK(br.Close()); } -void DequantMatricesSetCustom(DequantMatrices* matrices, - const std::vector<QuantEncoding>& encodings, - ModularFrameEncoder* encoder) { +Status DequantMatricesSetCustom(DequantMatrices* matrices, + const std::vector<QuantEncoding>& encodings, + ModularFrameEncoder* encoder) { JXL_ASSERT(encodings.size() == DequantMatrices::kNum); matrices->SetEncodings(encodings); for (size_t i = 0; i < encodings.size(); i++) { if (encodings[i].mode == QuantEncodingInternal::kQuantModeRAW) { - encoder->AddQuantTable(DequantMatrices::required_size_x[i] * kBlockDim, - DequantMatrices::required_size_y[i] * kBlockDim, - encodings[i], i); + JXL_RETURN_IF_ERROR(encoder->AddQuantTable( + DequantMatrices::required_size_x[i] * kBlockDim, + DequantMatrices::required_size_y[i] * kBlockDim, encodings[i], i)); } } DequantMatricesRoundtrip(matrices); + return true; } } // namespace jxl |