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

writeLyResCompPos() public method

Write a piece of bit stream according to the LY_RES_COMP_POS_PROG progression mode and between given bounds
public writeLyResCompPos ( 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 writeLyResCompPos(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;
            SubbandAn sb;
            float threshold;
            BitOutputBuffer hBuff = null;
            byte[] bBuff = null;
            int nPrec = 0;

            int minlys = 100000; // minimum layer start index of each component
            for (int c = cs; c < ce; c++)
            {
                for (int r = 0; r < lys.Length; r++)
                {
                    if (lys[c] != null && r < lys[c].Length && lys[c][r] < minlys)
                    {
                        minlys = lys[c][r];
                    }
                }
            }

            for (int l = minlys; l < lye; l++)
            {
                // loop on layers
                for (int r = rs; r < re; r++)
                {
                    // loop on resolution level
                    for (int c = cs; c < ce; c++)
                    {
                        // loop on components
                        mrl = src.getAnSubbandTree(t, c).resLvl;
                        if (r > mrl)
                            continue;
                        if (r >= lys[c].Length)
                            continue;
                        if (l < lys[c][r])
                            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; 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 resolution levels
            } // end loop on layers
        }