zstd_ldm.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under both the BSD-style license (found in the
  6. * LICENSE file in the root directory of this source tree) and the GPLv2 (found
  7. * in the COPYING file in the root directory of this source tree).
  8. */
  9. #ifndef ZSTD_LDM_H
  10. #define ZSTD_LDM_H
  11. #include "zstd_compress.h"
  12. #if defined (__cplusplus)
  13. extern "C" {
  14. #endif
  15. /*-*************************************
  16. * Long distance matching
  17. ***************************************/
  18. #define ZSTD_LDM_DEFAULT_WINDOW_LOG ZSTD_WINDOWLOG_DEFAULTMAX
  19. #define ZSTD_LDM_HASHEVERYLOG_NOTSET 9999
  20. /** ZSTD_compressBlock_ldm_generic() :
  21. *
  22. * This is a block compressor intended for long distance matching.
  23. *
  24. * The function searches for matches of length at least
  25. * ldmParams.minMatchLength using a hash table in cctx->ldmState.
  26. * Matches can be at a distance of up to cParams.windowLog.
  27. *
  28. * Upon finding a match, the unmatched literals are compressed using a
  29. * ZSTD_blockCompressor (depending on the strategy in the compression
  30. * parameters), which stores the matched sequences. The "long distance"
  31. * match is then stored with the remaining literals from the
  32. * ZSTD_blockCompressor. */
  33. size_t ZSTD_compressBlock_ldm(ZSTD_CCtx* cctx, const void* src, size_t srcSize);
  34. size_t ZSTD_compressBlock_ldm_extDict(ZSTD_CCtx* ctx,
  35. const void* src, size_t srcSize);
  36. /** ZSTD_ldm_initializeParameters() :
  37. * Initialize the long distance matching parameters to their default values. */
  38. size_t ZSTD_ldm_initializeParameters(ldmParams_t* params, U32 enableLdm);
  39. /** ZSTD_ldm_getTableSize() :
  40. * Estimate the space needed for long distance matching tables. */
  41. size_t ZSTD_ldm_getTableSize(U32 hashLog, U32 bucketSizeLog);
  42. /** ZSTD_ldm_getTableSize() :
  43. * Return prime8bytes^(minMatchLength-1) */
  44. U64 ZSTD_ldm_getHashPower(U32 minMatchLength);
  45. /** ZSTD_ldm_adjustParameters() :
  46. * If the params->hashEveryLog is not set, set it to its default value based on
  47. * windowLog and params->hashLog.
  48. *
  49. * Ensures that params->bucketSizeLog is <= params->hashLog (setting it to
  50. * params->hashLog if it is not). */
  51. void ZSTD_ldm_adjustParameters(ldmParams_t* params, U32 windowLog);
  52. #if defined (__cplusplus)
  53. }
  54. #endif
  55. #endif /* ZSTD_FAST_H */