ScummVM API documentation
Common::BitStreamImpl< STREAM, CONTAINER, valueBits, isLE, MSB2LSB > Class Template Reference

#include <bitstream.h>

Inheritance diagram for Common::BitStreamImpl< STREAM, CONTAINER, valueBits, isLE, MSB2LSB >:
Image::Indeo::GetBits

Public Member Functions

 BitStreamImpl (STREAM *stream, DisposeAfterUse::Flag disposeAfterUse=DisposeAfterUse::NO)
 
 BitStreamImpl (STREAM &stream)
 
uint peekBit ()
 
uint getBit ()
 
template<int n>
uint32 peekBits ()
 
template<int n>
uint32 getBits ()
 
uint32 peekBits (size_t n)
 
uint32 getBits (size_t n)
 
void addBit (uint32 &x, uint32 n)
 
void rewind ()
 
void skip (uint32 n)
 
void align ()
 
uint32 pos () const
 
uint32 size () const
 
bool eos () const
 

Static Public Member Functions

static bool isMSB2LSB ()
 

Detailed Description

template<class STREAM, typename CONTAINER, int valueBits, bool isLE, bool MSB2LSB>
class Common::BitStreamImpl< STREAM, CONTAINER, 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 32-bit little-endian values from the data stream and hands out the bits in the order of LSB to MSB.

Constructor & Destructor Documentation

◆ BitStreamImpl() [1/2]

template<class STREAM , typename CONTAINER , int valueBits, bool isLE, bool MSB2LSB>
Common::BitStreamImpl< STREAM, CONTAINER, 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.

◆ BitStreamImpl() [2/2]

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

Create a bit stream using this input data stream.

Member Function Documentation

◆ peekBit()

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

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

◆ getBit()

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

Read a bit from the bit stream.

◆ peekBits() [1/2]

template<class STREAM , typename CONTAINER , int valueBits, bool isLE, bool MSB2LSB>
template<int n>
uint32 Common::BitStreamImpl< STREAM, CONTAINER, valueBits, isLE, MSB2LSB >::peekBits ( )
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().

◆ getBits() [1/2]

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

Read a multi-bit value from the bit stream.

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

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

◆ peekBits() [2/2]

template<class STREAM , typename CONTAINER , int valueBits, bool isLE, bool MSB2LSB>
uint32 Common::BitStreamImpl< STREAM, CONTAINER, 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().

◆ getBits() [2/2]

template<class STREAM , typename CONTAINER , int valueBits, bool isLE, bool MSB2LSB>
uint32 Common::BitStreamImpl< STREAM, CONTAINER, 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 bit stream.

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

◆ addBit()

template<class STREAM , typename CONTAINER , int valueBits, bool isLE, bool MSB2LSB>
void Common::BitStreamImpl< STREAM, CONTAINER, 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, depending on the stream's bit order.

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

◆ rewind()

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

Rewind the bit stream back to the start.

◆ skip()

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

Skip the specified number of bits.

◆ align()

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

Skip the bits to closest data value border.

◆ pos()

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

Return the stream position in bits.

◆ size()

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

Return the stream size in bits.


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