MCPcopy Create free account
hub / github.com/LASzip/LASzip / update

Method update

src/arithmeticmodel.cpp:139–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139void ArithmeticModel::update()
140{
141 // halve counts when a threshold is reached
142 if ((total_count += update_cycle) > DM__MaxCount)
143 {
144 total_count = 0;
145 for (U32 n = 0; n < symbols; n++)
146 {
147 total_count += (symbol_count[n] = (symbol_count[n] + 1) >> 1);
148 }
149 }
150
151 // compute cumulative distribution, decoder table
152 U32 k, sum = 0, s = 0;
153 U32 scale = 0x80000000U / total_count;
154
155 if (compress || (table_size == 0))
156 {
157 for (k = 0; k < symbols; k++)
158 {
159 distribution[k] = (scale * sum) >> (31 - DM__LengthShift);
160 sum += symbol_count[k];
161 }
162 }
163 else
164 {
165 for (k = 0; k < symbols; k++)
166 {
167 distribution[k] = (scale * sum) >> (31 - DM__LengthShift);
168 sum += symbol_count[k];
169 U32 w = distribution[k] >> table_shift;
170 while (s < w) decoder_table[++s] = k - 1;
171 }
172 decoder_table[0] = 0;
173 while (s <= table_size) decoder_table[++s] = symbols - 1;
174 }
175
176 // set frequency of model updates
177 update_cycle = (5 * update_cycle) >> 2;
178 U32 max_cycle = (symbols + 6) << 3;
179 if (update_cycle > max_cycle) update_cycle = max_cycle;
180 symbols_until_update = update_cycle;
181}
182
183ArithmeticBitModel::ArithmeticBitModel()
184{

Callers 4

encodeBitMethod · 0.45
encodeSymbolMethod · 0.45
decodeBitMethod · 0.45
decodeSymbolMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected