Class BitReader
java.lang.Object
com.itextpdf.io.codec.brotli.dec.BitReader
Bit reading helpers.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) longPre-fetched bits.(package private) intCurrent bit-reading position in accumulator.private static final intprivate static final intprivate final byte[]private static final intInput byte buffer, consist of a ring-buffer and a "slack" region where bytes from the start of the ring-buffer are copied.private booleanInput stream is finished.private InputStreamprivate static final intprivate final int[]private intOffset of next item in intBuffer.private final IntReaderprivate static final intprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static voidcheckHealth(BitReader br, boolean endOfStream) (package private) static void(package private) static void(package private) static voidAdvances the Read buffer by 5 bytes to make room for reading next 24 bits.(package private) static voidinit(BitReader br, InputStream input) Initialize bit reader.(package private) static int(package private) static voidprivate static void(package private) static intReads the specified number of bits from Read Buffer.(package private) static voidFills up the input buffer.(package private) static void
-
Field Details
-
CAPACITY
private static final int CAPACITYInput byte buffer, consist of a ring-buffer and a "slack" region where bytes from the start of the ring-buffer are copied.- See Also:
-
SLACK
private static final int SLACK- See Also:
-
INT_BUFFER_SIZE
private static final int INT_BUFFER_SIZE- See Also:
-
BYTE_READ_SIZE
private static final int BYTE_READ_SIZE- See Also:
-
BYTE_BUFFER_SIZE
private static final int BYTE_BUFFER_SIZE- See Also:
-
byteBuffer
private final byte[] byteBuffer -
intBuffer
private final int[] intBuffer -
intReader
-
input
-
endOfStreamReached
private boolean endOfStreamReachedInput stream is finished. -
accumulator
long accumulatorPre-fetched bits. -
bitOffset
int bitOffsetCurrent bit-reading position in accumulator. -
intOffset
private int intOffsetOffset of next item in intBuffer. -
tailBytes
private int tailBytes
-
-
Constructor Details
-
BitReader
BitReader()
-
-
Method Details
-
readMoreInput
Fills up the input buffer.No-op if there are at least 36 bytes present after current position.
After encountering the end of the input stream, 64 additional zero bytes are copied to the buffer.
-
checkHealth
-
fillBitWindow
Advances the Read buffer by 5 bytes to make room for reading next 24 bits. -
readBits
Reads the specified number of bits from Read Buffer. -
init
Initialize bit reader.Initialisation turns bit reader to a ready state. Also a number of bytes is prefetched to accumulator. Because of that this method may block until enough data could be read from input.
- Parameters:
br- BitReader POJOinput- data source
-
prepare
-
reload
-
close
- Throws:
IOException
-
jumpToByteBoundary
-
intAvailable
-
copyBytes
-