C# Class CSJ2K.j2k.codestream.writer.HeaderEncoder

This class writes almost of the markers and marker segments in main header and in tile-part headers. It is created by the run() method of the Encoder instance.

A marker segment includes a marker and eventually marker segment parameters. It is designed by the three letter code of the marker associated with the marker segment. JPEG 2000 part I defines 6 types of markers:

  • Delimiting : SOC,SOT,SOD,EOC (written in FileCodestreamWriter).
  • Fixed information: SIZ.
  • Functional: COD,COC,RGN,QCD,QCC,POC.
  • In bit-stream: SOP,EPH.
  • Pointer: TLM,PLM,PLT,PPM,PPT.
  • Informational: CRG,COM.

Main Header is written when Encoder instance calls encodeMainHeader whereas tile-part headers are written when the EBCOTRateAllocator instance calls encodeTilePartHeader.

Mostrar archivo Open project: cureos/csj2k Class Usage Examples

Protected Properties

Property Type Description
baos System.IO.MemoryStream
dwt CSJ2K.j2k.wavelet.analysis.ForwardWT
encSpec CSJ2K.j2k.encoder.EncoderSpecs
hbuf System.IO.BinaryWriter
isOrigSig bool[]
origSrc ImgData
ralloc CSJ2K.j2k.entropy.encoder.PostCompRateAllocator
roiSc CSJ2K.j2k.roi.encoder.ROIScaler
tiler CSJ2K.j2k.image.Tiler

Public Methods

Method Description
HeaderEncoder ( ImgData origsrc, bool isorigsig, ForwardWT dwt, Tiler tiler, CSJ2K.j2k.encoder.EncoderSpecs encSpec, ROIScaler roiSc, PostCompRateAllocator ralloc, CSJ2K.j2k.util.ParameterList pl ) : System

Initializes the header writer with the references to the coding chain.

encodeMainHeader ( ) : void

Write main header. JJ2000 main header corresponds to the following sequence of marker segments:

  1. SOC
  2. SIZ
  3. COD
  4. COC (if needed)
  5. QCD
  6. QCC (if needed)
  7. POC (if needed)

encodeTilePartHeader ( int tileLength, int tileIdx ) : void

Writes tile-part header. JJ2000 tile-part header corresponds to the following sequence of marker segments:

  1. SOT
  2. COD (if needed)
  3. COC (if needed)
  4. QCD (if needed)
  5. QCC (if needed)
  6. RGN (if needed)
  7. POC (if needed)
  8. SOD

reset ( ) : void

Resets the contents of this HeaderEncoder to its initial state. It erases all the data in the header buffer and reactualizes the headerLength field of the bit stream writer.

writeTo ( BinaryDataOutput out_Renamed ) : void

Writes the header to the specified BinaryDataOutput.

writeTo ( System out_Renamed ) : void

Writes the header to the specified OutputStream.

Protected Methods

Method Description
writeCOC ( bool mh, int tileIdx, int compIdx ) : void

Writes COC marker segment . It is a functional marker containing the coding style for one component (coding style, decomposition, layering).

Its values overrides any value previously set in COD in the main header or in the tile header.

writeCOD ( bool mh, int tileIdx ) : void

Writes COD marker segment. COD is a functional marker segment containing the code style default (coding style, decomposition, layering) used for compressing all the components in an image.

The values can be overriden for an individual component by a COC marker in either the main or the tile header.

writeMainQCC ( int compIdx ) : void

Writes QCC marker segment in main header. It is a functional marker segment countaining the quantization used for compressing the specified component in an image. The values override for the specified component what was defined by a QCC marker in either the main or the tile header.

writeMainQCD ( ) : void

Writes QCD marker segment in main header. QCD is a functional marker segment countaining the quantization default used for compressing all the components in an image. The values can be overriden for an individual component by a QCC marker in either the main or the tile header.

writePOC ( bool mh, int tileIdx ) : void

Writes POC marker segment. POC is a functional marker segment containing the bounds and progression order for any progression order other than default in the codestream.

writeTileQCC ( int t, int compIdx ) : void

Writes QCC marker segment in tile header. It is a functional marker segment countaining the quantization used for compressing the specified component in an image. The values override for the specified component what was defined by a QCC marker in either the main or the tile header.

writeTileQCD ( int tIdx ) : void

Writes QCD marker segment in tile header. QCD is a functional marker segment countaining the quantization default used for compressing all the components in an image. The values can be overriden for an individual component by a QCC marker in either the main or the tile header.

Private Methods

Method Description
writeCOM ( ) : void

Write COM marker segment(s) to the codestream.

This marker is currently written in main header and indicates the JJ2000 encoder's version that has created the codestream.

writeRGN ( int tIdx ) : void

Writes the RGN marker segment in the tile header. It describes the scaling value in each tile component

May be used in tile or main header. If used in main header, it refers to a ROI of the whole image, regardless of tiling. When used in tile header, only the particular tile is affected.

writeSIZ ( ) : void

Writes SIZ marker segment of the codestream header. It is a fixed information marker segment containing informations about image and tile sizes. It is required in the main header immediately after SOC marker segment.

writeSOC ( ) : void

Start Of Codestream marker (SOC) signalling the beginning of a codestream.

Method Details

HeaderEncoder() public method

Initializes the header writer with the references to the coding chain.
public HeaderEncoder ( ImgData origsrc, bool isorigsig, ForwardWT dwt, Tiler tiler, CSJ2K.j2k.encoder.EncoderSpecs encSpec, ROIScaler roiSc, PostCompRateAllocator ralloc, CSJ2K.j2k.util.ParameterList pl ) : System
origsrc ImgData The original image data (before any component mixing, /// tiling, etc.) /// ///
isorigsig bool An array specifying for each component if it was /// originally signed or not. /// ///
dwt CSJ2K.j2k.wavelet.analysis.ForwardWT The discrete wavelet transform module. /// ///
tiler CSJ2K.j2k.image.Tiler The tiler module. /// ///
encSpec CSJ2K.j2k.encoder.EncoderSpecs The encoder specifications /// ///
roiSc CSJ2K.j2k.roi.encoder.ROIScaler The ROI scaler module. /// ///
ralloc CSJ2K.j2k.entropy.encoder.PostCompRateAllocator The post compression rate allocator. /// ///
pl CSJ2K.j2k.util.ParameterList ParameterList instance. /// ///
return System

encodeMainHeader() public method

Write main header. JJ2000 main header corresponds to the following sequence of marker segments:
  1. SOC
  2. SIZ
  3. COD
  4. COC (if needed)
  5. QCD
  6. QCC (if needed)
  7. POC (if needed)
public encodeMainHeader ( ) : void
return void

encodeTilePartHeader() public method

Writes tile-part header. JJ2000 tile-part header corresponds to the following sequence of marker segments:
  1. SOT
  2. COD (if needed)
  3. COC (if needed)
  4. QCD (if needed)
  5. QCC (if needed)
  6. RGN (if needed)
  7. POC (if needed)
  8. SOD
public encodeTilePartHeader ( int tileLength, int tileIdx ) : void
tileLength int
tileIdx int Index of the tile to write /// ///
return void

reset() public method

Resets the contents of this HeaderEncoder to its initial state. It erases all the data in the header buffer and reactualizes the headerLength field of the bit stream writer.
public reset ( ) : void
return void

writeCOC() protected method

Writes COC marker segment . It is a functional marker containing the coding style for one component (coding style, decomposition, layering).

Its values overrides any value previously set in COD in the main header or in the tile header.

protected writeCOC ( bool mh, int tileIdx, int compIdx ) : void
mh bool Flag indicating whether the main header is to be written. /// ///
tileIdx int Tile index. /// ///
compIdx int index of the component which need use of the COC marker /// segment. /// ///
return void

writeCOD() protected method

Writes COD marker segment. COD is a functional marker segment containing the code style default (coding style, decomposition, layering) used for compressing all the components in an image.

The values can be overriden for an individual component by a COC marker in either the main or the tile header.

protected writeCOD ( bool mh, int tileIdx ) : void
mh bool Flag indicating whether this marker belongs to the main /// header /// ///
tileIdx int Tile index if the marker belongs to a tile-part header /// ///
return void

writeMainQCC() protected method

Writes QCC marker segment in main header. It is a functional marker segment countaining the quantization used for compressing the specified component in an image. The values override for the specified component what was defined by a QCC marker in either the main or the tile header.
protected writeMainQCC ( int compIdx ) : void
compIdx int Index of the component which needs QCC marker segment. /// ///
return void

writeMainQCD() protected method

Writes QCD marker segment in main header. QCD is a functional marker segment countaining the quantization default used for compressing all the components in an image. The values can be overriden for an individual component by a QCC marker in either the main or the tile header.
protected writeMainQCD ( ) : void
return void

writePOC() protected method

Writes POC marker segment. POC is a functional marker segment containing the bounds and progression order for any progression order other than default in the codestream.
protected writePOC ( bool mh, int tileIdx ) : void
mh bool Flag indicating whether the main header is to be written /// ///
tileIdx int Tile index /// ///
return void

writeTileQCC() protected method

Writes QCC marker segment in tile header. It is a functional marker segment countaining the quantization used for compressing the specified component in an image. The values override for the specified component what was defined by a QCC marker in either the main or the tile header.
protected writeTileQCC ( int t, int compIdx ) : void
t int Tile index /// ///
compIdx int Index of the component which needs QCC marker segment. /// ///
return void

writeTileQCD() protected method

Writes QCD marker segment in tile header. QCD is a functional marker segment countaining the quantization default used for compressing all the components in an image. The values can be overriden for an individual component by a QCC marker in either the main or the tile header.
protected writeTileQCD ( int tIdx ) : void
tIdx int Tile index /// ///
return void

writeTo() public method

Writes the header to the specified BinaryDataOutput.
public writeTo ( BinaryDataOutput out_Renamed ) : void
out_Renamed BinaryDataOutput
return void

writeTo() public method

Writes the header to the specified OutputStream.
public writeTo ( System out_Renamed ) : void
out_Renamed System
return void

Property Details

baos protected_oe property

The ByteArrayOutputStream to store header data. This handler is kept in order to use methods not accessible from a general DataOutputStream. For the other methods, it's better to use variable hbuf.
protected System.IO.MemoryStream baos
return System.IO.MemoryStream

dwt protected_oe property

Reference to the DWT module
protected ForwardWT,CSJ2K.j2k.wavelet.analysis dwt
return CSJ2K.j2k.wavelet.analysis.ForwardWT

encSpec protected_oe property

The encoder specifications
protected EncoderSpecs,CSJ2K.j2k.encoder encSpec
return CSJ2K.j2k.encoder.EncoderSpecs

hbuf protected_oe property

The DataOutputStream to store header data. This kind of object is useful to write short, int, .... It's constructor takes baos as parameter.
protected System.IO.BinaryWriter hbuf
return System.IO.BinaryWriter

isOrigSig protected_oe property

An array specifying, for each component,if the data was signed or not
protected bool[] isOrigSig
return bool[]

origSrc protected_oe property

The image data reader. Source of original data info
protected ImgData origSrc
return ImgData

ralloc protected_oe property

Reference to the rate allocator
protected PostCompRateAllocator,CSJ2K.j2k.entropy.encoder ralloc
return CSJ2K.j2k.entropy.encoder.PostCompRateAllocator

roiSc protected_oe property

Reference to the ROI module
protected ROIScaler,CSJ2K.j2k.roi.encoder roiSc
return CSJ2K.j2k.roi.encoder.ROIScaler

tiler protected_oe property

Reference to the tiler module
protected Tiler,CSJ2K.j2k.image tiler
return CSJ2K.j2k.image.Tiler