reduced memory usage of very hich compression levels in 32-bits mode
This commit is contained in:
parent
1535414927
commit
1005fc1276
@ -2525,7 +2525,7 @@ static const ZSTD_compressionParameters ZSTD_defaultCParameters[4][ZSTD_MAX_CLEV
|
|||||||
ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, U64 srcSize, size_t dictSize)
|
ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, U64 srcSize, size_t dictSize)
|
||||||
{
|
{
|
||||||
ZSTD_compressionParameters cp;
|
ZSTD_compressionParameters cp;
|
||||||
size_t addedSize = srcSize ? 0 : 500;
|
size_t const addedSize = srcSize ? 0 : 500;
|
||||||
U64 const rSize = srcSize+dictSize ? srcSize+dictSize+addedSize : (U64)-1;
|
U64 const rSize = srcSize+dictSize ? srcSize+dictSize+addedSize : (U64)-1;
|
||||||
U32 const tableID = (rSize <= 256 KB) + (rSize <= 128 KB) + (rSize <= 16 KB); /* intentional underflow for srcSizeHint == 0 */
|
U32 const tableID = (rSize <= 256 KB) + (rSize <= 128 KB) + (rSize <= 16 KB); /* intentional underflow for srcSizeHint == 0 */
|
||||||
if (compressionLevel<=0) compressionLevel = 1;
|
if (compressionLevel<=0) compressionLevel = 1;
|
||||||
@ -2534,6 +2534,10 @@ ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, U64 srcSize, si
|
|||||||
tableID=0;
|
tableID=0;
|
||||||
#endif
|
#endif
|
||||||
cp = ZSTD_defaultCParameters[tableID][compressionLevel];
|
cp = ZSTD_defaultCParameters[tableID][compressionLevel];
|
||||||
if (cp.windowLog > ZSTD_WINDOWLOG_MAX) cp.windowLog = ZSTD_WINDOWLOG_MAX; /* auto-correction, for 32-bits mode */
|
if (MEM_32bits()) { /* auto-correction, for 32-bits mode */
|
||||||
|
if (cp.windowLog > ZSTD_WINDOWLOG_MAX) cp.windowLog = ZSTD_WINDOWLOG_MAX;
|
||||||
|
if (cp.contentLog > ZSTD_CONTENTLOG_MAX) cp.contentLog = ZSTD_CONTENTLOG_MAX;
|
||||||
|
if (cp.hashLog > ZSTD_HASHLOG_MAX) cp.hashLog = ZSTD_HASHLOG_MAX;
|
||||||
|
}
|
||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
|
@ -61,9 +61,9 @@ extern "C" {
|
|||||||
#define ZSTD_WINDOWLOG_MIN 18
|
#define ZSTD_WINDOWLOG_MIN 18
|
||||||
#define ZSTD_CONTENTLOG_MAX (ZSTD_WINDOWLOG_MAX+1)
|
#define ZSTD_CONTENTLOG_MAX (ZSTD_WINDOWLOG_MAX+1)
|
||||||
#define ZSTD_CONTENTLOG_MIN 4
|
#define ZSTD_CONTENTLOG_MIN 4
|
||||||
#define ZSTD_HASHLOG_MAX 28
|
#define ZSTD_HASHLOG_MAX ZSTD_WINDOWLOG_MAX
|
||||||
#define ZSTD_HASHLOG_MIN 12
|
#define ZSTD_HASHLOG_MIN 12
|
||||||
#define ZSTD_SEARCHLOG_MAX (ZSTD_CONTENTLOG_MAX-1)
|
#define ZSTD_SEARCHLOG_MAX (ZSTD_WINDOWLOG_MAX-1)
|
||||||
#define ZSTD_SEARCHLOG_MIN 1
|
#define ZSTD_SEARCHLOG_MIN 1
|
||||||
#define ZSTD_SEARCHLENGTH_MAX 7
|
#define ZSTD_SEARCHLENGTH_MAX 7
|
||||||
#define ZSTD_SEARCHLENGTH_MIN 3
|
#define ZSTD_SEARCHLENGTH_MIN 3
|
||||||
|
Loading…
Reference in New Issue
Block a user