public override void Read(BoxReader reader) { using (new SizeChecker(this, reader)) { base.Read(reader); if (Version == 1) { creationTime = reader.ReadUInt64(); modificationTime = reader.ReadUInt64(); TrackID = reader.ReadUInt32(); UInt32 reserved = reader.ReadUInt32(); // reserved = 0 Duration = reader.ReadUInt64(); } else { creationTime = (UInt32)reader.ReadUInt32(); modificationTime = (UInt32)reader.ReadUInt32(); TrackID = reader.ReadUInt32(); reader.ReadUInt32(); // reserved = 0 Duration = (UInt32)reader.ReadUInt32(); } for (int x = 0; x < 2; x++) { reader.ReadUInt32(); // int(32)[2] - reserved = 0 - 40 bytes } Layer = reader.ReadUInt16(); // layer = 0 AlternateGroup = reader.ReadUInt16(); // alternate_group = 0 _volume = reader.ReadUInt16(); reader.ReadUInt16(); // reserved = 0 - 48 bytes this.Matrix.Read(reader); _width = reader.ReadUInt32(); _height = reader.ReadUInt32(); } }
public override void Read(BoxReader reader) { using (new SizeChecker(this, reader)) { base.Read(reader); Balance = reader.ReadUInt16(); reader.ReadUInt16(); // reserved = 0 } }
public override void Read(BoxReader reader) { using (new SizeChecker(this, reader)) { base.Read(reader); GraphicsMode = reader.ReadUInt16(); OpColor[0] = reader.ReadUInt16(); OpColor[1] = reader.ReadUInt16(); OpColor[2] = reader.ReadUInt16(); } }
public override void Read(BoxReader reader) { using (new SizeChecker(this, reader)) { base.Read(reader); MaxPDUSize = reader.ReadUInt16(); AvgPDUSize = reader.ReadUInt16(); MaxBitrate = reader.ReadUInt16(); AvgBitrate = reader.ReadUInt16(); reader.ReadUInt16(); // reserved = 0 } }
public override void Read(BoxReader reader) { using (new SizeChecker(this, reader)) { base.Read(reader); if (Version == 1) { creationTime = reader.ReadUInt64(); modificationTime = reader.ReadUInt64(); TimeScale = reader.ReadUInt32(); Duration = reader.ReadUInt64(); } else { creationTime = (UInt64)reader.ReadUInt32(); modificationTime = (UInt64)reader.ReadUInt32(); TimeScale = reader.ReadUInt32(); Duration = (UInt64)reader.ReadUInt32(); } // Set rate 16.16. rate[0] = reader.ReadUInt16(); rate[1] = reader.ReadUInt16(); // Set _volume. reader.Read(volume, 0, 2); reader.ReadInt16(); // bit[16] - reserved = 0 for (int x = 0; x < 2; x++) { reader.ReadUInt32(); // bit(32)[2] - pre_defined = 0 } this.Matrix.Read(reader); for (int x = 0; x < 6; x++) { reader.ReadUInt32(); // bit(32)[6] - pre_defined = 0 } NextTrackID = reader.ReadUInt32(); } }
public override void Read(BoxReader reader) { using (new SizeChecker(this, reader)) { base.Read(reader); if (Version == 1) { creationTime = reader.ReadUInt64(); modificationTime = reader.ReadUInt64(); TimeScale = reader.ReadUInt32(); Duration = reader.ReadUInt64(); } else { creationTime = (UInt32)reader.ReadUInt32(); modificationTime = (UInt32)reader.ReadUInt32(); TimeScale = reader.ReadUInt32(); Duration = (UInt32)reader.ReadUInt32(); } language = reader.ReadUInt16(); reader.ReadUInt16(); // pre_defined = 0 } }
public override void Read(BoxReader reader) { base.Read(reader); reader.ReadBytes(6); // unsinged int(8)[6] reserved = 0 DataReferenceIndex = reader.ReadUInt16(); }
public void Read(BoxReader reader, byte version, uint LengthSizeOfTrafNum, uint LengthSizeOfTrunNum, uint LengthSizeOfSampleNum) { if (version == 1) { ulong tmpTime = reader.ReadUInt64(); // if (tmpTime < LastTime) BaseTime = LastTime; this.Time = BaseTime + tmpTime; this.MoofOffset = reader.ReadUInt64(); LastTime = Time; } else { this.Time = reader.ReadUInt32(); this.MoofOffset = reader.ReadUInt32(); } switch (((LengthSizeOfTrafNum + 1) * 8)) { case 0x18: this.TrafNumber = reader.ReadUInt24(); break; case 0x20: this.TrafNumber = reader.ReadUInt32(); break; case 8: this.TrafNumber = reader.ReadByte(); break; case 0x10: this.TrafNumber = reader.ReadUInt16(); break; } switch (((LengthSizeOfTrunNum + 1) * 8)) { case 0x18: this.TrunNumber = reader.ReadUInt24(); break; case 0x20: this.TrunNumber = reader.ReadUInt32(); break; case 8: this.TrunNumber = reader.ReadByte(); break; case 0x10: this.TrunNumber = reader.ReadUInt16(); break; } switch (((LengthSizeOfSampleNum + 1) * 8)) { case 8: this.SampleNumber = reader.ReadByte(); return; case 0x10: this.SampleNumber = reader.ReadUInt16(); break; case 0x18: this.SampleNumber = reader.ReadUInt24(); return; case 0x20: this.SampleNumber = reader.ReadUInt32(); return; } }
public override void Read(BoxReader reader) { using (new SizeChecker(this, reader)) { long pos = reader.BaseStream.Position; base.Read(reader); for (int i = 0; i < 2; i++) reader.ReadUInt32(); // unsigned int(32)[2] reserved = 0 ChannelCount = reader.ReadUInt16(); SampleSize = reader.ReadUInt16(); PreDefined = reader.ReadUInt16(); // unsigned int(16) pre_defined = 0 reader.ReadUInt16(); // unsigned int(16) reserved = 0 SampleRate = reader.ReadUInt32() >> 16; // read esds or avcc boxes BoxType bt = reader.PeekNextBoxType(); switch (bt.ToString().ToLower()) { case "esds": // AudioSampleEntry type is mp4a (denotes AAC encoding) case "avcc": PrivDataFullBox = new AnyPrivFullBox(bt, string.Empty); PrivDataFullBox.Read(reader); break; case "wfex": // AudioSampleEntry type is wma PrivDataBox = new AnyPrivBox(bt, string.Empty); PrivDataBox.Read(reader); break; case "damr": // 3gpp sound PrivDataFullBox = new AnyPrivFullBox(bt, string.Empty); PrivDataFullBox.Read(reader); break; default: throw new Exception(string.Format("AudioSampleEntry has unknown contents: {0}", bt.ToString())); } } }
public override void Read(BoxReader reader) { using (new SizeChecker(this, reader)) { base.Read(reader); predefined1 = reader.ReadByte(); // must be 01, configurationVersion profileIDC = reader.ReadByte(); // AVCProfileIndication constraintFlags = reader.ReadByte(); // profile_compatibility levelIDC = reader.ReadByte(); // AVCLevelIndication nalUnitLengthSizeByte = reader.ReadByte(); // first 6 bits are reserved and set to 1 nalUnitLengthSize = (byte)((nalUnitLengthSizeByte & 0x3) + 1); // lengthSizeMinusOne seqParamCountByte = reader.ReadByte(); // first 3 bits are reserved and set to 1 seqParamCount = (byte)(seqParamCountByte & 0x1F); // numOfSequenceParameterSets SPS = new SequenceParameterSet[seqParamCount]; for (int i = 0; i < seqParamCount; i++) { seqParamLength = reader.ReadUInt16(); seqParamSetData = new byte[seqParamLength]; reader.Read(seqParamSetData, 0, seqParamSetData.Length); SPS[i] = ParseSPS(seqParamSetData); } picParamCount = reader.ReadByte(); PPS = new PictureParameterSet[picParamCount]; for (int i = 0; i < picParamCount; i++) { picParamLength = reader.ReadUInt16(); picParamSetData = new byte[picParamLength]; reader.Read(picParamSetData, 0, picParamSetData.Length); PPS[i] = ParsePPS(picParamSetData); } } }
public override void Read(BoxReader reader) { using (new SizeChecker(this, reader)) { base.Read(reader); if (Version == 1) { creationTime = reader.ReadUInt64(); modificationTime = reader.ReadUInt64(); TrackID = reader.ReadUInt32(); UInt32 reserved = reader.ReadUInt32(); // reserved = 0 Duration = reader.ReadUInt64(); } else { creationTime = (UInt32)reader.ReadUInt32(); modificationTime = (UInt32)reader.ReadUInt32(); TrackID = reader.ReadUInt32(); reader.ReadUInt32(); // reserved = 0 Duration = (UInt32)reader.ReadUInt32(); } for (int x = 0; x < 2; x++) reader.ReadUInt32(); // int(32)[2] - reserved = 0 - 40 bytes Layer = reader.ReadUInt16(); // layer = 0 AlternateGroup = reader.ReadUInt16(); // alternate_group = 0 _volume = reader.ReadUInt16(); reader.ReadUInt16(); // reserved = 0 - 48 bytes this.Matrix.Read(reader); _width = reader.ReadUInt32(); _height = reader.ReadUInt32(); } }
public override void Read(BoxReader reader) { using (new SizeChecker(this, reader)) { long startpos = reader.BaseStream.Position; base.Read(reader); reader.ReadUInt16(); // pre_defined = 0; reader.ReadUInt16(); // reserved = 0; for (int i = 0; i < 3; i++) reader.ReadUInt32(); // unsigned int(32)[3] pre_defined = 0 Width = reader.ReadUInt16(); Height = reader.ReadUInt16(); HorizResolution = reader.ReadUInt32(); // = 0x0048000 = 72 dpi VertResolution = reader.ReadUInt32(); // = 0x0048000 = 72 dpi reader.ReadUInt32(); // reserved = 0 FrameCount = reader.ReadUInt16(); // frame_count = 1 // Compressor name has first 2 bytes which is the readable length, the rest are char's or null bytes CompressorName = ""; ushort len = reader.ReadUInt16(); // NOTE: Some encoders use only one byte for count of compressor name, so here // we test for whether the length is valid. If not valid, only the first byte is // used as the length. if (len > 30) { byte[] b = BitConverter.GetBytes(len); if (BitConverter.IsLittleEndian) { len = (ushort)b[1]; CompressorName += (char)b[0]; } else { len = (ushort)b[0]; CompressorName += (char)b[1]; } } for (int i=0; i<30; i++) { if (i < len) CompressorName += reader.ReadChar(); else reader.ReadChar(); } CompressorName = CompressorName.Trim().Replace("\0",""); Depth = reader.ReadUInt16(); // depth = 0x0018 reader.ReadUInt16(); // pre_defined = -1 bool bOptionalBoxFound = true; while (bOptionalBoxFound) { bOptionalBoxFound = false; long pos = reader.BaseStream.Position; Box test = new Box(BoxTypes.Any); test.Read(reader); reader.BaseStream.Position = pos; if (test.Type == BoxTypes.CleanApertureBox) { CleanApertureBox = new CleanApertureBox(); CleanApertureBox.Read(reader); bOptionalBoxFound = true; } else if (test.Type == BoxTypes.PixelAspectRatio) { PixelAspectRatioBox = new PixelAspectRatioBox(); PixelAspectRatioBox.Read(reader); bOptionalBoxFound = true; } else // retrieve CodecPrivateData from avcC if (test.Type == BoxTypes.AvcC) { AvcCBox = new AvcCBox(); AvcCBox.Read(reader); //if ((ulong) (reader.BaseStream.Position - pos) < this.Size) { // // klude to work around Expression problem (missing uuid, but box size large enough for it) // pos = reader.BaseStream.Position; // test = new Box(BoxTypes.Any); // test.Read(reader); // reader.BaseStream.Position = pos; // if (test.Type == BoxTypes.UUID) { // Uuid = new UuidBox(); // Uuid.Read(reader); // } //} bOptionalBoxFound = true; } else if (test.Type == BoxTypes.UUID) { Uuid = new UuidBox(); Uuid.Read(reader); } else if (test.Type == BoxTypes.Mp4v) { PrivDataFullBox = new AnyPrivFullBox(); PrivDataFullBox.Read(reader); bOptionalBoxFound = true; } else if (test.Type == BoxTypes.Vc1) { PrivDataBox = new AnyPrivBox(); PrivDataBox.Read(reader); bOptionalBoxFound = true; } } } }
public override void Read(BoxReader reader) { using (new SizeChecker(this, reader)) { base.Read(reader); if (Version == 1) { creationTime = reader.ReadUInt64(); modificationTime = reader.ReadUInt64(); TimeScale = reader.ReadUInt32(); Duration = reader.ReadUInt64(); } else { creationTime = (UInt64)reader.ReadUInt32(); modificationTime = (UInt64)reader.ReadUInt32(); TimeScale = reader.ReadUInt32(); Duration = (UInt64)reader.ReadUInt32(); } // Set rate 16.16. rate[0] = reader.ReadUInt16(); rate[1] = reader.ReadUInt16(); // Set _volume. reader.Read(volume, 0, 2); reader.ReadInt16(); // bit[16] - reserved = 0 for (int x = 0; x < 2; x++) reader.ReadUInt32(); // bit(32)[2] - pre_defined = 0 this.Matrix.Read(reader); for (int x = 0; x < 6; x++) reader.ReadUInt32(); // bit(32)[6] - pre_defined = 0 NextTrackID = reader.ReadUInt32(); } }