/// <summary> This class builds packets and keeps the state information of packet
/// interdependencies. It also supports saving the state and reverting
/// (restoring) to the last saved state, with the save() and restore() methods.
///
/// <p>Each time the encodePacket() method is called a new packet is encoded,
/// the packet header is returned by the method, and the packet body can be
/// obtained with the getLastBodyBuf() and getLastBodyLen() methods.</p>
///
/// </summary>
publicclassPktEncoder
{
/// <summary> Returns the buffer of the body of the last encoded packet. The length
/// of the body can be retrieved with the getLastBodyLen() method. The
/// length of the array returned by this method may be larger than the
/// actual body length.
///
/// </summary>
/// <returns> The buffer of body of the last encoded packet.
///
/// </returns>
/// <exception cref="IllegalArgumentException">If no packet has been coded since
/// last reset(), last restore(), or object creation.
///
/// </exception>
/// <seealso cref="getLastBodyLen">
///
/// </seealso>
virtualpublicbyte[]LastBodyBuf
{
get
{
if(lbbuf==null)
{
thrownewSystem.ArgumentException();
}
returnlbbuf;
}
}
/// <summary> Returns the length of the body of the last encoded packet, in
/// bytes. The body itself can be retrieved with the getLastBodyBuf()
/// method.
///
/// </summary>
/// <returns> The length of the body of last encoded packet, in bytes.
///
/// </returns>
/// <seealso cref="getLastBodyBuf">
///
/// </seealso>
virtualpublicintLastBodyLen
{
get
{
returnlblen;
}
}
/// <summary> Returns true if the current packet is writable i.e. should be written.
/// Returns false otherwise.
///
/// </summary>
virtualpublicboolPacketWritable
{
get
{
returnpacketWritable;
}
}
/// <summary> Tells if there was ROI information in the last written packet
///
/// </summary>
virtualpublicboolROIinPkt
{
get
{
returnroiInPkt;
}
}
/// <summary>Gives the length to read in current packet body to get all ROI
/// information
/// </summary>
virtualpublicintROILen
{
get
{
returnroiLen;
}
}
/// <summary> Returns the parameters that are used in this class and implementing
/// classes. It returns a 2D String array. Each of the 1D arrays is for a
/// different option, and they have 3 elements. The first element is the
/// option name, the second one is the synopsis, the third one is a long
/// description of what the parameter is and the fourth is its default
/// value. The synopsis or description may be 'null', in which case it is
/// assumed that there is no synopsis or description of the option,
/// respectively. Null may be returned if no options are supported.
///
/// </summary>
/// <returns> the options name, their synopsis and their explanation,
/// or null if no options are supported.
///
/// </returns>
publicstaticSystem.String[][]ParameterInfo
{
get
{
returnpinfo;
}
}
/// <summary>The prefix for packet encoding options: 'P' </summary>
publicconstcharOPT_PREFIX='P';
/// <summary>The list of parameters that is accepted for packet encoding.</summary>
//UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
privatestaticreadonlySystem.String[][]pinfo=newSystem.String[][]{newSystem.String[]{"Psop","[<tile idx>] on|off"+"[ [<tile idx>] on|off ...]","Specifies whether start of packet (SOP) markers should be used. "+"'on' enables, 'off' disables it.","off"},newSystem.String[]{"Peph","[<tile idx>] on|off"+"[ [<tile idx>] on|off ...]","Specifies whether end of packet header (EPH) markers should be "+" used. 'on' enables, 'off' disables it.","off"}};
/// <summary>The initial value for the lblock </summary>
privateconstintINIT_LBLOCK=3;
/// <summary>The source object </summary>
privateCodedCBlkDataSrcEncinfoSrc;
/// <summary>The encoder specs </summary>
privateEncoderSpecsencSpec;
/// <summary> The tag tree for inclusion information. The indexes are outlined
/// below. Note that the layer indexes start at 1, therefore, the layer
/// index minus 1 is used. The subband indices are used as they are defined
/// in the Subband class. The tile indices start at 0 and follow a
/// lexicographical order.
///
/// <ul>
/// <li>1st index: tile index, in lexicographical order</li>
/// <li>2nd index: component index </li>
/// <li>3rd index: resolution level </li>
/// <li>4th index: precinct index </li>
/// <li>5th index: subband index </li>
/// </ul>
///
/// </summary>
privateTagTreeEncoder[][][][][]ttIncl;
/// <summary> The tag tree for the maximum significant bit-plane. The indexes are
/// outlined below. Note that the layer indexes start at 1, therefore, the
/// layer index minus 1 is used. The subband indices are used as they are
/// defined in the Subband class. The tile indices start at 0 and follow a
/// lexicographical order.
///
/// <ul>
/// <li>1st index: tile index, in lexicographical order</li>
/// <li>2nd index: component index </li>
/// <li>3rd index: resolution level </li>
/// <li>4th index: precinct index </li>
/// <li>5th index: subband index</li>
/// </ul>
///
/// </summary>
privateTagTreeEncoder[][][][][]ttMaxBP;
/// <summary> The base number of bits for sending code-block length information
/// (referred as Lblock in the JPEG 2000 standard). The indexes are
/// outlined below. Note that the layer indexes start at 1, therefore, the
/// layer index minus 1 is used. The subband indices are used as they are
/// defined in the Subband class. The tile indices start at 0 and follow a
/// lexicographical order.
///
/// <ul>
/// <li>1st index: tile index, in lexicographical order </li>
/// <li>2nd index: component index </li>
/// <li>3rd index: resolution level </li>
/// <li>4th index: subband index </li>
/// <li>5th index: code-block index, in lexicographical order</li>
/// </ul>
///
/// </summary>
privateint[][][][][]lblock;
/// <summary> The last encoded truncation point for each code-block. A negative value
/// means that no information has been included for the block, yet. The
/// indexes are outlined below. The subband indices are used as they are
/// defined in the Subband class. The tile indices start at 0 and follow a
/// lexicographical order. The code-block indices follow a lexicographical
/// order within the subband tile.
///
/// <P>What is actually stored is the index of the element in
/// CBlkRateDistStats.truncIdxs that gives the real truncation point.
///
/// <ul>
/// <li>1st index: tile index, in lexicographical order </li>
/// <li>2nd index: component index </li>
/// <li>3rd index: resolution level </li>
/// <li>4th index: subband index</li>
/// <li>5th index: code-block index, in lexicographical order </li>
/// </ul>
///
/// </summary>
privateint[][][][][]prevtIdxs;
/// <summary> The saved base number of bits for sending code-block length
/// information. It is used for restoring previous saved state by
/// restore(). The indexes are outlined below. Note that the layer indexes
/// start at 1, therefore, the layer index minus 1 is used. The subband
/// indices are used as they are defined in the Subband class. The tile
/// indices start at 0 and follow a lexicographical order.
///
/// <ul>
/// <li>1st index: tile index, in lexicographical order </li>
/// <li>2nd index: component index </li>
/// <li>3rd index: resolution level </li>
/// <li>4th index: subband index </li>
/// <li>5th index: code-block index, in lexicographical order</li>
/// </ul>
///
/// </summary>
privateint[][][][][]bak_lblock;
/// <summary> The saved last encoded truncation point for each code-block. It is used
/// for restoring previous saved state by restore(). A negative value means
/// that no information has been included for the block, yet. The indexes
/// are outlined below. The subband indices are used as they are defined in
/// the Subband class. The tile indices start at 0 and follow a
/// lexicographical order. The code-block indices follow a lexicographical
/// order within the subband tile.
///
/// <ul>
/// <li>1st index: tile index, in lexicographical order </li>
/// <li>2nd index: component index </li>
/// <li>3rd index: resolution level </li>
/// <li>4th index: subband index </li>
/// <li>5th index: code-block index, in lexicographical order </li>
/// </ul>
///
/// </summary>
privateint[][][][][]bak_prevtIdxs;
/// <summary>The body buffer of the last encoded packet </summary>
privatebyte[]lbbuf;
/// <summary>The body length of the last encoded packet </summary>
privateintlblen;
/// <summary>The saved state </summary>
privateboolsaved;
/// <summary>Whether or not there is ROI information in the last encoded Packet </summary>
privateboolroiInPkt=false;
/// <summary>Length to read in current packet body to get all the ROI information </summary>
privateintroiLen=0;
/// <summary> Array containing the coordinates, width, height, indexes, ... of the
/// precincts.
///
/// <ul>
/// <li> 1st dim: tile index.</li>
/// <li> 2nd dim: component index.</li>
/// <li> 3rd dim: resolution level index.</li>
/// <li> 4th dim: precinct index.</li>
/// </ul>
///
/// </summary>
privatePrecInfo[][][][]ppinfo;
/// <summary>Whether or not the current packet is writable </summary>
privateboolpacketWritable;
/// <summary> Creates a new packet encoder object, using the information from the
/// 'infoSrc' object.
///
/// </summary>
/// <param name="infoSrc">The source of information to construct the object.
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
inttwoppx2=(int)(twoppx/2);
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
inttwoppy2=(int)(twoppy/2);
// Precincts are located at (cb0x+i*twoppx,cb0y+j*twoppy)
// Valid precincts are those which intersect with the current
// resolution level
intmaxPrec=ppinfo[t][c][r].Length;
intnPrec=0;
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
intp0x,p0y,p1x,p1y;// Precinct projection in subband
ints0x,s0y,s1x,s1y;// Active subband portion
intcw,ch;
intkstart,kend,lstart,lend,k0,l0;
intprg_ulx,prg_uly;
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
intprg_w=(int)twoppx<<ndl;
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
intprg_h=(int)twoppy<<ndl;
CBlkCoordInfocb;
for(inti=istart;i<=iend;i++)
{
// Vertical precincts
for(intj=jstart;j<=jend;j++,nPrec++)
{
// Horizontal precincts
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
prg_ulx=cb0x+j*xrsiz*((int)twoppx<<ndl);
}
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
prg_uly=cb0y+i*yrsiz*((int)twoppy<<ndl);
}
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
p0x=acb0x+j*(int)twoppx;
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
p1x=p0x+(int)twoppx;
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
p0y=acb0y+i*(int)twoppy;
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
p1y=p0y+(int)twoppy;
sb=(SubbandAn)root.getSubbandByIdx(0,0);
s0x=(p0x<sb.ulcx)?sb.ulcx:p0x;
s1x=(p1x>sb.ulcx+sb.w)?sb.ulcx+sb.w:p1x;
s0y=(p0y<sb.ulcy)?sb.ulcy:p0y;
s1y=(p1y>sb.ulcy+sb.h)?sb.ulcy+sb.h:p1y;
// Code-blocks are located at (acb0x+k*cw,acb0y+l*ch)
cw=sb.nomCBlkW;
ch=sb.nomCBlkH;
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
// Code-blocks are located at (acb0x+k*cw,acb0y+l*ch)
cw=sb.nomCBlkW;
ch=sb.nomCBlkH;
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
// Code-blocks are located at (acb0x+k*cw,acb0y+l*ch)
cw=sb.nomCBlkW;
ch=sb.nomCBlkH;
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
// Code-blocks are located at (acb0x+k*cw,acb0y+l*ch)
cw=sb.nomCBlkW;
ch=sb.nomCBlkH;
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"