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

Method readCorrector

src/integercompressor.cpp:467–549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}
466
467I32 IntegerCompressor::readCorrector(ArithmeticModel* mBits)
468{
469 I32 c;
470
471 // decode within which interval the corrector is falling
472
473 k = dec->decodeSymbol(mBits);
474
475 // decode the exact location of the corrector within the interval
476
477#ifdef COMPRESS_ONLY_K
478 if (k) // then c is either smaller than 0 or bigger than 1
479 {
480 if (k < 32)
481 {
482 c = dec->readBits(k);
483
484 if (c >= (1<<(k-1))) // if c is in the interval [ 2^(k-1) ... + 2^k - 1 ]
485 {
486 // so we translate c back into the interval [ 2^(k-1) + 1 ... 2^k ] by adding 1
487 c += 1;
488 }
489 else // otherwise c is in the interval [ 0 ... + 2^(k-1) - 1 ]
490 {
491 // so we translate c back into the interval [ - (2^k - 1) ... - (2^(k-1)) ] by subtracting (2^k - 1)
492 c -= ((1<<k) - 1);
493 }
494 }
495 else
496 {
497 c = corr_min;
498 }
499 }
500 else // then c is either 0 or 1
501 {
502 c = dec->readBit();
503 }
504#else // COMPRESS_ONLY_K
505 if (k) // then c is either smaller than 0 or bigger than 1
506 {
507 if (k < 32)
508 {
509 if (k <= bits_high) // for small k we can do this in one step
510 {
511 // decompress c with the range coder
512 c = dec->decodeSymbol(mCorrector[k]);
513 }
514 else
515 {
516 // for larger k we need to do this in two steps
517 int k1 = k-bits_high;
518 // decompress higher bits with table
519 c = dec->decodeSymbol(mCorrector[k]);
520 // read lower bits raw
521 int c1 = dec->readBits(k1);
522 // put the corrector back together
523 c = (c << k1) | c1;
524 }

Callers

nothing calls this directly

Calls 4

decodeSymbolMethod · 0.45
readBitsMethod · 0.45
readBitMethod · 0.45
decodeBitMethod · 0.45

Tested by

no test coverage detected