jj2000.j2k.entropy.encoder
Class PostCompRateAllocator

java.lang.Object
  |
  +--jj2000.j2k.image.ImgDataAdapter
        |
        +--jj2000.j2k.entropy.encoder.PostCompRateAllocator
All Implemented Interfaces:
ImgData
Direct Known Subclasses:
EBCOTRateAllocator

public abstract class PostCompRateAllocator
extends ImgDataAdapter

This is the abstract class from which post-compression rate allocators which generate layers should inherit. The source of data is a 'CodedCBlkDataSrcEnc' which delivers entropy coded blocks with rate-distortion statistics.

The post compression rate allocator implementation should create the layers, according to a rate allocation policy, and send the packets to a CodestreamWriter. Since the rate allocator sends the packets to the bit stream then it should output the packets to the bit stream in the order imposed by the bit stream profiles.

See Also:
CodedCBlkDataSrcEnc, CodestreamWriter

Field Summary
(package private)  CodestreamWriter bsWriter
          The bit-stream writer
protected  EncoderSpecs encSpec
          The source of entropy coded data
(package private)  HeaderEncoder headEnc
          The header encoder
protected  int numLayers
          The number of layers.
static char OPT_PREFIX
          The prefix for rate allocation options: 'A'
private static java.lang.String[][] pinfo
          The list of parameters that is accepted for entropy coding.
protected  CodedCBlkDataSrcEnc src
          The source of entropy coded data
 
Fields inherited from class jj2000.j2k.image.ImgDataAdapter
imgdatasrc, tIdx
 
Constructor Summary
PostCompRateAllocator(CodedCBlkDataSrcEnc src, int nl, CodestreamWriter bw, EncoderSpecs encSpec)
          Initializes the source of entropy coded data.
 
Method Summary
static PostCompRateAllocator createInstance(CodedCBlkDataSrcEnc src, ParameterList pl, float rate, CodestreamWriter bw, EncoderSpecs encSpec)
          Creates a PostCompRateAllocator object for the appropriate rate allocation parameters in the parameter list 'pl', having 'src' as the source of entropy coded data, 'rate' as the target bitrate and 'bw' as the bit stream writer object.
 int getNumLayers()
          Returns the number of layers that are actually generated.
static java.lang.String[][] getParameterInfo()
          Returns the parameters that are used in this class and implementing classes.
abstract  void initialize()
          Initializes the rate allocation points, taking into account header overhead and such.
private static LayersInfo parseAlayers(java.lang.String params, float rate)
          Convenience method that parses the 'Alayers' option.
abstract  void runAndWrite()
          Runs the rate allocation algorithm and writes the data to the bit stream.
 void setHeaderEncoder(HeaderEncoder headEnc)
          Keep a reference to the header encoder.
 
Methods inherited from class jj2000.j2k.image.ImgDataAdapter
getCompImgHeight, getCompImgWidth, getCompSubsX, getCompSubsY, getCompULX, getCompULY, getImgHeight, getImgULX, getImgULY, getImgWidth, getNomRangeBits, getNomTileHeight, getNomTileWidth, getNumComps, getNumTiles, getNumTiles, getTile, getTileCompHeight, getTileCompWidth, getTileHeight, getTileIdx, getTilePartULX, getTilePartULY, getTileWidth, nextTile, setTile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPT_PREFIX

public static final char OPT_PREFIX
The prefix for rate allocation options: 'A'

See Also:
Constant Field Values

pinfo

private static final java.lang.String[][] pinfo
The list of parameters that is accepted for entropy coding. Options for entropy coding start with 'R'.


src

protected CodedCBlkDataSrcEnc src
The source of entropy coded data


encSpec

protected EncoderSpecs encSpec
The source of entropy coded data


numLayers

protected int numLayers
The number of layers.


bsWriter

CodestreamWriter bsWriter
The bit-stream writer


headEnc

HeaderEncoder headEnc
The header encoder

Constructor Detail

PostCompRateAllocator

public PostCompRateAllocator(CodedCBlkDataSrcEnc src,
                             int nl,
                             CodestreamWriter bw,
                             EncoderSpecs encSpec)
Initializes the source of entropy coded data.

Parameters:
src - The source of entropy coded data.
bw - The packet bit stream writer.
See Also:
ProgressionType
Method Detail

setHeaderEncoder

public void setHeaderEncoder(HeaderEncoder headEnc)
Keep a reference to the header encoder.

Parameters:
headEnc - The header encoder

initialize

public abstract void initialize()
                         throws java.io.IOException
Initializes the rate allocation points, taking into account header overhead and such. This method must be called after the header has been simulated but before calling the runAndWrite() one. The header must be rewritten after a call to this method since the number of layers may change.

java.io.IOException
See Also:
runAndWrite()

runAndWrite

public abstract void runAndWrite()
                          throws java.io.IOException
Runs the rate allocation algorithm and writes the data to the bit stream. This must be called after the initialize() method.

java.io.IOException
See Also:
initialize()

getNumLayers

public int getNumLayers()
Returns the number of layers that are actually generated.

Returns:
The number of layers generated.

getParameterInfo

public static java.lang.String[][] getParameterInfo()
Returns the parameters that are used in this class and implementing classes. It returns a 2D String array. Each of the 1D arrays is for a different option, and they have 3 elements. The first element is the option name, the second one is the synopsis, the third one is a long description of what the parameter is and the fourth is its default value. The synopsis or description may be 'null', in which case it is assumed that there is no synopsis or description of the option, respectively. Null may be returned if no options are supported.

Returns:
the options name, their synopsis and their explanation, or null if no options are supported.

createInstance

public static PostCompRateAllocator createInstance(CodedCBlkDataSrcEnc src,
                                                   ParameterList pl,
                                                   float rate,
                                                   CodestreamWriter bw,
                                                   EncoderSpecs encSpec)
Creates a PostCompRateAllocator object for the appropriate rate allocation parameters in the parameter list 'pl', having 'src' as the source of entropy coded data, 'rate' as the target bitrate and 'bw' as the bit stream writer object.

Parameters:
src - The source of entropy coded data.
pl - The parameter lis (or options).
rate - The target bitrate for the rate allocation
bw - The bit stream writer object, where the bit stream data will be written.

parseAlayers

private static LayersInfo parseAlayers(java.lang.String params,
                                       float rate)
Convenience method that parses the 'Alayers' option.

Parameters:
params - The parameters of the 'Alayers' option
rate - The overall target bitrate
Returns:
The layer specification.