all: add zstd compression library

This commit is contained in:
Markus F.X.J. Oberhumer
2023-01-13 22:07:24 +01:00
parent c52d302f07
commit 9f830e0c41
10 changed files with 334 additions and 10 deletions
+2
View File
@@ -129,6 +129,8 @@ unsigned MemBuffer::getSizeForCompression(unsigned uncompressed_size, unsigned e
bytes = umax(bytes, (z / 3 * (8 + 2 * (w - 8) / 1)) / 8);
// NRV2E: 1 byte plus 3 bits per pair of width exceeding 7 ("ss12")
bytes = umax(bytes, (z / 3 * (8 + 3 * (w - 7) / 2)) / 8);
// zstd: ZSTD_COMPRESSBOUND
bytes = umax(bytes, z + (z >> 8) + ((z < (128 << 10)) ? (((128 << 10) - z) >> 11) : 0));
// extra + 256 safety for rounding
bytes = mem_size(1, bytes, extra, 256);
return bytes;