mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
LibCompress: Use named EndOfBlock constant
No behavior change.
This commit is contained in:
parent
ff6d58f321
commit
a01fdca2de
Notes:
sideshowbarker
2024-07-17 05:05:51 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/a01fdca2de Pull-request: https://github.com/SerenityOS/serenity/pull/24397 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/LucasChollet Reviewed-by: https://github.com/trflynn89
@ -20,6 +20,8 @@ static constexpr u8 deflate_special_code_length_copy = 16;
|
||||
static constexpr u8 deflate_special_code_length_zeros = 17;
|
||||
static constexpr u8 deflate_special_code_length_long_zeros = 18;
|
||||
|
||||
static constexpr int EndOfBlock = 256;
|
||||
|
||||
CanonicalCode const& CanonicalCode::fixed_literal_codes()
|
||||
{
|
||||
static CanonicalCode code;
|
||||
@ -182,13 +184,13 @@ ErrorOr<bool> DeflateDecompressor::CompressedBlock::try_read_more()
|
||||
if (symbol >= 286)
|
||||
return Error::from_string_literal("Invalid deflate literal/length symbol");
|
||||
|
||||
if (symbol < 256) {
|
||||
if (symbol < EndOfBlock) {
|
||||
u8 byte_symbol = symbol;
|
||||
m_decompressor.m_output_buffer.write({ &byte_symbol, sizeof(byte_symbol) });
|
||||
return true;
|
||||
}
|
||||
|
||||
if (symbol == 256) {
|
||||
if (symbol == EndOfBlock) {
|
||||
m_eof = true;
|
||||
return false;
|
||||
}
|
||||
@ -806,7 +808,7 @@ size_t DeflateCompressor::encode_block_lengths(Array<u8, max_huffman_literals> c
|
||||
literal_code_count = max_huffman_literals;
|
||||
distance_code_count = max_huffman_distances;
|
||||
|
||||
VERIFY(literal_bit_lengths[256] != 0); // Make sure at least the EndOfBlock marker is present
|
||||
VERIFY(literal_bit_lengths[EndOfBlock] != 0); // Make sure at least the EndOfBlock marker is present
|
||||
while (literal_bit_lengths[literal_code_count - 1] == 0)
|
||||
literal_code_count--;
|
||||
|
||||
@ -885,8 +887,8 @@ ErrorOr<void> DeflateCompressor::flush()
|
||||
|
||||
// insert EndOfBlock marker to the symbol buffer
|
||||
m_symbol_buffer[m_pending_symbol_size].distance = 0;
|
||||
m_symbol_buffer[m_pending_symbol_size++].literal = 256;
|
||||
m_symbol_frequencies[256]++;
|
||||
m_symbol_buffer[m_pending_symbol_size++].literal = EndOfBlock;
|
||||
m_symbol_frequencies[EndOfBlock]++;
|
||||
|
||||
// generate optimal dynamic huffman code lengths
|
||||
Array<u8, max_huffman_literals> dynamic_literal_bit_lengths {};
|
||||
|
Loading…
Reference in New Issue
Block a user