e57::BitpackIntegerDecoder< RegisterT > Class Template Reference

#include <Decoder.h>

Public Member Functions

 BitpackIntegerDecoder (bool isScaledInteger, unsigned bytestreamNumber, SourceDestBuffer &dbuf, int64_t minimum, int64_t maximum, double scale, double offset, uint64_t maxRecordCount)
 
size_t inputProcessAligned (const char *inbuf, const size_t firstBit, const size_t endBit) override
 
- Public Member Functions inherited from e57::BitpackDecoder
void destBufferSetNew (std::vector< SourceDestBuffer > &dbufs) override
 
size_t inputProcess (const char *source, const size_t availableByteCount) override
 
virtual size_t inputProcessAligned (const char *inbuf, const size_t firstBit, const size_t endBit)=0
 
void stateReset () override
 
uint64_t totalRecordsCompleted () override
 
- Public Member Functions inherited from e57::Decoder
unsigned bytestreamNumber () const
 
 Decoder ()=delete
 
virtual void destBufferSetNew (std::vector< SourceDestBuffer > &dbufs)=0
 
virtual size_t inputProcess (const char *source, const size_t count)=0
 
virtual void stateReset ()=0
 
virtual uint64_t totalRecordsCompleted ()=0
 
virtual ~Decoder ()=default
 

Protected Attributes

unsigned bitsPerRecord_
 
RegisterT destBitMask_
 
bool isScaledInteger_
 
int64_t maximum_
 
int64_t minimum_
 
double offset_
 
double scale_
 
- Protected Attributes inherited from e57::BitpackDecoder
unsigned int bitsPerWord_
 
unsigned int bytesPerWord_
 
uint64_t currentRecordIndex_ = 0
 
std::shared_ptr< SourceDestBufferImpldestBuffer_
 
std::vector< char > inBuffer_
 
unsigned int inBufferAlignmentSize_
 
size_t inBufferEndByte_ = 0
 
size_t inBufferFirstBit_ = 0
 
uint64_t maxRecordCount_ = 0
 
- Protected Attributes inherited from e57::Decoder
unsigned int bytestreamNumber_
 

Additional Inherited Members

- Static Public Member Functions inherited from e57::Decoder
static std::shared_ptr< DecoderDecoderFactory (unsigned bytestreamNumber, const CompressedVectorNodeImpl *cVector, std::vector< SourceDestBuffer > &dbufs, const ustring &codecPath)
 
- Protected Member Functions inherited from e57::BitpackDecoder
 BitpackDecoder (unsigned bytestreamNumber, SourceDestBuffer &dbuf, unsigned alignmentSize, uint64_t maxRecordCount)
 
void inBufferShiftDown ()
 
- Protected Member Functions inherited from e57::Decoder
 Decoder (unsigned bytestreamNumber)
 

Constructor & Destructor Documentation

◆ BitpackIntegerDecoder()

template<typename RegisterT >
BitpackIntegerDecoder::BitpackIntegerDecoder ( bool  isScaledInteger,
unsigned  bytestreamNumber,
SourceDestBuffer dbuf,
int64_t  minimum,
int64_t  maximum,
double  scale,
double  offset,
uint64_t  maxRecordCount 
)

Member Function Documentation

◆ inputProcessAligned()

template<typename RegisterT >
size_t BitpackIntegerDecoder::inputProcessAligned ( const char *  inbuf,
const size_t  firstBit,
const size_t  endBit 
)
overridevirtual

Read from inbuf, decode, store in destBuffer Repeat until have filled destBuffer, or completed all records

Precalculate exact number of full records that are in inbuf We can handle the case where don't have a full word at end of inbuf, but all the bits of the record are there;

Number of transfers is the smaller of what was requested and what is available in input.

The index in inbuf of the word we are currently working on.

For example on little endian machine: Assume: registerT=uint32_t, bitOffset=20, destBitMask=0x00007fff (for a 15 bit value). inp[wordPosition] LLLLLLLL LLLLXXXX XXXXXXXX XXXXXXXX Note LSB of value is at bit20 inp(wordPosition+1] XXXXXXXX XXXXXXXX XXXXXXXX XXXXXHHH H=high bits of value, X=uninteresting bits low = inp[i] >> bitOffset 00000000 00000000 0000LLLL LLLLLLLL L=low bits of value, X=uninteresting bits high = inp[i+1] << (32-bitOffset) XXXXXXXX XXXXXXXX XHHH0000 00000000 w = high | low XXXXXXXX XXXXXXXX XHHHLLLL LLLLLLLL destBitmask 00000000 00000000 01111111 11111111 w & mask 00000000 00000000 0HHHLLLL LLLLLLLL

Get lower word (contains at least the LSbit of the value),

Get upper word (may or may not contain interesting bits),

Shift high to just above the lower bits, shift low LSBit to bit0, OR together. Note shifts are logical (not arithmetic) because using unsigned variables.

The left shift (used above) is not defined if shift is >= size of word

Mask off uninteresting bits

Add minimum_ to value to get back what writer originally sent

The parameter isScaledInteger_ determines which version of setNextInt64 gets called

Store the result in next avaiable position in the user's dest buffer

Calc next bit alignment and which word it starts in

Update counts of records processed

Return number of bits processed.

Implements e57::BitpackDecoder.

References e57::binaryString(), e57::E57_ERROR_INTERNAL, and e57::toString().

Member Data Documentation

◆ bitsPerRecord_

template<typename RegisterT >
unsigned e57::BitpackIntegerDecoder< RegisterT >::bitsPerRecord_
protected

◆ destBitMask_

template<typename RegisterT >
RegisterT e57::BitpackIntegerDecoder< RegisterT >::destBitMask_
protected

◆ isScaledInteger_

template<typename RegisterT >
bool e57::BitpackIntegerDecoder< RegisterT >::isScaledInteger_
protected

◆ maximum_

template<typename RegisterT >
int64_t e57::BitpackIntegerDecoder< RegisterT >::maximum_
protected

◆ minimum_

template<typename RegisterT >
int64_t e57::BitpackIntegerDecoder< RegisterT >::minimum_
protected

◆ offset_

template<typename RegisterT >
double e57::BitpackIntegerDecoder< RegisterT >::offset_
protected

◆ scale_

template<typename RegisterT >
double e57::BitpackIntegerDecoder< RegisterT >::scale_
protected

The documentation for this class was generated from the following files: