|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjp2codec.codestream.reader.BitstreamReaderAgent
public class BitstreamReaderAgent
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).
HeaderDecoder
,
PktDecoder
Field Summary | |
---|---|
int |
acb
|
protected int |
anbytes
Actual number of read bytes |
protected float |
arate
Actual decoding rate in bpp |
protected int |
ax
The horizontal coordinate of the image origin in the canvas system, on the reference grid. |
protected int |
ay
The vertical coordinate of the image origin in the canvas system, on the reference grid. |
int |
cbUsed
|
protected int |
ctX
The current tile horizontal index |
protected int |
ctY
The current tile vertical index |
protected int[] |
culx
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[] |
culy
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 DecoderSpecs |
decSpec
The decoder specifications |
protected boolean[] |
derived
Whether or not the components in the current tile uses a derived quantization step size (only relevant in non reversible quantization mode). |
protected int[] |
gb
Number of guard bits off all component in the current tile. |
protected HeaderDecoder |
hd
The decoded bit stream header |
protected int |
imgH
The image width on the hi-res reference grid |
protected int |
imgW
The image width on the hi-res reference grid |
protected int[] |
mdl
The maximum number of decompostion levels for each component of the current tile. |
protected int |
nc
The number of components |
protected int |
ntH
The nominal tile height, in the hi-res reference grid |
protected int |
ntW
The nominal tile width, in the hi-res reference grid |
protected int |
ntX
The number of tile in the horizontal direction |
protected int |
ntY
The number of tiles in the vertical direction |
protected int[] |
offX
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[] |
offY
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 StdDequantizerParams[] |
params
Dequantization parameters of all subbands and all components in the current tile. |
PktDecoder |
pktDec
Reference to the PktDecoder instance |
protected int |
px
The horizontal coordinate of the tiling origin in the canvas system, on the reference grid. |
protected int |
py
The vertical coordinate of the tiling origin in the canvas system, on the reference grid. |
protected int |
res
Image resolution level to generate |
protected SubbandSyn[] |
subbTrees
The subband trees for each component in the current tile. |
protected int |
tnbytes
Number of bytes targeted to be read |
protected float |
trate
Target decoding rate in bpp |
Fields inherited from interface jp2codec.codestream.Markers |
---|
COC, COD, COM, CRG, EOC, EPH, EPH_LENGTH, ERS_SEG_MARKERS, ERS_SOP, MAX_COMP_BITDEPTH, MAX_LPPM, MAX_LPPT, PLM, PLT, POC, PPM, PPT, PRECINCT_PARTITION_DEF_SIZE, QCC, QCD, RCOM_GEN_USE, RGN, RSIZ_BASELINE, RSIZ_ER_FLAG, RSIZ_ROI, SCOX_PRECINCT_PARTITION, SCOX_USE_EPH, SCOX_USE_SOP, SIZ, SOC, SOD, SOP, SOP_LENGTH, SOT, SQCX_EXP_MASK, SQCX_EXP_SHIFT, SQCX_GB_MSK, SQCX_GB_SHIFT, SQCX_NO_QUANTIZATION, SQCX_SCALAR_DERIVED, SQCX_SCALAR_EXPOUNDED, SRGN_IMPLICIT, SSIZ_DEPTH_BITS, TLM |
Fields inherited from interface jp2codec.codestream.ProgressionType |
---|
COMP_POS_RES_LY_PROG, LY_RES_COMP_POS_PROG, POS_COMP_RES_LY_PROG, RES_LY_COMP_POS_PROG, RES_POS_COMP_LY_PROG |
Fields inherited from interface jp2codec.entropy.StdEntropyCoderOptions |
---|
FIRST_BYPASS_PASS_IDX, MAX_CB_AREA, MAX_CB_DIM, MIN_CB_DIM, NUM_EMPTY_PASSES_IN_MS_BP, NUM_NON_BYPASS_MS_BP, NUM_PASSES, OPT_BYPASS, OPT_ER_TERM, OPT_REG_TERM, OPT_RESET_MQ, OPT_SEG_MARKERS, OPT_VERT_STR_CAUSAL, STRIPE_HEIGHT |
Constructor Summary | |
---|---|
BitstreamReaderAgent(HeaderDecoder hd,
javax.imageio.stream.ImageInputStream ehs,
DecoderSpecs decSpec,
float rate,
int nbytes,
boolean parsing,
int resolution)
Reads all tiles headers and keep offset of their first packet. |
Method Summary | |
---|---|
boolean |
anyCodeBlockRemains()
|
int |
getActualNbytes()
Return the actual number of read bytes. |
float |
getActualRate()
Return the actual decoding rate in bits per pixel. |
DecLyrdCBlk |
getCodeBlock(int c,
int r,
int s,
int m,
int n)
|
DecLyrdCBlk |
getCodeBlock(int c,
int m,
int n,
SubbandSyn sb,
int fl,
int nl,
DecLyrdCBlk dlcb)
Returns the specified coded code-block, for the specified component, in the current tile. |
DecLyrdCBlk |
getCodeBlockOld(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. |
int |
getCompHeight(int c,
int rl)
Returns the height in pixels of the specified component in the current tile, for the given (tile-component) resolution level. |
int |
getCompImgHeight(int c,
int rl)
Returns the height in pixels of the specified component in the overall image, for the given (component) resolution level. |
int |
getCompImgWidth(int c,
int rl)
Returns the width in pixels of the specified component in the overall image, for the given (component) resolution level. |
int |
getCompSubsX(int c)
Returns the component subsampling factor in the horizontal direction, for the specified component. |
int |
getCompSubsY(int c)
Returns the component subsampling factor in the vertical direction, for the specified component. |
int |
getCompWidth(int c,
int rl)
Returns the width in pixels of the specified component in the current tile, for the given (tile-component) resolution level. |
int |
getHeight(int rl)
Returns the overall height of the current tile in pixels, for the given resolution level. |
int |
getImgHeight(int rl)
Returns the overall height of the image in pixels, for the given resolution level. |
int |
getImgRes()
Returns the image resolution level to reconstruct from the codestream. |
int |
getImgULX(int rl)
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. |
int |
getImgULY(int rl)
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. |
int |
getImgWidth(int rl)
Returns the overall width of the image in pixels, for the given (image) resolution level. |
Coord |
getNumCodeBlocks(SubbandSyn sb,
int c,
Coord co)
Returns the number of code-blocks in a subband, along the horizontal and vertical dimensions. |
int |
getNumComps()
Returns the number of components in the image. |
int |
getNumTiles()
Returns the total number of tiles in the image. |
Coord |
getNumTiles(Coord co)
Returns the number of tiles in the horizontal and vertical directions. |
int |
getPartitionULX()
Returns the horizontal coordinate of the origin of the cell and code-block partition, with respect to the canvas origin, on the reference grid. |
int |
getPartitionULY()
Returns the vertical coordinate of the origin of the cell and code-block partition, with respect to the canvas origin, on the reference grid. |
int |
getPPX(int t,
int c,
int rl)
Returns the precinct partition width for the specified tile-component and (tile-component) resolution level. |
int |
getPPY(int t,
int c,
int rl)
Returns the precinct partition height for the specified tile-component and (tile-component) resolution level. |
SubbandSyn |
getSubbandTree(int t,
int c)
Returns the subband tree, for the specified tile-component. |
int |
getTargetNbytes()
Return the target number of read bytes. |
float |
getTargetRate()
Return the target decoding rate in bits per pixel. |
Coord |
getTile(Coord co)
Returns the indexes of the current tile. |
int |
getTileIdx()
Returns the index of the current tile, relative to a standard scan-line order. |
Coord |
getTileOff(Coord co,
int c,
int rl)
Returns the horizontal and vertical offset of the upper-left corner of the current tile, in the specified component, relative to the canvas origin, for the specified resolution level. |
int |
getULX(int c,
int rl)
Returns the horizontal coordinate of the upper-left corner of the active tile, with respect to the canvas origin, in the component coordinates, for the specified component and resolution level. |
int |
getULY(int c,
int rl)
Returns the vertical coordinate of the upper-left corner of the active tile, with respect to the canvas origin, in the component coordinates, for the specified component and resolution level. |
int |
getWidth(int rl)
Returns the overall width of the current tile in pixels for the given (tile) resolution level. |
protected void |
initSubbandsFields(int c,
SubbandSyn sb)
Initialises subbands fields, such as code-blocks dimension and number of magnitude bits, in the subband tree. |
void |
nextTile()
Advances to the next tile, in standard scan-line order (by rows then columns). |
void |
run()
|
void |
setROI(int x,
int y,
int w,
int h)
|
void |
setTile(int x,
int y)
Changes the current tile, given the new indexes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected DecoderSpecs decSpec
protected boolean[] derived
initSubbandsFields(int, jp2codec.wavelet.synthesis.SubbandSyn)
protected int[] gb
initSubbandsFields(int, jp2codec.wavelet.synthesis.SubbandSyn)
protected StdDequantizerParams[] params
initSubbandsFields(int, jp2codec.wavelet.synthesis.SubbandSyn)
protected int[] mdl
protected final int nc
protected int res
protected SubbandSyn[] subbTrees
protected final int imgW
protected final int imgH
protected final int ax
protected final int ay
protected final int px
protected final int py
protected final int[] offX
protected final int[] offY
protected final int[] culx
protected final int[] culy
protected final int ntW
protected final int ntH
protected final int ntX
protected final int ntY
protected int ctX
protected int ctY
protected final HeaderDecoder hd
protected int tnbytes
protected int anbytes
protected float trate
protected float arate
public PktDecoder pktDec
public int acb
public int cbUsed
Constructor Detail |
---|
public BitstreamReaderAgent(HeaderDecoder hd, javax.imageio.stream.ImageInputStream ehs, DecoderSpecs decSpec, float rate, int nbytes, boolean parsing, int resolution) throws java.io.IOException
hd
- HeaderDecoder of the codestream.ehs
- The input stream where to read bit-stream.decSpec
- The decoder specifications
java.io.IOException
allocateRate()
Method Detail |
---|
public final int getPartitionULX()
getPartitionULX
in interface InvWTData
public int getPartitionULY()
getPartitionULY
in interface InvWTData
public final int getNumComps()
getNumComps
in interface MultiResImgData
public final int getCompSubsX(int c)
getCompSubsX
in interface MultiResImgData
c
- The index of the component (between 0 and N-1)
ImgData
public int getCompSubsY(int c)
getCompSubsY
in interface MultiResImgData
c
- The index of the component (between 0 and C-1)
ImgData
public int getWidth(int rl)
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.
getWidth
in interface MultiResImgData
rl
- The (tile) resolution level.
public int getHeight(int rl)
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.
getHeight
in interface MultiResImgData
rl
- The (tile) resolution level.
public int getImgWidth(int rl)
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
in interface MultiResImgData
rl
- The image resolution level.
public int getImgHeight(int rl)
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.
getImgHeight
in interface MultiResImgData
rl
- The image resolution level, from 0 to L.
public int getImgULX(int rl)
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
in interface MultiResImgData
rl
- The resolution level, from 0 to L.
public int getImgULY(int rl)
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
in interface MultiResImgData
rl
- The resolution level, from 0 to L.
public final int getCompWidth(int c, int rl)
getCompWidth
in interface MultiResImgData
c
- The index of the component, from 0 to N-1.rl
- The resolution level, from 0 to L.
public final int getCompHeight(int c, int rl)
getCompHeight
in interface MultiResImgData
c
- The index of the component, from 0 to N-1.rl
- The resolution level, from 0 to L.
public final int getCompImgWidth(int c, int rl)
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
in interface MultiResImgData
c
- The index of the component, from 0 to N-1.rl
- The resolution level, from 0 to L.
public final int getCompImgHeight(int c, int rl)
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.
getCompImgHeight
in interface MultiResImgData
c
- The index of the component, from 0 to N-1.rl
- The resolution level, from 0 to L.
public final Coord getTile(Coord co)
getTile
in interface MultiResImgData
co
- If not null this object is used to return the information. If
null a new one is created and returned.
public final int getTileIdx()
getTileIdx
in interface MultiResImgData
public final Coord getTileOff(Coord co, int c, int rl)
getTileOff
in interface MultiResImgData
co
- If not null the object is used to return the values, if null
a new one is created and returned.c
- The index of the component (between 0 and N-1)rl
- The resolution level, from 0 to L.
public final int getULX(int c, int rl)
getULX
in interface MultiResImgData
c
- The index of the component (between 0 and N-1)rl
- The resolution level, from 0 to L.
public final int getULY(int c, int rl)
getULY
in interface MultiResImgData
c
- The index of the component (between 0 and N-1)rl
- The resolution level, from 0 to L.
public final Coord getNumTiles(Coord co)
getNumTiles
in interface MultiResImgData
co
- If not null this object is used to return the information. If
null a new one is created and returned.
public final int getNumTiles()
getNumTiles
in interface MultiResImgData
public final SubbandSyn getSubbandTree(int t, int c)
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.
getSubbandTree
in interface InvWTData
t
- The tile indexc
- The index of the component, from 0 to C-1.
public final Coord getNumCodeBlocks(SubbandSyn sb, int c, Coord co)
getNumCodeBlocks
in interface CodedCBlkDataSrcDec
sb
- The subband for which to return the number of blocks.c
- The component where the subband is.co
- If not null the values are returned in this object. If null a
new object is allocated and returned.
public final int getPPX(int t, int c, int rl)
t
- the tile indexc
- The index of the component (between 0 and N-1)rl
- The resolution level, from 0 to L.
public final int getPPY(int t, int c, int rl)
t
- The tile indexc
- The index of the component (between 0 and N-1)rl
- The resolution level, from 0 to L.
protected void initSubbandsFields(int c, SubbandSyn sb)
c
- The component indexsb
- The subband tree to be initialised.public int getImgRes()
public float getTargetRate()
public float getActualRate()
public int getTargetNbytes()
public int getActualNbytes()
public void setTile(int x, int y)
setTile
in interface MultiResImgData
x
- The horizontal indexes the tile.y
- The vertical indexes of the new tile.public void nextTile()
nextTile
in interface MultiResImgData
public void setROI(int x, int y, int w, int h)
public boolean anyCodeBlockRemains()
public void run()
run
in interface java.lang.Runnable
public DecLyrdCBlk getCodeBlock(int c, int r, int s, int m, int n)
public DecLyrdCBlk getCodeBlock(int c, int m, int n, SubbandSyn sb, int fl, int nl, DecLyrdCBlk dlcb)
CodedCBlkDataSrcDec
The argument 'fl' is to be used by subsequent calls to this method for the same code-block. In this way supplamental 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 subblock.
The compressed code-block is uniquely specified by the current tile, the component (identified by 'c'), the subband (indentified by 'sb') and the code-bock vertical and horizontal indexes 'm' and 'n'.
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.
getCodeBlock
in interface CodedCBlkDataSrcDec
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'.dlcb
- 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.
public DecLyrdCBlk getCodeBlockOld(int c, int m, int n, SubbandSyn sb, int fl, int nl, DecLyrdCBlk ccb)
The argument 'fl' is to be used by subsequent calls to this method for the same code-block. In this way supplamental 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 subblock.
The compressed code-block is uniquely specified by the current tile, the component (identified by 'c'), the subband (indentified by 'sb') and the code-bock 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.
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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |