Example #1
0
        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;
                }
            }
        }
Example #2
0
 public MXFLocalTag(MXFReader reader)
     : base(reader)
 {
     this.Tag        = reader.ReadW();
     this.Size       = reader.ReadW();
     this.DataOffset = reader.Position;
     this.Length     = this.Size;
 }
Example #3
0
        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);
        }
        /// <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));
        }
Example #5
0
 /// <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;
     }
 }
Example #6
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));
        }
        /// <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));
        }
Example #8
0
 public MXFEntryPrimer(MXFReader reader)
     : base(reader)
 {
     this.Offset   = reader.Position;
     this.LocalTag = reader.ReadW();
     this.AliasUID = new MXFRefKey(reader, 16, "AliasUID");
     this.Length   = 20;           // Fixed length
 }
        public MXFANCFrameElement(MXFReader reader, MXFKLV headerKLV)
            : base(reader, headerKLV)
        {
            UInt16 nofPackets = reader.ReadW();

            for (int n = 0; n < nofPackets; n++)
            {
                MXFANCPacket newpacket = new MXFANCPacket(reader);
                this.AddChild(newpacket);
            }
        }
Example #10
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));
        }
Example #11
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);
            }
        }
Example #12
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));
        }
Example #13
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 0x3B02: this.LastModificationDate = reader.ReadTimestamp(); return(true);

            case 0x3B05: this.Version = reader.ReadW(); return(true);

            case 0x3B07: this.ObjectModelVersion = reader.ReadD(); return(true);

            case 0x3B03: this.ContentStorageUID = new MXFRefKey(reader, 16, "ContentStorageUID"); return(true);

            case 0x3B08: this.PrimaryPackageUID = new MXFRefKey(reader, 16, "PrimaryPackageUID"); return(true);

            case 0x3B09: this.OperationalPattern = new MXFKey(reader, 16); return(true);

            case 0x3B06: ReadKeyList(reader, "Identifications", "Identification"); return(true);

            case 0x3B0A: ReadKeyList(reader, "Essencecontainers", "Essencecontainer"); return(true);

            case 0x3B0B: ReadKeyList(reader, "Descriptive Metadata Schemes", "DM scheme"); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
Example #14
0
        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;
                    }
                }
            }
        }
Example #15
0
 public MXFCDPFooter(MXFReader reader)
     : base(reader)
 {
     this.SequenceCounter = reader.ReadW();
     this.PacketChecksum  = reader.ReadB();
 }