-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCvxCompress.hxx
199 lines (178 loc) · 4.57 KB
/
CvxCompress.hxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#include <stdbool.h>
#ifndef CVX_CVXCOMPRESS_HXX
#define CVX_CVXCOMPRESS_HXX
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
/*!
* This class implements lossy compression for seismic wavefields.
* It uses Antonini's 7-9 tap filter wavelet transform.
* It was derived from the ChvCompress code by Ergas et.al.
* Recoded with AVX & AVX2 intrinisics for maximum throughput.
* Words of praise or heaps of scorn can be directed at [email protected].
*/
class CvxCompress
{
public:
CvxCompress();
virtual ~CvxCompress();
/*!
* Compress a 3D wavefield using a given block size and number of threads
* nx is fast, nz is slow
* scale is a relative threshold for discarding wavelet coefficients.
* recommendation for seismic wave-fields: scale=1e-2->1e-5
* larger scale means higher compression (more lossy)
*/
float Compress(
float scale,
float* vol,
int nx,
int ny,
int nz,
int bx,
int by,
int bz,
bool use_local_RMS,
unsigned int* compressed,
int num_threads,
long& compressed_length
);
/*!
* Compress a 3D wavefield using a given block size
* nx is fast, nz is slow
* scale is a relative threshold for discarding wavelet coefficients.
* recommendation for seismic wave-fields: scale=1e-2->1e-5
* larger scale means higher compression (more lossy)
*/
float Compress(
float scale,
float* vol,
int nx,
int ny,
int nz,
int bx,
int by,
int bz,
bool use_local_RMS,
unsigned int* compressed,
long& compressed_length
);
/*!
* Compress a 3D wavefield using a given block size.
* Works same as above, except parameter use_local_RMS is hardcoded to be false.
*/
float Compress(
float scale,
float* vol,
int nx,
int ny,
int nz,
int bx,
int by,
int bz,
unsigned int* compressed,
long& compressed_length
);
float Compress(
float scale,
float* vol,
int nx,
int ny,
int nz,
int bx,
int by,
int bz,
unsigned int* compressed,
int num_threads,
long& compressed_length
);
/*!< Decompress a 3D wavefield that was compressed with Compress(...) method */
float* Decompress(
int& nx,
int& ny,
int& nz,
unsigned int* compressed,
long compressed_length
);
void Decompress(
float* vol,
int nx,
int ny,
int nz,
unsigned int* compressed,
int num_threads,
long compressed_length
);
void Decompress(
float* vol,
int nx,
int ny,
int nz,
unsigned int* compressed,
long compressed_length
);
bool Is_Valid_Block_Size(int bx, int by, int bz);
static int Min_BX() {return 8;} /*!< Get minimum X block size. Will always be a power of two.*/
static int Max_BX() {return 256;} /*!< Get maximum X block size. Will always be a power of two.*/
static int Min_BY() {return 8;} /*!< Get minimum Y block size. Will always be a power of two.*/
static int Max_BY() {return 256;} /*!< Get maximum Y block size. Will always be a power of two.*/
static int Min_BZ() {return 8;} /*!< Get minimum Z block size. Will always be a power of two.*/
static int Max_BZ() {return 256;} /*!< Get maximum Z block size. Will always be a power of two.*/
bool Run_Module_Tests(bool verbose, bool exhaustive_throughput_tests); /*!< Execute module tests.*/
};
#endif // __cplusplus
float cvx_compress(
float scale,
float* vol,
int nx,
int ny,
int nz,
int bx,
int by,
int bz,
unsigned int* compressed,
long* compressed_length
);
float* cvx_decompress_outofplace(
int* nx,
int* ny,
int* nz,
unsigned int* compressed,
long compressed_length
);
void cvx_decompress_inplace(
float* vol,
int nx,
int ny,
int nz,
unsigned int* compressed,
long compressed_length
);
float cvx_compress_th(
float scale,
float* vol,
int nx,
int ny,
int nz,
int bx,
int by,
int bz,
bool use_local_RMS,
unsigned int* compressed,
int num_threads,
long* compressed_length
);
void cvx_decompress_inplace_th(
float* vol,
int nx,
int ny,
int nz,
unsigned int* compressed,
int num_threads,
long compressed_length
);
#ifdef __cplusplus
}
#endif
#endif