Exemple #1
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);
        }
        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);
        }
Exemple #4
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);
        }
        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 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);
        }
        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);
        }
        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);
        }