public class StdEntropyDecoder extends EntropyDecoder implements StdEntropyCoderOptions
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.
Modifier and Type | Field and Description |
---|---|
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 symbol segmentation marker (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
|
OPT_PREFIX, src
mressrc, tIdx
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 and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
getCbULX, getCbULY, getParameterInfo, getSynSubbandTree
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
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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
private static final boolean DO_TIMING
private long[] time
private ByteToBitInput bin
private MQDecoder mq
private DecoderSpecs decSpec
private int options
StdEntropyCoderOptions
private final boolean doer
private final boolean verber
private static final int ZC_LUT_BITS
private static final int[] ZC_LUT_LH
private static final int[] ZC_LUT_HL
private static final int[] ZC_LUT_HH
private static final int SC_LUT_BITS
private static final int[] SC_LUT
private static final int SC_LUT_MASK
private static final int SC_SPRED_SHIFT
private static final int INT_SIGN_BIT
private static final int MR_LUT_BITS
private static final int[] MR_LUT
private static final int NUM_CTXTS
private static final int RLC_CTXT
private static final int UNIF_CTXT
private static final int[] MQ_INIT
private static final int SEG_SYMBOL
private final int[] state
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").
private static final int STATE_SEP
private static final int STATE_SIG_R1
private static final int STATE_VISITED_R1
private static final int STATE_NZ_CTXT_R1
private static final int STATE_H_L_SIGN_R1
private static final int STATE_H_R_SIGN_R1
private static final int STATE_V_U_SIGN_R1
private static final int STATE_V_D_SIGN_R1
private static final int STATE_PREV_MR_R1
private static final int STATE_H_L_R1
private static final int STATE_H_R_R1
private static final int STATE_V_U_R1
private static final int STATE_V_D_R1
private static final int STATE_D_UL_R1
private static final int STATE_D_UR_R1
private static final int STATE_D_DL_R1
private static final int STATE_D_DR_R1
private static final int STATE_SIG_R2
private static final int STATE_VISITED_R2
private static final int STATE_NZ_CTXT_R2
private static final int STATE_H_L_SIGN_R2
private static final int STATE_H_R_SIGN_R2
private static final int STATE_V_U_SIGN_R2
private static final int STATE_V_D_SIGN_R2
private static final int STATE_PREV_MR_R2
private static final int STATE_H_L_R2
private static final int STATE_H_R_R2
private static final int STATE_V_U_R2
private static final int STATE_V_D_R2
private static final int STATE_D_UL_R2
private static final int STATE_D_UR_R2
private static final int STATE_D_DL_R2
private static final int STATE_D_DR_R2
private static final int SIG_MASK_R1R2
private static final int VSTD_MASK_R1R2
private static final int RLC_MASK_R1R2
private static final int ZC_MASK
private static final int SC_SHIFT_R1
private static final int SC_SHIFT_R2
private static final int SC_MASK
private static final int MR_MASK
private DecLyrdCBlk srcblk
private int mQuit
public StdEntropyDecoder(CodedCBlkDataSrcDec src, DecoderSpecs decSpec, boolean doer, boolean verber, int mQuit)
src
- The source of datadecSpec
- The decoder specificationsdoer
- 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.public void finalize() throws Throwable
public DataBlk getCodeBlock(int c, int m, int n, SubbandSyn sb, DataBlk cblk)
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.
getCodeBlock
in interface CBlkQuantDataSrcDec
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.DataBlk
public DataBlk getInternCodeBlock(int c, int m, int n, SubbandSyn sb, DataBlk cblk)
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.
getInternCodeBlock
in interface CBlkQuantDataSrcDec
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.DataBlk
private boolean sigProgPass(DataBlk cblk, MQDecoder mq, int bp, int[] state, int[] zc_lut, boolean isterm)
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.
cblk
- The code-block data to decodemq
- The MQ-coder to usebp
- The bit-plane to decodestate
- The state information for the code-blockzc_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.private boolean rawSigProgPass(DataBlk cblk, ByteToBitInput bin, int bp, int[] state, boolean isterm)
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.
cblk
- The code-block data to decodebin
- The raw bit based inputbp
- The bit-plane to decodestate
- The state information for the code-blockisterm
- If this pass has been terminated. If the pass has been
terminated it can be used to check error resilience.private boolean magRefPass(DataBlk cblk, MQDecoder mq, int bp, int[] state, boolean isterm)
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.
cblk
- The code-block data to decodemq
- The MQ-decoder to usebp
- The bit-plane to decodestate
- The state information for the code-blockisterm
- If this pass has been terminated. If the pass has been
terminated it can be used to check error resilience.private boolean rawMagRefPass(DataBlk cblk, ByteToBitInput bin, int bp, int[] state, boolean isterm)
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.
cblk
- The code-block data to decodebin
- The raw bit based inputbp
- The bit-plane to decodestate
- The state information for the code-blockisterm
- If this pass has been terminated. If the pass has been
terminated it can be used to check error resilience.private boolean cleanuppass(DataBlk cblk, MQDecoder mq, int bp, int[] state, int[] zc_lut, boolean isterm)
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.
cblk
- The code-block data to codemq
- The MQ-coder to usebp
- The bit-plane to decodestate
- The state information for the code-blockzc_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.private void conceal(DataBlk cblk, int bp)
cblk
- The code-block's databp
- The last decoded bit-plane (which contains errors).Copyright © 2016 Open Microscopy Environment