Class Predictor

java.lang.Object
org.apache.pdfbox.filter.Predictor

public final class Predictor extends Object
Helper class to contain predictor decoding used by Flate and LZW filter. To see the history, look at the FlateFilter class.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static final class 
    Output stream that implements predictor decoding.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static int
    calcSetBitSeq(int by, int startBit, int bitSize, int val)
     
    (package private) static int
    calculateRowLength(int colors, int bitsPerComponent, int columns)
     
    (package private) static void
    decodePredictorRow(int predictor, int colors, int bitsPerComponent, int columns, byte[] actline, byte[] lastline)
    Decodes a single line of data in-place.
    (package private) static int
    getBitSeq(int by, int startBit, int bitSize)
     
    (package private) static OutputStream
    Wraps and OutputStream in a predictor decoding stream as necessary.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Predictor

      private Predictor()
  • Method Details

    • decodePredictorRow

      static void decodePredictorRow(int predictor, int colors, int bitsPerComponent, int columns, byte[] actline, byte[] lastline)
      Decodes a single line of data in-place.
      Parameters:
      predictor - Predictor value for the current line
      colors - Number of color components, from decode parameters.
      bitsPerComponent - Number of bits per components, from decode parameters.
      columns - Number samples in a row, from decode parameters.
      actline - Current (active) line to decode. Data will be decoded in-place, i.e. - the contents of this buffer will be modified.
      lastline - The previous decoded line. When decoding the first line, this parameter should be an empty byte array of the same length as actline.
    • calculateRowLength

      static int calculateRowLength(int colors, int bitsPerComponent, int columns)
    • getBitSeq

      static int getBitSeq(int by, int startBit, int bitSize)
    • calcSetBitSeq

      static int calcSetBitSeq(int by, int startBit, int bitSize, int val)
    • wrapPredictor

      static OutputStream wrapPredictor(OutputStream out, COSDictionary decodeParams)
      Wraps and OutputStream in a predictor decoding stream as necessary. If no predictor is specified by the parameters, the original stream is returned as is.
      Parameters:
      out - The stream to which decoded data should be written
      decodeParams - Decode parameters for the stream
      Returns:
      An OutputStream is returned, which will write decoded data into the given stream. If no predictor is specified, the original stream is returned.