Esempio n. 1
0
        public Mp4AvccBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.AVCC)
        {
            long position = stream.Position;

            this.RawBytes = new byte[size];
            stream.Read(this.RawBytes, this.RawBytes.Length);
            stream.Seek(position);
            this.ConfigurationVersion  = stream.ReadUInt08();
            this.AVCProfileIndication  = stream.ReadUInt08();
            this.AVCCompatibleProfiles = stream.ReadUInt08();
            this.AVCLevelIndication    = stream.ReadUInt08();
            byte num2 = stream.ReadUInt08();

            this.NaluLengthSize = (byte)(1 + (num2 & 3));
            byte capacity = (byte)(stream.ReadUInt08() & 0x1f);

            this.SequenceParameters = new List <byte[]>(capacity);
            for (uint i = 0; i < capacity; i++)
            {
                byte[] buffer = new byte[stream.ReadUInt16()];
                stream.Read(buffer, buffer.Length);
                this.SequenceParameters.Add(buffer);
            }
            byte num6 = stream.ReadUInt08();

            this.PictureParameters = new List <byte[]>();
            for (uint j = 0; j < num6; j++)
            {
                byte[] buffer = new byte[stream.ReadUInt16()];
                stream.Read(buffer, buffer.Length);
                this.PictureParameters.Add(buffer);
            }
        }
Esempio n. 2
0
 public override void ReadFields(Mp4Stream stream)
 {
     base.ReadFields(stream);
     this.HintTrackVersion         = stream.ReadUInt16();
     this.HighestCompatibleVersion = stream.ReadUInt16();
     this.MaxPacketSize            = stream.ReadUInt32();
 }
Esempio n. 3
0
 public Mp4TkhdBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.TKHD, 0L, stream)
 {
     this.Reserved2 = new byte[8];
     this.Matrix    = new uint[9];
     if (base.Version == 0)
     {
         this.CreationTime     = stream.ReadUInt32();
         this.ModificationTime = stream.ReadUInt32();
         this.TrackId          = stream.ReadUInt32();
         this.Reserved1        = stream.ReadUInt32();
         this.Duration         = stream.ReadUInt32();
     }
     else
     {
         this.CreationTime     = stream.ReadUInt64();
         this.ModificationTime = stream.ReadUInt64();
         this.TrackId          = stream.ReadUInt32();
         this.Reserved1        = stream.ReadUInt32();
         this.Duration         = stream.ReadUInt64();
     }
     stream.Read(this.Reserved2, 8);
     this.Layer          = stream.ReadUInt16();
     this.AlternateGroup = stream.ReadUInt16();
     this.Volume         = stream.ReadUInt16();
     this.Reserved3      = stream.ReadUInt16();
     for (int i = 0; i < 9; i++)
     {
         this.Matrix[i] = stream.ReadUInt32();
     }
     this.Width  = stream.ReadUInt32();
     this.Height = stream.ReadUInt32();
 }
Esempio n. 4
0
 public Mp4HmhdBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.HMHD, 0L, stream)
 {
     this.MaxPduSize = stream.ReadUInt16();
     this.AvgPduSize = stream.ReadUInt16();
     this.MaxBitrate = stream.ReadUInt32();
     this.AvgBitrate = stream.ReadUInt32();
     this.Reserved   = stream.ReadUInt32();
 }
Esempio n. 5
0
 public Mp4VmhdBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.VMHD, 0L, stream)
 {
     this.OpColor      = new ushort[3];
     this.GraphicsMode = stream.ReadUInt16();
     this.OpColor[0]   = stream.ReadUInt16();
     this.OpColor[1]   = stream.ReadUInt16();
     this.OpColor[2]   = stream.ReadUInt16();
 }
Esempio n. 6
0
        public Mp4EsDescriptor(Mp4Stream stream, uint headerSize, uint payloadSize) : base(Mp4DescriptorTag.ES, headerSize, payloadSize)
        {
            Mp4Descriptor descriptor;
            long          position = stream.Position;

            this.EsId = stream.ReadUInt16();
            byte num2 = stream.ReadUInt08();

            this.Flags          = (uint)((num2 >> 5) & 7);
            this.StreamPriority = (byte)(num2 & 0x1f);
            if ((this.Flags & 1) != 0)
            {
                this.DependsOn = stream.ReadUInt16();
            }
            else
            {
                this.DependsOn = 0;
            }
            if ((this.Flags & 2) != 0)
            {
                byte count = stream.ReadUInt08();
                if (count != 0)
                {
                    byte[] buffer = new byte[count + 1];
                    stream.Read(buffer, count);
                    buffer[count] = 0;
                    this.Url      = Encoding.ASCII.GetString(buffer, 0, count);
                }
            }
            if ((this.Flags & 2) != 0)
            {
                this.OcrEsId = stream.ReadUInt16();
            }
            else
            {
                this.OcrEsId = 0;
            }
            long offset = stream.Position;

            this.SubDescriptors = new List <Mp4Descriptor>();
            Mp4DescriptorFactory factory = new Mp4DescriptorFactory();
            Mp4SubStream         stream2 = new Mp4SubStream(stream, offset, (long)(payloadSize - ((uint)(offset - position))));

            while ((descriptor = factory.Read(stream2)) != null)
            {
                this.SubDescriptors.Add(descriptor);
            }
        }
        public Mp4ObjectDescriptor(Mp4Stream stream, Mp4DescriptorTag tag, uint headerSize, uint payloadSize) : base(tag, headerSize, payloadSize)
        {
            Mp4Descriptor descriptor;
            long          position = stream.Position;
            ushort        num2     = stream.ReadUInt16();

            this.ObjectDescriptorId = (ushort)(num2 >> 6);
            this.UrlFlag            = (num2 & 0x20) != 0;
            if (this.UrlFlag)
            {
                byte   count  = stream.ReadUInt08();
                byte[] buffer = new byte[0x100];
                stream.Read(buffer, count);
                buffer[count] = 0;
                this.Url      = Encoding.ASCII.GetString(buffer, 0, count);
            }
            long offset = stream.Position;

            this.SubDescriptors = new List <Mp4Descriptor>();
            Mp4DescriptorFactory factory = new Mp4DescriptorFactory();
            Mp4SubStream         stream2 = new Mp4SubStream(stream, offset, (long)(payloadSize - ((uint)(offset - position))));

            while ((descriptor = factory.Read(stream2)) != null)
            {
                this.SubDescriptors.Add(descriptor);
            }
        }
Esempio n. 8
0
 public Mp4MvhdBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.MVHD, 0L, stream)
 {
     this.Reserved1  = new byte[2];
     this.Reserved2  = new byte[8];
     this.Matrix     = new uint[9];
     this.Predefined = new byte[0x18];
     if (base.Version == 0)
     {
         this.CreationTime     = stream.ReadUInt32();
         this.ModificationTime = stream.ReadUInt32();
         this.TimeScale        = stream.ReadUInt32();
         this.Duration         = stream.ReadUInt32();
     }
     else
     {
         this.CreationTime     = stream.ReadUInt64();
         this.ModificationTime = stream.ReadUInt64();
         this.TimeScale        = stream.ReadUInt32();
         this.Duration         = stream.ReadUInt64();
     }
     this.Rate   = stream.ReadUInt32();
     this.Volume = stream.ReadUInt16();
     stream.Read(this.Reserved1, this.Reserved1.Length);
     stream.Read(this.Reserved2, this.Reserved2.Length);
     for (int i = 0; i < 9; i++)
     {
         this.Matrix[i] = stream.ReadUInt32();
     }
     stream.Read(this.Predefined, this.Predefined.Length);
     this.NextTrackId = stream.ReadUInt32();
 }
 public override void ReadFields(Mp4Stream stream)
 {
     base.ReadFields(stream);
     this.QtVersion       = stream.ReadUInt16();
     this.QtRevision      = stream.ReadUInt16();
     this.QtVendor        = stream.ReadUInt32();
     this.ChannelCount    = stream.ReadUInt16();
     this.SampleSize      = stream.ReadUInt16();
     this.QtCompressionId = stream.ReadUInt16();
     this.QtPacketSize    = stream.ReadUInt16();
     this.SampleRate      = stream.ReadUInt32();
     if (this.QtVersion == 1)
     {
         this.QtV1SamplesPerPacket = stream.ReadUInt32();
         this.QtV1BytesPerPacket   = stream.ReadUInt32();
         this.QtV1BytesPerFrame    = stream.ReadUInt32();
         this.QtV1BytesPerSample   = stream.ReadUInt32();
     }
     else if (this.QtVersion == 2)
     {
         uint num2;
         uint num3;
         this.QtV2StructSize               = stream.ReadUInt32();
         this.QtV2SampleRate64             = stream.ReadDouble();
         this.QtV2ChannelCount             = stream.ReadUInt32();
         this.QtV2Reserved                 = stream.ReadUInt32();
         this.QtV2BitsPerChannel           = stream.ReadUInt32();
         this.QtV2FormatSpecificFlags      = stream.ReadUInt32();
         this.QtV2BytesPerAudioPacket      = stream.ReadUInt32();
         this.QtV2LPCMFramesPerAudioPacket = stream.ReadUInt32();
         if (this.QtV2StructSize > 0x48)
         {
             uint num = this.QtV2StructSize - 0x48;
             this.QtV2Extension = new byte[num];
             stream.Read(this.QtV2Extension, (int)num);
         }
         this.QtV1BytesPerSample   = num2 = 0;
         this.QtV1BytesPerFrame    = num3 = num2;
         this.QtV1SamplesPerPacket = this.QtV1BytesPerPacket = num3;
     }
     else
     {
         this.QtV1SamplesPerPacket         = 0;
         this.QtV1BytesPerPacket           = 0;
         this.QtV1BytesPerFrame            = 0;
         this.QtV1BytesPerSample           = 0;
         this.QtV2StructSize               = 0;
         this.QtV2SampleRate64             = 0.0;
         this.QtV2ChannelCount             = 0;
         this.QtV2Reserved                 = 0;
         this.QtV2BitsPerChannel           = 0;
         this.QtV2FormatSpecificFlags      = 0;
         this.QtV2BytesPerAudioPacket      = 0;
         this.QtV2LPCMFramesPerAudioPacket = 0;
     }
 }
Esempio n. 10
0
        public override void ReadFields(Mp4Stream stream)
        {
            base.ReadFields(stream);
            this.Predefined1 = stream.ReadUInt16();
            this.Reserved2   = stream.ReadUInt16();
            stream.Read(this.Predefined2, this.Predefined2.Length);
            this.Width           = stream.ReadUInt16();
            this.Height          = stream.ReadUInt16();
            this.HorizResolution = stream.ReadUInt32();
            this.VertResolution  = stream.ReadUInt32();
            this.Reserved3       = stream.ReadUInt32();
            this.FrameCount      = stream.ReadUInt16();
            byte[] buffer = new byte[0x20];
            stream.Read(buffer, 0x20);
            int count = buffer[0];

            if (count < 0x20)
            {
                this.CompressorName = Encoding.ASCII.GetString(buffer, 1, count);
            }
            this.Depth       = stream.ReadUInt16();
            this.Predefined3 = stream.ReadUInt16();
        }
Esempio n. 11
0
 public virtual void ReadFields(Mp4Stream stream)
 {
     stream.Read(this.Reserved, this.Reserved.Length);
     this.DataReferenceIndex = stream.ReadUInt16();
 }
Esempio n. 12
0
 public Mp4SmhdBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.SMHD, 0L, stream)
 {
     this.Balance  = stream.ReadInt16();
     this.Reserved = stream.ReadUInt16();
 }
Esempio n. 13
0
        public Mp4HvccBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.HVCC)
        {
            long position = stream.Position;

            this.RawBytes = new byte[size];
            stream.Read(this.RawBytes, this.RawBytes.Length);
            stream.Seek(position);
            this.ConfigurationVersion = stream.ReadUInt08();
            byte temp = stream.ReadUInt08();

            GeneralProfileSpace = ((byte)(temp & 0xc0)) >> 6;
            GeneralTierFlag     = ((byte)(temp & 0x20)) >> 5;
            GeneralProfileIdc   = (byte)(temp & 0x1f);
            GeneralProfileCompatibilityFlags = stream.ReadUInt32();
            GeneralConstraintIndicatorFlags  = (ulong)(stream.ReadUInt32()) << 16;
            GeneralConstraintIndicatorFlags += stream.ReadUInt16();
            //GeneralConstraintIndicatorFlags |= (ulong)stream.ReadInt16();
            GeneralLevelIdc           = stream.ReadUInt08();
            MinSpatialSegmentationIdc = (uint)(stream.ReadUInt16() & 0xff);
            ParallelismType           = (byte)(stream.ReadUInt08() & 0x3);
            ChromaFormat         = (byte)(stream.ReadUInt08() & 0x3);
            BitDepthLumaMinus8   = (byte)(stream.ReadUInt08() & 0x7);
            BitDepthChromaMinus8 = (byte)(stream.ReadUInt08() & 0x7);
            avgFrameRate         = stream.ReadUInt16();
            temp = stream.ReadUInt08();
            constantFrameRate  = ((byte)(temp & 0xc0)) >> 6;
            numTemporalLayers  = ((byte)(temp & 0x38)) >> 3;
            temporalIdNested   = (byte)(temp & 0x4) >> 2;
            lengthSizeMinusOne = (byte)(temp & 0x3);
            numOfArrays        = stream.ReadUInt08();
            for (var i = 0; i < numOfArrays; i++)
            {
                byte ArrayCompleteness, NALUType;
                temp = stream.ReadUInt08();
                ArrayCompleteness = (byte)(temp & 0x80);
                NALUType          = (byte)(temp & 0x3f);
                var NumNALUs = stream.ReadUInt16();
                if (NALUType == 0x20)
                {
                    VideoParameters = new List <byte[]>(NumNALUs);
                    for (var j = 0; j < NumNALUs; j++)
                    {
                        var    NALULength = stream.ReadUInt16();
                        byte[] buffer     = new byte[NALULength];
                        stream.Read(buffer, buffer.Length);
                        VideoParameters.Add(buffer);
                    }
                }
                else if (NALUType == 0x21)
                {
                    SequenceParameters = new List <byte[]>(NumNALUs);
                    for (var j = 0; j < NumNALUs; j++)
                    {
                        var    NALULength = stream.ReadUInt16();
                        byte[] buffer     = new byte[NALULength];
                        stream.Read(buffer, buffer.Length);
                        SequenceParameters.Add(buffer);
                    }
                }
                else if (NALUType == 0x22)
                {
                    PictureParameters = new List <byte[]>(NumNALUs);
                    for (var j = 0; j < NumNALUs; j++)
                    {
                        var    NALULength = stream.ReadUInt16();
                        byte[] buffer     = new byte[NALULength];
                        stream.Read(buffer, buffer.Length);
                        PictureParameters.Add(buffer);
                    }
                }
            }
        }
Esempio n. 14
0
        public Mp4TfraBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.TFRA, 0L, stream)
        {
            this.TrackId = stream.ReadUInt32();
            uint num = stream.ReadUInt32();

            this.Reserved              = ((int)(num >> 6)) & 0x3ffffff;
            this.LengthSizeOfTrafNum   = (byte)((num >> 4) & 3);
            this.LengthSizeOfTrunNum   = (byte)((num >> 2) & 3);
            this.LengthSizeOfSampleNum = (byte)(num & 3);
            uint num2 = stream.ReadUInt32();

            this.Entries = new List <Mp4TfraEntry>();
            for (int i = 0; i < num2; i++)
            {
                Mp4TfraEntry item = new Mp4TfraEntry();
                if (base.Version == 1)
                {
                    item.Time       = stream.ReadUInt64();
                    item.MoofOffset = stream.ReadUInt64();
                }
                else
                {
                    item.Time       = stream.ReadUInt32();
                    item.MoofOffset = stream.ReadUInt32();
                }
                switch (this.LengthSizeOfTrafNum)
                {
                case 0:
                    item.TrafNumber = stream.ReadUInt08();
                    break;

                case 1:
                    item.TrafNumber = stream.ReadUInt16();
                    break;

                case 2:
                    item.TrafNumber = stream.ReadUInt24();
                    break;

                case 3:
                    item.TrafNumber = stream.ReadUInt32();
                    break;
                }
                switch (this.LengthSizeOfTrunNum)
                {
                case 0:
                    item.TrunNumber = stream.ReadUInt08();
                    break;

                case 1:
                    item.TrunNumber = stream.ReadUInt16();
                    break;

                case 2:
                    item.TrunNumber = stream.ReadUInt24();
                    break;

                case 3:
                    item.TrunNumber = stream.ReadUInt32();
                    break;
                }
                switch (this.LengthSizeOfSampleNum)
                {
                case 0:
                    item.SampleNumber = stream.ReadUInt08();
                    break;

                case 1:
                    item.SampleNumber = stream.ReadUInt16();
                    break;

                case 2:
                    item.SampleNumber = stream.ReadUInt24();
                    break;

                case 3:
                    item.SampleNumber = stream.ReadUInt32();
                    break;
                }
                this.Entries.Add(item);
            }
        }