ucar.jpeg.jj2000.j2k.entropy.encoder
Class EBCOTRateAllocator

java.lang.Object
  extended by ucar.jpeg.jj2000.j2k.image.ImgDataAdapter
      extended by ucar.jpeg.jj2000.j2k.entropy.encoder.PostCompRateAllocator
          extended by ucar.jpeg.jj2000.j2k.entropy.encoder.EBCOTRateAllocator
All Implemented Interfaces:
ImgData

public class EBCOTRateAllocator
extends PostCompRateAllocator

This implements the EBCOT post compression rate allocation algorithm. This algorithm finds the most suitable truncation points for the set of code-blocks, for each layer target bitrate. It works by first collecting the rate distortion info from all code-blocks, in all tiles and all components, and then running the rate-allocation on the whole image at once, for each layer.

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.

See Also:
PostCompRateAllocator, CodedCBlkDataSrcEnc, jj2000.j2k.codestream.writer.CodestreamWriter

Field Summary
 
Fields inherited from class ucar.jpeg.jj2000.j2k.entropy.encoder.PostCompRateAllocator
encSpec, numLayers, OPT_PREFIX, src
 
Fields inherited from class ucar.jpeg.jj2000.j2k.image.ImgDataAdapter
imgdatasrc, tIdx
 
Constructor Summary
EBCOTRateAllocator(CodedCBlkDataSrcEnc src, LayersInfo lyrs, CodestreamWriter writer, EncoderSpecs encSpec, ParameterList pl)
          Initializes the EBCOT rate allocator of entropy coded data.
 
Method Summary
 void finalize()
          Prints the timing information, if collected, and calls 'finalize' on the super class.
 void initialize()
          Initializes the layers array.
 void runAndWrite()
          Runs the rate allocation algorithm and writes the data to the bit stream writer object provided to the constructor.
 void writeCompPosResLy(int t, int rs, int re, int cs, int ce, int[][] lys, int lye)
          Write a piece of bit stream according to the COMP_POS_RES_LY_PROG progression mode and between given bounds
 void writeLyResCompPos(int t, int rs, int re, int cs, int ce, int[][] lys, int lye)
          Write a piece of bit stream according to the LY_RES_COMP_POS_PROG progression mode and between given bounds
 void writePosCompResLy(int t, int rs, int re, int cs, int ce, int[][] lys, int lye)
          Write a piece of bit stream according to the COMP_POS_RES_LY_PROG progression mode and between given bounds
 void writeResLyCompPos(int t, int rs, int re, int cs, int ce, int[][] lys, int lye)
          Write a piece of bit stream according to the RES_LY_COMP_POS_PROG progression mode and between given bounds
 void writeResPosCompLy(int t, int rs, int re, int cs, int ce, int[][] lys, int lye)
          Write a piece of bit stream according to the RES_POS_COMP_LY_PROG progression mode and between given bounds
 
Methods inherited from class ucar.jpeg.jj2000.j2k.entropy.encoder.PostCompRateAllocator
createInstance, getNumLayers, getParameterInfo, setHeaderEncoder
 
Methods inherited from class ucar.jpeg.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, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EBCOTRateAllocator

public EBCOTRateAllocator(CodedCBlkDataSrcEnc src,
                          LayersInfo lyrs,
                          CodestreamWriter writer,
                          EncoderSpecs encSpec,
                          ParameterList pl)
Initializes the EBCOT rate allocator of entropy coded data. The layout of layers, and their bitrate constraints, is specified by the 'lyrs' parameter.

Parameters:
src - The source of entropy coded data.
lyrs - The layers layout specification.
writer - The bit stream writer.
See Also:
ProgressionType
Method Detail

finalize

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

Overrides:
finalize in class Object
Throws:
Throwable

runAndWrite

public void runAndWrite()
                 throws IOException
Runs the rate allocation algorithm and writes the data to the bit stream writer object provided to the constructor.

Specified by:
runAndWrite in class PostCompRateAllocator
Throws:
IOException
See Also:
PostCompRateAllocator.initialize()

initialize

public void initialize()
                throws IOException
Initializes the layers array. This must be called after the main header has been entirely written or simulated, so as to take its overhead into account. This method will get all the code-blocks and then initialize the target bitrates for each layer, according to the specifications.

Specified by:
initialize in class PostCompRateAllocator
Throws:
IOException
See Also:
PostCompRateAllocator.runAndWrite()

writeResLyCompPos

public void writeResLyCompPos(int t,
                              int rs,
                              int re,
                              int cs,
                              int ce,
                              int[][] lys,
                              int lye)
                       throws IOException
Write a piece of bit stream according to the RES_LY_COMP_POS_PROG progression mode and between given bounds

Parameters:
t - Tile index.
rs - First resolution level index.
re - Last resolution level index.
cs - First component index.
ce - Last component index.
lys - First layer index for each component and resolution.
lye - Index of the last layer.
Throws:
IOException

writeLyResCompPos

public void writeLyResCompPos(int t,
                              int rs,
                              int re,
                              int cs,
                              int ce,
                              int[][] lys,
                              int lye)
                       throws IOException
Write a piece of bit stream according to the LY_RES_COMP_POS_PROG progression mode and between given bounds

Parameters:
t - Tile index.
rs - First resolution level index.
re - Last resolution level index.
cs - First component index.
ce - Last component index.
lys - First layer index for each component and resolution.
lye - Index of the last layer.
Throws:
IOException

writePosCompResLy

public void writePosCompResLy(int t,
                              int rs,
                              int re,
                              int cs,
                              int ce,
                              int[][] lys,
                              int lye)
                       throws IOException
Write a piece of bit stream according to the COMP_POS_RES_LY_PROG progression mode and between given bounds

Parameters:
t - Tile index.
rs - First resolution level index.
re - Last resolution level index.
cs - First component index.
ce - Last component index.
lys - First layer index for each component and resolution.
lye - Index of the last layer.
Throws:
IOException

writeCompPosResLy

public void writeCompPosResLy(int t,
                              int rs,
                              int re,
                              int cs,
                              int ce,
                              int[][] lys,
                              int lye)
                       throws IOException
Write a piece of bit stream according to the COMP_POS_RES_LY_PROG progression mode and between given bounds

Parameters:
t - Tile index.
rs - First resolution level index.
re - Last resolution level index.
cs - First component index.
ce - Last component index.
lys - First layer index for each component and resolution.
lye - Index of the last layer.
Throws:
IOException

writeResPosCompLy

public void writeResPosCompLy(int t,
                              int rs,
                              int re,
                              int cs,
                              int ce,
                              int[][] lys,
                              int lye)
                       throws IOException
Write a piece of bit stream according to the RES_POS_COMP_LY_PROG progression mode and between given bounds

Parameters:
t - Tile index.
rs - First resolution level index.
re - Last resolution level index.
cs - First component index.
ce - Last component index.
lys - First layer index for each component and resolution.
lye - Last layer index.
Throws:
IOException


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.