/// <summary> This class is used to read packet's head and body. All the members must be
/// re-initialized at the beginning of each tile thanks to the restart()
/// method.
///
/// </summary>
publicclassPktDecoder
{
/// <summary>Reference to the codestream reader agent </summary>
privateBitstreamReaderAgentsrc;
/// <summary>Flag indicating whether packed packet header was used for this tile </summary>
privateboolpph=false;
/// <summary>The packed packet header if it was used </summary>
privateSystem.IO.MemoryStreampphbais;
/// <summary>Reference to decoder specifications </summary>
privateDecoderSpecsdecSpec;
/// <summary>Reference to the HeaderDecoder </summary>
privateHeaderDecoderhd;
/// <summary>Initial value of the state variable associated with code-block
/// length.
/// </summary>
//UPGRADE_NOTE: Final was removed from the declaration of 'INIT_LBLOCK '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
privateintINIT_LBLOCK=3;
/// <summary>The wrapper to read bits for the packet heads </summary>
privatePktHeaderBitReaderbin;
/// <summary>Reference to the stream where to read from </summary>
privateRandomAccessIOehs;
/// <summary> Maximum number of precincts :
///
/// <ul>
/// <li> 1st dim: component index.</li>
/// <li> 2nd dim: resolution level index.</li>
/// </ul>
///
/// </summary>
privateCoord[][]numPrec;
/// <summary>Index of the current tile </summary>
privateinttIdx;
/// <summary> Array containing the coordinates, width, height, indexes, ... of the
/// precincts in the current tile:
///
/// <ul>
/// <li> 1st dim: component index.</li>
/// <li> 2nd dim: resolution level index.</li>
/// <li> 3rd dim: precinct index.</li>
/// </ul>
///
/// </summary>
privatePrecInfo[][][]ppinfo;
/// <summary> Lblock value used to read code size information in each packet head:
///
/// <ul>
/// <li> 1st dim: component index.</li>
/// <li> 2nd dim: resolution level index.</li>
/// <li> 3rd dim: subband index.</li>
/// <li> 4th/5th dim: code-block index (vert. and horiz.).</li>
/// </ul>
///
/// </summary>
privateint[][][][][]lblock;
/// <summary> Tag tree used to read inclusion informations in packet's head:
///
/// <ul>
/// <li> 1st dim: component index.</li>
/// <li> 2nd dim: resolution level index.</li>
/// <li> 3rd dim: precinct index.</li>
/// <li> 4th dim: subband index.</li>
///
/// </summary>
privateTagTreeDecoder[][][][]ttIncl;
/// <summary> Tag tree used to read bit-depth information in packet's head:
///
/// <ul>
/// <li> 1st dim: component index.</li>
/// <li> 2nd dim: resolution level index.</li>
/// <li> 3rd dim: precinct index.</li>
/// <li> 4th dim: subband index.</li>
/// </ul>
///
/// </summary>
privateTagTreeDecoder[][][][]ttMaxBP;
/// <summary>Number of layers in t he current tile </summary>
privateintnl=0;
/// <summary>The number of components </summary>
privateintnc;
/// <summary>Whether or not SOP marker segment are used </summary>
privateboolsopUsed=false;
/// <summary>Whether or not EPH marker are used </summary>
privateboolephUsed=false;
/// <summary>Index of the current packet in the tile. Used with SOP marker segment
///
/// </summary>
privateintpktIdx;
/// <summary>List of code-blocks found in last read packet head (one list
// Get the tile-component coordinates on the reference grid
tcx0=src.getResULX(c,mdl[c]);
tcy0=src.getResULY(c,mdl[c]);
tcx1=tcx0+src.getTileCompWidth(tIdx,c,mdl[c]);
tcy1=tcy0+src.getTileCompHeight(tIdx,c,mdl[c]);
for(intr=0;r<=mdl[c];r++)
{
// Tile's coordinates in the reduced resolution image domain
//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'"
// Calculate the maximum number of precincts for each
// resolution level taking into account tile specific options.
doubletwoppx=(double)getPPX(tIdx,c,r);
doubletwoppy=(double)getPPY(tIdx,c,r);
numPrec[c][r]=newCoord();
if(trx1>trx0)
{
//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[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;
inttmp1,tmp2;
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=(SubbandSyn)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'"