jp2codec.codestream.reader
Class PktDecoder

java.lang.Object
  extended by jp2codec.codestream.reader.PktDecoder
All Implemented Interfaces:
StdEntropyCoderOptions

public class PktDecoder
extends java.lang.Object
implements StdEntropyCoderOptions

This class is used to read packet's head and body. All the members must be re-initialized at the beginning of each tile thanks to the restart() method.


Field Summary
 int cbIdx
           
 
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
PktDecoder(DecoderSpecs decSpec, HeaderDecoder hd, javax.imageio.stream.ImageInputStream ehs, BitstreamReaderAgent src, boolean isTruncMode)
          Create an empty PktDecoder object associated with given decoder specifications and HeaderDecoder.
 
Method Summary
 Coord getIncArray(int c, int r)
          Returns the 'incArray' for the specified component and resolution level.
 Coord getIncArrayMax(int c)
          Returns the 'incArrayMax' for the specified component.
 int getNumPrecinct(int c, int r)
          Get the number of precinct in given component and resolution.
 int getPPX(int t, int c, int r)
          Returns the precinct partition width for the specified component, resolution level and tile.
 int getPPY(int t, int c, int rl)
          Returns the precinct partition height for the specified component, resolution level and tile.
 Coord[] getSotEotArray(int c, int r)
          Returns the 'sotEotArray' for the specified component and resolution level.
 Coord[] getSotEotArrayMax(int c)
          Returns the 'sotEotArrayMax' for the specified component.
 void readEPHMarker(jp2codec.codestream.reader.PktHeaderBitReader bin)
          Try to read an EPH marker.
 boolean readPktBody(int l, int r, int c, int p, CBlkInfo[][][] cbI, int[] nb)
          Reads specificied packet body in order to find offset of each code-block's piece of codeword.
 boolean readPktHead(int l, int r, int c, int p, CBlkInfo[][][] cbI, int[] nb)
          Read specified packet head and found length of each code-block's piece of codewords as well as number of skipped most significant bit-planes.
 boolean readSOPMarker(int[] nBytes, int p, int c, int r)
          Try to read a SOP marker and check that its sequence number if not out of sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cbIdx

public int cbIdx
Constructor Detail

PktDecoder

public PktDecoder(DecoderSpecs decSpec,
                  HeaderDecoder hd,
                  javax.imageio.stream.ImageInputStream ehs,
                  BitstreamReaderAgent src,
                  boolean isTruncMode)
Create an empty PktDecoder object associated with given decoder specifications and HeaderDecoder. This object must be initialized thanks to the restart method before being used.

Parameters:
decSpec - The decoder specifications
hd - The HeaderDecoder instance
ehs - The stream where to read data from
src - The bit stream reader agent
isTruncMode - Whether or not truncation mode is used
Method Detail

getNumPrecinct

public int getNumPrecinct(int c,
                          int r)
Get the number of precinct in given component and resolution.

Parameters:
c - Component index
r - Resolution index

readPktHead

public boolean readPktHead(int l,
                           int r,
                           int c,
                           int p,
                           CBlkInfo[][][] cbI,
                           int[] nb)
                    throws java.io.IOException
Read specified packet head and found length of each code-block's piece of codewords as well as number of skipped most significant bit-planes.

Parameters:
l - layer index
r - Resolution level index
c - Component index
p - Precinct index
cbI - CBlkInfo array of relevant component and resolution level.
nb - The number of bytes to read in each tile before reaching output rate (used by truncation mode)
Returns:
True if output rate is reached
Throws:
java.io.IOException

readPktBody

public boolean readPktBody(int l,
                           int r,
                           int c,
                           int p,
                           CBlkInfo[][][] cbI,
                           int[] nb)
                    throws java.io.IOException
Reads specificied packet body in order to find offset of each code-block's piece of codeword. This use the list of found code-blocks in previous red packet head.

Parameters:
l - layer index
r - Resolution level index
c - Component index
p - Precinct index
cbI - CBlkInfo array of relevant component and resolution level.
nb - The remainding number of bytes to read from the bit stream in each tile before reaching the decoding rate (in truncation mode)
Returns:
True if decoding rate is reached
Throws:
java.io.IOException

getPPX

public final int getPPX(int t,
                        int c,
                        int r)
Returns the precinct partition width for the specified component, resolution level and tile.

Parameters:
t - the tile index
c - The index of the component (between 0 and C-1)
r - The resolution level, from 0 to L.
Returns:
the precinct partition width for the specified component, resolution level and tile.

getPPY

public final int getPPY(int t,
                        int c,
                        int rl)
Returns the precinct partition height for the specified component, resolution level and tile.

Parameters:
t - the tile index
c - The index of the component (between 0 and C-1)
rl - The resolution level, from 0 to L.
Returns:
the precinct partition height in the specified component, for the specified resolution level, for the current tile.

readSOPMarker

public boolean readSOPMarker(int[] nBytes,
                             int p,
                             int c,
                             int r)
                      throws java.io.IOException
Try to read a SOP marker and check that its sequence number if not out of sequence. If so, an error is thrown.

Parameters:
nBytes - The number of bytes left to read from each tile
p - Precinct index
r - Resolution level index
c - Component index
Throws:
java.io.IOException

readEPHMarker

public void readEPHMarker(jp2codec.codestream.reader.PktHeaderBitReader bin)
                   throws java.io.IOException
Try to read an EPH marker. If it is not possible then an Error is thrown.

Parameters:
bin - The packet header reader to read the EPH marker from
Throws:
java.io.IOException

getSotEotArray

public Coord[] getSotEotArray(int c,
                              int r)
Returns the 'sotEotArray' for the specified component and resolution level. This method is used by the bit stream reader.

Parameters:
c - The component
r - The resolution level

getSotEotArrayMax

public Coord[] getSotEotArrayMax(int c)
Returns the 'sotEotArrayMax' for the specified component. This method is used by the bit stream reader.

Parameters:
c - The component

getIncArray

public Coord getIncArray(int c,
                         int r)
Returns the 'incArray' for the specified component and resolution level. This method is used by the bit stream reader.

Parameters:
c - The component
r - The resolution level

getIncArrayMax

public Coord getIncArrayMax(int c)
Returns the 'incArrayMax' for the specified component. This method is used by the bit stream reader.

Parameters:
c - The component