mirror of
https://github.com/Xevion/easy7zip.git
synced 2026-01-31 04:24:11 -06:00
.zst, .br: avoid setting of size hint for unknown size by -si, since unpackSize will be supplied as -1 (UINT64_MAX)
This commit is contained in:
@@ -383,7 +383,7 @@ static size_t st_compress(void *arg)
|
|||||||
/* 0, or not specified by user; could be chosen by compressor. */
|
/* 0, or not specified by user; could be chosen by compressor. */
|
||||||
uint32_t lgwin = 24 /* DEFAULT_LGWIN */;
|
uint32_t lgwin = 24 /* DEFAULT_LGWIN */;
|
||||||
/* Use file size to limit lgwin. */
|
/* Use file size to limit lgwin. */
|
||||||
if (ctx->unpackSize >= 0) {
|
if (ctx->unpackSize >= 0 && ctx->unpackSize != (uint64_t)(int64_t)-1) {
|
||||||
lgwin = BROTLI_MIN_WINDOW_BITS;
|
lgwin = BROTLI_MIN_WINDOW_BITS;
|
||||||
while (BROTLI_MAX_BACKWARD_LIMIT(lgwin) <
|
while (BROTLI_MAX_BACKWARD_LIMIT(lgwin) <
|
||||||
(uint64_t)ctx->unpackSize) {
|
(uint64_t)ctx->unpackSize) {
|
||||||
@@ -393,7 +393,7 @@ static size_t st_compress(void *arg)
|
|||||||
}
|
}
|
||||||
BrotliEncoderSetParameter(state, BROTLI_PARAM_LGWIN, lgwin);
|
BrotliEncoderSetParameter(state, BROTLI_PARAM_LGWIN, lgwin);
|
||||||
}
|
}
|
||||||
if (ctx->unpackSize > 0) {
|
if (ctx->unpackSize > 0 && ctx->unpackSize != (uint64_t)(int64_t)-1) {
|
||||||
uint32_t size_hint = ctx->unpackSize < (1 << 30) ?
|
uint32_t size_hint = ctx->unpackSize < (1 << 30) ?
|
||||||
(uint32_t)ctx->unpackSize : (1u << 30);
|
(uint32_t)ctx->unpackSize : (1u << 30);
|
||||||
BrotliEncoderSetParameter(state, BROTLI_PARAM_SIZE_HINT, size_hint);
|
BrotliEncoderSetParameter(state, BROTLI_PARAM_SIZE_HINT, size_hint);
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ CEncoder::CEncoder():
|
|||||||
_numThreads(NWindows::NSystem::GetNumberOfProcessors()),
|
_numThreads(NWindows::NSystem::GetNumberOfProcessors()),
|
||||||
_Long(-1),
|
_Long(-1),
|
||||||
_WindowLog(-1),
|
_WindowLog(-1),
|
||||||
_ctx(NULL)
|
_ctx(NULL),
|
||||||
|
unpackSize(0)
|
||||||
{
|
{
|
||||||
_props.clear();
|
_props.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
|
|||||||
if (ZSTD_isError(err)) return E_INVALIDARG;
|
if (ZSTD_isError(err)) return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unpackSize) {
|
if (unpackSize && unpackSize != (UInt64)(Int64)-1) { // size is known
|
||||||
err = ZSTD_CCtx_setParameter(_ctx, ZSTD_c_srcSizeHint, (int)(unpackSize <= INT_MAX ? unpackSize : INT_MAX));
|
err = ZSTD_CCtx_setParameter(_ctx, ZSTD_c_srcSizeHint, (int)(unpackSize <= INT_MAX ? unpackSize : INT_MAX));
|
||||||
if (ZSTD_isError(err)) return E_INVALIDARG;
|
if (ZSTD_isError(err)) return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user