/** * Decompress GZIP-compressed data * @param uncompressedBlock must be big enough to hold decompressed output. * @param compressedBlock compressed data starting at offset 0 * @param compressedLength size of compressed data, possibly less than the size of the buffer. * @return the uncompressed data size. */ public int unzipBlock(byte[] uncompressedBlock, byte[] compressedBlock, int compressedLength) { return unzipBlock(uncompressedBlock, 0, compressedBlock, 0, compressedLength); }
/** * Decompress GZIP-compressed data * @param uncompressedBlock must be big enough to hold decompressed output. * @param compressedBlock compressed data starting at offset 0 * @param compressedLength size of compressed data, possibly less than the size of the buffer. * @return the uncompressed data size. */ public int unzipBlock(byte[] uncompressedBlock, byte[] compressedBlock, int compressedLength) { return unzipBlock(uncompressedBlock, 0, compressedBlock, 0, compressedLength); }
private void inflateBlock(final byte[] compressedBlock, final int compressedLength) throws IOException { final int uncompressedLength = unpackInt32(compressedBlock, compressedLength-4); byte[] buffer = mCurrentBlock; mCurrentBlock = null; if (buffer == null || buffer.length != uncompressedLength) { try { buffer = new byte[uncompressedLength]; } catch (final NegativeArraySizeException e) { throw new RuntimeException("BGZF file has invalid uncompressedLength: " + uncompressedLength, e); } } blockGunzipper.unzipBlock(buffer, compressedBlock, compressedLength); mCurrentBlock = buffer; }
public void decompress(byte[] availableDecompressionBuffer, BlockGunzipper inflator) { if (mCompressedBlock == null || mCompressedBlock.length == 0) { mDecompressedBlock = EMPTY_BLOCK; return; } final int uncompressedLength = unpackInt32(mCompressedBlock, mBlockCompressedSize - 4); if (uncompressedLength < 0) { throw new RuntimeIOException(getSource() + " has invalid uncompressedLength: " + uncompressedLength); } else { mDecompressedBlock = availableDecompressionBuffer; if (mDecompressedBlock == null || uncompressedLength != mDecompressedBlock.length) { // can't reuse the buffer since the size is incorrect mDecompressedBlock = new byte[uncompressedLength]; } inflator.unzipBlock(mDecompressedBlock, mCompressedBlock, mBlockCompressedSize); } }
private byte[] inflateBlock(final byte[] compressedBlock, final int compressedLength, final byte[] bufferAvailableForReuse) throws IOException { final int uncompressedLength = unpackInt32(compressedBlock, compressedLength - 4); if (uncompressedLength < 0) { throw new RuntimeIOException(getSource() + " has invalid uncompressedLength: " + uncompressedLength); } byte[] buffer = bufferAvailableForReuse; if (buffer == null || uncompressedLength != buffer.length) { // can't reuse the buffer since the size is incorrect buffer = new byte[uncompressedLength]; } blockGunzipper.unzipBlock(buffer, compressedBlock, compressedLength); return buffer; }
private byte[] inflateBlock(final byte[] compressedBlock, final int compressedLength, final byte[] bufferAvailableForReuse) throws IOException { final int uncompressedLength = unpackInt32(compressedBlock, compressedLength - 4); if (uncompressedLength < 0) { throw new RuntimeIOException(getSource() + " has invalid uncompressedLength: " + uncompressedLength); } byte[] buffer = bufferAvailableForReuse; if (buffer == null || uncompressedLength != buffer.length) { // can't reuse the buffer since the size is incorrect buffer = new byte[uncompressedLength]; } blockGunzipper.unzipBlock(buffer, compressedBlock, compressedLength); return buffer; }