|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jj2000.j2k.codestream.writer.PktEncoder
This class builds packets and keeps the state information of packet interdependencies. It also supports saving the state and reverting (restoring) to the last saved state, with the save() and restore() methods.
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.
Field Summary | |
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 EncoderSpecs |
encSpec
The encoder specs |
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 java.lang.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. |
Constructor Summary | |
PktEncoder(CodedCBlkDataSrcEnc infoSrc,
EncoderSpecs encSpec,
Coord[][][] numPrec,
ParameterList pl)
Creates a new packet encoder object, using the information from the 'infoSrc' object. |
Method Summary | |
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 java.lang.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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final char OPT_PREFIX
private static final java.lang.String[][] pinfo
private static final int INIT_LBLOCK
private CodedCBlkDataSrcEnc infoSrc
private EncoderSpecs encSpec
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
Constructor Detail |
public PktEncoder(CodedCBlkDataSrcEnc infoSrc, EncoderSpecs encSpec, Coord[][][] numPrec, ParameterList pl)
infoSrc
- The source of information to construct the object.encSpec
- The encoding parameters.numPrec
- Maximum number of precincts in each tile, component
and resolution level.pl
- ParameterList instance that holds command line optionsMethod Detail |
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()
java.lang.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 java.lang.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 index
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |