extzstd 0.0.3.CONCEPT → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +5 -5
  2. data/HISTORY.ja.md +39 -0
  3. data/LICENSE +6 -6
  4. data/README.md +26 -45
  5. data/contrib/zstd/CHANGELOG +555 -0
  6. data/contrib/zstd/CODE_OF_CONDUCT.md +5 -0
  7. data/contrib/zstd/CONTRIBUTING.md +392 -0
  8. data/contrib/zstd/COPYING +339 -0
  9. data/contrib/zstd/LICENSE +13 -9
  10. data/contrib/zstd/Makefile +414 -0
  11. data/contrib/zstd/README.md +170 -45
  12. data/contrib/zstd/TESTING.md +44 -0
  13. data/contrib/zstd/appveyor.yml +289 -0
  14. data/contrib/zstd/lib/BUCK +234 -0
  15. data/contrib/zstd/lib/Makefile +354 -0
  16. data/contrib/zstd/lib/README.md +179 -0
  17. data/contrib/zstd/{common → lib/common}/bitstream.h +170 -130
  18. data/contrib/zstd/lib/common/compiler.h +175 -0
  19. data/contrib/zstd/lib/common/cpu.h +215 -0
  20. data/contrib/zstd/lib/common/debug.c +24 -0
  21. data/contrib/zstd/lib/common/debug.h +114 -0
  22. data/contrib/zstd/{common → lib/common}/entropy_common.c +79 -94
  23. data/contrib/zstd/lib/common/error_private.c +55 -0
  24. data/contrib/zstd/lib/common/error_private.h +80 -0
  25. data/contrib/zstd/{common → lib/common}/fse.h +153 -93
  26. data/contrib/zstd/{common → lib/common}/fse_decompress.c +37 -82
  27. data/contrib/zstd/lib/common/huf.h +340 -0
  28. data/contrib/zstd/{common → lib/common}/mem.h +154 -78
  29. data/contrib/zstd/lib/common/pool.c +344 -0
  30. data/contrib/zstd/lib/common/pool.h +84 -0
  31. data/contrib/zstd/lib/common/threading.c +121 -0
  32. data/contrib/zstd/lib/common/threading.h +155 -0
  33. data/contrib/zstd/{common → lib/common}/xxhash.c +85 -75
  34. data/contrib/zstd/{common → lib/common}/xxhash.h +85 -73
  35. data/contrib/zstd/lib/common/zstd_common.c +83 -0
  36. data/contrib/zstd/lib/common/zstd_errors.h +94 -0
  37. data/contrib/zstd/lib/common/zstd_internal.h +447 -0
  38. data/contrib/zstd/{compress → lib/compress}/fse_compress.c +194 -303
  39. data/contrib/zstd/lib/compress/hist.c +183 -0
  40. data/contrib/zstd/lib/compress/hist.h +75 -0
  41. data/contrib/zstd/lib/compress/huf_compress.c +798 -0
  42. data/contrib/zstd/lib/compress/zstd_compress.c +4278 -0
  43. data/contrib/zstd/lib/compress/zstd_compress_internal.h +1125 -0
  44. data/contrib/zstd/lib/compress/zstd_compress_literals.c +158 -0
  45. data/contrib/zstd/lib/compress/zstd_compress_literals.h +29 -0
  46. data/contrib/zstd/lib/compress/zstd_compress_sequences.c +419 -0
  47. data/contrib/zstd/lib/compress/zstd_compress_sequences.h +54 -0
  48. data/contrib/zstd/lib/compress/zstd_compress_superblock.c +845 -0
  49. data/contrib/zstd/lib/compress/zstd_compress_superblock.h +32 -0
  50. data/contrib/zstd/lib/compress/zstd_cwksp.h +525 -0
  51. data/contrib/zstd/lib/compress/zstd_double_fast.c +521 -0
  52. data/contrib/zstd/lib/compress/zstd_double_fast.h +38 -0
  53. data/contrib/zstd/lib/compress/zstd_fast.c +496 -0
  54. data/contrib/zstd/lib/compress/zstd_fast.h +37 -0
  55. data/contrib/zstd/lib/compress/zstd_lazy.c +1138 -0
  56. data/contrib/zstd/lib/compress/zstd_lazy.h +67 -0
  57. data/contrib/zstd/lib/compress/zstd_ldm.c +619 -0
  58. data/contrib/zstd/lib/compress/zstd_ldm.h +110 -0
  59. data/contrib/zstd/lib/compress/zstd_opt.c +1200 -0
  60. data/contrib/zstd/lib/compress/zstd_opt.h +56 -0
  61. data/contrib/zstd/lib/compress/zstdmt_compress.c +2143 -0
  62. data/contrib/zstd/lib/compress/zstdmt_compress.h +192 -0
  63. data/contrib/zstd/lib/decompress/huf_decompress.c +1248 -0
  64. data/contrib/zstd/lib/decompress/zstd_ddict.c +244 -0
  65. data/contrib/zstd/lib/decompress/zstd_ddict.h +44 -0
  66. data/contrib/zstd/lib/decompress/zstd_decompress.c +1885 -0
  67. data/contrib/zstd/lib/decompress/zstd_decompress_block.c +1432 -0
  68. data/contrib/zstd/lib/decompress/zstd_decompress_block.h +59 -0
  69. data/contrib/zstd/lib/decompress/zstd_decompress_internal.h +189 -0
  70. data/contrib/zstd/{common → lib/deprecated}/zbuff.h +86 -69
  71. data/contrib/zstd/lib/deprecated/zbuff_common.c +26 -0
  72. data/contrib/zstd/lib/deprecated/zbuff_compress.c +147 -0
  73. data/contrib/zstd/lib/deprecated/zbuff_decompress.c +75 -0
  74. data/contrib/zstd/lib/dictBuilder/cover.c +1236 -0
  75. data/contrib/zstd/lib/dictBuilder/cover.h +157 -0
  76. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.c +3 -3
  77. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.h +5 -5
  78. data/contrib/zstd/lib/dictBuilder/fastcover.c +757 -0
  79. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/zdict.c +437 -347
  80. data/contrib/zstd/lib/dictBuilder/zdict.h +305 -0
  81. data/contrib/zstd/lib/legacy/zstd_legacy.h +415 -0
  82. data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.c +272 -292
  83. data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.h +26 -32
  84. data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.c +162 -392
  85. data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.h +26 -32
  86. data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.c +162 -391
  87. data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.h +27 -33
  88. data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.c +195 -604
  89. data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.h +26 -32
  90. data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.c +300 -575
  91. data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.h +22 -31
  92. data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.c +165 -592
  93. data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.h +54 -67
  94. data/contrib/zstd/lib/legacy/zstd_v07.c +4541 -0
  95. data/contrib/zstd/lib/legacy/zstd_v07.h +187 -0
  96. data/contrib/zstd/lib/libzstd.pc.in +15 -0
  97. data/contrib/zstd/lib/zstd.h +2090 -0
  98. data/ext/depend +2 -0
  99. data/ext/extconf.rb +18 -5
  100. data/ext/extzstd.c +296 -214
  101. data/ext/extzstd.h +81 -36
  102. data/ext/extzstd_nogvls.h +0 -117
  103. data/ext/extzstd_stream.c +622 -0
  104. data/ext/libzstd_conf.h +8 -0
  105. data/ext/zstd_common.c +11 -0
  106. data/ext/zstd_compress.c +15 -0
  107. data/ext/zstd_decompress.c +6 -0
  108. data/ext/zstd_dictbuilder.c +10 -0
  109. data/ext/zstd_dictbuilder_fastcover.c +3 -0
  110. data/ext/zstd_legacy_v01.c +3 -1
  111. data/ext/zstd_legacy_v02.c +3 -1
  112. data/ext/zstd_legacy_v03.c +3 -1
  113. data/ext/zstd_legacy_v04.c +3 -1
  114. data/ext/zstd_legacy_v05.c +3 -1
  115. data/ext/zstd_legacy_v06.c +3 -1
  116. data/ext/zstd_legacy_v07.c +3 -0
  117. data/gemstub.rb +27 -21
  118. data/lib/extzstd.rb +82 -161
  119. data/lib/extzstd/version.rb +1 -1
  120. data/test/test_basic.rb +19 -6
  121. metadata +127 -59
  122. data/contrib/zstd/common/error_private.h +0 -125
  123. data/contrib/zstd/common/error_public.h +0 -77
  124. data/contrib/zstd/common/huf.h +0 -228
  125. data/contrib/zstd/common/zstd.h +0 -475
  126. data/contrib/zstd/common/zstd_common.c +0 -91
  127. data/contrib/zstd/common/zstd_internal.h +0 -238
  128. data/contrib/zstd/compress/huf_compress.c +0 -577
  129. data/contrib/zstd/compress/zbuff_compress.c +0 -327
  130. data/contrib/zstd/compress/zstd_compress.c +0 -3074
  131. data/contrib/zstd/compress/zstd_opt.h +0 -1046
  132. data/contrib/zstd/decompress/huf_decompress.c +0 -894
  133. data/contrib/zstd/decompress/zbuff_decompress.c +0 -294
  134. data/contrib/zstd/decompress/zstd_decompress.c +0 -1362
  135. data/contrib/zstd/dictBuilder/zdict.h +0 -113
  136. data/contrib/zstd/legacy/zstd_legacy.h +0 -140
  137. data/ext/extzstd_buffered.c +0 -265
  138. data/ext/zstd_amalgam.c +0 -18
@@ -0,0 +1,305 @@
1
+ /*
2
+ * Copyright (c) 2016-2020, 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
+ * You may select, at your option, one of the above-listed licenses.
9
+ */
10
+
11
+ #ifndef DICTBUILDER_H_001
12
+ #define DICTBUILDER_H_001
13
+
14
+ #if defined (__cplusplus)
15
+ extern "C" {
16
+ #endif
17
+
18
+
19
+ /*====== Dependencies ======*/
20
+ #include <stddef.h> /* size_t */
21
+
22
+
23
+ /* ===== ZDICTLIB_API : control library symbols visibility ===== */
24
+ #ifndef ZDICTLIB_VISIBILITY
25
+ # if defined(__GNUC__) && (__GNUC__ >= 4)
26
+ # define ZDICTLIB_VISIBILITY __attribute__ ((visibility ("default")))
27
+ # else
28
+ # define ZDICTLIB_VISIBILITY
29
+ # endif
30
+ #endif
31
+ #if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
32
+ # define ZDICTLIB_API __declspec(dllexport) ZDICTLIB_VISIBILITY
33
+ #elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
34
+ # define ZDICTLIB_API __declspec(dllimport) ZDICTLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
35
+ #else
36
+ # define ZDICTLIB_API ZDICTLIB_VISIBILITY
37
+ #endif
38
+
39
+
40
+ /*! ZDICT_trainFromBuffer():
41
+ * Train a dictionary from an array of samples.
42
+ * Redirect towards ZDICT_optimizeTrainFromBuffer_fastCover() single-threaded, with d=8, steps=4,
43
+ * f=20, and accel=1.
44
+ * Samples must be stored concatenated in a single flat buffer `samplesBuffer`,
45
+ * supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order.
46
+ * The resulting dictionary will be saved into `dictBuffer`.
47
+ * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
48
+ * or an error code, which can be tested with ZDICT_isError().
49
+ * Note: Dictionary training will fail if there are not enough samples to construct a
50
+ * dictionary, or if most of the samples are too small (< 8 bytes being the lower limit).
51
+ * If dictionary training fails, you should use zstd without a dictionary, as the dictionary
52
+ * would've been ineffective anyways. If you believe your samples would benefit from a dictionary
53
+ * please open an issue with details, and we can look into it.
54
+ * Note: ZDICT_trainFromBuffer()'s memory usage is about 6 MB.
55
+ * Tips: In general, a reasonable dictionary has a size of ~ 100 KB.
56
+ * It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`.
57
+ * In general, it's recommended to provide a few thousands samples, though this can vary a lot.
58
+ * It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
59
+ */
60
+ ZDICTLIB_API size_t ZDICT_trainFromBuffer(void* dictBuffer, size_t dictBufferCapacity,
61
+ const void* samplesBuffer,
62
+ const size_t* samplesSizes, unsigned nbSamples);
63
+
64
+ typedef struct {
65
+ int compressionLevel; /*< optimize for a specific zstd compression level; 0 means default */
66
+ unsigned notificationLevel; /*< Write log to stderr; 0 = none (default); 1 = errors; 2 = progression; 3 = details; 4 = debug; */
67
+ unsigned dictID; /*< force dictID value; 0 means auto mode (32-bits random value) */
68
+ } ZDICT_params_t;
69
+
70
+ /*! ZDICT_finalizeDictionary():
71
+ * Given a custom content as a basis for dictionary, and a set of samples,
72
+ * finalize dictionary by adding headers and statistics according to the zstd
73
+ * dictionary format.
74
+ *
75
+ * Samples must be stored concatenated in a flat buffer `samplesBuffer`,
76
+ * supplied with an array of sizes `samplesSizes`, providing the size of each
77
+ * sample in order. The samples are used to construct the statistics, so they
78
+ * should be representative of what you will compress with this dictionary.
79
+ *
80
+ * The compression level can be set in `parameters`. You should pass the
81
+ * compression level you expect to use in production. The statistics for each
82
+ * compression level differ, so tuning the dictionary for the compression level
83
+ * can help quite a bit.
84
+ *
85
+ * You can set an explicit dictionary ID in `parameters`, or allow us to pick
86
+ * a random dictionary ID for you, but we can't guarantee no collisions.
87
+ *
88
+ * The dstDictBuffer and the dictContent may overlap, and the content will be
89
+ * appended to the end of the header. If the header + the content doesn't fit in
90
+ * maxDictSize the beginning of the content is truncated to make room, since it
91
+ * is presumed that the most profitable content is at the end of the dictionary,
92
+ * since that is the cheapest to reference.
93
+ *
94
+ * `dictContentSize` must be >= ZDICT_CONTENTSIZE_MIN bytes.
95
+ * `maxDictSize` must be >= max(dictContentSize, ZSTD_DICTSIZE_MIN).
96
+ *
97
+ * @return: size of dictionary stored into `dstDictBuffer` (<= `maxDictSize`),
98
+ * or an error code, which can be tested by ZDICT_isError().
99
+ * Note: ZDICT_finalizeDictionary() will push notifications into stderr if
100
+ * instructed to, using notificationLevel>0.
101
+ * NOTE: This function currently may fail in several edge cases including:
102
+ * * Not enough samples
103
+ * * Samples are uncompressible
104
+ * * Samples are all exactly the same
105
+ */
106
+ ZDICTLIB_API size_t ZDICT_finalizeDictionary(void* dstDictBuffer, size_t maxDictSize,
107
+ const void* dictContent, size_t dictContentSize,
108
+ const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
109
+ ZDICT_params_t parameters);
110
+
111
+
112
+ /*====== Helper functions ======*/
113
+ ZDICTLIB_API unsigned ZDICT_getDictID(const void* dictBuffer, size_t dictSize); /**< extracts dictID; @return zero if error (not a valid dictionary) */
114
+ ZDICTLIB_API size_t ZDICT_getDictHeaderSize(const void* dictBuffer, size_t dictSize); /* returns dict header size; returns a ZSTD error code on failure */
115
+ ZDICTLIB_API unsigned ZDICT_isError(size_t errorCode);
116
+ ZDICTLIB_API const char* ZDICT_getErrorName(size_t errorCode);
117
+
118
+
119
+
120
+ #ifdef ZDICT_STATIC_LINKING_ONLY
121
+
122
+ /* ====================================================================================
123
+ * The definitions in this section are considered experimental.
124
+ * They should never be used with a dynamic library, as they may change in the future.
125
+ * They are provided for advanced usages.
126
+ * Use them only in association with static linking.
127
+ * ==================================================================================== */
128
+
129
+ #define ZDICT_CONTENTSIZE_MIN 128
130
+ #define ZDICT_DICTSIZE_MIN 256
131
+
132
+ /*! ZDICT_cover_params_t:
133
+ * k and d are the only required parameters.
134
+ * For others, value 0 means default.
135
+ */
136
+ typedef struct {
137
+ unsigned k; /* Segment size : constraint: 0 < k : Reasonable range [16, 2048+] */
138
+ unsigned d; /* dmer size : constraint: 0 < d <= k : Reasonable range [6, 16] */
139
+ unsigned steps; /* Number of steps : Only used for optimization : 0 means default (40) : Higher means more parameters checked */
140
+ unsigned nbThreads; /* Number of threads : constraint: 0 < nbThreads : 1 means single-threaded : Only used for optimization : Ignored if ZSTD_MULTITHREAD is not defined */
141
+ double splitPoint; /* Percentage of samples used for training: Only used for optimization : the first nbSamples * splitPoint samples will be used to training, the last nbSamples * (1 - splitPoint) samples will be used for testing, 0 means default (1.0), 1.0 when all samples are used for both training and testing */
142
+ unsigned shrinkDict; /* Train dictionaries to shrink in size starting from the minimum size and selects the smallest dictionary that is shrinkDictMaxRegression% worse than the largest dictionary. 0 means no shrinking and 1 means shrinking */
143
+ unsigned shrinkDictMaxRegression; /* Sets shrinkDictMaxRegression so that a smaller dictionary can be at worse shrinkDictMaxRegression% worse than the max dict size dictionary. */
144
+ ZDICT_params_t zParams;
145
+ } ZDICT_cover_params_t;
146
+
147
+ typedef struct {
148
+ unsigned k; /* Segment size : constraint: 0 < k : Reasonable range [16, 2048+] */
149
+ unsigned d; /* dmer size : constraint: 0 < d <= k : Reasonable range [6, 16] */
150
+ unsigned f; /* log of size of frequency array : constraint: 0 < f <= 31 : 1 means default(20)*/
151
+ unsigned steps; /* Number of steps : Only used for optimization : 0 means default (40) : Higher means more parameters checked */
152
+ unsigned nbThreads; /* Number of threads : constraint: 0 < nbThreads : 1 means single-threaded : Only used for optimization : Ignored if ZSTD_MULTITHREAD is not defined */
153
+ double splitPoint; /* Percentage of samples used for training: Only used for optimization : the first nbSamples * splitPoint samples will be used to training, the last nbSamples * (1 - splitPoint) samples will be used for testing, 0 means default (0.75), 1.0 when all samples are used for both training and testing */
154
+ unsigned accel; /* Acceleration level: constraint: 0 < accel <= 10, higher means faster and less accurate, 0 means default(1) */
155
+ unsigned shrinkDict; /* Train dictionaries to shrink in size starting from the minimum size and selects the smallest dictionary that is shrinkDictMaxRegression% worse than the largest dictionary. 0 means no shrinking and 1 means shrinking */
156
+ unsigned shrinkDictMaxRegression; /* Sets shrinkDictMaxRegression so that a smaller dictionary can be at worse shrinkDictMaxRegression% worse than the max dict size dictionary. */
157
+
158
+ ZDICT_params_t zParams;
159
+ } ZDICT_fastCover_params_t;
160
+
161
+ /*! ZDICT_trainFromBuffer_cover():
162
+ * Train a dictionary from an array of samples using the COVER algorithm.
163
+ * Samples must be stored concatenated in a single flat buffer `samplesBuffer`,
164
+ * supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order.
165
+ * The resulting dictionary will be saved into `dictBuffer`.
166
+ * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
167
+ * or an error code, which can be tested with ZDICT_isError().
168
+ * See ZDICT_trainFromBuffer() for details on failure modes.
169
+ * Note: ZDICT_trainFromBuffer_cover() requires about 9 bytes of memory for each input byte.
170
+ * Tips: In general, a reasonable dictionary has a size of ~ 100 KB.
171
+ * It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`.
172
+ * In general, it's recommended to provide a few thousands samples, though this can vary a lot.
173
+ * It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
174
+ */
175
+ ZDICTLIB_API size_t ZDICT_trainFromBuffer_cover(
176
+ void *dictBuffer, size_t dictBufferCapacity,
177
+ const void *samplesBuffer, const size_t *samplesSizes, unsigned nbSamples,
178
+ ZDICT_cover_params_t parameters);
179
+
180
+ /*! ZDICT_optimizeTrainFromBuffer_cover():
181
+ * The same requirements as above hold for all the parameters except `parameters`.
182
+ * This function tries many parameter combinations and picks the best parameters.
183
+ * `*parameters` is filled with the best parameters found,
184
+ * dictionary constructed with those parameters is stored in `dictBuffer`.
185
+ *
186
+ * All of the parameters d, k, steps are optional.
187
+ * If d is non-zero then we don't check multiple values of d, otherwise we check d = {6, 8}.
188
+ * if steps is zero it defaults to its default value.
189
+ * If k is non-zero then we don't check multiple values of k, otherwise we check steps values in [50, 2000].
190
+ *
191
+ * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
192
+ * or an error code, which can be tested with ZDICT_isError().
193
+ * On success `*parameters` contains the parameters selected.
194
+ * See ZDICT_trainFromBuffer() for details on failure modes.
195
+ * Note: ZDICT_optimizeTrainFromBuffer_cover() requires about 8 bytes of memory for each input byte and additionally another 5 bytes of memory for each byte of memory for each thread.
196
+ */
197
+ ZDICTLIB_API size_t ZDICT_optimizeTrainFromBuffer_cover(
198
+ void* dictBuffer, size_t dictBufferCapacity,
199
+ const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
200
+ ZDICT_cover_params_t* parameters);
201
+
202
+ /*! ZDICT_trainFromBuffer_fastCover():
203
+ * Train a dictionary from an array of samples using a modified version of COVER algorithm.
204
+ * Samples must be stored concatenated in a single flat buffer `samplesBuffer`,
205
+ * supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order.
206
+ * d and k are required.
207
+ * All other parameters are optional, will use default values if not provided
208
+ * The resulting dictionary will be saved into `dictBuffer`.
209
+ * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
210
+ * or an error code, which can be tested with ZDICT_isError().
211
+ * See ZDICT_trainFromBuffer() for details on failure modes.
212
+ * Note: ZDICT_trainFromBuffer_fastCover() requires 6 * 2^f bytes of memory.
213
+ * Tips: In general, a reasonable dictionary has a size of ~ 100 KB.
214
+ * It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`.
215
+ * In general, it's recommended to provide a few thousands samples, though this can vary a lot.
216
+ * It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
217
+ */
218
+ ZDICTLIB_API size_t ZDICT_trainFromBuffer_fastCover(void *dictBuffer,
219
+ size_t dictBufferCapacity, const void *samplesBuffer,
220
+ const size_t *samplesSizes, unsigned nbSamples,
221
+ ZDICT_fastCover_params_t parameters);
222
+
223
+ /*! ZDICT_optimizeTrainFromBuffer_fastCover():
224
+ * The same requirements as above hold for all the parameters except `parameters`.
225
+ * This function tries many parameter combinations (specifically, k and d combinations)
226
+ * and picks the best parameters. `*parameters` is filled with the best parameters found,
227
+ * dictionary constructed with those parameters is stored in `dictBuffer`.
228
+ * All of the parameters d, k, steps, f, and accel are optional.
229
+ * If d is non-zero then we don't check multiple values of d, otherwise we check d = {6, 8}.
230
+ * if steps is zero it defaults to its default value.
231
+ * If k is non-zero then we don't check multiple values of k, otherwise we check steps values in [50, 2000].
232
+ * If f is zero, default value of 20 is used.
233
+ * If accel is zero, default value of 1 is used.
234
+ *
235
+ * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
236
+ * or an error code, which can be tested with ZDICT_isError().
237
+ * On success `*parameters` contains the parameters selected.
238
+ * See ZDICT_trainFromBuffer() for details on failure modes.
239
+ * Note: ZDICT_optimizeTrainFromBuffer_fastCover() requires about 6 * 2^f bytes of memory for each thread.
240
+ */
241
+ ZDICTLIB_API size_t ZDICT_optimizeTrainFromBuffer_fastCover(void* dictBuffer,
242
+ size_t dictBufferCapacity, const void* samplesBuffer,
243
+ const size_t* samplesSizes, unsigned nbSamples,
244
+ ZDICT_fastCover_params_t* parameters);
245
+
246
+ typedef struct {
247
+ unsigned selectivityLevel; /* 0 means default; larger => select more => larger dictionary */
248
+ ZDICT_params_t zParams;
249
+ } ZDICT_legacy_params_t;
250
+
251
+ /*! ZDICT_trainFromBuffer_legacy():
252
+ * Train a dictionary from an array of samples.
253
+ * Samples must be stored concatenated in a single flat buffer `samplesBuffer`,
254
+ * supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order.
255
+ * The resulting dictionary will be saved into `dictBuffer`.
256
+ * `parameters` is optional and can be provided with values set to 0 to mean "default".
257
+ * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
258
+ * or an error code, which can be tested with ZDICT_isError().
259
+ * See ZDICT_trainFromBuffer() for details on failure modes.
260
+ * Tips: In general, a reasonable dictionary has a size of ~ 100 KB.
261
+ * It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`.
262
+ * In general, it's recommended to provide a few thousands samples, though this can vary a lot.
263
+ * It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
264
+ * Note: ZDICT_trainFromBuffer_legacy() will send notifications into stderr if instructed to, using notificationLevel>0.
265
+ */
266
+ ZDICTLIB_API size_t ZDICT_trainFromBuffer_legacy(
267
+ void *dictBuffer, size_t dictBufferCapacity,
268
+ const void *samplesBuffer, const size_t *samplesSizes, unsigned nbSamples,
269
+ ZDICT_legacy_params_t parameters);
270
+
271
+ /* Deprecation warnings */
272
+ /* It is generally possible to disable deprecation warnings from compiler,
273
+ for example with -Wno-deprecated-declarations for gcc
274
+ or _CRT_SECURE_NO_WARNINGS in Visual.
275
+ Otherwise, it's also possible to manually define ZDICT_DISABLE_DEPRECATE_WARNINGS */
276
+ #ifdef ZDICT_DISABLE_DEPRECATE_WARNINGS
277
+ # define ZDICT_DEPRECATED(message) ZDICTLIB_API /* disable deprecation warnings */
278
+ #else
279
+ # define ZDICT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
280
+ # if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
281
+ # define ZDICT_DEPRECATED(message) [[deprecated(message)]] ZDICTLIB_API
282
+ # elif (ZDICT_GCC_VERSION >= 405) || defined(__clang__)
283
+ # define ZDICT_DEPRECATED(message) ZDICTLIB_API __attribute__((deprecated(message)))
284
+ # elif (ZDICT_GCC_VERSION >= 301)
285
+ # define ZDICT_DEPRECATED(message) ZDICTLIB_API __attribute__((deprecated))
286
+ # elif defined(_MSC_VER)
287
+ # define ZDICT_DEPRECATED(message) ZDICTLIB_API __declspec(deprecated(message))
288
+ # else
289
+ # pragma message("WARNING: You need to implement ZDICT_DEPRECATED for this compiler")
290
+ # define ZDICT_DEPRECATED(message) ZDICTLIB_API
291
+ # endif
292
+ #endif /* ZDICT_DISABLE_DEPRECATE_WARNINGS */
293
+
294
+ ZDICT_DEPRECATED("use ZDICT_finalizeDictionary() instead")
295
+ size_t ZDICT_addEntropyTablesFromBuffer(void* dictBuffer, size_t dictContentSize, size_t dictBufferCapacity,
296
+ const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples);
297
+
298
+
299
+ #endif /* ZDICT_STATIC_LINKING_ONLY */
300
+
301
+ #if defined (__cplusplus)
302
+ }
303
+ #endif
304
+
305
+ #endif /* DICTBUILDER_H_001 */
@@ -0,0 +1,415 @@
1
+ /*
2
+ * Copyright (c) 2016-2020, 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
+ * You may select, at your option, one of the above-listed licenses.
9
+ */
10
+
11
+ #ifndef ZSTD_LEGACY_H
12
+ #define ZSTD_LEGACY_H
13
+
14
+ #if defined (__cplusplus)
15
+ extern "C" {
16
+ #endif
17
+
18
+ /* *************************************
19
+ * Includes
20
+ ***************************************/
21
+ #include "../common/mem.h" /* MEM_STATIC */
22
+ #include "../common/error_private.h" /* ERROR */
23
+ #include "../common/zstd_internal.h" /* ZSTD_inBuffer, ZSTD_outBuffer, ZSTD_frameSizeInfo */
24
+
25
+ #if !defined (ZSTD_LEGACY_SUPPORT) || (ZSTD_LEGACY_SUPPORT == 0)
26
+ # undef ZSTD_LEGACY_SUPPORT
27
+ # define ZSTD_LEGACY_SUPPORT 8
28
+ #endif
29
+
30
+ #if (ZSTD_LEGACY_SUPPORT <= 1)
31
+ # include "zstd_v01.h"
32
+ #endif
33
+ #if (ZSTD_LEGACY_SUPPORT <= 2)
34
+ # include "zstd_v02.h"
35
+ #endif
36
+ #if (ZSTD_LEGACY_SUPPORT <= 3)
37
+ # include "zstd_v03.h"
38
+ #endif
39
+ #if (ZSTD_LEGACY_SUPPORT <= 4)
40
+ # include "zstd_v04.h"
41
+ #endif
42
+ #if (ZSTD_LEGACY_SUPPORT <= 5)
43
+ # include "zstd_v05.h"
44
+ #endif
45
+ #if (ZSTD_LEGACY_SUPPORT <= 6)
46
+ # include "zstd_v06.h"
47
+ #endif
48
+ #if (ZSTD_LEGACY_SUPPORT <= 7)
49
+ # include "zstd_v07.h"
50
+ #endif
51
+
52
+ /** ZSTD_isLegacy() :
53
+ @return : > 0 if supported by legacy decoder. 0 otherwise.
54
+ return value is the version.
55
+ */
56
+ MEM_STATIC unsigned ZSTD_isLegacy(const void* src, size_t srcSize)
57
+ {
58
+ U32 magicNumberLE;
59
+ if (srcSize<4) return 0;
60
+ magicNumberLE = MEM_readLE32(src);
61
+ switch(magicNumberLE)
62
+ {
63
+ #if (ZSTD_LEGACY_SUPPORT <= 1)
64
+ case ZSTDv01_magicNumberLE:return 1;
65
+ #endif
66
+ #if (ZSTD_LEGACY_SUPPORT <= 2)
67
+ case ZSTDv02_magicNumber : return 2;
68
+ #endif
69
+ #if (ZSTD_LEGACY_SUPPORT <= 3)
70
+ case ZSTDv03_magicNumber : return 3;
71
+ #endif
72
+ #if (ZSTD_LEGACY_SUPPORT <= 4)
73
+ case ZSTDv04_magicNumber : return 4;
74
+ #endif
75
+ #if (ZSTD_LEGACY_SUPPORT <= 5)
76
+ case ZSTDv05_MAGICNUMBER : return 5;
77
+ #endif
78
+ #if (ZSTD_LEGACY_SUPPORT <= 6)
79
+ case ZSTDv06_MAGICNUMBER : return 6;
80
+ #endif
81
+ #if (ZSTD_LEGACY_SUPPORT <= 7)
82
+ case ZSTDv07_MAGICNUMBER : return 7;
83
+ #endif
84
+ default : return 0;
85
+ }
86
+ }
87
+
88
+
89
+ MEM_STATIC unsigned long long ZSTD_getDecompressedSize_legacy(const void* src, size_t srcSize)
90
+ {
91
+ U32 const version = ZSTD_isLegacy(src, srcSize);
92
+ if (version < 5) return 0; /* no decompressed size in frame header, or not a legacy format */
93
+ #if (ZSTD_LEGACY_SUPPORT <= 5)
94
+ if (version==5) {
95
+ ZSTDv05_parameters fParams;
96
+ size_t const frResult = ZSTDv05_getFrameParams(&fParams, src, srcSize);
97
+ if (frResult != 0) return 0;
98
+ return fParams.srcSize;
99
+ }
100
+ #endif
101
+ #if (ZSTD_LEGACY_SUPPORT <= 6)
102
+ if (version==6) {
103
+ ZSTDv06_frameParams fParams;
104
+ size_t const frResult = ZSTDv06_getFrameParams(&fParams, src, srcSize);
105
+ if (frResult != 0) return 0;
106
+ return fParams.frameContentSize;
107
+ }
108
+ #endif
109
+ #if (ZSTD_LEGACY_SUPPORT <= 7)
110
+ if (version==7) {
111
+ ZSTDv07_frameParams fParams;
112
+ size_t const frResult = ZSTDv07_getFrameParams(&fParams, src, srcSize);
113
+ if (frResult != 0) return 0;
114
+ return fParams.frameContentSize;
115
+ }
116
+ #endif
117
+ return 0; /* should not be possible */
118
+ }
119
+
120
+
121
+ MEM_STATIC size_t ZSTD_decompressLegacy(
122
+ void* dst, size_t dstCapacity,
123
+ const void* src, size_t compressedSize,
124
+ const void* dict,size_t dictSize)
125
+ {
126
+ U32 const version = ZSTD_isLegacy(src, compressedSize);
127
+ (void)dst; (void)dstCapacity; (void)dict; (void)dictSize; /* unused when ZSTD_LEGACY_SUPPORT >= 8 */
128
+ switch(version)
129
+ {
130
+ #if (ZSTD_LEGACY_SUPPORT <= 1)
131
+ case 1 :
132
+ return ZSTDv01_decompress(dst, dstCapacity, src, compressedSize);
133
+ #endif
134
+ #if (ZSTD_LEGACY_SUPPORT <= 2)
135
+ case 2 :
136
+ return ZSTDv02_decompress(dst, dstCapacity, src, compressedSize);
137
+ #endif
138
+ #if (ZSTD_LEGACY_SUPPORT <= 3)
139
+ case 3 :
140
+ return ZSTDv03_decompress(dst, dstCapacity, src, compressedSize);
141
+ #endif
142
+ #if (ZSTD_LEGACY_SUPPORT <= 4)
143
+ case 4 :
144
+ return ZSTDv04_decompress(dst, dstCapacity, src, compressedSize);
145
+ #endif
146
+ #if (ZSTD_LEGACY_SUPPORT <= 5)
147
+ case 5 :
148
+ { size_t result;
149
+ ZSTDv05_DCtx* const zd = ZSTDv05_createDCtx();
150
+ if (zd==NULL) return ERROR(memory_allocation);
151
+ result = ZSTDv05_decompress_usingDict(zd, dst, dstCapacity, src, compressedSize, dict, dictSize);
152
+ ZSTDv05_freeDCtx(zd);
153
+ return result;
154
+ }
155
+ #endif
156
+ #if (ZSTD_LEGACY_SUPPORT <= 6)
157
+ case 6 :
158
+ { size_t result;
159
+ ZSTDv06_DCtx* const zd = ZSTDv06_createDCtx();
160
+ if (zd==NULL) return ERROR(memory_allocation);
161
+ result = ZSTDv06_decompress_usingDict(zd, dst, dstCapacity, src, compressedSize, dict, dictSize);
162
+ ZSTDv06_freeDCtx(zd);
163
+ return result;
164
+ }
165
+ #endif
166
+ #if (ZSTD_LEGACY_SUPPORT <= 7)
167
+ case 7 :
168
+ { size_t result;
169
+ ZSTDv07_DCtx* const zd = ZSTDv07_createDCtx();
170
+ if (zd==NULL) return ERROR(memory_allocation);
171
+ result = ZSTDv07_decompress_usingDict(zd, dst, dstCapacity, src, compressedSize, dict, dictSize);
172
+ ZSTDv07_freeDCtx(zd);
173
+ return result;
174
+ }
175
+ #endif
176
+ default :
177
+ return ERROR(prefix_unknown);
178
+ }
179
+ }
180
+
181
+ MEM_STATIC ZSTD_frameSizeInfo ZSTD_findFrameSizeInfoLegacy(const void *src, size_t srcSize)
182
+ {
183
+ ZSTD_frameSizeInfo frameSizeInfo;
184
+ U32 const version = ZSTD_isLegacy(src, srcSize);
185
+ switch(version)
186
+ {
187
+ #if (ZSTD_LEGACY_SUPPORT <= 1)
188
+ case 1 :
189
+ ZSTDv01_findFrameSizeInfoLegacy(src, srcSize,
190
+ &frameSizeInfo.compressedSize,
191
+ &frameSizeInfo.decompressedBound);
192
+ break;
193
+ #endif
194
+ #if (ZSTD_LEGACY_SUPPORT <= 2)
195
+ case 2 :
196
+ ZSTDv02_findFrameSizeInfoLegacy(src, srcSize,
197
+ &frameSizeInfo.compressedSize,
198
+ &frameSizeInfo.decompressedBound);
199
+ break;
200
+ #endif
201
+ #if (ZSTD_LEGACY_SUPPORT <= 3)
202
+ case 3 :
203
+ ZSTDv03_findFrameSizeInfoLegacy(src, srcSize,
204
+ &frameSizeInfo.compressedSize,
205
+ &frameSizeInfo.decompressedBound);
206
+ break;
207
+ #endif
208
+ #if (ZSTD_LEGACY_SUPPORT <= 4)
209
+ case 4 :
210
+ ZSTDv04_findFrameSizeInfoLegacy(src, srcSize,
211
+ &frameSizeInfo.compressedSize,
212
+ &frameSizeInfo.decompressedBound);
213
+ break;
214
+ #endif
215
+ #if (ZSTD_LEGACY_SUPPORT <= 5)
216
+ case 5 :
217
+ ZSTDv05_findFrameSizeInfoLegacy(src, srcSize,
218
+ &frameSizeInfo.compressedSize,
219
+ &frameSizeInfo.decompressedBound);
220
+ break;
221
+ #endif
222
+ #if (ZSTD_LEGACY_SUPPORT <= 6)
223
+ case 6 :
224
+ ZSTDv06_findFrameSizeInfoLegacy(src, srcSize,
225
+ &frameSizeInfo.compressedSize,
226
+ &frameSizeInfo.decompressedBound);
227
+ break;
228
+ #endif
229
+ #if (ZSTD_LEGACY_SUPPORT <= 7)
230
+ case 7 :
231
+ ZSTDv07_findFrameSizeInfoLegacy(src, srcSize,
232
+ &frameSizeInfo.compressedSize,
233
+ &frameSizeInfo.decompressedBound);
234
+ break;
235
+ #endif
236
+ default :
237
+ frameSizeInfo.compressedSize = ERROR(prefix_unknown);
238
+ frameSizeInfo.decompressedBound = ZSTD_CONTENTSIZE_ERROR;
239
+ break;
240
+ }
241
+ if (!ZSTD_isError(frameSizeInfo.compressedSize) && frameSizeInfo.compressedSize > srcSize) {
242
+ frameSizeInfo.compressedSize = ERROR(srcSize_wrong);
243
+ frameSizeInfo.decompressedBound = ZSTD_CONTENTSIZE_ERROR;
244
+ }
245
+ return frameSizeInfo;
246
+ }
247
+
248
+ MEM_STATIC size_t ZSTD_findFrameCompressedSizeLegacy(const void *src, size_t srcSize)
249
+ {
250
+ ZSTD_frameSizeInfo frameSizeInfo = ZSTD_findFrameSizeInfoLegacy(src, srcSize);
251
+ return frameSizeInfo.compressedSize;
252
+ }
253
+
254
+ MEM_STATIC size_t ZSTD_freeLegacyStreamContext(void* legacyContext, U32 version)
255
+ {
256
+ switch(version)
257
+ {
258
+ default :
259
+ case 1 :
260
+ case 2 :
261
+ case 3 :
262
+ (void)legacyContext;
263
+ return ERROR(version_unsupported);
264
+ #if (ZSTD_LEGACY_SUPPORT <= 4)
265
+ case 4 : return ZBUFFv04_freeDCtx((ZBUFFv04_DCtx*)legacyContext);
266
+ #endif
267
+ #if (ZSTD_LEGACY_SUPPORT <= 5)
268
+ case 5 : return ZBUFFv05_freeDCtx((ZBUFFv05_DCtx*)legacyContext);
269
+ #endif
270
+ #if (ZSTD_LEGACY_SUPPORT <= 6)
271
+ case 6 : return ZBUFFv06_freeDCtx((ZBUFFv06_DCtx*)legacyContext);
272
+ #endif
273
+ #if (ZSTD_LEGACY_SUPPORT <= 7)
274
+ case 7 : return ZBUFFv07_freeDCtx((ZBUFFv07_DCtx*)legacyContext);
275
+ #endif
276
+ }
277
+ }
278
+
279
+
280
+ MEM_STATIC size_t ZSTD_initLegacyStream(void** legacyContext, U32 prevVersion, U32 newVersion,
281
+ const void* dict, size_t dictSize)
282
+ {
283
+ DEBUGLOG(5, "ZSTD_initLegacyStream for v0.%u", newVersion);
284
+ if (prevVersion != newVersion) ZSTD_freeLegacyStreamContext(*legacyContext, prevVersion);
285
+ switch(newVersion)
286
+ {
287
+ default :
288
+ case 1 :
289
+ case 2 :
290
+ case 3 :
291
+ (void)dict; (void)dictSize;
292
+ return 0;
293
+ #if (ZSTD_LEGACY_SUPPORT <= 4)
294
+ case 4 :
295
+ {
296
+ ZBUFFv04_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv04_createDCtx() : (ZBUFFv04_DCtx*)*legacyContext;
297
+ if (dctx==NULL) return ERROR(memory_allocation);
298
+ ZBUFFv04_decompressInit(dctx);
299
+ ZBUFFv04_decompressWithDictionary(dctx, dict, dictSize);
300
+ *legacyContext = dctx;
301
+ return 0;
302
+ }
303
+ #endif
304
+ #if (ZSTD_LEGACY_SUPPORT <= 5)
305
+ case 5 :
306
+ {
307
+ ZBUFFv05_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv05_createDCtx() : (ZBUFFv05_DCtx*)*legacyContext;
308
+ if (dctx==NULL) return ERROR(memory_allocation);
309
+ ZBUFFv05_decompressInitDictionary(dctx, dict, dictSize);
310
+ *legacyContext = dctx;
311
+ return 0;
312
+ }
313
+ #endif
314
+ #if (ZSTD_LEGACY_SUPPORT <= 6)
315
+ case 6 :
316
+ {
317
+ ZBUFFv06_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv06_createDCtx() : (ZBUFFv06_DCtx*)*legacyContext;
318
+ if (dctx==NULL) return ERROR(memory_allocation);
319
+ ZBUFFv06_decompressInitDictionary(dctx, dict, dictSize);
320
+ *legacyContext = dctx;
321
+ return 0;
322
+ }
323
+ #endif
324
+ #if (ZSTD_LEGACY_SUPPORT <= 7)
325
+ case 7 :
326
+ {
327
+ ZBUFFv07_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv07_createDCtx() : (ZBUFFv07_DCtx*)*legacyContext;
328
+ if (dctx==NULL) return ERROR(memory_allocation);
329
+ ZBUFFv07_decompressInitDictionary(dctx, dict, dictSize);
330
+ *legacyContext = dctx;
331
+ return 0;
332
+ }
333
+ #endif
334
+ }
335
+ }
336
+
337
+
338
+
339
+ MEM_STATIC size_t ZSTD_decompressLegacyStream(void* legacyContext, U32 version,
340
+ ZSTD_outBuffer* output, ZSTD_inBuffer* input)
341
+ {
342
+ DEBUGLOG(5, "ZSTD_decompressLegacyStream for v0.%u", version);
343
+ switch(version)
344
+ {
345
+ default :
346
+ case 1 :
347
+ case 2 :
348
+ case 3 :
349
+ (void)legacyContext; (void)output; (void)input;
350
+ return ERROR(version_unsupported);
351
+ #if (ZSTD_LEGACY_SUPPORT <= 4)
352
+ case 4 :
353
+ {
354
+ ZBUFFv04_DCtx* dctx = (ZBUFFv04_DCtx*) legacyContext;
355
+ const void* src = (const char*)input->src + input->pos;
356
+ size_t readSize = input->size - input->pos;
357
+ void* dst = (char*)output->dst + output->pos;
358
+ size_t decodedSize = output->size - output->pos;
359
+ size_t const hintSize = ZBUFFv04_decompressContinue(dctx, dst, &decodedSize, src, &readSize);
360
+ output->pos += decodedSize;
361
+ input->pos += readSize;
362
+ return hintSize;
363
+ }
364
+ #endif
365
+ #if (ZSTD_LEGACY_SUPPORT <= 5)
366
+ case 5 :
367
+ {
368
+ ZBUFFv05_DCtx* dctx = (ZBUFFv05_DCtx*) legacyContext;
369
+ const void* src = (const char*)input->src + input->pos;
370
+ size_t readSize = input->size - input->pos;
371
+ void* dst = (char*)output->dst + output->pos;
372
+ size_t decodedSize = output->size - output->pos;
373
+ size_t const hintSize = ZBUFFv05_decompressContinue(dctx, dst, &decodedSize, src, &readSize);
374
+ output->pos += decodedSize;
375
+ input->pos += readSize;
376
+ return hintSize;
377
+ }
378
+ #endif
379
+ #if (ZSTD_LEGACY_SUPPORT <= 6)
380
+ case 6 :
381
+ {
382
+ ZBUFFv06_DCtx* dctx = (ZBUFFv06_DCtx*) legacyContext;
383
+ const void* src = (const char*)input->src + input->pos;
384
+ size_t readSize = input->size - input->pos;
385
+ void* dst = (char*)output->dst + output->pos;
386
+ size_t decodedSize = output->size - output->pos;
387
+ size_t const hintSize = ZBUFFv06_decompressContinue(dctx, dst, &decodedSize, src, &readSize);
388
+ output->pos += decodedSize;
389
+ input->pos += readSize;
390
+ return hintSize;
391
+ }
392
+ #endif
393
+ #if (ZSTD_LEGACY_SUPPORT <= 7)
394
+ case 7 :
395
+ {
396
+ ZBUFFv07_DCtx* dctx = (ZBUFFv07_DCtx*) legacyContext;
397
+ const void* src = (const char*)input->src + input->pos;
398
+ size_t readSize = input->size - input->pos;
399
+ void* dst = (char*)output->dst + output->pos;
400
+ size_t decodedSize = output->size - output->pos;
401
+ size_t const hintSize = ZBUFFv07_decompressContinue(dctx, dst, &decodedSize, src, &readSize);
402
+ output->pos += decodedSize;
403
+ input->pos += readSize;
404
+ return hintSize;
405
+ }
406
+ #endif
407
+ }
408
+ }
409
+
410
+
411
+ #if defined (__cplusplus)
412
+ }
413
+ #endif
414
+
415
+ #endif /* ZSTD_LEGACY_H */