CSJ2K.j2k.codestream.writer.HeaderEncoder.writePOC C# (CSharp) Method

writePOC() protected method

Writes POC marker segment. POC is a functional marker segment containing the bounds and progression order for any progression order other than default in the codestream.
protected writePOC ( bool mh, int tileIdx ) : void
mh bool Flag indicating whether the main header is to be written /// ///
tileIdx int Tile index /// ///
return void
        protected internal virtual void writePOC(bool mh, int tileIdx)
        {
            int markSegLen = 0; // Segment marker length
            int lenCompField; // Holds the size of any component field as
            // this size depends on the number of
            //components
            Progression[] prog = null; // Holds the progression(s)
            int npoc; // Number of progression order changes

            // Get the progression order changes, their number and checks
            // if it is ok
            if (mh)
            {
                prog = (Progression[]) (encSpec.pocs.getDefault());
            }
            else
            {
                prog = (Progression[]) (encSpec.pocs.getTileDef(tileIdx));
            }

            // Calculate the length of a component field (depends on the number of
            // components)
            lenCompField = (nComp < 257?1:2);

            // POC marker
            hbuf.Write((System.Int16) CSJ2K.j2k.codestream.Markers.POC);

            // Lpoc (marker segment length (in bytes))
            // Basic: Lpoc(2 bytes) + npoc * [ RSpoc(1) + CSpoc(1 or 2) +
            // LYEpoc(2) + REpoc(1) + CEpoc(1 or 2) + Ppoc(1) ]
            npoc = prog.Length;
            markSegLen = 2 + npoc * (1 + lenCompField + 2 + 1 + lenCompField + 1);
            hbuf.Write((System.Int16) markSegLen);

            // Write each progression order change
            for (int i = 0; i < npoc; i++)
            {
                // RSpoc(i)
                hbuf.Write((System.Byte) prog[i].rs);
                // CSpoc(i)
                if (lenCompField == 2)
                {
                    hbuf.Write((System.Int16) prog[i].cs);
                }
                else
                {
                    hbuf.Write((System.Byte) prog[i].cs);
                }
                // LYEpoc(i)
                hbuf.Write((System.Int16) prog[i].lye);
                // REpoc(i)
                hbuf.Write((System.Byte) prog[i].re);
                // CEpoc(i)
                if (lenCompField == 2)
                {
                    hbuf.Write((System.Int16) prog[i].ce);
                }
                else
                {
                    hbuf.Write((System.Byte) prog[i].ce);
                }
                // Ppoc(i)
                hbuf.Write((System.Byte) prog[i].type);
            }
        }