public override bool Parse(AviParser parser) { const short MaxLongsPerEntryCount = 16; // Random choice. The only value I've seen up till now is 4. if (!base.Parse(parser)) { return(false); } ushort longsPerEntry = (ushort)parser.GetShort(Attribute.LongsPerEntry); if (longsPerEntry > MaxLongsPerEntryCount) { return(false); } parser.GetByte(Attribute.IndexSubType); parser.GetByte(Attribute.IndexType); parser.GetInt(Attribute.EntriesInUse); parser.GetInt(Attribute.ChunkId); parser.GetInt(Attribute.Reserved); parser.GetInt(Attribute.Reserved); parser.GetInt(Attribute.Reserved); if (longsPerEntry > 0) { ulong bytesRemaining = parser.BytesRemaining; parser.Parse(new IndexTableAttribute(longsPerEntry, bytesRemaining)); ulong numberOfEntriesInTable = bytesRemaining / (uint)(longsPerEntry * 4); parser.CheckAttribute(Attribute.IndexTable, numberOfEntriesInTable * longsPerEntry * 4 == bytesRemaining, false); } return(Valid); }
public override bool Parse(AviParser parser) { if (_frameFieldType == FrameFieldType.Short) { short leftEdge = parser.GetShort(LAttribute.LeftEdge); short topEdge = parser.GetShort(LAttribute.TopEdge); short rightEdge = parser.GetShort(LAttribute.RightEdge); short bottomEdge = parser.GetShort(LAttribute.BottomEdge); TypedValue = string.Format("({0}, {1}, {2}, {3})", leftEdge, topEdge, rightEdge, bottomEdge); } else { int leftEdge = parser.GetInt(LAttribute.LeftEdge); int topEdge = parser.GetInt(LAttribute.TopEdge); int rightEdge = parser.GetInt(LAttribute.RightEdge); int bottomEdge = parser.GetInt(LAttribute.BottomEdge); TypedValue = string.Format("({0}, {1}, {2}, {3})", leftEdge, topEdge, rightEdge, bottomEdge); } return(Valid); }
public override bool Parse(AviParser parser) { if (!base.Parse(parser)) { return(false); } switch (_aviStreamFormatType) { case AviStreamFormatType.Video: parser.GetInt(Attribute.Size); parser.GetInt(Attribute.Width); parser.GetInt(Attribute.Height); parser.GetShort(Attribute.Planes); parser.GetShort(Attribute.BitCount); Compression = parser.GetFourCC(Attribute.Compression); parser.GetInt(Attribute.SizeImage); parser.GetInt(Attribute.XPelsPerMeter); parser.GetInt(Attribute.YPelsPerMeter); parser.GetInt(Attribute.ClrUsed); parser.GetInt(Attribute.ClrImportant); ulong extraDataSize = parser.BytesRemaining; if ((extraDataSize >= 17) && (extraDataSize < 256)) { ExtraData = parser.GetDataPacket(parser.Position, (int)extraDataSize); Attributes.Add(new FormattedAttribute <Attribute, ulong>(Attribute.ExtraDataSize, extraDataSize)); } break; case AviStreamFormatType.Audio: FormatTagValue = parser.GetShort(Attribute.FormatTag, typeof(FormatTag)); parser.GetShort(Attribute.Channels); parser.GetInt(Attribute.SamplesPerSec); parser.GetInt(Attribute.AvgBytesPerSec); parser.GetShort(Attribute.BlockAlign); parser.GetShort(Attribute.BitsPerSample); if (FormatTagValue != (short)FormatTag.WAVE_FORMAT_PCM && parser.BytesRemaining > 0) { parser.GetShort(Attribute.ExtraSize); } // TODO parse the other audio formats switch (FormatTagValue) { case (short)FormatTag.WAVE_FORMAT_MPEGLAYER3: if (parser.BytesRemaining > 0) { parser.GetShort(Attribute.Id); parser.GetInt(Attribute.Flags); // TODO Parse the flags parser.GetShort(Attribute.BlockSize); parser.GetShort(Attribute.FramesPerBlock); // Some file I found did not have this last field if (parser.BytesRemaining > 0) { parser.GetShort(Attribute.CodecDelay); } } break; } break; default: break; } return(Valid); }