CSJ2K.j2k.codestream.reader.HeaderDecoder.HeaderDecoder C# (CSharp) Method

HeaderDecoder() public method

Creates a HeaderDecoder instance and read in two passes the main header of the codestream. The first and last marker segments shall be respectively SOC and SOT.
If an I/O error occurs while reading from the /// encoded header stream. /// If the end of the encoded header stream is /// reached before getting all the data. /// If invalid data is found in the /// codestream main header. /// ///
public HeaderDecoder ( RandomAccessIO ehs, CSJ2K.j2k.util.ParameterList pl, HeaderInfo hi ) : System
ehs RandomAccessIO The encoded header stream where marker segments are /// extracted. /// ///
pl CSJ2K.j2k.util.ParameterList The ParameterList object of the decoder /// ///
hi CSJ2K.j2k.codestream.HeaderInfo The HeaderInfo holding information found in marker segments /// ///
return System
        public HeaderDecoder(RandomAccessIO ehs, ParameterList pl, HeaderInfo hi)
        {
            this.hi = hi;
            // CONVERSION PROBLEM?
            //this.verbose = verbose;

            pl.checkList(OPT_PREFIX, ParameterList.toNameArray(pinfo));

            mainHeadOff = ehs.Pos;
            if (((short) ehs.readShort()) != CSJ2K.j2k.codestream.Markers.SOC)
            {
                throw new CorruptedCodestreamException("SOC marker segment not " + " found at the " + "beginning of the " + "codestream.");
            }

            // First Pass: Decode and store main header information until the SOT
            // marker segment is found
            nfMarkSeg = 0;
            do
            {
                extractMainMarkSeg(ehs.readShort(), ehs);
            }
            while ((nfMarkSeg & SOT_FOUND) == 0); //Stop when SOT is found
            ehs.seek(ehs.Pos - 2); // Realign codestream on SOT marker

            // Second pass: Read each marker segment previously found
            readFoundMainMarkSeg();
        }