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

Method encodeSymbol

src/arithmeticencoder.cpp:222–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220}
221
222void ArithmeticEncoder::encodeSymbol(ArithmeticModel* m, U32 sym)
223{
224 assert(m && (sym <= m->last_symbol));
225
226 U32 x, init_base = base;
227 // compute products
228 if (sym == m->last_symbol) {
229 x = m->distribution[sym] * (length >> DM__LengthShift);
230 base += x; // update interval
231 length -= x; // no product needed
232 }
233 else {
234 x = m->distribution[sym] * (length >>= DM__LengthShift);
235 base += x; // update interval
236 length = m->distribution[sym+1] * length - x;
237 }
238
239 if (init_base > base) propagate_carry(); // overflow = carry
240 if (length < AC__MinLength) renorm_enc_interval(); // renormalization
241
242 ++m->symbol_count[sym];
243 if (--m->symbols_until_update == 0) m->update(); // periodic model update
244}
245
246void ArithmeticEncoder::writeBit(U32 sym)
247{

Callers 7

writeMethod · 0.45
writeMethod · 0.45
write_gps_timeMethod · 0.45
writeMethod · 0.45
writeMethod · 0.45
write_gps_timeMethod · 0.45
writeCorrectorMethod · 0.45

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected