org.icepdf.core.pobjects.filters
Class PredictorDecode

java.lang.Object
  extended by java.io.InputStream
      extended by org.icepdf.core.pobjects.filters.ChunkingInputStream
          extended by org.icepdf.core.pobjects.filters.PredictorDecode
All Implemented Interfaces:
java.io.Closeable

public class PredictorDecode
extends ChunkingInputStream

Predictor decoder for LZW and Flate data streams. Uses the same streaming as our other Filters but simplifies how the bytes are read in as we treat the parent (LZW or Flate) stream as a regular ChunkingInputStream.

Since:
5.0.6

Field Summary
protected  byte[] aboveBuffer
           
protected static Name BITS_PER_COMPONENT_VALUE
           
protected  int bitsPerComponent
           
protected  int bytesPerPixel
           
protected static Name COLORS_VALUE
           
protected static Name COLUMNS_VALUE
           
protected static Name DECODE_PARMS_VALUE
           
protected static Name EARLY_CHANGE_VALUE
           
protected  int numComponents
           
protected  int predictor
           
protected static int PREDICTOR_NONE
          No predictor function is used
protected static int PREDICTOR_PNG_AVG
          For current row, derive each byte from average of byte left-by-bytesPerPixel and byte above
protected static int PREDICTOR_PNG_NONE
          For current row, PNG predictor to do nothing
protected static int PREDICTOR_PNG_OPTIMUM
          When given in DecodeParms dict, in stream dict, means first byte of each row is row's predictor
protected static int PREDICTOR_PNG_PAETH
          For current row, derive each byte from non-linear function of byte left-by-bytesPerPixel and byte above and byte left-by-bytesPerPixel of above
protected static int PREDICTOR_PNG_SUB
          For current row, derive each byte from byte left-by-bytesPerPixel
protected static int PREDICTOR_PNG_UP
          For current row, derive each byte from byte above
protected static int PREDICTOR_TIFF_2
          For every row, each component is derived from corresponding component in entry to left
protected static Name PREDICTOR_VALUE
           
protected  int width
           
protected static Name WIDTH_VALUE
           
 
Fields inherited from class org.icepdf.core.pobjects.filters.ChunkingInputStream
buffer, in
 
Constructor Summary
PredictorDecode(java.io.InputStream input, Library library, java.util.HashMap entries)
           
 
Method Summary
protected  void applyPredictor(int numRead, int currPredictor)
          Apply predictor logic to buffer[] using aboveBuffer[] from previous pass.
protected  int fillInternalBuffer()
          This is only called if bufferAvailable is 0.
static boolean isPredictor(Library library, java.util.HashMap entries)
           
 
Methods inherited from class org.icepdf.core.pobjects.filters.ChunkingInputStream
available, close, fillBufferFromInputStream, fillBufferFromInputStream, mark, markSupported, read, read, read, reset, setBufferSize, setInputStream, skip, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PREDICTOR_NONE

protected static final int PREDICTOR_NONE
No predictor function is used

See Also:
Constant Field Values

PREDICTOR_TIFF_2

protected static final int PREDICTOR_TIFF_2
For every row, each component is derived from corresponding component in entry to left

See Also:
Constant Field Values

PREDICTOR_PNG_NONE

protected static final int PREDICTOR_PNG_NONE
For current row, PNG predictor to do nothing

See Also:
Constant Field Values

PREDICTOR_PNG_SUB

protected static final int PREDICTOR_PNG_SUB
For current row, derive each byte from byte left-by-bytesPerPixel

See Also:
Constant Field Values

PREDICTOR_PNG_UP

protected static final int PREDICTOR_PNG_UP
For current row, derive each byte from byte above

See Also:
Constant Field Values

PREDICTOR_PNG_AVG

protected static final int PREDICTOR_PNG_AVG
For current row, derive each byte from average of byte left-by-bytesPerPixel and byte above

See Also:
Constant Field Values

PREDICTOR_PNG_PAETH

protected static final int PREDICTOR_PNG_PAETH
For current row, derive each byte from non-linear function of byte left-by-bytesPerPixel and byte above and byte left-by-bytesPerPixel of above

See Also:
Constant Field Values

PREDICTOR_PNG_OPTIMUM

protected static final int PREDICTOR_PNG_OPTIMUM
When given in DecodeParms dict, in stream dict, means first byte of each row is row's predictor

See Also:
Constant Field Values

DECODE_PARMS_VALUE

protected static final Name DECODE_PARMS_VALUE

PREDICTOR_VALUE

protected static final Name PREDICTOR_VALUE

WIDTH_VALUE

protected static final Name WIDTH_VALUE

COLUMNS_VALUE

protected static final Name COLUMNS_VALUE

COLORS_VALUE

protected static final Name COLORS_VALUE

BITS_PER_COMPONENT_VALUE

protected static final Name BITS_PER_COMPONENT_VALUE

EARLY_CHANGE_VALUE

protected static final Name EARLY_CHANGE_VALUE

predictor

protected int predictor

numComponents

protected int numComponents

bitsPerComponent

protected int bitsPerComponent

width

protected int width

bytesPerPixel

protected int bytesPerPixel

aboveBuffer

protected byte[] aboveBuffer
Constructor Detail

PredictorDecode

public PredictorDecode(java.io.InputStream input,
                       Library library,
                       java.util.HashMap entries)
Method Detail

fillInternalBuffer

protected int fillInternalBuffer()
                          throws java.io.IOException
Description copied from class: ChunkingInputStream
This is only called if bufferAvailable is 0. Implementations should read in more data, and return how many bytes are now available

Specified by:
fillInternalBuffer in class ChunkingInputStream
Throws:
java.io.IOException

applyPredictor

protected void applyPredictor(int numRead,
                              int currPredictor)
Apply predictor logic to buffer[] using aboveBuffer[] from previous pass.

Parameters:
numRead - number of bytes read in last pass.
currPredictor - predictor to apply to buffer data.

isPredictor

public static boolean isPredictor(Library library,
                                  java.util.HashMap entries)