jj2000.j2k.entropy.decoder
Class StdEntropyDecoder

java.lang.Object
  |
  +--jj2000.j2k.wavelet.synthesis.MultiResImgDataAdapter
        |
        +--jj2000.j2k.entropy.decoder.EntropyDecoder
              |
              +--jj2000.j2k.entropy.decoder.StdEntropyDecoder
All Implemented Interfaces:
CBlkQuantDataSrcDec, InvWTData, MultiResImgData, StdEntropyCoderOptions

public class StdEntropyDecoder
extends EntropyDecoder
implements StdEntropyCoderOptions

This class implements the JPEG 2000 entropy decoder, which codes stripes in code-blocks. This entropy decoding engine decodes one code-block at a time.

The code-blocks are rectangular and their dimensions must be powers of 2. Each dimension cannot be smaller than 4 and larger than 256. The product of the two dimensions (i.e. area of the code-block) cannot exceed 4096.

Context 0 of the MQ-coder is used as the uniform one (uniform, non-adaptive probability distribution). Context 1 is used for RLC coding. Contexts 2-10 are used for zero-coding (ZC), contexts 11-15 are used for sign-coding (SC) and contexts 16-18 are used for magnitude-refinement (MR).

This implementation also provides some timing features. They can be enabled by setting the 'DO_TIMING' constant of this class to true and recompiling. The timing uses the 'System.currentTimeMillis()' Java API call, which returns wall clock time, not the actual CPU time used. The timing results will be printed on the message output. Since the times reported are wall clock times and not CPU usage times they can not be added to find the total used time (i.e. some time might be counted in several places). When timing is disabled ('DO_TIMING' is false) there is no penalty if the compiler performs some basic optimizations. Even if not the penalty should be negligeable.


Field Summary
private  ByteToBitInput bin
          The bit based input for arithmetic coding bypass (i.e.
private  DecoderSpecs decSpec
          The decoder spec
private static boolean DO_TIMING
          Whether to collect timing information or not: false.
private  boolean doer
          Flag to indicate if we should try to detect errors or just ignore any error resilient information
private static int INT_SIGN_BIT
          The sign bit for int data
private  MQDecoder mq
          The MQ decoder to use.
private static int[] MQ_INIT
          The initial states for the MQ coder
private  int mQuit
          The maximum number of bit planes to decode for any code-block
private static int[] MR_LUT
          Magnitude Refinement context lookup table
private static int MR_LUT_BITS
          The number of bits used for the Magnitude Refinement lookup table
private static int MR_MASK
          The mask to obtain the MR index to 'MR_LUT' from the 'state' information.
private static int NUM_CTXTS
          The number of contexts used
private  int options
          The options that are turned on, as flag bits.
private static int RLC_CTXT
          The RLC context
private static int RLC_MASK_R1R2
          The mask to isolate the bits necessary to identify RLC coding state (significant, visited and non-zero context, for row 1 and 2).
private static int[] SC_LUT
          Sign Coding context lookup table.
private static int SC_LUT_BITS
          Number of bits used for the Sign Coding lookup table
private static int SC_LUT_MASK
          The mask to obtain the context index from the 'SC_LUT'
private static int SC_MASK
          The bit mask to isolate the state bits relative to the sign coding lookup table ('SC_LUT').
private static int SC_SHIFT_R1
          The shift to obtain the SC index to 'SC_LUT' from the 'state' information, for row 1.
private static int SC_SHIFT_R2
          The shift to obtain the SC index to 'SC_LUT' from the state information, for row 2.
private static int SC_SPRED_SHIFT
          The shift to obtain the sign predictor from the 'SC_LUT'.
private static int SEG_SYMBOL
          The 4 bits of the error resilience segmentation symbol (decimal 10, which is binary sequence 1010)
private static int SIG_MASK_R1R2
          The mask to isolate the significance bits for row 1 and 2 of the state array.
private  DecLyrdCBlk srcblk
          The source code-block to entropy code (avoids reallocation for each code-block).
private  int[] state
          The state array for entropy coding.
private static int STATE_D_DL_R1
          The flag bit for the diagonal down-left significance in the state array, for row 1.
private static int STATE_D_DL_R2
          The flag bit for the diagonal down-left significance in the state array, for row 2.
private static int STATE_D_DR_R1
          The flag bit for the diagonal down-right significance in the state array , for row 1.
private static int STATE_D_DR_R2
          The flag bit for the diagonal down-right significance in the state array , for row 2.
private static int STATE_D_UL_R1
          The flag bit for the diagonal up-left significance in the state array, for row 1.
private static int STATE_D_UL_R2
          The flag bit for the diagonal up-left significance in the state array, for row 2.
private static int STATE_D_UR_R1
          The flag bit for the diagonal up-right significance in the state array, for row 1.
private static int STATE_D_UR_R2
          The flag bit for the diagonal up-right significance in the state array, for row 2.
private static int STATE_H_L_R1
          The flag bit for the horizontal-left significance in the state array, for row 1.
private static int STATE_H_L_R2
          The flag bit for the horizontal-left significance in the state array, for row 2.
private static int STATE_H_L_SIGN_R1
          The flag bit for the horizontal-left sign in the state array, for row 1.
private static int STATE_H_L_SIGN_R2
          The flag bit for the horizontal-left sign in the state array, for row 2.
private static int STATE_H_R_R1
          The flag bit for the horizontal-right significance in the state array, for row 1.
private static int STATE_H_R_R2
          The flag bit for the horizontal-right significance in the state array, for row 2.
private static int STATE_H_R_SIGN_R1
          The flag bit for the horizontal-right sign in the state array, for row 1.
private static int STATE_H_R_SIGN_R2
          The flag bit for the horizontal-right sign in the state array, for row 2.
private static int STATE_NZ_CTXT_R1
          The flag bit for the "not zero context" bit in the state array, for row 1.
private static int STATE_NZ_CTXT_R2
          The flag bit for the "not zero context" bit in the state array, for row 2.
private static int STATE_PREV_MR_R1
          The flag bit for the previous MR primitive applied in the state array, for row 1.
private static int STATE_PREV_MR_R2
          The flag bit for the previous MR primitive applied in the state array, for row 2.
private static int STATE_SEP
          The separation between the upper and lower bits in the state array: 16
private static int STATE_SIG_R1
          The flag bit for the significance in the state array, for row 1.
private static int STATE_SIG_R2
          The flag bit for the significance in the state array, for row 2.
private static int STATE_V_D_R1
          The flag bit for the vertical-down significance in the state array, for row 1.
private static int STATE_V_D_R2
          The flag bit for the vertical-down significance in the state array, for row 2.
private static int STATE_V_D_SIGN_R1
          The flag bit for the vertical-down sign in the state array, for row 1.
private static int STATE_V_D_SIGN_R2
          The flag bit for the vertical-down sign in the state array, for row 2.
private static int STATE_V_U_R1
          The flag bit for the vertical-up significance in the state array, for row 1.
private static int STATE_V_U_R2
          The flag bit for the vertical-up significance in the state array, for row 2.
private static int STATE_V_U_SIGN_R1
          The flag bit for the vertical-up sign in the state array, for row 1.
private static int STATE_V_U_SIGN_R2
          The flag bit for the vertical-up sign in the state array, for row 2.
private static int STATE_VISITED_R1
          The flag bit for the "visited" bit in the state array, for row 1.
private static int STATE_VISITED_R2
          The flag bit for the "visited" bit in the state array, for row 2.
private  long[] time
          The cumulative wall time for the entropy coding engine, for each component.
private static int UNIF_CTXT
          The UNIFORM context (with a uniform probability distribution which does not adapt)
private  boolean verber
          Flag to indicate if we should be verbose about bit stream errors detected with the error resilience options
private static int VSTD_MASK_R1R2
          The mask to isolate the visited bits for row 1 and 2 of the state array.
private static int ZC_LUT_BITS
          Number of bits used for the Zero Coding lookup table
private static int[] ZC_LUT_HH
          Zero Coding context lookup tables for the HH global orientation
private static int[] ZC_LUT_HL
          Zero Coding context lookup tables for the HL global orientation
private static int[] ZC_LUT_LH
          Zero Coding context lookup tables for the LH global orientation
private static int ZC_MASK
          The mask to obtain the ZC_LUT index from the 'state' information
 
Fields inherited from class jj2000.j2k.entropy.decoder.EntropyDecoder
OPT_PREFIX, src
 
Fields inherited from class jj2000.j2k.wavelet.synthesis.MultiResImgDataAdapter
mressrc, tIdx
 
Fields inherited from interface jj2000.j2k.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_PRED_TERM, OPT_RESET_MQ, OPT_SEG_SYMBOLS, OPT_TERM_PASS, OPT_VERT_STR_CAUSAL, STRIPE_HEIGHT
 
Constructor Summary
StdEntropyDecoder(CodedCBlkDataSrcDec src, DecoderSpecs decSpec, boolean doer, boolean verber, int mQuit)
          Instantiates a new entropy decoder engine, with the specified source of data, nominal block width and height.
 
Method Summary
private  boolean cleanuppass(DataBlk cblk, MQDecoder mq, int bp, int[] state, int[] zc_lut, boolean isterm)
          Performs the cleanup pass on the specified data and bit-plane.
private  void conceal(DataBlk cblk, int bp)
          Conceals decoding errors detected in the last bit-plane.
 void finalize()
          Prints the timing information, if collected, and calls 'finalize' on the super class.
 DataBlk getCodeBlock(int c, int m, int n, SubbandSyn sb, DataBlk cblk)
          Returns the specified code-block in the current tile for the specified component, as a copy (see below).
 DataBlk getInternCodeBlock(int c, int m, int n, SubbandSyn sb, DataBlk cblk)
          Returns the specified code-block in the current tile for the specified component (as a reference or copy).
private  boolean magRefPass(DataBlk cblk, MQDecoder mq, int bp, int[] state, boolean isterm)
          Performs the magnitude refinement pass on the specified data and bit-plane.
private  boolean rawMagRefPass(DataBlk cblk, ByteToBitInput bin, int bp, int[] state, boolean isterm)
          Performs the magnitude refinement pass on the specified data and bit-plane.
private  boolean rawSigProgPass(DataBlk cblk, ByteToBitInput bin, int bp, int[] state, boolean isterm)
          Performs the significance propagation pass on the specified data and bit-plane.
private  boolean sigProgPass(DataBlk cblk, MQDecoder mq, int bp, int[] state, int[] zc_lut, boolean isterm)
          Performs the significance propagation pass on the specified data and bit-plane.
 
Methods inherited from class jj2000.j2k.entropy.decoder.EntropyDecoder
getCbULX, getCbULY, getParameterInfo, getSynSubbandTree
 
Methods inherited from class jj2000.j2k.wavelet.synthesis.MultiResImgDataAdapter
getCompImgHeight, getCompImgWidth, getCompSubsX, getCompSubsY, getImgHeight, getImgULX, getImgULY, getImgWidth, getNomTileHeight, getNomTileWidth, getNumComps, getNumTiles, getNumTiles, getResULX, getResULY, getTile, getTileCompHeight, getTileCompWidth, getTileHeight, getTileIdx, getTilePartULX, getTilePartULY, getTileWidth, nextTile, setTile
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jj2000.j2k.wavelet.synthesis.MultiResImgData
getCompImgHeight, getCompImgWidth, getCompSubsX, getCompSubsY, getImgHeight, getImgULX, getImgULY, getImgWidth, getNomTileHeight, getNomTileWidth, getNumComps, getNumTiles, getNumTiles, getResULX, getResULY, getTile, getTileCompHeight, getTileCompWidth, getTileHeight, getTileIdx, getTilePartULX, getTilePartULY, getTileWidth, nextTile, setTile
 

Field Detail

DO_TIMING

private static final boolean DO_TIMING
Whether to collect timing information or not: false. Used as a compile time directive.

See Also:
Constant Field Values

time

private long[] time
The cumulative wall time for the entropy coding engine, for each component.


bin

private ByteToBitInput bin
The bit based input for arithmetic coding bypass (i.e. raw) coding


mq

private MQDecoder mq
The MQ decoder to use. It has in as the underlying source of coded data.


decSpec

private DecoderSpecs decSpec
The decoder spec


options

private int options
The options that are turned on, as flag bits. The options are 'OPT_TERM_PASS', 'OPT_RESET_MQ', 'OPT_VERT_STR_CAUSAL', 'OPT_BYPASS' and 'OPT_SEG_SYMBOLS' as defined in the StdEntropyCoderOptions interface

See Also:
StdEntropyCoderOptions

doer

private final boolean doer
Flag to indicate if we should try to detect errors or just ignore any error resilient information


verber

private final boolean verber
Flag to indicate if we should be verbose about bit stream errors detected with the error resilience options


ZC_LUT_BITS

private static final int ZC_LUT_BITS
Number of bits used for the Zero Coding lookup table

See Also:
Constant Field Values

ZC_LUT_LH

private static final int[] ZC_LUT_LH
Zero Coding context lookup tables for the LH global orientation


ZC_LUT_HL

private static final int[] ZC_LUT_HL
Zero Coding context lookup tables for the HL global orientation


ZC_LUT_HH

private static final int[] ZC_LUT_HH
Zero Coding context lookup tables for the HH global orientation


SC_LUT_BITS

private static final int SC_LUT_BITS
Number of bits used for the Sign Coding lookup table

See Also:
Constant Field Values

SC_LUT

private static final int[] SC_LUT
Sign Coding context lookup table. The index into the table is a 9 bit index, which correspond the the value in the 'state' array shifted by 'SC_SHIFT'. Bits 8-5 are the signs of the horizontal-left, horizontal-right, vertical-up and vertical-down neighbors, respectively. Bit 4 is not used (0 or 1 makes no difference). Bits 3-0 are the significance of the horizontal-left, horizontal-right, vertical-up and vertical-down neighbors, respectively. The least 4 bits of the value in the lookup table define the context number and the sign bit defines the "sign predictor".


SC_LUT_MASK

private static final int SC_LUT_MASK
The mask to obtain the context index from the 'SC_LUT'

See Also:
Constant Field Values

SC_SPRED_SHIFT

private static final int SC_SPRED_SHIFT
The shift to obtain the sign predictor from the 'SC_LUT'. It must be an unsigned shift.

See Also:
Constant Field Values

INT_SIGN_BIT

private static final int INT_SIGN_BIT
The sign bit for int data

See Also:
Constant Field Values

MR_LUT_BITS

private static final int MR_LUT_BITS
The number of bits used for the Magnitude Refinement lookup table

See Also:
Constant Field Values

MR_LUT

private static final int[] MR_LUT
Magnitude Refinement context lookup table


NUM_CTXTS

private static final int NUM_CTXTS
The number of contexts used

See Also:
Constant Field Values

RLC_CTXT

private static final int RLC_CTXT
The RLC context

See Also:
Constant Field Values

UNIF_CTXT

private static final int UNIF_CTXT
The UNIFORM context (with a uniform probability distribution which does not adapt)

See Also:
Constant Field Values

MQ_INIT

private static final int[] MQ_INIT
The initial states for the MQ coder


SEG_SYMBOL

private static final int SEG_SYMBOL
The 4 bits of the error resilience segmentation symbol (decimal 10, which is binary sequence 1010)

See Also:
Constant Field Values

state

private final int[] state
The state array for entropy coding. Each element of the state array stores the state of two coefficients. The lower 16 bits store the state of a coefficient in row 'i' and column 'j', while the upper 16 bits store the state of a coefficient in row 'i+1' and column 'j'. The 'i' row is either the first or the third row of a stripe. This packing of the states into 32 bit words allows a faster scan of all coefficients on each coding pass and diminished the amount of data transferred. The size of the state array is increased by 1 on each side (top, bottom, left, right) to handle boundary conditions without any special logic.

The state of a coefficient is stored in the following way in the lower 16 bits, where bit 0 is the least significant bit. Bit 15 is the significance of a coefficient (0 if non-significant, 1 otherwise). Bit 14 is the visited state (i.e. if a coefficient has been coded in the significance propagation pass of the current bit-plane). Bit 13 is the "non zero-context" state (i.e. if one of the eight immediate neighbors is significant it is 1, otherwise is 0). Bits 12 to 9 store the sign of the already significant left, right, up and down neighbors (1 for negative, 0 for positive or not yet significant). Bit 8 indicates if the magnitude refinement has already been applied to the coefficient. Bits 7 to 4 store the significance of the left, right, up and down neighbors (1 for significant, 0 for non significant). Bits 3 to 0 store the significance of the diagonal coefficients (up-left, up-right, down-left and down-right; 1 for significant, 0 for non significant).

The upper 16 bits the state is stored as in the lower 16 bits, but with the bits shifted up by 16.

The lower 16 bits are referred to as "row 1" ("R1") while the upper 16 bits are referred to as "row 2" ("R2").


STATE_SEP

private static final int STATE_SEP
The separation between the upper and lower bits in the state array: 16

See Also:
Constant Field Values

STATE_SIG_R1

private static final int STATE_SIG_R1
The flag bit for the significance in the state array, for row 1.

See Also:
Constant Field Values

STATE_VISITED_R1

private static final int STATE_VISITED_R1
The flag bit for the "visited" bit in the state array, for row 1.

See Also:
Constant Field Values

STATE_NZ_CTXT_R1

private static final int STATE_NZ_CTXT_R1
The flag bit for the "not zero context" bit in the state array, for row 1. This bit is always the OR of bits STATE_H_L_R1, STATE_H_R_R1, STATE_V_U_R1, STATE_V_D_R1, STATE_D_UL_R1, STATE_D_UR_R1, STATE_D_DL_R1 and STATE_D_DR_R1.

See Also:
Constant Field Values

STATE_H_L_SIGN_R1

private static final int STATE_H_L_SIGN_R1
The flag bit for the horizontal-left sign in the state array, for row 1. This bit can only be set if the STATE_H_L_R1 is also set.

See Also:
Constant Field Values

STATE_H_R_SIGN_R1

private static final int STATE_H_R_SIGN_R1
The flag bit for the horizontal-right sign in the state array, for row 1. This bit can only be set if the STATE_H_R_R1 is also set.

See Also:
Constant Field Values

STATE_V_U_SIGN_R1

private static final int STATE_V_U_SIGN_R1
The flag bit for the vertical-up sign in the state array, for row 1. This bit can only be set if the STATE_V_U_R1 is also set.

See Also:
Constant Field Values

STATE_V_D_SIGN_R1

private static final int STATE_V_D_SIGN_R1
The flag bit for the vertical-down sign in the state array, for row 1. This bit can only be set if the STATE_V_D_R1 is also set.

See Also:
Constant Field Values

STATE_PREV_MR_R1

private static final int STATE_PREV_MR_R1
The flag bit for the previous MR primitive applied in the state array, for row 1.

See Also:
Constant Field Values

STATE_H_L_R1

private static final int STATE_H_L_R1
The flag bit for the horizontal-left significance in the state array, for row 1.

See Also:
Constant Field Values

STATE_H_R_R1

private static final int STATE_H_R_R1
The flag bit for the horizontal-right significance in the state array, for row 1.

See Also:
Constant Field Values

STATE_V_U_R1

private static final int STATE_V_U_R1
The flag bit for the vertical-up significance in the state array, for row 1.

See Also:
Constant Field Values

STATE_V_D_R1

private static final int STATE_V_D_R1
The flag bit for the vertical-down significance in the state array, for row 1.

See Also:
Constant Field Values

STATE_D_UL_R1

private static final int STATE_D_UL_R1
The flag bit for the diagonal up-left significance in the state array, for row 1.

See Also:
Constant Field Values

STATE_D_UR_R1

private static final int STATE_D_UR_R1
The flag bit for the diagonal up-right significance in the state array, for row 1.

See Also:
Constant Field Values

STATE_D_DL_R1

private static final int STATE_D_DL_R1
The flag bit for the diagonal down-left significance in the state array, for row 1.

See Also:
Constant Field Values

STATE_D_DR_R1

private static final int STATE_D_DR_R1
The flag bit for the diagonal down-right significance in the state array , for row 1.

See Also:
Constant Field Values

STATE_SIG_R2

private static final int STATE_SIG_R2
The flag bit for the significance in the state array, for row 2.

See Also:
Constant Field Values

STATE_VISITED_R2

private static final int STATE_VISITED_R2
The flag bit for the "visited" bit in the state array, for row 2.

See Also:
Constant Field Values

STATE_NZ_CTXT_R2

private static final int STATE_NZ_CTXT_R2
The flag bit for the "not zero context" bit in the state array, for row 2. This bit is always the OR of bits STATE_H_L_R2, STATE_H_R_R2, STATE_V_U_R2, STATE_V_D_R2, STATE_D_UL_R2, STATE_D_UR_R2, STATE_D_DL_R2 and STATE_D_DR_R2.

See Also:
Constant Field Values

STATE_H_L_SIGN_R2

private static final int STATE_H_L_SIGN_R2
The flag bit for the horizontal-left sign in the state array, for row 2. This bit can only be set if the STATE_H_L_R2 is also set.

See Also:
Constant Field Values

STATE_H_R_SIGN_R2

private static final int STATE_H_R_SIGN_R2
The flag bit for the horizontal-right sign in the state array, for row 2. This bit can only be set if the STATE_H_R_R2 is also set.

See Also:
Constant Field Values

STATE_V_U_SIGN_R2

private static final int STATE_V_U_SIGN_R2
The flag bit for the vertical-up sign in the state array, for row 2. This bit can only be set if the STATE_V_U_R2 is also set.

See Also:
Constant Field Values

STATE_V_D_SIGN_R2

private static final int STATE_V_D_SIGN_R2
The flag bit for the vertical-down sign in the state array, for row 2. This bit can only be set if the STATE_V_D_R2 is also set.

See Also:
Constant Field Values

STATE_PREV_MR_R2

private static final int STATE_PREV_MR_R2
The flag bit for the previous MR primitive applied in the state array, for row 2.

See Also:
Constant Field Values

STATE_H_L_R2

private static final int STATE_H_L_R2
The flag bit for the horizontal-left significance in the state array, for row 2.

See Also:
Constant Field Values

STATE_H_R_R2

private static final int STATE_H_R_R2
The flag bit for the horizontal-right significance in the state array, for row 2.

See Also:
Constant Field Values

STATE_V_U_R2

private static final int STATE_V_U_R2
The flag bit for the vertical-up significance in the state array, for row 2.

See Also:
Constant Field Values

STATE_V_D_R2

private static final int STATE_V_D_R2
The flag bit for the vertical-down significance in the state array, for row 2.

See Also:
Constant Field Values

STATE_D_UL_R2

private static final int STATE_D_UL_R2
The flag bit for the diagonal up-left significance in the state array, for row 2.

See Also:
Constant Field Values

STATE_D_UR_R2

private static final int STATE_D_UR_R2
The flag bit for the diagonal up-right significance in the state array, for row 2.

See Also:
Constant Field Values

STATE_D_DL_R2

private static final int STATE_D_DL_R2
The flag bit for the diagonal down-left significance in the state array, for row 2.

See Also:
Constant Field Values

STATE_D_DR_R2

private static final int STATE_D_DR_R2
The flag bit for the diagonal down-right significance in the state array , for row 2.

See Also:
Constant Field Values

SIG_MASK_R1R2

private static final int SIG_MASK_R1R2
The mask to isolate the significance bits for row 1 and 2 of the state array.

See Also:
Constant Field Values

VSTD_MASK_R1R2

private static final int VSTD_MASK_R1R2
The mask to isolate the visited bits for row 1 and 2 of the state array.

See Also:
Constant Field Values

RLC_MASK_R1R2

private static final int RLC_MASK_R1R2
The mask to isolate the bits necessary to identify RLC coding state (significant, visited and non-zero context, for row 1 and 2).

See Also:
Constant Field Values

ZC_MASK

private static final int ZC_MASK
The mask to obtain the ZC_LUT index from the 'state' information

See Also:
Constant Field Values

SC_SHIFT_R1

private static final int SC_SHIFT_R1
The shift to obtain the SC index to 'SC_LUT' from the 'state' information, for row 1.

See Also:
Constant Field Values

SC_SHIFT_R2

private static final int SC_SHIFT_R2
The shift to obtain the SC index to 'SC_LUT' from the state information, for row 2.

See Also:
Constant Field Values

SC_MASK

private static final int SC_MASK
The bit mask to isolate the state bits relative to the sign coding lookup table ('SC_LUT').

See Also:
Constant Field Values

MR_MASK

private static final int MR_MASK
The mask to obtain the MR index to 'MR_LUT' from the 'state' information. It is to be applied after the 'MR_SHIFT'

See Also:
Constant Field Values

srcblk

private DecLyrdCBlk srcblk
The source code-block to entropy code (avoids reallocation for each code-block).


mQuit

private int mQuit
The maximum number of bit planes to decode for any code-block

Constructor Detail

StdEntropyDecoder

public StdEntropyDecoder(CodedCBlkDataSrcDec src,
                         DecoderSpecs decSpec,
                         boolean doer,
                         boolean verber,
                         int mQuit)
Instantiates a new entropy decoder engine, with the specified source of data, nominal block width and height.

Parameters:
src - The source of data
doer - If true error detection will be performed, if any error detection features have been enabled.
verber - This flag indicates if the entropy decoder should be verbose about bit stream errors that are detected and concealed.
mQuit - the maximum number of bit planes to decode according to the m quit condition
Method Detail

finalize

public void finalize()
              throws java.lang.Throwable
Prints the timing information, if collected, and calls 'finalize' on the super class.

Overrides:
finalize in class java.lang.Object
java.lang.Throwable

getCodeBlock

public DataBlk getCodeBlock(int c,
                            int m,
                            int n,
                            SubbandSyn sb,
                            DataBlk cblk)
Returns the specified code-block in the current tile for the specified component, as a copy (see below).

The returned code-block may be progressive, which is indicated by the 'progressive' variable of the returned 'DataBlk' object. If a code-block is progressive it means that in a later request to this method for the same code-block it is possible to retrieve data which is a better approximation, since meanwhile more data to decode for the code-block could have been received. If the code-block is not progressive then later calls to this method for the same code-block will return the exact same data values.

The data returned by this method is always a copy of the internal data of this object, if any, and it can be modified "in place" without any problems after being returned. The 'offset' of the returned data is 0, and the 'scanw' is the same as the code-block width. See the 'DataBlk' class.

The 'ulx' and 'uly' members of the returned 'DataBlk' object contain the coordinates of the top-left corner of the block, with respect to the tile, not the subband.

Specified by:
getCodeBlock in interface CBlkQuantDataSrcDec
Parameters:
c - The component for which to return the next code-block.
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 which the code-block to return is.
cblk - If non-null this object will be used to return the new code-block. If null a new one will be allocated and returned. If the "data" array of the object is non-null it will be reused, if possible, to return the data.
Returns:
The next code-block in the current tile for component 'n', or null if all code-blocks for the current tile have been returned.
See Also:
DataBlk

getInternCodeBlock

public DataBlk getInternCodeBlock(int c,
                                  int m,
                                  int n,
                                  SubbandSyn sb,
                                  DataBlk cblk)
Returns the specified code-block in the current tile for the specified component (as a reference or copy).

The returned code-block may be progressive, which is indicated by the 'progressive' variable of the returned 'DataBlk' object. If a code-block is progressive it means that in a later request to this method for the same code-block it is possible to retrieve data which is a better approximation, since meanwhile more data to decode for the code-block could have been received. If the code-block is not progressive then later calls to this method for the same code-block will return the exact same data values.

The data returned by this method can be the data in the internal buffer of this object, if any, and thus can not be modified by the caller. The 'offset' and 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class.

The 'ulx' and 'uly' members of the returned 'DataBlk' object contain the coordinates of the top-left corner of the block, with respect to the tile, not the subband.

Specified by:
getInternCodeBlock in interface CBlkQuantDataSrcDec
Parameters:
c - The component for which to return the next code-block.
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 which the code-block to return is.
cblk - If non-null this object will be used to return the new code-block. If null a new one will be allocated and returned. If the "data" array of the object is non-null it will be reused, if possible, to return the data.
Returns:
The next code-block in the current tile for component 'n', or null if all code-blocks for the current tile have been returned.
See Also:
DataBlk

sigProgPass

private boolean sigProgPass(DataBlk cblk,
                            MQDecoder mq,
                            int bp,
                            int[] state,
                            int[] zc_lut,
                            boolean isterm)
Performs the significance propagation pass on the specified data and bit-plane. It decodes all insignificant samples which have, at least, one of its immediate eight neighbors already significant, using the ZC and SC primitives as needed. It toggles the "visited" state bit to 1 for all those samples.

This method also checks for segmentation markers if those are present and returns true if an error is detected, or false otherwise. If an error is detected it means that the bit stream contains some erroneous bit that have led to the decoding of incorrect data. This data affects the whole last decoded bit-plane (i.e. 'bp'). If 'true' is returned the 'conceal' method should be called and no more passes should be decoded for this code-block's bit stream.

Parameters:
cblk - The code-block data to decode
mq - The MQ-coder to use
bp - The bit-plane to decode
state - The state information for the code-block
zc_lut - The ZC lookup table to use in ZC.
isterm - If this pass has been terminated. If the pass has been terminated it can be used to check error resilience.
Returns:
True if an error was detected in the bit stream, false otherwise.

rawSigProgPass

private boolean rawSigProgPass(DataBlk cblk,
                               ByteToBitInput bin,
                               int bp,
                               int[] state,
                               boolean isterm)
Performs the significance propagation pass on the specified data and bit-plane. It decodes all insignificant samples which have, at least, one of its immediate eight neighbors already significant, using the ZC and SC primitives as needed. It toggles the "visited" state bit to 1 for all those samples.

This method bypasses the arithmetic coder and reads "raw" symbols from the bit stream.

This method also checks for segmentation markers if those are present and returns true if an error is detected, or false otherwise. If an error is detected it measn that the bit stream contains some erroneous bit that have led to the decoding of incorrect data. This data affects the whole last decoded bit-plane (i.e. 'bp'). If 'true' is returned the 'conceal' method should be called and no more passes should be decoded for this code-block's bit stream.

Parameters:
cblk - The code-block data to decode
bin - The raw bit based input
bp - The bit-plane to decode
state - The state information for the code-block
isterm - If this pass has been terminated. If the pass has been terminated it can be used to check error resilience.
Returns:
True if an error was detected in the bit stream, false otherwise.

magRefPass

private boolean magRefPass(DataBlk cblk,
                           MQDecoder mq,
                           int bp,
                           int[] state,
                           boolean isterm)
Performs the magnitude refinement pass on the specified data and bit-plane. It decodes the samples which are significant and which do not have the "visited" state bit turned on, using the MR primitive. The "visited" state bit is not mofified for any samples.

This method also checks for segmentation markers if those are present and returns true if an error is detected, or false otherwise. If an error is detected it means that the bit stream contains some erroneous bit that have led to the decoding of incorrect data. This data affects the whole last decoded bit-plane (i.e. 'bp'). If 'true' is returned the 'conceal' method should be called and no more passes should be decoded for this code-block's bit stream.

Parameters:
cblk - The code-block data to decode
mq - The MQ-decoder to use
bp - The bit-plane to decode
state - The state information for the code-block
isterm - If this pass has been terminated. If the pass has been terminated it can be used to check error resilience.
Returns:
True if an error was detected in the bit stream, false otherwise.

rawMagRefPass

private boolean rawMagRefPass(DataBlk cblk,
                              ByteToBitInput bin,
                              int bp,
                              int[] state,
                              boolean isterm)
Performs the magnitude refinement pass on the specified data and bit-plane. It decodes the samples which are significant and which do not have the "visited" state bit turned on, using the MR primitive. The "visited" state bit is not mofified for any samples.

This method bypasses the arithmetic coder and reads "raw" symbols from the bit stream.

This method also checks for segmentation markers if those are present and returns true if an error is detected, or false otherwise. If an error is detected it measn that the bit stream contains some erroneous bit that have led to the decoding of incorrect data. This data affects the whole last decoded bit-plane (i.e. 'bp'). If 'true' is returned the 'conceal' method should be called and no more passes should be decoded for this code-block's bit stream.

Parameters:
cblk - The code-block data to decode
bin - The raw bit based input
bp - The bit-plane to decode
state - The state information for the code-block
isterm - If this pass has been terminated. If the pass has been terminated it can be used to check error resilience.
Returns:
True if an error was detected in the bit stream, false otherwise.

cleanuppass

private boolean cleanuppass(DataBlk cblk,
                            MQDecoder mq,
                            int bp,
                            int[] state,
                            int[] zc_lut,
                            boolean isterm)
Performs the cleanup pass on the specified data and bit-plane. It decodes all insignificant samples which have its "visited" state bit off, using the ZC, SC, and RLC primitives. It toggles the "visited" state bit to 0 (off) for all samples in the code-block.

This method also checks for segmentation markers if those are present and returns true if an error is detected, or false otherwise. If an error is detected it measn that the bit stream contains some erroneous bit that have led to the decoding of incorrect data. This data affects the whole last decoded bit-plane (i.e. 'bp'). If 'true' is returned the 'conceal' method should be called and no more passes should be decoded for this code-block's bit stream.

Parameters:
cblk - The code-block data to code
mq - The MQ-coder to use
bp - The bit-plane to decode
state - The state information for the code-block
zc_lut - The ZC lookup table to use in ZC.
isterm - If this pass has been terminated. If the pass has been terminated it can be used to check error resilience.
Returns:
True if an error was detected in the bit stream, false otherwise.

conceal

private void conceal(DataBlk cblk,
                     int bp)
Conceals decoding errors detected in the last bit-plane. The concealement resets the state of the decoded data to what it was before the decoding of bit-plane 'bp' started. No more data should be decoded after this method is called for this code-block's data to which it is applied.

Parameters:
cblk - The code-block's data
bp - The last decoded bit-plane (which contains errors).