Class: Omnizip::Algorithms::LZMA::RangeCoder

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/omnizip/algorithms/lzma/range_coder.rb

Overview

Base class for range encoding and decoding

This class provides the core arithmetic coding functionality used by both the encoder and decoder. Range coding is a form of arithmetic coding that uses integer arithmetic to represent probability ranges.

The algorithm maintains a range [low, high) and subdivides it based on symbol probabilities. The range is periodically normalized to prevent arithmetic overflow/underflow.

Constant Summary

Constants included from Constants

Constants::BIT_MODEL_TOTAL, Constants::COMPRESSION_LEVEL_DEFAULT, Constants::COMPRESSION_LEVEL_MAX, Constants::COMPRESSION_LEVEL_MIN, Constants::DICT_SIZE_MAX, Constants::DICT_SIZE_MIN, Constants::DIST_ALIGN_BITS, Constants::DIST_ALIGN_SIZE, Constants::DIST_SLOT_FAST_LIMIT, Constants::END_POS_MODEL_INDEX, Constants::EOS_MARKER, Constants::INIT_PROBS, Constants::LEN_HIGH_SYMBOLS, Constants::LEN_LOW_SYMBOLS, Constants::LEN_MID_SYMBOLS, Constants::LIT_SIZE_MAX, Constants::MATCH_LEN_MAX, Constants::MATCH_LEN_MIN, Constants::MOVE_BITS, Constants::NUM_DIRECT_BITS, Constants::NUM_DIST_SLOTS, Constants::NUM_DIST_SLOT_BITS, Constants::NUM_FULL_DISTANCES, Constants::NUM_LEN_HIGH_BITS, Constants::NUM_LEN_LOW_BITS, Constants::NUM_LEN_MID_BITS, Constants::NUM_LEN_TO_POS_STATES, Constants::NUM_LIT_CONTEXT_BITS_MAX, Constants::NUM_LIT_POS_BITS_MAX, Constants::NUM_POS_BITS_MAX, Constants::NUM_STATES, Constants::POS_STATES_MAX, Constants::START_POS_MODEL_INDEX, Constants::TOP

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stream) ⇒ RangeCoder

Initialize the range coder

Parameters:

  • stream (IO)

    The input or output stream



44
45
46
47
48
# File 'lib/omnizip/algorithms/lzma/range_coder.rb', line 44

def initialize(stream)
  @stream = stream
  @range = 0xFFFFFFFF
  @low = 0
end

Instance Attribute Details

#lowObject (readonly)

Returns the value of attribute low.



39
40
41
# File 'lib/omnizip/algorithms/lzma/range_coder.rb', line 39

def low
  @low
end

#rangeObject (readonly)

Returns the value of attribute range.



39
40
41
# File 'lib/omnizip/algorithms/lzma/range_coder.rb', line 39

def range
  @range
end