zstd_lazy.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. * Copyright (c) Meta Platforms, Inc. and affiliates.
  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. * You may select, at your option, one of the above-listed licenses.
  9. */
  10. #ifndef ZSTD_LAZY_H
  11. #define ZSTD_LAZY_H
  12. #if defined (__cplusplus)
  13. extern "C" {
  14. #endif
  15. #include "zstd_compress_internal.h"
  16. /**
  17. * Dedicated Dictionary Search Structure bucket log. In the
  18. * ZSTD_dedicatedDictSearch mode, the hashTable has
  19. * 2 ** ZSTD_LAZY_DDSS_BUCKET_LOG entries in each bucket, rather than just
  20. * one.
  21. */
  22. #define ZSTD_LAZY_DDSS_BUCKET_LOG 2
  23. #define ZSTD_ROW_HASH_TAG_BITS 8 /* nb bits to use for the tag */
  24. #if !defined(ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR) \
  25. || !defined(ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR) \
  26. || !defined(ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR) \
  27. || !defined(ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR)
  28. U32 ZSTD_insertAndFindFirstIndex(ZSTD_matchState_t* ms, const BYTE* ip);
  29. void ZSTD_row_update(ZSTD_matchState_t* const ms, const BYTE* ip);
  30. void ZSTD_dedicatedDictSearch_lazy_loadDictionary(ZSTD_matchState_t* ms, const BYTE* const ip);
  31. void ZSTD_preserveUnsortedMark (U32* const table, U32 const size, U32 const reducerValue); /*! used in ZSTD_reduceIndex(). preemptively increase value of ZSTD_DUBT_UNSORTED_MARK */
  32. #endif
  33. #ifndef ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR
  34. size_t ZSTD_compressBlock_greedy(
  35. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  36. void const* src, size_t srcSize);
  37. size_t ZSTD_compressBlock_greedy_row(
  38. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  39. void const* src, size_t srcSize);
  40. size_t ZSTD_compressBlock_greedy_dictMatchState(
  41. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  42. void const* src, size_t srcSize);
  43. size_t ZSTD_compressBlock_greedy_dictMatchState_row(
  44. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  45. void const* src, size_t srcSize);
  46. size_t ZSTD_compressBlock_greedy_dedicatedDictSearch(
  47. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  48. void const* src, size_t srcSize);
  49. size_t ZSTD_compressBlock_greedy_dedicatedDictSearch_row(
  50. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  51. void const* src, size_t srcSize);
  52. size_t ZSTD_compressBlock_greedy_extDict(
  53. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  54. void const* src, size_t srcSize);
  55. size_t ZSTD_compressBlock_greedy_extDict_row(
  56. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  57. void const* src, size_t srcSize);
  58. #define ZSTD_COMPRESSBLOCK_GREEDY ZSTD_compressBlock_greedy
  59. #define ZSTD_COMPRESSBLOCK_GREEDY_ROW ZSTD_compressBlock_greedy_row
  60. #define ZSTD_COMPRESSBLOCK_GREEDY_DICTMATCHSTATE ZSTD_compressBlock_greedy_dictMatchState
  61. #define ZSTD_COMPRESSBLOCK_GREEDY_DICTMATCHSTATE_ROW ZSTD_compressBlock_greedy_dictMatchState_row
  62. #define ZSTD_COMPRESSBLOCK_GREEDY_DEDICATEDDICTSEARCH ZSTD_compressBlock_greedy_dedicatedDictSearch
  63. #define ZSTD_COMPRESSBLOCK_GREEDY_DEDICATEDDICTSEARCH_ROW ZSTD_compressBlock_greedy_dedicatedDictSearch_row
  64. #define ZSTD_COMPRESSBLOCK_GREEDY_EXTDICT ZSTD_compressBlock_greedy_extDict
  65. #define ZSTD_COMPRESSBLOCK_GREEDY_EXTDICT_ROW ZSTD_compressBlock_greedy_extDict_row
  66. #else
  67. #define ZSTD_COMPRESSBLOCK_GREEDY NULL
  68. #define ZSTD_COMPRESSBLOCK_GREEDY_ROW NULL
  69. #define ZSTD_COMPRESSBLOCK_GREEDY_DICTMATCHSTATE NULL
  70. #define ZSTD_COMPRESSBLOCK_GREEDY_DICTMATCHSTATE_ROW NULL
  71. #define ZSTD_COMPRESSBLOCK_GREEDY_DEDICATEDDICTSEARCH NULL
  72. #define ZSTD_COMPRESSBLOCK_GREEDY_DEDICATEDDICTSEARCH_ROW NULL
  73. #define ZSTD_COMPRESSBLOCK_GREEDY_EXTDICT NULL
  74. #define ZSTD_COMPRESSBLOCK_GREEDY_EXTDICT_ROW NULL
  75. #endif
  76. #ifndef ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR
  77. size_t ZSTD_compressBlock_lazy(
  78. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  79. void const* src, size_t srcSize);
  80. size_t ZSTD_compressBlock_lazy_row(
  81. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  82. void const* src, size_t srcSize);
  83. size_t ZSTD_compressBlock_lazy_dictMatchState(
  84. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  85. void const* src, size_t srcSize);
  86. size_t ZSTD_compressBlock_lazy_dictMatchState_row(
  87. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  88. void const* src, size_t srcSize);
  89. size_t ZSTD_compressBlock_lazy_dedicatedDictSearch(
  90. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  91. void const* src, size_t srcSize);
  92. size_t ZSTD_compressBlock_lazy_dedicatedDictSearch_row(
  93. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  94. void const* src, size_t srcSize);
  95. size_t ZSTD_compressBlock_lazy_extDict(
  96. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  97. void const* src, size_t srcSize);
  98. size_t ZSTD_compressBlock_lazy_extDict_row(
  99. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  100. void const* src, size_t srcSize);
  101. #define ZSTD_COMPRESSBLOCK_LAZY ZSTD_compressBlock_lazy
  102. #define ZSTD_COMPRESSBLOCK_LAZY_ROW ZSTD_compressBlock_lazy_row
  103. #define ZSTD_COMPRESSBLOCK_LAZY_DICTMATCHSTATE ZSTD_compressBlock_lazy_dictMatchState
  104. #define ZSTD_COMPRESSBLOCK_LAZY_DICTMATCHSTATE_ROW ZSTD_compressBlock_lazy_dictMatchState_row
  105. #define ZSTD_COMPRESSBLOCK_LAZY_DEDICATEDDICTSEARCH ZSTD_compressBlock_lazy_dedicatedDictSearch
  106. #define ZSTD_COMPRESSBLOCK_LAZY_DEDICATEDDICTSEARCH_ROW ZSTD_compressBlock_lazy_dedicatedDictSearch_row
  107. #define ZSTD_COMPRESSBLOCK_LAZY_EXTDICT ZSTD_compressBlock_lazy_extDict
  108. #define ZSTD_COMPRESSBLOCK_LAZY_EXTDICT_ROW ZSTD_compressBlock_lazy_extDict_row
  109. #else
  110. #define ZSTD_COMPRESSBLOCK_LAZY NULL
  111. #define ZSTD_COMPRESSBLOCK_LAZY_ROW NULL
  112. #define ZSTD_COMPRESSBLOCK_LAZY_DICTMATCHSTATE NULL
  113. #define ZSTD_COMPRESSBLOCK_LAZY_DICTMATCHSTATE_ROW NULL
  114. #define ZSTD_COMPRESSBLOCK_LAZY_DEDICATEDDICTSEARCH NULL
  115. #define ZSTD_COMPRESSBLOCK_LAZY_DEDICATEDDICTSEARCH_ROW NULL
  116. #define ZSTD_COMPRESSBLOCK_LAZY_EXTDICT NULL
  117. #define ZSTD_COMPRESSBLOCK_LAZY_EXTDICT_ROW NULL
  118. #endif
  119. #ifndef ZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR
  120. size_t ZSTD_compressBlock_lazy2(
  121. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  122. void const* src, size_t srcSize);
  123. size_t ZSTD_compressBlock_lazy2_row(
  124. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  125. void const* src, size_t srcSize);
  126. size_t ZSTD_compressBlock_lazy2_dictMatchState(
  127. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  128. void const* src, size_t srcSize);
  129. size_t ZSTD_compressBlock_lazy2_dictMatchState_row(
  130. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  131. void const* src, size_t srcSize);
  132. size_t ZSTD_compressBlock_lazy2_dedicatedDictSearch(
  133. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  134. void const* src, size_t srcSize);
  135. size_t ZSTD_compressBlock_lazy2_dedicatedDictSearch_row(
  136. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  137. void const* src, size_t srcSize);
  138. size_t ZSTD_compressBlock_lazy2_extDict(
  139. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  140. void const* src, size_t srcSize);
  141. size_t ZSTD_compressBlock_lazy2_extDict_row(
  142. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  143. void const* src, size_t srcSize);
  144. #define ZSTD_COMPRESSBLOCK_LAZY2 ZSTD_compressBlock_lazy2
  145. #define ZSTD_COMPRESSBLOCK_LAZY2_ROW ZSTD_compressBlock_lazy2_row
  146. #define ZSTD_COMPRESSBLOCK_LAZY2_DICTMATCHSTATE ZSTD_compressBlock_lazy2_dictMatchState
  147. #define ZSTD_COMPRESSBLOCK_LAZY2_DICTMATCHSTATE_ROW ZSTD_compressBlock_lazy2_dictMatchState_row
  148. #define ZSTD_COMPRESSBLOCK_LAZY2_DEDICATEDDICTSEARCH ZSTD_compressBlock_lazy2_dedicatedDictSearch
  149. #define ZSTD_COMPRESSBLOCK_LAZY2_DEDICATEDDICTSEARCH_ROW ZSTD_compressBlock_lazy2_dedicatedDictSearch_row
  150. #define ZSTD_COMPRESSBLOCK_LAZY2_EXTDICT ZSTD_compressBlock_lazy2_extDict
  151. #define ZSTD_COMPRESSBLOCK_LAZY2_EXTDICT_ROW ZSTD_compressBlock_lazy2_extDict_row
  152. #else
  153. #define ZSTD_COMPRESSBLOCK_LAZY2 NULL
  154. #define ZSTD_COMPRESSBLOCK_LAZY2_ROW NULL
  155. #define ZSTD_COMPRESSBLOCK_LAZY2_DICTMATCHSTATE NULL
  156. #define ZSTD_COMPRESSBLOCK_LAZY2_DICTMATCHSTATE_ROW NULL
  157. #define ZSTD_COMPRESSBLOCK_LAZY2_DEDICATEDDICTSEARCH NULL
  158. #define ZSTD_COMPRESSBLOCK_LAZY2_DEDICATEDDICTSEARCH_ROW NULL
  159. #define ZSTD_COMPRESSBLOCK_LAZY2_EXTDICT NULL
  160. #define ZSTD_COMPRESSBLOCK_LAZY2_EXTDICT_ROW NULL
  161. #endif
  162. #ifndef ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR
  163. size_t ZSTD_compressBlock_btlazy2(
  164. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  165. void const* src, size_t srcSize);
  166. size_t ZSTD_compressBlock_btlazy2_dictMatchState(
  167. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  168. void const* src, size_t srcSize);
  169. size_t ZSTD_compressBlock_btlazy2_extDict(
  170. ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
  171. void const* src, size_t srcSize);
  172. #define ZSTD_COMPRESSBLOCK_BTLAZY2 ZSTD_compressBlock_btlazy2
  173. #define ZSTD_COMPRESSBLOCK_BTLAZY2_DICTMATCHSTATE ZSTD_compressBlock_btlazy2_dictMatchState
  174. #define ZSTD_COMPRESSBLOCK_BTLAZY2_EXTDICT ZSTD_compressBlock_btlazy2_extDict
  175. #else
  176. #define ZSTD_COMPRESSBLOCK_BTLAZY2 NULL
  177. #define ZSTD_COMPRESSBLOCK_BTLAZY2_DICTMATCHSTATE NULL
  178. #define ZSTD_COMPRESSBLOCK_BTLAZY2_EXTDICT NULL
  179. #endif
  180. #if defined (__cplusplus)
  181. }
  182. #endif
  183. #endif /* ZSTD_LAZY_H */