public class FileCodestreamWriter extends CodestreamWriter implements Markers
Before any packet data is written to the bit stream (even in simulation mode) the complete header should be written to the HeaderEncoder object supplied to the constructor, following the procedure explained in the HeaderEncoder class. Otherwise incorrect estimates are given by getMaxAvailableBytes() for rate allocation.
CodestreamWriter
,
HeaderEncoder
Modifier and Type | Field and Description |
---|---|
static int |
DEF_BUF_LEN
The default buffer length, 1024 bytes
|
(package private) byte[] |
ephMarker
Array used to store the EPH markers values
|
private int |
lenLastNoROI
Length of last packets containing no ROI information
|
(package private) int |
ndata
The number of bytes already written to the bit stream, excluding the
header length, magic number and header length info.
|
private int |
offLastROIPkt
Offset of end of last packet containing ROI information
|
private OutputStream |
out
The file to write
|
(package private) int |
packetIdx
The packet index (when start of packet markers i.e.
|
private static int |
SOP_MARKER_LIMIT
The upper limit for the value of the Nsop field of the SOP marker
|
(package private) byte[] |
sopMarker
Array used to store the SOP markers values
|
private int |
tileIdx
Index of the current tile
|
maxBytes
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
Constructor and Description |
---|
FileCodestreamWriter(File file,
int mb)
Opens the file 'file' for writing the bit stream, using the 'he' header
encoder.
|
FileCodestreamWriter(OutputStream os,
int mb)
Uses the output stream 'os' for writing the bit stream, using the 'he'
header encoder.
|
FileCodestreamWriter(String fname,
int mb)
Opens the file named 'fname' for writing the bit stream, using the 'he'
header encoder.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Writes the EOC marker and closes the underlying stream.
|
void |
commitBitstreamHeader(HeaderEncoder he)
Writes the header data in the codestream and actualize ndata with the
header length.
|
int |
getLength()
Returns the current length of the entire bit stream.
|
int |
getMaxAvailableBytes()
Returns the number of bytes remaining available in the bit stream.
|
int |
getOffLastROIPkt()
Gives the offset of the end of last packet containing ROI information
|
private void |
initSOP_EPHArrays()
Performs the initialisation of the arrays that are used to store the
values used to write SOP and EPH markers
|
int |
writePacketBody(byte[] body,
int blen,
boolean sim,
boolean roiInPkt,
int roiLen)
Writes a packet body to the bit stream and returns the number of bytes
used by this body .If in simulation mode then no data is written to the
bit stream but the number of bytes is calculated.
|
int |
writePacketHead(byte[] head,
int hlen,
boolean sim,
boolean sop,
boolean eph)
Writes a packet head to the bit stream and returns the number of bytes
used by this header.
|
private static final int SOP_MARKER_LIMIT
private int tileIdx
private OutputStream out
int ndata
public static int DEF_BUF_LEN
byte[] sopMarker
byte[] ephMarker
int packetIdx
private int offLastROIPkt
private int lenLastNoROI
public FileCodestreamWriter(File file, int mb) throws IOException
file
- The file where to write the bit streammb
- The maximum number of bytes that can be written to the bit
stream.IOException
- If an error occurs while trying to open the file
for writing or while writing the magic number.public FileCodestreamWriter(String fname, int mb) throws IOException
fname
- The name of file where to write the bit streammb
- The maximum number of bytes that can be written to the bit
stream.IOException
- If an error occurs while trying to open the file
for writing or while writing the magic number.public FileCodestreamWriter(OutputStream os, int mb) throws IOException
os
- The output stream where to write the bit stream.mb
- The maximum number of bytes that can be written to the bit
stream.IOException
- If an error occurs while writing the magic
number to the 'os' output stream.public final int getMaxAvailableBytes()
getMaxAvailableBytes
in class CodestreamWriter
public int getLength()
getLength
in class CodestreamWriter
public int writePacketHead(byte[] head, int hlen, boolean sim, boolean sop, boolean eph) throws IOException
If the length of the data that is to be written to the bit stream is more than the space left (as returned by getMaxAvailableBytes()) only the data that does not exceed the allowed length is written, the rest is discarded. However the value returned by the method is the total length of the packet, as if all of it was written to the bit stream.
If the bit stream header has not been commited yet and 'sim' is false, then the bit stream header is automatically commited (see commitBitstreamHeader() method) before writting the packet.
writePacketHead
in class CodestreamWriter
head
- The packet head data.hlen
- The number of bytes in the packet head.sim
- Simulation mode flag. If true nothing is written to the bit
stream, but the number of bytes that would be written is returned.sop
- Start of packet header marker flag. This flag indicates
whether or not SOP markers should be written. If true, SOP markers
should be written, if false, they should not.eph
- End of Packet Header marker flag. This flag indicates
whether or not EPH markers should be written. If true, EPH markers
should be written, if false, they should not.IOException
- If an I/O error occurs while writing to the
output stream.commitBitstreamHeader(jj2000.j2k.codestream.writer.HeaderEncoder)
public int writePacketBody(byte[] body, int blen, boolean sim, boolean roiInPkt, int roiLen) throws IOException
If the length of the data that is to be written to the bit stream is more than the space left (as returned by getMaxAvailableBytes()) only the data that does not exceed the allowed length is written, the rest is discarded. However the value returned by the method is the total length of the packet body , as if all of it was written to the bit stream.
writePacketBody
in class CodestreamWriter
body
- The packet body data.blen
- The number of bytes in the packet body.sim
- Simulation mode flag. If true nothing is written to the bit
stream, but the number of bytes that would be written is returned.roiInPkt
- Whether or not this packet contains ROI informationroiLen
- Number of byte to read in packet body to get all the ROI
informationIOException
- If an I/O error occurs while writing to the
output stream.commitBitstreamHeader(jj2000.j2k.codestream.writer.HeaderEncoder)
public void close() throws IOException
close
in class CodestreamWriter
IOException
- If an error occurs while closing the underlying
stream.public int getOffLastROIPkt()
getOffLastROIPkt
in class CodestreamWriter
public void commitBitstreamHeader(HeaderEncoder he) throws IOException
commitBitstreamHeader
in class CodestreamWriter
he
- The current header encoder.IOException
- If an I/O error occurs while writing the data.private void initSOP_EPHArrays()
Copyright © 2017 Open Microscopy Environment