C# Класс CSJ2K.j2k.codestream.reader.HeaderDecoder

This class reads main and tile-part headers from the codestream given a RandomAccessIO instance located at the beginning of the codestream (i.e just before the SOC marker) or at the beginning of a tile-part (i.e. just before a SOT marker segment) respectively.

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

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

The main header is read when the constructor is called whereas tile-part headers are read when the FileBitstreamReaderAgent instance is created. The reading is done in 2 passes:

  1. All marker segments are buffered and their corresponding flag is activated (extractMainMarkSeg and extractTilePartMarkSeg methods).
  2. Buffered marker segment are analyzed in a logical way and specifications are stored in appropriate member of DecoderSpecs instance (readFoundMainMarkSeg and readFoundTilePartMarkSeg methods).

Whenever a marker segment is not recognized a warning message is displayed and its length parameter is used to skip it.

The information found in this header is stored in HeaderInfo and DecoderSpecs instances.

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
mainHeadOff int
nTileParts int[]

Открытые методы

Метод Описание
HeaderDecoder ( RandomAccessIO ehs, CSJ2K.j2k.util.ParameterList pl, HeaderInfo hi ) : System

Creates a HeaderDecoder instance and read in two passes the main header of the codestream. The first and last marker segments shall be respectively SOC and SOT.

ToString ( ) : System.String

Print information about the current header.

checkMarkerLength ( System ehs, System str ) : void

Checks that the marker segment length is correct.

createChannelDefinitionMapper ( BlkImgDataSrc src, CSJ2K csMap ) : BlkImgDataSrc

Creates and returns the ChannelDefinitonMapper which maps the input channels to the channel definition for the appropriate colorspace.

createColorSpaceMapper ( BlkImgDataSrc src, CSJ2K csMap ) : BlkImgDataSrc

Creates and returns the EnumeratedColorSpaceMapper corresponding to the information read from the JP2 image file via the ColorSpace parameter.

createDequantizer ( CBlkQuantDataSrcDec src, int rb, DecoderSpecs decSpec2 ) : CSJ2K.j2k.quantization.dequantizer.Dequantizer

Returns the dequantizer parameters. Dequantizer parameters normally are the quantization step sizes, see DequantizerParams.

createEntropyDecoder ( CodedCBlkDataSrcDec src, CSJ2K.j2k.util.ParameterList pl ) : CSJ2K.j2k.entropy.decoder.EntropyDecoder

Creates and returns the entropy decoder corresponding to the information read from the codestream header and with the special additional parameters from the parameter list.

createPalettizedColorSpaceMapper ( BlkImgDataSrc src, CSJ2K csMap ) : BlkImgDataSrc

Creates and returns the PalettizedColorSpaceMapper which uses the input samples as indicies into a sample palette to construct the output.

createROIDeScaler ( CBlkQuantDataSrcDec src, CSJ2K.j2k.util.ParameterList pl, DecoderSpecs decSpec2 ) : CSJ2K.j2k.roi.ROIDeScaler

Creates and returns the ROIDeScaler corresponding to the information read from the codestream header and with the special additional parameters from the parameter list.

createResampler ( BlkImgDataSrc src, CSJ2K csMap ) : BlkImgDataSrc

Creates and returns the Resampler which converts the input source to one in which all channels have the same number of samples. This is required for colorspace conversions.

extractTilePartMarkSeg ( short marker, RandomAccessIO ehs, int tileIdx, int tilePartIdx ) : void

This method extracts a marker segment in a tile-part header and stores it into a byte buffer for the second pass. The marker is first recognized, then its flag is activated and, finally, its content is buffered in an element of byte arrays accessible thanks to a hashTable. If a marker segment is not recognized, it prints a warning and skip it according to its length.

getCompSubsX ( int c ) : int

Returns the component sub-sampling factor, with respect to the reference grid, along the horizontal direction for the specified component.

getCompSubsY ( int c ) : int

Returns the component sub-sampling factor, with respect to the reference grid, along the vertical direction for the specified component.

getOriginalBitDepth ( int c ) : int

Returns the original bitdepth of the specified component.

getPPX ( int t, int c, int rl ) : int

Returns the precinct partition width for the specified tile-component and resolution level.

getPPY ( int t, int c, int rl ) : int

Returns the precinct partition height for the specified tile-component and resolution level.

getPackedPktHead ( int tile ) : System.IO.MemoryStream

Return the packed packet headers for a given tile.

getTilingOrigin ( Coord co ) : Coord

Returns the tiling origin, referred to as '(Px,Py)' in the 'ImgData' interface.

isOriginalSigned ( int c ) : bool

Returns true if the original data of the specified component was signed. If the data was not signed a level shift has to be applied at the end of the decompression chain.

precinctPartitionUsed ( ) : bool

Returns the boolean used to know if the precinct partition is used

readFoundTilePartMarkSeg ( int tileIdx, int tpIdx ) : void

Retrieves and reads all marker segments previously found in the tile-part header.

resetHeaderMarkers ( ) : void

Method that resets members indicating which markers have already been found

Приватные методы

Метод Описание
extractMainMarkSeg ( short marker, RandomAccessIO ehs ) : void

This method extract a marker segment from the main header and stores it into a byte buffer for the second pass. The marker segment is first identified. Then its flag is activated. Finally, its content is buffered into a byte array stored in an hashTable.

If the marker is not recognized, it prints a warning and skips it according to its length.

SIZ marker segment shall be the first encountered marker segment.

readCOC ( System ehs, bool mainh, int tileIdx, int tpIdx ) : void

Reads the COC marker segment and realigns the codestream where the next marker should be found.

readCOD ( System ehs, bool mainh, int tileIdx, int tpIdx ) : void

Reads a COD marker segment and realigns the codestream where the next marker should be found.

readCOM ( System ehs, bool mainh, int tileIdx, int comIdx ) : void

Reads a COM marker segments and realigns the bit stream at the point where the next marker segment should be found. COM is an informational marker segment that allows to include unstructured data in the main and tile-part headers.

readCRG ( System ehs ) : void

Reads a CRG marker segment and checks its length. CRG is an informational marker segment that allows specific registration of components with respect to each other.

readFilter ( System ehs, int filtIdx ) : CSJ2K.j2k.wavelet.synthesis.SynWTFilter

Reads a wavelet filter from the codestream and returns the filter object that implements it.

readFoundMainMarkSeg ( ) : void

Retrieves and reads all marker segments found in the main header during the first pass.

readPLM ( System ehs ) : void

Reads PLM marker segment and realigns the codestream where the next marker should be found. Informations stored in these fields are currently not taken into account.

readPLTFields ( System ehs ) : void

Reads the PLT fields and realigns the codestream where the next marker should be found. Informations stored in these fields are currently NOT taken into account.

readPOC ( System ehs, bool mainh, int t, int tpIdx ) : void

Reads the POC marker segment and realigns the codestream where the next marker should be found.

readPPM ( System ehs ) : void

Reads the PPM marker segment of the main header.

readPPT ( System ehs, int tile, int tpIdx ) : void

Reads the PPT marker segment of the main header.

readQCC ( System ehs, bool mainh, int tileIdx, int tpIdx ) : void

Reads a QCC marker segment and realigns the codestream at the point where the next marker should be found. QCC is a functional marker segment that describes the quantization of one component.

readQCD ( System ehs, bool mainh, int tileIdx, int tpIdx ) : void

Reads a QCD marker segment and realigns the codestream at the point where the next marker should be found. QCD is a functional marker segment that describes the quantization default.

readRGN ( System ehs, bool mainh, int tileIdx, int tpIdx ) : void

Reads the RGN marker segment of the codestream header.

May be used in tile or main header. If used in main header, it refers to the maxshift value of a component in all tiles. When used in tile header, only the particular tile-component is affected.

readSIZ ( System ehs ) : void

Reads the SIZ marker segment and realigns the codestream at the point where the next marker segment should be found.

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

readTLM ( System ehs ) : void

Reads TLM marker segment and realigns the codestream where the next marker should be found. Informations stored in these fields are currently NOT taken into account.

Описание методов

HeaderDecoder() публичный Метод

Creates a HeaderDecoder instance and read in two passes the main header of the codestream. The first and last marker segments shall be respectively SOC and SOT.
If an I/O error occurs while reading from the /// encoded header stream. /// If the end of the encoded header stream is /// reached before getting all the data. /// If invalid data is found in the /// codestream main header. /// ///
public HeaderDecoder ( RandomAccessIO ehs, CSJ2K.j2k.util.ParameterList pl, HeaderInfo hi ) : System
ehs RandomAccessIO The encoded header stream where marker segments are /// extracted. /// ///
pl CSJ2K.j2k.util.ParameterList The ParameterList object of the decoder /// ///
hi CSJ2K.j2k.codestream.HeaderInfo The HeaderInfo holding information found in marker segments /// ///
Результат System

ToString() публичный Метод

Print information about the current header.
public ToString ( ) : System.String
Результат System.String

checkMarkerLength() публичный Метод

Checks that the marker segment length is correct.
If an I/O error occurs /// ///
public checkMarkerLength ( System ehs, System str ) : void
ehs System The encoded header stream /// ///
str System The string identifying the marker, such as "SIZ marker" /// ///
Результат void

createChannelDefinitionMapper() публичный Метод

Creates and returns the ChannelDefinitonMapper which maps the input channels to the channel definition for the appropriate colorspace.
image access exception /// if image contains a bad colorspace box /// ///
public createChannelDefinitionMapper ( BlkImgDataSrc src, CSJ2K csMap ) : BlkImgDataSrc
src BlkImgDataSrc The bit stream reader agent where to get code-block /// data from. ///
csMap CSJ2K provides color space information from the image file /// ///
Результат BlkImgDataSrc

createColorSpaceMapper() публичный Метод

Creates and returns the EnumeratedColorSpaceMapper corresponding to the information read from the JP2 image file via the ColorSpace parameter.
image access exception /// if image contains a bad icc profile /// if image contains a bad colorspace box /// ///
public createColorSpaceMapper ( BlkImgDataSrc src, CSJ2K csMap ) : BlkImgDataSrc
src BlkImgDataSrc The bit stream reader agent where to get code-block /// data from. ///
csMap CSJ2K provides color space information from the image file /// ///
Результат BlkImgDataSrc

createDequantizer() публичный Метод

Returns the dequantizer parameters. Dequantizer parameters normally are the quantization step sizes, see DequantizerParams.
public createDequantizer ( CBlkQuantDataSrcDec src, int rb, DecoderSpecs decSpec2 ) : CSJ2K.j2k.quantization.dequantizer.Dequantizer
src CBlkQuantDataSrcDec The source of data for the dequantizer. /// ///
rb int The number of range bits for each component. Must be /// the number of range bits of the mixed components. /// ///
decSpec2 CSJ2K.j2k.decoder.DecoderSpecs The DecoderSpecs instance after any image manipulation. /// ///
Результат CSJ2K.j2k.quantization.dequantizer.Dequantizer

createEntropyDecoder() публичный Метод

Creates and returns the entropy decoder corresponding to the information read from the codestream header and with the special additional parameters from the parameter list.
public createEntropyDecoder ( CodedCBlkDataSrcDec src, CSJ2K.j2k.util.ParameterList pl ) : CSJ2K.j2k.entropy.decoder.EntropyDecoder
src CodedCBlkDataSrcDec The bit stream reader agent where to get code-block data /// from. /// ///
pl CSJ2K.j2k.util.ParameterList The parameter list containing parameters applicable to the /// entropy decoder (other parameters can also be present). /// ///
Результат CSJ2K.j2k.entropy.decoder.EntropyDecoder

createPalettizedColorSpaceMapper() публичный Метод

Creates and returns the PalettizedColorSpaceMapper which uses the input samples as indicies into a sample palette to construct the output.
image access exception /// if image contains a bad colorspace box /// ///
public createPalettizedColorSpaceMapper ( BlkImgDataSrc src, CSJ2K csMap ) : BlkImgDataSrc
src BlkImgDataSrc The bit stream reader agent where to get code-block /// data from. ///
csMap CSJ2K provides color space information from the image file /// ///
Результат BlkImgDataSrc

createROIDeScaler() публичный Метод

Creates and returns the ROIDeScaler corresponding to the information read from the codestream header and with the special additional parameters from the parameter list.
public createROIDeScaler ( CBlkQuantDataSrcDec src, CSJ2K.j2k.util.ParameterList pl, DecoderSpecs decSpec2 ) : CSJ2K.j2k.roi.ROIDeScaler
src CBlkQuantDataSrcDec The bit stream reader agent where to get code-block data /// from. /// ///
pl CSJ2K.j2k.util.ParameterList The parameter list containing parameters applicable to the /// entropy decoder (other parameters can also be present). /// ///
decSpec2 CSJ2K.j2k.decoder.DecoderSpecs The DecoderSpecs instance after any image manipulation. /// ///
Результат CSJ2K.j2k.roi.ROIDeScaler

createResampler() публичный Метод

Creates and returns the Resampler which converts the input source to one in which all channels have the same number of samples. This is required for colorspace conversions.
image access exception /// if image contains a bad colorspace box /// ///
public createResampler ( BlkImgDataSrc src, CSJ2K csMap ) : BlkImgDataSrc
src BlkImgDataSrc The bit stream reader agent where to get code-block /// data from. ///
csMap CSJ2K provides color space information from the image file /// ///
Результат BlkImgDataSrc

extractTilePartMarkSeg() публичный Метод

This method extracts a marker segment in a tile-part header and stores it into a byte buffer for the second pass. The marker is first recognized, then its flag is activated and, finally, its content is buffered in an element of byte arrays accessible thanks to a hashTable. If a marker segment is not recognized, it prints a warning and skip it according to its length.
public extractTilePartMarkSeg ( short marker, RandomAccessIO ehs, int tileIdx, int tilePartIdx ) : void
marker short The marker to process /// ///
ehs RandomAccessIO The encoded header stream /// ///
tileIdx int The index of the current tile /// ///
tilePartIdx int The index of the current tile part /// ///
Результат void

getCompSubsX() публичный Метод

Returns the component sub-sampling factor, with respect to the reference grid, along the horizontal direction for the specified component.
public getCompSubsX ( int c ) : int
c int The index of the component /// ///
Результат int

getCompSubsY() публичный Метод

Returns the component sub-sampling factor, with respect to the reference grid, along the vertical direction for the specified component.
public getCompSubsY ( int c ) : int
c int The index of the component /// ///
Результат int

getOriginalBitDepth() публичный Метод

Returns the original bitdepth of the specified component.
public getOriginalBitDepth ( int c ) : int
c int The index of the component /// ///
Результат int

getPPX() публичный Метод

Returns the precinct partition width for the specified tile-component and resolution level.
public getPPX ( int t, int c, int rl ) : int
t int the tile index /// ///
c int the component index /// ///
rl int the resolution level /// ///
Результат int

getPPY() публичный Метод

Returns the precinct partition height for the specified tile-component and resolution level.
public getPPY ( int t, int c, int rl ) : int
t int the tile index /// ///
c int the component index /// ///
rl int the resolution level /// ///
Результат int

getPackedPktHead() публичный Метод

Return the packed packet headers for a given tile.
If an I/O error occurs while reading from the /// encoder header stream /// ///
public getPackedPktHead ( int tile ) : System.IO.MemoryStream
tile int
Результат System.IO.MemoryStream

getTilingOrigin() публичный Метод

Returns the tiling origin, referred to as '(Px,Py)' in the 'ImgData' interface.
public getTilingOrigin ( Coord co ) : Coord
co Coord If not null this object is used to return the information. If /// null a new one is created and returned. /// ///
Результат Coord

isOriginalSigned() публичный Метод

Returns true if the original data of the specified component was signed. If the data was not signed a level shift has to be applied at the end of the decompression chain.
public isOriginalSigned ( int c ) : bool
c int The index of the component /// ///
Результат bool

precinctPartitionUsed() публичный Метод

Returns the boolean used to know if the precinct partition is used
public precinctPartitionUsed ( ) : bool
Результат bool

readFoundTilePartMarkSeg() публичный Метод

Retrieves and reads all marker segments previously found in the tile-part header.
public readFoundTilePartMarkSeg ( int tileIdx, int tpIdx ) : void
tileIdx int The index of the current tile /// ///
tpIdx int Index of the current tile-part /// ///
Результат void

resetHeaderMarkers() публичный Метод

Method that resets members indicating which markers have already been found
public resetHeaderMarkers ( ) : void
Результат void

Описание свойств

mainHeadOff публичное свойство

The offset of the main header in the input stream
public int mainHeadOff
Результат int

nTileParts публичное свойство

The number of tile parts in each tile
public int[] nTileParts
Результат int[]