public override bool Parse(AviParser parser) { // Call the Parse method of the parent to initialise the header and // allow parsing the containing header if there is one. if (!base.Parse(parser)) { return(false); } FileType = parser.GetFourCC(Attribute.FileType); // 'AVI ' or 'AVIX' return(Valid); }
public override bool Parse(AviParser parser) { if (!base.Parse(parser)) { return(false); } const int FrameSize = 4 * sizeof(short); const int IntFieldCount = 11; const int ShortFieldCount = 2; const int ExpectedSize = IntFieldCount * sizeof(int) + ShortFieldCount * sizeof(short) + FrameSize; // One sample had 8 bytes more. // The assumption is made that the frame is written in four ints // instead of in four shorts. const int ExtraBytesAllowed = 8; if ((Size < ExpectedSize) || (Size > ExpectedSize && Size <= ExpectedSize + ExtraBytesAllowed)) // invalidate the size attribute { parser.CheckAttribute(AviChunk.Attribute.Size, Size == ExpectedSize, false); } else if (Size > ExpectedSize + ExtraBytesAllowed) // invalidate the complete header { parser.CheckAttribute(AviChunk.Attribute.Size, Size == ExpectedSize, true); } if (parser.BytesRemaining >= 4) { StreamType = parser.GetFourCC(Attribute.StreamType); } if (parser.BytesRemaining >= 4) { Handler = parser.GetFourCC(Attribute.Handler); } if (parser.BytesRemaining >= 4) { parser.GetInt(Attribute.Flags); } // TODO parse flags // // AVISF_DISABLED = 0x00000001 // Indicates this stream should not be enabled by default // // AVISF_VIDEO_PALCHANGES = 0x00010000 // Indicates this video stream contains palette changes. // This flag warns the playback software that it will need to // animate the palette. // if (parser.BytesRemaining >= 2) { parser.GetShort(Attribute.Priority); } if (parser.BytesRemaining >= 2) { parser.GetShort(Attribute.Language); } if (parser.BytesRemaining >= 4) { parser.GetInt(Attribute.InitialFrames); } if (parser.BytesRemaining >= 4) { parser.GetInt(Attribute.Scale); } if (parser.BytesRemaining >= 4) { parser.GetInt(Attribute.Rate); } if (parser.BytesRemaining >= 4) { parser.GetInt(Attribute.Start); } if (parser.BytesRemaining >= 4) { parser.GetInt(Attribute.Length); } if (parser.BytesRemaining >= 4) { parser.GetInt(Attribute.SuggestedBufferSize); } if (parser.BytesRemaining >= 4) { parser.GetInt(Attribute.Quality); } if (parser.BytesRemaining >= 4) { parser.GetInt(Attribute.SampleSize); } if (Size == ExpectedSize) { if (parser.BytesRemaining >= 8) { parser.GetFrame(Attribute.Frame, FrameFieldType.Short); } } else if (Size == ExpectedSize + 4 * sizeof(short)) { if (parser.BytesRemaining >= 16) { parser.GetFrame(Attribute.Frame, FrameFieldType.Int); } } return(Valid); }