Package org.apache.pdfbox.filter
Class CCITTFaxDecoderStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.apache.pdfbox.filter.CCITTFaxDecoderStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
final class CCITTFaxDecoderStream extends java.io.FilterInputStream
CCITT Modified Huffman RLE, Group 3 (T4) and Group 4 (T6) fax compression.- 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 Class Summary
Nested Classes Modifier and Type Class Description private static class
CCITTFaxDecoderStream.Node
private static class
CCITTFaxDecoderStream.Tree
-
Field Summary
Fields Modifier and Type Field Description (package private) static short[][]
BLACK_CODES
(package private) static short[][]
BLACK_RUN_LENGTHS
(package private) static CCITTFaxDecoderStream.Tree
blackRunTree
(package private) int
buffer
(package private) int
bufferPos
private int[]
changesCurrentRow
private int
changesCurrentRowCount
private int[]
changesReferenceRow
private int
changesReferenceRowCount
(package private) static CCITTFaxDecoderStream.Tree
codeTree
private int
columns
private int
decodedLength
private int
decodedPos
private byte[]
decodedRow
(package private) static CCITTFaxDecoderStream.Node
EOL
(package private) static CCITTFaxDecoderStream.Tree
eolOnlyTree
(package private) static CCITTFaxDecoderStream.Node
FILL
private int
fillOrder
private int
lastChangingElement
private boolean
optionByteAligned
private boolean
optionG32D
private boolean
optionG3Fill
private boolean
optionUncompressed
private int
type
(package private) static int
VALUE_EOL
(package private) static int
VALUE_FILL
(package private) static int
VALUE_HMODE
(package private) static int
VALUE_PASSMODE
static short[][]
WHITE_CODES
static short[][]
WHITE_RUN_LENGTHS
(package private) static CCITTFaxDecoderStream.Tree
whiteRunTree
-
Constructor Summary
Constructors Constructor Description CCITTFaxDecoderStream(java.io.InputStream stream, int columns, int type, int fillOrder, long options)
Creates a CCITTFaxDecoderStream.CCITTFaxDecoderStream(java.io.InputStream stream, int columns, int type, int fillOrder, long options, boolean byteAligned)
Creates a CCITTFaxDecoderStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
decode1D()
private void
decode2D()
private void
decodeRow()
private void
decodeRowType2()
private void
decodeRowType4()
private void
decodeRowType6()
private int
decodeRun(CCITTFaxDecoderStream.Tree tree)
private void
fetch()
private int
getNextChangingElement(int a0, boolean white)
boolean
markSupported()
int
read()
int
read(byte[] b, int off, int len)
private boolean
readBit()
void
reset()
private void
resetBuffer()
long
skip(long n)
-
-
-
Field Detail
-
columns
private final int columns
-
decodedRow
private final byte[] decodedRow
-
optionG32D
private final boolean optionG32D
-
optionG3Fill
private final boolean optionG3Fill
-
optionUncompressed
private final boolean optionUncompressed
-
optionByteAligned
private final boolean optionByteAligned
-
fillOrder
private final int fillOrder
-
type
private final int type
-
decodedLength
private int decodedLength
-
decodedPos
private int decodedPos
-
changesReferenceRow
private int[] changesReferenceRow
-
changesCurrentRow
private int[] changesCurrentRow
-
changesReferenceRowCount
private int changesReferenceRowCount
-
changesCurrentRowCount
private int changesCurrentRowCount
-
lastChangingElement
private int lastChangingElement
-
buffer
int buffer
-
bufferPos
int bufferPos
-
BLACK_CODES
static final short[][] BLACK_CODES
-
BLACK_RUN_LENGTHS
static final short[][] BLACK_RUN_LENGTHS
-
WHITE_CODES
public static final short[][] WHITE_CODES
-
WHITE_RUN_LENGTHS
public static final short[][] WHITE_RUN_LENGTHS
-
EOL
static final CCITTFaxDecoderStream.Node EOL
-
FILL
static final CCITTFaxDecoderStream.Node FILL
-
blackRunTree
static final CCITTFaxDecoderStream.Tree blackRunTree
-
whiteRunTree
static final CCITTFaxDecoderStream.Tree whiteRunTree
-
eolOnlyTree
static final CCITTFaxDecoderStream.Tree eolOnlyTree
-
codeTree
static final CCITTFaxDecoderStream.Tree codeTree
-
VALUE_EOL
static final int VALUE_EOL
- See Also:
- Constant Field Values
-
VALUE_FILL
static final int VALUE_FILL
- See Also:
- Constant Field Values
-
VALUE_PASSMODE
static final int VALUE_PASSMODE
- See Also:
- Constant Field Values
-
VALUE_HMODE
static final int VALUE_HMODE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CCITTFaxDecoderStream
public CCITTFaxDecoderStream(java.io.InputStream stream, int columns, int type, int fillOrder, long options, boolean byteAligned)
Creates a CCITTFaxDecoderStream. This constructor may be used for CCITT streams embedded in PDF files, which use EncodedByteAlign.- Parameters:
stream
- the compressed CCITT stream.columns
- the number of columns in the stream.type
- the type of stream, must be one ofCOMPRESSION_CCITT_MODIFIED_HUFFMAN_RLE
,COMPRESSION_CCITT_T4
orCOMPRESSION_CCITT_T6
.fillOrder
- fillOrder, must beFILL_LEFT_TO_RIGHT
orFILL_RIGHT_TO_LEFT
.options
- CCITT T.4 or T.6 options.byteAligned
- enable byte alignment used in PDF files (EncodedByteAlign).
-
CCITTFaxDecoderStream
public CCITTFaxDecoderStream(java.io.InputStream stream, int columns, int type, int fillOrder, long options)
Creates a CCITTFaxDecoderStream.- Parameters:
stream
- the compressed CCITT stream.columns
- the number of columns in the stream.type
- the type of stream, must be one ofCOMPRESSION_CCITT_MODIFIED_HUFFMAN_RLE
,COMPRESSION_CCITT_T4
orCOMPRESSION_CCITT_T6
.fillOrder
- fillOrder, must beFILL_LEFT_TO_RIGHT
orFILL_RIGHT_TO_LEFT
.options
- CCITT T.4 or T.6 options.
-
-
Method Detail
-
fetch
private void fetch() throws java.io.IOException
- Throws:
java.io.IOException
-
decode1D
private void decode1D() throws java.io.IOException
- Throws:
java.io.IOException
-
decode2D
private void decode2D() throws java.io.IOException
- Throws:
java.io.IOException
-
getNextChangingElement
private int getNextChangingElement(int a0, boolean white)
-
decodeRowType2
private void decodeRowType2() throws java.io.IOException
- Throws:
java.io.IOException
-
decodeRowType4
private void decodeRowType4() throws java.io.IOException
- Throws:
java.io.IOException
-
decodeRowType6
private void decodeRowType6() throws java.io.IOException
- Throws:
java.io.IOException
-
decodeRow
private void decodeRow() throws java.io.IOException
- Throws:
java.io.IOException
-
decodeRun
private int decodeRun(CCITTFaxDecoderStream.Tree tree) throws java.io.IOException
- Throws:
java.io.IOException
-
resetBuffer
private void resetBuffer()
-
readBit
private boolean readBit() throws java.io.IOException
- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException
- Overrides:
read
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
read
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException
- Overrides:
skip
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classjava.io.FilterInputStream
-
reset
public void reset() throws java.io.IOException
- Overrides:
reset
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
-