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

Method encodeBit

src/arithmeticencoder.cpp:201–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201void ArithmeticEncoder::encodeBit(ArithmeticBitModel* m, U32 sym)
202{
203 assert(m && (sym <= 1));
204
205 U32 x = m->bit_0_prob * (length >> BM__LengthShift); // product l x p0
206 // update interval
207 if (sym == 0) {
208 length = x;
209 ++m->bit_0_count;
210 }
211 else {
212 U32 init_base = base;
213 base += x;
214 length -= x;
215 if (init_base > base) propagate_carry(); // overflow = carry
216 }
217
218 if (length < AC__MinLength) renorm_enc_interval(); // renormalization
219 if (--m->bits_until_update == 0) m->update(); // periodic model update
220}
221
222void ArithmeticEncoder::encodeSymbol(ArithmeticModel* m, U32 sym)
223{

Callers 1

writeCorrectorMethod · 0.45

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected