public class PktEncoder extends Object
Each time the encodePacket() method is called a new packet is encoded, the packet header is returned by the method, and the packet body can be obtained with the getLastBodyBuf() and getLastBodyLen() methods.
Modifier and Type | Field and Description |
---|---|
private int[][][][][] |
bak_lblock
The saved base number of bits for sending code-block length
information.
|
private int[][][][][] |
bak_prevtIdxs
The saved last encoded truncation point for each code-block.
|
private CodedCBlkDataSrcEnc |
infoSrc
The source object
|
private static int |
INIT_LBLOCK
The initial value for the lblock
|
private byte[] |
lbbuf
The body buffer of the last encoded packet
|
private int |
lblen
The body length of the last encoded packet
|
private int[][][][][] |
lblock
The base number of bits for sending code-block length information
(referred as Lblock in the JPEG 2000 standard).
|
static char |
OPT_PREFIX
The prefix for packet encoding options: 'P'
|
private boolean |
packetWritable
Whether or not the current packet is writable
|
private static String[][] |
pinfo
The list of parameters that is accepted for packet encoding.
|
private PrecInfo[][][][] |
ppinfo
Array containing the coordinates, width, height, indexes, ...
|
private int[][][][][] |
prevtIdxs
The last encoded truncation point for each code-block.
|
private boolean |
roiInPkt
Whether or not there is ROI information in the last encoded Packet
|
private int |
roiLen
Length to read in current packet body to get all the ROI information
|
private boolean |
saved
The saved state
|
private TagTreeEncoder[][][][][] |
ttIncl
The tag tree for inclusion information.
|
private TagTreeEncoder[][][][][] |
ttMaxBP
The tag tree for the maximum significant bit-plane.
|
(package private) J2KImageWriteParamJava |
wp
The encoder specs
|
Constructor and Description |
---|
PktEncoder(CodedCBlkDataSrcEnc infoSrc,
J2KImageWriteParamJava wp,
Point[][][] numPrec)
Creates a new packet header encoder, using the information from the
'infoSrc' object.
|
Modifier and Type | Method and Description |
---|---|
BitOutputBuffer |
encodePacket(int ly,
int c,
int r,
int t,
CBlkRateDistStats[][] cbs,
int[][] tIndx,
BitOutputBuffer hbuf,
byte[] bbuf,
int pIdx)
Encodes a packet and returns the buffer containing the encoded packet
header.
|
private void |
fillPrecInfo(int t,
int c,
int r)
Retrives precincts and code-blocks coordinates in the given resolution,
component and tile.
|
byte[] |
getLastBodyBuf()
Returns the buffer of the body of the last encoded packet.
|
int |
getLastBodyLen()
Returns the length of the body of the last encoded packet, in
bytes.
|
static String[][] |
getParameterInfo()
Returns the parameters that are used in this class and implementing
classes.
|
PrecInfo |
getPrecInfo(int t,
int c,
int r,
int p)
Returns information about a given precinct
|
int |
getROILen()
Gives the length to read in current packet body to get all ROI
information
|
boolean |
isPacketWritable()
Returns true if the current packet is writable i.e.
|
boolean |
isROIinPkt()
Tells if there was ROI information in the last written packet
|
void |
reset()
Resets the state of the object to the initial state, as if the object
was just created.
|
void |
restore()
Restores the last saved state of this object.
|
void |
save()
Saves the current state of this object.
|
public static final char OPT_PREFIX
private static final String[][] pinfo
private static final int INIT_LBLOCK
private CodedCBlkDataSrcEnc infoSrc
J2KImageWriteParamJava wp
private TagTreeEncoder[][][][][] ttIncl
private TagTreeEncoder[][][][][] ttMaxBP
private int[][][][][] lblock
private int[][][][][] prevtIdxs
What is actually stored is the index of the element in CBlkRateDistStats.truncIdxs that gives the real truncation point.
private int[][][][][] bak_lblock
private int[][][][][] bak_prevtIdxs
private byte[] lbbuf
private int lblen
private boolean saved
private boolean roiInPkt
private int roiLen
private PrecInfo[][][][] ppinfo
private boolean packetWritable
public PktEncoder(CodedCBlkDataSrcEnc infoSrc, J2KImageWriteParamJava wp, Point[][][] numPrec)
Note that this constructor visits all the tiles in the 'infoSrc' object. The 'infoSrc' object is left at the original tile (i.e. the current tile before calling this constructor), but any side effects of visiting the tiles is not reverted.
infoSrc
- The source of information to construct the
object.wp
- The parameters for the encodingnumPrec
- Maximum number of precinct in each tile, component
and resolution level.private void fillPrecInfo(int t, int c, int r)
t
- Tile index.c
- Component index.r
- Resolution level index.public BitOutputBuffer encodePacket(int ly, int c, int r, int t, CBlkRateDistStats[][] cbs, int[][] tIndx, BitOutputBuffer hbuf, byte[] bbuf, int pIdx)
Layers must be coded in increasing order, in consecutive manner, for each tile, component and resolution level (e.g., layer 1, then layer 2, etc.). For different tile, component and/or resolution level no particular order must be followed.
ly
- The layer index (starts at 1).c
- The component index.r
- The resolution levelt
- Index of the current tilecbs
- The 3D array of coded code-blocks.tIndx
- The truncation point indices for each code-block.hbuf
- The header buffer. If null a new BitOutputBuffer is created
and returned. This buffer is reset before anything is written to it.bbuf
- The body buffer. If null a new one is created. If not large
enough a new one is created.pIdx
- The precinct index.public byte[] getLastBodyBuf()
IllegalArgumentException
- If no packet has been coded since
last reset(), last restore(), or object creation.getLastBodyLen()
public int getLastBodyLen()
getLastBodyBuf()
public void save()
restore()
public void restore()
save()
public void reset()
public boolean isPacketWritable()
public boolean isROIinPkt()
public int getROILen()
public static String[][] getParameterInfo()
public PrecInfo getPrecInfo(int t, int c, int r, int p)
t
- Tile index.c
- Component index.r
- Resolution level index.p
- Precinct indexCopyright © 2016 Open Microscopy Environment