当前位置: 首页>>代码示例>>C#>>正文


C# ByteVector.Mid方法代码示例

本文整理汇总了C#中ByteVector.Mid方法的典型用法代码示例。如果您正苦于以下问题:C# ByteVector.Mid方法的具体用法?C# ByteVector.Mid怎么用?C# ByteVector.Mid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ByteVector的用法示例。


在下文中一共展示了ByteVector.Mid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StreamHeader

 public StreamHeader(ByteVector data, long streamLength)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (!data.StartsWith(FileIdentifier))
     {
         throw new CorruptFileException("Data does not begin with identifier.");
     }
     if (data.Count < 0x38L)
     {
         throw new CorruptFileException("Insufficient data in stream header");
     }
     this.stream_length = streamLength;
     this.version = data[3] & 15;
     if (this.version >= 7)
     {
         this.frames = data.Mid(4, 4).ToUInt(false);
         uint num = data.Mid(8, 4).ToUInt(false);
         this.sample_rate = sftable[(((num >> 0x11) & 1) * 2) + ((num >> 0x10) & 1)];
         this.header_data = 0;
     }
     else
     {
         this.header_data = data.Mid(0, 4).ToUInt(false);
         this.version = ((int) (this.header_data >> 11)) & 0x3ff;
         this.sample_rate = 0xac44;
         this.frames = data.Mid(4, (this.version < 5) ? 2 : 4).ToUInt(false);
     }
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:31,代码来源:StreamHeader.cs

示例2: Parse

		protected void Parse(ByteVector data)
		{
			if (data != null)
			{
				if (data.Count < Size)
					return;

				// The first eight buffer, data[0..7], are the File Identifier, "APETAGEX".

				// Read the version number
				version = data.Mid(8, 4).ToUInt(false);

				// Read the tag size
				tagSize = data.Mid(12, 4).ToUInt(false);

				// Read the item count
				itemCount = data.Mid(16, 4).ToUInt(false);

				// Read the flags

				uint flags = data.Mid(20, 4).ToUInt(false);

				headerPresent = (flags >> 31) == 1;
				footerPresent = (flags >> 30) != 1;
				isHeader = (flags >> 29) == 1;
			}
			else throw new ArgumentNullException("data");
		}
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:28,代码来源:ApeFooter.cs

示例3: Read

		//private void Read(ByteVector data, long stream_length, ReadStyle style)
		private void Read(ByteVector data, long streamLength)
		{
			if (data.StartsWith("MP+"))
				return;

			version = data[3] & 15;

			uint frames;

			if (version >= 7)
			{
				frames = data.Mid(4, 4).ToUInt(false);
				uint flags = data.Mid(8, 4).ToUInt(false);
				sampleRate = sfTable[(int)(((flags >> 17) & 1) * 2 + ((flags >> 16) & 1))];
				channels = 2;
			}
			else
			{
				uint headerData = data.Mid(0, 4).ToUInt(false);
				bitrate = (int)((headerData >> 23) & 0x01ff);
				version = (int)((headerData >> 11) & 0x03ff);
				sampleRate = 44100;
				channels = 2;
				if (version >= 5)
					frames = data.Mid(4, 4).ToUInt(false);
				else
					frames = data.Mid(4, 2).ToUInt(false);
			}

			uint samples = frames * 1152 - 576;
			duration = sampleRate > 0 ? TimeSpan.FromSeconds((double)samples / (double)sampleRate + 0.5) : TimeSpan.Zero;

			if (bitrate == 0)
				bitrate = (int)(duration > TimeSpan.Zero ? ((streamLength * 8L) / duration.TotalSeconds) / 1000 : 0);
		}		
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:36,代码来源:MpcProperties.cs

示例4: ParseCommentsFields

		private void ParseCommentsFields(ByteVector data)
		{
			if (data.Count < 5)
			{
				TagLibDebugger.Debug("A comment frame must contain at least 5 bytes.");
				return;
			}

			textEncoding = (StringType)data[0];
			language = data.Mid(1, 3);

			int byte_align = textEncoding == StringType.Latin1 || textEncoding == StringType.UTF8 ? 1 : 2;

			ByteVectorCollection l = ByteVectorCollection.Split(data.Mid(4), TextDelimiter(textEncoding), byte_align, 2);

			if (l.Count == 2)
			{
				if (l[0].Data != null && l[0].Data.Count > 0)
					description = l[0].ToString(textEncoding);
				else description = string.Empty;
				
				if (l[1].Data != null && l[1].Data.Count > 0)
					text = l[1].ToString(textEncoding);
				else text = string.Empty;
			}
		}
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:26,代码来源:Id3v2CommentsFrame.cs

示例5: ParseStreamList

 public static AviStream ParseStreamList (ByteVector data)
 {
    if (data == null)
       throw new ArgumentNullException ("data");
    
    AviStream stream = null;
    int pos = 4;
    
    if (data.StartsWith ("strl"))
       while (pos + 8 < data.Count)
       {
          ByteVector id = data.Mid (pos, 4);
          int block_length = (int) data.Mid (pos + 4, 4).ToUInt (false);
          
          if (id == "strh" && stream == null)
          {
             AviStreamHeader stream_header = new AviStreamHeader (data, pos + 8);
             if (stream_header.Type == "vids")
                stream = new AviVideoStream (stream_header);
             else if (stream_header.Type == "auds")
                stream = new AviAudioStream (stream_header);
          }
          else if (stream != null)
             stream.ParseItem (id, data, pos + 8, block_length);
          
          pos += block_length + 8;
       }
    
    return stream;
 }
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:30,代码来源:AviStream.cs

示例6: Parse

		private void Parse(ByteVector data)
		{
			// Check to see if a valid Xing header is available.

			if (!data.StartsWith("Xing"))
				return;

			// If the XingHeader doesn'type contain the number of frames and the total stream
			// info it'field invalid.

			if ((data[7] & 0x02) == 0)
			{
				TagLibDebugger.Debug("MPEG::XingHeader::parse() -- Xing header doesn't contain the total number of frames.");
				return;
			}

			if ((data[7] & 0x04) == 0)
			{
				TagLibDebugger.Debug("MPEG::XingHeader::parse() -- Xing header doesn't contain the total stream size.");
				return;
			}

			frames = data.Mid(8, 4).ToUInt();
			size = data.Mid(12, 4).ToUInt();

			valid = true;
		}
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:27,代码来源:MpegXingHeader.cs

示例7: ParseStreamList

 public static AviStream ParseStreamList(ByteVector data)
 {
     int num2;
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (!data.StartsWith("strl"))
     {
         return null;
     }
     AviStream stream = null;
     for (int i = 4; (i + 8) < data.Count; i += num2 + 8)
     {
         ByteVector id = data.Mid(i, 4);
         num2 = (int) data.Mid(i + 4, 4).ToUInt(false);
         if ((id == "strh") && (stream == null))
         {
             AviStreamHeader header = new AviStreamHeader(data, i + 8);
             if (header.Type == "vids")
             {
                 stream = new AviVideoStream(header);
             }
             else if (header.Type == "auds")
             {
                 stream = new AviAudioStream(header);
             }
         }
         else if (stream != null)
         {
             stream.ParseItem(id, data, i + 8, num2);
         }
     }
     return stream;
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:35,代码来源:AviStream.cs

示例8: ParseRelativeVolumeFields

		private void ParseRelativeVolumeFields(ByteVector data)
		{
			int pos = data.Find(TextDelimiter(StringType.Latin1));
			if (pos < 0)
				return;

			identification = data.Mid(0, pos).ToString(StringType.Latin1);
			pos += 1;

			// Each channel is at least 4 buffer.

			while (pos <= data.Count - 4)
			{
				Id3v2ChannelType type = (Id3v2ChannelType)data[pos];
				pos += 1;

				SetVolumeAdjustmentIndex(data.Mid(pos, 2).ToShort(), type);
				pos += 2;

				int bytes = BitsToBytes(data[pos]);
				pos += 1;

				SetPeakVolumeIndex(ParsePeakVolume(data.Mid(pos, bytes)), type);
				pos += bytes;
			}
		}
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:26,代码来源:Id3v2RelativeVolumeFrame.cs

示例9: XingHeader

 public XingHeader(ByteVector data)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (!data.StartsWith(FileIdentifier))
     {
         throw new CorruptFileException("Not a valid Xing header");
     }
     int startIndex = 8;
     if ((data[7] & 1) != 0)
     {
         this.frames = data.Mid(startIndex, 4).ToUInt();
         startIndex += 4;
     }
     else
     {
         this.frames = 0;
     }
     if ((data[7] & 2) != 0)
     {
         this.size = data.Mid(startIndex, 4).ToUInt();
         startIndex += 4;
     }
     else
     {
         this.size = 0;
     }
     this.present = true;
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:31,代码来源:XingHeader.cs

示例10: Picture

 public Picture(ByteVector data)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (data.Count < 0x20)
     {
         throw new CorruptFileException("Data must be at least 32 bytes long");
     }
     int startIndex = 0;
     this.type = (PictureType) data.Mid(startIndex, 4).ToUInt();
     startIndex += 4;
     int count = (int) data.Mid(startIndex, 4).ToUInt();
     startIndex += 4;
     this.mime_type = data.ToString(StringType.Latin1, startIndex, count);
     startIndex += count;
     int num3 = (int) data.Mid(startIndex, 4).ToUInt();
     startIndex += 4;
     this.description = data.ToString(StringType.UTF8, startIndex, num3);
     startIndex += num3;
     this.width = (int) data.Mid(startIndex, 4).ToUInt();
     startIndex += 4;
     this.height = (int) data.Mid(startIndex, 4).ToUInt();
     startIndex += 4;
     this.color_depth = (int) data.Mid(startIndex, 4).ToUInt();
     startIndex += 4;
     this.indexed_colors = (int) data.Mid(startIndex, 4).ToUInt();
     startIndex += 4;
     int length = (int) data.Mid(startIndex, 4).ToUInt();
     startIndex += 4;
     this.picture_data = data.Mid(startIndex, length);
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:33,代码来源:Picture.cs

示例11: StreamHeader

 public StreamHeader (ByteVector data, long streamLength)
 {
    if (data == null)
       throw new ArgumentNullException ("data");
    
    if (data.Count < 18)
       throw new CorruptFileException ("Not enough data in FLAC header.");
    
    this.stream_length = streamLength;
    this.flags = data.Mid (10, 4).ToUInt (true);
    low_length = data.Mid (14, 4).ToUInt (true);
 }
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:12,代码来源:StreamHeader.cs

示例12: AsfGuid

		public AsfGuid(ByteVector raw)
		{
			if (raw != null)
			{
				this.part1 = raw.Mid(0, 4).ToUInt(false);
				this.part2 = raw.Mid(4, 2).ToShort(false);
				this.part3 = raw.Mid(6, 2).ToShort(false);
				this.part4 = raw.Mid(8, 2).ToShort(true);
				this.part5 = raw.Mid(10, 6).ToLong(true);
			}
			else throw new ArgumentNullException("raw");
		}
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:12,代码来源:AsfGuid.cs

示例13: Mpeg4IsoHandlerBox

		// We can make our own handler.
		public Mpeg4IsoHandlerBox(ByteVector handlerType, string name, Mpeg4Box parent) : base("hdlr", 0, parent)
		{
			if (handlerType != null)
				this.handlerType = handlerType.Mid(0, 4);
			
			this.name = name;
		}
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:8,代码来源:Mpeg4IsoHandlerBox.cs

示例14: Footer

      public Footer (ByteVector data)
      {
         if (data.Count < Size)
            throw new CorruptFileException ("Provided data is smaller than object size.");
         
         if (!data.StartsWith (FileIdentifier))
            throw new CorruptFileException ("Provided data does not start with File Identifier");
         
         major_version   = data [3];
         revision_number = data [4];
         flags           = (HeaderFlags) data [5];
         
         
         if (major_version == 2 && (flags & (HeaderFlags) 127) != 0)
            throw new CorruptFileException ("Invalid flags set on version 2 tag.");
         
         if (major_version == 3 && (flags & (HeaderFlags) 15) != 0)
            throw new CorruptFileException ("Invalid flags set on version 3 tag.");
         
         if (major_version == 4 && (flags & (HeaderFlags) 7) != 0)
            throw new CorruptFileException ("Invalid flags set on version 4 tag.");
         
         
         ByteVector size_data = data.Mid (6, 4);
         
         foreach (byte b in size_data)
            if (b >= 128)
               throw new CorruptFileException ("One of the bytes in the header was greater than the allowed 128.");

         tag_size = SynchData.ToUInt (size_data);
      }
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:31,代码来源:Footer.cs

示例15: ReadPacket

        public override bool ReadPacket(ByteVector packet, int index)
        {
            if (packet == null)
            {
                throw new ArgumentNullException("packet");
            }
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index", "index must be at least zero.");
            }
            int num = PacketType(packet);
            if ((num != 0x80) && (index == 0))
            {
                throw new CorruptFileException("Stream does not begin with theora header.");
            }
            if (this.comment_data == null)
            {
                switch (num)
                {
                    case 0x80:
                        this.header = new HeaderPacket(packet);
                        goto Label_009D;

                    case 0x81:
                        this.comment_data = packet.Mid(7);
                        goto Label_009D;
                }
                return true;
            }
        Label_009D:
            return (this.comment_data != null);
        }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:32,代码来源:Theora.cs


注:本文中的ByteVector.Mid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。