Class: Omnizip::Algorithms::LZMA::Decoder
- Inherits:
-
Object
- Object
- Omnizip::Algorithms::LZMA::Decoder
- Defined in:
- lib/omnizip/algorithms/lzma/decoder.rb
Overview
LZMA Decoder - Factory for LZMA decompression implementations
This class provides a unified interface for LZMA decoding, delegating to the XZ Utils implementation for full compatibility.
The decoder reads a stream that consists of:
- Property byte (lc, lp, pb parameters)
- Dictionary size (4 bytes)
- Uncompressed size (8 bytes)
- Compressed data
Instance Attribute Summary collapse
-
#dict_size ⇒ Object
readonly
Returns the value of attribute dict_size.
-
#lc ⇒ Object
readonly
Returns the value of attribute lc.
-
#lp ⇒ Object
readonly
Returns the value of attribute lp.
-
#pb ⇒ Object
readonly
Returns the value of attribute pb.
-
#uncompressed_size ⇒ Object
readonly
Returns the value of attribute uncompressed_size.
Instance Method Summary collapse
-
#decode_stream(output = nil, preserve_dict: false) ⇒ String, Integer
Decode a compressed stream.
-
#finish_state_reset ⇒ void
Finish state reset - called AFTER setting new input.
-
#initialize(input, options = {}) ⇒ Decoder
constructor
Initialize the decoder.
-
#prepare_state_reset ⇒ void
Prepare state reset - called BEFORE setting new input.
-
#reset(new_lc: nil, new_lp: nil, new_pb: nil, preserve_dict: false) ⇒ void
Reset the decoder state for reuse with new properties.
-
#reset_state_machine_only ⇒ void
Reset state machine only - preserves rep distances.
-
#reset_state_only ⇒ void
Reset only state machine and rep distances, preserve probability models.
-
#set_input(new_input) ⇒ void
Set new input stream for chunked decoding.
-
#set_uncompressed_size(size, allow_eopm: true) ⇒ void
Set uncompressed size for chunked decoding.
Constructor Details
#initialize(input, options = {}) ⇒ Decoder
Initialize the decoder
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/omnizip/algorithms/lzma/decoder.rb', line 45 def initialize(input, = {}) # Use XZ Utils LZMA decoder (full XZ Utils compatibility) @impl = XzUtilsDecoder.new(input, ) # Expose header info as attributes @lc = @impl.lc @lp = @impl.lp @pb = @impl.pb @dict_size = @impl.dict_size @uncompressed_size = @impl.uncompressed_size end |
Instance Attribute Details
#dict_size ⇒ Object (readonly)
Returns the value of attribute dict_size.
37 38 39 |
# File 'lib/omnizip/algorithms/lzma/decoder.rb', line 37 def dict_size @dict_size end |
#lc ⇒ Object (readonly)
Returns the value of attribute lc.
37 38 39 |
# File 'lib/omnizip/algorithms/lzma/decoder.rb', line 37 def lc @lc end |
#lp ⇒ Object (readonly)
Returns the value of attribute lp.
37 38 39 |
# File 'lib/omnizip/algorithms/lzma/decoder.rb', line 37 def lp @lp end |
#pb ⇒ Object (readonly)
Returns the value of attribute pb.
37 38 39 |
# File 'lib/omnizip/algorithms/lzma/decoder.rb', line 37 def pb @pb end |
#uncompressed_size ⇒ Object (readonly)
Returns the value of attribute uncompressed_size.
37 38 39 |
# File 'lib/omnizip/algorithms/lzma/decoder.rb', line 37 def uncompressed_size @uncompressed_size end |
Instance Method Details
#decode_stream(output = nil, preserve_dict: false) ⇒ String, Integer
Decode a compressed stream
62 63 64 |
# File 'lib/omnizip/algorithms/lzma/decoder.rb', line 62 def decode_stream(output = nil, preserve_dict: false) @impl.decode_stream(output, preserve_dict: preserve_dict) end |
#finish_state_reset ⇒ void
This method returns an undefined value.
Finish state reset - called AFTER setting new input
This method is used by LZMA2 decoder for multi-chunk streams.
119 120 121 |
# File 'lib/omnizip/algorithms/lzma/decoder.rb', line 119 def finish_state_reset @impl.finish_state_reset end |
#prepare_state_reset ⇒ void
This method returns an undefined value.
Prepare state reset - called BEFORE setting new input
This method is used by LZMA2 decoder for multi-chunk streams.
99 100 101 |
# File 'lib/omnizip/algorithms/lzma/decoder.rb', line 99 def prepare_state_reset @impl.prepare_state_reset end |
#reset(new_lc: nil, new_lp: nil, new_pb: nil, preserve_dict: false) ⇒ void
This method returns an undefined value.
Reset the decoder state for reuse with new properties
This method is used by LZMA2 decoder for multi-chunk streams.
75 76 77 78 79 80 81 82 83 |
# File 'lib/omnizip/algorithms/lzma/decoder.rb', line 75 def reset(new_lc: nil, new_lp: nil, new_pb: nil, preserve_dict: false) @impl.reset(new_lc: new_lc, new_lp: new_lp, new_pb: new_pb, preserve_dict: preserve_dict) # Update cached properties @lc = @impl.lc @lp = @impl.lp @pb = @impl.pb end |
#reset_state_machine_only ⇒ void
This method returns an undefined value.
Reset state machine only - preserves rep distances
This method is used by LZMA2 decoder for multi-chunk streams where we want to reset the state machine but preserve rep distances from the previous chunk (control >= 0xA0 but < 0xC0).
110 111 112 |
# File 'lib/omnizip/algorithms/lzma/decoder.rb', line 110 def reset_state_machine_only @impl.reset_state_machine_only end |
#reset_state_only ⇒ void
This method returns an undefined value.
Reset only state machine and rep distances, preserve probability models
This method is used by LZMA2 decoder for multi-chunk streams.
90 91 92 |
# File 'lib/omnizip/algorithms/lzma/decoder.rb', line 90 def reset_state_only @impl.reset_state_only end |
#set_input(new_input) ⇒ void
This method returns an undefined value.
Set new input stream for chunked decoding
This method is used by LZMA2 decoder for multi-chunk streams.
129 130 131 |
# File 'lib/omnizip/algorithms/lzma/decoder.rb', line 129 def set_input(new_input) @impl.set_input(new_input) end |
#set_uncompressed_size(size, allow_eopm: true) ⇒ void
This method returns an undefined value.
Set uncompressed size for chunked decoding
This method is used by LZMA2 decoder for multi-chunk streams.
140 141 142 |
# File 'lib/omnizip/algorithms/lzma/decoder.rb', line 140 def set_uncompressed_size(size, allow_eopm: true) @impl.set_uncompressed_size(size, allow_eopm: allow_eopm) end |