estimateCompressedSize
Estimate the maximum compressed output size for a given input size and format.
This function returns an upper bound suitable for pre-allocating output buffers. The actual compressed size may be smaller (for compressible data) or close to this bound (for incompressible/random data).
Parameters
fmt | The compression format to estimate for. |
inputSize | Size of the uncompressed input data in bytes. |
Returns
Upper bound estimate of compressed size in bytes.
Examples
---
// Pre-allocate buffer for GZIP compression auto inputData = cast(ubyte[])"Hello, World!"; auto bufferSize = estimateCompressedSize(CompressionFormat.GZIP, inputData.length); auto outputBuffer = new ubyte[](bufferSize); ---