/src/c-blosc2/include/blosc2.h
Line | Count | Source |
1 | | /********************************************************************* |
2 | | Blosc - Blocked Shuffling and Compression Library |
3 | | |
4 | | Copyright (c) 2021 Blosc Development Team <blosc@blosc.org> |
5 | | https://blosc.org |
6 | | License: BSD 3-Clause (see LICENSE.txt) |
7 | | |
8 | | See LICENSE.txt for details about copyright and rights to use. |
9 | | **********************************************************************/ |
10 | | |
11 | | /********************************************************************* |
12 | | @file blosc2.h |
13 | | @brief Blosc2 header file. |
14 | | |
15 | | This file contains Blosc2 public API and the structures needed to use it. |
16 | | @author Blosc Development Team <blosc@blosc.org> |
17 | | **********************************************************************/ |
18 | | |
19 | | #ifndef BLOSC_BLOSC2_H |
20 | | #define BLOSC_BLOSC2_H |
21 | | |
22 | | #include "blosc2/blosc2-export.h" |
23 | | #include "blosc2/blosc2-common.h" |
24 | | #include "blosc2/blosc2-stdio.h" |
25 | | |
26 | | #if defined(_WIN32) && !defined(__MINGW32__) |
27 | | #include <windows.h> |
28 | | #include <malloc.h> |
29 | | #include <process.h> |
30 | | #define getpid _getpid |
31 | | #endif |
32 | | |
33 | | #include <limits.h> |
34 | | #include <stdlib.h> |
35 | | #include <stdint.h> |
36 | | #include <stdbool.h> |
37 | | #include <stdio.h> |
38 | | |
39 | | #ifdef __cplusplus |
40 | | extern "C" { |
41 | | #endif |
42 | | |
43 | | // For compatibility with the Blosc 1.x series |
44 | | #ifdef BLOSC1_COMPAT |
45 | | // Blosc2 symbols that should be accessible from Blosc 1.x API |
46 | | #define BLOSC_VERSION_MAJOR BLOSC2_VERSION_MAJOR |
47 | | #define BLOSC_VERSION_MINOR BLOSC2_VERSION_MINOR |
48 | | #define BLOSC_VERSION_RELEASE BLOSC2_VERSION_RELEASE |
49 | | #define BLOSC_VERSION_STRING BLOSC2_VERSION_STRING |
50 | | #define BLOSC_VERSION_DATE BLOSC2_VERSION_DATE |
51 | | #define BLOSC_MAX_OVERHEAD BLOSC2_MAX_OVERHEAD |
52 | | #define BLOSC_MAX_BUFFERSIZE BLOSC2_MAX_BUFFERSIZE |
53 | | |
54 | | // API that changed to blosc1_ prefix |
55 | | #define blosc_compress blosc1_compress |
56 | | #define blosc_decompress blosc1_decompress |
57 | | #define blosc_getitem blosc1_getitem |
58 | | #define blosc_get_compressor blosc1_get_compressor |
59 | | #define blosc_set_compressor blosc1_set_compressor |
60 | | #define blosc_cbuffer_sizes blosc1_cbuffer_sizes |
61 | | #define blosc_cbuffer_validate blosc1_cbuffer_validate |
62 | | #define blosc_cbuffer_metainfo blosc1_cbuffer_metainfo |
63 | | #define blosc_get_blocksize blosc1_get_blocksize |
64 | | #define blosc_set_blocksize blosc1_set_blocksize |
65 | | #define blosc_set_splitmode blosc1_set_splitmode |
66 | | |
67 | | // API that changed to blosc2_ prefix |
68 | | #define blosc_init blosc2_init |
69 | | #define blosc_destroy blosc2_destroy |
70 | | #define blosc_free_resources blosc2_free_resources |
71 | | #define blosc_get_nthreads blosc2_get_nthreads |
72 | | #define blosc_set_nthreads blosc2_set_nthreads |
73 | | #define blosc_compcode_to_compname blosc2_compcode_to_compname |
74 | | #define blosc_compname_to_compcode blosc2_compname_to_compcode |
75 | | #define blosc_list_compressors blosc2_list_compressors |
76 | | #define blosc_get_version_string blosc2_get_version_string |
77 | | #define blosc_get_complib_info blosc2_get_complib_info |
78 | | #define blosc_cbuffer_versions blosc2_cbuffer_versions |
79 | | #define blosc_cbuffer_complib blosc2_cbuffer_complib |
80 | | #endif |
81 | | |
82 | | |
83 | | /* Version numbers */ |
84 | | #define BLOSC2_VERSION_MAJOR 3 /* for major interface/format changes */ |
85 | | #define BLOSC2_VERSION_MINOR 4 /* for minor interface/format changes */ |
86 | | #define BLOSC2_VERSION_RELEASE 1 /* for tweaks, bug-fixes, or development */ |
87 | | |
88 | 0 | #define BLOSC2_VERSION_STRING "3.4.1.dev" /* string version. Sync with above! */ |
89 | | #define BLOSC2_VERSION_DATE "$Date:: 2026-10-26 #$" /* date version year-month-day */ |
90 | | |
91 | | |
92 | | /* Tracing macros */ |
93 | 36.7k | #define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__) |
94 | 2 | #define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__) |
95 | 15 | #define BLOSC_TRACE_INFO(msg, ...) BLOSC_TRACE(info, msg, ##__VA_ARGS__) |
96 | | #define BLOSC_TRACE(cat, msg, ...) \ |
97 | 36.7k | do { \ |
98 | 36.7k | const char *__e = getenv("BLOSC_TRACE"); \ |
99 | 36.7k | if (!__e) { break; } \ |
100 | 36.7k | fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \ |
101 | 0 | } while(0) |
102 | | |
103 | | #define BLOSC_ERROR_NULL(pointer, rc) \ |
104 | 555k | do { \ |
105 | 555k | if ((pointer) == NULL) { \ |
106 | 0 | BLOSC_TRACE_ERROR("Pointer is null"); \ |
107 | 0 | return (rc); \ |
108 | 0 | } \ |
109 | 555k | } while (0) |
110 | | #define BLOSC_ERROR(rc) \ |
111 | 40 | do { \ |
112 | 40 | int rc_ = (rc); \ |
113 | 40 | if (rc_ < BLOSC2_ERROR_SUCCESS) { \ |
114 | 40 | char *error_msg = print_error(rc_); \ |
115 | 40 | BLOSC_TRACE_ERROR("%s", error_msg); \ |
116 | 40 | return rc_; \ |
117 | 40 | } \ |
118 | 40 | } while (0) |
119 | | |
120 | | #define BLOSC_INFO(msg, ...) \ |
121 | 68.6k | do { \ |
122 | 68.6k | const char *__e = getenv("BLOSC_INFO"); \ |
123 | 68.6k | if (!__e) { break; } \ |
124 | 68.6k | fprintf(stderr, "[INFO] - " msg "\n", ##__VA_ARGS__); \ |
125 | 0 | } while(0) |
126 | | |
127 | | |
128 | | /* The VERSION_FORMAT symbols below should be just 1-byte long */ |
129 | | enum { |
130 | | /* Blosc format version, starting at 1 |
131 | | 1 -> Blosc pre-1.0 |
132 | | 2 -> Blosc 1.x stable series |
133 | | 3 -> Blosc 2-alpha.x series |
134 | | 4 -> Blosc 2.x beta.1 series |
135 | | 5 -> Blosc 2.x stable series |
136 | | */ |
137 | | BLOSC1_VERSION_FORMAT_PRE1 = 1, |
138 | | BLOSC1_VERSION_FORMAT = 2, |
139 | | BLOSC2_VERSION_FORMAT_ALPHA = 3, |
140 | | BLOSC2_VERSION_FORMAT_BETA1 = 4, |
141 | | BLOSC2_VERSION_FORMAT_STABLE = 5, |
142 | | BLOSC2_VERSION_FORMAT_VL_BLOCKS = 6, |
143 | | /* Highest chunk format version supported by this library. */ |
144 | | BLOSC2_VERSION_FORMAT = BLOSC2_VERSION_FORMAT_VL_BLOCKS, |
145 | | }; |
146 | | |
147 | | |
148 | | /* The FRAME_FORMAT_VERSION symbols below should be just 4-bit long */ |
149 | | enum { |
150 | | /* Blosc format version |
151 | | * 1 -> First version (introduced in beta.2) |
152 | | * 2 -> Second version (introduced in rc.1) |
153 | | * |
154 | | */ |
155 | | BLOSC2_VERSION_FRAME_FORMAT_BETA2 = 1, // for 2.0.0-beta2 and after |
156 | | BLOSC2_VERSION_FRAME_FORMAT_RC1 = 2, // for 2.0.0-rc1 and after |
157 | | BLOSC2_VERSION_FRAME_FORMAT_VL_BLOCKS = 3, |
158 | | /* Highest cframe format version supported by this library. */ |
159 | | BLOSC2_VERSION_FRAME_FORMAT = BLOSC2_VERSION_FRAME_FORMAT_VL_BLOCKS, |
160 | | }; |
161 | | |
162 | | |
163 | | //!< Struct for storing data from instrumentation of codecs |
164 | | // This can be flexible because it is typically used mainly for development |
165 | | typedef struct { |
166 | | float cratio; |
167 | | float cspeed; |
168 | | float filter_speed; |
169 | | //float memory; |
170 | | //float power; |
171 | | uint8_t flags[4]; |
172 | | } blosc2_instr; |
173 | | |
174 | | |
175 | | enum { |
176 | | #ifndef BLOSC_H |
177 | | BLOSC_MIN_HEADER_LENGTH = 16, |
178 | | //!< Minimum header length (Blosc1) |
179 | | #endif // BLOSC_H |
180 | | BLOSC_EXTENDED_HEADER_LENGTH = 32, |
181 | | //!< Extended header length (Blosc2, see README_HEADER) |
182 | | BLOSC2_MAX_OVERHEAD = BLOSC_EXTENDED_HEADER_LENGTH, |
183 | | //!< The maximum overhead during compression in bytes. This equals |
184 | | //!< to @ref BLOSC_EXTENDED_HEADER_LENGTH now, but can be higher in future |
185 | | //!< implementations. |
186 | | BLOSC2_MAX_BUFFERSIZE = (INT_MAX - BLOSC2_MAX_OVERHEAD), |
187 | | //!< Maximum source buffer size to be compressed |
188 | | #ifndef BLOSC_H |
189 | | BLOSC_MAX_TYPESIZE = UINT8_MAX, |
190 | | //!< Maximum typesize before considering source buffer as a stream of bytes. |
191 | | //!< Cannot be larger than 255. |
192 | | #endif // BLOSC_H |
193 | | BLOSC_MIN_BUFFERSIZE = 32, |
194 | | //!< Minimum buffer size to be compressed. |
195 | | }; |
196 | | |
197 | | enum { |
198 | | BLOSC2_DEFINED_TUNER_START = 0, |
199 | | BLOSC2_DEFINED_TUNER_STOP = 31, |
200 | | //!< Blosc-defined tuners must be between 0 - 31. |
201 | | BLOSC2_GLOBAL_REGISTERED_TUNER_START = 32, |
202 | | BLOSC2_GLOBAL_REGISTERED_TUNER_STOP = 159, |
203 | | //!< Blosc-registered tuners must be between 31 - 159. |
204 | | BLOSC2_GLOBAL_REGISTERED_TUNERS = 0, |
205 | | //!< Number of Blosc-registered tuners at the moment. |
206 | | BLOSC2_USER_REGISTERED_TUNER_START = 160, |
207 | | BLOSC2_USER_REGISTERED_TUNER_STOP = 255, |
208 | | //!< User-defined tuners must be between 160 - 255. |
209 | | }; |
210 | | |
211 | | /** |
212 | | * @brief Codes for the different tuners shipped with Blosc |
213 | | */ |
214 | | enum { |
215 | | BLOSC_STUNE = 0, |
216 | | BLOSC_LAST_TUNER = 1, |
217 | | //!< Determine the last tuner defined by Blosc. |
218 | | BLOSC_LAST_REGISTERED_TUNE = BLOSC2_GLOBAL_REGISTERED_TUNER_START + BLOSC2_GLOBAL_REGISTERED_TUNERS - 1, |
219 | | //!< Determine the last registered tuner. It is used to check if a tuner is registered or not. |
220 | | }; |
221 | | |
222 | | enum { |
223 | | BLOSC2_DEFINED_FILTERS_START = 0, |
224 | | BLOSC2_DEFINED_FILTERS_STOP = 31, |
225 | | //!< Blosc-defined filters must be between 0 - 31. |
226 | | BLOSC2_GLOBAL_REGISTERED_FILTERS_START = 32, |
227 | | BLOSC2_GLOBAL_REGISTERED_FILTERS_STOP = 159, |
228 | | //!< Blosc-registered filters must be between 32 - 159. |
229 | | BLOSC2_GLOBAL_REGISTERED_FILTERS = 5, |
230 | | //!< Number of Blosc-registered filters at the moment. |
231 | | BLOSC2_USER_REGISTERED_FILTERS_START = 160, |
232 | | BLOSC2_USER_REGISTERED_FILTERS_STOP = 255, |
233 | | //!< User-defined filters must be between 128 - 255. |
234 | | BLOSC2_MAX_FILTERS = 6, |
235 | | //!< Maximum number of filters in the filter pipeline |
236 | | BLOSC2_MAX_UDFILTERS = 16, |
237 | | //!< Maximum number of filters that a user can register. |
238 | | }; |
239 | | |
240 | | |
241 | | /** |
242 | | * @brief Codes for filters. |
243 | | * |
244 | | * @sa #blosc1_compress |
245 | | */ |
246 | | enum { |
247 | | #ifndef BLOSC_H |
248 | | BLOSC_NOSHUFFLE = 0, |
249 | | //!< No shuffle (for compatibility with Blosc1). |
250 | | BLOSC_NOFILTER = 0, |
251 | | //!< No filter. |
252 | | BLOSC_SHUFFLE = 1, |
253 | | //!< Byte-wise shuffle. `filters_meta` is the number of bytestreams to shuffle from the input. If 0, defaults to typesize. |
254 | | BLOSC_BITSHUFFLE = 2, |
255 | | //!< Bit-wise shuffle. `filters_meta` does not have any effect. |
256 | | #endif // BLOSC_H |
257 | | BLOSC_DELTA = 3, |
258 | | //!< Delta filter (bitwise XOR relative to reference). `filters_meta` does not have any effect. |
259 | | BLOSC_TRUNC_PREC = 4, |
260 | | //!< Truncate mantissa precision. |
261 | | //!< Positive values in `filters_meta` will keep bits; negative values will zero bits. |
262 | | BLOSC_LAST_FILTER = 5, |
263 | | //!< sentinel |
264 | | BLOSC_LAST_REGISTERED_FILTER = BLOSC2_GLOBAL_REGISTERED_FILTERS_START + BLOSC2_GLOBAL_REGISTERED_FILTERS - 1, |
265 | | //!< Determine the last registered filter. It is used to check if a filter is registered or not. |
266 | | }; |
267 | | |
268 | | /** |
269 | | * @brief Codes for internal flags (see blosc1_cbuffer_metainfo) |
270 | | */ |
271 | | enum { |
272 | | #ifndef BLOSC_H |
273 | | BLOSC_DOSHUFFLE = 0x1, //!< byte-wise shuffle |
274 | | BLOSC_MEMCPYED = 0x2, //!< plain copy |
275 | | BLOSC_DOBITSHUFFLE = 0x4, //!< bit-wise shuffle |
276 | | #endif // BLOSC_H |
277 | | BLOSC_DODELTA = 0x8, //!< delta coding |
278 | | }; |
279 | | |
280 | | /** |
281 | | * @brief Codes for new internal flags in Blosc2 |
282 | | */ |
283 | | enum { |
284 | | BLOSC2_USEDICT = 0x1, //!< use dictionaries with codec |
285 | | BLOSC2_BIGENDIAN = 0x2, //!< data is in big-endian ordering |
286 | | BLOSC2_INSTR_CODEC = 0x80, //!< codec is instrumented (mainly for development) |
287 | | }; |
288 | | |
289 | | /** |
290 | | * @brief Codes for flags in the secondary Blosc2 header byte. |
291 | | */ |
292 | | enum { |
293 | | BLOSC2_VL_BLOCKS = 0x1, //!< chunk uses variable-length blocks |
294 | | }; |
295 | | |
296 | | /** |
297 | | * @brief Values for different Blosc2 capabilities |
298 | | */ |
299 | | enum { |
300 | | BLOSC2_MAXDICTSIZE = 32 * 1024, //!< maximum size for compression dicts |
301 | | BLOSC2_MINUSEFULDICT = 256, //!< minimum dict size considered useful; smaller → fall back to plain compression |
302 | | BLOSC2_MAXBLOCKSIZE = 536866816, //!< maximum size for blocks |
303 | | BLOSC2_MAXTYPESIZE = BLOSC2_MAXBLOCKSIZE, //!< maximum size for types |
304 | | }; |
305 | | |
306 | | |
307 | | enum { |
308 | | BLOSC2_DEFINED_CODECS_START = 0, |
309 | | BLOSC2_DEFINED_CODECS_STOP = 31, |
310 | | //!< Blosc-defined codecs must be between 0 - 31. |
311 | | BLOSC2_GLOBAL_REGISTERED_CODECS_START = 32, |
312 | | BLOSC2_GLOBAL_REGISTERED_CODECS_STOP = 159, |
313 | | //!< Blosc-registered codecs must be between 31 - 159. |
314 | | BLOSC2_GLOBAL_REGISTERED_CODECS = 5, |
315 | | //!< Number of Blosc-registered codecs at the moment. |
316 | | BLOSC2_USER_REGISTERED_CODECS_START = 160, |
317 | | BLOSC2_USER_REGISTERED_CODECS_STOP = 255, |
318 | | //!< User-defined codecs must be between 160 - 255. |
319 | | }; |
320 | | |
321 | | /** |
322 | | * @brief Codes for the different compressors shipped with Blosc |
323 | | */ |
324 | | enum { |
325 | | #ifndef BLOSC_H |
326 | | BLOSC_BLOSCLZ = 0, |
327 | | BLOSC_LZ4 = 1, |
328 | | BLOSC_LZ4HC = 2, |
329 | | BLOSC_ZLIB = 4, |
330 | | BLOSC_ZSTD = 5, |
331 | | #endif // BLOSC_H |
332 | | BLOSC_LAST_CODEC = 6, |
333 | | //!< Determine the last codec defined by Blosc. |
334 | | BLOSC_LAST_REGISTERED_CODEC = BLOSC2_GLOBAL_REGISTERED_CODECS_START + BLOSC2_GLOBAL_REGISTERED_CODECS - 1, |
335 | | //!< Determine the last registered codec. It is used to check if a codec is registered or not. |
336 | | }; |
337 | | |
338 | | |
339 | | // Names for the different compressors shipped with Blosc |
340 | | |
341 | | #ifndef BLOSC_H |
342 | 20.9k | #define BLOSC_BLOSCLZ_COMPNAME "blosclz" |
343 | 17.4k | #define BLOSC_LZ4_COMPNAME "lz4" |
344 | 16.6k | #define BLOSC_LZ4HC_COMPNAME "lz4hc" |
345 | 13.0k | #define BLOSC_ZLIB_COMPNAME "zlib" |
346 | 9.43k | #define BLOSC_ZSTD_COMPNAME "zstd" |
347 | | #endif // BLOSC_H |
348 | | |
349 | | /** |
350 | | * @brief Codes for compression libraries shipped with Blosc (code must be < 8) |
351 | | */ |
352 | | enum { |
353 | | #ifndef BLOSC_H |
354 | | BLOSC_BLOSCLZ_LIB = 0, |
355 | | BLOSC_LZ4_LIB = 1, |
356 | | BLOSC_ZLIB_LIB = 3, |
357 | | BLOSC_ZSTD_LIB = 4, |
358 | | #endif // BLOSC_H |
359 | | BLOSC_UDCODEC_LIB = 6, |
360 | | BLOSC_SCHUNK_LIB = 7, //!< compressor library in super-chunk header |
361 | | }; |
362 | | |
363 | | /** |
364 | | * @brief Names for the different compression libraries shipped with Blosc |
365 | | */ |
366 | | #ifndef BLOSC_H |
367 | 0 | #define BLOSC_BLOSCLZ_LIBNAME "BloscLZ" |
368 | 0 | #define BLOSC_LZ4_LIBNAME "LZ4" |
369 | 0 | #define BLOSC_ZLIB_LIBNAME "Zlib" |
370 | 0 | #define BLOSC_ZSTD_LIBNAME "Zstd" |
371 | | #endif // BLOSC_H |
372 | | |
373 | | /** |
374 | | * @brief The codes for compressor formats shipped with Blosc |
375 | | */ |
376 | | enum { |
377 | | #ifndef BLOSC_H |
378 | | BLOSC_BLOSCLZ_FORMAT = BLOSC_BLOSCLZ_LIB, |
379 | | BLOSC_LZ4_FORMAT = BLOSC_LZ4_LIB, |
380 | | //!< LZ4HC and LZ4 share the same format |
381 | | BLOSC_LZ4HC_FORMAT = BLOSC_LZ4_LIB, |
382 | | BLOSC_ZLIB_FORMAT = BLOSC_ZLIB_LIB, |
383 | | BLOSC_ZSTD_FORMAT = BLOSC_ZSTD_LIB, |
384 | | #endif // BLOSC_H |
385 | | BLOSC_UDCODEC_FORMAT = BLOSC_UDCODEC_LIB, |
386 | | }; |
387 | | |
388 | | /** |
389 | | * @brief The version formats for compressors shipped with Blosc. |
390 | | * All versions here starts at 1 |
391 | | */ |
392 | | enum { |
393 | | #ifndef BLOSC_H |
394 | | BLOSC_BLOSCLZ_VERSION_FORMAT = 1, |
395 | | BLOSC_LZ4_VERSION_FORMAT = 1, |
396 | | BLOSC_LZ4HC_VERSION_FORMAT = 1, /* LZ4HC and LZ4 share the same format */ |
397 | | BLOSC_ZLIB_VERSION_FORMAT = 1, |
398 | | BLOSC_ZSTD_VERSION_FORMAT = 1, |
399 | | #endif // BLOSC_H |
400 | | BLOSC_UDCODEC_VERSION_FORMAT = 1, |
401 | | }; |
402 | | |
403 | | /** |
404 | | * @brief Split mode for blocks. |
405 | | * NEVER and ALWAYS are for experimenting with compression ratio. |
406 | | * AUTO for nearly optimal behaviour (based on heuristics). |
407 | | * FORWARD_COMPAT provides best forward compatibility (default). |
408 | | */ |
409 | | #ifndef BLOSC_H |
410 | | enum { |
411 | | BLOSC_ALWAYS_SPLIT = 1, |
412 | | BLOSC_NEVER_SPLIT = 2, |
413 | | BLOSC_AUTO_SPLIT = 3, |
414 | | BLOSC_FORWARD_COMPAT_SPLIT = 4, |
415 | | }; |
416 | | #endif // BLOSC_H |
417 | | |
418 | | /** |
419 | | * @brief Offsets for fields in Blosc2 chunk header. |
420 | | */ |
421 | | enum { |
422 | | BLOSC2_CHUNK_VERSION = 0x0, //!< the version for the chunk format |
423 | | BLOSC2_CHUNK_VERSIONLZ = 0x1, //!< the version for the format of internal codec |
424 | | BLOSC2_CHUNK_FLAGS = 0x2, //!< flags and codec info |
425 | | BLOSC2_CHUNK_TYPESIZE = 0x3, //!< (uint8) the number of bytes of the atomic type |
426 | | BLOSC2_CHUNK_NBYTES = 0x4, //!< (int32) uncompressed size of the buffer (this header is not included) |
427 | | BLOSC2_CHUNK_BLOCKSIZE = 0x8, //!< (int32) size of internal blocks |
428 | | BLOSC2_CHUNK_CBYTES = 0xc, //!< (int32) compressed size of the buffer (including this header) |
429 | | BLOSC2_CHUNK_FILTER_CODES = 0x10, //!< the codecs for the filter pipeline (1 byte per code) |
430 | | BLOSC2_CHUNK_FILTER_META = 0x18, //!< meta info for the filter pipeline (1 byte per code) |
431 | | BLOSC2_CHUNK_BLOSC2_FLAGS2 = 0x1e,//!< second flags byte specific for Blosc2 functionality |
432 | | BLOSC2_CHUNK_BLOSC2_FLAGS = 0x1F, //!< flags specific for Blosc2 functionality |
433 | | }; |
434 | | |
435 | | /** |
436 | | * @brief Run lengths for special values for chunks/frames |
437 | | */ |
438 | | enum { |
439 | | BLOSC2_NO_SPECIAL = 0x0, //!< no special value |
440 | | BLOSC2_SPECIAL_ZERO = 0x1, //!< zero special value |
441 | | BLOSC2_SPECIAL_NAN = 0x2, //!< NaN special value |
442 | | BLOSC2_SPECIAL_VALUE = 0x3, //!< repeated special value |
443 | | BLOSC2_SPECIAL_UNINIT = 0x4, //!< non initialized values |
444 | | BLOSC2_SPECIAL_LASTID = 0x4, //!< last valid ID for special value (update this adequately) |
445 | | BLOSC2_SPECIAL_MASK = 0x7 //!< special value mask (prev IDs cannot be larger than this) |
446 | | }; |
447 | | |
448 | | /** |
449 | | * @brief Error codes |
450 | | * Each time an error code is added here, its corresponding message error should be added in |
451 | | * print_error() |
452 | | */ |
453 | | enum { |
454 | | BLOSC2_ERROR_SUCCESS = 0, //<! Success |
455 | | BLOSC2_ERROR_FAILURE = -1, //<! Generic failure |
456 | | BLOSC2_ERROR_STREAM = -2, //<! Bad stream |
457 | | BLOSC2_ERROR_DATA = -3, //<! Invalid data |
458 | | BLOSC2_ERROR_MEMORY_ALLOC = -4, //<! Memory alloc/realloc failure |
459 | | BLOSC2_ERROR_READ_BUFFER = -5, //!< Not enough space to read |
460 | | BLOSC2_ERROR_WRITE_BUFFER = -6, //!< Not enough space to write |
461 | | BLOSC2_ERROR_CODEC_SUPPORT = -7, //!< Codec not supported |
462 | | BLOSC2_ERROR_CODEC_PARAM = -8, //!< Invalid parameter supplied to codec |
463 | | BLOSC2_ERROR_CODEC_DICT = -9, //!< Codec dictionary error |
464 | | BLOSC2_ERROR_VERSION_SUPPORT = -10, //!< Version not supported |
465 | | BLOSC2_ERROR_INVALID_HEADER = -11, //!< Invalid value in header |
466 | | BLOSC2_ERROR_INVALID_PARAM = -12, //!< Invalid parameter supplied to function |
467 | | BLOSC2_ERROR_FILE_READ = -13, //!< File read failure |
468 | | BLOSC2_ERROR_FILE_WRITE = -14, //!< File write failure |
469 | | BLOSC2_ERROR_FILE_OPEN = -15, //!< File open failure |
470 | | BLOSC2_ERROR_NOT_FOUND = -16, //!< Not found |
471 | | BLOSC2_ERROR_RUN_LENGTH = -17, //!< Bad run length encoding |
472 | | BLOSC2_ERROR_FILTER_PIPELINE = -18, //!< Filter pipeline error |
473 | | BLOSC2_ERROR_CHUNK_INSERT = -19, //!< Chunk insert failure |
474 | | BLOSC2_ERROR_CHUNK_APPEND = -20, //!< Chunk append failure |
475 | | BLOSC2_ERROR_CHUNK_UPDATE = -21, //!< Chunk update failure |
476 | | BLOSC2_ERROR_2GB_LIMIT = -22, //!< Sizes larger than 2gb not supported |
477 | | BLOSC2_ERROR_SCHUNK_COPY = -23, //!< Super-chunk copy failure |
478 | | BLOSC2_ERROR_FRAME_TYPE = -24, //!< Wrong type for frame |
479 | | BLOSC2_ERROR_FILE_TRUNCATE = -25, //!< File truncate failure |
480 | | BLOSC2_ERROR_THREAD_CREATE = -26, //!< Thread or thread context creation failure |
481 | | BLOSC2_ERROR_POSTFILTER = -27, //!< Postfilter failure |
482 | | BLOSC2_ERROR_FRAME_SPECIAL = -28, //!< Special frame failure |
483 | | BLOSC2_ERROR_SCHUNK_SPECIAL = -29, //!< Special super-chunk failure |
484 | | BLOSC2_ERROR_PLUGIN_IO = -30, //!< IO plugin error |
485 | | BLOSC2_ERROR_FILE_REMOVE = -31, //!< Remove file failure |
486 | | BLOSC2_ERROR_NULL_POINTER = -32, //!< Pointer is null |
487 | | BLOSC2_ERROR_INVALID_INDEX = -33, //!< Invalid index |
488 | | BLOSC2_ERROR_METALAYER_NOT_FOUND = -34, //!< Metalayer has not been found |
489 | | BLOSC2_ERROR_MAX_BUFSIZE_EXCEEDED = -35, //!< Max buffer size exceeded |
490 | | BLOSC2_ERROR_TUNER = -36, //!< Tuner failure |
491 | | BLOSC2_ERROR_LOCK = -37, //!< Frame lock failure |
492 | | }; |
493 | | |
494 | | |
495 | | #ifdef __GNUC__ |
496 | | #define BLOSC_ATTRIBUTE_UNUSED __attribute__((unused)) |
497 | | #else |
498 | | #define BLOSC_ATTRIBUTE_UNUSED |
499 | | #endif |
500 | | |
501 | | /** |
502 | | * @brief Get the string representation of an error code. |
503 | | * |
504 | | * The returned string is a static string, so it should not be modified or freed. |
505 | | * For unknown error codes, it returns "Unknown error". |
506 | | * |
507 | | * @param error_code The error code to get the string representation for. |
508 | | * @return A pointer to a static string representing the error code. |
509 | | */ |
510 | | BLOSC_EXPORT const char *blosc2_error_string(int error_code); |
511 | | |
512 | | /** |
513 | | * @brief Get the string representation of an error code. |
514 | | * |
515 | | * This function is identical to #blosc2_error_string, but with a legacy interface. |
516 | | * The returned string is a static read only string, so it should not be modified or freed, |
517 | | * although it is not const. |
518 | | * |
519 | | * Prefer using #blosc2_error_string instead. |
520 | | * |
521 | | * @param rc The error code to get the string representation for. |
522 | | * @return A pointer to a static string representing the error code. |
523 | | */ |
524 | | static char *print_error(int rc) BLOSC_ATTRIBUTE_UNUSED; |
525 | 40 | static char *print_error(int rc) { |
526 | | // TODO: remove this function, use blosc2_error_string only |
527 | 40 | return (char *) blosc2_error_string(rc); |
528 | 40 | } Unexecuted instantiation: fuzz_compress_frame.c:print_error Line | Count | Source | 525 | 20 | static char *print_error(int rc) { | 526 | | // TODO: remove this function, use blosc2_error_string only | 527 | 20 | return (char *) blosc2_error_string(rc); | 528 | 20 | } |
Unexecuted instantiation: blosclz.c:print_error Unexecuted instantiation: schunk.c:print_error Unexecuted instantiation: frame.c:print_error Unexecuted instantiation: stune.c:print_error Unexecuted instantiation: trunc-prec.c:print_error Unexecuted instantiation: timestamp.c:print_error Unexecuted instantiation: sframe.c:print_error Unexecuted instantiation: blosc2-stdio.c:print_error Unexecuted instantiation: b2nd.c:print_error Unexecuted instantiation: b2nd_utils.c:print_error Unexecuted instantiation: shuffle.c:print_error Unexecuted instantiation: blosc2-zfp.c:print_error Unexecuted instantiation: codecs-registry.c:print_error Unexecuted instantiation: tuners-registry.c:print_error Unexecuted instantiation: filters-registry.c:print_error Unexecuted instantiation: ndlz.c:print_error Unexecuted instantiation: ndlz4x4.c:print_error Unexecuted instantiation: ndlz8x8.c:print_error Unexecuted instantiation: ndcell.c:print_error Unexecuted instantiation: ndmean.c:print_error Line | Count | Source | 525 | 20 | static char *print_error(int rc) { | 526 | | // TODO: remove this function, use blosc2_error_string only | 527 | 20 | return (char *) blosc2_error_string(rc); | 528 | 20 | } |
Unexecuted instantiation: int_trunc.c:print_error Unexecuted instantiation: fuzz_decompress_frame.c:print_error Unexecuted instantiation: fuzz_compress_chunk.c:print_error Unexecuted instantiation: fuzz_decompress_chunk.c:print_error |
529 | | |
530 | | |
531 | | /** |
532 | | * @brief Initialize the Blosc library environment. |
533 | | * |
534 | | * You must call this previous to any other Blosc call, unless you want |
535 | | * Blosc to be used simultaneously in a multi-threaded environment, in |
536 | | * which case you can use the #blosc2_compress_ctx #blosc2_decompress_ctx pair. |
537 | | * |
538 | | * @sa #blosc2_destroy |
539 | | */ |
540 | | BLOSC_EXPORT void blosc2_init(void); |
541 | | |
542 | | |
543 | | /** |
544 | | * @brief Destroy the Blosc library environment. |
545 | | * |
546 | | * You must call this after to you are done with all the Blosc calls, |
547 | | * unless you have not used blosc2_init() before. |
548 | | * |
549 | | * @sa #blosc2_init |
550 | | */ |
551 | | BLOSC_EXPORT void blosc2_destroy(void); |
552 | | |
553 | | |
554 | | /** |
555 | | * @brief Compress a block of data in the @p src buffer and returns the size of |
556 | | * compressed block. |
557 | | * |
558 | | * @remark Compression is memory safe and guaranteed not to write @p dest |
559 | | * more than what is specified in @p destsize. |
560 | | * There is not a minimum for @p src buffer size @p nbytes. |
561 | | * Equivalent to #blosc2_compress. |
562 | | * |
563 | | * @warning The @p src buffer and the @p dest buffer can not overlap. |
564 | | * |
565 | | * @param clevel The desired compression level and must be a number |
566 | | * between 0 (no compression) and 9 (maximum compression). |
567 | | * @param doshuffle Specifies whether the shuffle compression preconditioner |
568 | | * should be applied or not. #BLOSC_NOFILTER means not applying filters, |
569 | | * #BLOSC_SHUFFLE means applying shuffle at a byte level and |
570 | | * #BLOSC_BITSHUFFLE at a bit level (slower but *may* achieve better |
571 | | * compression). |
572 | | * @param typesize Is the number of bytes for the atomic type in binary |
573 | | * @p src buffer. This is mainly useful for the shuffle preconditioner. |
574 | | * For implementation reasons, only a 1 < typesize < 256 will allow the |
575 | | * shuffle filter to work. When typesize is not in this range, shuffle |
576 | | * will be silently disabled. |
577 | | * @param nbytes The number of bytes to compress in the @p src buffer. |
578 | | * @param src The buffer containing the data to compress. |
579 | | * @param dest The buffer where the compressed data will be put, |
580 | | * must have at least the size of @p destsize. |
581 | | * @param destsize The size of the dest buffer. Blosc |
582 | | * guarantees that if you set @p destsize to, at least, |
583 | | * (@p nbytes + #BLOSC2_MAX_OVERHEAD), the compression will always succeed. |
584 | | * |
585 | | * @return The number of bytes compressed. |
586 | | * If @p src buffer cannot be compressed into @p destsize, the return |
587 | | * value is zero and you should discard the contents of the @p dest |
588 | | * buffer. A negative return value means that an internal error happened. This |
589 | | * should never happen. If you see this, please report it back |
590 | | * together with the buffer data causing this and compression settings. |
591 | | * |
592 | | * |
593 | | * @par Environment variables |
594 | | * @parblock |
595 | | * |
596 | | * This function honors different environment variables to control |
597 | | * internal parameters without the need of doing that programmatically. |
598 | | * Here are the ones supported: |
599 | | * |
600 | | * * **BLOSC_CLEVEL=(INTEGER)**: This will overwrite the @p clevel parameter |
601 | | * before the compression process starts. |
602 | | * |
603 | | * * **BLOSC_SHUFFLE=[NOSHUFFLE | SHUFFLE | BITSHUFFLE]**: This will |
604 | | * overwrite the @p doshuffle parameter before the compression process |
605 | | * starts. |
606 | | * |
607 | | * * **BLOSC_DELTA=(1|0)**: This will call #blosc2_set_delta() before the |
608 | | * compression process starts. |
609 | | * |
610 | | * * **BLOSC_TYPESIZE=(INTEGER)**: This will overwrite the @p typesize |
611 | | * parameter before the compression process starts. |
612 | | * |
613 | | * * **BLOSC_COMPRESSOR=[BLOSCLZ | LZ4 | LZ4HC | ZLIB | ZSTD]**: |
614 | | * This will call #blosc1_set_compressor before the compression process starts. |
615 | | * |
616 | | * * **BLOSC_NTHREADS=(INTEGER)**: This will call |
617 | | * #blosc2_set_nthreads before the compression process starts. |
618 | | * |
619 | | * * **BLOSC_SPLITMODE=(ALWAYS | NEVER | AUTO | FORWARD_COMPAT)**: |
620 | | * This will call #blosc1_set_splitmode() before the compression process starts. |
621 | | * |
622 | | * * **BLOSC_BLOCKSIZE=(INTEGER)**: This will call |
623 | | * #blosc1_set_blocksize before the compression process starts. |
624 | | * *NOTE:* The *blocksize* is a critical parameter with |
625 | | * important restrictions in the allowed values, so use this with care. |
626 | | * |
627 | | * * **BLOSC_NOLOCK=(ANY VALUE)**: This will call #blosc2_compress_ctx under |
628 | | * the hood, with the *compressor*, *blocksize* and |
629 | | * *numinternalthreads* parameters set to the same as the last calls to |
630 | | * #blosc1_set_compressor, #blosc1_set_blocksize and |
631 | | * #blosc2_set_nthreads. *BLOSC_CLEVEL*, *BLOSC_SHUFFLE*, *BLOSC_DELTA* and |
632 | | * *BLOSC_TYPESIZE* environment vars will also be honored. |
633 | | * |
634 | | * * **BLOSC_BLOSC1_COMPAT=(ANY VALUE)**: The chunk is written in the Blosc1 format, |
635 | | * as if #blosc2_ctx_set_blosc1_format() had been called, so that C-Blosc 1.x can |
636 | | * decode it. Also honored together with *BLOSC_NOLOCK*. |
637 | | * |
638 | | * @endparblock |
639 | | * |
640 | | * @sa #blosc1_decompress |
641 | | */ |
642 | | BLOSC_EXPORT int blosc1_compress(int clevel, int doshuffle, size_t typesize, |
643 | | size_t nbytes, const void* src, void* dest, |
644 | | size_t destsize); |
645 | | |
646 | | |
647 | | /** |
648 | | * @brief Decompress a block of compressed data in @p src, put the result in |
649 | | * @p dest and returns the size of the decompressed block. |
650 | | * |
651 | | * @warning The @p src buffer and the @p dest buffer can not overlap. |
652 | | * |
653 | | * @remark Decompression is memory safe and guaranteed not to write the @p dest |
654 | | * buffer more than what is specified in @p destsize. |
655 | | * Similar to #blosc2_decompress. |
656 | | * |
657 | | * @remark In case you want to keep under control the number of bytes read from |
658 | | * source, you can call #blosc1_cbuffer_sizes first to check whether the |
659 | | * @p nbytes (i.e. the number of bytes to be read from @p src buffer by this |
660 | | * function) in the compressed buffer is ok with you. |
661 | | * |
662 | | * @param src The buffer to be decompressed. |
663 | | * @param dest The buffer where the decompressed data will be put. |
664 | | * @param destsize The size of the @p dest buffer. |
665 | | * |
666 | | * @return The number of bytes decompressed. |
667 | | * If an error occurs, e.g. the compressed data is corrupted or the |
668 | | * output buffer is not large enough, then a negative value |
669 | | * will be returned instead. |
670 | | * |
671 | | * @par Environment variables |
672 | | * @parblock |
673 | | * This function honors different environment variables to control |
674 | | * internal parameters without the need of doing that programmatically. |
675 | | * Here are the ones supported: |
676 | | * |
677 | | * * **BLOSC_NTHREADS=(INTEGER)**: This will call |
678 | | * #blosc2_set_nthreads before the proper decompression |
679 | | * process starts. |
680 | | * |
681 | | * * **BLOSC_NOLOCK=(ANY VALUE)**: This will call #blosc2_decompress_ctx |
682 | | * under the hood, with the *numinternalthreads* parameter set to the |
683 | | * same value as the last call to #blosc2_set_nthreads. |
684 | | * |
685 | | * @endparblock |
686 | | * |
687 | | * @sa #blosc1_compress |
688 | | */ |
689 | | BLOSC_EXPORT int blosc1_decompress(const void* src, void* dest, size_t destsize); |
690 | | |
691 | | |
692 | | /** |
693 | | * @brief Get @p nitems (of @p typesize size) in @p src buffer starting in @p start. |
694 | | * The items are returned in @p dest buffer, which has to have enough |
695 | | * space for storing all items. |
696 | | * |
697 | | * @remark The function #blosc2_getitem is a more complete and secure version. |
698 | | * |
699 | | * @param src The compressed buffer from data will be decompressed. |
700 | | * @param start The position of the first item (of @p typesize size) from where data |
701 | | * will be retrieved. |
702 | | * @param nitems The number of items (of @p typesize size) that will be retrieved. |
703 | | * @param dest The buffer where the decompressed data retrieved will be put. |
704 | | * |
705 | | * @return The number of bytes copied to @p dest or a negative value if |
706 | | * some error happens. |
707 | | */ |
708 | | BLOSC_EXPORT int blosc1_getitem(const void* src, int start, int nitems, void* dest); |
709 | | |
710 | | /** |
711 | | * @brief Get @p nitems (of @p typesize size) in @p src buffer starting in @p start. |
712 | | * The items are returned in @p dest buffer. The dest buffer should have enough space |
713 | | * for storing all items. This function is a more secure version of #blosc1_getitem. |
714 | | * |
715 | | * @param src The compressed buffer holding the data to be retrieved. |
716 | | * @param srcsize Size of the compressed buffer. |
717 | | * @param start The position of the first item (of @p typesize size) from where data |
718 | | * will be retrieved. |
719 | | * @param nitems The number of items (of @p typesize size) that will be retrieved. |
720 | | * @param dest The buffer where the retrieved data will be stored decompressed. |
721 | | * @param destsize Size of the buffer where retrieved data will be stored. |
722 | | * |
723 | | * @return The number of bytes copied to @p dest or a negative value if |
724 | | * some error happens. |
725 | | */ |
726 | | BLOSC_EXPORT int blosc2_getitem(const void* src, int32_t srcsize, int start, int nitems, |
727 | | void* dest, int32_t destsize); |
728 | | |
729 | | /** |
730 | | Pointer to a callback function that executes `dojob(jobdata + i*jobdata_elsize)` for `i = 0 to numjobs-1`, |
731 | | possibly in parallel threads (but not returning until all `dojob` calls have returned). This allows the |
732 | | caller to provide a custom threading backend as an alternative to the default Blosc-managed threads. |
733 | | `callback_data` is passed through from `blosc2_set_threads_callback`. |
734 | | */ |
735 | | typedef void (*blosc_threads_callback)(void *callback_data, void (*dojob)(void *), int numjobs, size_t jobdata_elsize, void *jobdata); |
736 | | |
737 | | /** |
738 | | * @brief Set the threading backend for parallel compression/decompression to use @p callback to execute work |
739 | | * instead of using the Blosc-managed threads. The @p callback_data argument is passed through to the callback. |
740 | | |
741 | | * @param callback: the callback to use. Passing `NULL` uses the default Blosc threading backend. |
742 | | * @param callback_data: the callback data. |
743 | | * |
744 | | * @warning This function is *not* thread-safe and should be called |
745 | | * before any other Blosc function: it affects all Blosc contexts. |
746 | | * @sa https://github.com/Blosc/c-blosc2/pull/81 |
747 | | */ |
748 | | BLOSC_EXPORT void blosc2_set_threads_callback(blosc_threads_callback callback, void *callback_data); |
749 | | |
750 | | |
751 | | /** |
752 | | * @brief Returns the current number of threads that are used for |
753 | | * compression/decompression. |
754 | | */ |
755 | | BLOSC_EXPORT int16_t blosc2_get_nthreads(void); |
756 | | |
757 | | |
758 | | /** |
759 | | * @brief Initialize a pool of threads for compression/decompression. If |
760 | | * @p nthreads is 1, then the serial version is chosen and a possible |
761 | | * previous existing pool is ended. If this is not called, @p nthreads |
762 | | * is set to 1 internally. |
763 | | * |
764 | | * @param nthreads The number of threads to use. |
765 | | * |
766 | | * @return The previous number of threads. |
767 | | */ |
768 | | BLOSC_EXPORT int16_t blosc2_set_nthreads(int16_t nthreads); |
769 | | |
770 | | |
771 | | /** |
772 | | * @brief Get the current compressor that is used for compression. |
773 | | * |
774 | | * @return The string identifying the compressor being used. |
775 | | */ |
776 | | BLOSC_EXPORT const char* blosc1_get_compressor(void); |
777 | | |
778 | | |
779 | | /** |
780 | | * @brief Select the compressor to be used. The supported ones are "blosclz", |
781 | | * "lz4", "lz4hc", "zlib" and "ztsd". If this function is not |
782 | | * called, then "blosclz" will be used. |
783 | | * |
784 | | * @param compname The name identifier of the compressor to be set. |
785 | | * |
786 | | * @return The code for the compressor (>=0). In case the compressor |
787 | | * is not recognized, or there is not support for it in this build, |
788 | | * it returns a -1. |
789 | | */ |
790 | | BLOSC_EXPORT int blosc1_set_compressor(const char* compname); |
791 | | |
792 | | |
793 | | /** |
794 | | * @brief Select the delta coding filter to be used. |
795 | | * |
796 | | * @param dodelta A value >0 will activate the delta filter. |
797 | | * If 0, it will be de-activated |
798 | | * |
799 | | * This call should always succeed. |
800 | | */ |
801 | | BLOSC_EXPORT void blosc2_set_delta(int dodelta); |
802 | | |
803 | | |
804 | | /** |
805 | | * @brief Get the compressor name associated with the compressor code. |
806 | | * |
807 | | * @param compcode The code identifying the compressor |
808 | | * @param compname The pointer to a string where the compressor name will be put. |
809 | | * |
810 | | * @return The compressor code. If the compressor code is not recognized, |
811 | | * or there is not support for it in this build, -1 is returned. |
812 | | */ |
813 | | BLOSC_EXPORT int blosc2_compcode_to_compname(int compcode, const char** compname); |
814 | | |
815 | | |
816 | | /** |
817 | | * @brief Get the compressor code associated with the compressor name. |
818 | | * |
819 | | * @param compname The string containing the compressor name. |
820 | | * |
821 | | * @return The compressor code. If the compressor name is not recognized, |
822 | | * or there is not support for it in this build, -1 is returned instead. |
823 | | */ |
824 | | BLOSC_EXPORT int blosc2_compname_to_compcode(const char* compname); |
825 | | |
826 | | |
827 | | /** |
828 | | * @brief Get a list of compressors supported in the current build. |
829 | | * |
830 | | * @return The comma separated string with the list of compressor names |
831 | | * supported. |
832 | | * |
833 | | * This function does not leak, so you should not free() the returned |
834 | | * list. |
835 | | * |
836 | | * This function should always succeed. |
837 | | */ |
838 | | BLOSC_EXPORT const char* blosc2_list_compressors(void); |
839 | | |
840 | | |
841 | | /** |
842 | | * @brief Get the version of Blosc in string format. |
843 | | * |
844 | | * @return The string with the current Blosc version. |
845 | | * Useful for dynamic libraries. |
846 | | */ |
847 | | BLOSC_EXPORT const char* blosc2_get_version_string(void); |
848 | | |
849 | | |
850 | | /** |
851 | | * @brief Get info from compression libraries included in the current build. |
852 | | * |
853 | | * @param compname The compressor name that you want info from. |
854 | | * @param complib The pointer to a string where the |
855 | | * compression library name, if available, will be put. |
856 | | * @param version The pointer to a string where the |
857 | | * compression library version, if available, will be put. |
858 | | * |
859 | | * @warning You are in charge of the @p complib and @p version strings, |
860 | | * you should free() them so as to avoid leaks. |
861 | | * |
862 | | * @return The code for the compression library (>=0). If it is not supported, |
863 | | * this function returns -1. |
864 | | */ |
865 | | BLOSC_EXPORT int blosc2_get_complib_info(const char* compname, char** complib, |
866 | | char** version); |
867 | | |
868 | | |
869 | | /** |
870 | | * @brief Free possible memory temporaries and thread resources. Use this |
871 | | * when you are not going to use Blosc for a long while. |
872 | | * |
873 | | * @return A 0 if succeeds, in case of problems releasing the resources, |
874 | | * it returns a negative number. |
875 | | */ |
876 | | BLOSC_EXPORT int blosc2_free_resources(void); |
877 | | |
878 | | |
879 | | /** |
880 | | * @brief Get information about a compressed buffer, namely the number of |
881 | | * uncompressed bytes (@p nbytes) and compressed (@p cbytes). It also |
882 | | * returns the @p blocksize (which is used internally for doing the |
883 | | * compression by blocks). |
884 | | * |
885 | | * @remark Equivalent to function #blosc2_cbuffer_sizes. |
886 | | * |
887 | | * @param cbuffer The buffer of compressed data. |
888 | | * @param nbytes The pointer where the number of uncompressed bytes will be put. |
889 | | * @param cbytes The pointer where the number of compressed bytes will be put. |
890 | | * @param blocksize The pointer where the block size will be put. |
891 | | * |
892 | | * You only need to pass the first BLOSC_MIN_HEADER_LENGTH bytes of a |
893 | | * compressed buffer for this call to work. |
894 | | * |
895 | | * This function should always succeed. |
896 | | */ |
897 | | BLOSC_EXPORT void blosc1_cbuffer_sizes(const void* cbuffer, size_t* nbytes, |
898 | | size_t* cbytes, size_t* blocksize); |
899 | | /** |
900 | | * @brief Get information about a compressed buffer, namely the number of |
901 | | * uncompressed bytes (@p nbytes) and compressed (@p cbytes). It also |
902 | | * returns the @p blocksize (which is used internally for doing the |
903 | | * compression by blocks). |
904 | | * |
905 | | * @param cbuffer The buffer of compressed data. |
906 | | * @param nbytes The pointer where the number of uncompressed bytes will be put. |
907 | | * @param cbytes The pointer where the number of compressed bytes stored in the |
908 | | * chunk header will be put. |
909 | | * @param blocksize The pointer where the block size will be put. |
910 | | * |
911 | | * @note: if any of the nbytes, cbytes or blocksize is NULL, it will not be returned. |
912 | | * |
913 | | * You only need to pass the first BLOSC_MIN_HEADER_LENGTH bytes of a |
914 | | * compressed buffer for this call to work. |
915 | | * |
916 | | * @note For lazy chunks returned by #blosc2_schunk_get_lazychunk, the returned |
917 | | * @p cbytes value is still the compressed size encoded in the chunk header, |
918 | | * not the full size of the lazy proxy buffer. When passing a lazy chunk to |
919 | | * #blosc2_decompress_ctx or #blosc2_getitem_ctx, use the size returned by |
920 | | * #blosc2_schunk_get_lazychunk as @p srcsize. |
921 | | * |
922 | | * @return On failure, returns negative value. |
923 | | */ |
924 | | BLOSC_EXPORT int blosc2_cbuffer_sizes(const void* cbuffer, int32_t* nbytes, |
925 | | int32_t* cbytes, int32_t* blocksize); |
926 | | |
927 | | /** |
928 | | * @brief Checks that the compressed buffer starting at @p cbuffer of length @p cbytes |
929 | | * may contain valid blosc compressed data, and that it is safe to call |
930 | | * blosc1_decompress/blosc1_getitem. |
931 | | * On success, returns 0 and sets @p nbytes to the size of the uncompressed data. |
932 | | * This does not guarantee that the decompression function won't return an error, |
933 | | * but does guarantee that it is safe to attempt decompression. |
934 | | * |
935 | | * @param cbuffer The buffer of compressed data. |
936 | | * @param cbytes The number of compressed bytes. |
937 | | * @param nbytes The pointer where the number of uncompressed bytes will be put. |
938 | | * |
939 | | * @return On failure, returns negative value. |
940 | | */ |
941 | | BLOSC_EXPORT int blosc1_cbuffer_validate(const void* cbuffer, size_t cbytes, |
942 | | size_t* nbytes); |
943 | | |
944 | | /** |
945 | | * @brief Get information about a compressed buffer, namely the type size |
946 | | * (@p typesize), as well as some internal @p flags. |
947 | | * |
948 | | * @param cbuffer The buffer of compressed data. |
949 | | * @param typesize The pointer where the type size will be put. |
950 | | * @param flags The pointer of the integer where the additional info is encoded. |
951 | | * The @p flags is a set of bits, where the currently used ones are: |
952 | | * * bit 0: whether the shuffle filter has been applied or not |
953 | | * * bit 1: whether the internal buffer is a pure memcpy or not |
954 | | * * bit 2: whether the bitshuffle filter has been applied or not |
955 | | * * bit 3: whether the delta coding filter has been applied or not |
956 | | * |
957 | | * You can use the @p BLOSC_DOSHUFFLE, @p BLOSC_DOBITSHUFFLE, @p BLOSC_DODELTA |
958 | | * and @p BLOSC_MEMCPYED symbols for extracting the interesting bits |
959 | | * (e.g. @p flags & @p BLOSC_DOSHUFFLE says whether the buffer is byte-shuffled |
960 | | * or not). |
961 | | * |
962 | | * This function should always succeed. |
963 | | */ |
964 | | BLOSC_EXPORT void blosc1_cbuffer_metainfo(const void* cbuffer, size_t* typesize, |
965 | | int* flags); |
966 | | |
967 | | |
968 | | /** |
969 | | * @brief Get information about a compressed buffer, namely the internal |
970 | | * Blosc format version (@p version) and the format for the internal |
971 | | * Lempel-Ziv compressor used (@p versionlz). |
972 | | * |
973 | | * @param cbuffer The buffer of compressed data. |
974 | | * @param version The pointer where the Blosc format version will be put. |
975 | | * @param versionlz The pointer where the Lempel-Ziv version will be put. |
976 | | * |
977 | | * This function should always succeed. |
978 | | */ |
979 | | BLOSC_EXPORT void blosc2_cbuffer_versions(const void* cbuffer, int* version, |
980 | | int* versionlz); |
981 | | |
982 | | |
983 | | /** |
984 | | * @brief Get the compressor library/format used in a compressed buffer. |
985 | | * |
986 | | * @param cbuffer The buffer of compressed data. |
987 | | * |
988 | | * @return The string identifying the compressor library/format used. |
989 | | * |
990 | | * This function should always succeed. |
991 | | */ |
992 | | BLOSC_EXPORT const char* blosc2_cbuffer_complib(const void* cbuffer); |
993 | | |
994 | | /********************************************************************* |
995 | | Structures and functions related with user-defined input/output. |
996 | | *********************************************************************/ |
997 | | |
998 | | enum { |
999 | | BLOSC2_IO_FILESYSTEM = 0, |
1000 | | BLOSC2_IO_FILESYSTEM_MMAP = 1, |
1001 | | BLOSC_IO_LAST_BLOSC_DEFINED = 2, // sentinel |
1002 | | BLOSC_IO_LAST_REGISTERED = 32, // sentinel |
1003 | | }; |
1004 | | |
1005 | | enum { |
1006 | | BLOSC2_IO_BLOSC_DEFINED = 32, |
1007 | | BLOSC2_IO_REGISTERED = 160, |
1008 | | BLOSC2_IO_USER_DEFINED = 256 |
1009 | | }; |
1010 | | |
1011 | | typedef void* (*blosc2_open_cb)(const char *urlpath, const char *mode, void *params); |
1012 | | typedef int (*blosc2_close_cb)(void *stream); |
1013 | | typedef int64_t (*blosc2_size_cb)(void *stream); |
1014 | | typedef int64_t (*blosc2_write_cb)(const void *ptr, int64_t size, int64_t nitems, int64_t position, void *stream); |
1015 | | typedef int64_t (*blosc2_read_cb)(void **ptr, int64_t size, int64_t nitems, int64_t position, void *stream); |
1016 | | typedef int (*blosc2_truncate_cb)(void *stream, int64_t size); |
1017 | | typedef int (*blosc2_destroy_cb)(void *params); |
1018 | | |
1019 | | |
1020 | | /* |
1021 | | * Input/Output callbacks. |
1022 | | */ |
1023 | | typedef struct { |
1024 | | uint8_t id; |
1025 | | //!< The IO identifier. |
1026 | | char* name; |
1027 | | //!< The IO name. |
1028 | | bool is_allocation_necessary; |
1029 | | //!< If true, the caller needs to allocate data for the read function (ptr argument). If false, the read function |
1030 | | //!< takes care of memory allocation and stores the address in the allocated_ptr argument. |
1031 | | blosc2_open_cb open; |
1032 | | //!< The IO open callback. |
1033 | | blosc2_close_cb close; |
1034 | | //!< The IO close callback. |
1035 | | blosc2_size_cb size; |
1036 | | //!< The IO size callback. |
1037 | | blosc2_write_cb write; |
1038 | | //!< The IO write callback. |
1039 | | blosc2_read_cb read; |
1040 | | //!< The IO read callback. |
1041 | | blosc2_truncate_cb truncate; |
1042 | | //!< The IO truncate callback. |
1043 | | blosc2_destroy_cb destroy; |
1044 | | //!< The IO destroy callback (called in the end when finished with the schunk). |
1045 | | } blosc2_io_cb; |
1046 | | |
1047 | | |
1048 | | /* |
1049 | | * Input/Output parameters. |
1050 | | */ |
1051 | | typedef struct { |
1052 | | uint8_t id; |
1053 | | const char *name; |
1054 | | //!< The IO identifier. |
1055 | | void *params; |
1056 | | //!< The IO parameters. |
1057 | | } blosc2_io; |
1058 | | |
1059 | | static const blosc2_io BLOSC2_IO_DEFAULTS = { |
1060 | | /* .id = */ BLOSC2_IO_FILESYSTEM, |
1061 | | /* .name = */ "filesystem", |
1062 | | /* .params = */ NULL, |
1063 | | }; |
1064 | | |
1065 | | |
1066 | | /** |
1067 | | * @brief Register a user-defined input/output callbacks in Blosc. |
1068 | | * |
1069 | | * @param io The callbacks API to register. |
1070 | | * |
1071 | | * @return 0 if succeeds. Else a negative code is returned. |
1072 | | */ |
1073 | | BLOSC_EXPORT int blosc2_register_io_cb(const blosc2_io_cb *io); |
1074 | | |
1075 | | /** |
1076 | | * @brief Get a user-defined input/output callback in Blosc. |
1077 | | * |
1078 | | * @param id The id of the callback to get. |
1079 | | * |
1080 | | * @return A pointer containing the desired callback if success. Else a NULL pointer is returned. |
1081 | | */ |
1082 | | BLOSC_EXPORT blosc2_io_cb *blosc2_get_io_cb(uint8_t id); |
1083 | | |
1084 | | /********************************************************************* |
1085 | | Structures and functions related with contexts. |
1086 | | *********************************************************************/ |
1087 | | |
1088 | | typedef struct blosc2_context_s blosc2_context; /* opaque type */ |
1089 | | |
1090 | | typedef struct { |
1091 | | int (*init)(void * config, blosc2_context* cctx, blosc2_context* dctx); |
1092 | | //!< Initialize tuner. Keep in mind dctx may be NULL. This should memcpy the cctx->tuner_params. |
1093 | | int (*next_blocksize)(blosc2_context * context); |
1094 | | //!< Only compute the next blocksize. Only it is executed if tuner is not initialized. |
1095 | | int (*next_cparams)(blosc2_context * context); |
1096 | | //!< Compute the next cparams. Only is executed if tuner is initialized. |
1097 | | int (*update)(blosc2_context * context, double ctime); |
1098 | | //!< Update the tuner parameters. |
1099 | | int (*free)(blosc2_context * context); |
1100 | | //!< Free the tuner. |
1101 | | int id; |
1102 | | //!< The tuner id |
1103 | | char *name; |
1104 | | //!< The tuner name |
1105 | | } blosc2_tuner; |
1106 | | |
1107 | | |
1108 | | /** |
1109 | | * @brief Register locally a user-defined tuner in Blosc. |
1110 | | * |
1111 | | * @param tuner The tuner to register. |
1112 | | * |
1113 | | * @return 0 if succeeds. Else a negative code is returned. |
1114 | | */ |
1115 | | BLOSC_EXPORT int blosc2_register_tuner(blosc2_tuner *tuner); |
1116 | | |
1117 | | |
1118 | | /** |
1119 | | * @brief The parameters for a prefilter function. |
1120 | | * |
1121 | | */ |
1122 | | typedef struct { |
1123 | | void *user_data; // user-provided info (optional) |
1124 | | const uint8_t *input; // the input buffer |
1125 | | uint8_t *output; // the output buffer |
1126 | | int32_t output_size; // the output size (in bytes) |
1127 | | int32_t output_typesize; // the output typesize |
1128 | | int32_t output_offset; // offset to reach the start of the output buffer |
1129 | | int64_t nchunk; // the current nchunk in associated schunk (if exists; if not -1) |
1130 | | int32_t nblock; // the current nblock in associated chunk |
1131 | | int32_t tid; // thread id |
1132 | | uint8_t *ttmp; // a temporary that is able to hold several blocks for the output and is private for each thread |
1133 | | size_t ttmp_nbytes; // the size of the temporary in bytes |
1134 | | blosc2_context *ctx; // the compression context |
1135 | | bool output_is_disposable; // whether the output buffer is disposable |
1136 | | } blosc2_prefilter_params; |
1137 | | |
1138 | | /** |
1139 | | * @brief The parameters for a postfilter function. |
1140 | | * |
1141 | | */ |
1142 | | typedef struct { |
1143 | | void *user_data; // user-provided info (optional) |
1144 | | const uint8_t *input; // the input buffer |
1145 | | uint8_t *output; // the output buffer |
1146 | | int32_t size; // the input size (in bytes) |
1147 | | int32_t typesize; // the input typesize |
1148 | | int32_t offset; // offset to reach the start of the input buffer |
1149 | | int64_t nchunk; // the current nchunk in associated schunk (if exists; if not -1) |
1150 | | int32_t nblock; // the current nblock in associated chunk |
1151 | | int32_t tid; // thread id |
1152 | | uint8_t *ttmp; // a temporary that is able to hold several blocks for the output and is private for each thread |
1153 | | size_t ttmp_nbytes; // the size of the temporary in bytes |
1154 | | blosc2_context *ctx; // the decompression context |
1155 | | } blosc2_postfilter_params; |
1156 | | |
1157 | | /** |
1158 | | * @brief The type of the prefilter function. |
1159 | | * |
1160 | | * If the function call is successful, the return value should be 0; else, a negative value. |
1161 | | */ |
1162 | | typedef int (*blosc2_prefilter_fn)(blosc2_prefilter_params* params); |
1163 | | |
1164 | | /** |
1165 | | * @brief The type of the postfilter function. |
1166 | | * |
1167 | | * If the function call is successful, the return value should be 0; else, a negative value. |
1168 | | */ |
1169 | | typedef int (*blosc2_postfilter_fn)(blosc2_postfilter_params* params); |
1170 | | |
1171 | | /** |
1172 | | * @brief The parameters for creating a context for compression purposes. |
1173 | | * |
1174 | | * In parenthesis it is shown the default value used internally when a 0 |
1175 | | * (zero) in the fields of the struct is passed to a function. |
1176 | | */ |
1177 | | typedef struct { |
1178 | | uint8_t compcode; |
1179 | | //!< The compressor codec. |
1180 | | uint8_t compcode_meta; |
1181 | | //!< The metadata for the compressor codec. |
1182 | | uint8_t clevel; |
1183 | | //!< The compression level (5). |
1184 | | int use_dict; |
1185 | | //!< Use dicts or not when compressing. Only ZSTD and LZ4/LZ4HC support this; |
1186 | | //!< other codecs will return an error if this is set. |
1187 | | int32_t typesize; |
1188 | | //!< The type size (8). |
1189 | | int16_t nthreads; |
1190 | | //!< The number of threads to use internally (1). |
1191 | | int32_t blocksize; |
1192 | | //!< The requested size of the compressed blocks (0 means automatic). |
1193 | | int32_t splitmode; |
1194 | | //!< Whether the blocks should be split or not. |
1195 | | void* schunk; |
1196 | | //!< The associated schunk, if any (NULL). |
1197 | | uint8_t filters[BLOSC2_MAX_FILTERS]; |
1198 | | //!< The (sequence of) filters. |
1199 | | uint8_t filters_meta[BLOSC2_MAX_FILTERS]; |
1200 | | //!< The metadata for filters. |
1201 | | blosc2_prefilter_fn prefilter; |
1202 | | //!< The prefilter function. |
1203 | | blosc2_prefilter_params *preparams; |
1204 | | //!< The prefilter parameters. |
1205 | | void *tuner_params; |
1206 | | //!< Tune configuration. |
1207 | | int tuner_id; |
1208 | | //!< The tuner id. |
1209 | | bool instr_codec; |
1210 | | //!< Whether the codec is instrumented or not |
1211 | | void *codec_params; |
1212 | | //!< User defined parameters for the codec |
1213 | | void *filter_params[BLOSC2_MAX_FILTERS]; |
1214 | | //!< User defined parameters for the filters |
1215 | | } blosc2_cparams; |
1216 | | |
1217 | | /** |
1218 | | * @brief Default struct for compression params meant for user initialization. |
1219 | | */ |
1220 | | static const blosc2_cparams BLOSC2_CPARAMS_DEFAULTS = { |
1221 | | BLOSC_BLOSCLZ, 0, 5, 0, 8, 1, 0, |
1222 | | BLOSC_FORWARD_COMPAT_SPLIT, NULL, |
1223 | | {0, 0, 0, 0, 0, BLOSC_SHUFFLE}, |
1224 | | {0, 0, 0, 0, 0, 0}, |
1225 | | NULL, NULL, NULL, 0, 0, |
1226 | | NULL, {NULL, NULL, NULL, NULL, NULL, NULL} |
1227 | | }; |
1228 | | |
1229 | | |
1230 | | /** |
1231 | | @brief The parameters for creating a context for decompression purposes. |
1232 | | |
1233 | | In parenthesis it is shown the default value used internally when a 0 |
1234 | | (zero) in the fields of the struct is passed to a function. |
1235 | | */ |
1236 | | typedef struct { |
1237 | | int16_t nthreads; |
1238 | | //!< The number of threads to use internally (1). |
1239 | | void* schunk; |
1240 | | //!< The associated schunk, if any (NULL). |
1241 | | blosc2_postfilter_fn postfilter; |
1242 | | //!< The postfilter function. |
1243 | | blosc2_postfilter_params *postparams; |
1244 | | //!< The postfilter parameters. |
1245 | | int32_t typesize; |
1246 | | //!< The type size (8). |
1247 | | } blosc2_dparams; |
1248 | | |
1249 | | /** |
1250 | | * @brief Default struct for decompression params meant for user initialization. |
1251 | | */ |
1252 | | static const blosc2_dparams BLOSC2_DPARAMS_DEFAULTS = {1, NULL, NULL, NULL, 8}; |
1253 | | |
1254 | | |
1255 | | /** |
1256 | | * @brief Create a context for @a *_ctx() compression functions. |
1257 | | * |
1258 | | * @param cparams The blosc2_cparams struct with the compression parameters. |
1259 | | * |
1260 | | * @return A pointer to the new context. NULL is returned if this fails. |
1261 | | * |
1262 | | * @note This supports the same environment variables than #blosc2_compress |
1263 | | * for overriding the programmatic compression values. |
1264 | | * |
1265 | | * @sa #blosc2_compress |
1266 | | */ |
1267 | | BLOSC_EXPORT blosc2_context* blosc2_create_cctx(blosc2_cparams cparams); |
1268 | | |
1269 | | /** |
1270 | | * @brief Create a context for *_ctx() decompression functions. |
1271 | | * |
1272 | | * @param dparams The blosc2_dparams struct with the decompression parameters. |
1273 | | * |
1274 | | * @return A pointer to the new context. NULL is returned if this fails. |
1275 | | * |
1276 | | * @note This supports the same environment variables than #blosc2_decompress |
1277 | | * for overriding the programmatic decompression values. |
1278 | | * |
1279 | | * @sa #blosc2_decompress |
1280 | | * |
1281 | | */ |
1282 | | BLOSC_EXPORT blosc2_context* blosc2_create_dctx(blosc2_dparams dparams); |
1283 | | |
1284 | | /** |
1285 | | * @brief Free the resources associated with a context. |
1286 | | * |
1287 | | * @param context The context to free. |
1288 | | * |
1289 | | * This function should always succeed and is valid for contexts meant for |
1290 | | * both compression and decompression. |
1291 | | */ |
1292 | | BLOSC_EXPORT void blosc2_free_ctx(blosc2_context* context); |
1293 | | |
1294 | | /** |
1295 | | * @brief Create a @p cparams associated to a context. |
1296 | | * |
1297 | | * @param ctx The context from where to extract the compression parameters. |
1298 | | * @param cparams The pointer where the compression params will be stored. |
1299 | | * |
1300 | | * @return 0 if succeeds. Else a negative code is returned. |
1301 | | */ |
1302 | | BLOSC_EXPORT int blosc2_ctx_get_cparams(blosc2_context *ctx, blosc2_cparams *cparams); |
1303 | | |
1304 | | /** |
1305 | | * @brief Create a @p dparams associated to a context. |
1306 | | * |
1307 | | * @param ctx The context from where to extract the decompression parameters. |
1308 | | * @param dparams The pointer where the decompression params will be stored. |
1309 | | * |
1310 | | * @return 0 if succeeds. Else a negative code is returned. |
1311 | | */ |
1312 | | BLOSC_EXPORT int blosc2_ctx_get_dparams(blosc2_context *ctx, blosc2_dparams *dparams); |
1313 | | |
1314 | | /** |
1315 | | * @brief Set a maskout so as to avoid decompressing specified blocks. |
1316 | | * |
1317 | | * @param ctx The decompression context to update. |
1318 | | * |
1319 | | * @param maskout The boolean mask for the blocks where decompression |
1320 | | * is to be avoided. |
1321 | | * |
1322 | | * @remark The maskout is valid for contexts *only* meant for decompressing |
1323 | | * a chunk via #blosc2_decompress_ctx. Once a call to #blosc2_decompress_ctx |
1324 | | * is done, this mask is reset so that next call to #blosc2_decompress_ctx |
1325 | | * will decompress the whole chunk. |
1326 | | * |
1327 | | * @param nblocks The number of blocks in maskout above. |
1328 | | * |
1329 | | * @return If success, a 0 is returned. An error is signaled with a negative int. |
1330 | | * |
1331 | | */ |
1332 | | BLOSC_EXPORT int blosc2_set_maskout(blosc2_context *ctx, bool *maskout, int nblocks); |
1333 | | |
1334 | | /** |
1335 | | * @brief Compress a block of data in the @p src buffer and returns the size of |
1336 | | * compressed block. |
1337 | | * |
1338 | | * @remark Compression is memory safe and guaranteed not to write @p dest |
1339 | | * more than what is specified in @p destsize. |
1340 | | * There is not a minimum for @p src buffer size @p nbytes. |
1341 | | * |
1342 | | * @warning The @p src buffer and the @p dest buffer can not overlap. |
1343 | | * |
1344 | | * @param clevel The desired compression level and must be a number |
1345 | | * between 0 (no compression) and 9 (maximum compression). |
1346 | | * @param doshuffle Specifies whether the shuffle compression preconditioner |
1347 | | * should be applied or not. #BLOSC_NOFILTER means not applying filters, |
1348 | | * #BLOSC_SHUFFLE means applying shuffle at a byte level and |
1349 | | * #BLOSC_BITSHUFFLE at a bit level (slower but *may* achieve better |
1350 | | * compression). |
1351 | | * @param typesize Is the number of bytes for the atomic type in binary |
1352 | | * @p src buffer. This is mainly useful for the shuffle preconditioner. |
1353 | | * For implementation reasons, only a 1 < typesize < 256 will allow the |
1354 | | * shuffle filter to work. When typesize is not in this range, shuffle |
1355 | | * will be silently disabled. |
1356 | | * @param src The buffer containing the data to compress. |
1357 | | * @param srcsize The number of bytes to compress in the @p src buffer. |
1358 | | * @param dest The buffer where the compressed data will be put, |
1359 | | * must have at least the size of @p destsize. |
1360 | | * @param destsize The size of the dest buffer. Blosc |
1361 | | * guarantees that if you set @p destsize to, at least, |
1362 | | * (@p nbytes + #BLOSC2_MAX_OVERHEAD), the compression will always succeed. |
1363 | | * |
1364 | | * @return The number of bytes compressed. |
1365 | | * If @p src buffer cannot be compressed into @p destsize, the return |
1366 | | * value is zero and you should discard the contents of the @p dest |
1367 | | * buffer. A negative return value means that either a parameter is not correct |
1368 | | * or that an internal error happened. Set the BLOSC_TRACE environment variable |
1369 | | * for getting more info on what is happening. If the error is not related with |
1370 | | * wrong params, please report it back together with the buffer data causing this, |
1371 | | * as well as the compression params used. |
1372 | | */ |
1373 | | /* |
1374 | | * Environment variables |
1375 | | * _____________________ |
1376 | | * |
1377 | | * *blosc2_compress()* honors different environment variables to control |
1378 | | * internal parameters without the need of doing that programmatically. |
1379 | | * Here are the ones supported: |
1380 | | * |
1381 | | * **BLOSC_CLEVEL=(INTEGER)**: This will overwrite the @p clevel parameter |
1382 | | * before the compression process starts. |
1383 | | * |
1384 | | * **BLOSC_SHUFFLE=[NOSHUFFLE | SHUFFLE | BITSHUFFLE]**: This will |
1385 | | * overwrite the *doshuffle* parameter before the compression process |
1386 | | * starts. |
1387 | | * |
1388 | | * **BLOSC_DELTA=(1|0)**: This will call *blosc2_set_delta()^* before the |
1389 | | * compression process starts. |
1390 | | * |
1391 | | * **BLOSC_TYPESIZE=(INTEGER)**: This will overwrite the *typesize* |
1392 | | * parameter before the compression process starts. |
1393 | | * |
1394 | | * **BLOSC_COMPRESSOR=[BLOSCLZ | LZ4 | LZ4HC | ZLIB | ZSTD]**: |
1395 | | * This will call #blosc_set_compressor before the compression process starts. |
1396 | | * |
1397 | | * **BLOSC_NTHREADS=(INTEGER)**: This will call |
1398 | | * #blosc_set_nthreads before the compression process |
1399 | | * starts. |
1400 | | * |
1401 | | * **BLOSC_SPLITMODE=(ALWAYS | NEVER | AUTO | FORWARD_COMPAT)**: |
1402 | | * This will call #blosc1_set_splitmode() before the compression process starts. |
1403 | | * |
1404 | | * **BLOSC_BLOCKSIZE=(INTEGER)**: This will call |
1405 | | * #blosc_set_blocksize before the compression process starts. |
1406 | | * *NOTE:* The blocksize is a critical parameter with |
1407 | | * important restrictions in the allowed values, so use this with care. |
1408 | | * |
1409 | | * **BLOSC_NOLOCK=(ANY VALUE)**: This will call #blosc2_compress_ctx under |
1410 | | * the hood, with the *compressor*, *blocksize* and |
1411 | | * *numinternalthreads* parameters set to the same as the last calls to |
1412 | | * #blosc1_set_compressor, #blosc1_set_blocksize and |
1413 | | * #blosc2_set_nthreads. *BLOSC_CLEVEL*, *BLOSC_SHUFFLE*, *BLOSC_DELTA* and |
1414 | | * *BLOSC_TYPESIZE* environment vars will also be honored. |
1415 | | * |
1416 | | */ |
1417 | | BLOSC_EXPORT int blosc2_compress(int clevel, int doshuffle, int32_t typesize, |
1418 | | const void* src, int32_t srcsize, void* dest, |
1419 | | int32_t destsize); |
1420 | | |
1421 | | |
1422 | | /** |
1423 | | * @brief Decompress a block of compressed data in @p src, put the result in |
1424 | | * @p dest and returns the size of the decompressed block. |
1425 | | * |
1426 | | * @warning The @p src buffer and the @p dest buffer can not overlap. |
1427 | | * |
1428 | | * @remark Decompression is memory safe and guaranteed not to write the @p dest |
1429 | | * buffer more than what is specified in @p destsize. |
1430 | | * |
1431 | | * @remark In case you want to keep under control the number of bytes read from |
1432 | | * source, you can call #blosc1_cbuffer_sizes first to check whether the |
1433 | | * @p nbytes (i.e. the number of bytes to be read from @p src buffer by this |
1434 | | * function) in the compressed buffer is ok with you. |
1435 | | * |
1436 | | * @param src The buffer to be decompressed. |
1437 | | * @param srcsize The size of the buffer to be decompressed. |
1438 | | * @param dest The buffer where the decompressed data will be put. |
1439 | | * @param destsize The size of the @p dest buffer. |
1440 | | * |
1441 | | * @return The number of bytes decompressed. |
1442 | | * If an error occurs, e.g. the compressed data is corrupted or the |
1443 | | * output buffer is not large enough, then a negative value |
1444 | | * will be returned instead. |
1445 | | */ |
1446 | | /* |
1447 | | * Environment variables |
1448 | | * _____________________ |
1449 | | * |
1450 | | * *blosc1_decompress* honors different environment variables to control |
1451 | | * internal parameters without the need of doing that programmatically. |
1452 | | * Here are the ones supported: |
1453 | | * |
1454 | | * **BLOSC_NTHREADS=(INTEGER)**: This will call |
1455 | | * *blosc_set_nthreads(BLOSC_NTHREADS)* before the proper decompression |
1456 | | * process starts. |
1457 | | * |
1458 | | * **BLOSC_NOLOCK=(ANY VALUE)**: This will call *blosc2_decompress_ctx* |
1459 | | * under the hood, with the *numinternalthreads* parameter set to the |
1460 | | * same value as the last call to *blosc2_set_nthreads*. |
1461 | | * |
1462 | | */ |
1463 | | BLOSC_EXPORT int blosc2_decompress(const void* src, int32_t srcsize, |
1464 | | void* dest, int32_t destsize); |
1465 | | |
1466 | | /** |
1467 | | * @brief Context interface to Blosc compression. This does not require a call |
1468 | | * to #blosc2_init and can be called from multithreaded applications |
1469 | | * without the global lock being used, so allowing Blosc be executed |
1470 | | * simultaneously in those scenarios. |
1471 | | * |
1472 | | * @param context A blosc2_context struct with the different compression params. |
1473 | | * @param src The buffer containing the data to be compressed. |
1474 | | * @param srcsize The number of bytes to be compressed from the @p src buffer. |
1475 | | * @param dest The buffer where the compressed data will be put. |
1476 | | * @param destsize The size in bytes of the @p dest buffer. |
1477 | | * |
1478 | | * @return The number of bytes compressed. |
1479 | | * If @p src buffer cannot be compressed into @p destsize, the return |
1480 | | * value is zero and you should discard the contents of the @p dest |
1481 | | * buffer. A negative return value means that an internal error happened. |
1482 | | * It could happen that context is not meant for compression (which is stated in stderr). |
1483 | | * Otherwise, please report it back together with the buffer data causing this |
1484 | | * and compression settings. |
1485 | | */ |
1486 | | BLOSC_EXPORT int blosc2_compress_ctx( |
1487 | | blosc2_context* context, const void* src, int32_t srcsize, void* dest, |
1488 | | int32_t destsize); |
1489 | | |
1490 | | /** |
1491 | | * @brief Context interface to Blosc compression for chunks with variable-length blocks. |
1492 | | * |
1493 | | * @param context A blosc2_context struct with the different compression params. |
1494 | | * @param srcs A list of pointers, one per block. |
1495 | | * @param srcsizes A list of uncompressed sizes, one per block. |
1496 | | * @param nblocks The number of blocks in the chunk. |
1497 | | * @param dest The buffer where the compressed chunk will be put. |
1498 | | * @param destsize The size in bytes of the @p dest buffer. |
1499 | | * |
1500 | | * @return The number of bytes compressed, or a negative error code. |
1501 | | */ |
1502 | | BLOSC_EXPORT int blosc2_vlcompress_ctx( |
1503 | | blosc2_context* context, const void* const* srcs, const int32_t* srcsizes, |
1504 | | int32_t nblocks, void* dest, int32_t destsize); |
1505 | | |
1506 | | |
1507 | | /** |
1508 | | * @brief Context interface to Blosc decompression. This does not require a |
1509 | | * call to #blosc2_init and can be called from multithreaded |
1510 | | * applications without the global lock being used, so allowing Blosc |
1511 | | * be executed simultaneously in those scenarios. |
1512 | | * |
1513 | | * @param context The blosc2_context struct with the different compression params. |
1514 | | * @param src The buffer of compressed data. |
1515 | | * @param srcsize The length of buffer of compressed data. If @p src is a lazy |
1516 | | * chunk returned by #blosc2_schunk_get_lazychunk, pass the size returned by |
1517 | | * #blosc2_schunk_get_lazychunk here rather than the @p cbytes value reported by |
1518 | | * #blosc2_cbuffer_sizes. |
1519 | | * @param dest The buffer where the decompressed data will be put. |
1520 | | * @param destsize The size in bytes of the @p dest buffer. |
1521 | | * |
1522 | | * @warning The @p src buffer and the @p dest buffer can not overlap. |
1523 | | * |
1524 | | * @remark Decompression is memory safe and guaranteed not to write the @p dest |
1525 | | * buffer more than what is specified in @p destsize. |
1526 | | * |
1527 | | * @remark In case you want to keep under control the number of bytes read from |
1528 | | * source, you can call #blosc1_cbuffer_sizes first to check the @p nbytes |
1529 | | * (i.e. the number of bytes to be read from @p src buffer by this function) |
1530 | | * in the compressed buffer. |
1531 | | * |
1532 | | * @remark If #blosc2_set_maskout is called prior to this function, its |
1533 | | * @p block_maskout parameter will be honored for just *one single* shot; |
1534 | | * i.e. the maskout in context will be automatically reset to NULL, so |
1535 | | * mask won't be used next time (unless #blosc2_set_maskout is called again). |
1536 | | * |
1537 | | * @return The number of bytes decompressed (i.e. the maskout blocks are not |
1538 | | * counted). If an error occurs, e.g. the compressed data is corrupted, |
1539 | | * @p destsize is not large enough or context is not meant for decompression, |
1540 | | * then a negative value will be returned instead. |
1541 | | */ |
1542 | | BLOSC_EXPORT int blosc2_decompress_ctx(blosc2_context* context, const void* src, |
1543 | | int32_t srcsize, void* dest, int32_t destsize); |
1544 | | |
1545 | | /** |
1546 | | * @brief Context interface to Blosc decompression for chunks with variable-length blocks. |
1547 | | * |
1548 | | * @param context The blosc2_context struct with the different decompression params. |
1549 | | * @param src The buffer of compressed data. |
1550 | | * @param srcsize The length of buffer of compressed data. |
1551 | | * @param dests On output, one newly allocated buffer per block. |
1552 | | * @param destsizes On output, the uncompressed sizes of the blocks. |
1553 | | * @param maxblocks The number of entries available in @p dests and @p destsizes. |
1554 | | * |
1555 | | * @return The number of blocks decompressed, or a negative error code. |
1556 | | */ |
1557 | | BLOSC_EXPORT int blosc2_vldecompress_ctx(blosc2_context* context, const void* src, |
1558 | | int32_t srcsize, void** dests, |
1559 | | int32_t* destsizes, int32_t maxblocks); |
1560 | | |
1561 | | /** |
1562 | | * @brief Return the number of variable-length blocks stored in a VL-block chunk. |
1563 | | * |
1564 | | * This is a header-only query: it reads only the chunk header and does not |
1565 | | * allocate or decompress anything. |
1566 | | * |
1567 | | * @param src The buffer of compressed data. Must carry the #BLOSC2_VL_BLOCKS flag. |
1568 | | * @param srcsize The length of the compressed data buffer. |
1569 | | * @param nblocks On success, the number of VL blocks in the chunk. |
1570 | | * |
1571 | | * @return 0 on success, or a negative error code. |
1572 | | * Returns #BLOSC2_ERROR_INVALID_PARAM if the chunk does not use VL blocks. |
1573 | | */ |
1574 | | BLOSC_EXPORT int blosc2_vlchunk_get_nblocks(const void* src, int32_t srcsize, |
1575 | | int32_t* nblocks); |
1576 | | |
1577 | | /** |
1578 | | * @brief Decompress a single variable-length block from a VL-block chunk. |
1579 | | * |
1580 | | * Only the requested block is decompressed and allocated; all other blocks |
1581 | | * in the chunk are untouched. |
1582 | | * |
1583 | | * @param context A decompression context (#blosc2_context created with |
1584 | | * #blosc2_create_dctx). If @p src is a lazy chunk (obtained via |
1585 | | * #blosc2_schunk_get_lazychunk), the caller must set @c context->schunk |
1586 | | * to the owning super-chunk (which must have an associated frame) before |
1587 | | * calling this function; the frame is used to read block data from disk. |
1588 | | * @param src The buffer of compressed data. Must carry the #BLOSC2_VL_BLOCKS flag. |
1589 | | * May be a fully in-memory chunk or a lazy chunk proxy. |
1590 | | * @param srcsize The length of the compressed data buffer. |
1591 | | * @param nblock Zero-based index of the block to decompress. |
1592 | | * @param dest On success, points to a newly allocated buffer containing the |
1593 | | * decompressed block. The caller is responsible for freeing this buffer with |
1594 | | * @c free(). |
1595 | | * @param destsize On success, the uncompressed byte size of the block. |
1596 | | * |
1597 | | * @return The uncompressed byte size of the block on success, or a negative |
1598 | | * error code. Returns #BLOSC2_ERROR_INVALID_PARAM if the chunk does not use |
1599 | | * VL blocks or if @p nblock is out of range. |
1600 | | */ |
1601 | | BLOSC_EXPORT int blosc2_vldecompress_block_ctx(blosc2_context* context, |
1602 | | const void* src, int32_t srcsize, |
1603 | | int32_t nblock, uint8_t** dest, |
1604 | | int32_t* destsize); |
1605 | | |
1606 | | /** |
1607 | | * @brief Query the uncompressed size of one VL block, without allocating |
1608 | | * payload, dictionary, or decompression scratch buffers. |
1609 | | * |
1610 | | * @param context A decompression context. For lazy chunks it must be associated |
1611 | | * with the owning SChunk through blosc2_dparams.schunk. |
1612 | | * @param src A compressed VL chunk, or a lazy chunk. |
1613 | | * @param srcsize Actual source buffer length (the size returned by |
1614 | | * #blosc2_schunk_get_lazychunk for lazy chunks, not header cbytes). |
1615 | | * @param nblock Zero-based block index. |
1616 | | * @param nbytes Receives the selected block size on success; unchanged on error. |
1617 | | * @return 0 on success, a negative error code on failure. |
1618 | | * |
1619 | | * Lazy queries read only the selected four-byte size prefix. This is an |
1620 | | * admission query, not full payload validation; decompression revalidates the |
1621 | | * size. Source buffers, contexts and backing storage must not be modified |
1622 | | * concurrently. The context is not reinitialized by this query. |
1623 | | */ |
1624 | | BLOSC_EXPORT int blosc2_vlblock_get_nbytes_ctx(blosc2_context* context, |
1625 | | const void* src, int32_t srcsize, |
1626 | | int32_t nblock, int32_t* nbytes); |
1627 | | |
1628 | | /** |
1629 | | * @brief Decompress one VL block into a caller-owned buffer. |
1630 | | * |
1631 | | * Parameters have the same meaning as #blosc2_vlblock_get_nbytes_ctx. |
1632 | | * @param dest Caller-provided output buffer, which must not overlap src. |
1633 | | * @param destsize Capacity of dest in bytes. |
1634 | | * @return Bytes decompressed, or a negative error code. An insufficient |
1635 | | * destination returns BLOSC2_ERROR_WRITE_BUFFER before dictionary or scratch |
1636 | | * allocation. The output buffer may be partially modified on other errors. |
1637 | | * |
1638 | | * Never writes beyond destsize. Decompression scratch is sized from the |
1639 | | * selected admitted block, not other blocks. Lazy spans are checked against |
1640 | | * their chunk and owning frame before reading. This is not a total-memory |
1641 | | * budget: block tables, compressed input, dictionaries, and codec internals |
1642 | | * have separate allocations. No output buffer is allocated by this function. |
1643 | | */ |
1644 | | BLOSC_EXPORT int blosc2_vldecompress_block_into_ctx(blosc2_context* context, |
1645 | | const void* src, int32_t srcsize, |
1646 | | int32_t nblock, void* dest, |
1647 | | int32_t destsize); |
1648 | | |
1649 | | /** |
1650 | | * @brief Create a chunk made of zeros. |
1651 | | * |
1652 | | * @param cparams The compression parameters. |
1653 | | * @param nbytes The size (in bytes) of the chunk. |
1654 | | * @param dest The buffer where the data chunk will be put. |
1655 | | * @param destsize The size (in bytes) of the @p dest buffer; |
1656 | | * must be BLOSC_EXTENDED_HEADER_LENGTH at least. |
1657 | | * |
1658 | | * @return The number of bytes compressed (BLOSC_EXTENDED_HEADER_LENGTH). |
1659 | | * If negative, there has been an error and @p dest is unusable. |
1660 | | * */ |
1661 | | BLOSC_EXPORT int blosc2_chunk_zeros(blosc2_cparams cparams, int32_t nbytes, |
1662 | | void* dest, int32_t destsize); |
1663 | | |
1664 | | |
1665 | | /** |
1666 | | * @brief Create a chunk made of nans. |
1667 | | * |
1668 | | * @param cparams The compression parameters; |
1669 | | * only 4 bytes (float) and 8 bytes (double) are supported. |
1670 | | * @param nbytes The size (in bytes) of the chunk. |
1671 | | * @param dest The buffer where the data chunk will be put. |
1672 | | * @param destsize The size (in bytes) of the @p dest buffer; |
1673 | | * must be BLOSC_EXTENDED_HEADER_LENGTH at least. |
1674 | | * |
1675 | | * @note Whether the NaNs are floats or doubles will be given by the typesize. |
1676 | | * |
1677 | | * @return The number of bytes compressed (BLOSC_EXTENDED_HEADER_LENGTH). |
1678 | | * If negative, there has been an error and @p dest is unusable. |
1679 | | * */ |
1680 | | BLOSC_EXPORT int blosc2_chunk_nans(blosc2_cparams cparams, int32_t nbytes, |
1681 | | void* dest, int32_t destsize); |
1682 | | |
1683 | | |
1684 | | /** |
1685 | | * @brief Create a chunk made of repeated values. |
1686 | | * |
1687 | | * @param cparams The compression parameters. |
1688 | | * @param nbytes The size (in bytes) of the chunk. |
1689 | | * @param dest The buffer where the data chunk will be put. |
1690 | | * @param destsize The size (in bytes) of the @p dest buffer. |
1691 | | * @param repeatval A pointer to the repeated value (little endian). |
1692 | | * The size of the value is given by @p cparams.typesize param. |
1693 | | * |
1694 | | * @return The number of bytes compressed (BLOSC_EXTENDED_HEADER_LENGTH + typesize). |
1695 | | * If negative, there has been an error and @p dest is unusable. |
1696 | | * */ |
1697 | | BLOSC_EXPORT int blosc2_chunk_repeatval(blosc2_cparams cparams, int32_t nbytes, |
1698 | | void* dest, int32_t destsize, const void* repeatval); |
1699 | | |
1700 | | |
1701 | | /** |
1702 | | * @brief Create a chunk made of uninitialized values. |
1703 | | * |
1704 | | * @param cparams The compression parameters. |
1705 | | * @param nbytes The size (in bytes) of the chunk. |
1706 | | * @param dest The buffer where the data chunk will be put. |
1707 | | * @param destsize The size (in bytes) of the @p dest buffer; |
1708 | | * must be BLOSC_EXTENDED_HEADER_LENGTH at least. |
1709 | | * |
1710 | | * @return The number of bytes compressed (BLOSC_EXTENDED_HEADER_LENGTH). |
1711 | | * If negative, there has been an error and @p dest is unusable. |
1712 | | * */ |
1713 | | BLOSC_EXPORT int blosc2_chunk_uninit(blosc2_cparams cparams, int32_t nbytes, |
1714 | | void* dest, int32_t destsize); |
1715 | | |
1716 | | |
1717 | | /** |
1718 | | * @brief Context interface counterpart for #blosc1_getitem. |
1719 | | * |
1720 | | * @param context Context pointer. |
1721 | | * @param src The compressed buffer from data will be decompressed. |
1722 | | * @param srcsize Compressed buffer length. If @p src is a lazy chunk returned by |
1723 | | * #blosc2_schunk_get_lazychunk, pass the size returned by |
1724 | | * #blosc2_schunk_get_lazychunk here rather than the @p cbytes value reported by |
1725 | | * #blosc2_cbuffer_sizes. |
1726 | | * @param start The position of the first item (of @p typesize size) from where data |
1727 | | * will be retrieved. |
1728 | | * @param nitems The number of items (of @p typesize size) that will be retrieved. |
1729 | | * @param dest The buffer where the decompressed data retrieved will be put. |
1730 | | * @param destsize Output buffer length. |
1731 | | * |
1732 | | * @warning @p start and @p nitems are counted in the typesize that the *chunk* |
1733 | | * records, which is not the typesize the data was created with when the latter |
1734 | | * exceeds #BLOSC_MAX_TYPESIZE. Such buffers are compressed as a plain stream of |
1735 | | * bytes with a stored typesize of 1, so for them one "item" here is one byte. |
1736 | | * Code that does not control the typesize (a library reading whatever its caller |
1737 | | * supplied) should use #blosc2_getitem_bytes_ctx instead, which is unambiguous |
1738 | | * at any typesize. |
1739 | | * |
1740 | | * @return The number of bytes copied to @p dest or a negative value if |
1741 | | * some error happens. |
1742 | | */ |
1743 | | BLOSC_EXPORT int blosc2_getitem_ctx(blosc2_context* context, const void* src, |
1744 | | int32_t srcsize, int start, int nitems, void* dest, |
1745 | | int32_t destsize); |
1746 | | |
1747 | | |
1748 | | /** |
1749 | | * @brief Retrieve a byte range out of a compressed buffer. |
1750 | | * |
1751 | | * This is the counterpart of #blosc2_getitem_ctx that counts in bytes rather |
1752 | | * than in items. Because a buffer whose typesize exceeds #BLOSC_MAX_TYPESIZE is |
1753 | | * stored with a typesize of 1, the unit of #blosc2_getitem_ctx silently changes |
1754 | | * with the typesize; bytes do not. Prefer this entry point in generic code that |
1755 | | * does not pick the typesize itself, and #blosc2_getitem_ctx where the typesize |
1756 | | * is known and at most #BLOSC_MAX_TYPESIZE, as counting in items reads better |
1757 | | * there. |
1758 | | * |
1759 | | * @param context Context pointer. |
1760 | | * @param src The compressed buffer from data will be decompressed. |
1761 | | * @param srcsize Compressed buffer length. If @p src is a lazy chunk returned by |
1762 | | * #blosc2_schunk_get_lazychunk, pass the size returned by |
1763 | | * #blosc2_schunk_get_lazychunk here rather than the @p cbytes value reported by |
1764 | | * #blosc2_cbuffer_sizes. |
1765 | | * @param start The position, counted in bytes into the *uncompressed* buffer, of |
1766 | | * the first byte from where data will be retrieved. |
1767 | | * @param nbytes The number of bytes that will be retrieved. |
1768 | | * @param dest The buffer where the decompressed data retrieved will be put. |
1769 | | * @param destsize Output buffer length. |
1770 | | * |
1771 | | * @remark @p start and @p nbytes must both be multiples of the typesize stored |
1772 | | * in the chunk, or #BLOSC2_ERROR_INVALID_PARAM is returned. This constraint is |
1773 | | * vacuous for typesizes above #BLOSC_MAX_TYPESIZE (the stored typesize is 1), and |
1774 | | * is met automatically by any caller deriving byte offsets from the real |
1775 | | * typesize, so it costs nothing in the cases this function exists for. |
1776 | | * |
1777 | | * @return The number of bytes copied to @p dest or a negative value if |
1778 | | * some error happens. |
1779 | | */ |
1780 | | BLOSC_EXPORT int blosc2_getitem_bytes_ctx(blosc2_context* context, const void* src, |
1781 | | int32_t srcsize, int32_t start, int32_t nbytes, |
1782 | | void* dest, int32_t destsize); |
1783 | | |
1784 | | |
1785 | | /********************************************************************* |
1786 | | Super-chunk related structures and functions. |
1787 | | *********************************************************************/ |
1788 | | |
1789 | 489 | #define BLOSC2_MAX_METALAYERS 16 |
1790 | 2 | #define BLOSC2_METALAYER_NAME_MAXLEN 31 |
1791 | | |
1792 | | // Allow for a reasonable number of vl metalayers |
1793 | | // max is 64 * 1024 due to msgpack map 16 in frame |
1794 | | // mem usage 8 * 1024 entries for blosc2_schunk.vlmetalayers[] is 64 KB |
1795 | 465 | #define BLOSC2_MAX_VLMETALAYERS (8 * 1024) |
1796 | | #define BLOSC2_VLMETALAYERS_NAME_MAXLEN BLOSC2_METALAYER_NAME_MAXLEN |
1797 | | |
1798 | | /** |
1799 | | * @brief This struct is meant for holding storage parameters for a |
1800 | | * for a blosc2 container, allowing to specify, for example, how to interpret |
1801 | | * the contents included in the schunk. |
1802 | | */ |
1803 | | typedef struct { |
1804 | | bool contiguous; |
1805 | | //!< Whether the chunks are contiguous or sparse. |
1806 | | char* urlpath; |
1807 | | //!< The path for persistent storage. If NULL, that means in-memory. |
1808 | | blosc2_cparams* cparams; |
1809 | | //!< The compression params when creating a schunk. |
1810 | | //!< If NULL, sensible defaults are used depending on the context. |
1811 | | blosc2_dparams* dparams; |
1812 | | //!< The decompression params when creating a schunk. |
1813 | | //!< If NULL, sensible defaults are used depending on the context. |
1814 | | blosc2_io *io; |
1815 | | //!< Input/output backend. |
1816 | | } blosc2_storage; |
1817 | | |
1818 | | /** |
1819 | | * @brief Default struct for #blosc2_storage meant for user initialization. |
1820 | | */ |
1821 | | static const blosc2_storage BLOSC2_STORAGE_DEFAULTS = {false, NULL, NULL, NULL, NULL}; |
1822 | | |
1823 | | /** |
1824 | | * @brief Get default struct for compression params meant for user initialization. |
1825 | | */ |
1826 | | BLOSC_EXPORT blosc2_cparams blosc2_get_blosc2_cparams_defaults(void); |
1827 | | |
1828 | | /** |
1829 | | * @brief Get default struct for decompression params meant for user initialization. |
1830 | | */ |
1831 | | BLOSC_EXPORT blosc2_dparams blosc2_get_blosc2_dparams_defaults(void); |
1832 | | |
1833 | | /** |
1834 | | * @brief Get default struct for #blosc2_storage meant for user initialization. |
1835 | | */ |
1836 | | BLOSC_EXPORT blosc2_storage blosc2_get_blosc2_storage_defaults(void); |
1837 | | |
1838 | | /** |
1839 | | * @brief Get default struct for #blosc2_io meant for user initialization. |
1840 | | */ |
1841 | | BLOSC_EXPORT blosc2_io blosc2_get_blosc2_io_defaults(void); |
1842 | | |
1843 | | /** |
1844 | | * @brief Get default struct for #blosc2_stdio_mmap meant for user initialization. |
1845 | | */ |
1846 | | BLOSC_EXPORT blosc2_stdio_mmap blosc2_get_blosc2_stdio_mmap_defaults(void); |
1847 | | |
1848 | | typedef struct blosc2_frame_s blosc2_frame; /* opaque type */ |
1849 | | |
1850 | | /** |
1851 | | * @brief This struct is meant to store metadata information inside |
1852 | | * a #blosc2_schunk, allowing to specify, for example, how to interpret |
1853 | | * the contents included in the schunk. |
1854 | | */ |
1855 | | typedef struct blosc2_metalayer { |
1856 | | char* name; //!< The metalayer identifier for Blosc client (e.g. Blosc2 NDim). |
1857 | | uint8_t* content; //!< The serialized (msgpack preferably) content of the metalayer. |
1858 | | int32_t content_len; //!< The length in bytes of the content. |
1859 | | } blosc2_metalayer; |
1860 | | |
1861 | | /** |
1862 | | * @brief This struct is the standard container for Blosc 2 compressed data. |
1863 | | * |
1864 | | * This is essentially a container for Blosc 1 chunks of compressed data, |
1865 | | * and it allows to overcome the 32-bit limitation in Blosc 1. Optionally, |
1866 | | * a #blosc2_frame can be attached so as to store the compressed chunks contiguously. |
1867 | | */ |
1868 | | typedef struct blosc2_schunk { |
1869 | | uint8_t version; |
1870 | | uint8_t compcode; |
1871 | | //!< The default compressor. Each chunk can override this. |
1872 | | uint8_t compcode_meta; |
1873 | | //!< The default compressor metadata. Each chunk can override this. |
1874 | | uint8_t clevel; |
1875 | | //!< The compression level and other compress params. |
1876 | | uint8_t splitmode; |
1877 | | //!< The split mode. |
1878 | | int32_t typesize; |
1879 | | //!< The type size. |
1880 | | int32_t blocksize; |
1881 | | //!< The requested size of the compressed blocks (0; meaning automatic). |
1882 | | int32_t chunksize; |
1883 | | //!< Size of each chunk. 0 if not a fixed chunksize. |
1884 | | uint8_t flags2; |
1885 | | //!< Secondary chunk-format flags shared by all chunks in the schunk. 0 when empty. |
1886 | | uint8_t use_dict; |
1887 | | //!< Whether to use a dictionary for codec compression (1) or not (0). |
1888 | | uint8_t filters[BLOSC2_MAX_FILTERS]; |
1889 | | //!< The (sequence of) filters. 8-bit per filter. |
1890 | | uint8_t filters_meta[BLOSC2_MAX_FILTERS]; |
1891 | | //!< Metadata for filters. 8-bit per meta-slot. |
1892 | | int64_t nchunks; |
1893 | | //!< Number of chunks in super-chunk. |
1894 | | int64_t current_nchunk; |
1895 | | //!< The current chunk that is being accessed |
1896 | | int64_t nbytes; |
1897 | | //!< The data size (uncompressed). |
1898 | | int64_t cbytes; |
1899 | | //!< The data size + chunks header size (compressed). |
1900 | | uint8_t** data; |
1901 | | //!< Pointer to chunk data pointers buffer. |
1902 | | size_t data_len; |
1903 | | //!< Length of the chunk data pointers buffer. |
1904 | | blosc2_storage* storage; |
1905 | | //!< Pointer to storage info. |
1906 | | blosc2_frame* frame; |
1907 | | //!< Pointer to frame used as store for chunks. |
1908 | | //!<uint8_t* ctx; |
1909 | | //!< Context for the thread holder. NULL if not acquired. |
1910 | | blosc2_context* cctx; |
1911 | | //!< Context for compression |
1912 | | blosc2_context* dctx; |
1913 | | //!< Context for decompression. |
1914 | | struct blosc2_metalayer *metalayers[BLOSC2_MAX_METALAYERS]; |
1915 | | //!< The array of metalayers. |
1916 | | uint16_t nmetalayers; |
1917 | | //!< The number of metalayers in the super-chunk |
1918 | | struct blosc2_metalayer *vlmetalayers[BLOSC2_MAX_VLMETALAYERS]; |
1919 | | //<! The array of variable-length metalayers. |
1920 | | int16_t nvlmetalayers; |
1921 | | //!< The number of variable-length metalayers. |
1922 | | void *tuner_params; |
1923 | | //!< Tune configuration. |
1924 | | int tuner_id; |
1925 | | //<! Id for tuner |
1926 | | int8_t ndim; |
1927 | | //<! The ndim (mainly for ZFP usage) |
1928 | | int64_t *blockshape; |
1929 | | //<! The blockshape (mainly for ZFP usage) |
1930 | | bool view; |
1931 | | //<! Whether the schunk is a view or not. |
1932 | | int64_t change_tick; |
1933 | | //!< Bumped whenever the (vl)metalayers change: by local mutations and by the |
1934 | | //!< refresh that follows a mutation made through another handle on the same |
1935 | | //!< on-disk frame. Upper layers compare it against a cached value to know |
1936 | | //!< whether their deserialized view of the metalayers is still current. |
1937 | | } blosc2_schunk; |
1938 | | |
1939 | | |
1940 | | /** |
1941 | | * @brief Create a new super-chunk. |
1942 | | * |
1943 | | * @param storage The storage properties. |
1944 | | * |
1945 | | * @remark In case that storage.urlpath is not NULL, the data is stored |
1946 | | * on-disk. If the data file(s) exist, they are *overwritten*. |
1947 | | * |
1948 | | * @return The new super-chunk. |
1949 | | */ |
1950 | | BLOSC_EXPORT blosc2_schunk* blosc2_schunk_new(blosc2_storage *storage); |
1951 | | |
1952 | | /** |
1953 | | * Create a copy of a super-chunk. |
1954 | | * |
1955 | | * @param schunk The super-chunk to be copied. |
1956 | | * @param storage The storage properties. |
1957 | | * |
1958 | | * @return The new super-chunk. |
1959 | | */ |
1960 | | BLOSC_EXPORT blosc2_schunk* blosc2_schunk_copy(blosc2_schunk *schunk, blosc2_storage *storage); |
1961 | | |
1962 | | /** |
1963 | | * @brief Create a super-chunk out of a contiguous frame buffer. |
1964 | | * |
1965 | | * @param cframe The buffer of the in-memory frame. |
1966 | | * @param copy Whether the super-chunk should make a copy of |
1967 | | * the @p cframe data or not. The copy will be made to an internal |
1968 | | * sparse frame. |
1969 | | * |
1970 | | * @remark If copy is false, the @p cframe buffer passed will be owned |
1971 | | * by the super-chunk and will be automatically freed when |
1972 | | * blosc2_schunk_free() is called. If the user frees it after the |
1973 | | * opening, bad things will happen. Don't do that (or set @p copy). |
1974 | | * |
1975 | | * @param len The length of the buffer (in bytes). |
1976 | | * |
1977 | | * @return The new super-chunk. |
1978 | | */ |
1979 | | BLOSC_EXPORT blosc2_schunk* blosc2_schunk_from_buffer(uint8_t *cframe, int64_t len, bool copy); |
1980 | | |
1981 | | /** |
1982 | | * @brief Set the private `avoid_cframe_free` field in a frame. |
1983 | | * |
1984 | | * @param schunk The super-chunk referencing the frame. |
1985 | | * @param avoid_cframe_free The value to set in the blosc2_frame_s structure. |
1986 | | * |
1987 | | * @warning If you set it to `true` you will be responsible of freeing it. |
1988 | | */ |
1989 | | BLOSC_EXPORT void blosc2_schunk_avoid_cframe_free(blosc2_schunk *schunk, bool avoid_cframe_free); |
1990 | | |
1991 | | /** |
1992 | | * @brief Take the exclusive frame lock of a super-chunk and hold it across |
1993 | | * several operations. |
1994 | | * |
1995 | | * When the (opt-in) file locking is enabled on the handle (see the `locking` |
1996 | | * member of #blosc2_stdio_params, or the BLOSC_LOCKING environment variable), |
1997 | | * every schunk operation locks and unlocks the on-disk frame individually, so |
1998 | | * a sequence of operations is not atomic as a whole. Bracketing the sequence |
1999 | | * between blosc2_schunk_lock() and blosc2_schunk_unlock() makes it atomic |
2000 | | * against other handles and processes: the operations inside nest on the |
2001 | | * already-held lock instead of re-acquiring it. |
2002 | | * |
2003 | | * Everything inside the bracket is serialized exclusively — including plain |
2004 | | * reads through other locked handles — so keep brackets short. The bracket |
2005 | | * is re-entrant on the same handle. When locking is not enabled on the |
2006 | | * handle (or the super-chunk is not disk-based), this is a no-op returning |
2007 | | * success, so callers do not need to check whether locking is active. |
2008 | | * |
2009 | | * @param schunk The super-chunk. |
2010 | | * |
2011 | | * @return 0 on success; a negative error code (e.g. BLOSC2_ERROR_LOCK) |
2012 | | * otherwise. |
2013 | | */ |
2014 | | BLOSC_EXPORT int blosc2_schunk_lock(blosc2_schunk *schunk); |
2015 | | |
2016 | | /** |
2017 | | * @brief Release the frame lock taken with blosc2_schunk_lock(). |
2018 | | * |
2019 | | * @param schunk The super-chunk. |
2020 | | * |
2021 | | * @return 0 on success; a negative error code otherwise. Like |
2022 | | * blosc2_schunk_lock(), a no-op when locking is not enabled. |
2023 | | */ |
2024 | | BLOSC_EXPORT int blosc2_schunk_unlock(blosc2_schunk *schunk); |
2025 | | |
2026 | | /** |
2027 | | * @brief Re-sync the cached counters (nchunks, nbytes, cbytes) and |
2028 | | * metalayers of a disk-based super-chunk when another handle — possibly in |
2029 | | * another process — has changed it. |
2030 | | * |
2031 | | * This gives a deterministic sync point for readers in a single-writer, |
2032 | | * multiple-readers (SWMR) workflow: after calling it, the counters in |
2033 | | * @p schunk reflect the current on-disk state. Data-access functions |
2034 | | * already do this implicitly, so calling it is only needed to observe |
2035 | | * changes without touching data (e.g. when polling). |
2036 | | * |
2037 | | * A no-op for super-chunks not backed by an on-disk frame. |
2038 | | * |
2039 | | * @param schunk The super-chunk to refresh. |
2040 | | * |
2041 | | * @return 1 if the counters were re-synced, 0 if they were already current, |
2042 | | * or a negative error code. |
2043 | | */ |
2044 | | BLOSC_EXPORT int blosc2_schunk_refresh(blosc2_schunk *schunk); |
2045 | | |
2046 | | /** |
2047 | | * @brief Open an existing super-chunk that is on-disk (frame). No in-memory copy is made. |
2048 | | * |
2049 | | * @param urlpath The file name. |
2050 | | * |
2051 | | * @return The new super-chunk. NULL if not found or not in frame format. |
2052 | | */ |
2053 | | BLOSC_EXPORT blosc2_schunk* blosc2_schunk_open(const char* urlpath); |
2054 | | |
2055 | | /** |
2056 | | * @brief Open an existing super-chunk that is on-disk (frame). No in-memory copy is made. |
2057 | | * |
2058 | | * @param urlpath The file name. |
2059 | | * |
2060 | | * @param offset The frame offset. |
2061 | | * |
2062 | | * @return The new super-chunk. NULL if not found or not in frame format. |
2063 | | */ |
2064 | | BLOSC_EXPORT blosc2_schunk* blosc2_schunk_open_offset(const char* urlpath, int64_t offset); |
2065 | | |
2066 | | /** |
2067 | | * @brief Open an existing super-chunk (no copy is made) using a user-defined I/O interface. |
2068 | | * |
2069 | | * @param urlpath The file name. |
2070 | | * |
2071 | | * @param udio The user-defined I/O interface. |
2072 | | * |
2073 | | * @return The new super-chunk. |
2074 | | */ |
2075 | | BLOSC_EXPORT blosc2_schunk* blosc2_schunk_open_udio(const char* urlpath, const blosc2_io *udio); |
2076 | | |
2077 | | /** |
2078 | | * @brief Open an existing super-chunk (no copy is made) using a user-defined I/O interface. |
2079 | | * |
2080 | | * @param urlpath The file name. |
2081 | | * |
2082 | | * @param offset The frame offset. |
2083 | | * |
2084 | | * @param udio The user-defined I/O interface. |
2085 | | * |
2086 | | * @return The new super-chunk. |
2087 | | */ |
2088 | | BLOSC_EXPORT blosc2_schunk* blosc2_schunk_open_offset_udio(const char* urlpath, int64_t offset, const blosc2_io *udio); |
2089 | | |
2090 | | /* @brief Convert a super-chunk into a contiguous frame buffer. |
2091 | | * |
2092 | | * @param schunk The super-chunk to convert. |
2093 | | * @param cframe The address of the destination buffer (output). |
2094 | | * @param needs_free The pointer to a boolean indicating if it is the user's |
2095 | | * responsibility to free the resulting @p cframe buffer or not. |
2096 | | * |
2097 | | * @return If successful, return the size of the (frame) @p cframe buffer. |
2098 | | * Else, a negative value. |
2099 | | */ |
2100 | | BLOSC_EXPORT int64_t blosc2_schunk_to_buffer(blosc2_schunk* schunk, uint8_t** cframe, bool* needs_free); |
2101 | | |
2102 | | /* @brief Store a super-chunk into a file. |
2103 | | * |
2104 | | * @param schunk The super-chunk to write. |
2105 | | * @param urlpath The path for persistent storage. |
2106 | | * |
2107 | | * @return If successful, return the size of the (fileframe) in @p urlpath. |
2108 | | * Else, a negative value. |
2109 | | */ |
2110 | | BLOSC_EXPORT int64_t blosc2_schunk_to_file(blosc2_schunk* schunk, const char* urlpath); |
2111 | | |
2112 | | /* @brief Append a super-chunk into a file. |
2113 | | * |
2114 | | * @param schunk The super-chunk to write. |
2115 | | * @param urlpath The path for persistent storage. |
2116 | | * |
2117 | | * @return If successful, return the offset where @p schunk has been appended in @p urlpath. |
2118 | | * Else, a negative value. |
2119 | | */ |
2120 | | BLOSC_EXPORT int64_t blosc2_schunk_append_file(blosc2_schunk* schunk, const char* urlpath); |
2121 | | |
2122 | | /** |
2123 | | * @brief Release resources from a super-chunk. |
2124 | | * |
2125 | | * @param schunk The super-chunk to be freed. |
2126 | | * |
2127 | | * @remark All the memory resources attached to the super-chunk are freed. |
2128 | | * If the super-chunk is on-disk, the data continues there for a later |
2129 | | * re-opening. |
2130 | | * |
2131 | | * @return 0 if success. |
2132 | | */ |
2133 | | BLOSC_EXPORT int blosc2_schunk_free(blosc2_schunk *schunk); |
2134 | | |
2135 | | /** |
2136 | | * @brief Append an existing @p chunk to a super-chunk. |
2137 | | * |
2138 | | * @param schunk The super-chunk where the chunk will be appended. |
2139 | | * @param chunk The @p chunk to append. An internal copy is made, so @p chunk can be reused or |
2140 | | * freed if desired. |
2141 | | * @param copy Whether the chunk should be copied internally or can be used as-is. |
2142 | | * |
2143 | | * @return The number of chunks in super-chunk. If some problem is |
2144 | | * detected, this number will be negative. |
2145 | | */ |
2146 | | BLOSC_EXPORT int64_t blosc2_schunk_append_chunk(blosc2_schunk *schunk, uint8_t *chunk, bool copy); |
2147 | | |
2148 | | /** |
2149 | | * @brief Update a chunk at a specific position in a super-chunk. |
2150 | | * |
2151 | | * @param schunk The super-chunk where the chunk will be updated. |
2152 | | * @param nchunk The position where the chunk will be updated. |
2153 | | * @param chunk The new @p chunk. If an internal copy is made, the @p chunk can be reused or |
2154 | | * freed if desired. |
2155 | | * @param copy Whether the chunk should be copied internally or can be used as-is. |
2156 | | * |
2157 | | * @return The number of chunks in super-chunk. If some problem is |
2158 | | * detected, this number will be negative. |
2159 | | */ |
2160 | | BLOSC_EXPORT int64_t blosc2_schunk_update_chunk(blosc2_schunk *schunk, int64_t nchunk, uint8_t *chunk, bool copy); |
2161 | | |
2162 | | /** |
2163 | | * @brief Insert a chunk at a specific position in a super-chunk. |
2164 | | * |
2165 | | * @param schunk The super-chunk where the chunk will be appended. |
2166 | | * @param nchunk The position where the chunk will be inserted. |
2167 | | * @param chunk The @p chunk to insert. If an internal copy is made, the @p chunk can be reused or |
2168 | | * freed if desired. |
2169 | | * @param copy Whether the chunk should be copied internally or can be used as-is. |
2170 | | * |
2171 | | * @return The number of chunks in super-chunk. If some problem is |
2172 | | * detected, this number will be negative. |
2173 | | */ |
2174 | | BLOSC_EXPORT int64_t blosc2_schunk_insert_chunk(blosc2_schunk *schunk, int64_t nchunk, uint8_t *chunk, bool copy); |
2175 | | |
2176 | | /** |
2177 | | * @brief Delete a chunk at a specific position in a super-chunk. |
2178 | | * |
2179 | | * @param schunk The super-chunk where the chunk will be deleted. |
2180 | | * @param nchunk The position where the chunk will be deleted. |
2181 | | * |
2182 | | * @return The number of chunks in super-chunk. If some problem is |
2183 | | * detected, this number will be negative. |
2184 | | */ |
2185 | | BLOSC_EXPORT int64_t blosc2_schunk_delete_chunk(blosc2_schunk *schunk, int64_t nchunk); |
2186 | | |
2187 | | /** |
2188 | | * @brief Append a @p src data buffer to a super-chunk. |
2189 | | * |
2190 | | * @param schunk The super-chunk where data will be appended. |
2191 | | * @param src The buffer of data to compress. |
2192 | | * @param nbytes The size of the @p src buffer. |
2193 | | * |
2194 | | * @return The number of chunks in super-chunk. If some problem is |
2195 | | * detected, this number will be negative. |
2196 | | */ |
2197 | | BLOSC_EXPORT int64_t blosc2_schunk_append_buffer(blosc2_schunk *schunk, const void *src, int32_t nbytes); |
2198 | | |
2199 | | /** |
2200 | | * @brief Decompress and return the @p nchunk chunk of a super-chunk. |
2201 | | * |
2202 | | * If the chunk is uncompressed successfully, it is put in the @p *dest |
2203 | | * pointer. |
2204 | | * |
2205 | | * @param schunk The super-chunk from where the chunk will be decompressed. |
2206 | | * @param nchunk The chunk to be decompressed (0 indexed). |
2207 | | * @param dest The buffer where the decompressed data will be put. |
2208 | | * @param nbytes The size of the area pointed by @p *dest. |
2209 | | * |
2210 | | * @warning You must make sure that you have enough space to store the |
2211 | | * uncompressed data. |
2212 | | * |
2213 | | * @return The size of the decompressed chunk or 0 if it is non-initialized. If some problem is |
2214 | | * detected, a negative code is returned instead. |
2215 | | */ |
2216 | | BLOSC_EXPORT int blosc2_schunk_decompress_chunk(blosc2_schunk *schunk, int64_t nchunk, void *dest, int32_t nbytes); |
2217 | | |
2218 | | /** |
2219 | | * @brief Return a compressed chunk that is part of a super-chunk in the @p chunk parameter. |
2220 | | * |
2221 | | * @param schunk The super-chunk from where to extract a chunk. |
2222 | | * @param nchunk The chunk to be extracted (0 indexed). |
2223 | | * @param chunk The pointer to the chunk of compressed data. |
2224 | | * @param needs_free The pointer to a boolean indicating if it is the user's |
2225 | | * responsibility to free the chunk returned or not. |
2226 | | * |
2227 | | * @warning If the super-chunk is backed by a frame that is disk-based, a buffer is allocated for the |
2228 | | * (compressed) chunk, and hence a free is needed. |
2229 | | * You can check whether the chunk requires a free with the @p needs_free parameter. |
2230 | | * If the chunk does not need a free, it means that a pointer to the location in the super-chunk |
2231 | | * (or the backing in-memory frame) is returned in the @p chunk parameter. |
2232 | | * |
2233 | | * @note If the frame on disk has been modified through another handle (or process), |
2234 | | * the handle re-syncs its view automatically on the next access. A concurrent |
2235 | | * (non-serialized) write can still surface as #BLOSC2_ERROR_FILE_READ; retry or |
2236 | | * reopen the super-chunk in that case. Writers must be serialized externally. |
2237 | | * |
2238 | | * @return The size of the (compressed) chunk or 0 if it is non-initialized. If some problem is |
2239 | | * detected, a negative code is returned instead. |
2240 | | */ |
2241 | | BLOSC_EXPORT int blosc2_schunk_get_chunk(blosc2_schunk *schunk, int64_t nchunk, uint8_t **chunk, |
2242 | | bool *needs_free); |
2243 | | |
2244 | | /** |
2245 | | * @brief Return a (lazy) compressed chunk that is part of a super-chunk in the @p chunk parameter. |
2246 | | * |
2247 | | * @param schunk The super-chunk from where to extract a chunk. |
2248 | | * @param nchunk The chunk to be extracted (0 indexed). |
2249 | | * @param chunk The pointer to the (lazy) chunk of compressed data. |
2250 | | * @param needs_free The pointer to a boolean indicating if it is the user's |
2251 | | * responsibility to free the chunk returned or not. |
2252 | | * |
2253 | | * @note For disk-based frames, a lazy chunk is always returned. |
2254 | | * |
2255 | | * @warning Currently, a lazy chunk can only be used by #blosc2_decompress_ctx and #blosc2_getitem_ctx. |
2256 | | * |
2257 | | * @note The return value is the effective size of the returned buffer. For lazy |
2258 | | * chunks, use this return value as @p srcsize when calling |
2259 | | * #blosc2_decompress_ctx or #blosc2_getitem_ctx. This value can be larger than |
2260 | | * the @p cbytes reported by #blosc2_cbuffer_sizes because lazy chunks carry |
2261 | | * extra trailer metadata. |
2262 | | * |
2263 | | * @warning If the super-chunk is backed by a frame that is disk-based, a buffer is allocated for the |
2264 | | * (compressed) chunk, and hence a free is needed. |
2265 | | * You can check whether requires a free with the @p needs_free parameter. |
2266 | | * If the chunk does not need a free, it means that a pointer to the location in the super-chunk |
2267 | | * (or the backing in-memory frame) is returned in the @p chunk parameter. In this case the returned |
2268 | | * chunk is not lazy. |
2269 | | * |
2270 | | * @note If the frame on disk has been modified through another handle (or process), |
2271 | | * the handle re-syncs its view automatically on the next access. A concurrent |
2272 | | * (non-serialized) write can still surface as #BLOSC2_ERROR_FILE_READ; retry or |
2273 | | * reopen the super-chunk in that case. Writers must be serialized externally. |
2274 | | * |
2275 | | * @return The size of the returned chunk buffer, or 0 if it is non-initialized. |
2276 | | * If some problem is detected, a negative code is returned instead. For regular |
2277 | | * chunks this matches the compressed chunk size. Note that a lazy chunk is |
2278 | | * somewhat larger than a regular chunk because of the trailer section (for |
2279 | | * details see `README_CHUNK_FORMAT.rst`). |
2280 | | */ |
2281 | | BLOSC_EXPORT int blosc2_schunk_get_lazychunk(blosc2_schunk *schunk, int64_t nchunk, uint8_t **chunk, |
2282 | | bool *needs_free); |
2283 | | |
2284 | | /** |
2285 | | * @brief Decompress a single variable-length block from a schunk chunk. |
2286 | | * |
2287 | | * Convenience wrapper around #blosc2_vldecompress_block_ctx that fetches the |
2288 | | * compressed chunk from @p schunk and decompresses only the requested VL block. |
2289 | | * Only the requested block is allocated and decompressed; all other blocks in |
2290 | | * the chunk are untouched. |
2291 | | * |
2292 | | * @param schunk The super-chunk from which to read. |
2293 | | * @param nchunk Zero-based index of the chunk inside the super-chunk. |
2294 | | * @param nblock Zero-based index of the VL block inside the chunk. |
2295 | | * @param dest On success, points to a newly allocated buffer containing the |
2296 | | * decompressed block. The caller is responsible for freeing it with @c free(). |
2297 | | * @param destsize On success, the uncompressed byte size of the block. |
2298 | | * |
2299 | | * @return The uncompressed byte size of the block on success, or a negative |
2300 | | * error code. Returns #BLOSC2_ERROR_INVALID_PARAM if the chunk does not use |
2301 | | * VL blocks or if @p nblock is out of range. |
2302 | | */ |
2303 | | BLOSC_EXPORT int blosc2_schunk_get_vlblock(blosc2_schunk *schunk, int64_t nchunk, |
2304 | | int32_t nblock, |
2305 | | uint8_t **dest, int32_t *destsize); |
2306 | | |
2307 | | /** |
2308 | | * @brief Fill buffer with a schunk slice. |
2309 | | * |
2310 | | * @param schunk The super-chunk from where to extract a slice. |
2311 | | * @param start Index (0-based) where the slice begins. |
2312 | | * @param stop The first index (0-based) that is not in the selected slice. |
2313 | | * @param buffer The buffer where the data will be stored. |
2314 | | * |
2315 | | * @warning You must make sure that you have enough space in buffer to store the |
2316 | | * uncompressed data. |
2317 | | * |
2318 | | * @return An error code. |
2319 | | */ |
2320 | | BLOSC_EXPORT int blosc2_schunk_get_slice_buffer(blosc2_schunk *schunk, int64_t start, int64_t stop, void *buffer); |
2321 | | |
2322 | | /** |
2323 | | * @brief Fill buffer with elements at the given coordinates from a schunk. |
2324 | | * |
2325 | | * @param schunk The super-chunk from where to extract elements. |
2326 | | * @param ncoords The number of coordinates. |
2327 | | * @param coords The coordinates of the elements to be extracted. |
2328 | | * @param buffer The buffer where the data will be stored. |
2329 | | * |
2330 | | * @warning You must make sure that you have enough space in buffer to store the |
2331 | | * uncompressed data. |
2332 | | * |
2333 | | * @return An error code. |
2334 | | */ |
2335 | | BLOSC_EXPORT int blosc2_schunk_get_sparse_buffer(blosc2_schunk *schunk, int64_t ncoords, |
2336 | | const int64_t* coords, void *buffer); |
2337 | | |
2338 | | /** |
2339 | | * @brief Update a schunk slice from buffer. |
2340 | | * |
2341 | | * @param schunk The super-chunk where to set the slice. |
2342 | | * @param start Index (0-based) where the slice begins. |
2343 | | * @param stop The first index (0-based) that is not in the selected slice. |
2344 | | * @param buffer The buffer containing the data to set. |
2345 | | * |
2346 | | * |
2347 | | * @return An error code. |
2348 | | */ |
2349 | | BLOSC_EXPORT int blosc2_schunk_set_slice_buffer(blosc2_schunk *schunk, int64_t start, int64_t stop, void *buffer); |
2350 | | |
2351 | | /** |
2352 | | * @brief Return the @p cparams associated to a super-chunk. |
2353 | | * |
2354 | | * @param schunk The super-chunk from where to extract the compression parameters. |
2355 | | * @param cparams The pointer where the compression params will be returned. |
2356 | | * |
2357 | | * @warning A new struct is allocated, and the user should free it after use. |
2358 | | * |
2359 | | * @return 0 if succeeds. Else a negative code is returned. |
2360 | | */ |
2361 | | BLOSC_EXPORT int blosc2_schunk_get_cparams(blosc2_schunk *schunk, blosc2_cparams **cparams); |
2362 | | |
2363 | | /** |
2364 | | * @brief Return the @p dparams struct associated to a super-chunk. |
2365 | | * |
2366 | | * @param schunk The super-chunk from where to extract the decompression parameters. |
2367 | | * @param dparams The pointer where the decompression params will be returned. |
2368 | | * |
2369 | | * @warning A new struct is allocated, and the user should free it after use. |
2370 | | * |
2371 | | * @return 0 if succeeds. Else a negative code is returned. |
2372 | | */ |
2373 | | BLOSC_EXPORT int blosc2_schunk_get_dparams(blosc2_schunk *schunk, blosc2_dparams **dparams); |
2374 | | |
2375 | | /** |
2376 | | * @brief Reorder the chunk offsets of an existing super-chunk. |
2377 | | * |
2378 | | * @param schunk The super-chunk whose chunk offsets are to be reordered. |
2379 | | * @param offsets_order The new order of the chunk offsets. |
2380 | | * |
2381 | | * @return 0 if succeeds. Else a negative code is returned. |
2382 | | */ |
2383 | | BLOSC_EXPORT int blosc2_schunk_reorder_offsets(blosc2_schunk *schunk, int64_t *offsets_order); |
2384 | | |
2385 | | /** |
2386 | | * @brief Get the length (in bytes) of the internal frame of the super-chunk. |
2387 | | * |
2388 | | * @param schunk The super-chunk. |
2389 | | * |
2390 | | * @return The length (in bytes) of the internal frame. |
2391 | | * If there is not an internal frame, an estimate of the length is provided. |
2392 | | */ |
2393 | | BLOSC_EXPORT int64_t blosc2_schunk_frame_len(blosc2_schunk* schunk); |
2394 | | |
2395 | | /** |
2396 | | * @brief Quickly fill an empty frame with special values (zeros, NaNs, uninit). |
2397 | | * |
2398 | | * @param schunk The super-chunk to be filled. This must be empty initially. |
2399 | | * @param nitems The number of items to fill. |
2400 | | * @param special_value The special value to use for filling. The only values |
2401 | | * supported for now are BLOSC2_SPECIAL_ZERO, BLOSC2_SPECIAL_NAN and BLOSC2_SPECIAL_UNINIT. |
2402 | | * @param chunksize The chunksize for the chunks that are to be added to the super-chunk. |
2403 | | * |
2404 | | * @return The total number of chunks that have been added to the super-chunk. |
2405 | | * If there is an error, a negative value is returned. |
2406 | | */ |
2407 | | BLOSC_EXPORT int64_t blosc2_schunk_fill_special(blosc2_schunk* schunk, int64_t nitems, |
2408 | | int special_value, int32_t chunksize); |
2409 | | |
2410 | | |
2411 | | /********************************************************************* |
2412 | | Functions related with fixed-length metalayers. |
2413 | | *********************************************************************/ |
2414 | | |
2415 | | /** |
2416 | | * @brief Find whether the schunk has a metalayer or not. |
2417 | | * |
2418 | | * @param schunk The super-chunk from which the metalayer will be checked. |
2419 | | * @param name The name of the metalayer to be checked. |
2420 | | * |
2421 | | * @return If successful, return the index of the metalayer. Else, return a negative value. |
2422 | | */ |
2423 | 2 | static inline int blosc2_meta_exists(blosc2_schunk *schunk, const char *name) { |
2424 | 2 | if (strlen(name) > BLOSC2_METALAYER_NAME_MAXLEN) { |
2425 | 0 | BLOSC_TRACE_ERROR("Metalayers cannot be larger than %d chars.", BLOSC2_METALAYER_NAME_MAXLEN); |
2426 | 0 | return BLOSC2_ERROR_INVALID_PARAM; |
2427 | 0 | } |
2428 | | |
2429 | 2 | if (schunk == NULL) { |
2430 | 0 | BLOSC_TRACE_ERROR("Schunk must not be NUll."); |
2431 | 0 | return BLOSC2_ERROR_INVALID_PARAM; |
2432 | 0 | } |
2433 | | |
2434 | 2 | for (int nmetalayer = 0; nmetalayer < schunk->nmetalayers; nmetalayer++) { |
2435 | 0 | if (strcmp(name, schunk->metalayers[nmetalayer]->name) == 0) { |
2436 | 0 | return nmetalayer; |
2437 | 0 | } |
2438 | 0 | } |
2439 | 2 | return BLOSC2_ERROR_NOT_FOUND; |
2440 | 2 | } Unexecuted instantiation: fuzz_compress_frame.c:blosc2_meta_exists Unexecuted instantiation: blosc2.c:blosc2_meta_exists Unexecuted instantiation: blosclz.c:blosc2_meta_exists Unexecuted instantiation: schunk.c:blosc2_meta_exists Unexecuted instantiation: frame.c:blosc2_meta_exists Unexecuted instantiation: stune.c:blosc2_meta_exists Unexecuted instantiation: trunc-prec.c:blosc2_meta_exists Unexecuted instantiation: timestamp.c:blosc2_meta_exists Unexecuted instantiation: sframe.c:blosc2_meta_exists Unexecuted instantiation: blosc2-stdio.c:blosc2_meta_exists Unexecuted instantiation: b2nd.c:blosc2_meta_exists Unexecuted instantiation: b2nd_utils.c:blosc2_meta_exists Unexecuted instantiation: shuffle.c:blosc2_meta_exists Unexecuted instantiation: blosc2-zfp.c:blosc2_meta_exists Unexecuted instantiation: codecs-registry.c:blosc2_meta_exists Unexecuted instantiation: tuners-registry.c:blosc2_meta_exists Unexecuted instantiation: filters-registry.c:blosc2_meta_exists Unexecuted instantiation: ndlz.c:blosc2_meta_exists Unexecuted instantiation: ndlz4x4.c:blosc2_meta_exists Unexecuted instantiation: ndlz8x8.c:blosc2_meta_exists ndcell.c:blosc2_meta_exists Line | Count | Source | 2423 | 1 | static inline int blosc2_meta_exists(blosc2_schunk *schunk, const char *name) { | 2424 | 1 | if (strlen(name) > BLOSC2_METALAYER_NAME_MAXLEN) { | 2425 | 0 | BLOSC_TRACE_ERROR("Metalayers cannot be larger than %d chars.", BLOSC2_METALAYER_NAME_MAXLEN); | 2426 | 0 | return BLOSC2_ERROR_INVALID_PARAM; | 2427 | 0 | } | 2428 | | | 2429 | 1 | if (schunk == NULL) { | 2430 | 0 | BLOSC_TRACE_ERROR("Schunk must not be NUll."); | 2431 | 0 | return BLOSC2_ERROR_INVALID_PARAM; | 2432 | 0 | } | 2433 | | | 2434 | 1 | for (int nmetalayer = 0; nmetalayer < schunk->nmetalayers; nmetalayer++) { | 2435 | 0 | if (strcmp(name, schunk->metalayers[nmetalayer]->name) == 0) { | 2436 | 0 | return nmetalayer; | 2437 | 0 | } | 2438 | 0 | } | 2439 | 1 | return BLOSC2_ERROR_NOT_FOUND; | 2440 | 1 | } |
ndmean.c:blosc2_meta_exists Line | Count | Source | 2423 | 1 | static inline int blosc2_meta_exists(blosc2_schunk *schunk, const char *name) { | 2424 | 1 | if (strlen(name) > BLOSC2_METALAYER_NAME_MAXLEN) { | 2425 | 0 | BLOSC_TRACE_ERROR("Metalayers cannot be larger than %d chars.", BLOSC2_METALAYER_NAME_MAXLEN); | 2426 | 0 | return BLOSC2_ERROR_INVALID_PARAM; | 2427 | 0 | } | 2428 | | | 2429 | 1 | if (schunk == NULL) { | 2430 | 0 | BLOSC_TRACE_ERROR("Schunk must not be NUll."); | 2431 | 0 | return BLOSC2_ERROR_INVALID_PARAM; | 2432 | 0 | } | 2433 | | | 2434 | 1 | for (int nmetalayer = 0; nmetalayer < schunk->nmetalayers; nmetalayer++) { | 2435 | 0 | if (strcmp(name, schunk->metalayers[nmetalayer]->name) == 0) { | 2436 | 0 | return nmetalayer; | 2437 | 0 | } | 2438 | 0 | } | 2439 | 1 | return BLOSC2_ERROR_NOT_FOUND; | 2440 | 1 | } |
Unexecuted instantiation: bytedelta.c:blosc2_meta_exists Unexecuted instantiation: int_trunc.c:blosc2_meta_exists Unexecuted instantiation: fuzz_decompress_frame.c:blosc2_meta_exists Unexecuted instantiation: fuzz_compress_chunk.c:blosc2_meta_exists Unexecuted instantiation: fuzz_decompress_chunk.c:blosc2_meta_exists |
2441 | | |
2442 | | /** |
2443 | | * @brief Add content into a new metalayer. |
2444 | | * |
2445 | | * @param schunk The super-chunk to which the metalayer should be added. |
2446 | | * @param name The name of the metalayer. |
2447 | | * @param content The content of the metalayer. |
2448 | | * @param content_len The length of the content. |
2449 | | * |
2450 | | * @return If successful, the index of the new metalayer. Else, return a negative value. |
2451 | | */ |
2452 | | BLOSC_EXPORT int blosc2_meta_add(blosc2_schunk *schunk, const char *name, uint8_t *content, |
2453 | | int32_t content_len); |
2454 | | |
2455 | | /** |
2456 | | * @brief Update the content of an existing metalayer. |
2457 | | * |
2458 | | * @param schunk The frame containing the metalayer. |
2459 | | * @param name The name of the metalayer to be updated. |
2460 | | * @param content The new content of the metalayer. |
2461 | | * @param content_len The length of the content. |
2462 | | * |
2463 | | * @note Contrarily to #blosc2_meta_add the updates to metalayers |
2464 | | * are automatically serialized into a possible attached frame. |
2465 | | * |
2466 | | * @return If successful, the index of the metalayer. Else, return a negative value. |
2467 | | */ |
2468 | | BLOSC_EXPORT int blosc2_meta_update(blosc2_schunk *schunk, const char *name, uint8_t *content, |
2469 | | int32_t content_len); |
2470 | | |
2471 | | /** |
2472 | | * @brief Get the content out of a metalayer. |
2473 | | * |
2474 | | * @param schunk The frame containing the metalayer. |
2475 | | * @param name The name of the metalayer. |
2476 | | * @param content The pointer where the content will be put. |
2477 | | * @param content_len The length of the content. |
2478 | | * |
2479 | | * @warning The @p **content receives a malloc'ed copy of the content. |
2480 | | * The user is responsible of freeing it. |
2481 | | * |
2482 | | * @note This function is inlined so that external codec/filter plugins (like |
2483 | | * blosc2_grok) can use it without linking against libblosc2. This avoids |
2484 | | * pulling all of libblosc2's symbols (e.g. internal ZFP, Zstd) into the |
2485 | | * global namespace at load time, which would otherwise shadow symbols from |
2486 | | * other libraries that need differently-configured builds of the same |
2487 | | * dependencies. |
2488 | | * |
2489 | | * @return If successful, the index of the new metalayer. Else, return a negative value. |
2490 | | */ |
2491 | | static inline int blosc2_meta_get(blosc2_schunk *schunk, const char *name, uint8_t **content, |
2492 | 18 | int32_t *content_len) { |
2493 | 18 | if (schunk == NULL || name == NULL || content == NULL || content_len == NULL) { |
2494 | 16 | BLOSC_TRACE_ERROR("Invalid parameters."); |
2495 | 16 | return BLOSC2_ERROR_INVALID_PARAM; |
2496 | 16 | } |
2497 | | |
2498 | 2 | int nmetalayer = blosc2_meta_exists(schunk, name); |
2499 | 2 | if (nmetalayer < 0) { |
2500 | 2 | BLOSC_TRACE_WARNING("Metalayer \"%s\" not found.", name); |
2501 | 2 | return nmetalayer; |
2502 | 2 | } |
2503 | 0 | int32_t len = schunk->metalayers[nmetalayer]->content_len; |
2504 | 0 | if (len < 0) { |
2505 | 0 | BLOSC_TRACE_ERROR("Metalayer \"%s\" has corrupted content length %d.", name, len); |
2506 | 0 | return BLOSC2_ERROR_DATA; |
2507 | 0 | } |
2508 | 0 | *content_len = len; |
2509 | 0 | if (len == 0) { |
2510 | 0 | *content = NULL; |
2511 | 0 | return nmetalayer; |
2512 | 0 | } |
2513 | 0 | *content = (uint8_t*)malloc((size_t)len); |
2514 | 0 | if (*content == NULL) { |
2515 | 0 | BLOSC_TRACE_ERROR("Unable to allocate metalayer content buffer."); |
2516 | 0 | *content_len = 0; |
2517 | 0 | return BLOSC2_ERROR_MEMORY_ALLOC; |
2518 | 0 | } |
2519 | 0 | if (len > 0 && schunk->metalayers[nmetalayer]->content == NULL) { |
2520 | 0 | free(*content); |
2521 | 0 | *content = NULL; |
2522 | 0 | *content_len = 0; |
2523 | 0 | BLOSC_TRACE_ERROR("Metalayer \"%s\" has corrupted content pointer.", name); |
2524 | 0 | return BLOSC2_ERROR_DATA; |
2525 | 0 | } |
2526 | 0 | memcpy(*content, schunk->metalayers[nmetalayer]->content, (size_t)len); |
2527 | 0 | return nmetalayer; |
2528 | 0 | } Unexecuted instantiation: fuzz_compress_frame.c:blosc2_meta_get Unexecuted instantiation: blosc2.c:blosc2_meta_get Unexecuted instantiation: blosclz.c:blosc2_meta_get Unexecuted instantiation: schunk.c:blosc2_meta_get Unexecuted instantiation: frame.c:blosc2_meta_get Unexecuted instantiation: stune.c:blosc2_meta_get Unexecuted instantiation: trunc-prec.c:blosc2_meta_get Unexecuted instantiation: timestamp.c:blosc2_meta_get Unexecuted instantiation: sframe.c:blosc2_meta_get Unexecuted instantiation: blosc2-stdio.c:blosc2_meta_get Unexecuted instantiation: b2nd.c:blosc2_meta_get Unexecuted instantiation: b2nd_utils.c:blosc2_meta_get Unexecuted instantiation: shuffle.c:blosc2_meta_get Unexecuted instantiation: blosc2-zfp.c:blosc2_meta_get Unexecuted instantiation: codecs-registry.c:blosc2_meta_get Unexecuted instantiation: tuners-registry.c:blosc2_meta_get Unexecuted instantiation: filters-registry.c:blosc2_meta_get Unexecuted instantiation: ndlz.c:blosc2_meta_get Unexecuted instantiation: ndlz4x4.c:blosc2_meta_get Unexecuted instantiation: ndlz8x8.c:blosc2_meta_get Line | Count | Source | 2492 | 9 | int32_t *content_len) { | 2493 | 9 | if (schunk == NULL || name == NULL || content == NULL || content_len == NULL) { | 2494 | 8 | BLOSC_TRACE_ERROR("Invalid parameters."); | 2495 | 8 | return BLOSC2_ERROR_INVALID_PARAM; | 2496 | 8 | } | 2497 | | | 2498 | 1 | int nmetalayer = blosc2_meta_exists(schunk, name); | 2499 | 1 | if (nmetalayer < 0) { | 2500 | 1 | BLOSC_TRACE_WARNING("Metalayer \"%s\" not found.", name); | 2501 | 1 | return nmetalayer; | 2502 | 1 | } | 2503 | 0 | int32_t len = schunk->metalayers[nmetalayer]->content_len; | 2504 | 0 | if (len < 0) { | 2505 | 0 | BLOSC_TRACE_ERROR("Metalayer \"%s\" has corrupted content length %d.", name, len); | 2506 | 0 | return BLOSC2_ERROR_DATA; | 2507 | 0 | } | 2508 | 0 | *content_len = len; | 2509 | 0 | if (len == 0) { | 2510 | 0 | *content = NULL; | 2511 | 0 | return nmetalayer; | 2512 | 0 | } | 2513 | 0 | *content = (uint8_t*)malloc((size_t)len); | 2514 | 0 | if (*content == NULL) { | 2515 | 0 | BLOSC_TRACE_ERROR("Unable to allocate metalayer content buffer."); | 2516 | 0 | *content_len = 0; | 2517 | 0 | return BLOSC2_ERROR_MEMORY_ALLOC; | 2518 | 0 | } | 2519 | 0 | if (len > 0 && schunk->metalayers[nmetalayer]->content == NULL) { | 2520 | 0 | free(*content); | 2521 | 0 | *content = NULL; | 2522 | 0 | *content_len = 0; | 2523 | 0 | BLOSC_TRACE_ERROR("Metalayer \"%s\" has corrupted content pointer.", name); | 2524 | 0 | return BLOSC2_ERROR_DATA; | 2525 | 0 | } | 2526 | 0 | memcpy(*content, schunk->metalayers[nmetalayer]->content, (size_t)len); | 2527 | 0 | return nmetalayer; | 2528 | 0 | } |
Line | Count | Source | 2492 | 9 | int32_t *content_len) { | 2493 | 9 | if (schunk == NULL || name == NULL || content == NULL || content_len == NULL) { | 2494 | 8 | BLOSC_TRACE_ERROR("Invalid parameters."); | 2495 | 8 | return BLOSC2_ERROR_INVALID_PARAM; | 2496 | 8 | } | 2497 | | | 2498 | 1 | int nmetalayer = blosc2_meta_exists(schunk, name); | 2499 | 1 | if (nmetalayer < 0) { | 2500 | 1 | BLOSC_TRACE_WARNING("Metalayer \"%s\" not found.", name); | 2501 | 1 | return nmetalayer; | 2502 | 1 | } | 2503 | 0 | int32_t len = schunk->metalayers[nmetalayer]->content_len; | 2504 | 0 | if (len < 0) { | 2505 | 0 | BLOSC_TRACE_ERROR("Metalayer \"%s\" has corrupted content length %d.", name, len); | 2506 | 0 | return BLOSC2_ERROR_DATA; | 2507 | 0 | } | 2508 | 0 | *content_len = len; | 2509 | 0 | if (len == 0) { | 2510 | 0 | *content = NULL; | 2511 | 0 | return nmetalayer; | 2512 | 0 | } | 2513 | 0 | *content = (uint8_t*)malloc((size_t)len); | 2514 | 0 | if (*content == NULL) { | 2515 | 0 | BLOSC_TRACE_ERROR("Unable to allocate metalayer content buffer."); | 2516 | 0 | *content_len = 0; | 2517 | 0 | return BLOSC2_ERROR_MEMORY_ALLOC; | 2518 | 0 | } | 2519 | 0 | if (len > 0 && schunk->metalayers[nmetalayer]->content == NULL) { | 2520 | 0 | free(*content); | 2521 | 0 | *content = NULL; | 2522 | 0 | *content_len = 0; | 2523 | 0 | BLOSC_TRACE_ERROR("Metalayer \"%s\" has corrupted content pointer.", name); | 2524 | 0 | return BLOSC2_ERROR_DATA; | 2525 | 0 | } | 2526 | 0 | memcpy(*content, schunk->metalayers[nmetalayer]->content, (size_t)len); | 2527 | 0 | return nmetalayer; | 2528 | 0 | } |
Unexecuted instantiation: bytedelta.c:blosc2_meta_get Unexecuted instantiation: int_trunc.c:blosc2_meta_get Unexecuted instantiation: fuzz_decompress_frame.c:blosc2_meta_get Unexecuted instantiation: fuzz_compress_chunk.c:blosc2_meta_get Unexecuted instantiation: fuzz_decompress_chunk.c:blosc2_meta_get |
2529 | | |
2530 | | |
2531 | | /********************************************************************* |
2532 | | Variable-length metalayers functions. |
2533 | | *********************************************************************/ |
2534 | | |
2535 | | /** |
2536 | | * @brief Find whether the schunk has a variable-length metalayer or not. |
2537 | | * |
2538 | | * For on-disk super-chunks this also re-syncs the cached variable-length |
2539 | | * metalayers when another handle (or process) rewrote the frame, so a |
2540 | | * metalayer added or deleted elsewhere is reflected in the answer. |
2541 | | * |
2542 | | * @param schunk The super-chunk from which the variable-length metalayer will be checked. |
2543 | | * @param name The name of the variable-length metalayer to be checked. |
2544 | | * |
2545 | | * @return If successful, return the index of the variable-length metalayer. Else, return a negative value. |
2546 | | */ |
2547 | | BLOSC_EXPORT int blosc2_vlmeta_exists(blosc2_schunk *schunk, const char *name); |
2548 | | |
2549 | | /** |
2550 | | * @brief Add content into a new variable-length metalayer. |
2551 | | * |
2552 | | * @param schunk The super-chunk to which the variable-length metalayer should be added. |
2553 | | * @param name The name of the variable-length metalayer. |
2554 | | * @param content The content to be added. |
2555 | | * @param content_len The length of the content. |
2556 | | * @param cparams The parameters for compressing the variable-length metalayer content. If NULL, |
2557 | | * the `BLOSC2_CPARAMS_DEFAULTS` will be used. |
2558 | | * |
2559 | | * @return If successful, the index of the new variable-length metalayer. Else, return a negative value. |
2560 | | */ |
2561 | | BLOSC_EXPORT int blosc2_vlmeta_add(blosc2_schunk *schunk, const char *name, |
2562 | | uint8_t *content, int32_t content_len, |
2563 | | blosc2_cparams *cparams); |
2564 | | |
2565 | | /** |
2566 | | * @brief Update the content of an existing variable-length metalayer. |
2567 | | * |
2568 | | * @param schunk The super-chunk containing the variable-length metalayer. |
2569 | | * @param name The name of the variable-length metalayer to be updated. |
2570 | | * @param content The new content of the variable-length metalayer. |
2571 | | * @param content_len The length of the content. |
2572 | | * @param cparams The parameters for compressing the variable-length metalayer content. If NULL, |
2573 | | * the `BLOSC2_CPARAMS_DEFAULTS` will be used. |
2574 | | * |
2575 | | * @return If successful, the index of the variable-length metalayer. Else, return a negative value. |
2576 | | */ |
2577 | | BLOSC_EXPORT int blosc2_vlmeta_update(blosc2_schunk *schunk, const char *name, |
2578 | | uint8_t *content, int32_t content_len, |
2579 | | blosc2_cparams *cparams); |
2580 | | |
2581 | | /** |
2582 | | * @brief Get the content out of a variable-length metalayer. |
2583 | | * |
2584 | | * @param schunk The super-chunk containing the variable-length metalayer. |
2585 | | * @param name The name of the variable-length metalayer. |
2586 | | * @param content The pointer where the content will be put. |
2587 | | * @param content_len The pointer where the length of the content will be put. |
2588 | | * |
2589 | | * @warning The @p **content receives a malloc'ed copy of the content. |
2590 | | * The user is responsible of freeing it. |
2591 | | * |
2592 | | * @note For disk-based super-chunks, this checks whether another handle has |
2593 | | * rewritten the frame and, if so, re-reads the cached metalayers first, so |
2594 | | * updates made through other handles (or processes) become visible. |
2595 | | * |
2596 | | * @return If successful, the index of the new variable-length metalayer. Else, return a negative value. |
2597 | | */ |
2598 | | BLOSC_EXPORT int blosc2_vlmeta_get(blosc2_schunk *schunk, const char *name, |
2599 | | uint8_t **content, int32_t *content_len); |
2600 | | |
2601 | | /** |
2602 | | * @brief Delete the variable-length metalayer from the super-chunk. |
2603 | | * |
2604 | | * @param schunk The super-chunk containing the variable-length metalayer. |
2605 | | * @param name The name of the variable-length metalayer. |
2606 | | * |
2607 | | * @return If successful, the number of the variable-length metalayers in the super-chunk. Else, return a negative value. |
2608 | | */ |
2609 | | BLOSC_EXPORT int blosc2_vlmeta_delete(blosc2_schunk *schunk, const char *name); |
2610 | | |
2611 | | /** |
2612 | | * @brief Get a list of all the variable-length metalayer names. |
2613 | | * |
2614 | | * @param schunk The super-chunk containing the variable-length metalayers. |
2615 | | * @param names The pointer to a char** to store the name pointers. This should |
2616 | | * be of size *schunk->nvlmetalayers * sizeof(char*). |
2617 | | * |
2618 | | * @return The number of the variable-length metalayers in the super-chunk. |
2619 | | * This cannot fail unless the user does not pass a @p names which is large enough to |
2620 | | * keep pointers to all names, in which case funny things (seg faults and such) will happen. |
2621 | | */ |
2622 | | BLOSC_EXPORT int blosc2_vlmeta_get_names(blosc2_schunk *schunk, char **names); |
2623 | | |
2624 | | |
2625 | | /********************************************************************* |
2626 | | Time measurement utilities. |
2627 | | *********************************************************************/ |
2628 | | |
2629 | | #if defined(_WIN32) |
2630 | | /* For QueryPerformanceCounter(), etc. */ |
2631 | | #include <windows.h> |
2632 | | #elif defined(__MACH__) && defined(__APPLE__) |
2633 | | #include <mach/clock.h> |
2634 | | #include <mach/mach.h> |
2635 | | #include <time.h> |
2636 | | #elif defined(__unix__) |
2637 | | #if defined(__linux__) |
2638 | | #include <time.h> |
2639 | | #else |
2640 | | #include <sys/time.h> |
2641 | | #endif |
2642 | | #else |
2643 | | #error Unable to detect platform. |
2644 | | #endif |
2645 | | |
2646 | | /* The type of timestamp used on this system. */ |
2647 | | #if defined(_WIN32) |
2648 | | typedef LARGE_INTEGER blosc_timestamp_t; |
2649 | | #else |
2650 | | typedef struct timespec blosc_timestamp_t; |
2651 | | #endif |
2652 | | |
2653 | | /* |
2654 | | * @brief Set a timestamp. |
2655 | | * |
2656 | | * @param timestamp |
2657 | | * |
2658 | | */ |
2659 | | BLOSC_EXPORT void blosc_set_timestamp(blosc_timestamp_t* timestamp); |
2660 | | |
2661 | | /* |
2662 | | * @brief Get the nanoseconds between 2 timestamps. |
2663 | | * |
2664 | | * @param start_time |
2665 | | * @param end_time |
2666 | | * |
2667 | | * @return The nanoseconds between start_time and end_time. |
2668 | | */ |
2669 | | BLOSC_EXPORT double blosc_elapsed_nsecs(blosc_timestamp_t start_time, |
2670 | | blosc_timestamp_t end_time); |
2671 | | |
2672 | | /* |
2673 | | * @brief Get the seconds between 2 timestamps. |
2674 | | * |
2675 | | * @param start_time |
2676 | | * @param end_time |
2677 | | * |
2678 | | * @return The seconds between start_time and end_time. |
2679 | | */ |
2680 | | BLOSC_EXPORT double blosc_elapsed_secs(blosc_timestamp_t start_time, |
2681 | | blosc_timestamp_t end_time); |
2682 | | |
2683 | | |
2684 | | /********************************************************************* |
2685 | | Low-level functions follows. Use them only if you are an expert! |
2686 | | *********************************************************************/ |
2687 | | |
2688 | | /** |
2689 | | * @brief Get the internal blocksize to be used during compression. 0 means |
2690 | | * that an automatic blocksize is computed internally. |
2691 | | * |
2692 | | * @return The size in bytes of the internal block size. |
2693 | | */ |
2694 | | BLOSC_EXPORT int blosc1_get_blocksize(void); |
2695 | | |
2696 | | /** |
2697 | | * @brief Force the use of a specific blocksize. If 0, an automatic |
2698 | | * blocksize will be used (the default). |
2699 | | * |
2700 | | * @warning The blocksize is a critical parameter with important |
2701 | | * restrictions in the allowed values, so use this with care. |
2702 | | */ |
2703 | | BLOSC_EXPORT void blosc1_set_blocksize(size_t blocksize); |
2704 | | |
2705 | | |
2706 | | /** |
2707 | | * @brief Set the split mode. |
2708 | | |
2709 | | * @param splitmode It can take the next values: |
2710 | | * BLOSC_FORWARD_COMPAT_SPLIT |
2711 | | * BLOSC_AUTO_SPLIT |
2712 | | * BLOSC_NEVER_SPLIT |
2713 | | * BLOSC_ALWAYS_SPLIT |
2714 | | * |
2715 | | * BLOSC_FORWARD_COMPAT offers reasonably forward compatibility, |
2716 | | * BLOSC_AUTO_SPLIT is for nearly optimal results (based on heuristics), |
2717 | | * BLOSC_NEVER_SPLIT and BLOSC_ALWAYS_SPLIT are for the user experimenting |
2718 | | * when trying to get best compression ratios and/or speed. |
2719 | | * |
2720 | | * If not called, the default mode is BLOSC_FORWARD_COMPAT_SPLIT. |
2721 | | * |
2722 | | * This function should always succeed. |
2723 | | */ |
2724 | | BLOSC_EXPORT void blosc1_set_splitmode(int splitmode); |
2725 | | |
2726 | | /** |
2727 | | * @brief Make a compression context write Blosc1 chunks. |
2728 | | * |
2729 | | * The chunks use format version 2 and the 16-byte header, so that they can also be |
2730 | | * decoded by C-Blosc 1.x. They are not byte-identical to what C-Blosc 1.x would write. |
2731 | | * Contexts do not write Blosc1 chunks by default. |
2732 | | * |
2733 | | * The chunk format has room for a plain shuffle or bitshuffle filter, in whichever slot of |
2734 | | * the filter pipeline it is, and for the blosclz, lz4, lz4hc, zlib and zstd codecs. A |
2735 | | * compression call on a context that has any other filter or more than one filter, another |
2736 | | * codec, a dictionary or variable-length blocks fails with an error. A prefilter is applied |
2737 | | * as usual: the chunk records nothing about it, so a reader gets the prefiltered data. |
2738 | | * |
2739 | | * @param context A compression context. |
2740 | | * @param enable Whether to write Blosc1 chunks. |
2741 | | * |
2742 | | * @return 0 on success, a negative error code otherwise. |
2743 | | * |
2744 | | * @sa #blosc2_ctx_get_blosc1_format |
2745 | | */ |
2746 | | BLOSC_EXPORT int blosc2_ctx_set_blosc1_format(blosc2_context* context, bool enable); |
2747 | | |
2748 | | /** |
2749 | | * @brief Query whether a compression context writes Blosc1 chunks. |
2750 | | * |
2751 | | * @param context A compression context. |
2752 | | * |
2753 | | * @return true if the context is set to write Blosc1 chunks, false if it is not or if |
2754 | | * @p context is NULL. |
2755 | | * |
2756 | | * @sa #blosc2_ctx_set_blosc1_format |
2757 | | */ |
2758 | | BLOSC_EXPORT bool blosc2_ctx_get_blosc1_format(const blosc2_context* context); |
2759 | | |
2760 | | |
2761 | | /** |
2762 | | * @brief Get the offsets of a frame in a super-chunk. |
2763 | | * |
2764 | | * @param schunk The super-chunk containing the frame. |
2765 | | * |
2766 | | * @return If successful, return a pointer to a buffer of the decompressed offsets. |
2767 | | * The number of offsets is equal to schunk->nchunks; the user is |
2768 | | * responsible to free this buffer. Else, return a NULL value. |
2769 | | */ |
2770 | | BLOSC_EXPORT int64_t* blosc2_frame_get_offsets(blosc2_schunk *schunk); |
2771 | | |
2772 | | |
2773 | | /********************************************************************* |
2774 | | Structures and functions related with compression codecs. |
2775 | | *********************************************************************/ |
2776 | | |
2777 | | typedef int (* blosc2_codec_encoder_cb) (const uint8_t *input, int32_t input_len, uint8_t *output, int32_t output_len, |
2778 | | uint8_t meta, blosc2_cparams *cparams, const void* chunk); |
2779 | | typedef int (* blosc2_codec_decoder_cb) (const uint8_t *input, int32_t input_len, uint8_t *output, int32_t output_len, |
2780 | | uint8_t meta, blosc2_dparams *dparams, const void* chunk); |
2781 | | |
2782 | | typedef struct { |
2783 | | uint8_t compcode; |
2784 | | //!< The codec identifier. |
2785 | | char *compname; |
2786 | | //!< The codec name. |
2787 | | uint8_t complib; |
2788 | | //!< The codec library format. |
2789 | | uint8_t version; |
2790 | | //!< The codec version. |
2791 | | blosc2_codec_encoder_cb encoder; |
2792 | | //!< The codec encoder that is used during compression. |
2793 | | blosc2_codec_decoder_cb decoder; |
2794 | | //!< The codec decoder that is used during decompression. |
2795 | | // int (*free)(void* codec_params); |
2796 | | // //!< Free the codec_params stored in blosc2_context. |
2797 | | } blosc2_codec; |
2798 | | |
2799 | | /** |
2800 | | * @brief Register locally a user-defined codec in Blosc. |
2801 | | * |
2802 | | * @param codec The codec to register. |
2803 | | * |
2804 | | * @return 0 if succeeds. Else a negative code is returned. |
2805 | | */ |
2806 | | BLOSC_EXPORT int blosc2_register_codec(blosc2_codec *codec); |
2807 | | |
2808 | | |
2809 | | /********************************************************************* |
2810 | | Structures and functions related with filters plugins. |
2811 | | *********************************************************************/ |
2812 | | |
2813 | | typedef int (* blosc2_filter_forward_cb) (const uint8_t *, uint8_t *, int32_t, uint8_t, blosc2_cparams *, |
2814 | | uint8_t); |
2815 | | typedef int (* blosc2_filter_backward_cb) (const uint8_t *, uint8_t *, int32_t, uint8_t, blosc2_dparams *, |
2816 | | uint8_t); |
2817 | | |
2818 | | /** |
2819 | | * @brief The parameters for a user-defined filter. |
2820 | | */ |
2821 | | typedef struct { |
2822 | | uint8_t id; |
2823 | | //!< The filter identifier. |
2824 | | char * name; |
2825 | | //!< The filter name. |
2826 | | uint8_t version; |
2827 | | //!< The filter version. |
2828 | | blosc2_filter_forward_cb forward; |
2829 | | //!< The filter function that is used during compression. |
2830 | | blosc2_filter_backward_cb backward; |
2831 | | //!< The filter function that is used during decompression. |
2832 | | } blosc2_filter; |
2833 | | |
2834 | | /** |
2835 | | * @brief Register locally a user-defined filter in Blosc. |
2836 | | * |
2837 | | * @param filter The filter to register. |
2838 | | * |
2839 | | * @return 0 if succeeds. Else a negative code is returned. |
2840 | | */ |
2841 | | BLOSC_EXPORT int blosc2_register_filter(blosc2_filter *filter); |
2842 | | |
2843 | | /********************************************************************* |
2844 | | Directory utilities. |
2845 | | *********************************************************************/ |
2846 | | |
2847 | | /* |
2848 | | * @brief Remove a directory and its files. |
2849 | | * |
2850 | | * @param path The directory to remove. |
2851 | | * |
2852 | | * @return 0 if succeeds. Else a negative code is returned. |
2853 | | */ |
2854 | | BLOSC_EXPORT int blosc2_remove_dir(const char *path); |
2855 | | |
2856 | | /* |
2857 | | * @brief Remove a file or a directory given by path. |
2858 | | * |
2859 | | * @param path The file or directory to remove. |
2860 | | * |
2861 | | * @return 0 if succeeds. Else a negative code is returned. |
2862 | | */ |
2863 | | BLOSC_EXPORT int blosc2_remove_urlpath(const char *path); |
2864 | | |
2865 | | /* |
2866 | | * @brief Rename a file or a directory given by old_urlpath to new_path. |
2867 | | * |
2868 | | * @param old_urlpath The original path to the directory or file. |
2869 | | * @param new_path The new path to the directory or file. |
2870 | | * |
2871 | | * @return 0 if succeeds. Else a negative code is returned. |
2872 | | */ |
2873 | | BLOSC_EXPORT int blosc2_rename_urlpath(char* old_urlpath, char* new_path); |
2874 | | |
2875 | | |
2876 | | /********************************************************************* |
2877 | | Index utilities. |
2878 | | *********************************************************************/ |
2879 | | |
2880 | | /* |
2881 | | * @brief Convert a sequential index into a multidimensional index |
2882 | | * |
2883 | | * This function assume ndim <= B2ND_MAX_DIM. |
2884 | | */ |
2885 | | BLOSC_EXPORT void blosc2_unidim_to_multidim(uint8_t ndim, int64_t *shape, int64_t i, int64_t *index); |
2886 | | |
2887 | | /* |
2888 | | * @brief Convert a multidimensional index into a sequential index |
2889 | | */ |
2890 | | BLOSC_EXPORT void blosc2_multidim_to_unidim(const int64_t *index, int8_t ndim, const int64_t *strides, int64_t *i); |
2891 | | |
2892 | | /* |
2893 | | * @brief Get the unidimensional chunk indexes needed to get a slice of a schunk or a b2nd array |
2894 | | * |
2895 | | * @param schunk The super-chunk (of b2nd array or not). |
2896 | | * @param start Index (0-based if it is a schunk) where the slice begins. |
2897 | | * @param stop The first index (0-based if it is a schunk) that is not in the selected slice. |
2898 | | * @param chunks_idx The pointer to the buffer where the indexes will be written. It is the user responsibility |
2899 | | * to free the buffer. |
2900 | | * |
2901 | | * @return The number of chunks needed to get the slice. If some problem is |
2902 | | * detected, a negative code is returned instead. |
2903 | | */ |
2904 | | BLOSC_EXPORT int64_t blosc2_get_slice_nchunks(blosc2_schunk* schunk, int64_t *start, int64_t *stop, int64_t **chunks_idx); |
2905 | | |
2906 | | |
2907 | | /********************************************************************* |
2908 | | Raw shuffle functions. |
2909 | | *********************************************************************/ |
2910 | | |
2911 | | /** |
2912 | | * @brief Applies the shuffle operation to a block of data in @p src, and puts the result in @p dest. |
2913 | | * |
2914 | | * @warning The @p src buffer and the @p dest buffer can not overlap. |
2915 | | * |
2916 | | * @param typesize Is the number of bytes for the atomic type in binary @p src buffer. Only 1 < typesize |
2917 | | * < 256 is allowed. |
2918 | | * @param blocksize The size of the block. |
2919 | | * @param src The source buffer to be shuffled. |
2920 | | * @param dest The destination buffer where the shuffled data will be written. |
2921 | | * |
2922 | | * @return @p blocksize on success or a negative value if some error happens (mainly an invalid parameter). |
2923 | | */ |
2924 | | BLOSC_EXPORT int32_t blosc2_shuffle(const int32_t typesize, const int32_t blocksize, const void* src, |
2925 | | void* dest); |
2926 | | |
2927 | | /** |
2928 | | * @brief Applies the inverse shuffle operation to a block of data in @p src, and puts the result in @p dest. |
2929 | | * |
2930 | | * @warning The @p src buffer and the @p dest buffer can not overlap. |
2931 | | * |
2932 | | * @param typesize Is the number of bytes for the atomic type in binary @p src buffer. Only 1 < typesize |
2933 | | * < 256 is allowed. |
2934 | | * @param blocksize The size of the block. |
2935 | | * @param src The source buffer to be unshuffled. |
2936 | | * @param dest The destination buffer where the unshuffled data will be written. |
2937 | | * |
2938 | | * @return @p blocksize on success or a negative value if some error happens (mainly an invalid parameter). |
2939 | | */ |
2940 | | BLOSC_EXPORT int32_t blosc2_unshuffle(const int32_t typesize, const int32_t blocksize, const void* src, |
2941 | | void* dest); |
2942 | | |
2943 | | /** |
2944 | | * @brief Applies the bitshuffle operation to a block of data in @p src, and puts the result in @p dest. |
2945 | | * |
2946 | | * @warning The @p src buffer and the @p dest buffer can not overlap. |
2947 | | * |
2948 | | * @remark The function will shuffle the maximum amount of elements that can be divided by 8, and copy the |
2949 | | * rest to the destination buffer unchanged. There are @p blocksize / @p typesize elements. |
2950 | | * |
2951 | | * @param typesize Is the number of bytes for the atomic type in binary @p src buffer. Only 1 < typesize |
2952 | | * < 256 is allowed. |
2953 | | * @param blocksize The size of the block. |
2954 | | * @param src The source buffer to be shuffled. |
2955 | | * @param dest The destination buffer where the shuffled data will be written. |
2956 | | * |
2957 | | * @return @p blocksize on success or a negative value if some error happens (mainly an invalid parameter). |
2958 | | */ |
2959 | | BLOSC_EXPORT int32_t blosc2_bitshuffle(const int32_t typesize, const int32_t blocksize, const void* src, |
2960 | | void* dest); |
2961 | | |
2962 | | /** |
2963 | | * @brief Applies the inverse bitshuffle operation to a block of data in @p src, and puts the result in @p dest. |
2964 | | * |
2965 | | * @warning The @p src buffer and the @p dest buffer can not overlap. |
2966 | | * |
2967 | | * @remark The function will shuffle the maximum amount of elements that can be divided by 8, and copy the |
2968 | | * rest to the destination buffer unchanged. There are @p blocksize / @p typesize elements. |
2969 | | * |
2970 | | * @param typesize Is the number of bytes for the atomic type in binary @p src buffer. Only 1 < typesize |
2971 | | * < 256 is allowed. |
2972 | | * @param blocksize The size of the block. |
2973 | | * @param src The source buffer to be unshuffled. |
2974 | | * @param dest The destination buffer where the unshuffled data will be written. |
2975 | | * |
2976 | | * @return @p blocksize on success or a negative value if some error happens (mainly an invalid parameter). |
2977 | | */ |
2978 | | BLOSC_EXPORT int32_t blosc2_bitunshuffle(const int32_t typesize, const int32_t blocksize, const void* src, |
2979 | | void* dest); |
2980 | | |
2981 | | |
2982 | | /********************************************************************* |
2983 | | Private functions, these are here for convenience, |
2984 | | and are not meant to be included in public docs |
2985 | | *********************************************************************/ |
2986 | | |
2987 | | // Private function needed in b2nd.h for deserializing meta |
2988 | 0 | static inline void swap_store(void *dest, const void *pa, int size) { |
2989 | 0 | uint8_t *pa_ = (uint8_t *) pa; |
2990 | 0 | uint8_t *pa2_ = (uint8_t*)malloc((size_t) size); |
2991 | 0 | int i = 1; /* for big/little endian detection */ |
2992 | 0 | char *p = (char *) &i; |
2993 | |
|
2994 | 0 | if (p[0] == 1) { |
2995 | | /* little endian */ |
2996 | 0 | switch (size) { |
2997 | 0 | case 8: |
2998 | 0 | pa2_[0] = pa_[7]; |
2999 | 0 | pa2_[1] = pa_[6]; |
3000 | 0 | pa2_[2] = pa_[5]; |
3001 | 0 | pa2_[3] = pa_[4]; |
3002 | 0 | pa2_[4] = pa_[3]; |
3003 | 0 | pa2_[5] = pa_[2]; |
3004 | 0 | pa2_[6] = pa_[1]; |
3005 | 0 | pa2_[7] = pa_[0]; |
3006 | 0 | break; |
3007 | 0 | case 4: |
3008 | 0 | pa2_[0] = pa_[3]; |
3009 | 0 | pa2_[1] = pa_[2]; |
3010 | 0 | pa2_[2] = pa_[1]; |
3011 | 0 | pa2_[3] = pa_[0]; |
3012 | 0 | break; |
3013 | 0 | case 2: |
3014 | 0 | pa2_[0] = pa_[1]; |
3015 | 0 | pa2_[1] = pa_[0]; |
3016 | 0 | break; |
3017 | 0 | case 1: |
3018 | 0 | pa2_[0] = pa_[0]; |
3019 | 0 | break; |
3020 | 0 | default: |
3021 | 0 | fprintf(stderr, "Unhandled nitems: %d\n", size); |
3022 | 0 | } |
3023 | 0 | } else { |
3024 | | /* big endian: native byte order is already big-endian, just copy */ |
3025 | 0 | memcpy(pa2_, pa_, size); |
3026 | 0 | } |
3027 | 0 | memcpy(dest, pa2_, size); |
3028 | 0 | free(pa2_); |
3029 | 0 | } Unexecuted instantiation: fuzz_compress_frame.c:swap_store Unexecuted instantiation: blosc2.c:swap_store Unexecuted instantiation: blosclz.c:swap_store Unexecuted instantiation: schunk.c:swap_store Unexecuted instantiation: frame.c:swap_store Unexecuted instantiation: stune.c:swap_store Unexecuted instantiation: trunc-prec.c:swap_store Unexecuted instantiation: timestamp.c:swap_store Unexecuted instantiation: sframe.c:swap_store Unexecuted instantiation: blosc2-stdio.c:swap_store Unexecuted instantiation: b2nd.c:swap_store Unexecuted instantiation: b2nd_utils.c:swap_store Unexecuted instantiation: shuffle.c:swap_store Unexecuted instantiation: blosc2-zfp.c:swap_store Unexecuted instantiation: codecs-registry.c:swap_store Unexecuted instantiation: tuners-registry.c:swap_store Unexecuted instantiation: filters-registry.c:swap_store Unexecuted instantiation: ndlz.c:swap_store Unexecuted instantiation: ndlz4x4.c:swap_store Unexecuted instantiation: ndlz8x8.c:swap_store Unexecuted instantiation: ndcell.c:swap_store Unexecuted instantiation: ndmean.c:swap_store Unexecuted instantiation: bytedelta.c:swap_store Unexecuted instantiation: int_trunc.c:swap_store Unexecuted instantiation: fuzz_decompress_frame.c:swap_store Unexecuted instantiation: fuzz_compress_chunk.c:swap_store Unexecuted instantiation: fuzz_decompress_chunk.c:swap_store |
3030 | | |
3031 | | #ifdef __cplusplus |
3032 | | } |
3033 | | #endif |
3034 | | |
3035 | | #endif /* BLOSC_BLOSC2_H */ |