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 HuffmanTableaggInstTableprivate intamountOfDecodedSymbolsprivate intamountOfExportSymbolssNumber of exported symbols, 7.4.2.1.4private intamountOfImportedSymbolssprivate intamountOfNewSymbolsNumber of new symbols, 7.4.2.1.5private ArithmeticDecoderarithmeticDecoderprivate HuffmanTablebmSizeTableprivate CXcxprivate CXcxIAAIprivate CXcxIADHprivate CXcxIADTprivate CXcxIADWprivate CXcxIAEXprotected CXcxIAIDprivate CXcxIARDXprivate CXcxIARDYprivate HuffmanTabledhTableUser-supplied tables *private HuffmanTabledwTableprivate java.util.ArrayList<Bitmap>exportSymbolsReturn value of that segmentprivate GenericRefinementRegiongenericRefinementRegionprivate GenericRegiongenericRegionprivate ArithmeticIntegerDecoderiDecoderprivate java.util.ArrayList<Bitmap>importSymbolsprivate booleanisCodingContextRetainedprivate booleanisCodingContextUsedprivate booleanisHuffmanEncodedprivate Bitmap[]newSymbolsprivate java.util.ArrayList<Bitmap>sbSymbolsprivate intsbSymCodeLenprivate short[]sdATXSymbol dictionary AT flags, 7.4.2.1.2private short[]sdATYprivate shortsdHuffAggInstanceSelectionprivate shortsdHuffBMSizeSelectionprivate shortsdHuffDecodeHeightSelectionprivate shortsdHuffDecodeWidthSelectionprivate short[]sdrATXSymbol dictionary refinement AT flags, 7.4.2.1.3private short[]sdrATYprivate shortsdrTemplateSymbol dictionary flags, 7.4.2.1.1private bytesdTemplateprivate SegmentHeadersegmentHeaderFurther parametersprivate SubInputStreamsubInputStreamprivate TextRegiontextRegionprivate booleanuseRefinementAggregation
-
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 voidaddSymbol(Region region)private voidcheckInput()private voiddecodeAggregate(int symbolWidth, int heightClassHeight)private longdecodeDifferenceWidth()private voiddecodeDirectlyThroughGenericRegion(int symWidth, int hcHeight)private voiddecodeHeightClassBitmap(Bitmap heightClassCollectiveBitmap, int heightClassFirstSymbol, int heightClassHeight, int[] newSymbolsWidths)private BitmapdecodeHeightClassCollectiveBitmap(long bmSize, int heightClassHeight, int totalWidth)private longdecodeHeightClassDeltaHeight()private longdecodeHeightClassDeltaHeightWithHuffman()6.5.6 if isHuffmanEncodedprivate voiddecodeNewSymbols(int symWidth, int hcHeight, Bitmap ibo, int rdx, int rdy)private voiddecodeRefinedSymbol(int symbolWidth, int heightClassHeight)private voiddecodeThroughTextRegion(int symbolWidth, int heightClassHeight, long amountOfRefinementAggregationInstances)java.util.ArrayList<Bitmap>getDictionary()6.5.5 Decoding the symbol dictionaryprivate intgetSbSymCodeLen()6.5.8.2.3 - Setting SBSYMCODES and SBSYMCODELENprivate int[]getToExportFlags()private HuffmanTablegetUserTable(int tablePosition)private longhuffDecodeBmSize()private longhuffDecodeRefAggNInst()voidinit(SegmentHeader header, SubInputStream sis)Parse the stream and read information of header.private voidparseHeader()private voidreadAmountOfExportedSymbols()private voidreadAmountOfNewSymbols()private voidreadAtPixels(int amountOfPixels)private voidreadRefinementAtPixels(int amountOfAtPixels)private voidreadRegionFlags()private voidretrieveImportSymbols()Concatenates symbols from all referred-to segments.private voidsetAtPixels()private voidsetCodingStatistics()private voidsetExportedSymbols(int[] toExportFlags)private voidsetInSyms()private voidsetRefinementAtPixels()private voidsetRetainedCodingContexts(SymbolDictionary sd)private voidsetSymbolsArray()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.IOExceptionInvalidHeaderValueExceptionIntegerMaxValueException
-
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.IOExceptionInvalidHeaderValueExceptionIntegerMaxValueException
-
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:
getDictionaryin 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:
IntegerMaxValueExceptionInvalidHeaderValueExceptionjava.io.IOException
-
decodeAggregate
private final void decodeAggregate(int symbolWidth, int heightClassHeight) throws java.io.IOException, InvalidHeaderValueException, IntegerMaxValueException- Throws:
java.io.IOExceptionInvalidHeaderValueExceptionIntegerMaxValueException
-
huffDecodeRefAggNInst
private final long huffDecodeRefAggNInst() throws java.io.IOException, InvalidHeaderValueException- Throws:
java.io.IOExceptionInvalidHeaderValueException
-
decodeThroughTextRegion
private final void decodeThroughTextRegion(int symbolWidth, int heightClassHeight, long amountOfRefinementAggregationInstances) throws java.io.IOException, IntegerMaxValueException, InvalidHeaderValueException- Throws:
java.io.IOExceptionIntegerMaxValueExceptionInvalidHeaderValueException
-
decodeRefinedSymbol
private final void decodeRefinedSymbol(int symbolWidth, int heightClassHeight) throws java.io.IOException, InvalidHeaderValueException, IntegerMaxValueException- Throws:
java.io.IOExceptionInvalidHeaderValueExceptionIntegerMaxValueException
-
decodeNewSymbols
private final void decodeNewSymbols(int symWidth, int hcHeight, Bitmap ibo, int rdx, int rdy) throws java.io.IOException, InvalidHeaderValueException, IntegerMaxValueException- Throws:
java.io.IOExceptionInvalidHeaderValueExceptionIntegerMaxValueException
-
decodeDirectlyThroughGenericRegion
private final void decodeDirectlyThroughGenericRegion(int symWidth, int hcHeight) throws java.io.IOException, IntegerMaxValueException, InvalidHeaderValueException- Throws:
java.io.IOExceptionIntegerMaxValueExceptionInvalidHeaderValueException
-
addSymbol
private final void addSymbol(Region region) throws IntegerMaxValueException, InvalidHeaderValueException, java.io.IOException
- Throws:
IntegerMaxValueExceptionInvalidHeaderValueExceptionjava.io.IOException
-
decodeDifferenceWidth
private final long decodeDifferenceWidth() throws java.io.IOException, InvalidHeaderValueException- Throws:
java.io.IOExceptionInvalidHeaderValueException
-
decodeHeightClassDeltaHeight
private final long decodeHeightClassDeltaHeight() throws java.io.IOException, InvalidHeaderValueException- Throws:
java.io.IOExceptionInvalidHeaderValueException
-
decodeHeightClassDeltaHeightWithHuffman
private final long decodeHeightClassDeltaHeightWithHuffman() throws java.io.IOException, InvalidHeaderValueException6.5.6 if isHuffmanEncoded- Returns:
- long - Result of decoding HCDH
- Throws:
java.io.IOExceptionInvalidHeaderValueException
-
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.IOExceptionInvalidHeaderValueException
-
huffDecodeBmSize
private final long huffDecodeBmSize() throws java.io.IOException, InvalidHeaderValueException- Throws:
java.io.IOExceptionInvalidHeaderValueException
-
getSbSymCodeLen
private int getSbSymCodeLen() throws java.io.IOException6.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, IntegerMaxValueException6.5.8.2.4 - Setting SBSYMS- Throws:
java.io.IOExceptionInvalidHeaderValueExceptionIntegerMaxValueException
-
retrieveImportSymbols
private void retrieveImportSymbols() throws java.io.IOException, InvalidHeaderValueException, IntegerMaxValueExceptionConcatenates symbols from all referred-to segments.- Throws:
java.io.IOExceptionInvalidHeaderValueExceptionIntegerMaxValueException
-
getUserTable
private HuffmanTable getUserTable(int tablePosition) throws InvalidHeaderValueException, java.io.IOException
- Throws:
InvalidHeaderValueExceptionjava.io.IOException
-
init
public void init(SegmentHeader header, SubInputStream sis) throws InvalidHeaderValueException, IntegerMaxValueException, java.io.IOException
Description copied from interface:SegmentDataParse the stream and read information of header.- Specified by:
initin interfaceSegmentData- Parameters:
header- - The segments' header (to make referred-to segments available in data part).sis- - WrappedImageInputStreamintoSubInputStream.- 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
-
-