CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.writeResLyCompPos C# (CSharp) Method

writeResLyCompPos() public method

Write a piece of bit stream according to the RES_LY_COMP_POS_PROG progression mode and between given bounds
public writeResLyCompPos ( int t, int rs, int re, int cs, int ce, int lys, int lye ) : void
t int Tile index. /// ///
rs int First resolution level index. /// ///
re int Last resolution level index. /// ///
cs int First component index. /// ///
ce int Last component index. /// ///
lys int First layer index for each component and resolution. /// ///
lye int Index of the last layer. /// ///
return void
        public virtual void writeResLyCompPos(int t, int rs, int re, int cs, int ce, int[][] lys, int lye)
        {
            bool sopUsed; // Should SOP markers be used ?
            bool ephUsed; // Should EPH markers be used ?
            int nc = src.NumComps;
            int[] mrl = new int[nc];
            SubbandAn sb;
            float threshold;
            BitOutputBuffer hBuff = null;
            byte[] bBuff = null;
            int nPrec = 0;

            // Max number of resolution levels in the tile
            int maxResLvl = 0;
            for (int c = 0; c < nc; c++)
            {
                mrl[c] = src.getAnSubbandTree(t, c).resLvl;
                if (mrl[c] > maxResLvl)
                    maxResLvl = mrl[c];
            }

            int minlys; // minimum layer start index of each component

            for (int r = rs; r < re; r++)
            {
                //loop on resolution levels
                if (r > maxResLvl)
                    continue;

                minlys = 100000;
                for (int c = cs; c < ce; c++)
                {
                    if (r < lys[c].Length && lys[c][r] < minlys)
                    {
                        minlys = lys[c][r];
                    }
                }

                for (int l = minlys; l < lye; l++)
                {
                    //loop on layers
                    for (int c = cs; c < ce; c++)
                    {
                        //loop on components
                        if (r >= lys[c].Length)
                            continue;
                        if (l < lys[c][r])
                            continue;

                        // If no more decomposition levels for this component
                        if (r > mrl[c])
                            continue;

                        nPrec = numPrec[t][c][r].x * numPrec[t][c][r].y;
                        for (int p = 0; p < nPrec; p++)
                        {
                            // loop on precincts

                            // set boolean sopUsed here (SOP markers)
                            sopUsed = ((System.String) encSpec.sops.getTileDef(t)).Equals("on");
                            // set boolean ephUsed here (EPH markers)
                            ephUsed = ((System.String) encSpec.ephs.getTileDef(t)).Equals("on");

                            sb = src.getAnSubbandTree(t, c);
                            for (int i = mrl[c]; i > r; i--)
                            {
                                sb = sb.subb_LL;
                            }

                            threshold = layers[l].rdThreshold;
                            findTruncIndices(l, c, r, t, sb, threshold, p);

                            hBuff = pktEnc.encodePacket(l + 1, c, r, t, cblks[t][c][r], truncIdxs[t][l][c][r], hBuff, bBuff, p);

                            if (pktEnc.PacketWritable)
                            {
                                bsWriter.writePacketHead(hBuff.Buffer, hBuff.Length, false, sopUsed, ephUsed);
                                bsWriter.writePacketBody(pktEnc.LastBodyBuf, pktEnc.LastBodyLen, false, pktEnc.ROIinPkt, pktEnc.ROILen);
                            }
                        } // End loop on precincts
                    } // End loop on components
                } // End loop on layers
            } // End loop on resolution levels
        }