public override bool Parse(QtParser parser) { if (!base.Parse(parser)) { return(false); } parser.GetUShort(Attribute.SubSequenceIdentifer); parser.GetByte(Attribute.LayerNumber); byte flags = parser.GetByte(); bool durationFlag = (flags & 0x80) == 0x80; bool avgRateFlag = (flags & 0x40) == 0x40; byte reserved = (byte)(flags & 0x3F); parser.AddAttribute(new FormattedAttribute <Attribute, bool>(Attribute.DurationFlag, durationFlag)); parser.AddAttribute(new FormattedAttribute <Attribute, bool>(Attribute.AvgRateFlag, avgRateFlag)); parser.AddAttribute(new FormattedAttribute <Attribute, byte>(Attribute.Reserved, reserved)); parser.CheckAttribute(Attribute.Reserved, reserved == 0, false); if (durationFlag) { parser.GetUInt(Attribute.Duration); } if (avgRateFlag) { parser.GetByte(Attribute.AccurateStatisticsFlag); parser.GetUShort(Attribute.AvgBitRate); parser.GetUShort(Attribute.AvgFrameRate); } parser.GetTable(Attribute.DependencyInfo, Attribute.NumReferences, NumberOfEntriesType.Byte, 32, () => new DependencyInfo(), parser.BytesRemaining); return(Valid); }
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); }
public override bool Parse(QtParser parser) { if (!base.Parse(parser)) { return(false); } const int EntrySize = 4; uint numberOfEntries = (uint)(parser.BytesRemaining / EntrySize); parser.AddAttribute(new FormattedAttribute <Attribute, uint>(Attribute.TableSize, numberOfEntries)); parser.GetTable(Attribute.TrackIDTable, Attribute.TableSize, numberOfEntries, EntrySize, () => new TrackID(), parser.BytesRemaining); return(Valid); }
public override bool Parse(QtParser parser) { uint flags = 0; for (int i = 0; i < _size; i++) { flags = (flags << 8) | parser.GetByte(); } foreach (TFlag flag in Enum.GetValues(typeof(TFlag))) { parser.AddAttribute(new FormattedAttribute <TFlag, bool>(flag, IsFlagSet(flags, flag))); } this.TypedValue = flags; return(this.Valid); }
public override bool Parse(QtParser parser) { if (!base.Parse(parser)) { return(false); } if (parser.BytesRemaining > 255) { Valid = false; string value = string.Format("{0} descriptor bytes found", parser.BytesRemaining); parser.AddAttribute(new FormattedAttribute <Attribute, string>(Attribute.Descriptor, value)); parser.GetDataPacket(parser.Position, (long)parser.BytesRemaining); parser.Position += (long)parser.BytesRemaining; } return(Valid); }
// 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); } 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); }
public override bool Parse(QtParser parser) { if (!base.Parse(parser)) { return(false); } byte version = parser.GetByte(Attribute.ConfigurationVersion); if (!CheckValue(version, 1)) { return(false); } parser.GetByte(Attribute.AvcProfileIndication); parser.GetByte(Attribute.ProfileCompatibility); parser.GetByte(Attribute.AvcLevelIndication); // bit(6) reserved = ‘111111’b; // unsigned int(2) lengthSizeMinusOne; byte lengthSizeMinusOne = parser.GetByte(); if (!CheckReservedBits(lengthSizeMinusOne, 0xFC)) { return(false); } lengthSizeMinusOne &= 0x03; parser.AddAttribute(new FormattedAttribute <Attribute, byte>(Attribute.LengthSizeMinusOne, lengthSizeMinusOne)); // bit(3) reserved = ‘111’b; // unsigned int(5) numOfSequenceParameterSets; byte numOfSequenceParameterSets = parser.GetByte(); if (((QtAtom)Parent).HeaderName == AtomName.AvcParameterSampleEntry) { if (!CheckValue(numOfSequenceParameterSets, 0)) { return(false); } parser.AddAttribute(new FormattedAttribute <Attribute, byte>(Attribute.NumOfSequenceParameterSets, numOfSequenceParameterSets)); } else { // Check the three msb //FIXME: if (!CheckReservedBits(numOfSequenceParameterSets, 0xE0)) return false; numOfSequenceParameterSets &= 0x1F; // remove the three msb parser.AddAttribute(new FormattedAttribute <Attribute, byte>(Attribute.NumOfSequenceParameterSets, numOfSequenceParameterSets)); } SequenceParameterSets = CreateNalUnit(parser, numOfSequenceParameterSets, Attribute.SequenceParameterSets); byte numOfPictureParameterSets = parser.GetByte(Attribute.NumOfPictureParameterSets); if (((QtAtom)Parent).HeaderName == AtomName.AvcParameterSampleEntry) { if (!CheckValue(numOfPictureParameterSets, 0)) { return(false); } } PictureParameterSets = CreateNalUnit(parser, numOfPictureParameterSets, Attribute.PictureParameterSets); return(Valid); }