com.google.android.exoplayer2.util.Util.inflate()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(180)

本文整理了Java中com.google.android.exoplayer2.util.Util.inflate()方法的一些代码示例,展示了Util.inflate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.inflate()方法的具体详情如下:
包路径:com.google.android.exoplayer2.util.Util
类名称:Util
方法名:inflate

Util.inflate介绍

[英]Uncompresses the data in input.
[中]解压缩输入中的数据。

代码示例

代码示例来源:origin: google/ExoPlayer

private void maybeInflateData(ParsableByteArray buffer) {
 if (buffer.bytesLeft() > 0 && buffer.peekUnsignedByte() == INFLATE_HEADER) {
  if (inflater == null) {
   inflater = new Inflater();
  }
  if (Util.inflate(buffer, inflatedBuffer, inflater)) {
   buffer.reset(inflatedBuffer.data, inflatedBuffer.limit());
  } // else assume data is not compressed.
 }
}

代码示例来源:origin: google/ExoPlayer

private static @Nullable ArrayList<Mesh> parseMshp(ParsableByteArray input) {
 int version = input.readUnsignedByte();
 if (version != 0) {
  return null;
 }
 input.skipBytes(7); // flags + crc.
 int encoding = input.readInt();
 if (encoding == TYPE_DFL8) {
  ParsableByteArray output = new ParsableByteArray();
  Inflater inflater = new Inflater(true);
  try {
   if (!Util.inflate(input, output, inflater)) {
    return null;
   }
  } finally {
   inflater.end();
  }
  input = output;
 } else if (encoding != TYPE_RAW) {
  return null;
 }
 return parseRawMshpData(input);
}

代码示例来源:origin: google/ExoPlayer

@Test
public void testInflate() {
 byte[] testData = TestUtil.buildTestData(/*arbitrary test data size*/ 256 * 1024);
 byte[] compressedData = new byte[testData.length * 2];
 Deflater compresser = new Deflater(9);
 compresser.setInput(testData);
 compresser.finish();
 int compressedDataLength = compresser.deflate(compressedData);
 compresser.end();
 ParsableByteArray input = new ParsableByteArray(compressedData, compressedDataLength);
 ParsableByteArray output = new ParsableByteArray();
 assertThat(Util.inflate(input, output, /* inflater= */ null)).isTrue();
 assertThat(output.limit()).isEqualTo(testData.length);
 assertThat(Arrays.copyOf(output.data, output.limit())).isEqualTo(testData);
}

相关文章