Esempio n. 1
0
 protected override void LoadFromStream(System.IO.Stream stream)
 {
     base.LoadFromStream(stream);
     ConfigurationVersion = (byte)stream.ReadByte();
     ProfileIndication    = (byte)stream.ReadByte();
     Compatibility        = (byte)stream.ReadByte();
     LevelIndication      = (byte)stream.ReadByte();
     stream.ReadByte(); // Reserved
     SequenceParameterSets = new byte[stream.ReadByte() & ~0xE0][];
     for (int i = 0; i < SequenceParameterSets.Length; i++)
     {
         SequenceParameterSets[i] = stream.ReadBytes(stream.ReadBEUInt16());
     }
     PictureParameterSets = new byte[stream.ReadByte()][];
     for (int i = 0; i < PictureParameterSets.Length; i++)
     {
         PictureParameterSets[i] = stream.ReadBytes(stream.ReadBEUInt16());
     }
     if (ProfileHasExtraData(ProfileIndication))
     {
         ChromaFormatIdc          = (byte)(stream.ReadByte() & ~0xfc);
         BitDepthLuma             = (byte)(stream.ReadByte() & ~0xf8);
         BitDepthChroma           = (byte)(stream.ReadByte() & ~0xf8);
         SequenceParameterSetsExt = new byte[stream.ReadByte()][];
         for (int i = 0; i < SequenceParameterSetsExt.Length; i++)
         {
             SequenceParameterSetsExt[i] = stream.ReadBytes(stream.ReadBEUInt16());
         }
     }
 }
Esempio n. 2
0
        public override void LoadFromBinaryReader(System.IO.Stream binaryReader)
        {
            base.LoadFromBinaryReader(binaryReader);

            int numStrips = _imageSize.Width / 8;

            Strips = new List <StripData>(numStrips);

            for (int i = 0; i < numStrips; i++)
            {
                var strip = new StripData();
                strip.OffSet = binaryReader.ReadUint32();

                Strips.Add(strip);
            }

            int stripSize;

            for (int i = 0; i < (numStrips - 1); i++)
            {
                //O tamanho do strip é determinando pegando a posição do próximo Strip - 1 (pois o primeiro byte tem as informações do CODEC)
                //e subtraindo da posição do Strip atual.
                stripSize = (int)((Strips[i + 1].OffSet - Strips[i].OffSet) - 1);

                Strips[i].CodecId   = binaryReader.ReadByte1();
                Strips[i].ImageData = binaryReader.ReadBytes(stripSize);
            }

            if (Strips.Count > 0) //Sam & Max has at least one ROOM that contains only palette and ZPlanes, but no images.
            {
                stripSize = (int)((BlockSize - Strips[Strips.Count - 1].OffSet) - 1);
                Strips[Strips.Count - 1].CodecId   = binaryReader.ReadByte1();
                Strips[Strips.Count - 1].ImageData = binaryReader.ReadBytes(stripSize);
            }
        }
Esempio n. 3
0
        public override void LoadFromBinaryReader(System.IO.Stream binaryReader)
        {
            base.LoadFromBinaryReader(binaryReader);
            Contents = binaryReader.ReadBytes((int)(BlockSize - 8));

            //Hack para o monkey island 2 com vozes.
            if (BinaryHelper.ConvertByteArrayToUTF8String(binaryReader.PeekBytes(4)) == "021_")
            {
                var lstBytes = new List <byte>(Contents);
                lstBytes.AddRange(binaryReader.ReadBytes(8));

                Contents = lstBytes.ToArray();
            }
        }
Esempio n. 4
0
        public static FcgiRequest ReadRequest(this System.IO.Stream stream)
        {
            var version = (byte)stream.ReadByte2();
            //Program.Log(string.Format("read version : {0}", version));
            var type       = stream.ReadByte();
            var reqId      = (ushort)(stream.ReadByte2() * 256 + stream.ReadByte2());
            var contentLen = stream.ReadByte2() * 256 + stream.ReadByte2();
            var paddingLen = stream.ReadByte2();
            var reserverd  = stream.ReadByte2();
            //Program.Log(string.Format("{0}, {1}, {2}", contentLen, paddingLen, reserverd));
            var content = stream.ReadBytes(contentLen);
            var padding = stream.ReadBytes(paddingLen);

            return(new FcgiRequest {
                Version = version, Type = (FcgiType)type, RequestId = reqId, Content = content, Padding = padding
            });
        }
Esempio n. 5
0
            protected override void LoadFromStream(System.IO.Stream stream)
            {
                base.LoadFromStream(stream);
                stream.ReadBEUInt32();
                stream.ReadBEUInt16();
                stream.ReadBEUInt16();
                CodecStreamVersion  = stream.ReadBEUInt16(); // 2 == uncompressed YCbCr
                CodecStreamRevision = stream.ReadBEUInt16();
                stream.ReadBEUInt32();                       // Reserved
                stream.ReadBEUInt32();                       // Reserved
                stream.ReadBEUInt32();                       // Reserved
                VideoWidth  = stream.ReadBEUInt16();
                VideoHeight = stream.ReadBEUInt16();
                HorzDPI     = stream.ReadBEUInt32();
                VertDPI     = stream.ReadBEUInt32();
                DataSize    = stream.ReadBEUInt32();
                FrameCount  = stream.ReadBEUInt16();
                byte count = (byte)stream.ReadByte();

                if (count > 31)
                {
                    count = 0;
                }
                if (count == 0)
                {
                    CompressorName = null;
                }
                else
                {
                    byte[] data = stream.ReadBytes(count);
                    CompressorName = Encoding.UTF8.GetString(data);
                }
                if (count != 31)
                {
                    stream.ReadBytes(31 - count);
                }
                stream.ReadBEUInt16(); // Depth?
                stream.ReadBEUInt16(); // pre_defined?
            }
Esempio n. 6
0
        public override void LoadFromBinaryReader(System.IO.Stream binaryReader)
        {
            base.LoadFromBinaryReader(binaryReader);

            Unknown = binaryReader.ReadUint16();
            Width   = binaryReader.ReadUint16();
            Height  = binaryReader.ReadUint16();

            Padding    = new ushort[2];
            Padding[0] = binaryReader.ReadUint16();
            Padding[1] = binaryReader.ReadUint16();

            Data = binaryReader.ReadBytes((int)(BlockSize - 18));
        }
Esempio n. 7
0
        public void Read(System.IO.Stream stream)
        {
            byte[] buf        = stream.ReadByte4();
            var    str        = System.Text.Encoding.ASCII.GetString(buf);
            var    magiccheck = "\u007fELF";

            if (str != magiccheck)
            {
                throw new Exception("Not a ELF file.");
            }
            this.Head_Magic = str;

            var classtype = stream.ReadByte();

            if (classtype == 1)
            {
                Head_Is64Bit = false;
            }
            else if (classtype == 2)
            {
                Head_Is64Bit = true;
            }
            else
            {
                throw new Exception("Error ClassType =" + classtype);
            }
            var endianess = stream.ReadByte1();

            if (endianess == 1)
            {
                Head_IsLittleEndian = true;
            }
            else if (endianess == 2)
            {
                Head_IsLittleEndian = false;
            }
            else
            {
                throw new Exception("Error Endianess =" + endianess);
            }

            Head_Version     = stream.ReadByte1();
            this.Head_Unuse9 = stream.ReadBytes(9);



            Head_Type        = (FileType)stream.ReadUInt16(this);
            Head_Machine     = (MachineType)stream.ReadUInt16(this);
            Head_FileVersion = stream.ReadUInt32(this);
            if (Head_FileVersion != 1)
            {
                throw new ArgumentException("unknown version" + Head_FileVersion);
            }
            Head_EntryPoint              = stream.ReadUIntPtr(this);
            Head_SegmentHeaderOffset     = stream.ReadUIntPtr(this);
            Head_SectionHeaderOffset     = stream.ReadUIntPtr(this);
            Head_MachineFlags            = stream.ReadUInt32(this);
            Head_ELFHeadSize             = stream.ReadUInt16(this); // elf header size
            Head_SegmentHeaderEntrySize  = stream.ReadUInt16(this);
            Head_SegmentHeaderEntryCount = stream.ReadUInt16(this);
            Head_SectionHeaderEntrySize  = stream.ReadUInt16(this);
            Head_SectionHeaderEntryCount = stream.ReadUInt16(this);
            Head_StringTableIndex        = stream.ReadUInt16(this);
        }
Esempio n. 8
0
File: DTX.cs Progetto: maxton/DtxCS
 /// <summary>
 /// Parses the entirety of a .dta file in a stream to a DataArray.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public static DataArray FromDtaStream(System.IO.Stream data)
 => FromDtaString(new UTF8Encoding(false).GetString(data.ReadBytes((int)data.Length)));