ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB > Class Template Reference

A template implementing a bit stream for different data memory layouts. More...

#include <bitstream.h>

Inheritance diagram for Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >:

List of all members.

Public Member Functions

 BitStreamImpl (STREAM *stream, DisposeAfterUse::Flag disposeAfterUse=DisposeAfterUse::NO)
 Create a bit stream using this input data stream and optionally delete it on destruction.
 BitStreamImpl (STREAM &stream)
 Create a bit stream using this input data stream.
 ~BitStreamImpl ()
uint peekBit ()
 Read a bit from the bit stream, without changing the stream's position.
uint getBit ()
 Read a bit from the bit stream.
uint32 peekBits (size_t n)
 Read a multi-bit value from the bit stream, without changing the stream's position.
uint32 getBits (size_t n)
 Read a multi-bit value from the bit stream.
void addBit (uint32 &x, uint32 n)
 Add a bit to the value x, making it an n+1-bit value.
void rewind ()
 Rewind the bit stream back to the start.
void skip (uint32 n)
 Skip the specified amount of bits.
void align ()
 Skip the bits to closest data value border.
uint32 pos () const
 Return the stream position in bits.
uint32 size () const
 Return the stream size in bits.
bool eos () const

Static Public Member Functions

static bool isMSB2LSB ()

Private Member Functions

uint32 readData ()
 Read a data value.
void fillContainer (size_t min)
 Fill the container with at least min bits.
void skipBits (size_t n)
 Skip already read bits.

Static Private Member Functions

static uint32 getNBits (uint64 value, size_t n)
 Get n bits from the bit container.

Private Attributes

STREAM * _stream
 The input stream.
DisposeAfterUse::Flag _disposeAfterUse
 Should we delete the stream on destruction?
uint64 _bitContainer
 The currently available bits.
uint8 _bitsLeft
 Number of bits currently left in the bit container.
uint32 _size
 Total bitstream size (in bits).
uint32 _pos
 Current bitstream position (in bits).

Detailed Description

template<class STREAM, int valueBits, bool isLE, bool MSB2LSB>
class Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >

A template implementing a bit stream for different data memory layouts.

Such a bit stream reads valueBits-wide values from the data stream and gives access to their bits, one at a time.

For example, a bit stream with the layout parameters 32, true, false for valueBits, isLE and isMSB2LSB, reads 32bit little-endian values from the data stream and hands out the bits in the order of LSB to MSB.

Definition at line 47 of file bitstream.h.


Constructor & Destructor Documentation

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::BitStreamImpl ( STREAM *  stream,
DisposeAfterUse::Flag  disposeAfterUse = DisposeAfterUse::NO 
) [inline]

Create a bit stream using this input data stream and optionally delete it on destruction.

Definition at line 134 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::BitStreamImpl ( STREAM &  stream  )  [inline]

Create a bit stream using this input data stream.

Definition at line 144 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::~BitStreamImpl (  )  [inline]

Definition at line 153 of file bitstream.h.


Member Function Documentation

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
void Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::addBit ( uint32 x,
uint32  n 
) [inline]

Add a bit to the value x, making it an n+1-bit value.

The current value is shifted and the bit is added to the appropriate place, dependant on the stream's bitorder.

For example: A bit y is added to the value 00001100 with size 4. If the stream's bitorder is MSB2LSB, the resulting value is 0001100y. If the stream's bitorder is LSB2MSB, the resulting value is 000y1100.

Definition at line 219 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
void Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::align (  )  [inline]

Skip the bits to closest data value border.

Definition at line 251 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
bool Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::eos (  )  const [inline]

Definition at line 268 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
void Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::fillContainer ( size_t  min  )  [inline, private]

Fill the container with at least min bits.

Definition at line 80 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
uint Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::getBit (  )  [inline]

Read a bit from the bit stream.

Definition at line 166 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::getBits ( size_t  n  )  [inline]

Read a multi-bit value from the bit stream.

The value is read as if just taken as a whole from the bitstream.

For example: Reading a 4-bit value from an 8-bit bitstream with the contents 01010011: If the bitstream is MSB2LSB, the 4-bit value would be 0101. If the bitstream is LSB2MSB, the 4-bit value would be 0011.

Definition at line 197 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
static uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::getNBits ( uint64  value,
size_t  n 
) [inline, static, private]

Get n bits from the bit container.

Definition at line 106 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
static bool Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::isMSB2LSB (  )  [inline, static]

Definition at line 272 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
uint Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::peekBit (  )  [inline]

Read a bit from the bit stream, without changing the stream's position.

Definition at line 159 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::peekBits ( size_t  n  )  [inline]

Read a multi-bit value from the bit stream, without changing the stream's position.

The bit order is the same as in getBits().

Definition at line 179 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::pos (  )  const [inline]

Return the stream position in bits.

Definition at line 259 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::readData (  )  [inline, private]

Read a data value.

Definition at line 58 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
void Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::rewind (  )  [inline]

Rewind the bit stream back to the start.

Definition at line 230 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::size (  )  const [inline]

Return the stream size in bits.

Definition at line 264 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
void Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::skip ( uint32  n  )  [inline]

Skip the specified amount of bits.

Definition at line 239 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
void Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::skipBits ( size_t  n  )  [inline, private]

Skip already read bits.

Definition at line 119 of file bitstream.h.


Member Data Documentation

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
uint64 Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::_bitContainer [private]

The currently available bits.

Definition at line 52 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
uint8 Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::_bitsLeft [private]

Number of bits currently left in the bit container.

Definition at line 53 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
DisposeAfterUse::Flag Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::_disposeAfterUse [private]

Should we delete the stream on destruction?

Definition at line 50 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::_pos [private]

Current bitstream position (in bits).

Definition at line 55 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
uint32 Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::_size [private]

Total bitstream size (in bits).

Definition at line 54 of file bitstream.h.

template<class STREAM , int valueBits, bool isLE, bool MSB2LSB>
STREAM* Common::BitStreamImpl< STREAM, valueBits, isLE, MSB2LSB >::_stream [private]

The input stream.

Definition at line 49 of file bitstream.h.


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


Generated on Sat Sep 21 2019 05:03:18 for ResidualVM by doxygen 1.7.1
curved edge   curved edge