-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cmp] add ztsd image compression support
* Based on the latest Bled, which adds ztsd compression support. * Note that initial extraction of the 512 bytes MBR is very slow, because is seems clear that ZSTD was never designed for fast init or processing small elements of data, but instead for post init large volume streaming. * Also note that this code adds 400 KB to the Rufus executable *AFTER UPX COMPRESSION*! Hopefully, the BusyBox folks can come up with a better and smaller way to add zstd support, because it's clear that the method used by the current BusyBox proposal, which is to leave as much of the original code untouched, isn't for the best... * Closes #2590. * Closes #2620. * Closes #2621.
- Loading branch information
Showing
38 changed files
with
10,440 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* Bled (Base Library for Easy Decompression) | ||
* | ||
* Copyright © 2014-2023 Pete Batard <[email protected]> | ||
* Copyright © 2014-2024 Pete Batard <[email protected]> | ||
* | ||
* Licensed under GPLv2 or later, see file LICENSE in this source tree. | ||
*/ | ||
|
@@ -31,7 +31,9 @@ jmp_buf bb_error_jmp; | |
char* bb_virtual_buf = NULL; | ||
size_t bb_virtual_len = 0, bb_virtual_pos = 0; | ||
int bb_virtual_fd = -1; | ||
uint32_t BB_BUFSIZE = 0x10000; | ||
// ZSTD has a minimal buffer size of (1 << ZSTD_BLOCKSIZELOG_MAX) + ZSTD_blockHeaderSize = 128 KB + 3 | ||
// So we set our bufsize to 256 KB | ||
uint32_t BB_BUFSIZE = 0x40000; | ||
|
||
static long long int unpack_none(transformer_state_t *xstate) | ||
{ | ||
|
@@ -49,6 +51,7 @@ unpacker_t unpacker[BLED_COMPRESSION_MAX] = { | |
unpack_xz_stream, | ||
unpack_none, | ||
unpack_vtsi_stream, | ||
unpack_zstd_stream, | ||
}; | ||
|
||
/* Uncompress file 'src', compressed using 'type', to file 'dst' */ | ||
|
@@ -267,7 +270,7 @@ int64_t bled_uncompress_from_buffer_to_buffer(const char* src, const size_t src_ | |
|
||
/* Initialize the library. | ||
* When the parameters are not NULL or zero you can: | ||
* - specify the buffer size to use (must be larger than 64KB and a power of two) | ||
* - specify the buffer size to use (must be larger than 256KB and a power of two) | ||
* - specify the printf-like function you want to use to output message | ||
* void print_function(const char* format, ...); | ||
* - specify the read/write functions you want to use; | ||
|
@@ -283,11 +286,11 @@ int bled_init(uint32_t buffer_size, printf_t print_function, read_t read_functio | |
if (bled_initialized) | ||
return -1; | ||
BB_BUFSIZE = buffer_size; | ||
/* buffer_size must be larger than 64 KB and a power of two */ | ||
if (buffer_size < 0x10000 || (buffer_size & (buffer_size - 1)) != 0) { | ||
/* buffer_size must be larger than 256 KB and a power of two */ | ||
if (buffer_size < 0x40000 || (buffer_size & (buffer_size - 1)) != 0) { | ||
if (buffer_size != 0 && print_function != NULL) | ||
print_function("bled_init: invalid buffer_size, defaulting to 64 KB"); | ||
BB_BUFSIZE = 0x10000; | ||
BB_BUFSIZE = 0x40000; | ||
} | ||
bled_printf = print_function; | ||
bled_read = read_function; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* Bled (Base Library for Easy Decompression) | ||
* | ||
* Copyright © 2014-2015 Pete Batard <[email protected]> | ||
* Copyright © 2014-2024 Pete Batard <[email protected]> | ||
* | ||
* Licensed under GPLv2 or later, see file LICENSE in this source tree. | ||
*/ | ||
|
@@ -31,6 +31,7 @@ typedef enum { | |
BLED_COMPRESSION_XZ, // .xz | ||
BLED_COMPRESSION_7ZIP, // .7z | ||
BLED_COMPRESSION_VTSI, // .vtsi | ||
BLED_COMPRESSION_ZSTD, // .zst | ||
BLED_COMPRESSION_MAX | ||
} bled_compression_type; | ||
|
||
|
Oops, something went wrong.