CSJ2K.j2k.codestream.writer.PktEncoder.save C# (CSharp) Méthode

save() public méthode

Saves the current state of this object. The last saved state can be restored with the restore() method.
public save ( ) : void
Résultat void
        public virtual void save()
        {
            int maxsbi, minsbi;

            // Have we done any save yet?
            if (bak_lblock == null)
            {
                // Allocate backup buffers
                bak_lblock = new int[ttIncl.Length][][][][];
                bak_prevtIdxs = new int[ttIncl.Length][][][][];
                for (int t = ttIncl.Length - 1; t >= 0; t--)
                {
                    bak_lblock[t] = new int[ttIncl[t].Length][][][];
                    bak_prevtIdxs[t] = new int[ttIncl[t].Length][][][];
                    for (int c = ttIncl[t].Length - 1; c >= 0; c--)
                    {
                        bak_lblock[t][c] = new int[lblock[t][c].Length][][];
                        bak_prevtIdxs[t][c] = new int[ttIncl[t][c].Length][][];
                        for (int r = lblock[t][c].Length - 1; r >= 0; r--)
                        {
                            bak_lblock[t][c][r] = new int[lblock[t][c][r].Length][];
                            bak_prevtIdxs[t][c][r] = new int[prevtIdxs[t][c][r].Length][];
                            minsbi = (r == 0)?0:1;
                            maxsbi = (r == 0)?1:4;
                            for (int s = minsbi; s < maxsbi; s++)
                            {
                                bak_lblock[t][c][r][s] = new int[lblock[t][c][r][s].Length];
                                bak_prevtIdxs[t][c][r][s] = new int[prevtIdxs[t][c][r][s].Length];
                            }
                        }
                    }
                }
            }

            //-- Save the data

            // Use reference caches to minimize array access overhead
            TagTreeEncoder[][][] ttIncl_t_c, ttMaxBP_t_c;
            TagTreeEncoder[][] ttIncl_t_c_r, ttMaxBP_t_c_r;
            int[][][] lblock_t_c, bak_lblock_t_c;
            int[][] prevtIdxs_t_c_r, bak_prevtIdxs_t_c_r;

            // Loop on tiles
            for (int t = ttIncl.Length - 1; t >= 0; t--)
            {
                // Loop on components
                for (int c = ttIncl[t].Length - 1; c >= 0; c--)
                {
                    // Initialize reference caches
                    lblock_t_c = lblock[t][c];
                    bak_lblock_t_c = bak_lblock[t][c];
                    ttIncl_t_c = ttIncl[t][c];
                    ttMaxBP_t_c = ttMaxBP[t][c];
                    // Loop on resolution levels
                    for (int r = lblock_t_c.Length - 1; r >= 0; r--)
                    {
                        // Initialize reference caches
                        ttIncl_t_c_r = ttIncl_t_c[r];
                        ttMaxBP_t_c_r = ttMaxBP_t_c[r];
                        prevtIdxs_t_c_r = prevtIdxs[t][c][r];
                        bak_prevtIdxs_t_c_r = bak_prevtIdxs[t][c][r];

                        // Loop on subbands
                        minsbi = (r == 0)?0:1;
                        maxsbi = (r == 0)?1:4;
                        for (int s = minsbi; s < maxsbi; s++)
                        {
                            // Save 'lblock'
                            Array.Copy(lblock_t_c[r][s], 0, bak_lblock_t_c[r][s], 0, lblock_t_c[r][s].Length);
                            // Save 'prevtIdxs'
                            Array.Copy(prevtIdxs_t_c_r[s], 0, bak_prevtIdxs_t_c_r[s], 0, prevtIdxs_t_c_r[s].Length);
                        } // End loop on subbands

                        // Loop on precincts
                        for (int p = ppinfo[t][c][r].Length - 1; p >= 0; p--)
                        {
                            if (p < ttIncl_t_c_r.Length)
                            {
                                // Loop on subbands
                                for (int s = minsbi; s < maxsbi; s++)
                                {
                                    ttIncl_t_c_r[p][s].save();
                                    ttMaxBP_t_c_r[p][s].save();
                                } // End loop on subbands
                            }
                        } // End loop on precincts
                    } // End loop on resolutions
                } // End loop on components
            } // End loop on tiles

            // Set the saved state
            saved = true;
        }