Slim numerical data compression 1.0
Public Member Functions | Private Member Functions | Private Attributes
ibitstream Class Reference

Input bit stream. More...

Inheritance diagram for ibitstream:
bitstream

List of all members.

Public Member Functions

 ibitstream (FILE *file, int buffersize=DEFAULT_IOBUFFER_SIZE)
 Start ibitstream using a FILE ptr to an open file.
 ibitstream (const char *filename, int buffersize=DEFAULT_IOBUFFER_SIZE)
 Start inputbitstream by filename.
 ~ibitstream ()
 Destructor only uses base class destructor.
void setupstream ()
 Allocate a buffer and set up all pointers, then fill buffer.
void windup ()
 Put the current word to the buffer with upper 0 bits as needed.
virtual void print () const
 Print buffer contents.
virtual int get_bytes_used ()
 Return the number of bytes used so far in this stream.
Word_t readbits (int nbits)
 Read data from the buffer as unsigned ints.
int32_t readbits_int (int nbits)
 Read data from the buffer as (signed) ints.
Word_t read_unary ()
 Read a single unary-coded value.
int readstring (char *s, int count=-1)
 Read a null-terminated string of 8-bit characters from the bit stream.

Private Member Functions

void next_word ()
 Move to next word in buffer, refilling it if needed.
int fill ()
 Fill the read buffer and reset for more data.

Private Attributes

Word_t partial_word
int partial_word_bitptr

Detailed Description

Input bit stream.

Allows you to read data N bits at a time with buffered reading.


Member Function Documentation

int ibitstream::fill ( ) [private]

Fill the read buffer and reset for more data.

Returns:
Bytes read from disk.

References bitstream::beyondbuffer, bitstream::bitptr, bitstream::buf_used, bitstream::buffer_base, bitstream::buffptr, bitstream::bufsize, and bitstream::fp.

Referenced by next_word(), and setupstream().

Word_t ibitstream::read_unary ( )

Read a single unary-coded value.

Returns:
The unary-coded value from the stream.

References readbits().

Referenced by mexp_golomb_read_u32().

Word_t ibitstream::readbits ( int  n_bits)

Read data from the buffer as unsigned ints.

Parameters:
n_bitsNumber of bits to use
Returns:
Data read (in the lowest n_bits bits).

References bitstream::bitptr, bitstream::Bits_per_word, bitstream::buffptr, and next_word().

Referenced by mexp_golomb_read_u32(), read_unary(), readbits_int(), readstring(), and windup().

int ibitstream::readbits_int ( int  n_bits)

Read data from the buffer as (signed) ints.

Parameters:
n_bitsNumber of bits to read.
Returns:
The data read from the stream.

References readbits().

int ibitstream::readstring ( char *  s,
int  count = -1 
)

Read a null-terminated string of 8-bit characters from the bit stream.

Parameters:
sPointer to the string (must be available memory).
countMaximum size of the string.
Returns:
Number of chars read (including null).

References readbits().


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