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);
            }

            // Now parse the header.
            LstType = parser.GetFourCC(Attribute.ListType);

            if (LstType == (uint)ListType.Info)
            {
                do
                {
                    Valid = parser.Parse(new InfoAttribute(parser.BytesRemaining));
                }while (parser.BytesRemaining > 0 && Valid);
            }
            else if (LstType == (uint)ListType.Prmi)
            {
                uint maxPrmiLength = (uint)AviDetector.Configurable[AviDetector.ConfigurationKey.HeaderListMaxPrmiLength];
                parser.GetInt(Attribute.Unknown);
                parser.GetInt(Attribute.Unknown);
                parser.GetInt(Attribute.Unknown);
                if (parser.BytesRemaining > maxPrmiLength)
                {
                    return(false);                                                              // Sanity check
                }
                parser.GetString(Attribute.AviAdobePremiereInfoList, parser.BytesRemaining);
            }
            return(Valid);
        }
Beispiel #2
0
        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);
        }