Class: Omnizip::Algorithms::Zstandard::FSE::Decoder
- Inherits:
-
Object
- Object
- Omnizip::Algorithms::Zstandard::FSE::Decoder
- Defined in:
- lib/omnizip/algorithms/zstandard/fse/table.rb
Overview
Stateful single-stream FSE decoder.
Instance Attribute Summary collapse
-
#state ⇒ Integer
readonly
Current state index.
Instance Method Summary collapse
-
#current_symbol ⇒ Integer
The symbol the current state decodes, without transitioning.
-
#decode(bitstream) ⇒ Integer
Decode one symbol: read it from the current state, then transition.
-
#init_state(bitstream) ⇒ Object
Initialize the state by reading accuracy_log bits.
-
#initialize(table) ⇒ Decoder
constructor
A new instance of Decoder.
Constructor Details
#initialize(table) ⇒ Decoder
Returns a new instance of Decoder.
154 155 156 157 |
# File 'lib/omnizip/algorithms/zstandard/fse/table.rb', line 154 def initialize(table) @table = table @state = 0 end |
Instance Attribute Details
#state ⇒ Integer (readonly)
Returns current state index.
151 152 153 |
# File 'lib/omnizip/algorithms/zstandard/fse/table.rb', line 151 def state @state end |
Instance Method Details
#current_symbol ⇒ Integer
The symbol the current state decodes, without transitioning.
181 182 183 |
# File 'lib/omnizip/algorithms/zstandard/fse/table.rb', line 181 def current_symbol @table[@state].symbol end |
#decode(bitstream) ⇒ Integer
Decode one symbol: read it from the current state, then transition.
168 169 170 171 172 173 174 175 176 |
# File 'lib/omnizip/algorithms/zstandard/fse/table.rb', line 168 def decode(bitstream) entry = @table[@state] @state = if entry.num_bits.positive? entry.baseline + bitstream.read_bits(entry.num_bits) else entry.baseline end entry.symbol end |
#init_state(bitstream) ⇒ Object
Initialize the state by reading accuracy_log bits.
160 161 162 |
# File 'lib/omnizip/algorithms/zstandard/fse/table.rb', line 160 def init_state(bitstream) @state = bitstream.read_bits(@table.accuracy_log) end |