Class BitReader

java.lang.Object
com.itextpdf.io.codec.brotli.dec.BitReader

final class BitReader extends Object
Bit reading helpers.
  • Field Details

    • CAPACITY

      private static final int CAPACITY
      Input 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

      private final IntReader intReader
    • input

      private InputStream input
    • endOfStreamReached

      private boolean endOfStreamReached
      Input stream is finished.
    • accumulator

      long accumulator
      Pre-fetched bits.
    • bitOffset

      int bitOffset
      Current bit-reading position in accumulator.
    • intOffset

      private int intOffset
      Offset of next item in intBuffer.
    • tailBytes

      private int tailBytes
  • Constructor Details

    • BitReader

      BitReader()
  • Method Details

    • readMoreInput

      static void readMoreInput(BitReader br)
      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

      static void checkHealth(BitReader br, boolean endOfStream)
    • fillBitWindow

      static void fillBitWindow(BitReader br)
      Advances the Read buffer by 5 bytes to make room for reading next 24 bits.
    • readBits

      static int readBits(BitReader br, int n)
      Reads the specified number of bits from Read Buffer.
    • init

      static void init(BitReader br, InputStream input)
      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 POJO
      input - data source
    • prepare

      private static void prepare(BitReader br)
    • reload

      static void reload(BitReader br)
    • close

      static void close(BitReader br) throws IOException
      Throws:
      IOException
    • jumpToByteBoundary

      static void jumpToByteBoundary(BitReader br)
    • intAvailable

      static int intAvailable(BitReader br)
    • copyBytes

      static void copyBytes(BitReader br, byte[] data, int offset, int length)