| 1 | /********************************************************************* |
|---|
| 2 | Blosc - Blocked Suffling and Compression Library |
|---|
| 3 | |
|---|
| 4 | Author: Francesc Alted (faltet@pytables.org) |
|---|
| 5 | |
|---|
| 6 | See LICENSES/BLOSC.txt for details about copyright and rights to use. |
|---|
| 7 | **********************************************************************/ |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | #ifndef BLOSC_H |
|---|
| 11 | #define BLOSC_H |
|---|
| 12 | |
|---|
| 13 | /* Version numbers */ |
|---|
| 14 | #define BLOSC_VERSION_MAJOR 0 /* for major interface/format changes */ |
|---|
| 15 | #define BLOSC_VERSION_MINOR 9 /* for minor interface/format changes */ |
|---|
| 16 | #define BLOSC_VERSION_RELEASE 1 /* for tweaks, bug-fixes, or development */ |
|---|
| 17 | |
|---|
| 18 | #define BLOSC_VERSION_STRING "0.9.1.dev" /* string version. Sync with above! */ |
|---|
| 19 | #define BLOSC_VERSION_DATE "2010-05-26" /* date version */ |
|---|
| 20 | |
|---|
| 21 | /* The *_VERS_FORMAT should be just 1-byte long */ |
|---|
| 22 | #define BLOSC_VERSION_FORMAT 2 /* Blosc format version, starting at 1 */ |
|---|
| 23 | #define BLOSCLZ_VERSION_FORMAT 1 /* Blosclz format version, starting at 1 */ |
|---|
| 24 | |
|---|
| 25 | /* The combined blosc and blosclz formats */ |
|---|
| 26 | #define BLOSC_VERSION_CFORMAT (BLOSC_VERSION_FORMAT << 8) & (BLOSCLZ_VERSION_FORMAT) |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | /** |
|---|
| 30 | |
|---|
| 31 | Initialize a pool of threads for compression/decompression. If |
|---|
| 32 | `nthreads` is 1, then the serial version is chosen and a possible |
|---|
| 33 | previous existing pool is ended. Returns the previous number of |
|---|
| 34 | threads. If this is not called, `nthreads` is set to 1 internally. |
|---|
| 35 | |
|---|
| 36 | */ |
|---|
| 37 | |
|---|
| 38 | int blosc_set_nthreads(int nthreads); |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | /** |
|---|
| 42 | |
|---|
| 43 | Compress a block of data in the `src` buffer and returns the size of |
|---|
| 44 | compressed block. The size of `src` buffer is specified by |
|---|
| 45 | `nbytes`. There is not a minimum `src` buffer size (`nbytes`). |
|---|
| 46 | |
|---|
| 47 | `clevel` is the desired compression level and must be a number |
|---|
| 48 | between 0 (no compression) and 9 (maximum compression). |
|---|
| 49 | |
|---|
| 50 | `doshuffle` specifies whether the shuffle compression preconditioner |
|---|
| 51 | should be applyied or not. 0 means not applying it and 1 means |
|---|
| 52 | applying it. |
|---|
| 53 | |
|---|
| 54 | `typesize` is the number of bytes for the atomic type in binary |
|---|
| 55 | `src` buffer. This is mainly useful for the shuffle preconditioner. |
|---|
| 56 | Only a typesize > 1 will allow the shuffle to work. |
|---|
| 57 | |
|---|
| 58 | The `dest` buffer must have at least the size of the `src` buffer. |
|---|
| 59 | The `src` buffer and the `dest` buffer can not overlap. |
|---|
| 60 | |
|---|
| 61 | If `src` buffer is not compressible (len(`dest`) >= len(`src`)), the |
|---|
| 62 | return value is zero and you should discard the contents of the |
|---|
| 63 | `dest` buffer. |
|---|
| 64 | |
|---|
| 65 | A negative return value means that an internal error happened. This |
|---|
| 66 | should never happen. If you see this, please report it back |
|---|
| 67 | together with the buffer data causing this and compression settings. |
|---|
| 68 | |
|---|
| 69 | Compression is memory safe and guaranteed not to write the `dest` |
|---|
| 70 | buffer more than what is specified in `nbytes`. However, it is not |
|---|
| 71 | re-entrant and not thread-safe (despite the fact that it uses |
|---|
| 72 | threads internally ;-) |
|---|
| 73 | |
|---|
| 74 | */ |
|---|
| 75 | |
|---|
| 76 | unsigned int blosc_compress(int clevel, int doshuffle, size_t typesize, |
|---|
| 77 | size_t nbytes, const void *src, void *dest); |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | /** |
|---|
| 81 | |
|---|
| 82 | Decompress a block of compressed data in `src`, put the result in |
|---|
| 83 | `dest` and returns the size of the decompressed block. If error |
|---|
| 84 | occurs, e.g. the compressed data is corrupted or the output buffer |
|---|
| 85 | is not large enough, then 0 (zero) or a negative value will be |
|---|
| 86 | returned instead. |
|---|
| 87 | |
|---|
| 88 | The `src` buffer and the `dest` buffer can not overlap. |
|---|
| 89 | |
|---|
| 90 | Decompression is memory safe and guaranteed not to write the `dest` |
|---|
| 91 | buffer more than what is specified in `dest_size`. However, it is |
|---|
| 92 | not re-entrant and not thread-safe (despite the fact that it uses |
|---|
| 93 | threads internally ;-) |
|---|
| 94 | |
|---|
| 95 | */ |
|---|
| 96 | |
|---|
| 97 | unsigned int blosc_decompress(const void *src, void *dest, size_t dest_size); |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | /** |
|---|
| 101 | |
|---|
| 102 | Free possible memory temporaries and thread resources. Use this |
|---|
| 103 | when you are not going to use Blosc for a long while. |
|---|
| 104 | |
|---|
| 105 | */ |
|---|
| 106 | |
|---|
| 107 | void blosc_free_resources(void); |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | /********************************************************************* |
|---|
| 112 | |
|---|
| 113 | Low-level functions follows. Use them only if you are an expert! |
|---|
| 114 | |
|---|
| 115 | *********************************************************************/ |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | /** |
|---|
| 119 | |
|---|
| 120 | Force the use of a specific blocksize. If 0, an automatic |
|---|
| 121 | blocksize will be used (the default). |
|---|
| 122 | |
|---|
| 123 | */ |
|---|
| 124 | |
|---|
| 125 | void blosc_set_blocksize(size_t blocksize); |
|---|
| 126 | |
|---|
| 127 | |
|---|
| 128 | #endif |
|---|