Top Description Inners Fields Constructors Methods
org.apache.pdfbox.filter

pack-priv final Class CCITTFaxDecoderStream

extends FilterInputStream
Class Inheritance
Imports
java.io.EOFException, .FilterInputStream, .IOException, .InputStream, java.util.Arrays

CCITT Modified Huffman RLE, Group 3 (T4) and Group 4 (T6) fax compression.
Authors
Harald Kuhr, Oliver Schmidtmer, last modified by $Author: haraldk$
Version
$Id: CCITTFaxDecoderStream.java,v 1.0 23.05.12 15:55 haraldk Exp$ Taken from commit 24c6682236e5a02151359486aa4075ddc5ab1534 of 18.08.2018 from twelvemonkeys/imageio/plugins/tiff/CCITTFaxDecoderStream.java Initial changes for PDFBox, discussed in PDFBOX-3338: - removed Validate() usages - catch VALUE_EOL in decode1D()

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
pack-priv static final short[][]
pack-priv static final short[][]
pack-priv static final CCITTFaxDecoderStream.Tree
pack-priv int
pack-priv int
private int[]
private int
private int[]
private int
pack-priv static final CCITTFaxDecoderStream.Tree
private final int
private int
private int
private final byte[]
pack-priv static final CCITTFaxDecoderStream.Node
pack-priv static final CCITTFaxDecoderStream.Tree
pack-priv static final CCITTFaxDecoderStream.Node
private int
private final boolean
private final boolean
private final boolean
private final boolean
private final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
public static final short[][]
public static final short[][]
pack-priv static final CCITTFaxDecoderStream.Tree
Inherited from java.io.FilterInputStream:
in

Constructor Summary

AccessConstructor and Description
public
CCITTFaxDecoderStream(final InputStream
the compressed CCITT stream.
stream
,
final int
the number of columns in the stream.
columns
,
final int
the type of stream, must be one of COMPRESSION_CCITT_MODIFIED_HUFFMAN_RLE, COMPRESSION_CCITT_T4 or COMPRESSION_CCITT_T6.
type
,
final long
CCITT T.4 or T.6 options.
options
,
final boolean
enable byte alignment used in PDF files (EncodedByteAlign).
byteAligned
)

Creates a CCITTFaxDecoderStream.

Method Summary

Modifier and TypeMethod and Description
private void
private void
private void
private void
private void
private void
private int
private void
private int
getNextChangingElement(final int a0, final boolean white)

public boolean
markSupported()

Overrides java.io.FilterInputStream.markSupported.

Tests if this input stream supports the mark and reset methods.

public int
read()

Overrides java.io.FilterInputStream.read.

Reads the next byte of data from the input stream.

public int
read(byte[]
the buffer into which the data is read.
b
,
int
the start offset in array b at which the data is written.
off
,
int
the maximum number of bytes to read.
len
)

Overrides java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes.

private boolean
public synchronized void
reset()

Overrides java.io.FilterInputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.

private void
public long
skip(long
the number of bytes to be skipped.
n
)

Overrides java.io.FilterInputStream.skip.

Skips over and discards n bytes of data from the input stream.

Inherited from java.io.FilterInputStream:
availableclosemarkread

Field Detail

BLACK_CODESback to summary
pack-priv static final short[][] BLACK_CODES
BLACK_RUN_LENGTHSback to summary
pack-priv static final short[][] BLACK_RUN_LENGTHS
blackRunTreeback to summary
pack-priv static final CCITTFaxDecoderStream.Tree blackRunTree
bufferback to summary
pack-priv int buffer
bufferPosback to summary
pack-priv int bufferPos
changesCurrentRowback to summary
private int[] changesCurrentRow
changesCurrentRowCountback to summary
private int changesCurrentRowCount
changesReferenceRowback to summary
private int[] changesReferenceRow
changesReferenceRowCountback to summary
private int changesReferenceRowCount
codeTreeback to summary
pack-priv static final CCITTFaxDecoderStream.Tree codeTree
columnsback to summary
private final int columns
decodedLengthback to summary
private int decodedLength
decodedPosback to summary
private int decodedPos
decodedRowback to summary
private final byte[] decodedRow
EOLback to summary
pack-priv static final CCITTFaxDecoderStream.Node EOL
eolOnlyTreeback to summary
pack-priv static final CCITTFaxDecoderStream.Tree eolOnlyTree
FILLback to summary
pack-priv static final CCITTFaxDecoderStream.Node FILL
lastChangingElementback to summary
private int lastChangingElement
optionByteAlignedback to summary
private final boolean optionByteAligned
optionG32Dback to summary
private final boolean optionG32D
optionG3Fillback to summary
private final boolean optionG3Fill
optionUncompressedback to summary
private final boolean optionUncompressed
typeback to summary
private final int type
VALUE_EOLback to summary
pack-priv static final int VALUE_EOL
VALUE_FILLback to summary
pack-priv static final int VALUE_FILL
VALUE_HMODEback to summary
pack-priv static final int VALUE_HMODE
VALUE_PASSMODEback to summary
pack-priv static final int VALUE_PASSMODE
WHITE_CODESback to summary
public static final short[][] WHITE_CODES
WHITE_RUN_LENGTHSback to summary
public static final short[][] WHITE_RUN_LENGTHS
whiteRunTreeback to summary
pack-priv static final CCITTFaxDecoderStream.Tree whiteRunTree

Constructor Detail

CCITTFaxDecoderStreamback to summary
public CCITTFaxDecoderStream(final InputStream stream, final int columns, final int type, final long options, final boolean byteAligned)

Creates a CCITTFaxDecoderStream. This constructor may be used for CCITT streams embedded in PDF files, which use EncodedByteAlign.

Parameters
stream:InputStream

the compressed CCITT stream.

columns:int

the number of columns in the stream.

type:int

the type of stream, must be one of COMPRESSION_CCITT_MODIFIED_HUFFMAN_RLE, COMPRESSION_CCITT_T4 or COMPRESSION_CCITT_T6.

options:long

CCITT T.4 or T.6 options.

byteAligned:boolean

enable byte alignment used in PDF files (EncodedByteAlign).

Method Detail

decode1Dback to summary
private void decode1D() throws IOException
decode2Dback to summary
private void decode2D() throws IOException
decodeRowback to summary
private void decodeRow() throws IOException
decodeRowType2back to summary
private void decodeRowType2() throws IOException
decodeRowType4back to summary
private void decodeRowType4() throws IOException
decodeRowType6back to summary
private void decodeRowType6() throws IOException
decodeRunback to summary
private int decodeRun(final CCITTFaxDecoderStream.Tree tree) throws IOException
fetchback to summary
private void fetch() throws IOException
getNextChangingElementback to summary
private int getNextChangingElement(final int a0, final boolean white)
markSupportedback to summary
public boolean markSupported()

Overrides java.io.FilterInputStream.markSupported.

Doc from java.io.FilterInputStream.markSupported.

Tests if this input stream supports the mark and reset methods.

Returns:boolean

true if this stream type supports the mark and reset method; false otherwise.

Annotations
@Override
readback to summary
public int read() throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned.

Parameters
b:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readBitback to summary
private boolean readBit() throws IOException
resetback to summary
public synchronized void reset() throws IOException

Overrides java.io.FilterInputStream.reset.

Doc from java.io.FilterInputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.

Stream marks are intended to be used in situations where you need to read ahead a little to see what's in the stream. Often this is most easily done by invoking some general parser. If the stream is of the type handled by the parse, it just chugs along happily. If the stream is not of that type, the parser should toss an exception when it fails. If this happens within readlimit bytes, it allows the outer code to reset the stream and try another parser.

Annotations
@Override
Exceptions
IOException:
if this stream has not been marked or if the mark has been invalidated.
resetBufferback to summary
private void resetBuffer()
skipback to summary
public long skip(long n) throws IOException

Overrides java.io.FilterInputStream.skip.

Doc from java.io.FilterInputStream.skip.

Skips over and discards n bytes of data from the input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned.

Parameters
n:long

the number of bytes to be skipped.

Returns:long

the actual number of bytes skipped.

Annotations
@Override
Exceptions
IOException:
if in.skip(n) throws an IOException.
org.apache.pdfbox.filter back to summary

private final Class CCITTFaxDecoderStream.Node

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv boolean
pack-priv boolean
pack-priv CCITTFaxDecoderStream.Node
pack-priv CCITTFaxDecoderStream.Node
pack-priv int

Constructor Summary

AccessConstructor and Description
private
Node()

Method Summary

Modifier and TypeMethod and Description
pack-priv void
set(final boolean next, final CCITTFaxDecoderStream.Node node)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

pack-priv CCITTFaxDecoderStream.Node
walk(final boolean next)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

canBeFillback to summary
pack-priv boolean canBeFill
isLeafback to summary
pack-priv boolean isLeaf
leftback to summary
pack-priv CCITTFaxDecoderStream.Node left
rightback to summary
pack-priv CCITTFaxDecoderStream.Node right
valueback to summary
pack-priv int value

Constructor Detail

Nodeback to summary
private Node()

Method Detail

setback to summary
pack-priv void set(final boolean next, final CCITTFaxDecoderStream.Node node)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
walkback to summary
pack-priv CCITTFaxDecoderStream.Node walk(final boolean next)
org.apache.pdfbox.filter back to summary

private final Class CCITTFaxDecoderStream.Tree

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final CCITTFaxDecoderStream.Node

Constructor Summary

AccessConstructor and Description
private
Tree()

Method Summary

Modifier and TypeMethod and Description
pack-priv void
fill(final int depth, final int path, final int value)

pack-priv void
fill(final int depth, final int path, final CCITTFaxDecoderStream.Node node)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

rootback to summary
pack-priv final CCITTFaxDecoderStream.Node root

Constructor Detail

Treeback to summary
private Tree()

Method Detail

fillback to summary
pack-priv void fill(final int depth, final int path, final int value) throws IOException
fillback to summary
pack-priv void fill(final int depth, final int path, final CCITTFaxDecoderStream.Node node) throws IOException