Package org.apache.pdfbox.jbig2.segments
Class SymbolDictionary
- java.lang.Object
-
- org.apache.pdfbox.jbig2.segments.SymbolDictionary
-
- All Implemented Interfaces:
Dictionary
,SegmentData
public class SymbolDictionary extends java.lang.Object implements Dictionary
This class represents the data of segment type "Symbol dictionary". Parsing is described in 7.4.2.1.1 - 7.4.1.1.5 and decoding procedure is described in 6.5.
-
-
Field Summary
Fields Modifier and Type Field Description private HuffmanTable
aggInstTable
private int
amountOfDecodedSymbols
private int
amountOfExportSymbolss
Number of exported symbols, 7.4.2.1.4private int
amountOfImportedSymbolss
private int
amountOfNewSymbols
Number of new symbols, 7.4.2.1.5private ArithmeticDecoder
arithmeticDecoder
private HuffmanTable
bmSizeTable
private CX
cx
private CX
cxIAAI
private CX
cxIADH
private CX
cxIADT
private CX
cxIADW
private CX
cxIAEX
protected CX
cxIAID
private CX
cxIARDX
private CX
cxIARDY
private HuffmanTable
dhTable
User-supplied tables *private HuffmanTable
dwTable
private java.util.ArrayList<Bitmap>
exportSymbols
Return value of that segmentprivate GenericRefinementRegion
genericRefinementRegion
private GenericRegion
genericRegion
private ArithmeticIntegerDecoder
iDecoder
private java.util.ArrayList<Bitmap>
importSymbols
private boolean
isCodingContextRetained
private boolean
isCodingContextUsed
private boolean
isHuffmanEncoded
private Bitmap[]
newSymbols
private java.util.ArrayList<Bitmap>
sbSymbols
private int
sbSymCodeLen
private short[]
sdATX
Symbol dictionary AT flags, 7.4.2.1.2private short[]
sdATY
private short
sdHuffAggInstanceSelection
private short
sdHuffBMSizeSelection
private short
sdHuffDecodeHeightSelection
private short
sdHuffDecodeWidthSelection
private short[]
sdrATX
Symbol dictionary refinement AT flags, 7.4.2.1.3private short[]
sdrATY
private short
sdrTemplate
Symbol dictionary flags, 7.4.2.1.1private byte
sdTemplate
private SegmentHeader
segmentHeader
Further parametersprivate SubInputStream
subInputStream
private TextRegion
textRegion
private boolean
useRefinementAggregation
-
Constructor Summary
Constructors Constructor Description SymbolDictionary()
SymbolDictionary(SubInputStream subInputStream, SegmentHeader segmentHeader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addSymbol(Region region)
private void
checkInput()
private void
decodeAggregate(int symbolWidth, int heightClassHeight)
private long
decodeDifferenceWidth()
private void
decodeDirectlyThroughGenericRegion(int symWidth, int hcHeight)
private void
decodeHeightClassBitmap(Bitmap heightClassCollectiveBitmap, int heightClassFirstSymbol, int heightClassHeight, int[] newSymbolsWidths)
private Bitmap
decodeHeightClassCollectiveBitmap(long bmSize, int heightClassHeight, int totalWidth)
private long
decodeHeightClassDeltaHeight()
private long
decodeHeightClassDeltaHeightWithHuffman()
6.5.6 if isHuffmanEncodedprivate void
decodeNewSymbols(int symWidth, int hcHeight, Bitmap ibo, int rdx, int rdy)
private void
decodeRefinedSymbol(int symbolWidth, int heightClassHeight)
private void
decodeThroughTextRegion(int symbolWidth, int heightClassHeight, long amountOfRefinementAggregationInstances)
java.util.ArrayList<Bitmap>
getDictionary()
6.5.5 Decoding the symbol dictionaryprivate int
getSbSymCodeLen()
6.5.8.2.3 - Setting SBSYMCODES and SBSYMCODELENprivate int[]
getToExportFlags()
private HuffmanTable
getUserTable(int tablePosition)
private long
huffDecodeBmSize()
private long
huffDecodeRefAggNInst()
void
init(SegmentHeader header, SubInputStream sis)
Parse the stream and read information of header.private void
parseHeader()
private void
readAmountOfExportedSymbols()
private void
readAmountOfNewSymbols()
private void
readAtPixels(int amountOfPixels)
private void
readRefinementAtPixels(int amountOfAtPixels)
private void
readRegionFlags()
private void
retrieveImportSymbols()
Concatenates symbols from all referred-to segments.private void
setAtPixels()
private void
setCodingStatistics()
private void
setExportedSymbols(int[] toExportFlags)
private void
setInSyms()
private void
setRefinementAtPixels()
private void
setRetainedCodingContexts(SymbolDictionary sd)
private void
setSymbolsArray()
6.5.8.2.4 - Setting SBSYMS
-
-
-
Field Detail
-
subInputStream
private SubInputStream subInputStream
-
sdrTemplate
private short sdrTemplate
Symbol dictionary flags, 7.4.2.1.1
-
sdTemplate
private byte sdTemplate
-
isCodingContextRetained
private boolean isCodingContextRetained
-
isCodingContextUsed
private boolean isCodingContextUsed
-
sdHuffAggInstanceSelection
private short sdHuffAggInstanceSelection
-
sdHuffBMSizeSelection
private short sdHuffBMSizeSelection
-
sdHuffDecodeWidthSelection
private short sdHuffDecodeWidthSelection
-
sdHuffDecodeHeightSelection
private short sdHuffDecodeHeightSelection
-
useRefinementAggregation
private boolean useRefinementAggregation
-
isHuffmanEncoded
private boolean isHuffmanEncoded
-
sdATX
private short[] sdATX
Symbol dictionary AT flags, 7.4.2.1.2
-
sdATY
private short[] sdATY
-
sdrATX
private short[] sdrATX
Symbol dictionary refinement AT flags, 7.4.2.1.3
-
sdrATY
private short[] sdrATY
-
amountOfExportSymbolss
private int amountOfExportSymbolss
Number of exported symbols, 7.4.2.1.4
-
amountOfNewSymbols
private int amountOfNewSymbols
Number of new symbols, 7.4.2.1.5
-
segmentHeader
private SegmentHeader segmentHeader
Further parameters
-
amountOfImportedSymbolss
private int amountOfImportedSymbolss
-
importSymbols
private java.util.ArrayList<Bitmap> importSymbols
-
amountOfDecodedSymbols
private int amountOfDecodedSymbols
-
newSymbols
private Bitmap[] newSymbols
-
dhTable
private HuffmanTable dhTable
User-supplied tables *
-
dwTable
private HuffmanTable dwTable
-
bmSizeTable
private HuffmanTable bmSizeTable
-
aggInstTable
private HuffmanTable aggInstTable
-
exportSymbols
private java.util.ArrayList<Bitmap> exportSymbols
Return value of that segment
-
sbSymbols
private java.util.ArrayList<Bitmap> sbSymbols
-
arithmeticDecoder
private ArithmeticDecoder arithmeticDecoder
-
iDecoder
private ArithmeticIntegerDecoder iDecoder
-
textRegion
private TextRegion textRegion
-
genericRegion
private GenericRegion genericRegion
-
genericRefinementRegion
private GenericRefinementRegion genericRefinementRegion
-
cx
private CX cx
-
cxIADH
private CX cxIADH
-
cxIADW
private CX cxIADW
-
cxIAAI
private CX cxIAAI
-
cxIAEX
private CX cxIAEX
-
cxIARDX
private CX cxIARDX
-
cxIARDY
private CX cxIARDY
-
cxIADT
private CX cxIADT
-
cxIAID
protected CX cxIAID
-
sbSymCodeLen
private int sbSymCodeLen
-
-
Constructor Detail
-
SymbolDictionary
public SymbolDictionary()
-
SymbolDictionary
public SymbolDictionary(SubInputStream subInputStream, SegmentHeader segmentHeader) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
parseHeader
private void parseHeader() throws java.io.IOException, InvalidHeaderValueException, IntegerMaxValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
IntegerMaxValueException
-
readRegionFlags
private void readRegionFlags() throws java.io.IOException
- Throws:
java.io.IOException
-
setAtPixels
private void setAtPixels() throws java.io.IOException
- Throws:
java.io.IOException
-
setRefinementAtPixels
private void setRefinementAtPixels() throws java.io.IOException
- Throws:
java.io.IOException
-
readAtPixels
private void readAtPixels(int amountOfPixels) throws java.io.IOException
- Throws:
java.io.IOException
-
readRefinementAtPixels
private void readRefinementAtPixels(int amountOfAtPixels) throws java.io.IOException
- Throws:
java.io.IOException
-
readAmountOfExportedSymbols
private void readAmountOfExportedSymbols() throws java.io.IOException
- Throws:
java.io.IOException
-
readAmountOfNewSymbols
private void readAmountOfNewSymbols() throws java.io.IOException
- Throws:
java.io.IOException
-
setInSyms
private void setInSyms() throws java.io.IOException, InvalidHeaderValueException, IntegerMaxValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
IntegerMaxValueException
-
setRetainedCodingContexts
private void setRetainedCodingContexts(SymbolDictionary sd)
-
checkInput
private void checkInput() throws InvalidHeaderValueException
- Throws:
InvalidHeaderValueException
-
getDictionary
public java.util.ArrayList<Bitmap> getDictionary() throws java.io.IOException, IntegerMaxValueException, InvalidHeaderValueException
6.5.5 Decoding the symbol dictionary- Specified by:
getDictionary
in interfaceDictionary
- Returns:
- List of decoded symbol bitmaps as an
ArrayList
- Throws:
java.io.IOException
- if an underlying IO operation failsIntegerMaxValueException
- if the maximum value limit of an integer is exceededInvalidHeaderValueException
- if the segment header value is invalid
-
setCodingStatistics
private void setCodingStatistics() throws java.io.IOException
- Throws:
java.io.IOException
-
decodeHeightClassBitmap
private final void decodeHeightClassBitmap(Bitmap heightClassCollectiveBitmap, int heightClassFirstSymbol, int heightClassHeight, int[] newSymbolsWidths) throws IntegerMaxValueException, InvalidHeaderValueException, java.io.IOException
- Throws:
IntegerMaxValueException
InvalidHeaderValueException
java.io.IOException
-
decodeAggregate
private final void decodeAggregate(int symbolWidth, int heightClassHeight) throws java.io.IOException, InvalidHeaderValueException, IntegerMaxValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
IntegerMaxValueException
-
huffDecodeRefAggNInst
private final long huffDecodeRefAggNInst() throws java.io.IOException, InvalidHeaderValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
-
decodeThroughTextRegion
private final void decodeThroughTextRegion(int symbolWidth, int heightClassHeight, long amountOfRefinementAggregationInstances) throws java.io.IOException, IntegerMaxValueException, InvalidHeaderValueException
- Throws:
java.io.IOException
IntegerMaxValueException
InvalidHeaderValueException
-
decodeRefinedSymbol
private final void decodeRefinedSymbol(int symbolWidth, int heightClassHeight) throws java.io.IOException, InvalidHeaderValueException, IntegerMaxValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
IntegerMaxValueException
-
decodeNewSymbols
private final void decodeNewSymbols(int symWidth, int hcHeight, Bitmap ibo, int rdx, int rdy) throws java.io.IOException, InvalidHeaderValueException, IntegerMaxValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
IntegerMaxValueException
-
decodeDirectlyThroughGenericRegion
private final void decodeDirectlyThroughGenericRegion(int symWidth, int hcHeight) throws java.io.IOException, IntegerMaxValueException, InvalidHeaderValueException
- Throws:
java.io.IOException
IntegerMaxValueException
InvalidHeaderValueException
-
addSymbol
private final void addSymbol(Region region) throws IntegerMaxValueException, InvalidHeaderValueException, java.io.IOException
- Throws:
IntegerMaxValueException
InvalidHeaderValueException
java.io.IOException
-
decodeDifferenceWidth
private final long decodeDifferenceWidth() throws java.io.IOException, InvalidHeaderValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
-
decodeHeightClassDeltaHeight
private final long decodeHeightClassDeltaHeight() throws java.io.IOException, InvalidHeaderValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
-
decodeHeightClassDeltaHeightWithHuffman
private final long decodeHeightClassDeltaHeightWithHuffman() throws java.io.IOException, InvalidHeaderValueException
6.5.6 if isHuffmanEncoded- Returns:
- long - Result of decoding HCDH
- Throws:
java.io.IOException
InvalidHeaderValueException
-
decodeHeightClassCollectiveBitmap
private final Bitmap decodeHeightClassCollectiveBitmap(long bmSize, int heightClassHeight, int totalWidth) throws java.io.IOException
- Throws:
java.io.IOException
-
setExportedSymbols
private void setExportedSymbols(int[] toExportFlags)
-
getToExportFlags
private int[] getToExportFlags() throws java.io.IOException, InvalidHeaderValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
-
huffDecodeBmSize
private final long huffDecodeBmSize() throws java.io.IOException, InvalidHeaderValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
-
getSbSymCodeLen
private int getSbSymCodeLen() throws java.io.IOException
6.5.8.2.3 - Setting SBSYMCODES and SBSYMCODELEN- Returns:
- Result of computing SBSYMCODELEN
- Throws:
java.io.IOException
-
setSymbolsArray
private final void setSymbolsArray() throws java.io.IOException, InvalidHeaderValueException, IntegerMaxValueException
6.5.8.2.4 - Setting SBSYMS- Throws:
java.io.IOException
InvalidHeaderValueException
IntegerMaxValueException
-
retrieveImportSymbols
private void retrieveImportSymbols() throws java.io.IOException, InvalidHeaderValueException, IntegerMaxValueException
Concatenates symbols from all referred-to segments.- Throws:
java.io.IOException
InvalidHeaderValueException
IntegerMaxValueException
-
getUserTable
private HuffmanTable getUserTable(int tablePosition) throws InvalidHeaderValueException, java.io.IOException
- Throws:
InvalidHeaderValueException
java.io.IOException
-
init
public void init(SegmentHeader header, SubInputStream sis) throws InvalidHeaderValueException, IntegerMaxValueException, java.io.IOException
Description copied from interface:SegmentData
Parse the stream and read information of header.- Specified by:
init
in interfaceSegmentData
- Parameters:
header
- - The segments' header (to make referred-to segments available in data part).sis
- - WrappedImageInputStream
intoSubInputStream
.- Throws:
InvalidHeaderValueException
- if the segment header value is invalidIntegerMaxValueException
- if the maximum value limit of an integer is exceededjava.io.IOException
- if an underlying IO operation fails
-
-