| java.lang.Object jj2000.j2k.codestream.writer.CodestreamWriter
All known Subclasses: jj2000.j2k.codestream.writer.FileCodestreamWriter,
CodestreamWriter | abstract public class CodestreamWriter (Code) | | This is the abstract class for writing to a bit stream. Data is
written in packets, each packet having a head and a body. The
bit stream always has a maximum number of bytes that can be written
to it. After that many number of bytes no more data is written to
the bit stream but the number of bytes is counted so that the value
returned by getMaxAvailableBytes() is negative. If the number of
bytes is unlimited a ridicoulosly large value, such as
Integer.MAX_VALUE, is equivalent.
Data may be written to the bit stream in sumulation mode. When in
simulation mode no data is written to the bit stream but the
resulting number of bytes is calculated and returned (although it
is not accounted in the bit stream). This can be used in rate
control loops.
Implementing classes should write the header of the bit stream
before writing any packets. The bit stream header should be written
with the aid of the HeaderEncoder class.
See Also: HeaderEncoder |
Constructor Summary | |
protected | CodestreamWriter(int mb) Allocates this object and initializes the maximum numner of
bytes. |
Method Summary | |
abstract public void | close() Closes the underlying resource (file, stream, network connection,
etc.). | abstract public void | commitBitstreamHeader(HeaderEncoder he) Writes the header data to the bit stream, if it has not been already
done. | abstract public int | getLength() Returns the current length of the entire bit stream. | abstract public int | getMaxAvailableBytes() Returns the number of bytes remaining available in the bit stream. | abstract public int | getOffLastROIPkt() | abstract public 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. | abstract public 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. |
maxBytes | protected int maxBytes(Code) | | The maximum number of bytes that can be written to the
bit stream
|
ndata | protected int ndata(Code) | | The number of bytes already written to the bit stream
|
CodestreamWriter | protected CodestreamWriter(int mb)(Code) | | Allocates this object and initializes the maximum numner of
bytes.
Parameters: mb - The maximum number of bytes that can be written tothe bit stream. |
close | abstract public void close() throws IOException(Code) | | Closes the underlying resource (file, stream, network connection,
etc.). After a CodestreamWriter is closed no more data can be written
to it.
exception: IOException - If an I/O error occurs while closing theresource. |
commitBitstreamHeader | abstract public void commitBitstreamHeader(HeaderEncoder he) throws IOException(Code) | | Writes the header data to the bit stream, if it has not been already
done. In some implementations this method can be called only once, and
an IllegalArgumentException is thrown if called more than once.
exception: IOException - If an I/O error occurs while writing the data. exception: IllegalArgumentException - If this method has already beencalled. |
getLength | abstract public int getLength()(Code) | | Returns the current length of the entire bit stream.
the current length of the bit stream |
getMaxAvailableBytes | abstract public int getMaxAvailableBytes()(Code) | | Returns the number of bytes remaining available in the bit stream. This
is the maximum allowed number of bytes minus the number of bytes that
have already been written to the bit stream. If more bytes have been
written to the bit stream than the maximum number of allowed bytes,
then a negative value is returned.
The number of bytes remaining available in the bit stream. |
getOffLastROIPkt | abstract public int getOffLastROIPkt()(Code) | | Gives the offset of the end of last packet containing ROI information
End of last ROI packet |
writePacketBody | abstract public int writePacketBody(byte body, int blen, boolean sim, boolean roiInPkt, int roiLen) throws IOException(Code) | | 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. This can be used for
iterative rate allocation.
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.
Parameters: body - The packet body data. Parameters: blen - The number of bytes in the packet body. Parameters: sim - Simulation mode flag. If true nothing is written to the bitstream, but the number of bytes that would be written is returned. Parameters: roiInPkt - Whether or not there is ROI information in this packet Parameters: roiLen - Number of byte to read in packet body to get all the ROIinformation The number of bytes spent by the packet body. exception: IOException - If an I/O error occurs while writing tothe output stream. See Also: CodestreamWriter.commitBitstreamHeader |
writePacketHead | abstract public int writePacketHead(byte head, int hlen, boolean sim, boolean sop, boolean eph) throws IOException(Code) | | Writes a packet head to the bit stream and returns the number of bytes
used by this header. It returns the total number of bytes that the
packet head takes in the bit stream. If in simulation mode then no data
is written to the bit stream but the number of bytes is
calculated. This can be used for iterative rate allocation.
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.
Parameters: head - The packet head data. Parameters: hlen - The number of bytes in the packet head. Parameters: sim - Simulation mode flag. If true nothing is written to the bitstream, but the number of bytes that would be written is returned. Parameters: sop - Start of packet header marker flag. This flag indicateswhether or not SOP markers should be written. If true, SOP markersshould be written, if false, they should not. Parameters: eph - End of Packet Header marker flag. This flag indicateswhether or not EPH markers should be written. If true, EPH markersshould be written, if false, they should not. The number of bytes spent by the packet head. exception: IOException - If an I/O error occurs while writing to theoutput stream. See Also: CodestreamWriter.commitBitstreamHeader |
|
|