Class FileBitstreamReaderAgent

  • All Implemented Interfaces:
    Markers, ProgressionType, CodedCBlkDataSrcDec, StdEntropyCoderOptions, InvWTData, MultiResImgData

    public class FileBitstreamReaderAgent
    extends BitstreamReaderAgent
    implements Markers, ProgressionType, StdEntropyCoderOptions
    This class reads the bit stream (with the help of HeaderDecoder for tile headers and PktDecoder for packets header and body) and retrives location of all code-block's codewords.

    Note: All tile-parts headers are read by the constructor whereas packets are processed when decoding related tile (when setTile method is called).

    In parsing mode, the reader simulates a virtual layer-resolution progressive bit stream with the same truncation points in each code-block, whereas in truncation mode, only the first bytes are taken into account (it behaves like if it is a real truncated codestream).

    See Also:
    HeaderDecoder, PktDecoder
    • Field Detail

      • pktDec

        public PktDecoder pktDec
        Reference to the PktDecoder instance
    • Constructor Detail

      • FileBitstreamReaderAgent

        public FileBitstreamReaderAgent​(HeaderDecoder hd,
                                        RandomAccessIO ehs,
                                        DecoderSpecs decSpec,
                                        J2KImageReadParamJava j2krparam,
                                        boolean cdstrInfo,
                                        HeaderInfo hi)
                                 throws IOException
        Reads all tiles headers and keep offset of their first packet. Finally it calls the rate allocation method.
        Parameters:
        hd - HeaderDecoder of the codestream.
        ehs - The input stream where to read bit-stream.
        decSpec - The decoder specifications
        j2krparam - The J2KImageReadParam instance created from the command-line arguments.
        cdstrInfo - Whether or not to print information found in codestream.
        Throws:
        IOException
        See Also:
        allocateRate()
    • Method Detail

      • getNumTileParts

        public int getNumTileParts​(int t)
        Returns the number of tile-part found for a given tile
        Parameters:
        t - Tile index
      • getCBlkInfo

        public CBlkInfo[][][][][] getCBlkInfo()
        Gets the reference to the CBlkInfo array
      • setTile

        public void setTile​(int x,
                            int y)
        Changes the current tile, given the new indexes. An IllegalArgumentException is thrown if the indexes do not correspond to a valid tile.
        Specified by:
        setTile in interface MultiResImgData
        Specified by:
        setTile in class BitstreamReaderAgent
        Parameters:
        x - The horizontal indexes the tile.
        y - The vertical indexes of the new tile.
      • nextTile

        public void nextTile()
        Advances to the next tile, in standard scan-line order (by rows then columns). An NoNextElementException is thrown if the current tile is the last one (i.e. there is no next tile).
        Specified by:
        nextTile in interface MultiResImgData
        Specified by:
        nextTile in class BitstreamReaderAgent
      • getCodeBlock

        public DecLyrdCBlk getCodeBlock​(int c,
                                        int m,
                                        int n,
                                        SubbandSyn sb,
                                        int fl,
                                        int nl,
                                        DecLyrdCBlk ccb)
        Returns the specified coded code-block, for the specified component, in the current tile. The first layer to return is indicated by 'fl'. The number of layers that is returned depends on 'nl' and the amount of available data.

        The argument 'fl' is to be used by subsequent calls to this method for the same code-block. In this way supplemental data can be retrieved at a later time. The fact that data from more than one layer can be returned means that several packets from the same code-block, of the same component, and the same tile, have been concatenated.

        The returned compressed code-block can have its progressive attribute set. If this attribute is set it means that more data can be obtained by subsequent calls to this method (subject to transmission delays, etc). If the progressive attribute is not set it means that the returned data is all the data that can be obtained for the specified code-block.

        The compressed code-block is uniquely specified by the current tile, the component (identified by 'c'), the subband (indentified by 'sb') and the code-block vertical and horizontal indexes 'n' and 'm'.

        The 'ulx' and 'uly' members of the returned 'DecLyrdCBlk' object contain the coordinates of the top-left corner of the block, with respect to the tile, not the subband.

        Specified by:
        getCodeBlock in interface CodedCBlkDataSrcDec
        Parameters:
        c - The index of the component, from 0 to N-1.
        m - The vertical index of the code-block to return, in the specified subband.
        n - The horizontal index of the code-block to return, in the specified subband.
        sb - The subband in whic the requested code-block is.
        fl - The first layer to return.
        nl - The number of layers to return, if negative all available layers are returned, starting at 'fl'.
        ccb - If not null this object is used to return the compressed code-block. If null a new object is created and returned. If the data array in ccb is not null then it can be reused to return the compressed data.
        Returns:
        The compressed code-block, with a certain number of layers determined by the available data and 'nl'.