Class: Omnizip::Algorithms::Zstandard::SequencesDecoder
- Inherits:
-
Object
- Object
- Omnizip::Algorithms::Zstandard::SequencesDecoder
- Includes:
- Constants
- Defined in:
- lib/omnizip/algorithms/zstandard/sequences.rb
Overview
Sequences section decoder (RFC 8878 Section 3.1.1.3.2)
Decodes sequences of (literals_length, match_length, offset) which are then executed to produce the decompressed output.
Constant Summary
Constants included from Constants
Constants::BLOCK_HEADER_SIZE, Constants::BLOCK_MAX_SIZE, Constants::BLOCK_TYPE_COMPRESSED, Constants::BLOCK_TYPE_RAW, Constants::BLOCK_TYPE_RESERVED, Constants::BLOCK_TYPE_RLE, Constants::BUFFER_SIZE, Constants::DEFAULT_LEVEL, Constants::DEFAULT_REPEAT_OFFSETS, Constants::FSE_MAX_ACCURACY_LOG, Constants::FSE_MIN_ACCURACY_LOG, Constants::HUFFMAN_MAX_BITS, Constants::HUFFMAN_MAX_CODE_LENGTH, Constants::HUFFMAN_MAX_LOG, Constants::HUFFMAN_STANDARD_TABLE_SIZE, Constants::LITERALS_BLOCK_COMPRESSED, Constants::LITERALS_BLOCK_RAW, Constants::LITERALS_BLOCK_RLE, Constants::LITERALS_BLOCK_TREELESS, Constants::LITERALS_LENGTH_ACCURACY_LOG, Constants::LITERAL_LENGTH_TABLE, Constants::MAGIC_BYTES, Constants::MAGIC_NUMBER, Constants::MATCH_LENGTH_ACCURACY_LOG, Constants::MATCH_LENGTH_TABLE, Constants::MAX_LEVEL, Constants::MIN_LEVEL, Constants::MODE_FSE, Constants::MODE_PREDEFINED, Constants::MODE_REPEAT, Constants::MODE_RLE, Constants::OFFSET_ACCURACY_LOG, Constants::PREDEFINED_LL_DISTRIBUTION, Constants::PREDEFINED_ML_DISTRIBUTION, Constants::PREDEFINED_OFFSET_DISTRIBUTION, Constants::REPEAT_OFFSET_1, Constants::REPEAT_OFFSET_2, Constants::REPEAT_OFFSET_3, Constants::SKIPPABLE_MAGIC_BASE, Constants::SKIPPABLE_MAGIC_MASK, Constants::WINDOW_LOG_MAX, Constants::WINDOW_LOG_MIN
Instance Attribute Summary collapse
-
#sequences ⇒ Array<Hash>
readonly
Decoded sequences.
Class Method Summary collapse
-
.decode(input, literals_size, previous_tables = {}) ⇒ SequencesDecoder
Parse and decode sequences section.
Instance Method Summary collapse
-
#decode_section ⇒ void
Decode the sequences section.
-
#initialize(input, literals_size, previous_tables = {}) ⇒ SequencesDecoder
constructor
Initialize decoder.
Constructor Details
#initialize(input, literals_size, previous_tables = {}) ⇒ SequencesDecoder
Initialize decoder
53 54 55 56 57 58 59 |
# File 'lib/omnizip/algorithms/zstandard/sequences.rb', line 53 def initialize(input, literals_size, previous_tables = {}) @input = input @literals_size = literals_size @previous_tables = previous_tables @sequences = [] @fse_tables = {} end |
Instance Attribute Details
#sequences ⇒ Array<Hash> (readonly)
Returns Decoded sequences.
34 35 36 |
# File 'lib/omnizip/algorithms/zstandard/sequences.rb', line 34 def sequences @sequences end |
Class Method Details
.decode(input, literals_size, previous_tables = {}) ⇒ SequencesDecoder
Parse and decode sequences section
42 43 44 45 46 |
# File 'lib/omnizip/algorithms/zstandard/sequences.rb', line 42 def self.decode(input, literals_size, previous_tables = {}) decoder = new(input, literals_size, previous_tables) decoder.decode_section decoder end |
Instance Method Details
#decode_section ⇒ void
This method returns an undefined value.
Decode the sequences section
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/omnizip/algorithms/zstandard/sequences.rb', line 64 def decode_section # Read number of sequences num_sequences = read_sequence_count return if num_sequences.zero? # Read symbol compression modes modes = read_symbol_modes # Build FSE tables based on modes build_fse_tables(modes) # Decode sequences decode_sequences_internal(num_sequences) end |