public override bool Parse(AviParser parser) { if (!base.Parse(parser)) { return(false); } if ((uint)Size > MaxUnparsedBytes) { return(false); } // Put the position back to the beginning of the header. // We want to be able the read the channel property. parser.Position -= 8; // Read the channel property (first 2 bytes of fourcc) if (!ParseChannel(parser)) { return(false); } // Read the information type property (last 2 bytes of fourcc) ParseStreamType(parser); // Skip the 'Size' bytes parser.Position += 4; ulong size = Math.Min(Size, parser.BytesRemaining); if (size > 0) { StreamData = parser.GetDataPacket(parser.Position, (long)size); } // Show the number of bytes that go to the codec detector parser.AddAttribute(new FormattedAttribute <Attribute, ulong>(Attribute.NumberOfBytesForCodecDetector, parser.BytesRemaining)); // Prevent AviChunk.ParseEnd() from displaying the unparsed bytes as hex dump parser.Position += (long)parser.BytesRemaining; 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); }