public T GetSubChunk <T>(string id) where T : RiffSubChunk { RiffSubChunk chunk; SubChunks.TryGetValue(id, out chunk); return(chunk as T); }
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); }
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; } } }
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); }