コード例 #1
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 = (MXFEmphasis)reader.ReadByte(); return(true);

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

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

            case 0x3D10: this.ChannelStatusMode = reader.ReadArray(reader.ReadChannelstatusMode, 8); return(true);

            case 0x3D11:
                this.FixedChannelStatusData = reader.ReadArray(reader.ReadByte, localTag.Size);
                return(true);

            case 0x3D12:
                this.UserDataMode = reader.ReadArray(reader.ReadUserDataMode, 2); return(true);

            case 0x3D13:
                this.FixedUserData = reader.ReadArray(reader.ReadByte, localTag.Size);
                return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #2
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            if (localTag.Key != null)
            {
                switch (localTag.Key)
                {
                case var _ when localTag.Key == initMetadata_Key: this.VC1InitializationMetadata = reader.ReadArray(reader.ReadByte, localTag.Size); return(true);

                case var _ when localTag.Key == singleSequence_Key: this.VC1SingleSequence = reader.ReadBool(); return(true);

                case var _ when localTag.Key == codedContent_Key: this.VC1CodedContentType = (MXFCodedContentScanning)reader.ReadByte(); return(true);

                case var _ when localTag.Key == identicalGOP_Key: this.VC1IdenticalGOP = reader.ReadBool(); return(true);

                case var _ when localTag.Key == maxGOP_Key: this.VC1MaxGOP = reader.ReadUInt16(); return(true);

                case var _ when localTag.Key == pictureCount_Key: this.VC1BPictureCount = reader.ReadUInt16(); return(true);

                case var _ when localTag.Key == avgBitRate_Key: this.VC1AverageBitRate = reader.ReadUInt32(); return(true);

                case var _ when localTag.Key == maxBitRate_Key: this.VC1MaximumBitRate = reader.ReadUInt32(); return(true);

                case var _ when localTag.Key == profile_Key: this.VC1Profile = reader.ReadByte(); return(true);

                case var _ when localTag.Key == level_Key: this.VC1Level = reader.ReadByte(); return(true);
                }
            }

            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #3
0
ファイル: MXFLocalTag.cs プロジェクト: rayden84/MXFInspect
 /// <summary>
 /// Parse this tag
 /// </summary>
 /// <param name="reader"></param>
 public void Parse(MXFReader reader)
 {
     if (this.Size == 1)
     {
         this.Value = reader.ReadByte();
     }
     else if (this.Size == 2)
     {
         this.Value = reader.ReadUInt16();
     }
     else if (this.Size == 4)
     {
         this.Value = reader.ReadUInt32();
     }
     else if (this.Size == 8)
     {
         this.Value = reader.ReadUInt64();
     }
     else
     {
         byte[] data = new byte[this.Size];
         for (int n = 0; n < this.Size; n++)
         {
             data[n] = reader.ReadByte();
         }
         this.Value = data;
     }
 }
コード例 #4
0
ファイル: MXFKLV.cs プロジェクト: rayden84/MXFInspect
        /// <summary>
        /// Decode the length
        /// </summary>
        /// <param name="reader"></param>
        private MXFBER DecodeBerLength(MXFReader reader)
        {
            long size = reader.ReadByte();

            if (size <= 0x7F)
            {
                // short form, size = length
                return(new MXFBER(0, size));
            }
            else if (size > 0x80)
            {
                // long form: size is number of octets following, 1 + x octets
                int additionalOctets = (int)size - 0x80;

                // SMPTE 379M 5.3.4 guarantee that additional octets must not exceed 8 bytes
                if (additionalOctets > 8)
                {
                    LogWarning("KLV length has more than 8 octets (not valid according to SMPTE 379M 5.3.4) found at offset {0}!", reader.Position);
                }
                size = 0;
                for (int i = 0; i < additionalOctets; i++)
                {
                    size = size << 8 | reader.ReadByte();
                }

                return(new MXFBER(additionalOctets, size));
            }
            else
            {
                // size is 0x80, which means indefinite
                LogWarning("KLV length having value 0x80 (=indefinite, not valid according to SMPTE 379M 5.3.4) found at offset {0}!", reader.Position);
                return(new MXFBER(-1, -1));
            }
        }
コード例 #5
0
        public MXFANCPacket(MXFReader reader)
            : base(reader)
        {
            this.LineNumber            = reader.ReadUInt16();
            this.WrappingType          = (MXFANCWrappingType)reader.ReadByte();
            this.PayloadSamplingCoding = (MXFANCPayloadCoding)reader.ReadByte();
            this.PayloadSampleCount    = reader.ReadUInt16();

            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.ReadUInt32();
            UInt32 unknownData2 = reader.ReadUInt32();

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

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

                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 = reader.ReadArray(reader.ReadByte, (int)(this.Length - 3));
                    break;
                }
            }
        }
コード例 #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 0x8113: this.CameraSettingFileURI = reader.ReadUTF8String(localTag.Size); return(true);

            case 0x8114: this.CameraAttributes = reader.ReadUTF8String(localTag.Size); return(true);

            case 0x3210: this.TransferCharacteristic = reader.ReadULKey(); return(true);

            case 0x8106: this.CaptureFrameRate = reader.ReadRational(); return(true);

            case 0x8100: this.AutoExposureMode = reader.ReadULKey(); return(true);

            case 0x8101: this.AutoFocusSensingAreaSetting = (MXFAutoFocusSensingAreaSetting)reader.ReadByte(); return(true);

            case 0x8102: this.ColorCorrectionFilterWheelSetting = (MXFColorCorrectionFilterWheelSetting)reader.ReadByte(); return(true);

            case 0x8103: this.NeutralDensityFilterWheelSetting = reader.ReadUInt16(); return(true);

            case 0x8104: this.ImageSensorDimensionEffectiveWidth = reader.ReadUInt16(); return(true);

            case 0x8105: this.ImageSensorDimensionEffectiveHeight = reader.ReadUInt16(); return(true);

            case 0x8107: this.ImageSensorReadoutMode = (MXFImageSensorReadoutMode)reader.ReadByte(); return(true);

            case 0x8108: this.ShutterSpeedAngle = reader.ReadUInt32(); return(true);

            case 0x8109: this.ShutterSpeedTime = reader.ReadRational(); return(true);

            case 0x810a: this.CameraMasterGainAdjustment = (short)reader.ReadUInt16(); return(true);

            case 0x810b: this.ISOSensitivity = reader.ReadUInt16(); return(true);

            case 0x810c: this.ElectricalExtenderMagnification = reader.ReadUInt16(); return(true);

            case 0x8115: this.ExposureIndexOfPhotoMeter = reader.ReadUInt16(); return(true);

            case 0x8118: this.ColorMatrix = reader.ReadArray(reader.ReadRational, localTag.Size); return(true);

            case 0x810d: this.AutoWhiteBalanceMode = (MXFAutoWhiteBalanceMode)reader.ReadByte(); return(true);

            case 0x810e: this.WhiteBalance = reader.ReadUInt16(); return(true);

            case 0x810f: this.CameraMasterBlackLevel = (short)reader.ReadUInt16(); return(true);

            case 0x8110: this.CameraKneePoint = reader.ReadUInt16(); return(true);

            case 0x8111: this.CameraKneeSlope = reader.ReadUInt16(); return(true);

            case 0x8112: this.CameraLuminanceDynamicRange = reader.ReadUInt16(); return(true);

            case 0x8116: this.GammaForCDL = reader.ReadByte(); return(true);
            }


            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #7
0
ファイル: MXFSystemItem.cs プロジェクト: rayden84/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.ReadByte();

            // Parse Content package rate
            byte rate      = reader.ReadByte();
            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.ReadByte();

            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.ReadUInt16();
            this.ContinuityCount = reader.ReadUInt16();

            this.SMPTE = reader.ReadULKey();             // 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);
        }
コード例 #8
0
ファイル: MXFPulldown.cs プロジェクト: rayden84/MXFInspect
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x0D03: this.PulldownDirection = (MXFPulldownDirection?)reader.ReadByte(); return(true);

            case 0x0D02: this.PulldownKind = (MXFPulldownKind?)reader.ReadByte(); return(true);

            case 0x0D04: this.PhaseFrame = reader.ReadUInt32(); return(true);

            case 0x0D01: this.AddChild(reader.ReadReference <MXFSegment>("InputSegment")); return(true);
            }

            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #9
0
ファイル: MXFSourceClip.cs プロジェクト: rayden84/MXFInspect
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x1201: this.StartPosition = reader.ReadUInt64(); return(true);

            case 0x1202: this.FadeInLength = reader.ReadUInt64(); return(true);

            case 0x1203: this.FadeInType = (MXFFadeType?)reader.ReadByte(); return(true);

            case 0x1204: this.FadeOutLength = reader.ReadUInt64(); return(true);

            case 0x1205: this.FadeOutType = (MXFFadeType?)reader.ReadByte(); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #10
0
 public MXFCDPFuture(MXFReader reader, byte sectionID)
     : base(reader)
 {
     this.SectionID = sectionID;
     this.Length    = reader.ReadByte();
     this.Data      = reader.ReadArray(reader.ReadByte, (int)this.Length);
 }
コード例 #11
0
ファイル: MXFEntryIndex.cs プロジェクト: rayden84/MXFInspect
        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.ReadSignedByte();
            this.KeyFrameOffset = reader.ReadSignedByte();
            this.Flags          = new IndexEntryFlags(reader.ReadByte());
            this.StreamOffset   = reader.ReadUInt64();

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

            if (posTableCount.HasValue && posTableCount.Value > 0)
            {
                this.PosTable = new MXFRational[posTableCount.Value];
                for (int n = 0; n < posTableCount; n++)
                {
                    this.PosTable[n] = reader.ReadRational();
                }
            }
        }
コード例 #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 0x3D0A: this.BlockAlign = reader.ReadUInt16(); return(true);

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

            case 0x3D09: this.AverageBytesPerSecond = reader.ReadUInt32(); return(true);

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

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

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

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

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

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

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

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

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

            case 0x3D31: this.PeakEnvelopeData = reader.ReadArray(reader.ReadByte, localTag.Size); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #13
0
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x3301: this.ComponentDepth = reader.ReadUInt32(); return(true);

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

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

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

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

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

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

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

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

            case 0x3306: this.ColorRange = reader.ReadUInt32(); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #14
0
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x000F: Size = reader.ReadByte(); return(true);

            case 0x0010: IsSigned = reader.ReadBool(); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #15
0
        public MXFEntryDelta(MXFReader reader, UInt32 length)
            : base(reader)
        {
            this.m_eType = MXFObjectType.Index;

            this.Length        = length;
            this.PosTableIndex = reader.ReadSignedByte();
            this.Slice         = reader.ReadByte();
            this.ElementDelta  = reader.ReadUInt32();
        }
コード例 #16
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.ReadUInt64(); return(true);

            case 0x1502: this.FramesPerSecond = reader.ReadUInt16(); return(true);

            case 0x1503: this.DropFrame = (reader.ReadByte() != 0); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #17
0
        public MXFEntryCCData(MXFReader reader)
            : base(reader)
        {
            this.Length = 3;             // Fixed
            byte b0 = reader.ReadByte();

            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.ReadByte();
                this.Data[1] = reader.ReadByte();
            }

            // When this object is not valid, set the type to filler
            if (this.Valid.HasValue && !this.Valid.Value)
            {
                this.m_eType = MXFObjectType.Filler;
            }
        }
コード例 #18
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 0x5701: this.ToleranceMode = (MXFToleranceModeType)reader.ReadByte(); return(true);

            case 0x5703: this.ToleranceWindow = reader.ReadArray <byte>(reader.ReadByte, localTag.Size); return(true);

            // TODO replace generic MXFObject with class ApplicationPluginObject once implemented
            case 0x5702: this.AddChild(reader.ReadReference <MXFObject>("InterpolationDefinition")); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #19
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            if (localTag.Key != null)
            {
                switch (localTag.Key)
                {
                case var _ when localTag.Key == constantBPictureFlag_Key: this.AVCConstantBPictureFlag = reader.ReadBool(); return(true);

                case var _ when localTag.Key == codedContentKind_Key: this.AVCCodedContentKind = (MXFAVCContentScanning)reader.ReadByte(); return(true);

                case var _ when localTag.Key == closedGOPIndicator_Key: this.AVCClosedGOPIndicator = reader.ReadBool(); return(true);

                case var _ when localTag.Key == identicalGOPIndicator_Key: this.AVCIdenticalGOPIndicator = reader.ReadBool(); return(true);

                case var _ when localTag.Key == maximumGOPSize_Key: this.AVCMaximumGOPSize = reader.ReadUInt16(); return(true);

                case var _ when localTag.Key == maximumBPictureCount_Key: this.AVCMaximumBPictureCount = reader.ReadUInt16(); return(true);

                case var _ when localTag.Key == profile_Key: this.AVCProfile = reader.ReadByte(); return(true);

                case var _ when localTag.Key == maximumBitRate_Key: this.AVCMaximumBitRate = reader.ReadUInt32(); return(true);

                case var _ when localTag.Key == profileConstraint_Key: this.AVCProfileConstraint = reader.ReadByte(); return(true);

                case var _ when localTag.Key == level_Key: this.AVCLevel = reader.ReadByte(); return(true);

                case var _ when localTag.Key == decodingDelay_Key: this.AVCDecodingDelay = reader.ReadByte(); return(true);

                case var _ when localTag.Key == maximumRefFrames_Key: this.AVCMaximumRefFrames = reader.ReadByte(); return(true);

                case var _ when localTag.Key == sequenceParameterSetFlag_Key: this.AVCSequenceParameterSetFlag = reader.ReadByte(); return(true);

                case var _ when localTag.Key == pictureParameterSetFlag_Key: this.AVCPictureParameterSetFlag = reader.ReadByte(); return(true);

                case var _ when localTag.Key == averageBitRate_Key: this.AVCAverageBitRate = reader.ReadByte(); return(true);
                }
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #20
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 0x1601: this.TimecodeStreamSampleRate = reader.ReadRational(); return(true);

            case 0x1603: this.TimecodeSource = (MXFTCSource?)reader.ReadByte(); return(true);

            case 0x1602: this.TimecodeStreamData = reader.ReadArray(reader.ReadByte, localTag.Size); return(true);
            }

            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #21
0
ファイル: MXFTimeStamp.cs プロジェクト: rayden84/MXFInspect
        /// <summary>
        /// Parse a SMPTE12M timecode
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="frameRate"></param>
        public void ParseSMPTE12M(MXFReader reader, double frameRate)
        {
            byte hoursb   = reader.ReadByte();
            byte minutesb = reader.ReadByte();
            byte secondsb = reader.ReadByte();
            byte framesb  = reader.ReadByte();

            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;
            }
        }
コード例 #22
0
        private (byte Tag, UInt32 Size) GetTag(MXFReader reader)
        {
            byte   tag  = reader.ReadByte();
            UInt32 size = 0;

            if (nofSizeSize == 2)
            {
                size = reader.ReadUInt16();
            }
            else
            {
                size = reader.ReadUInt32();
            }


            return(tag, size);
        }
コード例 #23
0
        public MXFEntrySVCInfo(MXFReader reader)
            : base(reader)
        {
            this.Length = 7;             // Fixed

            byte b0 = reader.ReadByte();

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

            this.Data = reader.ReadArray(reader.ReadByte, 6);

            this.DataString = System.Text.Encoding.ASCII.GetString(this.Data);
        }
コード例 #24
0
ファイル: MXFTimeStamp.cs プロジェクト: rayden84/MXFInspect
        /// <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.ReadByte();
            byte secondb = reader.ReadByte();
            byte minuteb = reader.ReadByte();
            byte hourb   = reader.ReadByte();

            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.ReadByte(), 0x30);           // Binary group data BG1 + BG2
            this.Month = ParseBCD(reader.ReadByte(), 0x10);           // Binary group data BG3 + BG4
            this.Year  = ParseBCD(reader.ReadByte(), 0xF0);           // Binary group data BG5 + BG6
        }
コード例 #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 0x3406: this.ComponentMaxRef = reader.ReadUInt32(); return(true);

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

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

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

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

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

            case 0x3403: this.Palette = reader.ReadArray(reader.ReadByte, localTag.Size); return(true);

            case 0x3404: this.PaletteLayout = reader.ReadRGBALayout(); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #26
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 = (MXFSignalStandard)reader.ReadByte(); return(true);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            case 0x320D: this.VideoLineMap = reader.ReadArray(reader.ReadInt32, 4); return(true);

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

            case 0x3210: this.TransferCharacteristic = reader.ReadULKey(); return(true);

            case 0x3211: this.ImageAlignmentFactor = reader.ReadUInt32(); return(true);

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

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

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

            case 0x3201: this.PictureCompression = reader.ReadULKey(); return(true);

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

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

            case var _ when localTag.Key == altCenterCuts_Key: this.AddChild(reader.ReadAUIDSet("AlternativeCenterCuts", "AlternativeCenterCut")); return(true);

            case var _ when localTag.Key == activeHeight_Key: this.ActiveHeight = reader.ReadUInt32(); return(true);

            case var _ when localTag.Key == activeWidth_Key: this.ActiveHeight = reader.ReadUInt32(); return(true);

            case var _ when localTag.Key == activeXOffset_Key: this.ActiveHeight = reader.ReadUInt32(); return(true);

            case var _ when localTag.Key == activeYOffset_Key: this.ActiveHeight = reader.ReadUInt32(); return(true);

            case var _ when localTag.Key == displayPrimaries_Key: this.MasteringDisplayPrimaries = reader.ReadArray(reader.ReadColorPrimary, 3);  return(true);

            case var _ when localTag.Key == displayWhitePointChromaticity_Key: this.MasteringDisplayWhitePointChromaticity = reader.ReadColorPrimary(); return(true);

            case var _ when localTag.Key == displayMaxLuminance_Key: this.MasteringDisplayMaximumLuminance = reader.ReadUInt32(); return(true);

            case var _ when localTag.Key == displayMinLuminance_Key: this.MasteringDisplayMinimumLuminance = reader.ReadUInt32(); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #27
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            if (localTag.Key != null)
            {
                switch (localTag.Key)
                {
                case var _ when localTag.Key == bitRate_Key: this.BitRate = reader.ReadUInt32(); return(true);

                case var _ when localTag.Key == identicalGOPIndicator_Key: this.IdenticalGOPIndicator = reader.ReadBool(); return(true);

                case var _ when localTag.Key == maxGOPSize_Key: this.MaximumGOPSize = reader.ReadUInt16(); return(true);

                case var _ when localTag.Key == maxBPictureCount_Key: this.MaximumBPictureCount = reader.ReadUInt16(); return(true);

                case var _ when localTag.Key == constantBPictureFlag_Key: this.ConstantBPictureFlag = reader.ReadBool(); return(true);

                case var _ when localTag.Key == codedContentScanningKind_Key: this.CodedContentScanningKind = (MXFCodedContentScanning)reader.ReadByte(); return(true);

                case var _ when localTag.Key == profileAndLevel_Key: this.ProfileAndLevel = reader.ReadByte(); return(true);

                case var _ when localTag.Key == singleSequenceFlag_Key: this.SingleSequenceFlag = reader.ReadBool(); return(true);

                case var _ when localTag.Key == closedGOP_Key: this.ClosedGOPIndicator = reader.ReadBool(); return(true);

                case var _ when localTag.Key == lowDelay_Key: this.LowDelayIndicator = reader.ReadBool(); return(true);
                }
            }

            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #28
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.ReadSignedByte(); return(true);

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

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

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

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

            case 0x3D06: this.SoundEssenceCoding = reader.ReadULKey(); return(true);

            case var _ when localTag.Key == refImageEditRate_Key: this.ReferenceImageEditRate = reader.ReadRational(); return(true);

            case var _ when localTag.Key == refAudioAlignmentLevel: this.ReferenceAudioAlignmentLevel = reader.ReadByte(); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
コード例 #29
0
 public MXFCDPFooter(MXFReader reader)
     : base(reader)
 {
     this.SequenceCounter = reader.ReadUInt16();
     this.PacketChecksum  = reader.ReadByte();
 }
コード例 #30
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.ReadUInt32(); return(true);

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

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

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

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

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

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

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

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

            case 0x3F11: this.SingleIndexLocation = reader.ReadBool(); return(true);

            case 0x3F12: this.SingleEssenceLocation = reader.ReadBool(); return(true);

            case 0x3F13: this.ForwardIndexDirection = reader.ReadBool(); return(true);

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

            case 0x3F0A:                      // Index entry array
            {
                UInt32 NbIndexEntries = reader.ReadUInt32();
                UInt32 entryLength    = reader.ReadUInt32();
                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.ReadUInt32();
                UInt32 entryLength    = reader.ReadUInt32();
                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));
        }