Skip to content

Commit

Permalink
tighter lzp/rle bounds in encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
kspalaiologos committed Dec 9, 2024
1 parent cc87a80 commit 187b322
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libbz3.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,14 @@ BZIP3_API s32 bz3_encode_block(struct bz3_state * state, u8 * buffer, s32 data_s
s32 lzp_size, rle_size;

rle_size = mrlec(b1, data_size, b2);
if (rle_size < data_size + 64) {
if (rle_size < data_size) {
swap(b1, b2);
data_size = rle_size;
model |= 4;
}

lzp_size = lzp_compress(b1, b2, data_size, state->lzp_lut);
if (lzp_size > 0 && lzp_size < data_size + 64) {
if (lzp_size > 0 && lzp_size < data_size) {
swap(b1, b2);
data_size = lzp_size;
model |= 2;
Expand Down

0 comments on commit 187b322

Please sign in to comment.