jj2000.j2k.entropy.encoder
Class CBlkRateDistStats

java.lang.Object
  |
  +--jj2000.j2k.entropy.CodedCBlk
        |
        +--jj2000.j2k.entropy.encoder.CBlkRateDistStats

public class CBlkRateDistStats
extends CodedCBlk

This class stores coded (compressed) code-blocks with their associated rate-distortion statistics. This object should always contain all the compressed data of the code-block. It is applicable to the encoder engine only. Some data of the coded-block is stored in the super class, see CodedCBlk.

The rate-distortion statistics (i.e. R-D slope) is stored for valid points only. The set of valid points is determined by the entropy coder engine itself. Normally they are selected so as to lye in a convex hull, which can be achived by using the 'selectConvexHull' method of this class, but some other strategies might be employed.

The rate (in bytes) for each truncation point (valid or not) is stored in the 'truncRates' array. The rate of a truncation point is the total number of bytes in 'data' (see super class) that have to be decoded to reach the truncation point.

The slope (reduction of distortion divided by the increase in rate) at each of the valid truncation points is stored in 'truncSlopes'.

The index of each valid truncation point is stored in 'truncIdxs'. The index should be interpreted in the following way: a valid truncation point at position 'n' has the index 'truncIdxs[n]', the rate 'truncRates[truncIdxs[n]]' and the slope 'truncSlopes[n]'. The arrays 'truncIdxs' and 'truncRates' have at least 'nVldTrunc' elements. The 'truncRates' array has at least 'nTotTrunc' elements.

In addition the 'isTermPass' array contains a flag for each truncation point (valid and non-valid ones) that tells if the pass is terminated or not. If this variable is null then it means that no pass is terminated, except the last one which always is.

The compressed data is stored in the 'data' member variable of the super class.

See Also:
CodedCBlk

Field Summary
 boolean[] isTermPass
          Array of flags indicating terminated passes (valid or non-valid truncation points).
 int nROIcoeff
          The number of ROI coefficients in the code-block
 int nROIcp
          Number of ROI coding passes
 int nTotTrunc
          The total number of truncation points
 int nVldTrunc
          The number of valid truncation points
 SubbandAn sb
          The subband to which the code-block belongs
 double[] truncDists
          The distortion for each truncation point (valid and non-valid ones)
 int[] truncIdxs
          The indices of the valid truncation points, in increasing order.
 int[] truncRates
          The rate (in bytes) for each truncation point (valid and non-valid ones)
 float[] truncSlopes
          The negative of the rate-distortion slope for each valid truncation point
 
Fields inherited from class jj2000.j2k.entropy.CodedCBlk
data, m, n, skipMSBP
 
Constructor Summary
CBlkRateDistStats()
          Creates a new CBlkRateDistStats object without allocating any space for 'truncRates', 'truncSlopes', 'truncDists' and 'truncIdxs' or 'data'.
CBlkRateDistStats(int m, int n, int skipMSBP, byte[] data, int[] rates, double[] dists, boolean[] termp, int np, boolean inclast)
          Creates a new CBlkRateDistStats object and initializes the valid truncation points, their rates and their slopes, from the 'rates' and 'dist' arrays.
 
Method Summary
 void selectConvexHull(int[] rates, double[] dists, boolean[] termp, int n, boolean inclast)
          Compute the rate-distorsion slopes and selects those that lie in a convex hull.
 java.lang.String toString()
          Returns the contents of the object in a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sb

public SubbandAn sb
The subband to which the code-block belongs


nTotTrunc

public int nTotTrunc
The total number of truncation points


nVldTrunc

public int nVldTrunc
The number of valid truncation points


truncRates

public int[] truncRates
The rate (in bytes) for each truncation point (valid and non-valid ones)


truncDists

public double[] truncDists
The distortion for each truncation point (valid and non-valid ones)


truncSlopes

public float[] truncSlopes
The negative of the rate-distortion slope for each valid truncation point


truncIdxs

public int[] truncIdxs
The indices of the valid truncation points, in increasing order.


isTermPass

public boolean[] isTermPass
Array of flags indicating terminated passes (valid or non-valid truncation points).


nROIcoeff

public int nROIcoeff
The number of ROI coefficients in the code-block


nROIcp

public int nROIcp
Number of ROI coding passes

Constructor Detail

CBlkRateDistStats

public CBlkRateDistStats()
Creates a new CBlkRateDistStats object without allocating any space for 'truncRates', 'truncSlopes', 'truncDists' and 'truncIdxs' or 'data'.


CBlkRateDistStats

public CBlkRateDistStats(int m,
                         int n,
                         int skipMSBP,
                         byte[] data,
                         int[] rates,
                         double[] dists,
                         boolean[] termp,
                         int np,
                         boolean inclast)
Creates a new CBlkRateDistStats object and initializes the valid truncation points, their rates and their slopes, from the 'rates' and 'dist' arrays. The 'rates', 'dist' and 'termp' arrays must contain the rate (in bytes), the reduction in distortion (from nothing coded) and the flag indicating if termination is used, respectively, for each truncation point.

The valid truncation points are selected by taking them as lying on a convex hull. This is done by calling the method selectConvexHull().

Note that the arrays 'rates' and 'termp' are copied, not referenced, so they can be modified after a call to this constructor.

Parameters:
m - The horizontal index of the code-block, within the subband.
n - The vertical index of the code-block, within the subband.
skipMSBP - The number of skipped most significant bit-planes for this code-block.
data - The compressed data. This array is referenced by this object so it should not be modified after.
rates - The rates (in bytes) for each truncation point in the compressed data. This array is modified by the method but no reference is kept to it.
dists - The reduction in distortion (with respect to no information coded) for each truncation point. This array is modified by the method but no reference is kept to it.
termp - An array of boolean flags indicating, for each pass, if a pass is terminated or not (true if terminated). If null then it is assumed that no pass is terminated except the last one which always is.
np - The number of truncation points contained in 'rates', 'dist' and 'termp'.
inclast - If false the convex hull is constructed as for lossy coding. If true it is constructed as for lossless coding, in which case it is ensured that all bit-planes are sent (i.e. the last truncation point is always included).
Method Detail

selectConvexHull

public void selectConvexHull(int[] rates,
                             double[] dists,
                             boolean[] termp,
                             int n,
                             boolean inclast)
Compute the rate-distorsion slopes and selects those that lie in a convex hull. It will compute the slopes, select the ones that form the convex hull and initialize the 'truncIdxs' and 'truncSlopes' arrays, as well as 'nVldTrunc', with the selected truncation points. It will also initialize 'truncRates' and 'isTermPass' arrays, as well as 'nTotTrunc', with all the truncation points (selected or not).

Note that the arrays 'rates' and 'termp' are copied, not referenced, so they can be modified after a call to this method.

Parameters:
rates - The rates (in bytes) for each truncation point in the compressed data. This array is modified by the method.
dists - The reduction in distortion (with respect to no information coded) for each truncation point. This array is modified by the method.
termp - An array of boolean flags indicating, for each pass, if a pass is terminated or not (true if terminated). If null then it is assumed that no pass is terminated except the last one which always is.
n - The number of truncation points contained in 'rates', 'dist' and 'termp'.
inclast - If false the convex hull is constructed as for lossy coding. If true it is constructed as for lossless coding, in which case it is ensured that all bit-planes are sent (i.e. the last truncation point is always included).

toString

public java.lang.String toString()
Returns the contents of the object in a string. This is used for debugging.

Overrides:
toString in class CodedCBlk
Returns:
A string with the contents of the object