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_context_map.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_context_map.cc')
-rw-r--r-- | third_party/jpeg-xl/lib/jxl/enc_context_map.cc | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/third_party/jpeg-xl/lib/jxl/enc_context_map.cc b/third_party/jpeg-xl/lib/jxl/enc_context_map.cc index 6968a6fbae..36efc4e649 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_context_map.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_context_map.cc @@ -7,6 +7,7 @@ #include "lib/jxl/enc_context_map.h" +#include <jxl/types.h> #include <stdint.h> #include <algorithm> @@ -18,6 +19,7 @@ #include "lib/jxl/enc_ans.h" #include "lib/jxl/enc_aux_out.h" #include "lib/jxl/entropy_coder.h" +#include "lib/jxl/fields.h" #include "lib/jxl/pack_signed.h" namespace jxl { @@ -69,16 +71,18 @@ void EncodeContextMap(const std::vector<uint8_t>& context_map, } std::vector<uint8_t> transformed_symbols = MoveToFrontTransform(context_map); - std::vector<std::vector<Token>> tokens(1), mtf_tokens(1); - for (size_t i = 0; i < context_map.size(); i++) { - tokens[0].emplace_back(0, context_map[i]); + std::vector<std::vector<Token>> tokens(1); + std::vector<std::vector<Token>> mtf_tokens(1); + for (const uint8_t& ctx : context_map) { + tokens[0].emplace_back(0, ctx); } - for (size_t i = 0; i < transformed_symbols.size(); i++) { - mtf_tokens[0].emplace_back(0, transformed_symbols[i]); + for (const uint8_t& sym : transformed_symbols) { + mtf_tokens[0].emplace_back(0, sym); } HistogramParams params; params.uint_method = HistogramParams::HybridUintMethod::kContextMap; - size_t ans_cost, mtf_cost; + size_t ans_cost; + size_t mtf_cost; { EntropyEncodingData codes; std::vector<uint8_t> sink_context_map; @@ -104,14 +108,14 @@ void EncodeContextMap(const std::vector<uint8_t>& context_map, BitWriter::Allotment allotment(writer, 3 + entry_bits * context_map.size()); writer->Write(1, 1); writer->Write(2, entry_bits); - for (size_t i = 0; i < context_map.size(); i++) { - writer->Write(entry_bits, context_map[i]); + for (uint8_t entry : context_map) { + writer->Write(entry_bits, entry); } allotment.ReclaimAndCharge(writer, layer, aux_out); } else { BitWriter::Allotment allotment(writer, 2 + tokens[0].size() * 24); writer->Write(1, 0); - writer->Write(1, use_mtf); // Use/don't use MTF. + writer->Write(1, TO_JXL_BOOL(use_mtf)); // Use/don't use MTF. EntropyEncodingData codes; std::vector<uint8_t> sink_context_map; BuildAndEncodeHistograms(params, 1, tokens, &codes, &sink_context_map, @@ -123,9 +127,9 @@ void EncodeContextMap(const std::vector<uint8_t>& context_map, void EncodeBlockCtxMap(const BlockCtxMap& block_ctx_map, BitWriter* writer, AuxOut* aux_out) { - auto& dct = block_ctx_map.dc_thresholds; - auto& qft = block_ctx_map.qf_thresholds; - auto& ctx_map = block_ctx_map.ctx_map; + const auto& dct = block_ctx_map.dc_thresholds; + const auto& qft = block_ctx_map.qf_thresholds; + const auto& ctx_map = block_ctx_map.ctx_map; BitWriter::Allotment allotment( writer, (dct[0].size() + dct[1].size() + dct[2].size() + qft.size()) * 34 + 1 + |