1
0

zstd_lazy.h 9.5 KB

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