Example #1
0
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            parser.GetUInt(Attribute.Version, "{0:X8}");

            // TODO: the sequence of descriptors is taken (mostly) from ffmpeg
            // TODO: verify that this is the actual sequence seen in (all) 3GPP files
            BaseDescriptor descriptor = ReadDescriptor(parser);

            if (descriptor.Tag == DescriptorClassTag.ES_DescrTag)
            {
                parser.GetUShort();                             // ID
                parser.GetByte();                               // priority
            }
            else
            {
                parser.GetUShort();                             // ID
            }

            descriptor = ReadDescriptor(parser);
            if (descriptor.Tag == DescriptorClassTag.DecoderConfigDescrTag)
            {
                parser.GetByte(Attribute.ObjectTypeIndication);                         // 0x20 Visual ISO/IEC 14496-2
                parser.GetByte(Attribute.StreamType);
                parser.GetThreeBytes(Attribute.BufferSizeDB);                           // 3 bytes
                parser.GetUInt(Attribute.MaxBitrate);
                parser.GetUInt(Attribute.AvgBitrate);

                descriptor = ReadDescriptor(parser);
                if ((parser.Position + descriptor.Length) > parser.Length)
                {
                    return(false);
                }
                if (descriptor.Tag == DescriptorClassTag.DecSpecificInfoTag)
                {
                    // Extra data can be empty (0 bytes)
                    if (descriptor.Length > 0)
                    {
                        ExtraData = parser.GetDataPacket(parser.Position, descriptor.Length);
                    }

                    Attributes.Add(new FormattedAttribute <Attribute, long>(Attribute.DecSpecificInfoSize, descriptor.Length));
                }
                parser.Position += Math.Min(descriptor.Length, parser.Length - parser.Position);
            }
            return(this.Valid);
        }
Example #2
0
        // See QuickTime File Format Specification, 2010-08-03, pg.1
        private static void ParseTcmiAtom(QtParser parser, uint size)
        {
            long tcmiPosition = (parser.Position - 4);

            parser.AddAttribute(new FormattedAttribute <QtAtom.Attribute, uint>(QtAtom.Attribute.Size, size));
            uint type = parser.GetFourCC(QtAtom.Attribute.Type);

            parser.CheckAttribute(QtAtom.Attribute.Type, type == Tcmi, false);
            parser.GetByte(QtAtom.Attribute.Version);
            parser.GetThreeBytes(QtAtom.Attribute.Flags);
            parser.GetUShort(Attribute.TextFont);
            parser.GetUShort(Attribute.TextFace);
            parser.GetUShort(Attribute.TextSize);
            parser.GetUShort(Attribute.TcmiReserved);
            parser.Parse(new Color(Attribute.TextColor));
            parser.Parse(new Color(Attribute.BackgroundColor));
            parser.GetPascalString(Attribute.FontName, 0);
            parser.CheckAttribute(QtAtom.Attribute.Size, size == (parser.Position - tcmiPosition), false);
        }
Example #3
0
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            if (!CheckComponentSubType(ComponentSubType.tmcd))
            {
                Valid = false;
                return(Valid);
            }

            uint reserved = parser.GetUInt();

            if (reserved == 0)
            {
                parser.AddAttribute(new FormattedAttribute <QtSampleDescriptionAtom.Attribute, int>(QtSampleDescriptionAtom.Attribute.Reserved, (int)reserved));
                parser.GetShort(QtSampleDescriptionAtom.Attribute.Reserved);
                parser.GetShort(QtSampleDescriptionAtom.Attribute.DataReferenceIndex);
                reserved = parser.GetUInt(Attribute.Reserved1);
                parser.CheckAttribute(Attribute.Reserved1, reserved == 0, true);
                parser.Parse(new Flags());
                parser.GetInt(Attribute.TimeScale);
                parser.GetInt(Attribute.FrameDuration);
                parser.GetByte(Attribute.NumberOfFrames);
                reserved = parser.GetThreeBytes(Attribute.Reserved2);
                parser.CheckAttribute(Attribute.Reserved2, reserved == 0, false);

                if (parser.BytesRemaining > 0)
                {
                    parser.GetHexDump(QtAtom.Attribute.AdditionalData, (int)parser.BytesRemaining);
                }
            }
            else
            {
                ParseTcmiAtom(parser, reserved);
            }
            return(Valid);
        }