C# Class CSJ2K.j2k.entropy.decoder.StdEntropyDecoder

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.

Inheritance: CSJ2K.j2k.entropy.decoder.EntropyDecoder
Show file Open project: cureos/csj2k

Public Methods

Method Description
StdEntropyDecoder ( CodedCBlkDataSrcDec src, DecoderSpecs decSpec, bool doer, bool verber, int mQuit ) : System

Instantiates a new entropy decoder engine, with the specified source of data, nominal block width and height.

getCodeBlock ( int c, int m, int n, CSJ2K.j2k.wavelet.synthesis.SubbandSyn sb, CSJ2K.j2k.image.DataBlk cblk ) : CSJ2K.j2k.image.DataBlk

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.

getInternCodeBlock ( int c, int m, int n, CSJ2K.j2k.wavelet.synthesis.SubbandSyn sb, CSJ2K.j2k.image.DataBlk cblk ) : CSJ2K.j2k.image.DataBlk

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.

Private Methods

Method Description
StdEntropyDecoder ( ) : System

Static initializer: initializes all the lookup tables.

cleanuppass ( CSJ2K.j2k.image.DataBlk cblk, CSJ2K.j2k.entropy.decoder.MQDecoder mq, int bp, int state, int zc_lut, bool isterm ) : bool

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.

conceal ( CSJ2K.j2k.image.DataBlk cblk, int bp ) : void

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.

magRefPass ( CSJ2K.j2k.image.DataBlk cblk, CSJ2K.j2k.entropy.decoder.MQDecoder mq, int bp, int state, bool isterm ) : bool

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.

rawMagRefPass ( CSJ2K.j2k.image.DataBlk cblk, CSJ2K.j2k.entropy.decoder.ByteToBitInput bin, int bp, int state, bool isterm ) : bool

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.

rawSigProgPass ( CSJ2K.j2k.image.DataBlk cblk, CSJ2K.j2k.entropy.decoder.ByteToBitInput bin, int bp, int state, bool isterm ) : bool

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.

sigProgPass ( CSJ2K.j2k.image.DataBlk cblk, CSJ2K.j2k.entropy.decoder.MQDecoder mq, int bp, int state, int zc_lut, bool isterm ) : bool

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.

Method Details

StdEntropyDecoder() public method

Instantiates a new entropy decoder engine, with the specified source of data, nominal block width and height.
public StdEntropyDecoder ( CodedCBlkDataSrcDec src, DecoderSpecs decSpec, bool doer, bool verber, int mQuit ) : System
src CodedCBlkDataSrcDec The source of data /// ///
decSpec CSJ2K.j2k.decoder.DecoderSpecs
doer bool If true error detection will be performed, if any error /// detection features have been enabled. /// ///
verber bool This flag indicates if the entropy decoder should be /// verbose about bit stream errors that are detected and concealed. /// ///
mQuit int the maximum number of bit planes to decode according to /// the m quit condition /// ///
return System

getCodeBlock() public method

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.

public getCodeBlock ( int c, int m, int n, CSJ2K.j2k.wavelet.synthesis.SubbandSyn sb, CSJ2K.j2k.image.DataBlk cblk ) : CSJ2K.j2k.image.DataBlk
c int The component for which to return the next code-block. /// ///
m int The vertical index of the code-block to return, in the /// specified subband. /// ///
n int The horizontal index of the code-block to return, in the /// specified subband. /// ///
sb CSJ2K.j2k.wavelet.synthesis.SubbandSyn The subband in which the code-block to return is. /// ///
cblk CSJ2K.j2k.image.DataBlk 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. /// ///
return CSJ2K.j2k.image.DataBlk

getInternCodeBlock() public method

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.

public getInternCodeBlock ( int c, int m, int n, CSJ2K.j2k.wavelet.synthesis.SubbandSyn sb, CSJ2K.j2k.image.DataBlk cblk ) : CSJ2K.j2k.image.DataBlk
c int The component for which to return the next code-block. /// ///
m int The vertical index of the code-block to return, in the /// specified subband. /// ///
n int The horizontal index of the code-block to return, in the /// specified subband. /// ///
sb CSJ2K.j2k.wavelet.synthesis.SubbandSyn The subband in which the code-block to return is. /// ///
cblk CSJ2K.j2k.image.DataBlk 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. /// ///
return CSJ2K.j2k.image.DataBlk