10c16b537SWarner Losh /* 20c16b537SWarner Losh * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. 30c16b537SWarner Losh * All rights reserved. 40c16b537SWarner Losh * 50c16b537SWarner Losh * This source code is licensed under both the BSD-style license (found in the 60c16b537SWarner Losh * LICENSE file in the root directory of this source tree) and the GPLv2 (found 70c16b537SWarner Losh * in the COPYING file in the root directory of this source tree). 80c16b537SWarner Losh */ 90c16b537SWarner Losh 100c16b537SWarner Losh #ifndef ZSTD_LDM_H 110c16b537SWarner Losh #define ZSTD_LDM_H 120c16b537SWarner Losh 130c16b537SWarner Losh #if defined (__cplusplus) 140c16b537SWarner Losh extern "C" { 150c16b537SWarner Losh #endif 160c16b537SWarner Losh 17*052d3c12SConrad Meyer #include "zstd_compress_internal.h" /* ldmParams_t, U32 */ 18*052d3c12SConrad Meyer #include "zstd.h" /* ZSTD_CCtx, size_t */ 19*052d3c12SConrad Meyer 200c16b537SWarner Losh /*-************************************* 210c16b537SWarner Losh * Long distance matching 220c16b537SWarner Losh ***************************************/ 230c16b537SWarner Losh 240c16b537SWarner Losh #define ZSTD_LDM_DEFAULT_WINDOW_LOG ZSTD_WINDOWLOG_DEFAULTMAX 250c16b537SWarner Losh #define ZSTD_LDM_HASHEVERYLOG_NOTSET 9999 260c16b537SWarner Losh 270c16b537SWarner Losh /** ZSTD_compressBlock_ldm_generic() : 280c16b537SWarner Losh * 290c16b537SWarner Losh * This is a block compressor intended for long distance matching. 300c16b537SWarner Losh * 310c16b537SWarner Losh * The function searches for matches of length at least 320c16b537SWarner Losh * ldmParams.minMatchLength using a hash table in cctx->ldmState. 330c16b537SWarner Losh * Matches can be at a distance of up to cParams.windowLog. 340c16b537SWarner Losh * 350c16b537SWarner Losh * Upon finding a match, the unmatched literals are compressed using a 360c16b537SWarner Losh * ZSTD_blockCompressor (depending on the strategy in the compression 370c16b537SWarner Losh * parameters), which stores the matched sequences. The "long distance" 380c16b537SWarner Losh * match is then stored with the remaining literals from the 390c16b537SWarner Losh * ZSTD_blockCompressor. */ 400c16b537SWarner Losh size_t ZSTD_compressBlock_ldm(ZSTD_CCtx* cctx, const void* src, size_t srcSize); 410c16b537SWarner Losh size_t ZSTD_compressBlock_ldm_extDict(ZSTD_CCtx* ctx, 420c16b537SWarner Losh const void* src, size_t srcSize); 430c16b537SWarner Losh 440c16b537SWarner Losh /** ZSTD_ldm_initializeParameters() : 450c16b537SWarner Losh * Initialize the long distance matching parameters to their default values. */ 460c16b537SWarner Losh size_t ZSTD_ldm_initializeParameters(ldmParams_t* params, U32 enableLdm); 470c16b537SWarner Losh 480c16b537SWarner Losh /** ZSTD_ldm_getTableSize() : 490c16b537SWarner Losh * Estimate the space needed for long distance matching tables. */ 500c16b537SWarner Losh size_t ZSTD_ldm_getTableSize(U32 hashLog, U32 bucketSizeLog); 510c16b537SWarner Losh 520c16b537SWarner Losh /** ZSTD_ldm_getTableSize() : 530c16b537SWarner Losh * Return prime8bytes^(minMatchLength-1) */ 540c16b537SWarner Losh U64 ZSTD_ldm_getHashPower(U32 minMatchLength); 550c16b537SWarner Losh 560c16b537SWarner Losh /** ZSTD_ldm_adjustParameters() : 570c16b537SWarner Losh * If the params->hashEveryLog is not set, set it to its default value based on 580c16b537SWarner Losh * windowLog and params->hashLog. 590c16b537SWarner Losh * 600c16b537SWarner Losh * Ensures that params->bucketSizeLog is <= params->hashLog (setting it to 610c16b537SWarner Losh * params->hashLog if it is not). */ 620c16b537SWarner Losh void ZSTD_ldm_adjustParameters(ldmParams_t* params, U32 windowLog); 630c16b537SWarner Losh 640c16b537SWarner Losh #if defined (__cplusplus) 650c16b537SWarner Losh } 660c16b537SWarner Losh #endif 670c16b537SWarner Losh 680c16b537SWarner Losh #endif /* ZSTD_FAST_H */ 69