Class LSBBitReader
java.lang.Object
com.twelvemonkeys.imageio.plugins.webp.LSBBitReader
LSBBitReader
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private long
Pre-buffers up to the next 8 Bytes in input.private final ImageInputStream
private long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
peekBits
(int bits) Reads the specified number of bits from the buffer in an LSB-first way.int
readBit()
long
readBits
(int bits) Reads the specified number of bits from the stream in an LSB-first way and advances the bitOffset.private long
readBits
(int bits, boolean peek) private void
private void
-
Field Details
-
imageInput
-
bitOffset
private int bitOffset -
streamPosition
private long streamPosition -
buffer
private long bufferPre-buffers up to the next 8 Bytes in input. Contains valid bits in bits 63 tobitOffset
(inclusive).
-
-
Constructor Details
-
LSBBitReader
-
-
Method Details
-
readBits
Reads the specified number of bits from the stream in an LSB-first way and advances the bitOffset. The underlying ImageInputStream will be advanced to the first not (completely) read byte. Requesting more than 64 bits will advance the reader by the correct amount and return the lowest 64 bits of the read number- Parameters:
bits
- the number of bits to read- Returns:
- a signed long built from the requested bits (truncated to the low 64 bits)
- Throws:
IOException
- if an I/O error occurs- See Also:
-
peekBits
Reads the specified number of bits from the buffer in an LSB-first way. Does not advance the bitOffset or the underlying input stream. As only 56 bits are buffered (in the worst case) peeking more is not possible without advancing the reader and as such disallowed.- Parameters:
bits
- the number of bits to peek (max 56)- Returns:
- a signed long built from the requested bits
- Throws:
IOException
- if an I/O error occurs- See Also:
-
readBits
- Throws:
IOException
-
refillBuffer
- Throws:
IOException
-
resetBuffer
- Throws:
IOException
-
readBit
- Throws:
IOException
-