Example #1
0
        public override bool Parse(QtParser parser)
        {
            uint maxUnparsedBytes = (uint)QtDetector.Configurable[QtDetector.ConfigurationKey.FileTypeMaxUnparsedBytes];

            if (!base.Parse(parser) || parser.BytesRemaining > maxUnparsedBytes)
            {
                return(false);
            }

            Brand majorBrand = (Brand)parser.GetFourCC(Attribute.MajorBrand);

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

            // Gets the list of compatible brands
            StringBuilder sb = new StringBuilder();
            List <Brand>  compatibleBrands = new List <Brand>();

            // Remaining data of the atom are the compatible brands
            while (parser.BytesRemaining >= 4)
            {
                uint compatibleBrand = parser.GetUInt();

                if (compatibleBrand != 0)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append(", ");
                    }

                    // Add 4CC
                    sb.Append(compatibleBrand.ToString4CC());
                    compatibleBrands.Add((Brand)compatibleBrand);
                }
            }

            // Create attribute with comma separated list of compatible brands
            parser.AddAttribute(new FormattedAttribute <Attribute, string>(Attribute.CompatibleBrands, sb.ToString()));

            _dataFormat = GetDataFormat((Brand)majorBrand);
            if (DataFormat == CodecID.Unknown)
            {
                // Scan compatible brands for known brand
                foreach (Brand brand in compatibleBrands)
                {
                    _dataFormat = GetDataFormat(brand);

                    if (DataFormat != CodecID.Unknown)
                    {
                        break;
                    }
                }
            }

            // Unsupported formats, such as JPEG-2000, should be ignored
            parser.CheckAttribute(Attribute.MajorBrand, DataFormat != CodecID.Unknown);

            // We expect the major brand in the list of compatible brands
            parser.CheckAttribute(Attribute.CompatibleBrands, compatibleBrands.Contains(majorBrand), false);
            return(this.Valid);
        }
Example #2
0
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            uint colorParameterType = parser.GetFourCC(Attribute.ColorParameterType);

            parser.CheckAttribute(Attribute.ColorParameterType, colorParameterType == "nclc".To4CC(), false);

            parser.GetUShort(Attribute.PrimariesIndex);
            parser.GetUShort(Attribute.TransferFunctionIndex);
            parser.GetUShort(Attribute.MatrixIndex);

            return(Valid);
        }
Example #3
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);
        }
        public override bool Parse(QtParser parser)
        {
            if (!base.Parse(parser))
            {
                return(false);
            }

            parser.GetFlags <Attribute, Flag>(Attribute.Flags, 4);

            uint dataReferenceType = parser.GetFourCC(Attribute.DataReferenceType);
            int  dataReferenceSize = parser.GetInt(Attribute.DataReferenceSize);

            if (dataReferenceType == (uint)DataReferenceType.alis)
            {
                parser.GetUInt(Attribute.DataReference);                 // TODO test
            }
            else if (dataReferenceType == (uint)DataReferenceType.url_)
            {
                uint maxUrlLength = (uint)QtDetector.Configurable[QtDetector.ConfigurationKey.ReferenceMovieDataReferenceMaxUrlLength];
                parser.GetCString(Attribute.DataReference, maxUrlLength);
            }
            return(this.Valid);
        }