C# Class CSJ2K.j2k.codestream.reader.FileBitstreamReaderAgent

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).

Inheritance: BitstreamReaderAgent
Show file Open project: cureos/csj2k

Public Properties

Property Type Description
pktDec PktDecoder

Public Methods

Method Description
FileBitstreamReaderAgent ( HeaderDecoder hd, RandomAccessIO ehs, DecoderSpecs decSpec, CSJ2K.j2k.util.ParameterList pl, bool cdstrInfo, HeaderInfo hi ) : System

Reads all tiles headers and keep offset of their first packet. Finally it calls the rate allocation method.

getCodeBlock ( int c, int m, int n, CSJ2K.j2k.wavelet.synthesis.SubbandSyn sb, int fl, int nl, CSJ2K.j2k.entropy.decoder.DecLyrdCBlk ccb ) : CSJ2K.j2k.entropy.decoder.DecLyrdCBlk

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.

getNumTileParts ( int t ) : int

Returns the number of tile-part found for a given tile

nextTile ( ) : void

Advances to the next tile, in standard scan-line order (by rows then columns). A NoNextElementException is thrown if the current tile is the last one (i.e. there is no next tile).

setTile ( int x, int y ) : void

Changes the current tile, given the new indexes. An IllegalArgumentException is thrown if the indexes do not correspond to a valid tile.

Private Methods

Method Description
allocateRate ( ) : void

Allocates output bit-rate for each tile in parsing mode: The allocator simulates the truncation of a virtual layer-resolution progressive codestream.

readCompPosResLy ( int lys, int lye, int ress, int rese, int comps, int compe ) : bool

Reads packets of the current tile according to the component-position-resolution-layer progressiveness.

readLyResCompPos ( int lys, int lye, int ress, int rese, int comps, int compe ) : bool

Reads packets of the current tile according to the layer-resolution-component-position progressiveness.

readPosCompResLy ( int lys, int lye, int ress, int rese, int comps, int compe ) : bool

Reads packets of the current tile according to the position-component-resolution-layer progressiveness.

readResLyCompPos ( int lys, int lye, int ress, int rese, int comps, int compe ) : bool

Reads packets of the current tile according to the resolution-layer-component-position progressiveness.

readResPosCompLy ( int lys, int lye, int ress, int rese, int comps, int compe ) : bool

Reads packets of the current tile according to the resolution-position-component-layer progressiveness.

readTilePartHeader ( ) : int

Reads SOT marker segment of the tile-part header and calls related methods of the HeaderDecoder to read other markers segments. The tile-part header is entirely read when a SOD marker is encountered.

readTilePkts ( int t ) : void

Finish initialization of members for specified tile, reads packets head of each tile and keeps location of each code-block's codewords. The last 2 tasks are done by calling specific methods of PktDecoder.

Then, if a parsing output rate is defined, it keeps information of first layers only. This operation simulates a creation of a layer-resolution-component progressive bit-stream which will be next truncated and decoded.

Method Details

FileBitstreamReaderAgent() public method

Reads all tiles headers and keep offset of their first packet. Finally it calls the rate allocation method.
public FileBitstreamReaderAgent ( HeaderDecoder hd, RandomAccessIO ehs, DecoderSpecs decSpec, CSJ2K.j2k.util.ParameterList pl, bool cdstrInfo, HeaderInfo hi ) : System
hd HeaderDecoder HeaderDecoder of the codestream. /// ///
ehs RandomAccessIO The input stream where to read bit-stream. /// ///
decSpec CSJ2K.j2k.decoder.DecoderSpecs The decoder specifications /// ///
pl CSJ2K.j2k.util.ParameterList The ParameterList instance created from the /// command-line arguments. /// ///
cdstrInfo bool Whether or not to print information found in /// codestream. /// ///
hi CSJ2K.j2k.codestream.HeaderInfo
return System

getCodeBlock() public method

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.

public getCodeBlock ( int c, int m, int n, CSJ2K.j2k.wavelet.synthesis.SubbandSyn sb, int fl, int nl, CSJ2K.j2k.entropy.decoder.DecLyrdCBlk ccb ) : CSJ2K.j2k.entropy.decoder.DecLyrdCBlk
c int The index of the component, from 0 to N-1. /// ///
m int The vertical index of the code-block to return, in the /// specified subband. /// ///
n int The horizontal index of the code-block to return, in the /// specified subband. /// ///
sb CSJ2K.j2k.wavelet.synthesis.SubbandSyn The subband in whic the requested code-block is. /// ///
fl int The first layer to return. /// ///
nl int The number of layers to return, if negative all available /// layers are returned, starting at 'fl'. /// ///
ccb CSJ2K.j2k.entropy.decoder.DecLyrdCBlk 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. /// ///
return CSJ2K.j2k.entropy.decoder.DecLyrdCBlk

getNumTileParts() public method

Returns the number of tile-part found for a given tile
public getNumTileParts ( int t ) : int
t int Tile index /// /// ///
return int

nextTile() public method

Advances to the next tile, in standard scan-line order (by rows then columns). A NoNextElementException is thrown if the current tile is the last one (i.e. there is no next tile).
public nextTile ( ) : void
return void

setTile() public method

Changes the current tile, given the new indexes. An IllegalArgumentException is thrown if the indexes do not correspond to a valid tile.
public setTile ( int x, int y ) : void
x int The horizontal indexes the tile. /// ///
y int The vertical indexes of the new tile. /// ///
return void

Property Details

pktDec public property

Reference to the PktDecoder instance
public PktDecoder,CSJ2K.j2k.codestream.reader pktDec
return PktDecoder