CSJ2K.j2k.codestream.reader.PktDecoder.restart C# (CSharp) Method

restart() public method

Re-initialize the PktDecoder instance at the beginning of a new tile.
public restart ( int nc, int mdl, int nl, CSJ2K.j2k.codestream.reader.CBlkInfo cbI, bool pph, System pphbais ) : CSJ2K.j2k.codestream.reader.CBlkInfo[][][][][]
nc int The number of components in this tile /// ///
mdl int The maximum number of decomposition level in each component /// of this tile /// ///
nl int The number of layers in this tile /// ///
cbI CSJ2K.j2k.codestream.reader.CBlkInfo The code-blocks array /// ///
pph bool Flag indicating whether packed packet headers was used /// ///
pphbais System Stream containing the packed packet headers /// ///
return CSJ2K.j2k.codestream.reader.CBlkInfo[][][][][]
        public virtual CBlkInfo[][][][][] restart(int nc, int[] mdl, int nl, CBlkInfo[][][][][] cbI, bool pph, System.IO.MemoryStream pphbais)
        {
            this.nc = nc;
            this.nl = nl;
            this.tIdx = src.TileIdx;
            this.pph = pph;
            this.pphbais = pphbais;

            sopUsed = ((System.Boolean) decSpec.sops.getTileDef(tIdx));
            pktIdx = 0;
            ephUsed = ((System.Boolean) decSpec.ephs.getTileDef(tIdx));

            cbI = new CBlkInfo[nc][][][][];
            lblock = new int[nc][][][][];
            ttIncl = new TagTreeDecoder[nc][][][];
            ttMaxBP = new TagTreeDecoder[nc][][][];
            numPrec = new Coord[nc][];
            ppinfo = new PrecInfo[nc][][];

            // Used to compute the maximum number of precincts for each resolution
            // level
            int tcx0, tcy0, tcx1, tcy1; // Current tile position in the domain of
            // the image component
            int trx0, try0, trx1, try1; // Current tile position in the reduced
            // resolution image domain
            //int xrsiz, yrsiz; // Component sub-sampling factors

            SubbandSyn root, sb;
            int mins, maxs;
            Coord nBlk = null;
            int cb0x = src.CbULX;
            int cb0y = src.CbULY;

            for (int c = 0; c < nc; c++)
            {
                cbI[c] = new CBlkInfo[mdl[c] + 1][][][];
                lblock[c] = new int[mdl[c] + 1][][][];
                ttIncl[c] = new TagTreeDecoder[mdl[c] + 1][][];
                ttMaxBP[c] = new TagTreeDecoder[mdl[c] + 1][][];
                numPrec[c] = new Coord[mdl[c] + 1];
                ppinfo[c] = new PrecInfo[mdl[c] + 1][];

                // 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 (int r = 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'"
                    trx0 = (int) System.Math.Ceiling(tcx0 / (double) (1 << (mdl[c] - r)));
                    //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'"
                    try0 = (int) System.Math.Ceiling(tcy0 / (double) (1 << (mdl[c] - r)));
                    //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'"
                    trx1 = (int) System.Math.Ceiling(tcx1 / (double) (1 << (mdl[c] - r)));
                    //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'"
                    try1 = (int) System.Math.Ceiling(tcy1 / (double) (1 << (mdl[c] - r)));

                    // Calculate the maximum number of precincts for each
                    // resolution level taking into account tile specific options.
                    double twoppx = (double) getPPX(tIdx, c, r);
                    double twoppy = (double) getPPY(tIdx, c, r);
                    numPrec[c][r] = new Coord();
                    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'"
                        numPrec[c][r].x = (int) System.Math.Ceiling((trx1 - cb0x) / twoppx) - (int) System.Math.Floor((trx0 - cb0x) / twoppx);
                    }
                    else
                    {
                        numPrec[c][r].x = 0;
                    }
                    if (try1 > try0)
                    {
                        //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'"
                        numPrec[c][r].y = (int) System.Math.Ceiling((try1 - cb0y) / twoppy) - (int) System.Math.Floor((try0 - cb0y) / twoppy);
                    }
                    else
                    {
                        numPrec[c][r].y = 0;
                    }

                    // First and last subbands indexes
                    mins = (r == 0)?0:1;
                    maxs = (r == 0)?1:4;

                    int maxPrec = numPrec[c][r].x * numPrec[c][r].y;

                    ttIncl[c][r] = new TagTreeDecoder[maxPrec][];
                    for (int i = 0; i < maxPrec; i++)
                    {
                        ttIncl[c][r][i] = new TagTreeDecoder[maxs + 1];
                    }
                    ttMaxBP[c][r] = new TagTreeDecoder[maxPrec][];
                    for (int i2 = 0; i2 < maxPrec; i2++)
                    {
                        ttMaxBP[c][r][i2] = new TagTreeDecoder[maxs + 1];
                    }
                    cbI[c][r] = new CBlkInfo[maxs + 1][][];
                    lblock[c][r] = new int[maxs + 1][][];

                    ppinfo[c][r] = new PrecInfo[maxPrec];
                    fillPrecInfo(c, r, mdl[c]);

                    root = (SubbandSyn) src.getSynSubbandTree(tIdx, c);
                    for (int s = mins; s < maxs; s++)
                    {
                        sb = (SubbandSyn) root.getSubbandByIdx(r, s);
                        nBlk = sb.numCb;

                        cbI[c][r][s] = new CBlkInfo[nBlk.y][];
                        for (int i3 = 0; i3 < nBlk.y; i3++)
                        {
                            cbI[c][r][s][i3] = new CBlkInfo[nBlk.x];
                        }
                        lblock[c][r][s] = new int[nBlk.y][];
                        for (int i4 = 0; i4 < nBlk.y; i4++)
                        {
                            lblock[c][r][s][i4] = new int[nBlk.x];
                        }

                        for (int i = nBlk.y - 1; i >= 0; i--)
                        {
                            ArrayUtil.intArraySet(lblock[c][r][s][i], INIT_LBLOCK);
                        }
                    } // loop on subbands
                } // End loop on resolution levels
            } // End loop on components

            return cbI;
        }