예제 #1
0
        public T GetSubChunk <T>(string id) where T : RiffSubChunk
        {
            RiffSubChunk chunk;

            SubChunks.TryGetValue(id, out chunk);
            return(chunk as T);
        }
예제 #2
0
        protected override uint LoadChunk(uint length, BinaryReader br)
        {
            var    initialOffset = br.BaseStream.Position;
            ushort subChunkCount = br.ReadUInt16();

            Delay = br.ReadUInt16();
            br.ReadUInt16();
            Width  = br.ReadUInt16();
            Height = br.ReadUInt16();

            for (int i = 0; i < subChunkCount; i++)
            {
                SubChunks.Add(Load(br, _videoWidth, _videoHeight));
            }

            ApiUtil.Assert(br.BaseStream.Position == initialOffset + length);
            return(length);
        }
예제 #3
0
        public void ParseRiff(Stream file)
        {
            using (BinaryReader reader = GetBinaryReader(file, Endianness.LittleEndian))
            {
                RiffChunk = RiffChunk.Parse(reader);
                SubChunks.Clear();

                // Size is counted from after the ChunkSize field, not the RiffType field
                long startOffset = reader.BaseStream.Position - 4;
                long endOffset   = startOffset + RiffChunk.Size;

                // Make sure 8 bytes are available for the subchunk header
                while (reader.BaseStream.Position + 8 < endOffset)
                {
                    RiffSubChunk subChunk = ParseSubChunk(reader);
                    SubChunks[subChunk.SubChunkId] = subChunk;
                }
            }
        }
예제 #4
0
        protected override uint LoadChunk(uint length, ISerializer s)
        {
            if (s == null)
            {
                throw new ArgumentNullException(nameof(s));
            }
            var    initialOffset = s.Offset;
            ushort subChunkCount = s.UInt16(null, 0);

            Delay = s.UInt16(null, 0);
            s.UInt16(null, 0);
            Width  = s.UInt16(null, 0);
            Height = s.UInt16(null, 0);

            for (int i = 0; i < subChunkCount; i++)
            {
                SubChunks.Add(Load(s, _videoWidth, _videoHeight));
            }

            ApiUtil.Assert(s.Offset == initialOffset + length);
            return(length);
        }