Пример #1
0
        public void ParseSegments()
        {
            if (SubtitleSegments != null)
            {
                return;
            }

            SubtitleSegments   = new List <SubtitleSegment>();
            ClutDefinitions    = new List <ClutDefinitionSegment>();
            RegionCompositions = new List <RegionCompositionSegment>();
            PageCompositions   = new List <PageCompositionSegment>();
            ObjectDataList     = new List <ObjectDataSegment>();

            int index = 2;
            var ss    = new SubtitleSegment(DataBuffer, index);
            ClutDefinitionSegment cds = null;

            while (ss.SyncByte == Helper.B00001111)
            {
                SubtitleSegments.Add(ss);
                if (ss.ClutDefinition != null)
                {
                    cds = ss.ClutDefinition;
                    ClutDefinitions.Add(ss.ClutDefinition);
                }
                else if (ss.RegionComposition != null)
                {
                    RegionCompositions.Add(ss.RegionComposition);
                }
                else if (ss.PageComposition != null)
                {
                    PageCompositions.Add(ss.PageComposition);
                }
                else if (ss.ObjectData != null)
                {
                    ObjectDataList.Add(ss.ObjectData);
                }

                index += 6 + ss.SegmentLength;
                if (index + 6 < DataBuffer.Length)
                {
                    ss = new SubtitleSegment(DataBuffer, index);
                }
                else
                {
                    ss.SyncByte = Helper.B11111111;
                }
            }
        }
Пример #2
0
        public DvbSubPes(int index, byte[] buffer)
        {
            int start = index;

            Length = index + 1;

            if (index + 9 >= buffer.Length)
            {
                return;
            }

            if (buffer[0 + index] != 0x20)
            {
                return;
            }

            if (buffer[1 + index] != 0)
            {
                return;
            }

            SubtitleSegments   = new List <SubtitleSegment>();
            ClutDefinitions    = new List <ClutDefinitionSegment>();
            RegionCompositions = new List <RegionCompositionSegment>();
            PageCompositions   = new List <PageCompositionSegment>();
            ObjectDataList     = new List <ObjectDataSegment>();

            // Find length of segments
            index = start + 2;
            var ss = new SubtitleSegment(buffer, index);

            while (ss.SyncByte == Helper.B00001111)
            {
                SubtitleSegments.Add(ss);
                index += 6 + ss.SegmentLength;
                if (index + 6 < buffer.Length)
                {
                    ss = new SubtitleSegment(buffer, index);
                }
                else
                {
                    ss.SyncByte = Helper.B11111111;
                }
            }
            Length = index;
            int size = index - start;

            _dataBuffer = new byte[size];
            Buffer.BlockCopy(buffer, start, _dataBuffer, 0, _dataBuffer.Length);

            // Parse segments
            index = 2;
            ss    = new SubtitleSegment(_dataBuffer, index);
            while (ss.SyncByte == Helper.B00001111)
            {
                SubtitleSegments.Add(ss);
                if (ss.ClutDefinition != null)
                {
                    ClutDefinitions.Add(ss.ClutDefinition);
                }
                else if (ss.RegionComposition != null)
                {
                    RegionCompositions.Add(ss.RegionComposition);
                }
                else if (ss.PageComposition != null)
                {
                    PageCompositions.Add(ss.PageComposition);
                }
                else if (ss.ObjectData != null)
                {
                    ObjectDataList.Add(ss.ObjectData);
                }

                index += 6 + ss.SegmentLength;
                if (index + 6 < _dataBuffer.Length)
                {
                    ss = new SubtitleSegment(_dataBuffer, index);
                }
                else
                {
                    ss.SyncByte = Helper.B11111111;
                }
            }
        }
Пример #3
0
        public DvbSubPes(int index, byte[] buffer)
        {
            int start = index;
            Length = index + 1;

            if (index + 9 >= buffer.Length)
                return;

            if (buffer[0 + index] != 0x20)
                return;

            if (buffer[1 + index] != 0)
                return;

            SubtitleSegments = new List<SubtitleSegment>();
            ClutDefinitions = new List<ClutDefinitionSegment>();
            RegionCompositions = new List<RegionCompositionSegment>();
            PageCompositions = new List<PageCompositionSegment>();
            ObjectDataList = new List<ObjectDataSegment>();

            // Find length of segments
            index = start + 2;
            var ss = new SubtitleSegment(buffer, index);
            while (ss.SyncByte == Helper.B00001111)
            {
                SubtitleSegments.Add(ss);
                index += 6 + ss.SegmentLength;
                if (index + 6 < buffer.Length)
                    ss = new SubtitleSegment(buffer, index);
                else
                    ss.SyncByte = Helper.B11111111;
            }
            Length = index;
            int size = index - start;
            DataBuffer = new byte[size];
            Buffer.BlockCopy(buffer, start, DataBuffer, 0, DataBuffer.Length);

            // Parse segments
            index = 2;
            ss = new SubtitleSegment(DataBuffer, index);
            while (ss.SyncByte == Helper.B00001111)
            {
                SubtitleSegments.Add(ss);
                if (ss.ClutDefinition != null)
                {
                    ClutDefinitions.Add(ss.ClutDefinition);
                }
                else if (ss.RegionComposition != null)
                {
                    RegionCompositions.Add(ss.RegionComposition);
                }
                else if (ss.PageComposition != null)
                {
                    PageCompositions.Add(ss.PageComposition);
                }
                else if (ss.ObjectData != null)
                {
                    ObjectDataList.Add(ss.ObjectData);
                }

                index += 6 + ss.SegmentLength;
                if (index + 6 < DataBuffer.Length)
                    ss = new SubtitleSegment(DataBuffer, index);
                else
                    ss.SyncByte = Helper.B11111111;
            }
        }
Пример #4
0
        public void ParseSegments()
        {
            if (SubtitleSegments != null)
                return;

            SubtitleSegments = new List<SubtitleSegment>();
            ClutDefinitions = new List<ClutDefinitionSegment>();
            RegionCompositions = new List<RegionCompositionSegment>();
            PageCompositions = new List<PageCompositionSegment>();
            ObjectDataList = new List<ObjectDataSegment>();

            int index = 2;
            var ss = new SubtitleSegment(DataBuffer, index);
            while (ss.SyncByte == Helper.B00001111)
            {
                SubtitleSegments.Add(ss);
                if (ss.ClutDefinition != null)
                {
                    ClutDefinitions.Add(ss.ClutDefinition);
                }
                else if (ss.RegionComposition != null)
                {
                    RegionCompositions.Add(ss.RegionComposition);
                }
                else if (ss.PageComposition != null)
                {
                    PageCompositions.Add(ss.PageComposition);
                }
                else if (ss.ObjectData != null)
                {
                    ObjectDataList.Add(ss.ObjectData);
                }

                index += 6 + ss.SegmentLength;
                if (index + 6 < DataBuffer.Length)
                    ss = new SubtitleSegment(DataBuffer, index);
                else
                    ss.SyncByte = Helper.B11111111;
            }
        }
        /// <summary>
        /// The parse segments.
        /// </summary>
        public void ParseSegments()
        {
            if (this.SubtitleSegments != null)
            {
                return;
            }

            this.SubtitleSegments = new List<SubtitleSegment>();
            this.ClutDefinitions = new List<ClutDefinitionSegment>();
            this.RegionCompositions = new List<RegionCompositionSegment>();
            this.PageCompositions = new List<PageCompositionSegment>();
            this.ObjectDataList = new List<ObjectDataSegment>();

            int index = 2;
            var ss = new SubtitleSegment(this._dataBuffer, index);
            while (ss.SyncByte == Helper.B00001111)
            {
                this.SubtitleSegments.Add(ss);
                if (ss.ClutDefinition != null)
                {
                    this.ClutDefinitions.Add(ss.ClutDefinition);
                }
                else if (ss.RegionComposition != null)
                {
                    this.RegionCompositions.Add(ss.RegionComposition);
                }
                else if (ss.PageComposition != null)
                {
                    this.PageCompositions.Add(ss.PageComposition);
                }
                else if (ss.ObjectData != null)
                {
                    this.ObjectDataList.Add(ss.ObjectData);
                }

                index += 6 + ss.SegmentLength;
                if (index + 6 < this._dataBuffer.Length)
                {
                    ss = new SubtitleSegment(this._dataBuffer, index);
                }
                else
                {
                    ss.SyncByte = Helper.B11111111;
                }
            }
        }