mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 00:47:45 +00:00
LibCompress: Decode the LZMA match type in a separate function
This should keep the `read_some` function a bit flatter and shorter, and make it easier to match the match type decoding process with the specification.
This commit is contained in:
parent
4a37bac374
commit
42514c6961
2 changed files with 98 additions and 64 deletions
|
@ -118,6 +118,16 @@ protected:
|
|||
Array<Probability, number_of_states> m_is_rep_g1_probabilities;
|
||||
Array<Probability, number_of_states> m_is_rep_g2_probabilities;
|
||||
Array<Probability, (number_of_states << maximum_number_of_position_bits)> m_is_rep0_long_probabilities;
|
||||
|
||||
enum MatchType {
|
||||
Literal,
|
||||
SimpleMatch,
|
||||
RepMatch0,
|
||||
ShortRepMatch,
|
||||
RepMatch1,
|
||||
RepMatch2,
|
||||
RepMatch3,
|
||||
};
|
||||
};
|
||||
|
||||
class LzmaDecompressor : public Stream
|
||||
|
@ -159,6 +169,8 @@ private:
|
|||
ErrorOr<u8> decode_direct_bit();
|
||||
ErrorOr<u8> decode_bit_with_probability(Probability& probability);
|
||||
|
||||
ErrorOr<MatchType> decode_match_type();
|
||||
|
||||
// Decodes a multi-bit symbol using a given probability tree (either in normal or in reverse order).
|
||||
// The specification states that "unsigned" is at least 16 bits in size, our implementation assumes this as the maximum symbol size.
|
||||
ErrorOr<u16> decode_symbol_using_bit_tree(size_t bit_count, Span<Probability> probability_tree);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue