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

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

            uint componentType = parser.GetFourCC(Attribute.ComponentType);

            // Component type should be 'dhlr' or 'mhlr' according to QuickTime specs and 0 according to MP4 spec
            parser.CheckAttribute(Attribute.ComponentType, (componentType == (uint)ComponentType.dhlr || componentType == (uint)ComponentType.mhlr || componentType == 0), false);

            if (componentType == 0)             // Labels names from MP4 spec
            {
                ComponentSubType = (ComponentSubType)parser.GetFourCC(Attribute.HandlerType);
                parser.GetUInt(Attribute.Reserved);
                parser.GetUInt(Attribute.Reserved);
                parser.GetUInt(Attribute.Reserved);

                // Note: For 'MP4' format, the component name may be represented by a single '1'!

                if (parser.BytesRemaining > 0)
                {
                    // FIXME: often, the 'ComponentName' is a Pascal string!!
                    ComponentName = parser.GetCString(Attribute.ComponentName, (uint)(parser.BytesRemaining - 1));
                }
            }
            else                // Label names from QuickTime spec
            {
                ComponentSubType = (ComponentSubType)parser.GetFourCC(Attribute.ComponentSubType);
                // From QuickTime File Format Specification: 'Reserved. Set to 0.'
                // By finding quicktime files with a value filled in for this value
                // it is assumed that 'set to 0' is ment for quicktime file writers.
                // Not for file readers. That is why the attribute is not invalided
                // when a value != 0 is found.
                parser.GetFourCC(Attribute.ComponentManufacturer);
                // From QuickTime File Format Specification: 'Reserved. Set to 0.'
                // By finding quicktime files with a value filled in for this value
                // it is assumed that 'set to 0' is ment for quicktime file writers.
                // Not for file readers. That is why the attribute is not invalided
                // when a value != 0 is found.
                parser.GetInt(Attribute.ComponentFlags);
                // From QuickTime File Format Specification: 'Reserved. Set to 0.'
                // By finding quicktime files with a value filled in for this value
                // it is assumed that 'set to 0' is ment for quicktime file writers.
                // Not for file readers. That is why the attribute is not invalided
                // when a value != 0 is found.
                parser.GetInt(Attribute.ComponentFlagsMask);

                if (parser.BytesRemaining > 0)
                {
                    ComponentName = parser.GetPascalString(Attribute.ComponentName, (int)parser.BytesRemaining);
                }
            }
            return(Valid);
        }
Example #3
0
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser)) return false;

            parser.GetUInt(Attribute.BufferSizeDB);
            parser.GetUInt(Attribute.MaxBitrate);
            parser.GetUInt(Attribute.AvgBitrate);

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

            parser.GetPascalString(Attribute.Data);

            return(this.Valid);
        }
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            parser.GetFourCC(Attribute.CompressionID);

            return(this.Valid);
        }
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            parser.GetInt(Attribute.Quality);

            return(this.Valid);
        }
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            parser.GetUInt(Attribute.NumberOfEntries);

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

            parser.GetUInt(Attribute.GroupingType);
            parser.GetUInt(Attribute.EntryCount);

            return(Valid);
        }
 internal void Parse(QtParser parser)
 {
     A = parser.GetFixed16_16(LAttribute.A);
     B = parser.GetFixed16_16(LAttribute.B);
     U = parser.GetFixed2_30(LAttribute.U);
     C = parser.GetFixed16_16(LAttribute.C);
     D = parser.GetFixed16_16(LAttribute.D);
     V = parser.GetFixed2_30(LAttribute.V);
     X = parser.GetFixed16_16(LAttribute.X);
     Y = parser.GetFixed16_16(LAttribute.Y);
     W = parser.GetFixed2_30(LAttribute.W);
 }
Example #10
0
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            parser.GetFourCC(Attribute.Vendor);
            parser.GetByte(Attribute.DecoderVersion);

            return(this.Valid);
        }
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            parser.GetShort(Attribute.GraphicsMode);
            parser.GetOpcolor(Attribute.Opcolor);

            return(this.Valid);
        }
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            //TODO: not all user data atoms contain a (pascal) string
            //parser.GetPascalString(Attribute.Data);

            return(this.Valid);
        }
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            parser.GetUInt(Attribute.HSpacing);
            parser.GetUInt(Attribute.VSpacing);

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

            parser.GetUInt(Attribute.AvgBitrate);
            parser.GetUInt(Attribute.MaxBitrate);

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

            // This atom is not flagged a full atom to be able to parse the
            // version byte over here. To preserve memory,
            // the version byte is not made available in QtAtom.
            byte version = parser.GetByte(QtAtom.Attribute.Version);

            ParseFlags(parser);

            if (version == 1)
            {
                parser.GetLongDateTime(Attribute.CreationTime, "{0:F}");
                parser.GetLongDateTime(Attribute.ModificationTime, "{0:F}");
                parser.GetUInt(Attribute.TimeScale);
                parser.GetULong(Attribute.Duration);
            }
            else             // version == 0
            {
                parser.GetDateTime(Attribute.CreationTime, "{0:F}");
                parser.GetDateTime(Attribute.ModificationTime, "{0:F}");
                parser.GetUInt(Attribute.TimeScale);
                parser.GetUInt(Attribute.Duration);
            }

            parser.GetFixed16_16(Attribute.PreferredRate);
            parser.GetFixed8_8(Attribute.PreferredVolume);
            parser.GetUShort(Attribute.Reserved);
            parser.GetUInt(Attribute.Reserved);
            parser.GetUInt(Attribute.Reserved);
            Matrix matrix = parser.GetMatrix(Attribute.MatrixStructure);

            // Matrix check from From ISO_IEC_15444-12_2005 Base Media File Format
            parser.CheckAttribute(Attribute.MatrixStructure, matrix.U == 0.0, false);
            parser.CheckAttribute(Attribute.MatrixStructure, matrix.V == 0.0, false);
            parser.CheckAttribute(Attribute.MatrixStructure, matrix.W == 1.0, false);
            parser.GetUInt(Attribute.PreviewTime);
            parser.GetUInt(Attribute.PreviewDuration);
            parser.GetUInt(Attribute.PosterTime);
            parser.GetUInt(Attribute.SelectionTime);
            parser.GetUInt(Attribute.SelectionDuration);
            parser.GetUInt(Attribute.CurrentTime);
            uint nextTrackID = parser.GetUInt(Attribute.NextTrackID);

            parser.CheckAttribute(Attribute.NextTrackID, nextTrackID != 0, false);

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

            // TODO
            //parser.Parse(new MatteImageDescriptionStructure());
            //parser.Parse(new MatteData());

            return(this.Valid);
        }
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            parser.GetUInt(Attribute.AtomID);
            parser.GetUShort(Attribute.Reserved);
            parser.GetUShort(Attribute.ChildCount);
            parser.GetUInt(Attribute.Reserved);

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

            int flags = parser.GetInt(Attribute.Flags);

            parser.CheckAttribute(Attribute.Flags, flags == 0);
            parser.GetUInt(Attribute.DataRate);

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

            parser.GetFourCC(Attribute.Vendor);
            parser.GetByte(Attribute.DecoderVersion);
            parser.GetUShort(Attribute.ModeSet);
            parser.GetByte(Attribute.ModeChangedPeriod);
            parser.GetByte(Attribute.FramesPerSample);

            return(this.Valid);
        }
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            const int EntrySize = 4;

            long numberOfEntries = parser.BytesRemaining / EntrySize;

            parser.Parse(new TrackIDTable(numberOfEntries));

            return(this.Valid);
        }
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            Size = 4;

            if (parser.GetUInt() != 0)
            {
                this.Valid = false;
            }
            return(this.Valid);
        }
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            double balance = parser.GetFixed8_8(Attribute.Balance);

            parser.CheckAttribute(Attribute.Balance, balance >= -1.0 && balance <= 1.0);
            short reserved = parser.GetShort(Attribute.Reserved);

            parser.CheckAttribute(Attribute.Reserved, reserved == 0);

            return(this.Valid);
        }
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

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

            // Video specific
            parser.GetUShort(Attribute.Version);
            ushort revisionLevel = parser.GetUShort(Attribute.RevisionLevel);

            parser.CheckAttribute(Attribute.RevisionLevel, revisionLevel == 0, false);
            parser.GetFourCC(Attribute.Vendor);
            int temporalQuality = parser.GetInt(Attribute.TemporalQuality);

            parser.CheckAttribute(Attribute.TemporalQuality, (temporalQuality >= 0 && temporalQuality <= 1023), false);
            int spatialQuality = parser.GetInt(Attribute.SpatialQuality);

            parser.CheckAttribute(Attribute.SpatialQuality, (spatialQuality >= 0 && spatialQuality <= 1024), false);
            parser.GetUShort(Attribute.Width);
            parser.GetUShort(Attribute.Height);
            parser.GetFixed16_16(Attribute.HorizontalResolution);
            parser.GetFixed16_16(Attribute.VerticalResolution);
            int dataSize = parser.GetInt(Attribute.DataSize);

            parser.CheckAttribute(Attribute.DataSize, dataSize == 0, false);
            parser.GetUShort(Attribute.FrameCount);
            parser.GetFixedLengthString(Attribute.CompressorName, 32);

            parser.GetShort(Attribute.Depth);
            short colorTableId = parser.GetShort(Attribute.ColorTableId);

            // If the color table ID is set to 0, a color table is contained within the sample description itself.
            // The color table immediately follows the color table ID field in the sample description.
            if (colorTableId == 0)
            {
                // TODO
            }
            return(Valid);
        }
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            int flags = parser.GetInt(Attribute.Flags);

            parser.CheckAttribute(Attribute.Flags, flags == 0);
            parser.GetFourCC(Attribute.SoftwarePackage);
            parser.GetUInt(Attribute.Version);
            parser.GetUInt(Attribute.Mask);
            parser.GetUShort(Attribute.CheckType);

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

            parser.GetDateTime(Attribute.CreationTime, "{0:F}");
            parser.GetDateTime(Attribute.ModificationTime, "{0:F}");
            parser.GetUInt(Attribute.Timescale);
            parser.GetUInt(Attribute.Duration);
            // TODO Language
            parser.GetUShort(Attribute.Language);               // codes < 0x800 Macintosh language codes
            // codes >= 0x800 ISO language codes
            parser.GetUShort(Attribute.Quality);

            return(this.Valid);
        }
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

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

            // Audio specific
            ushort version       = parser.GetUShort(Attribute.CompressedDataVersion);
            ushort revisionLevel = parser.GetUShort(Attribute.RevisionLevel);

            parser.CheckAttribute(Attribute.RevisionLevel, revisionLevel == 0);
            uint vendor = parser.GetFourCC(Attribute.Vendor);

            parser.CheckAttribute(Attribute.Vendor, vendor == 0, false);                // Not always true
            ushort numberOfChannels = parser.GetUShort(Attribute.NumberOfChannels);

            parser.CheckAttribute(Attribute.NumberOfChannels, numberOfChannels == 1 || numberOfChannels == 2, false);             // Example with value 6 found
            ushort sampleSize = parser.GetUShort(Attribute.SampleSize);

            parser.CheckAttribute(Attribute.SampleSize, sampleSize == 8 || sampleSize == 16, false);
            short compressionID = parser.GetShort(Attribute.CompressionID);

            parser.CheckAttribute(Attribute.CompressionID, compressionID == 0 || compressionID == -1 || compressionID == -2);
            ushort packetSize = parser.GetUShort(Attribute.PacketSize);

            parser.CheckAttribute(Attribute.PacketSize, packetSize == 0);
            parser.GetFixed16_16(Attribute.SampleRate);

            if (version == 1)
            {
                parser.GetUInt(Attribute.SamplePerPacket);
                parser.GetUInt(Attribute.BytesPerPacket);
                parser.GetUInt(Attribute.BytesPerFrame);
                parser.GetUInt(Attribute.BytesPerSample);
            }
            return(this.Valid);
        }
Example #27
0
File: AstParser.cs Project: mbid/qt
        private static T ParseT <T>(string body, Func <QtParser, T> fun)
        {
            StringBuilder lexerOutput     = new StringBuilder();
            StringBuilder lexerErrOutput  = new StringBuilder();
            QtLexer       lexer           = new QtLexer(new AntlrInputStream(body), new StringWriter(lexerOutput), new StringWriter(lexerErrOutput));
            StringBuilder parserOutput    = new StringBuilder();
            StringBuilder parserErrOutput = new StringBuilder();
            QtParser      parser          = new QtParser(new CommonTokenStream(lexer), new StringWriter(parserOutput), new StringWriter(parserErrOutput));
            T             result          = fun(parser);

            if (lexerErrOutput.Length > 0)
            {
                throw new ArgumentException(lexerErrOutput.ToString(), "body");
            }
            if (parserErrOutput.Length > 0)
            {
                throw new ArgumentException(parserErrOutput.ToString(), "body");
            }
            return(result);
        }
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            uint flags = parser.GetUInt(Attribute.Flags);

            parser.CheckAttribute(Attribute.Flags, flags == 0);
            parser.GetFourCC(Attribute.ComponentType);
            parser.GetFourCC(Attribute.ComponentSubType);
            parser.GetFourCC(Attribute.ComponentManufacturer);
            uint componentFlags = parser.GetUInt(Attribute.ComponentFlags);

            parser.CheckAttribute(Attribute.ComponentFlags, (componentFlags & 0xFF000000) == 0);
            parser.GetUInt(Attribute.ComponentFlagsMask);
            parser.GetUInt(Attribute.MinimumVersion);

            return(this.Valid);
        }
        public void TestAtomIsCreatedByFactoryMethod()
        {
            // Create a collection containing all classes derived from QtAtom
            // from the QuickTime/MP4/3GPP plug-in.
            IEnumerable <QtAtom> atomsFromComponent = GetAtomsFromComponent();

            // Call the QtAtom factory method to find out which classes are created
            HashSet <QtAtom> atomsCreatedByFactory = new HashSet <QtAtom>();
            QtAtom           dummyAtom             = new QtAtom(Enumerable.Repeat(_detector, 1));

            foreach (AtomName atomName in Enum.GetValues(typeof(AtomName)))
            {
                QtAtom atom = QtParser.CreateAtom(dummyAtom, atomName, 0U);
                Assert.IsNotNull(atom);

                if (!atomsCreatedByFactory.Contains(atom, new EqualityComparer()))
                {
                    atomsCreatedByFactory.Add(atom);
                }
            }

            // Report any atom from component not created by the factory method
            foreach (QtAtom atom in atomsFromComponent)
            {
                if (!atomsCreatedByFactory.Contains(atom, new EqualityComparer()))
                {
                    Assert.Fail("Atom not created by factory: {0}", atom.GetType().Name);
                }
            }

            // Atoms created by factory not in Component
            foreach (QtAtom atom in atomsCreatedByFactory)
            {
                if (!atomsFromComponent.Contains(atom, new EqualityComparer()))
                {
                    Assert.Fail("Atom not in component: {0}", atom.GetType().Name);
                }
            }
        }