Module: Cabriolet::QuantumShared
- Included in:
- Compressors::Quantum, Decompressors::Quantum
- Defined in:
- lib/cabriolet/quantum_shared.rb
Overview
Shared Quantum compression constants and models Used by both Compressors::Quantum and Decompressors::Quantum
Defined Under Namespace
Classes: Model, ModelSymbol
Constant Summary collapse
- FRAME_SIZE =
Frame size (32KB per frame)
32_768- MIN_MATCH =
Match constants
3- MAX_MATCH =
259- POSITION_BASE =
Position slot tables (same as in qtmd.c)
[ 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12_288, 16_384, 24_576, 32_768, 49_152, 65_536, 98_304, 131_072, 196_608, 262_144, 393_216, 524_288, 786_432, 1_048_576, 1_572_864 ].freeze
- EXTRA_BITS =
[ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19 ].freeze
- LENGTH_BASE =
[ 0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 14, 18, 22, 26, 30, 38, 46, 54, 62, 78, 94, 110, 126, 158, 190, 222, 254 ].freeze
- LENGTH_EXTRA =
[ 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 ].freeze
Class Method Summary collapse
-
.find_length_slot(length) ⇒ Integer
Find length slot for a given length.
-
.find_position_slot(offset) ⇒ Integer
Find position slot for a given offset.
Class Method Details
.find_length_slot(length) ⇒ Integer
Find length slot for a given length
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/cabriolet/quantum_shared.rb', line 86 def self.find_length_slot(length) return 0 if length < 4 # Binary search through LENGTH_BASE low = 1 high = LENGTH_BASE.size - 1 while low < high mid = (low + high + 1) / 2 if LENGTH_BASE[mid] <= length low = mid else high = mid - 1 end end low end |
.find_position_slot(offset) ⇒ Integer
Find position slot for a given offset
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cabriolet/quantum_shared.rb', line 63 def self.find_position_slot(offset) return 0 if offset < 4 # Binary search through POSITION_BASE low = 1 high = POSITION_BASE.size - 1 while low < high mid = (low + high + 1) / 2 if POSITION_BASE[mid] <= offset low = mid else high = mid - 1 end end low end |