/src/c-blosc2/plugins/codecs/ndlz/ndlz.c
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 | | This codec is meant to leverage multidimensionality for getting |
13 | | better compression ratios. The idea is to look for similarities |
14 | | in places that are closer in a euclidean metric, not the typical |
15 | | linear one. |
16 | | **********************************************************************/ |
17 | | |
18 | | #include "ndlz-private.h" |
19 | | #include "ndlz4x4.h" |
20 | | #include "ndlz8x8.h" |
21 | | #include "ndlz.h" |
22 | | |
23 | | int ndlz_compress(const uint8_t *input, int32_t input_len, uint8_t *output, int32_t output_len, |
24 | 0 | uint8_t meta, blosc2_cparams *cparams, const void *chunk) { |
25 | 0 | NDLZ_ERROR_NULL(input); |
26 | 0 | NDLZ_ERROR_NULL(output); |
27 | 0 | NDLZ_ERROR_NULL(cparams); |
28 | 0 | BLOSC_UNUSED_PARAM(chunk); |
29 | |
|
30 | 0 | switch (meta) { |
31 | 0 | case 4: |
32 | 0 | return ndlz4_compress(input, input_len, output, output_len, meta, cparams); |
33 | 0 | case 8: |
34 | 0 | return ndlz8_compress(input, input_len, output, output_len, meta, cparams); |
35 | 0 | default: |
36 | 0 | BLOSC_TRACE_ERROR("NDLZ is not available for this cellsize: %d", meta); |
37 | 0 | } |
38 | 0 | return BLOSC2_ERROR_FAILURE; |
39 | 0 | } |
40 | | |
41 | | int ndlz_decompress(const uint8_t *input, int32_t input_len, uint8_t *output, int32_t output_len, |
42 | 0 | uint8_t meta, blosc2_dparams *dparams, const void *chunk) { |
43 | 0 | NDLZ_ERROR_NULL(input); |
44 | 0 | NDLZ_ERROR_NULL(output); |
45 | 0 | NDLZ_ERROR_NULL(dparams); |
46 | 0 | BLOSC_UNUSED_PARAM(chunk); |
47 | |
|
48 | 0 | switch (meta) { |
49 | 0 | case 4: |
50 | 0 | return ndlz4_decompress(input, input_len, output, output_len, meta, dparams); |
51 | 0 | case 8: |
52 | 0 | return ndlz8_decompress(input, input_len, output, output_len, meta, dparams); |
53 | 0 | default: |
54 | 0 | BLOSC_TRACE_ERROR("NDLZ is not available for this cellsize: %d", meta); |
55 | 0 | } |
56 | 0 | return BLOSC2_ERROR_FAILURE; |
57 | 0 | } |