Class Predictor


  • public final class Predictor
    extends java.lang.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 class  Predictor.PredictorOutputStream
      Output stream that implements predictor decoding.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Predictor()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      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 java.io.OutputStream wrapPredictor​(java.io.OutputStream out, COSDictionary decodeParams)
      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 Detail

      • Predictor

        private Predictor()
    • Method Detail

      • 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 java.io.OutputStream wrapPredictor​(java.io.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.