|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jj2000.j2k.codestream.writer.CodestreamWriter | +--jj2000.j2k.codestream.writer.FileCodestreamWriter
This class implements a CodestreamWriter for Java streams. The streams can be files or network connections, or any other resource that presents itself as a OutputStream. See the CodestreamWriter abstract class for more details on the implementation of the CodestreamWriter abstract class.
Before any packet data is written to the bit stream (even in simulation mode) the complete header should be written otherwise incorrect estimates are given by getMaxAvailableBytes() for rate allocation.
CodestreamWriter
Field Summary | |
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 codestream, excluding the header length, magic number and header length info. |
private int |
offLastROIPkt
Offset of end of last packet containing ROI information |
private java.io.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 |
Fields inherited from class jj2000.j2k.codestream.writer.CodestreamWriter |
maxBytes |
Fields inherited from interface jj2000.j2k.codestream.Markers |
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 Summary | |
FileCodestreamWriter(java.io.File file,
int mb)
Opens the file 'file' for writing the codestream. |
|
FileCodestreamWriter(java.io.OutputStream os,
int mb)
Uses the output stream 'os' for writing the bit stream, using the 'he' header encoder. |
|
FileCodestreamWriter(java.lang.String fname,
int mb)
Opens the file named 'fname' for writing the bit stream, using the 'he' header encoder. |
Method Summary | |
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final int SOP_MARKER_LIMIT
private int tileIdx
private java.io.OutputStream out
int ndata
public static int DEF_BUF_LEN
byte[] sopMarker
byte[] ephMarker
int packetIdx
private int offLastROIPkt
private int lenLastNoROI
Constructor Detail |
public FileCodestreamWriter(java.io.File file, int mb) throws java.io.IOException
file
- The file where to write the bit streammb
- The maximum number of bytes that can be written to the bit
stream.
java.io.IOException
- If an error occurs while trying to open the file
for writing or while writing the magic number.public FileCodestreamWriter(java.lang.String fname, int mb) throws java.io.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.
java.io.IOException
- If an error occurs while trying to open the file
for writing or while writing the magic number.public FileCodestreamWriter(java.io.OutputStream os, int mb) throws java.io.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.
java.io.IOException
- If an error occurs while writing the magic
number to the 'os' output stream.Method Detail |
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 java.io.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.
java.io.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 java.io.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
information
java.io.IOException
- If an I/O error occurs while writing to the
output stream.commitBitstreamHeader(jj2000.j2k.codestream.writer.HeaderEncoder)
public void close() throws java.io.IOException
close
in class CodestreamWriter
java.io.IOException
- If an error occurs while closing the underlying
stream.public int getOffLastROIPkt()
getOffLastROIPkt
in class CodestreamWriter
public void commitBitstreamHeader(HeaderEncoder he) throws java.io.IOException
commitBitstreamHeader
in class CodestreamWriter
he
- The current header encoder.
java.io.IOException
- If an I/O error occurs while writing the data.private void initSOP_EPHArrays()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |