mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibGfx/JPEGXL: Make EntropyDecoder::read_config()
static
This function will soon be used for the LZ77 decoder with a different parameter than `m_log_alphabet_size`.
This commit is contained in:
parent
a0bceeb704
commit
07ea66528e
Notes:
sideshowbarker
2024-07-17 06:54:15 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/07ea66528e Pull-request: https://github.com/SerenityOS/serenity/pull/20480 Reviewed-by: https://github.com/gmta ✅
1 changed files with 20 additions and 20 deletions
|
@ -1158,7 +1158,7 @@ public:
|
|||
entropy_decoder.m_log_alphabet_size = 5 + TRY(stream.read_bits(2));
|
||||
|
||||
for (auto& config : entropy_decoder.m_configs)
|
||||
config = TRY(entropy_decoder.read_config(stream));
|
||||
config = TRY(read_config(stream, entropy_decoder.m_log_alphabet_size));
|
||||
|
||||
if (use_prefix_code) {
|
||||
entropy_decoder.m_distributions = Vector<BrotliCanonicalCode> {};
|
||||
|
@ -1257,6 +1257,25 @@ private:
|
|||
return result;
|
||||
}
|
||||
|
||||
static ErrorOr<HybridUint> read_config(LittleEndianInputBitStream& stream, u8 log_alphabet_size)
|
||||
{
|
||||
// C.2.3 - Hybrid integer configuration
|
||||
HybridUint config {};
|
||||
config.split_exponent = TRY(stream.read_bits(ceil(log2(log_alphabet_size + 1))));
|
||||
if (config.split_exponent != log_alphabet_size) {
|
||||
auto nbits = ceil(log2(config.split_exponent + 1));
|
||||
config.msb_in_token = TRY(stream.read_bits(nbits));
|
||||
nbits = ceil(log2(config.split_exponent - config.msb_in_token + 1));
|
||||
config.lsb_in_token = TRY(stream.read_bits(nbits));
|
||||
} else {
|
||||
config.msb_in_token = 0;
|
||||
config.lsb_in_token = 0;
|
||||
}
|
||||
|
||||
config.split = 1 << config.split_exponent;
|
||||
return config;
|
||||
}
|
||||
|
||||
ErrorOr<void> read_pre_clustered_distributions(LittleEndianInputBitStream& stream, u8 num_distrib)
|
||||
{
|
||||
// C.2.2 Distribution clustering
|
||||
|
@ -1301,25 +1320,6 @@ private:
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<HybridUint> read_config(LittleEndianInputBitStream& stream) const
|
||||
{
|
||||
// C.2.3 - Hybrid integer configuration
|
||||
HybridUint config {};
|
||||
config.split_exponent = TRY(stream.read_bits(ceil(log2(m_log_alphabet_size + 1))));
|
||||
if (config.split_exponent != m_log_alphabet_size) {
|
||||
auto nbits = ceil(log2(config.split_exponent + 1));
|
||||
config.msb_in_token = TRY(stream.read_bits(nbits));
|
||||
nbits = ceil(log2(config.split_exponent - config.msb_in_token + 1));
|
||||
config.lsb_in_token = TRY(stream.read_bits(nbits));
|
||||
} else {
|
||||
config.msb_in_token = 0;
|
||||
config.lsb_in_token = 0;
|
||||
}
|
||||
|
||||
config.split = 1 << config.split_exponent;
|
||||
return config;
|
||||
}
|
||||
|
||||
bool m_lz77_enabled {};
|
||||
Vector<u32> m_clusters;
|
||||
Vector<HybridUint> m_configs;
|
||||
|
|
Loading…
Reference in a new issue