Class BrotliInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.jpedal.io.filter.BrotliInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class BrotliInputStream extends FilterInputStream
An input stream that decodes data from a brotli encoded data from the wrapped stream

Brotli is "...a lossless compressed data format that compresses data using a combination of the LZ77 algorithm and Huffman coding, with efficiency comparable to the best currently available general-purpose compression methods"

See Also:
  • Field Details

    • distanceRingBuffer

      public final int[] distanceRingBuffer
      Ring buffer storing past distances, used alongside SPECIAL_DISTANCES to reuse recent distances

      This gets initialized at the beginning of the stream, not at each metablock

    • distanceRingBufferPointer

      public int distanceRingBufferPointer
      Index of the last value added to the ring buffer
  • Constructor Details

    • BrotliInputStream

      public BrotliInputStream(InputStream in)
  • Method Details

    • getFromSlidingWindow

      public byte getFromSlidingWindow(int distance)
      Returns a byte from the sliding window, offset backwards from the windowWritePointer. Accounts for wrapping the sliding window.

      You will always be getting values behind the windowWritePointer, so the distance value is the backwards distance from the pointer. I.e, a value of 2 will get you the byte 2 positions behind the write pointer, or windowWritePointer - 2

      Parameters:
      distance - How far behind the windowWritePointer to get
      Returns:
      a byte from the sliding window, offset backwards from the windowWritePointer
    • read

      public int read() throws IOException
      Overrides:
      read in class FilterInputStream
      Throws:
      IOException
    • read

      public int read(byte[] b, int off, int len) throws IOException
      Overrides:
      read in class FilterInputStream
      Throws:
      IOException
    • markSupported

      public boolean markSupported()
      Overrides:
      markSupported in class FilterInputStream