Class: Omnizip::Algorithms::PPMd7::Encoder
- Inherits:
-
Object
- Object
- Omnizip::Algorithms::PPMd7::Encoder
- Defined in:
- lib/omnizip/algorithms/ppmd7/encoder.rb
Overview
PPMd7 Encoder using range coding
Encodes a stream of bytes using the PPMd7 prediction model combined with range encoding for arithmetic coding.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#encode_stream(input) ⇒ void
Encode a stream of bytes.
-
#initialize(output, options = {}) ⇒ Encoder
constructor
Initialize the encoder.
Constructor Details
#initialize(output, options = {}) ⇒ Encoder
Initialize the encoder
39 40 41 42 43 44 45 46 |
# File 'lib/omnizip/algorithms/ppmd7/encoder.rb', line 39 def initialize(output, = {}) @output = output @model = Model.new( [:model_order] || Model::DEFAULT_ORDER, [:mem_size] || Model::DEFAULT_MEM_SIZE, ) @range_encoder = LZMA::RangeEncoder.new(output) end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
31 32 33 |
# File 'lib/omnizip/algorithms/ppmd7/encoder.rb', line 31 def model @model end |
Instance Method Details
#encode_stream(input) ⇒ void
This method returns an undefined value.
Encode a stream of bytes
Reads from input, compresses using PPMd7 model, and writes to output stream.
55 56 57 58 59 60 61 62 |
# File 'lib/omnizip/algorithms/ppmd7/encoder.rb', line 55 def encode_stream(input) while (byte = input.getbyte) encode_symbol(byte) end # Flush encoder @range_encoder.flush end |