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

This is the generic interface for bit stream reader agents. A bit stream reader agent is an entity that allows reading from a bit stream and requesting compressed code-blocks. It can be a simple file reader, or a network connection, or anything else.

The bit stream reader agent allows to make request for compressed block data in any order. The amount of data returned would normally depend on the data available at the time of the request, be it from a file or from a network connection.

The bit stream reader agent has the notion of a current tile, and coordinates are relative to the current tile, where applicable.

Resolution level 0 is the lowest resolution level, i.e. the LL subband alone.

Inheritance: CodedCBlkDataSrcDec
Show file Open project: cureos/csj2k Class Usage Examples

Protected Properties

Property Type Description
anbytes int
arate float
ax int
ay int
ctX int
ctY int
culx int[]
culy int[]
decSpec CSJ2K.j2k.decoder.DecoderSpecs
derived bool[]
gb int[]
hd HeaderDecoder
imgH int
imgW int
mdl int[]
nc int
nt int
ntH int
ntW int
ntX int
ntY int
offX int[]
offY int[]
params_Renamed CSJ2K.j2k.quantization.dequantizer.StdDequantizerParams[]
px int
py int
subbTrees CSJ2K.j2k.wavelet.synthesis.SubbandSyn[]
targetRes int
tnbytes int
trate float

Public Methods

Method Description
createInstance ( RandomAccessIO in_Renamed, HeaderDecoder hd, CSJ2K.j2k.util.ParameterList pl, DecoderSpecs decSpec, bool cdstrInfo, HeaderInfo hi ) : BitstreamReaderAgent

Creates a bit stream reader of the correct type that works on the provided RandomAccessIO, with the special parameters from the parameter list.

getCodeBlock ( int param1, int param2, int param3, CSJ2K param4, int param5, int param6, CSJ2K param7 ) : CSJ2K.j2k.entropy.decoder.DecLyrdCBlk
getCompImgHeight ( int c, int rl ) : int

Returns the height in pixels of the specified component in the overall image, for the given (component) resolution level.

Note: Component resolution level indexes may differ from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of same component of each tile.

Example: For an image (2 tiles) with 1 component (tile 0 having 2 decomposition levels and tile 1 having 3 decomposition levels), the first tile(-component) has 3 resolution levels and the second one has 4 resolution levels, whereas the component has only 3 resolution levels available.

getCompImgWidth ( int c, int rl ) : int

Returns the width in pixels of the specified component in the overall image, for the given (component) resolution level.

Note: Component resolution level indexes may differ from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of same component of each tile.

Example: For an image (2 tiles) with 1 component (tile 0 having 2 decomposition levels and tile 1 having 3 decomposition levels), the first tile(-component) has 3 resolution levels and the second one has 4 resolution levels, whereas the component has only 3 resolution levels available.

getCompSubsX ( int c ) : int

Returns the component subsampling factor in the horizontal direction, for the specified component. This is, approximately, the ratio of dimensions between the reference grid and the component itself, see the 'ImgData' interface desription for details.

getCompSubsY ( int c ) : int

Returns the component subsampling factor in the vertical direction, for the specified component. This is, approximately, the ratio of dimensions between the reference grid and the component itself, see the 'ImgData' interface desription for details.

getImgHeight ( int rl ) : int

Returns the overall height of the image in pixels, for the given resolution level. This is the image's height without accounting for any component subsampling or tiling.

Note: Image resolution level indexes may differ from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of each component of each tile.

Example: For an image (1 tile) with 2 components (component 0 having 2 decomposition levels and component 1 having 3 decomposition levels), the first (tile-) component has 3 resolution levels and the second one has 4 resolution levels, whereas the image has only 3 resolution levels available.

getImgULX ( int rl ) : int

Returns the horizontal coordinate of the image origin, the top-left corner, in the canvas system, on the reference grid at the specified resolution level.

Note: Image resolution level indexes may differ from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of each component of each tile.

Example: For an image (1 tile) with 2 components (component 0 having 2 decomposition levels and component 1 having 3 decomposition levels), the first (tile-) component has 3 resolution levels and the second one has 4 resolution levels, whereas the image has only 3 resolution levels available.

getImgULY ( int rl ) : int

Returns the vertical coordinate of the image origin, the top-left corner, in the canvas system, on the reference grid at the specified resolution level.

Note: Image resolution level indexes may differ from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of each component of each tile.

Example: For an image (1 tile) with 2 components (component 0 having 2 decomposition levels and component 1 having 3 decomposition levels), the first (tile-) component has 3 resolution levels and the second one has 4 resolution levels, whereas the image has only 3 resolution levels available.

getImgWidth ( int rl ) : int

Returns the overall width of the image in pixels, for the given (image) resolution level. This is the image's width without accounting for any component subsampling or tiling.

Note: Image resolution level indexes may differ from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of each component of each tile.

Example: For an image (1 tile) with 2 components (component 0 having 2 decomposition levels and component 1 having 3 decomposition levels), the first (tile-) component has 3 resolution levels and the second one has 4 resolution levels, whereas the image has only 3 resolution levels available.

getNumTiles ( Coord co ) : Coord

Returns the number of tiles in the horizontal and vertical directions.

getNumTiles ( ) : int

Returns the total number of tiles in the image.

getPPX ( int t, int c, int rl ) : int

Returns the precinct partition width for the specified tile-component and (tile-component) resolution level.

getPPY ( int t, int c, int rl ) : int

Returns the precinct partition height for the specified tile-component and (tile-component) resolution level.

getResULX ( int c, int rl ) : int

Returns the horizontal coordinate of the upper-left corner of the specified resolution in the given component of the current tile.

getResULY ( int c, int rl ) : int

Returns the vertical coordinate of the upper-left corner of the specified component in the given component of the current tile.

getSynSubbandTree ( int t, int c ) : CSJ2K.j2k.wavelet.synthesis.SubbandSyn

Returns the subband tree, for the specified tile-component. This method returns the root element of the subband tree structure, see Subband and SubbandSyn. The tree comprises all the available resolution levels.

Note: this method is not able to return subband tree for a tile different than the current one.

The number of magnitude bits ('magBits' member variable) for each subband is not initialized.

getTile ( Coord co ) : Coord

Returns the indexes of the current tile. These are the horizontal and vertical indexes of the current tile.

getTileCompHeight ( int t, int c, int rl ) : int

Returns the height in pixels of the specified tile-component for the given (tile-component) resolution level.

getTileCompWidth ( int t, int c, int rl ) : int

Returns the width in pixels of the specified tile-component for the given (tile-component) resolution level.

getTileHeight ( int rl ) : int

Returns the overall height of the current tile in pixels, for the given resolution level. This is the tile's height without accounting for any component subsampling.

Note: Tile resolution level indexes may be different from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of each component of the tile.

For an image (1 tile) with 2 components (component 0 having 2 decomposition levels and component 1 having 3 decomposition levels), the first (tile-)component has 3 resolution levels and the second one has 4 resolution levels, whereas the tile has only 3 resolution levels available.

getTileWidth ( int rl ) : int

Returns the overall width of the current tile in pixels for the given (tile) resolution level. This is the tile's width without accounting for any component subsampling.

Note: Tile resolution level indexes may be different from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of each component of the tile.

For an image (1 tile) with 2 components (component 0 having 2 decomposition levels and component 1 having 3 decomposition levels), the first (tile-)component has 3 resolution levels and the second one has 4 resolution levels, whereas the tile has only 3 resolution levels available.

nextTile ( ) : void

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

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.

Protected Methods

Method Description
BitstreamReaderAgent ( HeaderDecoder hd, DecoderSpecs decSpec ) : System

Initializes members of this class. This constructor takes a HeaderDecoder object. This object must be initialized by the constructor of the implementing class from the header of the bit stream.

initSubbandsFields ( int c, CSJ2K.j2k.wavelet.synthesis.SubbandSyn sb ) : void

Initialises subbands fields, such as number of code-blocks, code-blocks dimension and number of magnitude bits, in the subband tree. The nominal code-block width/height depends on the precincts dimensions if used. The way the number of magnitude bits is computed depends on the quantization type (reversible, derived, expounded).

Method Details

BitstreamReaderAgent() protected method

Initializes members of this class. This constructor takes a HeaderDecoder object. This object must be initialized by the constructor of the implementing class from the header of the bit stream.
protected BitstreamReaderAgent ( HeaderDecoder hd, DecoderSpecs decSpec ) : System
hd HeaderDecoder The decoded header of the bit stream from where to initialize /// the values. /// ///
decSpec CSJ2K.j2k.decoder.DecoderSpecs The decoder specifications /// ///
return System

createInstance() public static method

Creates a bit stream reader of the correct type that works on the provided RandomAccessIO, with the special parameters from the parameter list.
If an I/O error occurs while reading initial /// data from the bit stream. /// If an unrecognised bit stream /// reader option is present. /// ///
public static createInstance ( RandomAccessIO in_Renamed, HeaderDecoder hd, CSJ2K.j2k.util.ParameterList pl, DecoderSpecs decSpec, bool cdstrInfo, HeaderInfo hi ) : BitstreamReaderAgent
in_Renamed RandomAccessIO
hd HeaderDecoder Header of the codestream. /// ///
pl CSJ2K.j2k.util.ParameterList The parameter list containing parameters applicable to the /// bit stream read (other parameters may also be present). /// ///
decSpec CSJ2K.j2k.decoder.DecoderSpecs The decoder specifications /// ///
cdstrInfo bool Whether or not to print information found in /// codestream. /// ///
hi CSJ2K.j2k.codestream.HeaderInfo Reference to the HeaderInfo instance. /// ///
return BitstreamReaderAgent

getCodeBlock() public abstract method

public abstract getCodeBlock ( int param1, int param2, int param3, CSJ2K param4, int param5, int param6, CSJ2K param7 ) : CSJ2K.j2k.entropy.decoder.DecLyrdCBlk
param1 int
param2 int
param3 int
param4 CSJ2K
param5 int
param6 int
param7 CSJ2K
return CSJ2K.j2k.entropy.decoder.DecLyrdCBlk

getCompImgHeight() public method

Returns the height in pixels of the specified component in the overall image, for the given (component) resolution level.

Note: Component resolution level indexes may differ from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of same component of each tile.

Example: For an image (2 tiles) with 1 component (tile 0 having 2 decomposition levels and tile 1 having 3 decomposition levels), the first tile(-component) has 3 resolution levels and the second one has 4 resolution levels, whereas the component has only 3 resolution levels available.

public getCompImgHeight ( int c, int rl ) : int
c int The index of the component, from 0 to N-1. /// ///
rl int The resolution level, from 0 to L. /// ///
return int

getCompImgWidth() public method

Returns the width in pixels of the specified component in the overall image, for the given (component) resolution level.

Note: Component resolution level indexes may differ from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of same component of each tile.

Example: For an image (2 tiles) with 1 component (tile 0 having 2 decomposition levels and tile 1 having 3 decomposition levels), the first tile(-component) has 3 resolution levels and the second one has 4 resolution levels, whereas the component has only 3 resolution levels available.

public getCompImgWidth ( int c, int rl ) : int
c int The index of the component, from 0 to N-1. /// ///
rl int The resolution level, from 0 to L. /// ///
return int

getCompSubsX() public method

Returns the component subsampling factor in the horizontal direction, for the specified component. This is, approximately, the ratio of dimensions between the reference grid and the component itself, see the 'ImgData' interface desription for details.
public getCompSubsX ( int c ) : int
c int The index of the component (between 0 and N-1) /// ///
return int

getCompSubsY() public method

Returns the component subsampling factor in the vertical direction, for the specified component. This is, approximately, the ratio of dimensions between the reference grid and the component itself, see the 'ImgData' interface desription for details.
public getCompSubsY ( int c ) : int
c int The index of the component (between 0 and C-1) /// ///
return int

getImgHeight() public method

Returns the overall height of the image in pixels, for the given resolution level. This is the image's height without accounting for any component subsampling or tiling.

Note: Image resolution level indexes may differ from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of each component of each tile.

Example: For an image (1 tile) with 2 components (component 0 having 2 decomposition levels and component 1 having 3 decomposition levels), the first (tile-) component has 3 resolution levels and the second one has 4 resolution levels, whereas the image has only 3 resolution levels available.

public getImgHeight ( int rl ) : int
rl int The image resolution level, from 0 to L. /// ///
return int

getImgULX() public method

Returns the horizontal coordinate of the image origin, the top-left corner, in the canvas system, on the reference grid at the specified resolution level.

Note: Image resolution level indexes may differ from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of each component of each tile.

Example: For an image (1 tile) with 2 components (component 0 having 2 decomposition levels and component 1 having 3 decomposition levels), the first (tile-) component has 3 resolution levels and the second one has 4 resolution levels, whereas the image has only 3 resolution levels available.

public getImgULX ( int rl ) : int
rl int The resolution level, from 0 to L. /// ///
return int

getImgULY() public method

Returns the vertical coordinate of the image origin, the top-left corner, in the canvas system, on the reference grid at the specified resolution level.

Note: Image resolution level indexes may differ from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of each component of each tile.

Example: For an image (1 tile) with 2 components (component 0 having 2 decomposition levels and component 1 having 3 decomposition levels), the first (tile-) component has 3 resolution levels and the second one has 4 resolution levels, whereas the image has only 3 resolution levels available.

public getImgULY ( int rl ) : int
rl int The resolution level, from 0 to L. /// ///
return int

getImgWidth() public method

Returns the overall width of the image in pixels, for the given (image) resolution level. This is the image's width without accounting for any component subsampling or tiling.

Note: Image resolution level indexes may differ from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of each component of each tile.

Example: For an image (1 tile) with 2 components (component 0 having 2 decomposition levels and component 1 having 3 decomposition levels), the first (tile-) component has 3 resolution levels and the second one has 4 resolution levels, whereas the image has only 3 resolution levels available.

public getImgWidth ( int rl ) : int
rl int The image resolution level. /// ///
return int

getNumTiles() public method

Returns the number of tiles in the horizontal and vertical directions.
public getNumTiles ( Coord co ) : Coord
co Coord If not null this object is used to return the information. If /// null a new one is created and returned. /// ///
return Coord

getNumTiles() public method

Returns the total number of tiles in the image.
public getNumTiles ( ) : int
return int

getPPX() public method

Returns the precinct partition width for the specified tile-component and (tile-component) resolution level.
public getPPX ( int t, int c, int rl ) : int
t int the tile index /// ///
c int The index of the component (between 0 and N-1) /// ///
rl int The resolution level, from 0 to L. /// ///
return int

getPPY() public method

Returns the precinct partition height for the specified tile-component and (tile-component) resolution level.
public getPPY ( int t, int c, int rl ) : int
t int The tile index /// ///
c int The index of the component (between 0 and N-1) /// ///
rl int The resolution level, from 0 to L. /// ///
return int

getResULX() public method

Returns the horizontal coordinate of the upper-left corner of the specified resolution in the given component of the current tile.
public getResULX ( int c, int rl ) : int
c int The component index. /// ///
rl int The resolution level index. /// ///
return int

getResULY() public method

Returns the vertical coordinate of the upper-left corner of the specified component in the given component of the current tile.
public getResULY ( int c, int rl ) : int
c int The component index. /// ///
rl int The resolution level index. /// ///
return int

getSynSubbandTree() public method

Returns the subband tree, for the specified tile-component. This method returns the root element of the subband tree structure, see Subband and SubbandSyn. The tree comprises all the available resolution levels.

Note: this method is not able to return subband tree for a tile different than the current one.

The number of magnitude bits ('magBits' member variable) for each subband is not initialized.

public getSynSubbandTree ( int t, int c ) : CSJ2K.j2k.wavelet.synthesis.SubbandSyn
t int The tile index /// ///
c int The index of the component, from 0 to C-1. /// ///
return CSJ2K.j2k.wavelet.synthesis.SubbandSyn

getTile() public method

Returns the indexes of the current tile. These are the horizontal and vertical indexes of the current tile.
public getTile ( Coord co ) : Coord
co Coord If not null this object is used to return the information. If /// null a new one is created and returned. /// ///
return Coord

getTileCompHeight() public method

Returns the height in pixels of the specified tile-component for the given (tile-component) resolution level.
public getTileCompHeight ( int t, int c, int rl ) : int
t int The tile index. /// ///
c int The index of the component, from 0 to N-1. /// ///
rl int The resolution level, from 0 to L. /// ///
return int

getTileCompWidth() public method

Returns the width in pixels of the specified tile-component for the given (tile-component) resolution level.
public getTileCompWidth ( int t, int c, int rl ) : int
t int The tile index /// ///
c int The index of the component, from 0 to N-1. /// ///
rl int The resolution level, from 0 to L. /// ///
return int

getTileHeight() public method

Returns the overall height of the current tile in pixels, for the given resolution level. This is the tile's height without accounting for any component subsampling.

Note: Tile resolution level indexes may be different from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of each component of the tile.

For an image (1 tile) with 2 components (component 0 having 2 decomposition levels and component 1 having 3 decomposition levels), the first (tile-)component has 3 resolution levels and the second one has 4 resolution levels, whereas the tile has only 3 resolution levels available.

public getTileHeight ( int rl ) : int
rl int The (tile) resolution level. /// ///
return int

getTileWidth() public method

Returns the overall width of the current tile in pixels for the given (tile) resolution level. This is the tile's width without accounting for any component subsampling.

Note: Tile resolution level indexes may be different from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of each component of the tile.

For an image (1 tile) with 2 components (component 0 having 2 decomposition levels and component 1 having 3 decomposition levels), the first (tile-)component has 3 resolution levels and the second one has 4 resolution levels, whereas the tile has only 3 resolution levels available.

public getTileWidth ( int rl ) : int
rl int The (tile) resolution level. /// ///
return int

initSubbandsFields() protected method

Initialises subbands fields, such as number of code-blocks, code-blocks dimension and number of magnitude bits, in the subband tree. The nominal code-block width/height depends on the precincts dimensions if used. The way the number of magnitude bits is computed depends on the quantization type (reversible, derived, expounded).
protected initSubbandsFields ( int c, CSJ2K.j2k.wavelet.synthesis.SubbandSyn sb ) : void
c int The component index /// ///
sb CSJ2K.j2k.wavelet.synthesis.SubbandSyn The subband tree to be initialised. /// ///
return void

nextTile() public abstract method

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).
public abstract nextTile ( ) : void
return void

setTile() public abstract method

Changes the current tile, given the new indexes. An IllegalArgumentException is thrown if the indexes do not correspond to a valid tile.
public abstract 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

anbytes protected property

Actual number of read bytes
protected int anbytes
return int

arate protected property

Actual decoding rate in bpp
protected float arate
return float

ax protected property

The horizontal coordinate of the image origin in the canvas system, on the reference grid.
protected int ax
return int

ay protected property

The vertical coordinate of the image origin in the canvas system, on the reference grid.
protected int ay
return int

ctX protected property

The current tile horizontal index
protected int ctX
return int

ctY protected property

The current tile vertical index
protected int ctY
return int

culx protected property

The horizontal coordinates of the upper-left corner of the active tile, with respect to the canvas origin, in the component hi-res grid, for each component.
protected int[] culx
return int[]

culy protected property

The vertical coordinates of the upper-left corner of the active tile, with respect to the canvas origin, in the component hi-res grid, for each component.
protected int[] culy
return int[]

decSpec protected property

The decoder specifications
protected DecoderSpecs,CSJ2K.j2k.decoder decSpec
return CSJ2K.j2k.decoder.DecoderSpecs

derived protected property

Whether or not the components in the current tile uses a derived quantization step size (only relevant in non reversible quantization mode). This field is actualized by the setTile method in FileBitstreamReaderAgent.
protected bool[] derived
return bool[]

gb protected property

Number of guard bits off all component in the current tile. This field is actualized by the setTile method in FileBitstreamReaderAgent.
protected int[] gb
return int[]

hd protected property

The decoded bit stream header
protected HeaderDecoder,CSJ2K.j2k.codestream.reader hd
return HeaderDecoder

imgH protected property

The image width on the hi-res reference grid
protected int imgH
return int

imgW protected property

The image width on the hi-res reference grid
protected int imgW
return int

mdl protected property

The maximum number of decompostion levels for each component of the current tile. It means that component c has mdl[c]+1 resolution levels (indexed from 0 to mdl[c])
protected int[] mdl
return int[]

nc protected property

The number of components
protected int nc
return int

nt protected property

The total number of tiles
protected int nt
return int

ntH protected property

The nominal tile height, in the hi-res reference grid
protected int ntH
return int

ntW protected property

The nominal tile width, in the hi-res reference grid
protected int ntW
return int

ntX protected property

The number of tile in the horizontal direction
protected int ntX
return int

ntY protected property

The number of tiles in the vertical direction
protected int ntY
return int

offX protected property

The horizontal offsets of the upper-left corner of the current tile (not active tile) with respect to the canvas origin, in the component hi-res grid, for each component.
protected int[] offX
return int[]

offY protected property

The vertical offsets of the upper-left corner of the current tile (not active tile) with respect to the canvas origin, in the component hi-res grid, for each component.
protected int[] offY
return int[]

params_Renamed protected property

Dequantization parameters of all subbands and all components in the current tile. The value is actualized by the setTile method in FileBitstreamReaderAgent.
protected StdDequantizerParams[],CSJ2K.j2k.quantization.dequantizer params_Renamed
return CSJ2K.j2k.quantization.dequantizer.StdDequantizerParams[]

px protected property

The horizontal coordinate of the tiling origin in the canvas system, on the reference grid.
protected int px
return int

py protected property

The vertical coordinate of the tiling origin in the canvas system, on the reference grid.
protected int py
return int

subbTrees protected property

The subband trees for each component in the current tile. Each element in the array is the root element of the subband tree for a component. The number of magnitude bits in each subband (magBits member variable) is not initialized.
protected SubbandSyn[],CSJ2K.j2k.wavelet.synthesis subbTrees
return CSJ2K.j2k.wavelet.synthesis.SubbandSyn[]

targetRes protected property

Image resolution level to generate
protected int targetRes
return int

tnbytes protected property

Number of bytes targeted to be read
protected int tnbytes
return int

trate protected property

Target decoding rate in bpp
protected float trate
return float