コード例 #1
0
ファイル: MXFLocalTag.cs プロジェクト: terra111/MXFInspect
 /// <summary>
 /// Parse this tag
 /// </summary>
 /// <param name="reader"></param>
 public void Parse(MXFReader reader)
 {
     if (this.Size == 1)
     {
         this.Value = reader.ReadB();
     }
     else if (this.Size == 2)
     {
         this.Value = reader.ReadW();
     }
     else if (this.Size == 4)
     {
         this.Value = reader.ReadD();
     }
     else if (this.Size == 8)
     {
         this.Value = reader.ReadL();
     }
     else
     {
         byte[] data = new byte[this.Size];
         for (int n = 0; n < this.Size; n++)
         {
             data[n] = reader.ReadB();
         }
         this.Value = data;
     }
 }
コード例 #2
0
ファイル: MXFKLV.cs プロジェクト: terra111/MXFInspect
        /// <summary>
        /// Validate if the current position is a valid SMPTE key
        /// </summary>
        private MXFKey CreateAndValidateKey(MXFReader reader)
        {
            byte iso = reader.ReadB();
            byte len = reader.ReadB();
            byte smp = 0, te = 0;
            bool valid = false;

            if (iso == 0x06)              // Do not check length when not iso
            {
                smp   = reader.ReadB();
                te    = reader.ReadB();
                valid = (smp == 0x2B && te == 0x34);                 // SMPTE define
            }
            if (!valid)
            {
                //throw new ApplicationException(string.Format("Invalid SMPTE Key found at offset {0}! Incorrect MXF file!", reader.Position - 4));
                MXFKey key = new MXFKey(iso, len, smp, te, reader);
                LogError("Invalid SMPTE Key found at offset {0}! Key: {1}", reader.Position - 4, key.Name);
                return(key);
            }
            else
            {
                return(new MXFKey(iso, len, smp, te, reader));
            }
        }
コード例 #3
0
ファイル: MXFANCPacket.cs プロジェクト: terra111/MXFInspect
        public MXFANCPacket(MXFReader reader)
            : base(reader)
        {
            this.LineNumber            = reader.ReadW();
            this.WrappingType          = (MXFANCWrappingType)reader.ReadB();
            this.PayloadSamplingCoding = (MXFANCPayloadCoding)reader.ReadB();
            this.PayloadSampleCount    = reader.ReadW();

            this.Length = this.PayloadSampleCount;
            if (this.PayloadSamplingCoding == MXFANCPayloadCoding.Coding_10_bit_luma_samples ||
                this.PayloadSamplingCoding == MXFANCPayloadCoding.Coding_10_bit_color_difference_samples ||
                this.PayloadSamplingCoding == MXFANCPayloadCoding.Coding_10_bit_luma_and_color_difference_samples)
            {
                this.Length = 4 * (this.PayloadSampleCount / 3);                 // 3 samples are stored in 4 bytes
            }

            // Skip 8 bytes (seems to be data but cannot find any meaning in the spec!)
            UInt32 unknownData1 = reader.ReadD();
            UInt32 unknownData2 = reader.ReadD();

            // Length Alignment
            this.Length = 4 * ((this.Length + 3) / 4);

            if (this.Length > 3)
            {
                // Read the DID
                this.DID  = reader.ReadB();
                this.SDID = reader.ReadB();
                this.Size = reader.ReadB();

                UInt16 combinedID = (UInt16)((((UInt16)this.DID) << 8) | this.SDID);
                if (m_DIDDescription.ContainsKey(combinedID))
                {
                    this.ContentDescription = m_DIDDescription[combinedID];
                }
                else
                {
                    this.ContentDescription = "<unknown content>";
                }

                switch (combinedID)
                {
                case 0x6101:                         // CDP
                    this.AddChild(new MXFCDPPacket(reader));
                    break;

                case 0x4105:                         // AFD
                    break;

                case 0x4302:                         // OP47
                    break;

                default:
                    // Read the real payload without the did/sdid/size
                    this.Payload = new byte[this.Length - 3];
                    reader.Read(this.Payload, this.Length - 3);
                    break;
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x3D0D: this.Emphasis = reader.ReadB(); return(true);

            case 0x3D0F: this.BlockStartOffset = reader.ReadW(); return(true);

            case 0x3D08: this.AuxiliaryBitsMode = reader.ReadB(); return(true);

            case 0x3D10:
                this.ChannelStatusMode = new byte[localTag.Size];
                reader.Read(this.ChannelStatusMode, localTag.Size);
                return(true);

            case 0x3D11:
                this.FixedChannelStatusData = new byte[localTag.Size];
                reader.Read(this.FixedChannelStatusData, localTag.Size);
                return(true);

            case 0x3D12:
                this.UserDataMode = new byte[localTag.Size];
                reader.Read(this.UserDataMode, localTag.Size);
                return(true);

            case 0x3D13:
                this.FixedUserData = new byte[localTag.Size];
                reader.Read(this.FixedUserData, localTag.Size);
                return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #5
0
ファイル: MXFSystemItem.cs プロジェクト: terra111/MXFInspect
        public MXFSystemItem(MXFReader reader, MXFKLV headerKLV)
            : base(headerKLV, "SystemItem (CP)", KeyType.SystemItem)
        {
            this.m_eType = MXFObjectType.SystemItem;
            if (this.Key[12] == 0x14)
            {
                this.Key.Name = "SystemItem (GC)";
            }

            reader.Seek(this.DataOffset);             // Seek to the start of the data

            // Parse system bitmap
            this.SystemBitmap = (SystemBitmap)reader.ReadB();

            // Parse Content package rate
            byte rate      = reader.ReadB();
            int  rateIndex = (rate & 0x1E) >> 1;

            int[] rates = new int[16] {
                0, 24, 25, 30, 48, 50, 60, 72, 75, 90, 96, 100, 120, 0, 0, 0
            };
            int rateNonDrop = 1;

            if (rateIndex < 16)
            {
                rateNonDrop = rates[rateIndex];
            }
            this.PackageRate = rateNonDrop;
            if ((rate & 0x01) == 0x01)             // 1.001 divider active?
            {
                this.PackageRate = this.PackageRate / 1.001;
            }


            // Parse Content Package Type
            byte type = reader.ReadB();

            this.StreamStatus   = (SystemStreamStatus)((type & 0xE0) >> 5);
            this.LowLatencyMode = ((type & 0x10) == 0x10);
            this.TransferMode   = (SystemTransferMode)((type & 0x0C) >> 2);
            this.TimingMode     = (SystemTimingMode)(type & 0x03);

            this.ChannelHandle   = reader.ReadW();
            this.ContinuityCount = reader.ReadW();

            this.SMPTE = new MXFRefKey(reader, 16, "SMPTE");             // Always read even if zero

            MXFTimeStamp creationTimeStamp = reader.ReadBCDTimeCode(this.PackageRate);

            this.CreationDate = creationTimeStamp.ToString();

            this.UserDate            = reader.ReadBCDTimeCode(this.PackageRate);
            this.UserDateFullFrameNb = this.UserDate.GetString(true);
        }
コード例 #6
0
        /// <summary>
        /// Create a new key by reading from the current file location
        /// </summary>
        /// <param name="firstPart"></param>
        /// <param name="reader"></param>
        public MXFKey(MXFReader reader)
        {
            byte isoMark = reader.ReadB();
            byte length  = reader.ReadB();

            this.m_mxfKey = new byte[length];
            for (int n = 2; n < length; n++)
            {
                m_mxfKey[n] = reader.ReadB();
            }

            FindKeyName();
        }
コード例 #7
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x3D0A: this.BlockAlign = reader.ReadW(); return(true);

            case 0x3D0B: this.SequenceOffset = reader.ReadB(); return(true);

            case 0x3D09: this.AveragesBytesPerSecond = reader.ReadD(); return(true);

            case 0x3D32: this.ChannelAssignment = reader.ReadKey(); return(true);

            case 0x3D29: this.PeakEnvelopeVersion = reader.ReadD(); return(true);

            case 0x3D2A: this.PeakEnvelopeFormat = reader.ReadD(); return(true);

            case 0x3D2B: this.PointsPerPeakValue = reader.ReadD(); return(true);

            case 0x3D2C: this.PeakEnvelopeBlockSize = reader.ReadD(); return(true);

            case 0x3D2D: this.PeakChannels = reader.ReadD(); return(true);

            case 0x3D2E: this.PeakFrames = reader.ReadD(); return(true);

            case 0x3D2F: this.PeakOfPeaksPosition = reader.ReadL(); return(true);

            case 0x3D30: this.PeakEnvelopeTimestamp = reader.ReadTimestamp(); return(true);

            case 0x3D31:
                this.PeakEnvelopeData = new byte[localTag.Size];
                reader.Read(this.PeakEnvelopeData, localTag.Size);
                return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #8
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x3301: this.ComponentDepth = reader.ReadD(); return(true);

            case 0x3302: this.HorizontalSubsampling = reader.ReadD(); return(true);

            case 0x3308: this.VerticalSubsampling = reader.ReadD(); return(true);

            case 0x3303: this.ColorSiting = reader.ReadB(); return(true);

            case 0x330B: this.ReversedByteOrder = reader.ReadBool(); return(true);

            case 0x3307: this.PaddingBits = (Int16)reader.ReadW(); return(true);

            case 0x3309: this.AlphaSampleDepth = reader.ReadD(); return(true);

            case 0x3304: this.BlackRefLevel = reader.ReadD(); return(true);

            case 0x3305: this.WhiteRefLevel = reader.ReadD(); return(true);

            case 0x3306: this.ColorRange = reader.ReadD(); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #9
0
        public MXFEntryIndex(UInt64 index, MXFReader reader, byte?sliceCount, byte?posTableCount, UInt32 length)
            : base(reader)
        {
            this.m_eType = MXFObjectType.Index;

            this.Length         = length;
            this.Index          = index;
            this.TemporalOffset = reader.ReadsB();
            this.KeyFrameOffset = reader.ReadsB();
            this.Flags          = reader.ReadB();
            this.StreamOffset   = reader.ReadL();

            if (sliceCount.HasValue && sliceCount.Value > 0)
            {
                this.SliceOffsets = new UInt32[sliceCount.Value];
                for (int n = 0; n < sliceCount; n++)
                {
                    this.SliceOffsets[n] = reader.ReadD();
                }
            }

            if (posTableCount.HasValue && posTableCount.Value > 0)
            {
                this.PosTable = new MXFRational[posTableCount.Value];
                for (int n = 0; n < posTableCount; n++)
                {
                    this.PosTable[n] = reader.ReadRational();
                }
            }
        }
コード例 #10
0
ファイル: MXFCDPFuture.cs プロジェクト: terra111/MXFInspect
 public MXFCDPFuture(MXFReader reader, byte sectionID)
     : base(reader)
 {
     this.SectionID = sectionID;
     this.Length    = reader.ReadB();
     this.Data      = new byte[this.Length];
     reader.Read(this.Data, this.Length);
 }
コード例 #11
0
        /// <summary>
        /// Create a new key by reading from the current file location with a fixed size
        /// </summary>
        /// <param name="firstPart"></param>
        /// <param name="reader"></param>
        public MXFKey(MXFReader reader, UInt32 length)
        {
            this.m_mxfKey = new byte[length];
            for (int n = 0; n < length; n++)
            {
                m_mxfKey[n] = reader.ReadB();
            }

            FindKeyName();
        }
コード例 #12
0
ファイル: MXFEntryDelta.cs プロジェクト: terra111/MXFInspect
        public MXFEntryDelta(MXFReader reader, UInt32 length)
            : base(reader)
        {
            this.m_eType = MXFObjectType.Index;

            this.Length        = length;
            this.PosTableIndex = reader.ReadsB();
            this.Slice         = reader.ReadB();
            this.ElementDelta  = reader.ReadD();
        }
コード例 #13
0
        public MXFEntryCCData(MXFReader reader)
            : base(reader)
        {
            this.Length = 3;             // Fixed
            byte b0 = reader.ReadB();

            if ((b0 & 0xF8) == 0xF8)             // Valid marker bits?
            {
                this.Valid   = ((b0 & 0x04) != 0);
                this.CCType  = (CCDataType)(b0 & 0x03);
                this.Data    = new byte[2];
                this.Data[0] = reader.ReadB();
                this.Data[1] = reader.ReadB();
            }

            // When this object is not valid, set the type to filler
            if (this.Valid.HasValue && !this.Valid.Value)
            {
                this.m_eType = MXFObjectType.Filler;
            }
        }
コード例 #14
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x1501: this.StartTimecode = reader.ReadL(); return(true);

            case 0x1502: this.RoundedTimecodeBase = reader.ReadW(); return(true);

            case 0x1503: this.DropFrame = (reader.ReadB() != 0); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #15
0
ファイル: MXFKLV.cs プロジェクト: terra111/MXFInspect
        /// <summary>
        /// Decode the length
        /// </summary>
        /// <param name="reader"></param>
        private long DecodeBerLength(MXFReader reader)
        {
            long size = reader.ReadB();

            if ((size & 0x80) != 0)
            {
                // long form
                int bytes_num = (int)(size & 0x7F);
                // SMPTE 379M 5.3.4 guarantee that bytes_num must not exceed 8 bytes
                if (bytes_num > 8)
                {
                    //throw new ArgumentException("KLV length more then 8 bytes!");
                    LogWarning("KLV length more then 8 bytes (not valid according to SMPTE 379M 5.3.4) found at offset {0}!", reader.Position);
                }
                size = 0;
                while ((bytes_num--) != 0)
                {
                    size = size << 8 | reader.ReadB();
                }
            }
            return(size);
        }
コード例 #16
0
        /// <summary>
        /// Parse a SMNTE12M timecode
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="frameRate"></param>
        public void ParseSMPTE12M(MXFReader reader, double frameRate)
        {
            byte hoursb   = reader.ReadB();
            byte minutesb = reader.ReadB();
            byte secondsb = reader.ReadB();
            byte framesb  = reader.ReadB();

            this.Hour   = ParseBCD(hoursb, 0x30);
            this.Minute = ParseBCD(minutesb, 0x70);
            this.Second = ParseBCD(secondsb, 0x70);
            this.Frame  = ParseBCD(framesb, 0x30);

            this.FrameRate = frameRate;

            this.Field     = (byte)(((secondsb & 0x80) != 0) ? 1 : 0);
            this.DropFrame = ((framesb & 0x80) != 0);
            this.HasFields = false;

            if (frameRate >= 49.0)
            {
                this.FullFrame = (byte)(this.Frame * 2 + this.Field);
                this.HasFields = true;
            }
        }
コード例 #17
0
        public MXFPackageMetaData(MXFReader reader, MXFKLV headerKLV)
            : base(headerKLV, "PackageMetadata", KeyType.PackageMetaDataSet)
        {
            this.m_eType = MXFObjectType.Essence;             // I will count this as essence data
            if (this.Key[5] == 0x63)
            {
                nofSizeSize = 4;
            }
            switch (this.Key[14])
            {
            case 0x02: this.Key.Name = "Package Metadata set"; break;

            case 0x03: this.Key.Name = "Picture Metadata set"; break;

            case 0x04: this.Key.Name = "Sound Metadata set"; break;

            case 0x05: this.Key.Name = "Data Metadata set"; break;

            case 0x06: this.Key.Name = "Control Metadata set"; break;
            }


            reader.Seek(this.DataOffset);              // Seek to the start of the data

            long end = this.DataOffset + this.Length;

            while (reader.Position < end)
            {
                byte   type = reader.ReadB();
                UInt32 size = 0;
                if (nofSizeSize == 2)
                {
                    size = reader.ReadW();
                }
                else
                {
                    size = reader.ReadD();
                }
                long startPos = reader.Position;
                if (m_itemTypes.ContainsKey(type))
                {
                    this.AddChild(new MXFData(m_itemTypes[type], reader, size));
                }
                reader.Seek(startPos + size);
            }
        }
コード例 #18
0
        public MXFEntrySVCInfo(MXFReader reader)
            : base(reader)
        {
            this.Length = 7;             // Fixed

            byte b0 = reader.ReadB();

            if ((b0 & 0x40) != 0)
            {
                this.CaptionServiceNumber = (byte)(b0 & 0x1F);
            }
            else
            {
                this.CaptionServiceNumber = (byte)(b0 & 0x3F);
            }

            this.Data = new byte[6];
            reader.Read(this.Data, 6);

            this.DataString = System.Text.Encoding.ASCII.GetString(this.Data);
        }
コード例 #19
0
        /// <summary>
        /// Create a new key combining 2 parts, first should be 4 bytes
        /// </summary>
        /// <param name="firstPart"></param>
        /// <param name="reader"></param>
        public MXFKey(byte b0, byte b1, byte b2, byte b3, MXFReader reader)
        {
            this.m_mxfKey = null;
            int len = b1 + 2;

            if (len >= 4)
            {
                this.m_mxfKey    = new byte[len];
                this.m_mxfKey[0] = b0;
                this.m_mxfKey[1] = b1;
                this.m_mxfKey[2] = b2;
                this.m_mxfKey[3] = b3;

                for (int n = 4; n < len; n++)
                {
                    m_mxfKey[n] = reader.ReadB();
                }
            }

            FindKeyName();
        }
コード例 #20
0
        /// <summary>
        /// Parse a BCD timecode from the reader
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="frameRateNonDrop"></param>
        public void ParseBCDTimeCode(MXFReader reader, double frameRate)
        {
            byte frameb  = reader.ReadB();
            byte secondb = reader.ReadB();
            byte minuteb = reader.ReadB();
            byte hourb   = reader.ReadB();

            bool colorFlag = (frameb & 0x80) == 0x80;
            bool dropFlag  = (frameb & 0x40) == 0x40;

            this.Frame = ParseBCD(frameb, 0x30);

            this.FrameRate = frameRate;

            // When the rate is greater then 30 fps, use the toggle
            if (frameRate >= 59)
            {
                this.Field     = (byte)(((secondb & 0x80) == 0x80) ? 1 : 0);
                this.FullFrame = (byte)((this.Frame * 2) + this.Field);
                this.HasFields = true;
            }
            else if (frameRate >= 49)
            {
                this.Field     = (byte)(((hourb & 0x80) == 0x80) ? 1 : 0);
                this.FullFrame = (byte)((this.Frame * 2) + this.Field);
                this.HasFields = true;
            }
            else
            {
                this.FullFrame = this.Frame;
                this.HasFields = false;
            }

            this.Second = ParseBCD(secondb, 0x70);
            this.Minute = ParseBCD(minuteb, 0x70);
            this.Hour   = ParseBCD(hourb, 0x30);

            // Read the other bytes
            this.Day   = ParseBCD(reader.ReadB(), 0x30);           // Binary group data BG1 + BG2
            this.Month = ParseBCD(reader.ReadB(), 0x10);           // Binary group data BG3 + BG4
            this.Year  = ParseBCD(reader.ReadB(), 0xF0);           // Binary group data BG5 + BG6
        }
コード例 #21
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x3D03: this.AudioSamplingRate = reader.ReadRational(); return(true);

            case 0x3D02: this.Locked = reader.ReadBool(); return(true);

            case 0x3D04: this.AudioRefLevel = reader.ReadsB(); return(true);

            case 0x3D05: this.ElectroSpatialFormulation = reader.ReadB(); return(true);

            case 0x3D07: this.ChannelCount = reader.ReadD(); return(true);

            case 0x3D01: this.QuantizationBits = reader.ReadD(); return(true);

            case 0x3D0C: this.DialNorm = reader.ReadsB(); return(true);

            case 0x3D06: this.SoundEssenceCoding = reader.ReadKey(); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #22
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x3406: this.ComponentMaxRef = reader.ReadD(); return(true);

            case 0x3407: this.ComponentMinRef = reader.ReadD(); return(true);

            case 0x3408: this.AlphaMaxRef = reader.ReadD(); return(true);

            case 0x3409: this.AlphaMinRef = reader.ReadD(); return(true);

            case 0x3405: this.ScanningDirection = reader.ReadB(); return(true);

            case 0x3401: this.PixelLayout = reader.ReadW(); return(true);

            case 0x3403: this.Palette = reader.ReadS(localTag.Size); return(true);                    // TODO

            case 0x3404: this.PaletteLayout = reader.ReadS(localTag.Size); return(true);              // TODO
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #23
0
ファイル: MXFData.cs プロジェクト: terra111/MXFInspect
        /// <summary>
        ///Default constructor
        /// </summary>
        /// <param name="reader"></param>
        public MXFData(string name, MXFReader reader, UInt32 size)
            : base(reader)
        {
            this.Size = size;
            this.Name = name;
            this.Data = new byte[size];
            for (int n = 0; n < size; n++)
            {
                this.Data[n] = reader.ReadB();
            }

            StringBuilder sb = new StringBuilder();

            for (int n = 0; n < this.Data.Length; n++)
            {
                if (n > 0)
                {
                    sb.Append(", ");
                }
                sb.Append(string.Format("{0:X02}", this.Data[n]));
            }
            this.DataString = sb.ToString();
        }
コード例 #24
0
 public MXFCDPFooter(MXFReader reader)
     : base(reader)
 {
     this.SequenceCounter = reader.ReadW();
     this.PacketChecksum  = reader.ReadB();
 }
コード例 #25
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x3F05: this.EditUnitByteCount = reader.ReadD(); return(true);

            case 0x3F06: this.IndexSID = reader.ReadD(); return(true);

            case 0x3F07: this.BodySID = reader.ReadD(); return(true);

            case 0x3F08: this.SliceCount = reader.ReadB(); return(true);

            case 0x3F0C: this.IndexStartPosition = reader.ReadL(); return(true);

            case 0x3F0D: this.IndexDuration = reader.ReadL(); return(true);

            case 0x3F0E: this.PosTableCount = reader.ReadB(); return(true);

            case 0x3F0F: this.ExtStartOffset = reader.ReadL(); return(true);

            case 0x3F10: this.VBEByteCount = reader.ReadL(); return(true);

            case 0x3F0B: this.IndexEditRate = reader.ReadRational(); return(true);

            case 0x3F0A:                      // Index entry array
            {
                UInt32 NbIndexEntries = reader.ReadD();
                UInt32 entryLength    = reader.ReadD();
                if (NbIndexEntries > 0)
                {
                    this.IndexEntries = new List <MXFEntryIndex>();
                    MXFObject indexCollection = new MXFNamedObject("IndexEntries", reader.Position, MXFObjectType.Index);

                    for (UInt64 i = 0; i < NbIndexEntries; i++)
                    {
                        long next = reader.Position + entryLength;

                        MXFEntryIndex newEntry = new MXFEntryIndex((ulong)this.IndexStartPosition + i, reader, this.SliceCount, this.PosTableCount, entryLength);
                        this.IndexEntries.Add(newEntry);                                         // Also add this entry to the local list

                        // And to the child collection
                        indexCollection.AddChild(newEntry);

                        reader.Seek(next);
                    }
                    this.AddChild(indexCollection);
                }
            }
                return(true);

            case 0x3F09:                      // Delta entry array
            {
                UInt32 NbDeltaEntries = reader.ReadD();
                UInt32 entryLength    = reader.ReadD();
                if (NbDeltaEntries > 0)
                {
                    MXFObject deltaCollection = new MXFNamedObject("DeltaEntries", reader.Position, MXFObjectType.Index);
                    for (int i = 0; i < NbDeltaEntries; i++)
                    {
                        long next = reader.Position + entryLength;
                        deltaCollection.AddChild(new MXFEntryDelta(reader, entryLength));
                        reader.Seek(next);
                    }
                    this.AddChild(deltaCollection);
                }
            }
                return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #26
0
ファイル: MXFCDPPacket.cs プロジェクト: terra111/MXFInspect
        public MXFCDPPacket(MXFReader reader)
            : base(reader)
        {
            UInt16 identifier = reader.ReadW();

            if (identifier == 0x9669)
            {
                this.Length     = reader.ReadB();
                this.FrameRateE = (MXFCDFFrameRate)((reader.ReadB() & 0xF0) >> 4);

                switch (this.FrameRateE)
                {
                case MXFCDFFrameRate.Rate_24: this.FrameRate = 24; break;

                case MXFCDFFrameRate.Rate_24000_1001: this.FrameRate = 24000.0 / 1001.0; break;

                case MXFCDFFrameRate.Rate_25: this.FrameRate = 25; break;

                case MXFCDFFrameRate.Rate_30: this.FrameRate = 30; break;

                case MXFCDFFrameRate.Rate_30000_1001: this.FrameRate = 30000.0 / 1001.0; break;

                case MXFCDFFrameRate.Rate_50: this.FrameRate = 50; break;

                case MXFCDFFrameRate.Rate_60: this.FrameRate = 60; break;

                case MXFCDFFrameRate.Rate_60000_1001: this.FrameRate = 60000.0 / 1001.0; break;
                }

                byte options = reader.ReadB();
                this.TimeCodePresent      = ((options & 0x80) != 0);
                this.CCDataPresent        = ((options & 0x40) != 0);
                this.SVCInfoPresent       = ((options & 0x20) != 0);
                this.SVCInfoStart         = ((options & 0x10) != 0);
                this.SVCInfoChange        = ((options & 0x08) != 0);
                this.SVCInfoComplete      = ((options & 0x04) != 0);
                this.CaptionServiceActive = ((options & 0x02) != 0);
                this.SequenceCounter      = reader.ReadW();

                byte count  = 0;
                long endPos = this.Offset + this.Length;
                while (reader.Position < endPos)
                {
                    identifier = reader.ReadB();
                    switch (identifier)
                    {
                    case 0x71:
                        this.TimeCode = new MXFTimeStamp();
                        this.TimeCode.ParseSMPTE12M(reader, this.FrameRate.Value);
                        break;

                    case 0x72:
                        count = (byte)(reader.ReadB() & 0x1F);
                        for (int n = 0; n < count; n++)
                        {
                            this.AddChild(new MXFEntryCCData(reader));
                        }
                        break;

                    case 0x73:
                        count = (byte)(reader.ReadB() & 0x0F);
                        for (int n = 0; n < count; n++)
                        {
                            this.AddChild(new MXFEntrySVCInfo(reader));
                        }
                        break;

                    case 0x74:
                        this.AddChild(new MXFCDPFooter(reader));
                        break;

                    default:
                        this.AddChild(new MXFCDPFuture(reader, (byte)identifier));
                        break;
                    }
                }
            }
        }
コード例 #27
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x3215: this.SignalStandard = reader.ReadB(); return(true);

            case 0x320C: this.FrameLayout = reader.ReadB(); return(true);

            case 0x3203: this.StoredWidth = reader.ReadD(); return(true);

            case 0x3202: this.StoredHeight = reader.ReadD(); return(true);

            case 0x3216: this.StoredF2Offset = (Int32)reader.ReadD(); return(true);

            case 0x3205: this.SampledWidth = reader.ReadD(); return(true);

            case 0x3204: this.SampledHeight = reader.ReadD(); return(true);

            case 0x3206: this.SampledXOffset = (Int32)reader.ReadD(); return(true);

            case 0x3207: this.SampledYOffset = (Int32)reader.ReadD(); return(true);

            case 0x3208: this.DisplayHeight = reader.ReadD(); return(true);

            case 0x3209: this.DisplayWidth = reader.ReadD(); return(true);

            case 0x320A: this.DisplayXOffset = (Int32)reader.ReadD(); return(true);

            case 0x320B: this.DisplayYOffset = (Int32)reader.ReadD(); return(true);

            case 0x3217: this.DisplayF2Offset = (Int32)reader.ReadD(); return(true);

            case 0x320E: this.AspectRatio = reader.ReadRational(); return(true);

            case 0x3218: this.ActiveFormatDescriptor = reader.ReadB(); return(true);

            case 0x320D:
                this.VideoLineMap    = new Int32[4];
                this.VideoLineMap[0] = (Int32)reader.ReadD();
                this.VideoLineMap[1] = (Int32)reader.ReadD();
                this.VideoLineMap[2] = (Int32)reader.ReadD();
                this.VideoLineMap[3] = (Int32)reader.ReadD();
                return(true);

            case 0x320F: this.AlphaTransparency = reader.ReadB(); return(true);

            case 0x3210: this.TransferCharacteristics = reader.ReadKey(); return(true);

            case 0x3211: this.ImageAlignmentOffset = reader.ReadD(); return(true);

            case 0x3213: this.ImageStartOffset = reader.ReadD(); return(true);

            case 0x3214: this.ImageEndOffset = reader.ReadD(); return(true);

            case 0x3212: this.FieldDominance = reader.ReadB(); return(true);

            case 0x3201: this.PictureEssenceCoding = reader.ReadKey(); return(true);

            case 0x321A: this.CodingEquations = reader.ReadKey(); return(true);

            case 0x3219: this.ColorPrimaries = reader.ReadKey(); return(true);
            }

            //PropertyDescriptor prop = TypeDescriptor.GetProperties(typeof(MXFGenericPictureEssenceDescriptor))["StoredWidth"];
            //DescriptionAttribute attr = prop.Attributes[typeof(DescriptionAttribute)] as DescriptionAttribute;
            //FieldInfo fi = attr.GetType().GetField("description", BindingFlags.NonPublic | BindingFlags.Instance);
            //if (fi != null)
            //	fi.SetValue(attr, "DIT IS GELUKT!!!");

            return(base.ParseLocalTag(reader, localTag));
        }