public writePacketHead ( byte head, int hlen, bool sim, bool sop, bool eph ) : int | ||
head | byte | The packet head data. /// /// |
hlen | int | The number of bytes in the packet head. /// /// |
sim | bool | Simulation mode flag. If true nothing is written to the bit /// stream, but the number of bytes that would be written is returned. /// /// |
sop | bool | 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 | bool | 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. /// /// |
return | int |
public override int writePacketHead(byte[] head, int hlen, bool sim, bool sop, bool eph)
{
// CONVERSION PROBLEM?
int len = hlen + (sop ? (int)CSJ2K.j2k.codestream.Markers.SOP_LENGTH : 0) + (eph ? (int)CSJ2K.j2k.codestream.Markers.EPH_LENGTH : 0);
// If not in simulation mode write the data
if (!sim)
{
// Write the head bytes
if (MaxAvailableBytes < len)
{
len = MaxAvailableBytes;
}
if (len > 0)
{
// Write Start Of Packet header markers if necessary
if (sop)
{
// The first 4 bytes of the array have been filled in the
// classe's constructor.
sopMarker[4] = (byte) (packetIdx >> 8);
sopMarker[5] = (byte) (packetIdx);
out_Renamed.Write(sopMarker, 0, CSJ2K.j2k.codestream.Markers.SOP_LENGTH);
packetIdx++;
if (packetIdx > SOP_MARKER_LIMIT)
{
// Reset SOP value as we have reached its upper limit
packetIdx = 0;
}
}
out_Renamed.Write(head, 0, hlen);
// Update data length
ndata += len;
// Write End of Packet Header markers if necessary
if (eph)
{
out_Renamed.Write(ephMarker, 0, CSJ2K.j2k.codestream.Markers.EPH_LENGTH);
}
// Deal with ROI Information
lenLastNoROI += len;
}
}
return len;
}