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

readCOM() private method

Reads a COM marker segments and realigns the bit stream at the point where the next marker segment should be found. COM is an informational marker segment that allows to include unstructured data in the main and tile-part headers.
If an I/O error occurs while reading from the /// encoded header stream /// ///
private readCOM ( System ehs, bool mainh, int tileIdx, int comIdx ) : void
ehs System The encoded header stream /// ///
mainh bool Flag indicating whether or not this marker segment is read /// from the main header. /// ///
tileIdx int The index of the current tile /// ///
comIdx int Occurence of this COM marker in eith main or tile-part /// header /// ///
return void
        private void readCOM(System.IO.BinaryReader ehs, bool mainh, int tileIdx, int comIdx)
        {
            HeaderInfo.COM ms = hi.NewCOM;

            // Read length of COM field
            ms.lcom = ehs.ReadUInt16();

            // Read the registration value of the COM marker segment
            ms.rcom = ehs.ReadUInt16();
            switch (ms.rcom)
            {

                case CSJ2K.j2k.codestream.Markers.RCOM_GEN_USE:
                    ms.ccom = new byte[ms.lcom - 4];
                    for (int i = 0; i < ms.lcom - 4; i++)
                    {
                        ms.ccom[i] = ehs.ReadByte();
                    }
                    break;

                default:
                    // --- Unknown or unsupported markers ---
                    // (skip them and see if we can get way with it)
                    FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "COM marker registered as 0x" + System.Convert.ToString(ms.rcom, 16) + " unknown, ignoring (this might crash the " + "decoder or decode a quality degraded or even " + "useless image)");
                    System.IO.BinaryReader temp_BinaryReader;
                    System.Int64 temp_Int64;
                    temp_BinaryReader = ehs;
                    temp_Int64 = temp_BinaryReader.BaseStream.Position;
                    temp_Int64 = temp_BinaryReader.BaseStream.Seek(ms.lcom - 4, System.IO.SeekOrigin.Current) - temp_Int64;
                    // CONVERSION PROBLEM?
                    int generatedAux2 = (int)temp_Int64; //Ignore this field for the moment
                    break;

            }

            if (mainh)
            {
                hi.comValue["main_" + comIdx] = ms;
            }
            else
            {
                hi.comValue["t" + tileIdx + "_" + comIdx] = ms;
            }

            // Check marker length
            checkMarkerLength(ehs, "COM marker");
        }