Class: Omnizip::Algorithms::Zstandard::FSE::Encoder::CState
- Inherits:
-
Object
- Object
- Omnizip::Algorithms::Zstandard::FSE::Encoder::CState
- Defined in:
- lib/omnizip/algorithms/zstandard/fse/encoder.rb
Overview
FSE encoder state (value in [table_size, 2*table_size)).
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
-
.init2(table, symbol) ⇒ Object
Initialize to the baseline for the first symbol to encode (the last to decode); C FSE_initCState2.
Instance Method Summary collapse
- #encode(bitc, table, symbol) ⇒ Object
- #flush(bitc) ⇒ Object
-
#initialize(value, state_log) ⇒ CState
constructor
A new instance of CState.
Constructor Details
#initialize(value, state_log) ⇒ CState
Returns a new instance of CState.
501 502 503 504 |
# File 'lib/omnizip/algorithms/zstandard/fse/encoder.rb', line 501 def initialize(value, state_log) @value = value @state_log = state_log end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
499 500 501 |
# File 'lib/omnizip/algorithms/zstandard/fse/encoder.rb', line 499 def value @value end |
Class Method Details
.init2(table, symbol) ⇒ Object
Initialize to the baseline for the first symbol to encode (the last to decode); C FSE_initCState2. rubocop:disable-next Metrics/AbcSize
509 510 511 512 513 514 515 |
# File 'lib/omnizip/algorithms/zstandard/fse/encoder.rb', line 509 def self.init2(table, symbol) s_tt = table.symbol_tt[symbol] nb_bits_out = (s_tt.delta_nb_bits + (1 << 15)) >> 16 value = (nb_bits_out << 16) - s_tt.delta_nb_bits idx = (value >> nb_bits_out) + s_tt.delta_find_state new(table.state_table[idx], table.table_log) end |
Instance Method Details
#encode(bitc, table, symbol) ⇒ Object
517 518 519 520 521 522 523 |
# File 'lib/omnizip/algorithms/zstandard/fse/encoder.rb', line 517 def encode(bitc, table, symbol) s_tt = table.symbol_tt[symbol] nb_bits_out = (@value + s_tt.delta_nb_bits) >> 16 bitc.add_bits(@value, nb_bits_out) idx = (@value >> nb_bits_out) + s_tt.delta_find_state @value = table.state_table[idx] end |
#flush(bitc) ⇒ Object
525 526 527 528 |
# File 'lib/omnizip/algorithms/zstandard/fse/encoder.rb', line 525 def flush(bitc) bitc.add_bits(@value, @state_log) bitc.flush end |