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


Java ParsableByteArray.readLittleEndianUnsignedInt方法代码示例

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


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

示例1: readVorbisIdentificationHeader

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Reads a vorbis identification header from {@code headerData}.
 *
 * @see <a href="https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-630004.2.2">Vorbis
 *     spec/Identification header</a>
 * @param headerData a {@link ParsableByteArray} wrapping the header data.
 * @return a {@link VorbisUtil.VorbisIdHeader} with meta data.
 * @throws ParserException thrown if invalid capture pattern is detected.
 */
public static VorbisIdHeader readVorbisIdentificationHeader(ParsableByteArray headerData)
    throws ParserException {

  verifyVorbisHeaderCapturePattern(0x01, headerData, false);

  long version = headerData.readLittleEndianUnsignedInt();
  int channels = headerData.readUnsignedByte();
  long sampleRate = headerData.readLittleEndianUnsignedInt();
  int bitrateMax = headerData.readLittleEndianInt();
  int bitrateNominal = headerData.readLittleEndianInt();
  int bitrateMin = headerData.readLittleEndianInt();

  int blockSize = headerData.readUnsignedByte();
  int blockSize0 = (int) Math.pow(2, blockSize & 0x0F);
  int blockSize1 = (int) Math.pow(2, (blockSize & 0xF0) >> 4);

  boolean framingFlag = (headerData.readUnsignedByte() & 0x01) > 0;
  // raw data of vorbis setup header has to be passed to decoder as CSD buffer #1
  byte[] data = Arrays.copyOf(headerData.data, headerData.limit());

  return new VorbisIdHeader(version, channels, sampleRate, bitrateMax, bitrateNominal, bitrateMin,
      blockSize0, blockSize1, framingFlag, data);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:33,代码来源:VorbisUtil.java

示例2: peek

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Peeks and returns a {@link ChunkHeader}.
 *
 * @param input Input stream to peek the chunk header from.
 * @param scratch Buffer for temporary use.
 * @throws IOException If peeking from the input fails.
 * @throws InterruptedException If interrupted while peeking from input.
 * @return A new {@code ChunkHeader} peeked from {@code input}.
 */
public static ChunkHeader peek(ExtractorInput input, ParsableByteArray scratch)
    throws IOException, InterruptedException {
  input.peekFully(scratch.data, 0, SIZE_IN_BYTES);
  scratch.setPosition(0);

  int id = scratch.readInt();
  long size = scratch.readLittleEndianUnsignedInt();

  return new ChunkHeader(id, size);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:20,代码来源:WavHeaderReader.java

示例3: readVorbisCommentHeader

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Reads a vorbis comment header.
 *
 * @see <a href="https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-640004.2.3">
 *     Vorbis spec/Comment header</a>
 * @param headerData a {@link ParsableByteArray} wrapping the header data.
 * @return a {@link VorbisUtil.CommentHeader} with all the comments.
 * @throws ParserException thrown if invalid capture pattern is detected.
 */
public static CommentHeader readVorbisCommentHeader(ParsableByteArray headerData)
    throws ParserException {

  verifyVorbisHeaderCapturePattern(0x03, headerData, false);
  int length = 7;

  int len = (int) headerData.readLittleEndianUnsignedInt();
  length += 4;
  String vendor = headerData.readString(len);
  length += vendor.length();

  long commentListLen = headerData.readLittleEndianUnsignedInt();
  String[] comments = new String[(int) commentListLen];
  length += 4;
  for (int i = 0; i < commentListLen; i++) {
    len = (int) headerData.readLittleEndianUnsignedInt();
    length += 4;
    comments[i] = headerData.readString(len);
    length += comments[i].length();
  }
  if ((headerData.readUnsignedByte() & 0x01) == 0) {
    throw new ParserException("framing bit expected to be set");
  }
  length += 1;
  return new CommentHeader(vendor, comments, length);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:36,代码来源:VorbisUtil.java

示例4: parseFourCcVc1Private

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Builds initialization data for a {@link Format} from FourCC codec private data.
 * <p>
 * VC1 is the only supported compression type.
 *
 * @return The initialization data for the {@link Format}, or null if the compression type is
 *     not VC1.
 * @throws ParserException If the initialization data could not be built.
 */
private static List<byte[]> parseFourCcVc1Private(ParsableByteArray buffer)
    throws ParserException {
  try {
    buffer.skipBytes(16); // size(4), width(4), height(4), planes(2), bitcount(2).
    long compression = buffer.readLittleEndianUnsignedInt();
    if (compression != FOURCC_COMPRESSION_VC1) {
      return null;
    }

    // Search for the initialization data from the end of the BITMAPINFOHEADER. The last 20
    // bytes of which are: sizeImage(4), xPel/m (4), yPel/m (4), clrUsed(4), clrImportant(4).
    int startOffset = buffer.getPosition() + 20;
    byte[] bufferData = buffer.data;
    for (int offset = startOffset; offset < bufferData.length - 4; offset++) {
      if (bufferData[offset] == 0x00 && bufferData[offset + 1] == 0x00
          && bufferData[offset + 2] == 0x01 && bufferData[offset + 3] == 0x0F) {
        // We've found the initialization data.
        byte[] initializationData = Arrays.copyOfRange(bufferData, offset, bufferData.length);
        return Collections.singletonList(initializationData);
      }
    }

    throw new ParserException("Failed to find FourCC VC1 initialization data");
  } catch (ArrayIndexOutOfBoundsException e) {
    throw new ParserException("Error parsing FourCC VC1 codec private");
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:37,代码来源:MatroskaExtractor.java


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