mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-28 04:25:27 +00:00
Adjust LZ4F block size
This commit is contained in:
parent
0f92d1de1b
commit
f28bd1972f
@ -410,7 +410,7 @@ bool LZ4FEncoder::update(const void *in, size_t size) {
|
|||||||
auto inbuf = (const uint8_t *) in;
|
auto inbuf = (const uint8_t *) in;
|
||||||
size_t read, write;
|
size_t read, write;
|
||||||
do {
|
do {
|
||||||
read = size > CHUNK ? CHUNK : size;
|
read = size > BLOCK_SZ ? BLOCK_SZ : size;
|
||||||
write = LZ4F_compressUpdate(ctx, outbuf, outCapacity, inbuf, read, nullptr);
|
write = LZ4F_compressUpdate(ctx, outbuf, outCapacity, inbuf, read, nullptr);
|
||||||
if (LZ4F_isError(write)) {
|
if (LZ4F_isError(write)) {
|
||||||
LOGW("LZ4 encode error: %s\n", LZ4F_getErrorName(write));
|
LOGW("LZ4 encode error: %s\n", LZ4F_getErrorName(write));
|
||||||
@ -442,7 +442,7 @@ void LZ4FEncoder::write_header() {
|
|||||||
.contentChecksumFlag = LZ4F_contentChecksumEnabled
|
.contentChecksumFlag = LZ4F_contentChecksumEnabled
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
outCapacity = LZ4F_compressBound(CHUNK, &prefs);
|
outCapacity = LZ4F_compressBound(BLOCK_SZ, &prefs);
|
||||||
outbuf = new uint8_t[outCapacity];
|
outbuf = new uint8_t[outCapacity];
|
||||||
size_t write = LZ4F_compressBegin(ctx, outbuf, outCapacity, &prefs);
|
size_t write = LZ4F_compressBegin(ctx, outbuf, outCapacity, &prefs);
|
||||||
total += write;
|
total += write;
|
||||||
|
@ -140,6 +140,7 @@ public:
|
|||||||
uint64_t finalize() override;
|
uint64_t finalize() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static constexpr size_t BLOCK_SZ = 1 << 22;
|
||||||
LZ4F_compressionContext_t ctx;
|
LZ4F_compressionContext_t ctx;
|
||||||
uint8_t *outbuf;
|
uint8_t *outbuf;
|
||||||
size_t outCapacity;
|
size_t outCapacity;
|
||||||
|
Loading…
Reference in New Issue
Block a user