Exemple #1
0
        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);
        }
        private void ParseStreamType(AviParser parser)
        {
            byte streamTypeByte0 = parser.GetByte();
            byte streamTypeByte1 = parser.GetByte();

            StreamType = (InformationType)(((short)streamTypeByte0 << 8) | streamTypeByte1);

            parser.AddAttribute(new FormattedAttribute <Attribute, InformationType>(Attribute.InformationType, StreamType));
        }
        private bool ParseChannel(AviParser parser)
        {
            byte AsciiValueOfCharacterZero = Convert.ToByte('0');
            byte channelByte0 = parser.GetByte();
            byte channelByte1 = parser.GetByte();

            if (!((char)channelByte0).IsHexDigit() || !((char)channelByte1).IsHexDigit())
            {
                this.Valid = false;
                return(this.Valid);
            }

            Channel = (byte)((16 * (channelByte0 - AsciiValueOfCharacterZero)) + (channelByte1 - AsciiValueOfCharacterZero));

            parser.AddAttribute(new FormattedAttribute <Attribute, byte>(Attribute.Channel, Channel));

            return(true);
        }
        public override bool Parse(AviParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            // The 'Size' property is not set in the base class because this
            // class does not have the ChunkFlags.SizeAndType attribute set.
            Size = 1;

            parser.GetByte(Attribute.PaddingByte);

            return(this.Valid);
        }