Skip to content

What we pass to BZIP3 Backend

Peter Hyman edited this page Feb 2, 2023 · 1 revision

BZIP3 gets a block size

lrzip-next takes as input a BZIP3 block size code from 0 to 8, associated with lrzip-next compression levels 1 to 9. These are converted to absolute block sizes Using the macro:
#define BZIP3_BLOCK_SIZE_FROM_PROP(p) (p == 8 ? 0x1FFFFFFF : (((u32)2 | ((p) & 1)) << ((p) / 2 + 24)))
which was adapted from lzma2 code.

lrzip-next level BZIP3 bs code BZIP3 Block Size
1 0 32MB
2 1 48MB
3 2 64MB
4 3 96MB
5 4 128MB
6 5 196MB
7 6 256MB
8 7 384MB
9 8 512MB-1

The BZIP3 Block Size is used to set up the state structure for compression/decompression.

struct bz3_state *state;
...
state = bz3_new(control->bzip3_block_size);	// allocate bzip3 state
if (!state)
  fatal("Failed to allocate %'"PRIu32" bytes bzip3 state.\n", control->bzip3_block_size);