示例#1
0
		public EBMLReader(IEBMLDataSource dataSrc, EBMLDocType ebmlDoc) {
			this.dataSrc = dataSrc;
			this.docType = ebmlDoc;
			this.bytePatterns = new BytePatterns(ebmlDoc.CreateSyncPoints());


			lastElementPos = dataSrc.HasKnownLength ? dataSrc.Length : ~VIntConsts.UNKNOWN_LENGTH;
		}
        public void SyncTo(BytePatterns bytePatterns, long seekUntil)
        {
            long foundPosition = -1;
            bytePatterns.Match(data, (int)Position, (pattern, i) => { foundPosition = i; return false; });

            if(foundPosition > seekUntil) foundPosition = seekUntil;
            if(foundPosition != -1) Position = foundPosition;
        }
示例#3
0
        public void SyncTo(BytePatterns bytePatterns, long seekUntil)
        {
            bytePatterns.Reset();

            var b = new byte[1024 * 1024];
            int foundRelativePosition = int.MinValue;
            while(foundRelativePosition == int.MinValue && !EOF) {
                if(seekUntil != -1 || Position < seekUntil) source.Read(b, 0, b.Length); else break;

                bytePatterns.Match(b, 0, (pattern, i) => { foundRelativePosition = i; return false; });
            }

            if(seekUntil != -1 && Position - b.Length + foundRelativePosition > seekUntil) foundRelativePosition = b.Length - (int)(Position - seekUntil);
            if(foundRelativePosition != int.MinValue) source.Position -= b.Length - foundRelativePosition;
        }
示例#4
0
 public void SyncTo(BytePatterns bytePatterns, long seekUntil)
 {
     throw new NotSupportedException();
 }
示例#5
0
        public void SyncTo(BytePatterns bytePatterns, long seekUntil)
        {
            bytePatterns.Reset();
            int foundRelativePosition = -1;
            while(foundRelativePosition < 0 && !EOF) {
                bytePatterns.Match(blocks.Current, (int)relativePosition, (pattern, i) => { foundRelativePosition = i; return false; });
                if(foundRelativePosition < 0) {
                    bytePatterns.Reset();
                    if(seekUntil == -1 || absolutePosition + BlockSize <= seekUntil) advance(); else break;
                }
            }

            if(seekUntil != -1 && absolutePosition + foundRelativePosition > seekUntil) foundRelativePosition = (int)(seekUntil - absolutePosition);
            if(foundRelativePosition >= 0) relativePosition = foundRelativePosition;
        }