public class HeaderEncoder extends Object implements Markers, StdEntropyCoderOptions
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:
Main Header is written when Encoder instance calls encodeMainHeader whereas tile-part headers are written when the EBCOTRateAllocator instance calls encodeTilePartHeader.
Markers
,
EBCOTRateAllocator
Modifier and Type | Field and Description |
---|---|
protected ByteArrayOutputStream |
baos
The ByteArrayOutputStream to store header data.
|
private int |
defimgn
Nominal range bit of the component defining default values in QCD for
main header
|
private int |
deftilenr
Nominal range bit of the component defining default values in QCD for
tile headers
|
protected ForwardWT |
dwt
Reference to the DWT module
|
private boolean |
enJJ2KMarkSeg
Whether or not to write the JJ2000 COM marker segment
|
protected DataOutputStream |
hbuf
The DataOutputStream to store header data.
|
protected boolean[] |
isOrigSig
An array specifying, for each component,if the data was signed
or not
|
protected int |
nComp
The number of components in the image
|
protected ImgData |
origSrc
The image data reader.
|
private String |
otherCOMMarkSeg
Other COM marker segments specified in the command line
|
protected PostCompRateAllocator |
ralloc
Reference to the rate allocator
|
protected ROIScaler |
roiSc
Reference to the ROI module
|
protected Tiler |
tiler
Reference to the tiler module
|
protected J2KImageWriteParamJava |
wp
The encoder specifications
|
COC, COD, COM, CRG, EOC, EPH, EPH_LENGTH, ERS_SEG_SYMBOLS, ERS_SOP, MAX_COMP_BITDEPTH, MAX_LPPM, MAX_LPPT, PLM, PLT, POC, PPM, PPT, PRECINCT_PARTITION_DEF_SIZE, QCC, QCD, RCOM_GEN_USE, RGN, RSIZ_BASELINE, RSIZ_ER_FLAG, RSIZ_ROI, SCOX_HOR_CB_PART, SCOX_PRECINCT_PARTITION, SCOX_USE_EPH, SCOX_USE_SOP, SCOX_VER_CB_PART, SIZ, SOC, SOD, SOP, SOP_LENGTH, SOT, SQCX_EXP_MASK, SQCX_EXP_SHIFT, SQCX_GB_MSK, SQCX_GB_SHIFT, SQCX_NO_QUANTIZATION, SQCX_SCALAR_DERIVED, SQCX_SCALAR_EXPOUNDED, SRGN_IMPLICIT, SSIZ_DEPTH_BITS, TLM
FIRST_BYPASS_PASS_IDX, MAX_CB_AREA, MAX_CB_DIM, MIN_CB_DIM, NUM_EMPTY_PASSES_IN_MS_BP, NUM_NON_BYPASS_MS_BP, NUM_PASSES, OPT_BYPASS, OPT_PRED_TERM, OPT_RESET_MQ, OPT_SEG_SYMBOLS, OPT_TERM_PASS, OPT_VERT_STR_CAUSAL, STRIPE_HEIGHT
Constructor and Description |
---|
HeaderEncoder(ImgData origsrc,
boolean[] isorigsig,
ForwardWT dwt,
Tiler tiler,
J2KImageWriteParamJava wp,
ROIScaler roiSc,
PostCompRateAllocator ralloc)
Initializes the header writer with the references to the coding chain.
|
Modifier and Type | Method and Description |
---|---|
void |
encodeMainHeader()
Write main header.
|
void |
encodeTilePartHeader(int tileLength,
int tileIdx)
Writes tile-part header.
|
protected byte[] |
getBuffer()
Returns the byte-buffer used to store the codestream header.
|
protected int |
getBufferLength()
Returns the number of bytes used in the codestream header's
buffer.
|
int |
getLength()
Returns the length of the header.
|
void |
reset()
Resets the contents of this HeaderEncoder to its initial state.
|
protected void |
writeCOC(boolean mh,
int tileIdx,
int compIdx)
Writes COC marker segment .
|
protected void |
writeCOD(boolean mh,
int tileIdx)
Writes COD marker segment.
|
private void |
writeCOM()
Write a COM marker segment adding some comments to the codestream.
|
protected void |
writeMainQCC(int compIdx)
Writes QCC marker segment in main header.
|
protected void |
writeMainQCD()
Writes QCD marker segment in main header.
|
protected void |
writePOC(boolean mh,
int tileIdx)
Writes POC marker segment.
|
private void |
writeRGN(int tIdx)
Writes the RGN marker segment in the tile header.
|
private void |
writeSIZ()
Writes SIZ marker segment of the codestream header.
|
private void |
writeSOC()
Start Of Codestream marker (SOC) signalling the beginning of a
codestream.
|
protected void |
writeTileQCC(int t,
int compIdx)
Writes QCC marker segment in tile header.
|
protected void |
writeTileQCD(int tIdx)
Writes QCD marker segment in tile header.
|
void |
writeTo(BinaryDataOutput out)
Writes the header to the specified BinaryDataOutput.
|
void |
writeTo(OutputStream out)
Writes the header to the specified OutputStream.
|
private int defimgn
private int deftilenr
protected int nComp
private boolean enJJ2KMarkSeg
private String otherCOMMarkSeg
protected ByteArrayOutputStream baos
hbuf
protected DataOutputStream hbuf
baos
protected ImgData origSrc
protected boolean[] isOrigSig
protected PostCompRateAllocator ralloc
protected ForwardWT dwt
protected Tiler tiler
protected ROIScaler roiSc
protected J2KImageWriteParamJava wp
public HeaderEncoder(ImgData origsrc, boolean[] isorigsig, ForwardWT dwt, Tiler tiler, J2KImageWriteParamJava wp, ROIScaler roiSc, PostCompRateAllocator ralloc)
origsrc
- The original image data (before any component mixing,
tiling, etc.)isorigsig
- An array specifying for each component if it was
originally signed or not.dwt
- The discrete wavelet transform module.tiler
- The tiler module.wp
- The encoder specificationsroiSc
- The ROI scaler module.ralloc
- The post compression rate allocator.public void reset()
protected byte[] getBuffer()
public int getLength()
public void writeTo(BinaryDataOutput out) throws IOException
out
- Where to write the header.IOException
protected int getBufferLength()
public void writeTo(OutputStream out) throws IOException
out
- Where to write the header.IOException
private void writeSOC() throws IOException
IOException
private void writeSIZ() throws IOException
IOException
protected void writeCOD(boolean mh, int tileIdx) throws IOException
The values can be overriden for an individual component by a COC marker in either the main or the tile header.
mh
- Flag indicating whether this marker belongs to the main
headertileIdx
- Tile index if the marker belongs to a tile-part headerIOException
writeCOC(boolean, int, int)
protected void writeCOC(boolean mh, int tileIdx, int compIdx) throws IOException
Its values overrides any value previously set in COD in the main header or in the tile header.
mh
- Flag indicating whether the main header is to be writtentileIdx
- Tile indexcompIdx
- index of the component which need use of the COC marker
segment.IOException
writeCOD(boolean, int)
protected void writeMainQCD() throws IOException
IOException
protected void writeMainQCC(int compIdx) throws IOException
compIdx
- Index of the component which needs QCC marker
segment.IOException
protected void writeTileQCD(int tIdx) throws IOException
tIdx
- Tile indexIOException
protected void writeTileQCC(int t, int compIdx) throws IOException
t
- Tile indexcompIdx
- Index of the component which needs QCC marker
segment.IOException
protected void writePOC(boolean mh, int tileIdx) throws IOException
mh
- Flag indicating whether the main header is to be writtentileIdx
- Tile indexIOException
public void encodeMainHeader() throws IOException
IOException
private void writeCOM() throws IOException
This marker is currently written in main header and indicates the JJ2000 encoder's version that has created the codestream.
IOException
private void writeRGN(int tIdx) throws IOException
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.
tIdx
- The tile indexIOException
- If an I/O error occurs while reading from the
encoder header streampublic void encodeTilePartHeader(int tileLength, int tileIdx) throws IOException
tileLength
- The length of the current tile-part.tileIdx
- Index of the tile to writeIOException
Copyright © 2015 Open Microscopy Environment