#include <sys/types.h>
#include "globals.h"
typedef struct _bstreambuf BStream |
Stream buffer for bit input / output.
int BFclose | ( | BFile * | stream | ) |
Closes a bit input / output file buffer.
If this is an output buffer, it is flushed before closing.
stream | The file buffer to close. |
References BFflush(), _bfilebuf::fd, and _bfilebuf::mode.
Referenced by compress_reversed_index(), compute_code_lengths(), decode_check_huff(), and decompress_check_reversed_index().
int BFflush | ( | BFile * | stream | ) |
Flushes a bit input / output file buffer.
In the case of an output file buffer, the buffer is flushed, even an incomplete byte (so the next one begins at a new byte). In the case of an input file buffer, the buffer skips to the next input byte.
stream | The file buffer to flush. |
References _bfilebuf::bits_in_buf, _bfilebuf::buf, _bfilebuf::fd, _bfilebuf::mode, and _bfilebuf::position.
Referenced by BFclose(), compress_reversed_index(), compute_code_lengths(), decode_check_huff(), and decompress_check_reversed_index().
int BFopen | ( | char * | filename, | |
char * | type, | |||
BFile * | bf | |||
) |
Opens a file for bit input / output.
Sets up a bit input/output file buffer (BF)
filename | Name of file to open | |
type | File-open mode string: "w" or "r" accepted | |
bf | Buffer in which to set up the opened BF |
References _bfilebuf::bits_in_buf, _bfilebuf::buf, _bfilebuf::fd, _bfilebuf::mode, and _bfilebuf::position.
Referenced by compress_reversed_index(), compute_code_lengths(), decode_check_huff(), and decompress_check_reversed_index().
int BFposition | ( | BFile * | stream | ) |
Gets the stream position of a BFile.
References _bfilebuf::position.
Referenced by compress_reversed_index(), compute_code_lengths(), and decode_check_huff().
int BFread | ( | unsigned char * | data, | |
int | nbits, | |||
BFile * | stream | |||
) |
Read bit data from a file via a BFile buffer.
NOTE: be sure that you read the data into an unsigned char!
data | Pointer to the location for the read bit data. | |
nbits | Number of bits to read. | |
stream | The BFile buffer to use. |
References _bfilebuf::bits_in_buf, _bfilebuf::buf, _bfilebuf::fd, and _bfilebuf::position.
Referenced by BFreadWord(), decode_check_huff(), and read_golomb_code_bf().
int BFreadWord | ( | unsigned int * | data, | |
int | nbits, | |||
BFile * | stream | |||
) |
Reads bit data from a file into an unsigned int.
This function reads nbits into an unsigned int, padded to the right.
data | Pointer to the location for the read bit data. | |
nbits | Number of bits to read. | |
stream | The BFile buffer to use. |
int BFwrite | ( | unsigned char | data, | |
int | nbits, | |||
BFile * | stream | |||
) |
Writes bit data to file via a BFile buffer.
Bits accumulate in the buffer till there are 8 of them. Then a byte is written to file (as an unsigned char).
data | The data to write. | |
nbits | The number of bits to write from data. | |
stream | The buffer to write via. |
References _bfilebuf::bits_in_buf, _bfilebuf::buf, _bfilebuf::fd, and _bfilebuf::position.
Referenced by BFwriteWord(), and write_golomb_code().
int BFwriteWord | ( | unsigned int | data, | |
int | nbits, | |||
BFile * | stream | |||
) |
Writes bit data to a file from an unsigned int.
This function writes nbits from an unsigned int, padded to the right.
data | The data to write. | |
nbits | Number of bits to write. | |
stream | The BFile buffer to use. |
References BFwrite(), and bytes.
Referenced by compute_code_lengths(), and write_golomb_code().
int BSclose | ( | BStream * | stream | ) |
Closes a bit input / output stream buffer.
If this is an output buffer, it is flushed before closing.
stream | The stream buffer to close. |
References _bstreambuf::base, BSflush(), and _bstreambuf::mode.
Referenced by ClosePositionStream(), get_id_at_position(), and get_positions().
int BSflush | ( | BStream * | stream | ) |
Flushes a bit input / output stream buffer.
In the case of an output stream, the stream is flushed, even an incomplete byte (so the next one begins at a new byte). In the case of an input stream, the stream skips to the next input byte.
stream | The stream to flush. |
References _bstreambuf::base, _bstreambuf::bits_in_buf, _bstreambuf::buf, _bstreambuf::mode, and _bstreambuf::position.
Referenced by BSclose().
int BSopen | ( | unsigned char * | base, | |
char * | type, | |||
BStream * | bf | |||
) |
Creates a stream buffer for bit input / output.
Sets up a bit input/output stream buffer (BS)
base | Pointer to the stream | |
type | Mode-string: "w" or "r" accepted | |
bf | Buffer in which to set up the opened BS |
References _bstreambuf::base, _bstreambuf::bits_in_buf, _bstreambuf::buf, _bstreambuf::mode, and _bstreambuf::position.
Referenced by get_id_at_position(), get_positions(), and OpenPositionStream().
int BSposition | ( | BStream * | stream | ) |
Gets the stream position of a BStream.
References _bstreambuf::position.
int BSread | ( | unsigned char * | data, | |
int | nbits, | |||
BStream * | stream | |||
) |
Read bit data from a stream via a BStream buffer.
NOTE: be sure that you read the data into an unsigned char!
data | Pointer to the location for the read bit data. | |
nbits | Number of bits to read. | |
stream | The BStream buffer to use. |
References _bstreambuf::base, _bstreambuf::bits_in_buf, _bstreambuf::buf, and _bstreambuf::position.
Referenced by get_id_at_position(), and read_golomb_code_bs().
int BSseek | ( | BStream * | stream, | |
off_t | offset | |||
) |
Moves the position marker of a BStream (clearing the bit buffer in the process).
stream | The stream whose position marker is changed. | |
offset | The desired new offset. |
References _bstreambuf::bits_in_buf, _bstreambuf::buf, and _bstreambuf::position.
Referenced by get_id_at_position(), get_positions(), and OpenPositionStream().
int BSwrite | ( | unsigned char | data, | |
int | nbits, | |||
BStream * | stream | |||
) |
Writes bit data to a character stream via a BStream buffer.
Bits accumulate in the buffer till there are 8 of them. Then a byte is written to the stream (as an unsigned char).
data | The data to write. | |
nbits | The number of bits to write from data. | |
stream | The buffer to write via. |
References _bstreambuf::base, _bstreambuf::bits_in_buf, _bstreambuf::buf, and _bstreambuf::position.