Class 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 Detail

      • 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
      • amountOfImportedSymbols

        private int amountOfImportedSymbols
      • importSymbols

        private java.util.ArrayList<Bitmap> importSymbols
      • amountOfDecodedSymbols

        private int amountOfDecodedSymbols
      • newSymbols

        private Bitmap[] newSymbols
      • dhTable

        private HuffmanTable dhTable
        User-supplied tables *
      • exportSymbols

        private java.util.ArrayList<Bitmap> exportSymbols
        Return value of that segment
      • sbSymbols

        private java.util.ArrayList<Bitmap> sbSymbols
      • 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

      • 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
      • adoptRetainedCodingContexts

        private void adoptRetainedCodingContexts​(SymbolDictionary sd)
        Adopt retained arithmetic coding context from another symbol dictionary. Per spec §7.4.2.2, only bitmap coding statistics (CX) are reused; configuration compatibility is validated in parseHeader() before this is called, and ArithmeticDecoder must not be reused as it is bound to the current stream.
      • validateContextValues

        private void validateContextValues​(SymbolDictionary sd)
                                    throws InvalidHeaderValueException
        The values of SDHUFF, SDREFAGG, SDTEMPLATE, SDRTEMPLATE, and all of the AT locations (both direct and refinement) for this symbol dictionary must match the corresponding values from the symbol dictionary whose context values are being used.
        Parameters:
        sd -
        Throws:
        InvalidHeaderValueException
      • checkInput

        private void checkInput()
      • resetBitmapCodingStatistics

        private void resetBitmapCodingStatistics()
        Step 4 (§7.4.2.2): Reset arithmetic coding statistics for the generic region and generic refinement region decoding procedures to zero. Only the bitmap CX is reset here; integer coder contexts are separate (step 5).
      • resetIntegerCoderStatistics

        private void resetIntegerCoderStatistics()
                                          throws java.io.IOException
        Step 5 (§7.4.2.2): Reset arithmetic coding statistics for all contexts of all arithmetic integer coders to zero.
        Throws:
        java.io.IOException
      • decodeHeightClassBitmap

        private void decodeHeightClassBitmap​(Bitmap heightClassCollectiveBitmap,
                                             int heightClassFirstSymbol,
                                             int heightClassHeight,
                                             int[] newSymbolsWidths)
      • huffDecodeRefAggNInst

        private long huffDecodeRefAggNInst()
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • decodeNewSymbols

        private void decodeNewSymbols​(int symWidth,
                                      int hcHeight,
                                      Bitmap ibo,
                                      int rdx,
                                      int rdy)
                               throws java.io.IOException
        Decodes a new symbol using the provided parameters.
        Parameters:
        symWidth - The width of the symbol.
        hcHeight - The height of the symbol.
        ibo - The input bitmap object.
        rdx - The x-offset for refinement.
        rdy - The y-offset for refinement.
        Throws:
        java.lang.IllegalStateException - if cx or arithmeticDecoder is not initialized.
        java.io.IOException - if an I/O error occurs during decoding.
      • decodeDifferenceWidth

        private long decodeDifferenceWidth()
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • decodeHeightClassDeltaHeight

        private long decodeHeightClassDeltaHeight()
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • decodeHeightClassDeltaHeightWithHuffman

        private long decodeHeightClassDeltaHeightWithHuffman()
                                                      throws java.io.IOException
        6.5.6 if isHuffmanEncoded
        Returns:
        long - Result of decoding HCDH
        Throws:
        java.io.IOException
      • decodeHeightClassCollectiveBitmap

        private Bitmap decodeHeightClassCollectiveBitmap​(long bmSize,
                                                         int heightClassHeight,
                                                         int totalWidth)
                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • setExportedSymbols

        private void setExportedSymbols​(int[] toExportFlags)
      • huffDecodeBmSize

        private long huffDecodeBmSize()
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • getSbSymCodeLen

        private int getSbSymCodeLen()
        6.5.8.2.3 - Setting SBSYMCODES and SBSYMCODELEN
        Returns:
        Result of computing SBSYMCODELEN
      • getUserTable

        private HuffmanTable getUserTable​(int tablePosition)
                                   throws java.io.IOException
        Throws:
        java.io.IOException