Slim numerical data compression 1.0
|
Output bit stream. More...
Public Member Functions | |
obitstream (FILE *file, int buffersize=DEFAULT_IOBUFFER_SIZE) | |
Start obitstream using a FILE ptr to an open file. | |
obitstream (const char *filename, int buffersize=DEFAULT_IOBUFFER_SIZE) | |
Start outputbitstream by filename. | |
void | writebits (uint32_t data, int nbits) |
Write data to the buffer. | |
void | writestring (const char *str, bool write_trailing_null=false) |
Write 8-bit character strings to the buffer. | |
template<typename T > | |
void | writeword (const T data) |
Write all the bits of a word. | |
void | write_unary (unsigned int value) |
Write a unary code for the value. | |
virtual void | print () const |
Print buffer contents. | |
virtual void | close () |
Close the output stream by flushing and closing the FILE *. | |
void | windup () |
Put the current word to the buffer with upper 0 bits as needed. | |
void | flush (bool flush_trailing_bits) |
Flush the write buffer and reset for more data. |
Output bit stream.
Allows you to write data one bit at a time with buffered writing.
void obitstream::flush | ( | bool | flush_trailing_bits | ) |
Flush the write buffer and reset for more data.
Do we need to flush even the partial words, as at EOF?
References bitstream::bitptr, bitstream::buf_used, bitstream::buffer_base, bitstream::buffptr, and bitstream::fp.
Referenced by close(), and writebits().
void obitstream::write_unary | ( | unsigned int | value | ) |
Write a unary code for the value.
Code will be (value) 1s followed by a zero. Since low-order bits are "first" in our convention, this means that the code for 4 is the 5-bit value 01111, interpreted by the reader as 1,1,1,1,0.
value | The value to be coded. |
The length of the code for (value) is 1+value bits.
References bitstream::Bits_per_word, and writebits().
Referenced by mexp_golomb_write().
void obitstream::writebits | ( | uint32_t | data32, |
int | nbits | ||
) |
Write data to the buffer.
nbits | Number of bits to use |
data | Data to write (in the lowest nbits bits). |
References bitstream::beyondbuffer, bitstream::bitptr, bitstream::Bits_per_word, bitstream::buffptr, and flush().
Referenced by mexp_golomb_write(), windup(), write_unary(), writestring(), and writeword().
void obitstream::writestring | ( | const char * | str, |
bool | write_trailing_null = false |
||
) |
Write 8-bit character strings to the buffer.
str | The string to write. 0-terminated |
write_trailing_null | Whether to put the 0 terminator to the output. |
References writebits().
template void obitstream::writeword< uint32_t > | ( | const T | data | ) |
Write all the bits of a word.
Instantiation for several types.
data | The word to write. |
References writebits().