c233bdbaee
* Maximum window size in 32-bit mode is 1GB, since allocations for 2GB fail on my Mac. * Maximum window size in 64-bit mode is 2GB, since that is the largest power of 2 that works with the overflow prevention. * Allow `--long=windowLog` to set the window log, along with `--zstd=wlog=#`. These options also set the window size during decompression, but don't override `--memory=#` if it is set. * Present a helpful error message when the window size is too large during decompression. * The long range matcher defaults to a hash log 7 less than the window log, which keeps it at 20 for window log 27. * Keep the default long range matcher window size and the default maximum window size at 27 for the API and CLI. * Add tests that use the maximum window size and hash size for compression and decompression.
68 lines
2.3 KiB
C
68 lines
2.3 KiB
C
/*
|
|
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under both the BSD-style license (found in the
|
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
|
* in the COPYING file in the root directory of this source tree).
|
|
*/
|
|
|
|
#ifndef ZSTD_LDM_H
|
|
#define ZSTD_LDM_H
|
|
|
|
#include "zstd_compress.h"
|
|
|
|
#if defined (__cplusplus)
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*-*************************************
|
|
* Long distance matching
|
|
***************************************/
|
|
|
|
#define ZSTD_LDM_DEFAULT_WINDOW_LOG ZSTD_WINDOWLOG_DEFAULTMAX
|
|
#define ZSTD_LDM_HASHEVERYLOG_NOTSET 9999
|
|
|
|
/** ZSTD_compressBlock_ldm_generic() :
|
|
*
|
|
* This is a block compressor intended for long distance matching.
|
|
*
|
|
* The function searches for matches of length at least
|
|
* ldmParams.minMatchLength using a hash table in cctx->ldmState.
|
|
* Matches can be at a distance of up to cParams.windowLog.
|
|
*
|
|
* Upon finding a match, the unmatched literals are compressed using a
|
|
* ZSTD_blockCompressor (depending on the strategy in the compression
|
|
* parameters), which stores the matched sequences. The "long distance"
|
|
* match is then stored with the remaining literals from the
|
|
* ZSTD_blockCompressor. */
|
|
size_t ZSTD_compressBlock_ldm(ZSTD_CCtx* cctx, const void* src, size_t srcSize);
|
|
size_t ZSTD_compressBlock_ldm_extDict(ZSTD_CCtx* ctx,
|
|
const void* src, size_t srcSize);
|
|
|
|
/** ZSTD_ldm_initializeParameters() :
|
|
* Initialize the long distance matching parameters to their default values. */
|
|
size_t ZSTD_ldm_initializeParameters(ldmParams_t* params, U32 enableLdm);
|
|
|
|
/** ZSTD_ldm_getTableSize() :
|
|
* Estimate the space needed for long distance matching tables. */
|
|
size_t ZSTD_ldm_getTableSize(U32 hashLog, U32 bucketSizeLog);
|
|
|
|
/** ZSTD_ldm_getTableSize() :
|
|
* Return prime8bytes^(minMatchLength-1) */
|
|
U64 ZSTD_ldm_getHashPower(U32 minMatchLength);
|
|
|
|
/** ZSTD_ldm_adjustParameters() :
|
|
* If the params->hashEveryLog is not set, set it to its default value based on
|
|
* windowLog and params->hashLog.
|
|
*
|
|
* Ensures that params->bucketSizeLog is <= params->hashLog (setting it to
|
|
* params->hashLog if it is not). */
|
|
void ZSTD_ldm_adjustParameters(ldmParams_t* params, U32 windowLog);
|
|
|
|
#if defined (__cplusplus)
|
|
}
|
|
#endif
|
|
|
|
#endif /* ZSTD_FAST_H */
|