mirror of
https://github.com/facebook/zstd.git
synced 2024-11-28 10:36:45 +08:00
Allow negative compression levels in training
* Set `dictCLevel` in `zstdcli.c`. * Only set to default level if the compression level `== 0`, not `<= 0`.
This commit is contained in:
parent
daf3ab0aad
commit
569e2abccd
@ -724,7 +724,7 @@ static size_t ZDICT_analyzeEntropy(void* dstBuffer, size_t maxDstSize,
|
|||||||
memset(repOffset, 0, sizeof(repOffset));
|
memset(repOffset, 0, sizeof(repOffset));
|
||||||
repOffset[1] = repOffset[4] = repOffset[8] = 1;
|
repOffset[1] = repOffset[4] = repOffset[8] = 1;
|
||||||
memset(bestRepOffset, 0, sizeof(bestRepOffset));
|
memset(bestRepOffset, 0, sizeof(bestRepOffset));
|
||||||
if (compressionLevel<=0) compressionLevel = g_compressionLevel_default;
|
if (compressionLevel==0) compressionLevel = g_compressionLevel_default;
|
||||||
params = ZSTD_getParams(compressionLevel, averageSampleSize, dictBufferSize);
|
params = ZSTD_getParams(compressionLevel, averageSampleSize, dictBufferSize);
|
||||||
{ size_t const beginResult = ZSTD_compressBegin_advanced(esr.ref, dictBuffer, dictBufferSize, params, 0);
|
{ size_t const beginResult = ZSTD_compressBegin_advanced(esr.ref, dictBuffer, dictBufferSize, params, 0);
|
||||||
if (ZSTD_isError(beginResult)) {
|
if (ZSTD_isError(beginResult)) {
|
||||||
@ -873,7 +873,7 @@ size_t ZDICT_finalizeDictionary(void* dictBuffer, size_t dictBufferCapacity,
|
|||||||
size_t hSize;
|
size_t hSize;
|
||||||
#define HBUFFSIZE 256 /* should prove large enough for all entropy headers */
|
#define HBUFFSIZE 256 /* should prove large enough for all entropy headers */
|
||||||
BYTE header[HBUFFSIZE];
|
BYTE header[HBUFFSIZE];
|
||||||
int const compressionLevel = (params.compressionLevel <= 0) ? g_compressionLevel_default : params.compressionLevel;
|
int const compressionLevel = (params.compressionLevel == 0) ? g_compressionLevel_default : params.compressionLevel;
|
||||||
U32 const notificationLevel = params.notificationLevel;
|
U32 const notificationLevel = params.notificationLevel;
|
||||||
|
|
||||||
/* check conditions */
|
/* check conditions */
|
||||||
@ -918,7 +918,7 @@ size_t ZDICT_addEntropyTablesFromBuffer_advanced(void* dictBuffer, size_t dictCo
|
|||||||
const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
|
const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
|
||||||
ZDICT_params_t params)
|
ZDICT_params_t params)
|
||||||
{
|
{
|
||||||
int const compressionLevel = (params.compressionLevel <= 0) ? g_compressionLevel_default : params.compressionLevel;
|
int const compressionLevel = (params.compressionLevel == 0) ? g_compressionLevel_default : params.compressionLevel;
|
||||||
U32 const notificationLevel = params.notificationLevel;
|
U32 const notificationLevel = params.notificationLevel;
|
||||||
size_t hSize = 8;
|
size_t hSize = 8;
|
||||||
|
|
||||||
|
@ -550,7 +550,9 @@ int main(int argCount, const char* argv[])
|
|||||||
U32 fastLevel;
|
U32 fastLevel;
|
||||||
++argument;
|
++argument;
|
||||||
fastLevel = readU32FromChar(&argument);
|
fastLevel = readU32FromChar(&argument);
|
||||||
if (fastLevel) cLevel = - (int)fastLevel;
|
if (fastLevel) {
|
||||||
|
dictCLevel = cLevel = -(int)fastLevel;
|
||||||
|
}
|
||||||
} else if (*argument != 0) {
|
} else if (*argument != 0) {
|
||||||
/* Invalid character following --fast */
|
/* Invalid character following --fast */
|
||||||
CLEAN_RETURN(badusage(programName));
|
CLEAN_RETURN(badusage(programName));
|
||||||
|
Loading…
Reference in New Issue
Block a user