Debian Codegraph @

src/bitshuffle_internals.h

raw
1 /*
2 * Bitshuffle - Filter for improving compression of typed binary data.
3 *
4 * This file is part of Bitshuffle
5 * Author: Kiyoshi Masui <[email protected]>
6 * Website: https://www.github.com/kiyo-masui/bitshuffle
7 * Created: 2014
8 *
9 * See LICENSE file for details about copyright and rights to use.
10 */
11
12
13 #ifndef BITSHUFFLE_INTERNALS_H
14 #define BITSHUFFLE_INTERNALS_H
15
16 // We assume GNU g++ defining `__cplusplus` has stdint.h
17 #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199900L) || defined(__cplusplus)
18 #include <stdint.h>
19 #else
20 typedef unsigned char uint8_t;
21 typedef unsigned short uint16_t;
22 typedef unsigned int uint32_t;
23 typedef signed int int32_t;
24 typedef unsigned long long uint64_t;
25 typedef long long int64_t;
26 #endif
27
28 #include <stdlib.h>
29 #include "iochain.h"
30
31
32 // Constants.
33 #ifndef BSHUF_MIN_RECOMMEND_BLOCK
34 #define BSHUF_MIN_RECOMMEND_BLOCK 128
35 #define BSHUF_BLOCKED_MULT 8 // Block sizes must be multiple of this.
36 #define BSHUF_TARGET_BLOCK_SIZE_B 8192
37 #endif
38
39
40 // Macros.
41 #define CHECK_ERR_FREE(count, buf) \
42 do { \
43 if ((count) < 0) { \
44 free(buf); \
45 return (count); \
46 } \
47 } while (0)
48
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 /* ---- Utility functions for internal use only ---- */
55
56 int64_t bshuf_trans_bit_elem(const void* in, void* out, const size_t size,
57 const size_t elem_size);
58
59 /* Read a 32 bit unsigned integer from a buffer big endian order. */
60 uint32_t bshuf_read_uint32_BE(const void* buf);
61
62 /* Write a 32 bit unsigned integer to a buffer in big endian order. */
63 void bshuf_write_uint32_BE(void* buf, uint32_t num);
64
65 int64_t bshuf_untrans_bit_elem(const void* in, void* out, const size_t size,
66 const size_t elem_size);
67
68 /* Function definition for worker functions that process a single block. */
69 typedef int64_t (*bshufBlockFunDef)(ioc_chain* C_ptr,
70 const size_t size, const size_t elem_size, const int option);
71
72 /* Wrap a function for processing a single block to process an entire buffer in
73 * parallel. */
74 int64_t bshuf_blocked_wrap_fun(bshufBlockFunDef fun, const void* in, void* out,
75 const size_t size, const size_t elem_size, size_t block_size, const int option);
76
77 #ifdef __cplusplus
78 } // extern "C"
79 #endif
80
81 #endif // BITSHUFFLE_INTERNALS_H