class
BufferedBitstreamReader
Wraps a Bitstream and a DataStream.
Buffers the data from the data stream into the bit stream as required and then reads from the bitstream.
Public
Constructors
BufferedBitstreamReader
Constructs a new instance of the object.
Methods
ReadBits
Reads bits from the stream into the provided buffer from the current cursor location and advances the cursor.
- outData
- Buffer to read the data from. Must have enough capacity to store bits.
- count
- Number of bits to read.
Returns: Number of bits read.
ReadBytes
Reads bytes from the stream into the provided buffer from the current cursor location and advances the cursor.
- outData
- Buffer to read the data from. Must have enough capacity to store bytes.
- count
- Number of bytes to read.
Returns: Number of bytes read.
ReadVarInt
Decodes a 32-bit integer value encoded as a base-128 varint from the stream.
Read is performed at the current cursor location and advances the cursor. Varints are a method of serializing integers using one or more bytes, where smaller values use less bytes. Returns the number of bits written.
Skip
Skip a defined number of bits, moving the read/write cursor by this amount.
This can also be a negative value, in which case the file pointer rewinds a defined number of bits. Note the cursor can never skip past the capacity of the buffer, and will be clamped.
SkipBytes
Same as skip() except is uses number of bytes instead of number of bits as the parameter.
Seek
Repositions the read/write cursor to the specified bit.
Note the cursor can never skip past the capacity of the buffer, and will be clamped.
Tell
Returns the current read/write cursor position, in bits.
Align
Aligns the read/write cursor to a byte boundary. determines the alignment in bytes.
Note the requested alignment might not be achieved if count > 1 and it would move the cursor past the capacity of the buffer, as the cursor will be clamped to buffer end regardless of alignment.
Returns number of bits skipped due to alignment.
Preload
Preloads the specified number of bytes into the bitstream from the data stream.
ClearBuffered
Clears buffered data behind the current cursor location.
- force
- If false the buffer will only be cleared if its current size is over the maximum buffer size limit. Otherwise it will always be cleared.