1 | /** |
---|
2 | * @file szd_float.c |
---|
3 | * @author Sheng Di, Dingwen Tao, Xin Liang |
---|
4 | * @date Aug, 2018 |
---|
5 | * @brief |
---|
6 | * (C) 2016 by Mathematics and Computer Science (MCS), Argonne National Laboratory. |
---|
7 | * See COPYRIGHT in top-level directory. |
---|
8 | */ |
---|
9 | |
---|
10 | #include <stdlib.h> |
---|
11 | #include <stdio.h> |
---|
12 | #include <string.h> |
---|
13 | #include "szd_float.h" |
---|
14 | #include "TightDataPointStorageF.h" |
---|
15 | #include "sz.h" |
---|
16 | #include "Huffman.h" |
---|
17 | #include "szd_float_pwr.h" |
---|
18 | #include "szd_float_ts.h" |
---|
19 | #include "utility.h" |
---|
20 | |
---|
21 | /** |
---|
22 | * |
---|
23 | * |
---|
24 | * @return status SUCCESSFUL (SZ_SCES) or not (other error codes) f |
---|
25 | * */ |
---|
26 | int SZ_decompress_args_float(float** newData, size_t r5, size_t r4, size_t r3, size_t r2, size_t r1, unsigned char* cmpBytes, size_t cmpSize) |
---|
27 | { |
---|
28 | int status = SZ_SCES; |
---|
29 | size_t dataLength = computeDataLength(r5,r4,r3,r2,r1); |
---|
30 | |
---|
31 | //unsigned char* tmpBytes; |
---|
32 | size_t targetUncompressSize = dataLength <<2; //i.e., *4 |
---|
33 | //tmpSize must be "much" smaller than dataLength |
---|
34 | size_t i, tmpSize = 8+MetaDataByteLength+exe_params->SZ_SIZE_TYPE; |
---|
35 | unsigned char* szTmpBytes; |
---|
36 | |
---|
37 | if(cmpSize!=8+4+MetaDataByteLength && cmpSize!=8+8+MetaDataByteLength) //4,8 means two posibilities of SZ_SIZE_TYPE |
---|
38 | { |
---|
39 | confparams_dec->losslessCompressor = is_lossless_compressed_data(cmpBytes, cmpSize); |
---|
40 | if(confparams_dec->szMode!=SZ_TEMPORAL_COMPRESSION) |
---|
41 | { |
---|
42 | if(confparams_dec->losslessCompressor!=-1) |
---|
43 | confparams_dec->szMode = SZ_BEST_COMPRESSION; |
---|
44 | else |
---|
45 | confparams_dec->szMode = SZ_BEST_SPEED; |
---|
46 | } |
---|
47 | |
---|
48 | if(confparams_dec->szMode==SZ_BEST_SPEED) |
---|
49 | { |
---|
50 | tmpSize = cmpSize; |
---|
51 | szTmpBytes = cmpBytes; |
---|
52 | } |
---|
53 | else if(confparams_dec->szMode==SZ_BEST_COMPRESSION || confparams_dec->szMode==SZ_DEFAULT_COMPRESSION || confparams_dec->szMode==SZ_TEMPORAL_COMPRESSION) |
---|
54 | { |
---|
55 | if(targetUncompressSize<MIN_ZLIB_DEC_ALLOMEM_BYTES) //Considering the minimum size |
---|
56 | targetUncompressSize = MIN_ZLIB_DEC_ALLOMEM_BYTES; |
---|
57 | tmpSize = sz_lossless_decompress(confparams_dec->losslessCompressor, cmpBytes, (unsigned long)cmpSize, &szTmpBytes, (unsigned long)targetUncompressSize+4+MetaDataByteLength+exe_params->SZ_SIZE_TYPE);// (unsigned long)targetUncompressSize+8: consider the total length under lossless compression mode is actually 3+4+1+targetUncompressSize |
---|
58 | //szTmpBytes = (unsigned char*)malloc(sizeof(unsigned char)*tmpSize); |
---|
59 | //memcpy(szTmpBytes, tmpBytes, tmpSize); |
---|
60 | //free(tmpBytes); //release useless memory |
---|
61 | } |
---|
62 | else |
---|
63 | { |
---|
64 | printf("Wrong value of confparams_dec->szMode in the double compressed bytes.\n"); |
---|
65 | status = SZ_MERR; |
---|
66 | return status; |
---|
67 | } |
---|
68 | } |
---|
69 | else |
---|
70 | szTmpBytes = cmpBytes; |
---|
71 | //TODO: convert szTmpBytes to data array. |
---|
72 | TightDataPointStorageF* tdps; |
---|
73 | int errBoundMode = new_TightDataPointStorageF_fromFlatBytes(&tdps, szTmpBytes, tmpSize); |
---|
74 | |
---|
75 | //writeByteData(tdps->typeArray, tdps->typeArray_size, "decompress-typebytes.tbt"); |
---|
76 | int dim = computeDimension(r5,r4,r3,r2,r1); |
---|
77 | int floatSize = sizeof(float); |
---|
78 | if(tdps->isLossless) |
---|
79 | { |
---|
80 | *newData = (float*)malloc(floatSize*dataLength); |
---|
81 | if(sysEndianType==BIG_ENDIAN_SYSTEM) |
---|
82 | { |
---|
83 | memcpy(*newData, szTmpBytes+4+MetaDataByteLength+exe_params->SZ_SIZE_TYPE, dataLength*floatSize); |
---|
84 | } |
---|
85 | else |
---|
86 | { |
---|
87 | unsigned char* p = szTmpBytes+4+MetaDataByteLength+exe_params->SZ_SIZE_TYPE; |
---|
88 | for(i=0;i<dataLength;i++,p+=floatSize) |
---|
89 | (*newData)[i] = bytesToFloat(p); |
---|
90 | } |
---|
91 | } |
---|
92 | else |
---|
93 | { |
---|
94 | if(tdps->raBytes_size > 0) //v2.0 |
---|
95 | { |
---|
96 | if (dim == 1) |
---|
97 | getSnapshotData_float_1D(newData,r1,tdps, errBoundMode); |
---|
98 | else if(dim == 2) |
---|
99 | decompressDataSeries_float_2D_nonblocked_with_blocked_regression(newData, r2, r1, tdps->raBytes); |
---|
100 | else if(dim == 3) |
---|
101 | decompressDataSeries_float_3D_nonblocked_with_blocked_regression(newData, r3, r2, r1, tdps->raBytes); |
---|
102 | else if(dim == 4) |
---|
103 | decompressDataSeries_float_3D_nonblocked_with_blocked_regression(newData, r4*r3, r2, r1, tdps->raBytes); |
---|
104 | else |
---|
105 | { |
---|
106 | printf("Error: currently support only at most 4 dimensions!\n"); |
---|
107 | status = SZ_DERR; |
---|
108 | } |
---|
109 | } |
---|
110 | else //1.4.13 |
---|
111 | { |
---|
112 | if (dim == 1) |
---|
113 | getSnapshotData_float_1D(newData,r1,tdps, errBoundMode); |
---|
114 | else if (dim == 2) |
---|
115 | getSnapshotData_float_2D(newData,r2,r1,tdps, errBoundMode); |
---|
116 | else if (dim == 3) |
---|
117 | getSnapshotData_float_3D(newData,r3,r2,r1,tdps, errBoundMode); |
---|
118 | else if (dim == 4) |
---|
119 | getSnapshotData_float_4D(newData,r4,r3,r2,r1,tdps, errBoundMode); |
---|
120 | else |
---|
121 | { |
---|
122 | printf("Error: currently support only at most 4 dimensions!\n"); |
---|
123 | status = SZ_DERR; |
---|
124 | } |
---|
125 | } |
---|
126 | } |
---|
127 | free_TightDataPointStorageF2(tdps); |
---|
128 | if(confparams_dec->szMode!=SZ_BEST_SPEED && cmpSize!=8+MetaDataByteLength+exe_params->SZ_SIZE_TYPE) |
---|
129 | free(szTmpBytes); |
---|
130 | return status; |
---|
131 | } |
---|
132 | |
---|
133 | void decompressDataSeries_float_1D(float** data, size_t dataSeriesLength, TightDataPointStorageF* tdps) |
---|
134 | { |
---|
135 | updateQuantizationInfo(tdps->intervals); |
---|
136 | size_t i, j, k = 0, p = 0, l = 0; // k is to track the location of residual_bit |
---|
137 | // in resiMidBits, p is to track the |
---|
138 | // byte_index of resiMidBits, l is for |
---|
139 | // leadNum |
---|
140 | unsigned char* leadNum; |
---|
141 | double interval = tdps->realPrecision*2; |
---|
142 | |
---|
143 | convertByteArray2IntArray_fast_2b(tdps->exactDataNum, tdps->leadNumArray, tdps->leadNumArray_size, &leadNum); |
---|
144 | |
---|
145 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
146 | |
---|
147 | int* type = (int*)malloc(dataSeriesLength*sizeof(int)); |
---|
148 | |
---|
149 | HuffmanTree* huffmanTree = createHuffmanTree(tdps->stateNum); |
---|
150 | decode_withTree(huffmanTree, tdps->typeArray, dataSeriesLength, type); |
---|
151 | SZ_ReleaseHuffman(huffmanTree); |
---|
152 | |
---|
153 | unsigned char preBytes[4]; |
---|
154 | unsigned char curBytes[4]; |
---|
155 | |
---|
156 | memset(preBytes, 0, 4); |
---|
157 | |
---|
158 | size_t curByteIndex = 0; |
---|
159 | int reqBytesLength, resiBitsLength, resiBits; |
---|
160 | unsigned char leadingNum; |
---|
161 | float medianValue, exactData, predValue; |
---|
162 | |
---|
163 | reqBytesLength = tdps->reqLength/8; |
---|
164 | resiBitsLength = tdps->reqLength%8; |
---|
165 | medianValue = tdps->medianValue; |
---|
166 | |
---|
167 | int type_; |
---|
168 | for (i = 0; i < dataSeriesLength; i++) { |
---|
169 | type_ = type[i]; |
---|
170 | switch (type_) { |
---|
171 | case 0: |
---|
172 | // compute resiBits |
---|
173 | resiBits = 0; |
---|
174 | if (resiBitsLength != 0) { |
---|
175 | int kMod8 = k % 8; |
---|
176 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
177 | if (rightMovSteps > 0) { |
---|
178 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
179 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
180 | } else if (rightMovSteps < 0) { |
---|
181 | int code1 = getLeftMovingCode(kMod8); |
---|
182 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
183 | int leftMovSteps = -rightMovSteps; |
---|
184 | rightMovSteps = 8 - leftMovSteps; |
---|
185 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
186 | p++; |
---|
187 | resiBits = resiBits |
---|
188 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
189 | } else // rightMovSteps == 0 |
---|
190 | { |
---|
191 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
192 | resiBits = (tdps->residualMidBits[p] & code); |
---|
193 | p++; |
---|
194 | } |
---|
195 | k += resiBitsLength; |
---|
196 | } |
---|
197 | |
---|
198 | // recover the exact data |
---|
199 | memset(curBytes, 0, 4); |
---|
200 | leadingNum = leadNum[l++]; |
---|
201 | memcpy(curBytes, preBytes, leadingNum); |
---|
202 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
203 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
204 | if (resiBitsLength != 0) { |
---|
205 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
206 | curBytes[reqBytesLength] = resiByte; |
---|
207 | } |
---|
208 | |
---|
209 | exactData = bytesToFloat(curBytes); |
---|
210 | (*data)[i] = exactData + medianValue; |
---|
211 | memcpy(preBytes,curBytes,4); |
---|
212 | break; |
---|
213 | default: |
---|
214 | //predValue = 2 * (*data)[i-1] - (*data)[i-2]; |
---|
215 | predValue = (*data)[i-1]; |
---|
216 | (*data)[i] = predValue + (type_-exe_params->intvRadius)*interval; |
---|
217 | break; |
---|
218 | } |
---|
219 | //printf("%.30G\n",(*data)[i]); |
---|
220 | } |
---|
221 | |
---|
222 | #ifdef HAVE_TIMECMPR |
---|
223 | if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
224 | memcpy(multisteps->hist_data, (*data), dataSeriesLength*sizeof(float)); |
---|
225 | #endif |
---|
226 | |
---|
227 | free(leadNum); |
---|
228 | free(type); |
---|
229 | return; |
---|
230 | } |
---|
231 | |
---|
232 | void decompressDataSeries_float_2D(float** data, size_t r1, size_t r2, TightDataPointStorageF* tdps) |
---|
233 | { |
---|
234 | updateQuantizationInfo(tdps->intervals); |
---|
235 | //printf("tdps->intervals=%d, exe_params->intvRadius=%d\n", tdps->intervals, exe_params->intvRadius); |
---|
236 | |
---|
237 | size_t j, k = 0, p = 0, l = 0; // k is to track the location of residual_bit |
---|
238 | // in resiMidBits, p is to track the |
---|
239 | // byte_index of resiMidBits, l is for |
---|
240 | // leadNum |
---|
241 | size_t dataSeriesLength = r1*r2; |
---|
242 | // printf ("%d %d\n", r1, r2); |
---|
243 | |
---|
244 | unsigned char* leadNum; |
---|
245 | double realPrecision = tdps->realPrecision; |
---|
246 | |
---|
247 | convertByteArray2IntArray_fast_2b(tdps->exactDataNum, tdps->leadNumArray, tdps->leadNumArray_size, &leadNum); |
---|
248 | |
---|
249 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
250 | |
---|
251 | int* type = (int*)malloc(dataSeriesLength*sizeof(int)); |
---|
252 | |
---|
253 | HuffmanTree* huffmanTree = createHuffmanTree(tdps->stateNum); |
---|
254 | decode_withTree(huffmanTree, tdps->typeArray, dataSeriesLength, type); |
---|
255 | SZ_ReleaseHuffman(huffmanTree); |
---|
256 | |
---|
257 | unsigned char preBytes[4]; |
---|
258 | unsigned char curBytes[4]; |
---|
259 | |
---|
260 | memset(preBytes, 0, 4); |
---|
261 | |
---|
262 | size_t curByteIndex = 0; |
---|
263 | int reqBytesLength, resiBitsLength, resiBits; |
---|
264 | unsigned char leadingNum; |
---|
265 | float medianValue, exactData; |
---|
266 | int type_; |
---|
267 | |
---|
268 | reqBytesLength = tdps->reqLength/8; |
---|
269 | resiBitsLength = tdps->reqLength%8; |
---|
270 | medianValue = tdps->medianValue; |
---|
271 | |
---|
272 | float pred1D, pred2D; |
---|
273 | size_t ii, jj; |
---|
274 | |
---|
275 | /* Process Row-0, data 0 */ |
---|
276 | |
---|
277 | // compute resiBits |
---|
278 | resiBits = 0; |
---|
279 | if (resiBitsLength != 0) { |
---|
280 | int kMod8 = k % 8; |
---|
281 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
282 | if (rightMovSteps > 0) { |
---|
283 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
284 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
285 | } else if (rightMovSteps < 0) { |
---|
286 | int code1 = getLeftMovingCode(kMod8); |
---|
287 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
288 | int leftMovSteps = -rightMovSteps; |
---|
289 | rightMovSteps = 8 - leftMovSteps; |
---|
290 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
291 | p++; |
---|
292 | resiBits = resiBits |
---|
293 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
294 | } else // rightMovSteps == 0 |
---|
295 | { |
---|
296 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
297 | resiBits = (tdps->residualMidBits[p] & code); |
---|
298 | p++; |
---|
299 | } |
---|
300 | k += resiBitsLength; |
---|
301 | } |
---|
302 | |
---|
303 | // recover the exact data |
---|
304 | memset(curBytes, 0, 4); |
---|
305 | leadingNum = leadNum[l++]; |
---|
306 | memcpy(curBytes, preBytes, leadingNum); |
---|
307 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
308 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
309 | if (resiBitsLength != 0) { |
---|
310 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
311 | curBytes[reqBytesLength] = resiByte; |
---|
312 | } |
---|
313 | |
---|
314 | exactData = bytesToFloat(curBytes); |
---|
315 | (*data)[0] = exactData + medianValue; |
---|
316 | memcpy(preBytes,curBytes,4); |
---|
317 | |
---|
318 | /* Process Row-0, data 1 */ |
---|
319 | type_ = type[1]; |
---|
320 | if (type_ != 0) |
---|
321 | { |
---|
322 | pred1D = (*data)[0]; |
---|
323 | (*data)[1] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
324 | } |
---|
325 | else |
---|
326 | { |
---|
327 | // compute resiBits |
---|
328 | resiBits = 0; |
---|
329 | if (resiBitsLength != 0) { |
---|
330 | int kMod8 = k % 8; |
---|
331 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
332 | if (rightMovSteps > 0) { |
---|
333 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
334 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
335 | } else if (rightMovSteps < 0) { |
---|
336 | int code1 = getLeftMovingCode(kMod8); |
---|
337 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
338 | int leftMovSteps = -rightMovSteps; |
---|
339 | rightMovSteps = 8 - leftMovSteps; |
---|
340 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
341 | p++; |
---|
342 | resiBits = resiBits |
---|
343 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
344 | } else // rightMovSteps == 0 |
---|
345 | { |
---|
346 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
347 | resiBits = (tdps->residualMidBits[p] & code); |
---|
348 | p++; |
---|
349 | } |
---|
350 | k += resiBitsLength; |
---|
351 | } |
---|
352 | |
---|
353 | // recover the exact data |
---|
354 | memset(curBytes, 0, 4); |
---|
355 | leadingNum = leadNum[l++]; |
---|
356 | memcpy(curBytes, preBytes, leadingNum); |
---|
357 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
358 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
359 | if (resiBitsLength != 0) { |
---|
360 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
361 | curBytes[reqBytesLength] = resiByte; |
---|
362 | } |
---|
363 | |
---|
364 | exactData = bytesToFloat(curBytes); |
---|
365 | (*data)[1] = exactData + medianValue; |
---|
366 | memcpy(preBytes,curBytes,4); |
---|
367 | } |
---|
368 | |
---|
369 | /* Process Row-0, data 2 --> data r2-1 */ |
---|
370 | for (jj = 2; jj < r2; jj++) |
---|
371 | { |
---|
372 | type_ = type[jj]; |
---|
373 | if (type_ != 0) |
---|
374 | { |
---|
375 | pred1D = 2*(*data)[jj-1] - (*data)[jj-2]; |
---|
376 | (*data)[jj] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
377 | } |
---|
378 | else |
---|
379 | { |
---|
380 | // compute resiBits |
---|
381 | resiBits = 0; |
---|
382 | if (resiBitsLength != 0) { |
---|
383 | int kMod8 = k % 8; |
---|
384 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
385 | if (rightMovSteps > 0) { |
---|
386 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
387 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
388 | } else if (rightMovSteps < 0) { |
---|
389 | int code1 = getLeftMovingCode(kMod8); |
---|
390 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
391 | int leftMovSteps = -rightMovSteps; |
---|
392 | rightMovSteps = 8 - leftMovSteps; |
---|
393 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
394 | p++; |
---|
395 | resiBits = resiBits |
---|
396 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
397 | } else // rightMovSteps == 0 |
---|
398 | { |
---|
399 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
400 | resiBits = (tdps->residualMidBits[p] & code); |
---|
401 | p++; |
---|
402 | } |
---|
403 | k += resiBitsLength; |
---|
404 | } |
---|
405 | |
---|
406 | // recover the exact data |
---|
407 | memset(curBytes, 0, 4); |
---|
408 | leadingNum = leadNum[l++]; |
---|
409 | memcpy(curBytes, preBytes, leadingNum); |
---|
410 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
411 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
412 | if (resiBitsLength != 0) { |
---|
413 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
414 | curBytes[reqBytesLength] = resiByte; |
---|
415 | } |
---|
416 | |
---|
417 | exactData = bytesToFloat(curBytes); |
---|
418 | (*data)[jj] = exactData + medianValue; |
---|
419 | memcpy(preBytes,curBytes,4); |
---|
420 | } |
---|
421 | } |
---|
422 | |
---|
423 | size_t index; |
---|
424 | /* Process Row-1 --> Row-r1-1 */ |
---|
425 | for (ii = 1; ii < r1; ii++) |
---|
426 | { |
---|
427 | /* Process row-ii data 0 */ |
---|
428 | index = ii*r2; |
---|
429 | |
---|
430 | type_ = type[index]; |
---|
431 | if (type_ != 0) |
---|
432 | { |
---|
433 | pred1D = (*data)[index-r2]; |
---|
434 | (*data)[index] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
435 | } |
---|
436 | else |
---|
437 | { |
---|
438 | // compute resiBits |
---|
439 | resiBits = 0; |
---|
440 | if (resiBitsLength != 0) { |
---|
441 | int kMod8 = k % 8; |
---|
442 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
443 | if (rightMovSteps > 0) { |
---|
444 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
445 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
446 | } else if (rightMovSteps < 0) { |
---|
447 | int code1 = getLeftMovingCode(kMod8); |
---|
448 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
449 | int leftMovSteps = -rightMovSteps; |
---|
450 | rightMovSteps = 8 - leftMovSteps; |
---|
451 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
452 | p++; |
---|
453 | resiBits = resiBits |
---|
454 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
455 | } else // rightMovSteps == 0 |
---|
456 | { |
---|
457 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
458 | resiBits = (tdps->residualMidBits[p] & code); |
---|
459 | p++; |
---|
460 | } |
---|
461 | k += resiBitsLength; |
---|
462 | } |
---|
463 | |
---|
464 | // recover the exact data |
---|
465 | memset(curBytes, 0, 4); |
---|
466 | leadingNum = leadNum[l++]; |
---|
467 | memcpy(curBytes, preBytes, leadingNum); |
---|
468 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
469 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
470 | if (resiBitsLength != 0) { |
---|
471 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
472 | curBytes[reqBytesLength] = resiByte; |
---|
473 | } |
---|
474 | |
---|
475 | exactData = bytesToFloat(curBytes); |
---|
476 | (*data)[index] = exactData + medianValue; |
---|
477 | memcpy(preBytes,curBytes,4); |
---|
478 | } |
---|
479 | |
---|
480 | /* Process row-ii data 1 --> r2-1*/ |
---|
481 | for (jj = 1; jj < r2; jj++) |
---|
482 | { |
---|
483 | index = ii*r2+jj; |
---|
484 | pred2D = (*data)[index-1] + (*data)[index-r2] - (*data)[index-r2-1]; |
---|
485 | |
---|
486 | type_ = type[index]; |
---|
487 | if (type_ != 0) |
---|
488 | { |
---|
489 | (*data)[index] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
490 | } |
---|
491 | else |
---|
492 | { |
---|
493 | // compute resiBits |
---|
494 | resiBits = 0; |
---|
495 | if (resiBitsLength != 0) { |
---|
496 | int kMod8 = k % 8; |
---|
497 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
498 | if (rightMovSteps > 0) { |
---|
499 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
500 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
501 | } else if (rightMovSteps < 0) { |
---|
502 | int code1 = getLeftMovingCode(kMod8); |
---|
503 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
504 | int leftMovSteps = -rightMovSteps; |
---|
505 | rightMovSteps = 8 - leftMovSteps; |
---|
506 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
507 | p++; |
---|
508 | resiBits = resiBits |
---|
509 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
510 | } else // rightMovSteps == 0 |
---|
511 | { |
---|
512 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
513 | resiBits = (tdps->residualMidBits[p] & code); |
---|
514 | p++; |
---|
515 | } |
---|
516 | k += resiBitsLength; |
---|
517 | } |
---|
518 | |
---|
519 | // recover the exact data |
---|
520 | memset(curBytes, 0, 4); |
---|
521 | leadingNum = leadNum[l++]; |
---|
522 | memcpy(curBytes, preBytes, leadingNum); |
---|
523 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
524 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
525 | if (resiBitsLength != 0) { |
---|
526 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
527 | curBytes[reqBytesLength] = resiByte; |
---|
528 | } |
---|
529 | |
---|
530 | exactData = bytesToFloat(curBytes); |
---|
531 | (*data)[index] = exactData + medianValue; |
---|
532 | memcpy(preBytes,curBytes,4); |
---|
533 | } |
---|
534 | } |
---|
535 | } |
---|
536 | |
---|
537 | #ifdef HAVE_TIMECMPR |
---|
538 | if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
539 | memcpy(multisteps->hist_data, (*data), dataSeriesLength*sizeof(float)); |
---|
540 | #endif |
---|
541 | |
---|
542 | free(leadNum); |
---|
543 | free(type); |
---|
544 | return; |
---|
545 | } |
---|
546 | |
---|
547 | void decompressDataSeries_float_3D(float** data, size_t r1, size_t r2, size_t r3, TightDataPointStorageF* tdps) |
---|
548 | { |
---|
549 | updateQuantizationInfo(tdps->intervals); |
---|
550 | size_t j, k = 0, p = 0, l = 0; // k is to track the location of residual_bit |
---|
551 | // in resiMidBits, p is to track the |
---|
552 | // byte_index of resiMidBits, l is for |
---|
553 | // leadNum |
---|
554 | size_t dataSeriesLength = r1*r2*r3; |
---|
555 | size_t r23 = r2*r3; |
---|
556 | unsigned char* leadNum; |
---|
557 | double realPrecision = tdps->realPrecision; |
---|
558 | |
---|
559 | //TODO |
---|
560 | convertByteArray2IntArray_fast_2b(tdps->exactDataNum, tdps->leadNumArray, tdps->leadNumArray_size, &leadNum); |
---|
561 | |
---|
562 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
563 | int* type = (int*)malloc(dataSeriesLength*sizeof(int)); |
---|
564 | |
---|
565 | HuffmanTree* huffmanTree = createHuffmanTree(tdps->stateNum); |
---|
566 | decode_withTree(huffmanTree, tdps->typeArray, dataSeriesLength, type); |
---|
567 | SZ_ReleaseHuffman(huffmanTree); |
---|
568 | |
---|
569 | unsigned char preBytes[4]; |
---|
570 | unsigned char curBytes[4]; |
---|
571 | |
---|
572 | memset(preBytes, 0, 4); |
---|
573 | size_t curByteIndex = 0; |
---|
574 | int reqBytesLength, resiBitsLength, resiBits; |
---|
575 | unsigned char leadingNum; |
---|
576 | float medianValue, exactData; |
---|
577 | int type_; |
---|
578 | |
---|
579 | reqBytesLength = tdps->reqLength/8; |
---|
580 | resiBitsLength = tdps->reqLength%8; |
---|
581 | medianValue = tdps->medianValue; |
---|
582 | |
---|
583 | float pred1D, pred2D, pred3D; |
---|
584 | size_t ii, jj, kk; |
---|
585 | |
---|
586 | /////////////////////////// Process layer-0 /////////////////////////// |
---|
587 | /* Process Row-0 data 0*/ |
---|
588 | // compute resiBits |
---|
589 | resiBits = 0; |
---|
590 | if (resiBitsLength != 0) { |
---|
591 | int kMod8 = k % 8; |
---|
592 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
593 | if (rightMovSteps > 0) { |
---|
594 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
595 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
596 | } else if (rightMovSteps < 0) { |
---|
597 | int code1 = getLeftMovingCode(kMod8); |
---|
598 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
599 | int leftMovSteps = -rightMovSteps; |
---|
600 | rightMovSteps = 8 - leftMovSteps; |
---|
601 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
602 | p++; |
---|
603 | resiBits = resiBits |
---|
604 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
605 | } else // rightMovSteps == 0 |
---|
606 | { |
---|
607 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
608 | resiBits = (tdps->residualMidBits[p] & code); |
---|
609 | p++; |
---|
610 | } |
---|
611 | k += resiBitsLength; |
---|
612 | } |
---|
613 | |
---|
614 | // recover the exact data |
---|
615 | memset(curBytes, 0, 4); |
---|
616 | leadingNum = leadNum[l++]; |
---|
617 | memcpy(curBytes, preBytes, leadingNum); |
---|
618 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
619 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
620 | if (resiBitsLength != 0) { |
---|
621 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
622 | curBytes[reqBytesLength] = resiByte; |
---|
623 | } |
---|
624 | exactData = bytesToFloat(curBytes); |
---|
625 | (*data)[0] = exactData + medianValue; |
---|
626 | memcpy(preBytes,curBytes,4); |
---|
627 | |
---|
628 | /* Process Row-0, data 1 */ |
---|
629 | pred1D = (*data)[0]; |
---|
630 | |
---|
631 | type_ = type[1]; |
---|
632 | if (type_ != 0) |
---|
633 | { |
---|
634 | (*data)[1] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
635 | } |
---|
636 | else |
---|
637 | { |
---|
638 | // compute resiBits |
---|
639 | resiBits = 0; |
---|
640 | if (resiBitsLength != 0) { |
---|
641 | int kMod8 = k % 8; |
---|
642 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
643 | if (rightMovSteps > 0) { |
---|
644 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
645 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
646 | } else if (rightMovSteps < 0) { |
---|
647 | int code1 = getLeftMovingCode(kMod8); |
---|
648 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
649 | int leftMovSteps = -rightMovSteps; |
---|
650 | rightMovSteps = 8 - leftMovSteps; |
---|
651 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
652 | p++; |
---|
653 | resiBits = resiBits |
---|
654 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
655 | } else // rightMovSteps == 0 |
---|
656 | { |
---|
657 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
658 | resiBits = (tdps->residualMidBits[p] & code); |
---|
659 | p++; |
---|
660 | } |
---|
661 | k += resiBitsLength; |
---|
662 | } |
---|
663 | |
---|
664 | // recover the exact data |
---|
665 | memset(curBytes, 0, 4); |
---|
666 | leadingNum = leadNum[l++]; |
---|
667 | memcpy(curBytes, preBytes, leadingNum); |
---|
668 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
669 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
670 | if (resiBitsLength != 0) { |
---|
671 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
672 | curBytes[reqBytesLength] = resiByte; |
---|
673 | } |
---|
674 | |
---|
675 | exactData = bytesToFloat(curBytes); |
---|
676 | (*data)[1] = exactData + medianValue; |
---|
677 | memcpy(preBytes,curBytes,4); |
---|
678 | } |
---|
679 | /* Process Row-0, data 2 --> data r3-1 */ |
---|
680 | for (jj = 2; jj < r3; jj++) |
---|
681 | { |
---|
682 | pred1D = 2*(*data)[jj-1] - (*data)[jj-2]; |
---|
683 | |
---|
684 | type_ = type[jj]; |
---|
685 | if (type_ != 0) |
---|
686 | { |
---|
687 | (*data)[jj] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
688 | } |
---|
689 | else |
---|
690 | { |
---|
691 | // compute resiBits |
---|
692 | resiBits = 0; |
---|
693 | if (resiBitsLength != 0) { |
---|
694 | int kMod8 = k % 8; |
---|
695 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
696 | if (rightMovSteps > 0) { |
---|
697 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
698 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
699 | } else if (rightMovSteps < 0) { |
---|
700 | int code1 = getLeftMovingCode(kMod8); |
---|
701 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
702 | int leftMovSteps = -rightMovSteps; |
---|
703 | rightMovSteps = 8 - leftMovSteps; |
---|
704 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
705 | p++; |
---|
706 | resiBits = resiBits |
---|
707 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
708 | } else // rightMovSteps == 0 |
---|
709 | { |
---|
710 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
711 | resiBits = (tdps->residualMidBits[p] & code); |
---|
712 | p++; |
---|
713 | } |
---|
714 | k += resiBitsLength; |
---|
715 | } |
---|
716 | |
---|
717 | // recover the exact data |
---|
718 | memset(curBytes, 0, 4); |
---|
719 | leadingNum = leadNum[l++]; |
---|
720 | memcpy(curBytes, preBytes, leadingNum); |
---|
721 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
722 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
723 | if (resiBitsLength != 0) { |
---|
724 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
725 | curBytes[reqBytesLength] = resiByte; |
---|
726 | } |
---|
727 | |
---|
728 | exactData = bytesToFloat(curBytes); |
---|
729 | (*data)[jj] = exactData + medianValue; |
---|
730 | memcpy(preBytes,curBytes,4); |
---|
731 | } |
---|
732 | } |
---|
733 | |
---|
734 | size_t index; |
---|
735 | /* Process Row-1 --> Row-r2-1 */ |
---|
736 | for (ii = 1; ii < r2; ii++) |
---|
737 | { |
---|
738 | /* Process row-ii data 0 */ |
---|
739 | index = ii*r3; |
---|
740 | pred1D = (*data)[index-r3]; |
---|
741 | |
---|
742 | type_ = type[index]; |
---|
743 | if (type_ != 0) |
---|
744 | { |
---|
745 | (*data)[index] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
746 | } |
---|
747 | else |
---|
748 | { |
---|
749 | // compute resiBits |
---|
750 | resiBits = 0; |
---|
751 | if (resiBitsLength != 0) { |
---|
752 | int kMod8 = k % 8; |
---|
753 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
754 | if (rightMovSteps > 0) { |
---|
755 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
756 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
757 | } else if (rightMovSteps < 0) { |
---|
758 | int code1 = getLeftMovingCode(kMod8); |
---|
759 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
760 | int leftMovSteps = -rightMovSteps; |
---|
761 | rightMovSteps = 8 - leftMovSteps; |
---|
762 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
763 | p++; |
---|
764 | resiBits = resiBits |
---|
765 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
766 | } else // rightMovSteps == 0 |
---|
767 | { |
---|
768 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
769 | resiBits = (tdps->residualMidBits[p] & code); |
---|
770 | p++; |
---|
771 | } |
---|
772 | k += resiBitsLength; |
---|
773 | } |
---|
774 | |
---|
775 | // recover the exact data |
---|
776 | memset(curBytes, 0, 4); |
---|
777 | leadingNum = leadNum[l++]; |
---|
778 | memcpy(curBytes, preBytes, leadingNum); |
---|
779 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
780 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
781 | if (resiBitsLength != 0) { |
---|
782 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
783 | curBytes[reqBytesLength] = resiByte; |
---|
784 | } |
---|
785 | |
---|
786 | exactData = bytesToFloat(curBytes); |
---|
787 | (*data)[index] = exactData + medianValue; |
---|
788 | memcpy(preBytes,curBytes,4); |
---|
789 | } |
---|
790 | |
---|
791 | /* Process row-ii data 1 --> r3-1*/ |
---|
792 | for (jj = 1; jj < r3; jj++) |
---|
793 | { |
---|
794 | index = ii*r3+jj; |
---|
795 | pred2D = (*data)[index-1] + (*data)[index-r3] - (*data)[index-r3-1]; |
---|
796 | |
---|
797 | type_ = type[index]; |
---|
798 | if (type_ != 0) |
---|
799 | { |
---|
800 | (*data)[index] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
801 | } |
---|
802 | else |
---|
803 | { |
---|
804 | // compute resiBits |
---|
805 | resiBits = 0; |
---|
806 | if (resiBitsLength != 0) { |
---|
807 | int kMod8 = k % 8; |
---|
808 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
809 | if (rightMovSteps > 0) { |
---|
810 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
811 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
812 | } else if (rightMovSteps < 0) { |
---|
813 | int code1 = getLeftMovingCode(kMod8); |
---|
814 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
815 | int leftMovSteps = -rightMovSteps; |
---|
816 | rightMovSteps = 8 - leftMovSteps; |
---|
817 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
818 | p++; |
---|
819 | resiBits = resiBits |
---|
820 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
821 | } else // rightMovSteps == 0 |
---|
822 | { |
---|
823 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
824 | resiBits = (tdps->residualMidBits[p] & code); |
---|
825 | p++; |
---|
826 | } |
---|
827 | k += resiBitsLength; |
---|
828 | } |
---|
829 | |
---|
830 | // recover the exact data |
---|
831 | memset(curBytes, 0, 4); |
---|
832 | leadingNum = leadNum[l++]; |
---|
833 | memcpy(curBytes, preBytes, leadingNum); |
---|
834 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
835 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
836 | if (resiBitsLength != 0) { |
---|
837 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
838 | curBytes[reqBytesLength] = resiByte; |
---|
839 | } |
---|
840 | |
---|
841 | exactData = bytesToFloat(curBytes); |
---|
842 | (*data)[index] = exactData + medianValue; |
---|
843 | memcpy(preBytes,curBytes,4); |
---|
844 | } |
---|
845 | } |
---|
846 | } |
---|
847 | |
---|
848 | /////////////////////////// Process layer-1 --> layer-r1-1 /////////////////////////// |
---|
849 | |
---|
850 | for (kk = 1; kk < r1; kk++) |
---|
851 | { |
---|
852 | /* Process Row-0 data 0*/ |
---|
853 | index = kk*r23; |
---|
854 | pred1D = (*data)[index-r23]; |
---|
855 | |
---|
856 | type_ = type[index]; |
---|
857 | if (type_ != 0) |
---|
858 | { |
---|
859 | (*data)[index] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
860 | } |
---|
861 | else |
---|
862 | { |
---|
863 | // compute resiBits |
---|
864 | resiBits = 0; |
---|
865 | if (resiBitsLength != 0) { |
---|
866 | int kMod8 = k % 8; |
---|
867 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
868 | if (rightMovSteps > 0) { |
---|
869 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
870 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
871 | } else if (rightMovSteps < 0) { |
---|
872 | int code1 = getLeftMovingCode(kMod8); |
---|
873 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
874 | int leftMovSteps = -rightMovSteps; |
---|
875 | rightMovSteps = 8 - leftMovSteps; |
---|
876 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
877 | p++; |
---|
878 | resiBits = resiBits |
---|
879 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
880 | } else // rightMovSteps == 0 |
---|
881 | { |
---|
882 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
883 | resiBits = (tdps->residualMidBits[p] & code); |
---|
884 | p++; |
---|
885 | } |
---|
886 | k += resiBitsLength; |
---|
887 | } |
---|
888 | |
---|
889 | // recover the exact data |
---|
890 | memset(curBytes, 0, 4); |
---|
891 | leadingNum = leadNum[l++]; |
---|
892 | memcpy(curBytes, preBytes, leadingNum); |
---|
893 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
894 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
895 | if (resiBitsLength != 0) { |
---|
896 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
897 | curBytes[reqBytesLength] = resiByte; |
---|
898 | } |
---|
899 | |
---|
900 | exactData = bytesToFloat(curBytes); |
---|
901 | (*data)[index] = exactData + medianValue; |
---|
902 | memcpy(preBytes,curBytes,4); |
---|
903 | } |
---|
904 | |
---|
905 | /* Process Row-0 data 1 --> data r3-1 */ |
---|
906 | for (jj = 1; jj < r3; jj++) |
---|
907 | { |
---|
908 | index = kk*r23+jj; |
---|
909 | pred2D = (*data)[index-1] + (*data)[index-r23] - (*data)[index-r23-1]; |
---|
910 | |
---|
911 | type_ = type[index]; |
---|
912 | if (type_ != 0) |
---|
913 | { |
---|
914 | (*data)[index] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
915 | } |
---|
916 | else |
---|
917 | { |
---|
918 | // compute resiBits |
---|
919 | resiBits = 0; |
---|
920 | if (resiBitsLength != 0) { |
---|
921 | int kMod8 = k % 8; |
---|
922 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
923 | if (rightMovSteps > 0) { |
---|
924 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
925 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
926 | } else if (rightMovSteps < 0) { |
---|
927 | int code1 = getLeftMovingCode(kMod8); |
---|
928 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
929 | int leftMovSteps = -rightMovSteps; |
---|
930 | rightMovSteps = 8 - leftMovSteps; |
---|
931 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
932 | p++; |
---|
933 | resiBits = resiBits |
---|
934 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
935 | } else // rightMovSteps == 0 |
---|
936 | { |
---|
937 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
938 | resiBits = (tdps->residualMidBits[p] & code); |
---|
939 | p++; |
---|
940 | } |
---|
941 | k += resiBitsLength; |
---|
942 | } |
---|
943 | |
---|
944 | // recover the exact data |
---|
945 | memset(curBytes, 0, 4); |
---|
946 | leadingNum = leadNum[l++]; |
---|
947 | memcpy(curBytes, preBytes, leadingNum); |
---|
948 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
949 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
950 | if (resiBitsLength != 0) { |
---|
951 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
952 | curBytes[reqBytesLength] = resiByte; |
---|
953 | } |
---|
954 | |
---|
955 | exactData = bytesToFloat(curBytes); |
---|
956 | (*data)[index] = exactData + medianValue; |
---|
957 | memcpy(preBytes,curBytes,4); |
---|
958 | } |
---|
959 | } |
---|
960 | |
---|
961 | /* Process Row-1 --> Row-r2-1 */ |
---|
962 | for (ii = 1; ii < r2; ii++) |
---|
963 | { |
---|
964 | /* Process Row-i data 0 */ |
---|
965 | index = kk*r23 + ii*r3; |
---|
966 | pred2D = (*data)[index-r3] + (*data)[index-r23] - (*data)[index-r23-r3]; |
---|
967 | |
---|
968 | type_ = type[index]; |
---|
969 | if (type_ != 0) |
---|
970 | { |
---|
971 | (*data)[index] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
972 | } |
---|
973 | else |
---|
974 | { |
---|
975 | // compute resiBits |
---|
976 | resiBits = 0; |
---|
977 | if (resiBitsLength != 0) { |
---|
978 | int kMod8 = k % 8; |
---|
979 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
980 | if (rightMovSteps > 0) { |
---|
981 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
982 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
983 | } else if (rightMovSteps < 0) { |
---|
984 | int code1 = getLeftMovingCode(kMod8); |
---|
985 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
986 | int leftMovSteps = -rightMovSteps; |
---|
987 | rightMovSteps = 8 - leftMovSteps; |
---|
988 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
989 | p++; |
---|
990 | resiBits = resiBits |
---|
991 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
992 | } else // rightMovSteps == 0 |
---|
993 | { |
---|
994 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
995 | resiBits = (tdps->residualMidBits[p] & code); |
---|
996 | p++; |
---|
997 | } |
---|
998 | k += resiBitsLength; |
---|
999 | } |
---|
1000 | |
---|
1001 | // recover the exact data |
---|
1002 | memset(curBytes, 0, 4); |
---|
1003 | leadingNum = leadNum[l++]; |
---|
1004 | memcpy(curBytes, preBytes, leadingNum); |
---|
1005 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
1006 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
1007 | if (resiBitsLength != 0) { |
---|
1008 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
1009 | curBytes[reqBytesLength] = resiByte; |
---|
1010 | } |
---|
1011 | |
---|
1012 | exactData = bytesToFloat(curBytes); |
---|
1013 | (*data)[index] = exactData + medianValue; |
---|
1014 | memcpy(preBytes,curBytes,4); |
---|
1015 | } |
---|
1016 | |
---|
1017 | /* Process Row-i data 1 --> data r3-1 */ |
---|
1018 | for (jj = 1; jj < r3; jj++) |
---|
1019 | { |
---|
1020 | index = kk*r23 + ii*r3 + jj; |
---|
1021 | pred3D = (*data)[index-1] + (*data)[index-r3] + (*data)[index-r23] |
---|
1022 | - (*data)[index-r3-1] - (*data)[index-r23-r3] - (*data)[index-r23-1] + (*data)[index-r23-r3-1]; |
---|
1023 | |
---|
1024 | type_ = type[index]; |
---|
1025 | if (type_ != 0) |
---|
1026 | { |
---|
1027 | (*data)[index] = pred3D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
1028 | } |
---|
1029 | else |
---|
1030 | { |
---|
1031 | // compute resiBits |
---|
1032 | resiBits = 0; |
---|
1033 | if (resiBitsLength != 0) { |
---|
1034 | int kMod8 = k % 8; |
---|
1035 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
1036 | if (rightMovSteps > 0) { |
---|
1037 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1038 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
1039 | } else if (rightMovSteps < 0) { |
---|
1040 | int code1 = getLeftMovingCode(kMod8); |
---|
1041 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
1042 | int leftMovSteps = -rightMovSteps; |
---|
1043 | rightMovSteps = 8 - leftMovSteps; |
---|
1044 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
1045 | p++; |
---|
1046 | resiBits = resiBits |
---|
1047 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
1048 | } else // rightMovSteps == 0 |
---|
1049 | { |
---|
1050 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1051 | resiBits = (tdps->residualMidBits[p] & code); |
---|
1052 | p++; |
---|
1053 | } |
---|
1054 | k += resiBitsLength; |
---|
1055 | } |
---|
1056 | |
---|
1057 | // recover the exact data |
---|
1058 | memset(curBytes, 0, 4); |
---|
1059 | leadingNum = leadNum[l++]; |
---|
1060 | memcpy(curBytes, preBytes, leadingNum); |
---|
1061 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
1062 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
1063 | if (resiBitsLength != 0) { |
---|
1064 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
1065 | curBytes[reqBytesLength] = resiByte; |
---|
1066 | } |
---|
1067 | |
---|
1068 | exactData = bytesToFloat(curBytes); |
---|
1069 | (*data)[index] = exactData + medianValue; |
---|
1070 | memcpy(preBytes,curBytes,4); |
---|
1071 | } |
---|
1072 | } |
---|
1073 | } |
---|
1074 | } |
---|
1075 | |
---|
1076 | #ifdef HAVE_TIMECMPR |
---|
1077 | if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
1078 | memcpy(multisteps->hist_data, (*data), dataSeriesLength*sizeof(float)); |
---|
1079 | #endif |
---|
1080 | |
---|
1081 | free(leadNum); |
---|
1082 | free(type); |
---|
1083 | return; |
---|
1084 | } |
---|
1085 | |
---|
1086 | |
---|
1087 | void decompressDataSeries_float_4D(float** data, size_t r1, size_t r2, size_t r3, size_t r4, TightDataPointStorageF* tdps) |
---|
1088 | { |
---|
1089 | updateQuantizationInfo(tdps->intervals); |
---|
1090 | size_t j, k = 0, p = 0, l = 0; // k is to track the location of residual_bit |
---|
1091 | // in resiMidBits, p is to track the |
---|
1092 | // byte_index of resiMidBits, l is for |
---|
1093 | // leadNum |
---|
1094 | size_t dataSeriesLength = r1*r2*r3*r4; |
---|
1095 | size_t r234 = r2*r3*r4; |
---|
1096 | size_t r34 = r3*r4; |
---|
1097 | // printf ("%d %d %d %d\n", r1, r2, r3, r4); |
---|
1098 | unsigned char* leadNum; |
---|
1099 | double realPrecision = tdps->realPrecision; |
---|
1100 | |
---|
1101 | convertByteArray2IntArray_fast_2b(tdps->exactDataNum, tdps->leadNumArray, tdps->leadNumArray_size, &leadNum); |
---|
1102 | |
---|
1103 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
1104 | int* type = (int*)malloc(dataSeriesLength*sizeof(int)); |
---|
1105 | |
---|
1106 | HuffmanTree* huffmanTree = createHuffmanTree(tdps->stateNum); |
---|
1107 | decode_withTree(huffmanTree, tdps->typeArray, dataSeriesLength, type); |
---|
1108 | SZ_ReleaseHuffman(huffmanTree); |
---|
1109 | |
---|
1110 | unsigned char preBytes[4]; |
---|
1111 | unsigned char curBytes[4]; |
---|
1112 | |
---|
1113 | memset(preBytes, 0, 4); |
---|
1114 | size_t curByteIndex = 0; |
---|
1115 | int reqBytesLength, resiBitsLength, resiBits; |
---|
1116 | unsigned char leadingNum; |
---|
1117 | float medianValue, exactData; |
---|
1118 | int type_; |
---|
1119 | |
---|
1120 | reqBytesLength = tdps->reqLength/8; |
---|
1121 | resiBitsLength = tdps->reqLength%8; |
---|
1122 | medianValue = tdps->medianValue; |
---|
1123 | |
---|
1124 | float pred1D, pred2D, pred3D; |
---|
1125 | size_t ii, jj, kk, ll; |
---|
1126 | size_t index; |
---|
1127 | |
---|
1128 | for (ll = 0; ll < r1; ll++) |
---|
1129 | { |
---|
1130 | |
---|
1131 | /////////////////////////// Process layer-0 /////////////////////////// |
---|
1132 | /* Process Row-0 data 0*/ |
---|
1133 | index = ll*r234; |
---|
1134 | |
---|
1135 | // compute resiBits |
---|
1136 | resiBits = 0; |
---|
1137 | if (resiBitsLength != 0) { |
---|
1138 | int kMod8 = k % 8; |
---|
1139 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
1140 | if (rightMovSteps > 0) { |
---|
1141 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1142 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
1143 | } else if (rightMovSteps < 0) { |
---|
1144 | int code1 = getLeftMovingCode(kMod8); |
---|
1145 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
1146 | int leftMovSteps = -rightMovSteps; |
---|
1147 | rightMovSteps = 8 - leftMovSteps; |
---|
1148 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
1149 | p++; |
---|
1150 | resiBits = resiBits |
---|
1151 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
1152 | } else // rightMovSteps == 0 |
---|
1153 | { |
---|
1154 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1155 | resiBits = (tdps->residualMidBits[p] & code); |
---|
1156 | p++; |
---|
1157 | } |
---|
1158 | k += resiBitsLength; |
---|
1159 | } |
---|
1160 | |
---|
1161 | // recover the exact data |
---|
1162 | memset(curBytes, 0, 4); |
---|
1163 | leadingNum = leadNum[l++]; |
---|
1164 | memcpy(curBytes, preBytes, leadingNum); |
---|
1165 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
1166 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
1167 | if (resiBitsLength != 0) { |
---|
1168 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
1169 | curBytes[reqBytesLength] = resiByte; |
---|
1170 | } |
---|
1171 | exactData = bytesToFloat(curBytes); |
---|
1172 | (*data)[index] = exactData + medianValue; |
---|
1173 | memcpy(preBytes,curBytes,4); |
---|
1174 | |
---|
1175 | /* Process Row-0, data 1 */ |
---|
1176 | index = ll*r234+1; |
---|
1177 | |
---|
1178 | pred1D = (*data)[index-1]; |
---|
1179 | |
---|
1180 | type_ = type[index]; |
---|
1181 | if (type_ != 0) |
---|
1182 | { |
---|
1183 | (*data)[index] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
1184 | } |
---|
1185 | else |
---|
1186 | { |
---|
1187 | // compute resiBits |
---|
1188 | resiBits = 0; |
---|
1189 | if (resiBitsLength != 0) { |
---|
1190 | int kMod8 = k % 8; |
---|
1191 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
1192 | if (rightMovSteps > 0) { |
---|
1193 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1194 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
1195 | } else if (rightMovSteps < 0) { |
---|
1196 | int code1 = getLeftMovingCode(kMod8); |
---|
1197 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
1198 | int leftMovSteps = -rightMovSteps; |
---|
1199 | rightMovSteps = 8 - leftMovSteps; |
---|
1200 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
1201 | p++; |
---|
1202 | resiBits = resiBits |
---|
1203 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
1204 | } else // rightMovSteps == 0 |
---|
1205 | { |
---|
1206 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1207 | resiBits = (tdps->residualMidBits[p] & code); |
---|
1208 | p++; |
---|
1209 | } |
---|
1210 | k += resiBitsLength; |
---|
1211 | } |
---|
1212 | |
---|
1213 | // recover the exact data |
---|
1214 | memset(curBytes, 0, 4); |
---|
1215 | leadingNum = leadNum[l++]; |
---|
1216 | memcpy(curBytes, preBytes, leadingNum); |
---|
1217 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
1218 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
1219 | if (resiBitsLength != 0) { |
---|
1220 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
1221 | curBytes[reqBytesLength] = resiByte; |
---|
1222 | } |
---|
1223 | |
---|
1224 | exactData = bytesToFloat(curBytes); |
---|
1225 | (*data)[index] = exactData + medianValue; |
---|
1226 | memcpy(preBytes,curBytes,4); |
---|
1227 | } |
---|
1228 | |
---|
1229 | /* Process Row-0, data 2 --> data r4-1 */ |
---|
1230 | for (jj = 2; jj < r4; jj++) |
---|
1231 | { |
---|
1232 | index = ll*r234+jj; |
---|
1233 | |
---|
1234 | pred1D = 2*(*data)[index-1] - (*data)[index-2]; |
---|
1235 | |
---|
1236 | type_ = type[index]; |
---|
1237 | if (type_ != 0) |
---|
1238 | { |
---|
1239 | (*data)[index] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
1240 | } |
---|
1241 | else |
---|
1242 | { |
---|
1243 | // compute resiBits |
---|
1244 | resiBits = 0; |
---|
1245 | if (resiBitsLength != 0) { |
---|
1246 | int kMod8 = k % 8; |
---|
1247 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
1248 | if (rightMovSteps > 0) { |
---|
1249 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1250 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
1251 | } else if (rightMovSteps < 0) { |
---|
1252 | int code1 = getLeftMovingCode(kMod8); |
---|
1253 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
1254 | int leftMovSteps = -rightMovSteps; |
---|
1255 | rightMovSteps = 8 - leftMovSteps; |
---|
1256 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
1257 | p++; |
---|
1258 | resiBits = resiBits |
---|
1259 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
1260 | } else // rightMovSteps == 0 |
---|
1261 | { |
---|
1262 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1263 | resiBits = (tdps->residualMidBits[p] & code); |
---|
1264 | p++; |
---|
1265 | } |
---|
1266 | k += resiBitsLength; |
---|
1267 | } |
---|
1268 | |
---|
1269 | // recover the exact data |
---|
1270 | memset(curBytes, 0, 4); |
---|
1271 | leadingNum = leadNum[l++]; |
---|
1272 | memcpy(curBytes, preBytes, leadingNum); |
---|
1273 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
1274 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
1275 | if (resiBitsLength != 0) { |
---|
1276 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
1277 | curBytes[reqBytesLength] = resiByte; |
---|
1278 | } |
---|
1279 | |
---|
1280 | exactData = bytesToFloat(curBytes); |
---|
1281 | (*data)[index] = exactData + medianValue; |
---|
1282 | memcpy(preBytes,curBytes,4); |
---|
1283 | } |
---|
1284 | } |
---|
1285 | |
---|
1286 | /* Process Row-1 --> Row-r3-1 */ |
---|
1287 | for (ii = 1; ii < r3; ii++) |
---|
1288 | { |
---|
1289 | /* Process row-ii data 0 */ |
---|
1290 | index = ll*r234+ii*r4; |
---|
1291 | |
---|
1292 | pred1D = (*data)[index-r4]; |
---|
1293 | |
---|
1294 | type_ = type[index]; |
---|
1295 | if (type_ != 0) |
---|
1296 | { |
---|
1297 | (*data)[index] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
1298 | } |
---|
1299 | else |
---|
1300 | { |
---|
1301 | // compute resiBits |
---|
1302 | resiBits = 0; |
---|
1303 | if (resiBitsLength != 0) { |
---|
1304 | int kMod8 = k % 8; |
---|
1305 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
1306 | if (rightMovSteps > 0) { |
---|
1307 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1308 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
1309 | } else if (rightMovSteps < 0) { |
---|
1310 | int code1 = getLeftMovingCode(kMod8); |
---|
1311 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
1312 | int leftMovSteps = -rightMovSteps; |
---|
1313 | rightMovSteps = 8 - leftMovSteps; |
---|
1314 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
1315 | p++; |
---|
1316 | resiBits = resiBits |
---|
1317 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
1318 | } else // rightMovSteps == 0 |
---|
1319 | { |
---|
1320 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1321 | resiBits = (tdps->residualMidBits[p] & code); |
---|
1322 | p++; |
---|
1323 | } |
---|
1324 | k += resiBitsLength; |
---|
1325 | } |
---|
1326 | |
---|
1327 | // recover the exact data |
---|
1328 | memset(curBytes, 0, 4); |
---|
1329 | leadingNum = leadNum[l++]; |
---|
1330 | memcpy(curBytes, preBytes, leadingNum); |
---|
1331 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
1332 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
1333 | if (resiBitsLength != 0) { |
---|
1334 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
1335 | curBytes[reqBytesLength] = resiByte; |
---|
1336 | } |
---|
1337 | |
---|
1338 | exactData = bytesToFloat(curBytes); |
---|
1339 | (*data)[index] = exactData + medianValue; |
---|
1340 | memcpy(preBytes,curBytes,4); |
---|
1341 | } |
---|
1342 | |
---|
1343 | /* Process row-ii data 1 --> r4-1*/ |
---|
1344 | for (jj = 1; jj < r4; jj++) |
---|
1345 | { |
---|
1346 | index = ll*r234+ii*r4+jj; |
---|
1347 | |
---|
1348 | pred2D = (*data)[index-1] + (*data)[index-r4] - (*data)[index-r4-1]; |
---|
1349 | |
---|
1350 | type_ = type[index]; |
---|
1351 | if (type_ != 0) |
---|
1352 | { |
---|
1353 | (*data)[index] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
1354 | } |
---|
1355 | else |
---|
1356 | { |
---|
1357 | // compute resiBits |
---|
1358 | resiBits = 0; |
---|
1359 | if (resiBitsLength != 0) { |
---|
1360 | int kMod8 = k % 8; |
---|
1361 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
1362 | if (rightMovSteps > 0) { |
---|
1363 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1364 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
1365 | } else if (rightMovSteps < 0) { |
---|
1366 | int code1 = getLeftMovingCode(kMod8); |
---|
1367 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
1368 | int leftMovSteps = -rightMovSteps; |
---|
1369 | rightMovSteps = 8 - leftMovSteps; |
---|
1370 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
1371 | p++; |
---|
1372 | resiBits = resiBits |
---|
1373 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
1374 | } else // rightMovSteps == 0 |
---|
1375 | { |
---|
1376 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1377 | resiBits = (tdps->residualMidBits[p] & code); |
---|
1378 | p++; |
---|
1379 | } |
---|
1380 | k += resiBitsLength; |
---|
1381 | } |
---|
1382 | |
---|
1383 | // recover the exact data |
---|
1384 | memset(curBytes, 0, 4); |
---|
1385 | leadingNum = leadNum[l++]; |
---|
1386 | memcpy(curBytes, preBytes, leadingNum); |
---|
1387 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
1388 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
1389 | if (resiBitsLength != 0) { |
---|
1390 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
1391 | curBytes[reqBytesLength] = resiByte; |
---|
1392 | } |
---|
1393 | |
---|
1394 | exactData = bytesToFloat(curBytes); |
---|
1395 | (*data)[index] = exactData + medianValue; |
---|
1396 | memcpy(preBytes,curBytes,4); |
---|
1397 | } |
---|
1398 | } |
---|
1399 | } |
---|
1400 | |
---|
1401 | /////////////////////////// Process layer-1 --> layer-r2-1 /////////////////////////// |
---|
1402 | |
---|
1403 | for (kk = 1; kk < r2; kk++) |
---|
1404 | { |
---|
1405 | /* Process Row-0 data 0*/ |
---|
1406 | index = ll*r234+kk*r34; |
---|
1407 | |
---|
1408 | pred1D = (*data)[index-r34]; |
---|
1409 | |
---|
1410 | type_ = type[index]; |
---|
1411 | if (type_ != 0) |
---|
1412 | { |
---|
1413 | (*data)[index] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
1414 | } |
---|
1415 | else |
---|
1416 | { |
---|
1417 | // compute resiBits |
---|
1418 | resiBits = 0; |
---|
1419 | if (resiBitsLength != 0) { |
---|
1420 | int kMod8 = k % 8; |
---|
1421 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
1422 | if (rightMovSteps > 0) { |
---|
1423 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1424 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
1425 | } else if (rightMovSteps < 0) { |
---|
1426 | int code1 = getLeftMovingCode(kMod8); |
---|
1427 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
1428 | int leftMovSteps = -rightMovSteps; |
---|
1429 | rightMovSteps = 8 - leftMovSteps; |
---|
1430 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
1431 | p++; |
---|
1432 | resiBits = resiBits |
---|
1433 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
1434 | } else // rightMovSteps == 0 |
---|
1435 | { |
---|
1436 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1437 | resiBits = (tdps->residualMidBits[p] & code); |
---|
1438 | p++; |
---|
1439 | } |
---|
1440 | k += resiBitsLength; |
---|
1441 | } |
---|
1442 | |
---|
1443 | // recover the exact data |
---|
1444 | memset(curBytes, 0, 4); |
---|
1445 | leadingNum = leadNum[l++]; |
---|
1446 | memcpy(curBytes, preBytes, leadingNum); |
---|
1447 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
1448 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
1449 | if (resiBitsLength != 0) { |
---|
1450 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
1451 | curBytes[reqBytesLength] = resiByte; |
---|
1452 | } |
---|
1453 | |
---|
1454 | exactData = bytesToFloat(curBytes); |
---|
1455 | (*data)[index] = exactData + medianValue; |
---|
1456 | memcpy(preBytes,curBytes,4); |
---|
1457 | } |
---|
1458 | |
---|
1459 | /* Process Row-0 data 1 --> data r4-1 */ |
---|
1460 | for (jj = 1; jj < r4; jj++) |
---|
1461 | { |
---|
1462 | index = ll*r234+kk*r34+jj; |
---|
1463 | |
---|
1464 | pred2D = (*data)[index-1] + (*data)[index-r34] - (*data)[index-r34-1]; |
---|
1465 | |
---|
1466 | type_ = type[index]; |
---|
1467 | if (type_ != 0) |
---|
1468 | { |
---|
1469 | (*data)[index] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
1470 | } |
---|
1471 | else |
---|
1472 | { |
---|
1473 | // compute resiBits |
---|
1474 | resiBits = 0; |
---|
1475 | if (resiBitsLength != 0) { |
---|
1476 | int kMod8 = k % 8; |
---|
1477 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
1478 | if (rightMovSteps > 0) { |
---|
1479 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1480 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
1481 | } else if (rightMovSteps < 0) { |
---|
1482 | int code1 = getLeftMovingCode(kMod8); |
---|
1483 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
1484 | int leftMovSteps = -rightMovSteps; |
---|
1485 | rightMovSteps = 8 - leftMovSteps; |
---|
1486 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
1487 | p++; |
---|
1488 | resiBits = resiBits |
---|
1489 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
1490 | } else // rightMovSteps == 0 |
---|
1491 | { |
---|
1492 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1493 | resiBits = (tdps->residualMidBits[p] & code); |
---|
1494 | p++; |
---|
1495 | } |
---|
1496 | k += resiBitsLength; |
---|
1497 | } |
---|
1498 | |
---|
1499 | // recover the exact data |
---|
1500 | memset(curBytes, 0, 4); |
---|
1501 | leadingNum = leadNum[l++]; |
---|
1502 | memcpy(curBytes, preBytes, leadingNum); |
---|
1503 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
1504 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
1505 | if (resiBitsLength != 0) { |
---|
1506 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
1507 | curBytes[reqBytesLength] = resiByte; |
---|
1508 | } |
---|
1509 | |
---|
1510 | exactData = bytesToFloat(curBytes); |
---|
1511 | (*data)[index] = exactData + medianValue; |
---|
1512 | memcpy(preBytes,curBytes,4); |
---|
1513 | } |
---|
1514 | } |
---|
1515 | |
---|
1516 | /* Process Row-1 --> Row-r3-1 */ |
---|
1517 | for (ii = 1; ii < r3; ii++) |
---|
1518 | { |
---|
1519 | /* Process Row-i data 0 */ |
---|
1520 | index = ll*r234+kk*r34+ii*r4; |
---|
1521 | |
---|
1522 | pred2D = (*data)[index-r4] + (*data)[index-r34] - (*data)[index-r34-r4]; |
---|
1523 | |
---|
1524 | type_ = type[index]; |
---|
1525 | if (type_ != 0) |
---|
1526 | { |
---|
1527 | (*data)[index] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
1528 | } |
---|
1529 | else |
---|
1530 | { |
---|
1531 | // compute resiBits |
---|
1532 | resiBits = 0; |
---|
1533 | if (resiBitsLength != 0) { |
---|
1534 | int kMod8 = k % 8; |
---|
1535 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
1536 | if (rightMovSteps > 0) { |
---|
1537 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1538 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
1539 | } else if (rightMovSteps < 0) { |
---|
1540 | int code1 = getLeftMovingCode(kMod8); |
---|
1541 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
1542 | int leftMovSteps = -rightMovSteps; |
---|
1543 | rightMovSteps = 8 - leftMovSteps; |
---|
1544 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
1545 | p++; |
---|
1546 | resiBits = resiBits |
---|
1547 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
1548 | } else // rightMovSteps == 0 |
---|
1549 | { |
---|
1550 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1551 | resiBits = (tdps->residualMidBits[p] & code); |
---|
1552 | p++; |
---|
1553 | } |
---|
1554 | k += resiBitsLength; |
---|
1555 | } |
---|
1556 | |
---|
1557 | // recover the exact data |
---|
1558 | memset(curBytes, 0, 4); |
---|
1559 | leadingNum = leadNum[l++]; |
---|
1560 | memcpy(curBytes, preBytes, leadingNum); |
---|
1561 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
1562 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
1563 | if (resiBitsLength != 0) { |
---|
1564 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
1565 | curBytes[reqBytesLength] = resiByte; |
---|
1566 | } |
---|
1567 | |
---|
1568 | exactData = bytesToFloat(curBytes); |
---|
1569 | (*data)[index] = exactData + medianValue; |
---|
1570 | memcpy(preBytes,curBytes,4); |
---|
1571 | } |
---|
1572 | |
---|
1573 | /* Process Row-i data 1 --> data r4-1 */ |
---|
1574 | for (jj = 1; jj < r4; jj++) |
---|
1575 | { |
---|
1576 | index = ll*r234+kk*r34+ii*r4+jj; |
---|
1577 | |
---|
1578 | pred3D = (*data)[index-1] + (*data)[index-r4] + (*data)[index-r34] |
---|
1579 | - (*data)[index-r4-1] - (*data)[index-r34-r4] - (*data)[index-r34-1] + (*data)[index-r34-r4-1]; |
---|
1580 | |
---|
1581 | |
---|
1582 | type_ = type[index]; |
---|
1583 | if (type_ != 0) |
---|
1584 | { |
---|
1585 | (*data)[index] = pred3D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
1586 | } |
---|
1587 | else |
---|
1588 | { |
---|
1589 | // compute resiBits |
---|
1590 | resiBits = 0; |
---|
1591 | if (resiBitsLength != 0) { |
---|
1592 | int kMod8 = k % 8; |
---|
1593 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
1594 | if (rightMovSteps > 0) { |
---|
1595 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1596 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
1597 | } else if (rightMovSteps < 0) { |
---|
1598 | int code1 = getLeftMovingCode(kMod8); |
---|
1599 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
1600 | int leftMovSteps = -rightMovSteps; |
---|
1601 | rightMovSteps = 8 - leftMovSteps; |
---|
1602 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
1603 | p++; |
---|
1604 | resiBits = resiBits |
---|
1605 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
1606 | } else // rightMovSteps == 0 |
---|
1607 | { |
---|
1608 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
1609 | resiBits = (tdps->residualMidBits[p] & code); |
---|
1610 | p++; |
---|
1611 | } |
---|
1612 | k += resiBitsLength; |
---|
1613 | } |
---|
1614 | |
---|
1615 | // recover the exact data |
---|
1616 | memset(curBytes, 0, 4); |
---|
1617 | leadingNum = leadNum[l++]; |
---|
1618 | memcpy(curBytes, preBytes, leadingNum); |
---|
1619 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
1620 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
1621 | if (resiBitsLength != 0) { |
---|
1622 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
1623 | curBytes[reqBytesLength] = resiByte; |
---|
1624 | } |
---|
1625 | |
---|
1626 | exactData = bytesToFloat(curBytes); |
---|
1627 | (*data)[index] = exactData + medianValue; |
---|
1628 | memcpy(preBytes,curBytes,4); |
---|
1629 | } |
---|
1630 | } |
---|
1631 | } |
---|
1632 | |
---|
1633 | } |
---|
1634 | } |
---|
1635 | |
---|
1636 | //I didn't implement time-based compression for 4D actually. |
---|
1637 | //#ifdef HAVE_TIMECMPR |
---|
1638 | // if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
1639 | // memcpy(multisteps->hist_data, (*data), dataSeriesLength*sizeof(float)); |
---|
1640 | //#endif |
---|
1641 | |
---|
1642 | free(leadNum); |
---|
1643 | free(type); |
---|
1644 | return; |
---|
1645 | } |
---|
1646 | |
---|
1647 | void getSnapshotData_float_1D(float** data, size_t dataSeriesLength, TightDataPointStorageF* tdps, int errBoundMode) |
---|
1648 | { |
---|
1649 | size_t i; |
---|
1650 | |
---|
1651 | if (tdps->allSameData) { |
---|
1652 | float value = bytesToFloat(tdps->exactMidBytes); |
---|
1653 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
1654 | for (i = 0; i < dataSeriesLength; i++) |
---|
1655 | (*data)[i] = value; |
---|
1656 | } else { |
---|
1657 | if (tdps->rtypeArray == NULL) { |
---|
1658 | if(errBoundMode < PW_REL) |
---|
1659 | { |
---|
1660 | #ifdef HAVE_TIMECMPR |
---|
1661 | if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
1662 | { |
---|
1663 | if(multisteps->compressionType == 0) //snapshot |
---|
1664 | decompressDataSeries_float_1D(data, dataSeriesLength, tdps); |
---|
1665 | else |
---|
1666 | decompressDataSeries_float_1D_ts(data, dataSeriesLength, multisteps, tdps); |
---|
1667 | } |
---|
1668 | else |
---|
1669 | #endif |
---|
1670 | decompressDataSeries_float_1D(data, dataSeriesLength, tdps); |
---|
1671 | } |
---|
1672 | else |
---|
1673 | { |
---|
1674 | decompressDataSeries_float_1D_pwr_pre_log(data, dataSeriesLength, tdps); |
---|
1675 | //decompressDataSeries_float_1D_pwrgroup(data, dataSeriesLength, tdps); |
---|
1676 | } |
---|
1677 | return; |
---|
1678 | } else { |
---|
1679 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
1680 | // insert the reserved values |
---|
1681 | //int[] rtypes = TypeManager.convertByteArray2IntArray_fast_1b( |
---|
1682 | // dataSeriesLength, rtypeArray); |
---|
1683 | int* rtypes; |
---|
1684 | int validLength = computeBitNumRequired(dataSeriesLength); |
---|
1685 | decompressBitArraybySimpleLZ77(&rtypes, tdps->rtypeArray, tdps->rtypeArray_size, dataSeriesLength, validLength); |
---|
1686 | size_t count = 0; |
---|
1687 | for (i = 0; i < dataSeriesLength; i++) { |
---|
1688 | if (rtypes[i] == 1) |
---|
1689 | (*data)[i] = tdps->reservedValue; |
---|
1690 | else |
---|
1691 | count++; |
---|
1692 | } |
---|
1693 | // get the decompressed data |
---|
1694 | float* decmpData; |
---|
1695 | if(errBoundMode < PW_REL) |
---|
1696 | decompressDataSeries_float_1D(&decmpData, dataSeriesLength, tdps); |
---|
1697 | else |
---|
1698 | //decompressDataSeries_float_1D_pwr(&decmpData, dataSeriesLength, tdps); |
---|
1699 | decompressDataSeries_float_1D_pwr_pre_log(&decmpData, dataSeriesLength, tdps); |
---|
1700 | // insert the decompressed data |
---|
1701 | size_t k = 0; |
---|
1702 | for (i = 0; i < dataSeriesLength; i++) { |
---|
1703 | if (rtypes[i] == 0) { |
---|
1704 | (*data)[i] = decmpData[k++]; |
---|
1705 | } |
---|
1706 | } |
---|
1707 | free(decmpData); |
---|
1708 | free(rtypes); |
---|
1709 | } |
---|
1710 | } |
---|
1711 | } |
---|
1712 | |
---|
1713 | void getSnapshotData_float_2D(float** data, size_t r1, size_t r2, TightDataPointStorageF* tdps, int errBoundMode) |
---|
1714 | { |
---|
1715 | size_t i; |
---|
1716 | size_t dataSeriesLength = r1*r2; |
---|
1717 | if (tdps->allSameData) { |
---|
1718 | float value = bytesToFloat(tdps->exactMidBytes); |
---|
1719 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
1720 | for (i = 0; i < dataSeriesLength; i++) |
---|
1721 | (*data)[i] = value; |
---|
1722 | } else { |
---|
1723 | if (tdps->rtypeArray == NULL) { |
---|
1724 | if(errBoundMode < PW_REL) |
---|
1725 | { |
---|
1726 | #ifdef HAVE_TIMECMPR |
---|
1727 | if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
1728 | { |
---|
1729 | if(multisteps->compressionType == 0) |
---|
1730 | decompressDataSeries_float_2D(data, r1, r2, tdps); |
---|
1731 | else |
---|
1732 | decompressDataSeries_float_1D_ts(data, r1*r2, multisteps, tdps); |
---|
1733 | } |
---|
1734 | else |
---|
1735 | #endif |
---|
1736 | decompressDataSeries_float_2D(data, r1, r2, tdps); |
---|
1737 | } |
---|
1738 | else |
---|
1739 | { |
---|
1740 | //decompressDataSeries_float_2D_pwr(data, r1, r2, tdps); |
---|
1741 | decompressDataSeries_float_2D_pwr_pre_log(data, r1, r2, tdps); |
---|
1742 | } |
---|
1743 | |
---|
1744 | return; |
---|
1745 | } else { |
---|
1746 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
1747 | // insert the reserved values |
---|
1748 | //int[] rtypes = TypeManager.convertByteArray2IntArray_fast_1b( |
---|
1749 | // dataSeriesLength, rtypeArray); |
---|
1750 | int* rtypes; |
---|
1751 | int validLength = computeBitNumRequired(dataSeriesLength); |
---|
1752 | decompressBitArraybySimpleLZ77(&rtypes, tdps->rtypeArray, tdps->rtypeArray_size, dataSeriesLength, validLength); |
---|
1753 | size_t count = 0; |
---|
1754 | for (i = 0; i < dataSeriesLength; i++) { |
---|
1755 | if (rtypes[i] == 1) |
---|
1756 | (*data)[i] = tdps->reservedValue; |
---|
1757 | else |
---|
1758 | count++; |
---|
1759 | } |
---|
1760 | // get the decompressed data |
---|
1761 | float* decmpData; |
---|
1762 | if(errBoundMode < PW_REL) |
---|
1763 | decompressDataSeries_float_2D(&decmpData, r1, r2, tdps); |
---|
1764 | else |
---|
1765 | //decompressDataSeries_float_2D_pwr(&decmpData, r1, r2, tdps); |
---|
1766 | decompressDataSeries_float_2D_pwr_pre_log(&decmpData, r1, r2, tdps); |
---|
1767 | // insert the decompressed data |
---|
1768 | size_t k = 0; |
---|
1769 | for (i = 0; i < dataSeriesLength; i++) { |
---|
1770 | if (rtypes[i] == 0) { |
---|
1771 | (*data)[i] = decmpData[k++]; |
---|
1772 | } |
---|
1773 | } |
---|
1774 | free(decmpData); |
---|
1775 | free(rtypes); |
---|
1776 | } |
---|
1777 | } |
---|
1778 | } |
---|
1779 | |
---|
1780 | void getSnapshotData_float_3D(float** data, size_t r1, size_t r2, size_t r3, TightDataPointStorageF* tdps, int errBoundMode) |
---|
1781 | { |
---|
1782 | size_t i; |
---|
1783 | size_t dataSeriesLength = r1*r2*r3; |
---|
1784 | if (tdps->allSameData) { |
---|
1785 | float value = bytesToFloat(tdps->exactMidBytes); |
---|
1786 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
1787 | for (i = 0; i < dataSeriesLength; i++) |
---|
1788 | (*data)[i] = value; |
---|
1789 | } else { |
---|
1790 | if (tdps->rtypeArray == NULL) { |
---|
1791 | if(errBoundMode < PW_REL) |
---|
1792 | { |
---|
1793 | #ifdef HAVE_TIMECMPR |
---|
1794 | if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
1795 | { |
---|
1796 | if(multisteps->compressionType == 0) |
---|
1797 | decompressDataSeries_float_3D(data, r1, r2, r3, tdps); |
---|
1798 | else |
---|
1799 | decompressDataSeries_float_1D_ts(data, dataSeriesLength, multisteps, tdps); |
---|
1800 | } |
---|
1801 | else |
---|
1802 | #endif |
---|
1803 | decompressDataSeries_float_3D(data, r1, r2, r3, tdps); |
---|
1804 | } |
---|
1805 | else |
---|
1806 | { |
---|
1807 | //decompressDataSeries_float_3D_pwr(data, r1, r2, r3, tdps); |
---|
1808 | decompressDataSeries_float_3D_pwr_pre_log(data, r1, r2, r3, tdps); |
---|
1809 | } |
---|
1810 | |
---|
1811 | return; |
---|
1812 | } else { |
---|
1813 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
1814 | // insert the reserved values |
---|
1815 | //int[] rtypes = TypeManager.convertByteArray2IntArray_fast_1b( |
---|
1816 | // dataSeriesLength, rtypeArray); |
---|
1817 | int* rtypes; |
---|
1818 | int validLength = computeBitNumRequired(dataSeriesLength); |
---|
1819 | decompressBitArraybySimpleLZ77(&rtypes, tdps->rtypeArray, tdps->rtypeArray_size, dataSeriesLength, validLength); |
---|
1820 | size_t count = 0; |
---|
1821 | for (i = 0; i < dataSeriesLength; i++) { |
---|
1822 | if (rtypes[i] == 1) |
---|
1823 | (*data)[i] = tdps->reservedValue; |
---|
1824 | else |
---|
1825 | count++; |
---|
1826 | } |
---|
1827 | // get the decompressed data |
---|
1828 | float* decmpData; |
---|
1829 | if(errBoundMode < PW_REL) |
---|
1830 | decompressDataSeries_float_3D(&decmpData, r1, r2, r3, tdps); |
---|
1831 | else |
---|
1832 | //decompressDataSeries_float_3D_pwr(&decmpData, r1, r2, r3, tdps); |
---|
1833 | decompressDataSeries_float_3D_pwr_pre_log(&decmpData, r1, r2, r3, tdps); |
---|
1834 | // insert the decompressed data |
---|
1835 | size_t k = 0; |
---|
1836 | for (i = 0; i < dataSeriesLength; i++) { |
---|
1837 | if (rtypes[i] == 0) { |
---|
1838 | (*data)[i] = decmpData[k++]; |
---|
1839 | } |
---|
1840 | } |
---|
1841 | free(decmpData); |
---|
1842 | free(rtypes); |
---|
1843 | } |
---|
1844 | } |
---|
1845 | } |
---|
1846 | |
---|
1847 | void getSnapshotData_float_4D(float** data, size_t r1, size_t r2, size_t r3, size_t r4, TightDataPointStorageF* tdps, int errBoundMode) |
---|
1848 | { |
---|
1849 | size_t i; |
---|
1850 | size_t dataSeriesLength = r1*r2*r3*r4; |
---|
1851 | if (tdps->allSameData) { |
---|
1852 | float value = bytesToFloat(tdps->exactMidBytes); |
---|
1853 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
1854 | for (i = 0; i < dataSeriesLength; i++) |
---|
1855 | (*data)[i] = value; |
---|
1856 | } else { |
---|
1857 | if (tdps->rtypeArray == NULL) { |
---|
1858 | if(errBoundMode < PW_REL) |
---|
1859 | { |
---|
1860 | #ifdef HAVE_TIMECMPR |
---|
1861 | if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
1862 | { |
---|
1863 | if(multisteps->compressionType == 0) |
---|
1864 | decompressDataSeries_float_4D(data, r1, r2, r3, r4, tdps); |
---|
1865 | else |
---|
1866 | decompressDataSeries_float_1D_ts(data, r1*r2*r3*r4, multisteps, tdps); |
---|
1867 | } |
---|
1868 | else |
---|
1869 | #endif |
---|
1870 | decompressDataSeries_float_4D(data, r1, r2, r3, r4, tdps); |
---|
1871 | } |
---|
1872 | else |
---|
1873 | { |
---|
1874 | //decompressDataSeries_float_3D_pwr(data, r1*r2, r3, r4, tdps); |
---|
1875 | decompressDataSeries_float_3D_pwr_pre_log(data, r1*r2, r3, r4, tdps); |
---|
1876 | //ToDO |
---|
1877 | //decompressDataSeries_float_4D_pwr(data, r1, r2, r3, r4, tdps); |
---|
1878 | } |
---|
1879 | return; |
---|
1880 | } else { |
---|
1881 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
1882 | int* rtypes; |
---|
1883 | int validLength = computeBitNumRequired(dataSeriesLength); |
---|
1884 | decompressBitArraybySimpleLZ77(&rtypes, tdps->rtypeArray, tdps->rtypeArray_size, dataSeriesLength, validLength); |
---|
1885 | size_t count = 0; |
---|
1886 | for (i = 0; i < dataSeriesLength; i++) { |
---|
1887 | if (rtypes[i] == 1) |
---|
1888 | (*data)[i] = tdps->reservedValue; |
---|
1889 | else |
---|
1890 | count++; |
---|
1891 | } |
---|
1892 | // get the decompressed data |
---|
1893 | float* decmpData; |
---|
1894 | if(errBoundMode < PW_REL) |
---|
1895 | decompressDataSeries_float_4D(&decmpData, r1, r2, r3, r4, tdps); |
---|
1896 | else |
---|
1897 | //decompressDataSeries_float_3D_pwr(&decmpData, r1*r2, r3, r4, tdps); |
---|
1898 | decompressDataSeries_float_3D_pwr_pre_log(&decmpData, r1*r2, r3, r4, tdps); |
---|
1899 | //ToDO |
---|
1900 | //decompressDataSeries_float_4D_pwr(&decompData, r1, r2, r3, r4, tdps); |
---|
1901 | // insert the decompressed data |
---|
1902 | size_t k = 0; |
---|
1903 | for (i = 0; i < dataSeriesLength; i++) { |
---|
1904 | if (rtypes[i] == 0) { |
---|
1905 | (*data)[i] = decmpData[k++]; |
---|
1906 | } |
---|
1907 | } |
---|
1908 | free(decmpData); |
---|
1909 | free(rtypes); |
---|
1910 | } |
---|
1911 | } |
---|
1912 | } |
---|
1913 | |
---|
1914 | size_t decompressDataSeries_float_3D_RA_block(float * data, float mean, size_t dim_0, size_t dim_1, size_t dim_2, size_t block_dim_0, size_t block_dim_1, size_t block_dim_2, double realPrecision, int * type, float * unpredictable_data){ |
---|
1915 | |
---|
1916 | size_t dim0_offset = dim_1 * dim_2; |
---|
1917 | size_t dim1_offset = dim_2; |
---|
1918 | // printf("SZ_compress_float_3D_MDQ_RA_block real dim: %d %d %d\n", real_block_dims[0], real_block_dims[1], real_block_dims[2]); |
---|
1919 | // fflush(stdout); |
---|
1920 | |
---|
1921 | size_t unpredictable_count = 0; |
---|
1922 | size_t r1, r2, r3; |
---|
1923 | r1 = block_dim_0; |
---|
1924 | r2 = block_dim_1; |
---|
1925 | r3 = block_dim_2; |
---|
1926 | |
---|
1927 | float * cur_data_pos = data; |
---|
1928 | float * last_row_pos; |
---|
1929 | float pred1D, pred2D, pred3D; |
---|
1930 | size_t i, j, k; |
---|
1931 | size_t r23 = r2*r3; |
---|
1932 | int type_; |
---|
1933 | // Process Row-0 data 0 |
---|
1934 | pred1D = mean; |
---|
1935 | type_ = type[0]; |
---|
1936 | // printf("Type 0 %d, mean %.4f\n", type_, mean); |
---|
1937 | if (type_ != 0){ |
---|
1938 | cur_data_pos[0] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
1939 | } |
---|
1940 | else{ |
---|
1941 | cur_data_pos[0] = unpredictable_data[unpredictable_count ++]; |
---|
1942 | } |
---|
1943 | |
---|
1944 | /* Process Row-0 data 1*/ |
---|
1945 | pred1D = cur_data_pos[0]; |
---|
1946 | type_ = type[1]; |
---|
1947 | if (type_ != 0){ |
---|
1948 | cur_data_pos[1] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
1949 | } |
---|
1950 | else{ |
---|
1951 | cur_data_pos[1] = unpredictable_data[unpredictable_count ++]; |
---|
1952 | } |
---|
1953 | /* Process Row-0 data 2 --> data r3-1 */ |
---|
1954 | for (j = 2; j < r3; j++){ |
---|
1955 | pred1D = 2*cur_data_pos[j-1] - cur_data_pos[j-2]; |
---|
1956 | type_ = type[j]; |
---|
1957 | if (type_ != 0){ |
---|
1958 | cur_data_pos[j] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
1959 | } |
---|
1960 | else{ |
---|
1961 | cur_data_pos[j] = unpredictable_data[unpredictable_count ++]; |
---|
1962 | } |
---|
1963 | } |
---|
1964 | |
---|
1965 | last_row_pos = cur_data_pos; |
---|
1966 | cur_data_pos += dim1_offset; |
---|
1967 | // printf("SZ_compress_float_3D_MDQ_RA_block row 0 done, cur_data_pos: %ld\n", cur_data_pos - block_ori_data); |
---|
1968 | // fflush(stdout); |
---|
1969 | |
---|
1970 | /* Process Row-1 --> Row-r2-1 */ |
---|
1971 | size_t index; |
---|
1972 | for (i = 1; i < r2; i++) |
---|
1973 | { |
---|
1974 | /* Process row-i data 0 */ |
---|
1975 | index = i*r3; |
---|
1976 | pred1D = last_row_pos[0]; |
---|
1977 | type_ = type[index]; |
---|
1978 | if (type_ != 0){ |
---|
1979 | cur_data_pos[0] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
1980 | } |
---|
1981 | else{ |
---|
1982 | cur_data_pos[0] = unpredictable_data[unpredictable_count ++]; |
---|
1983 | } |
---|
1984 | /* Process row-i data 1 --> data r3-1*/ |
---|
1985 | for (j = 1; j < r3; j++) |
---|
1986 | { |
---|
1987 | index = i*r3+j; |
---|
1988 | pred2D = cur_data_pos[j-1] + last_row_pos[j] - last_row_pos[j-1]; |
---|
1989 | type_ = type[index]; |
---|
1990 | if (type_ != 0){ |
---|
1991 | cur_data_pos[j] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
1992 | } |
---|
1993 | else{ |
---|
1994 | cur_data_pos[j] = unpredictable_data[unpredictable_count ++]; |
---|
1995 | } |
---|
1996 | // printf("pred2D %.2f cur_data %.2f last_row_data %.2f %.2f, result %.2f\n", pred2D, cur_data_pos[j-1], last_row_pos[j], last_row_pos[j-1], cur_data_pos[j]); |
---|
1997 | // getchar(); |
---|
1998 | } |
---|
1999 | last_row_pos = cur_data_pos; |
---|
2000 | cur_data_pos += dim1_offset; |
---|
2001 | } |
---|
2002 | cur_data_pos += dim0_offset - r2 * dim1_offset; |
---|
2003 | |
---|
2004 | // printf("SZ_compress_float_3D_MDQ_RA_block layer 0 done, cur_data_pos: %ld\n", cur_data_pos - block_ori_data); |
---|
2005 | // fflush(stdout); |
---|
2006 | // exit(0); |
---|
2007 | |
---|
2008 | /////////////////////////// Process layer-1 --> layer-r1-1 /////////////////////////// |
---|
2009 | |
---|
2010 | for (k = 1; k < r1; k++) |
---|
2011 | { |
---|
2012 | // if(idx == 63 && idy == 63 && idz == 63){ |
---|
2013 | // printf("SZ_compress_float_3D_MDQ_RA_block layer %d done, cur_data_pos: %ld\n", k-1, cur_data_pos - data); |
---|
2014 | // fflush(stdout); |
---|
2015 | // } |
---|
2016 | /* Process Row-0 data 0*/ |
---|
2017 | index = k*r23; |
---|
2018 | pred1D = cur_data_pos[- dim0_offset]; |
---|
2019 | type_ = type[index]; |
---|
2020 | if (type_ != 0){ |
---|
2021 | cur_data_pos[0] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
2022 | } |
---|
2023 | else{ |
---|
2024 | cur_data_pos[0] = unpredictable_data[unpredictable_count ++]; |
---|
2025 | } |
---|
2026 | /* Process Row-0 data 1 --> data r3-1 */ |
---|
2027 | for (j = 1; j < r3; j++) |
---|
2028 | { |
---|
2029 | //index = k*r2*r3+j; |
---|
2030 | index ++; |
---|
2031 | pred2D = cur_data_pos[j-1] + cur_data_pos[j - dim0_offset] - cur_data_pos[j - 1 - dim0_offset]; |
---|
2032 | type_ = type[index]; |
---|
2033 | if (type_ != 0){ |
---|
2034 | cur_data_pos[j] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
2035 | } |
---|
2036 | else{ |
---|
2037 | cur_data_pos[j] = unpredictable_data[unpredictable_count ++]; |
---|
2038 | } |
---|
2039 | // printf("pred2D %.2f cur_data %.2f %.2f %.2f, result %.2f\n", pred2D, cur_data_pos[j-1], cur_data_pos[j - dim0_offset], cur_data_pos[j - 1 - dim0_offset], cur_data_pos[j]); |
---|
2040 | // getchar(); |
---|
2041 | } |
---|
2042 | last_row_pos = cur_data_pos; |
---|
2043 | cur_data_pos += dim1_offset; |
---|
2044 | |
---|
2045 | // if(idx == 63 && idy == 63 && idz == 63){ |
---|
2046 | // printf("SZ_compress_float_3D_MDQ_RA_block layer row 0 done, cur_data_pos: %ld\n", k-1, cur_data_pos - data); |
---|
2047 | // fflush(stdout); |
---|
2048 | // } |
---|
2049 | |
---|
2050 | /* Process Row-1 --> Row-r2-1 */ |
---|
2051 | for (i = 1; i < r2; i++) |
---|
2052 | { |
---|
2053 | // if(idx == 63 && idy == 63 && idz == 63){ |
---|
2054 | // printf("SZ_compress_float_3D_MDQ_RA_block layer row %d done, cur_data_pos: %ld\n", i-1, cur_data_pos - data); |
---|
2055 | // fflush(stdout); |
---|
2056 | // } |
---|
2057 | /* Process Row-i data 0 */ |
---|
2058 | index = k*r23 + i*r3; |
---|
2059 | pred2D = last_row_pos[0] + cur_data_pos[- dim0_offset] - last_row_pos[- dim0_offset]; |
---|
2060 | type_ = type[index]; |
---|
2061 | if (type_ != 0){ |
---|
2062 | cur_data_pos[0] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
2063 | } |
---|
2064 | else{ |
---|
2065 | cur_data_pos[0] = unpredictable_data[unpredictable_count ++]; |
---|
2066 | } |
---|
2067 | |
---|
2068 | /* Process Row-i data 1 --> data r3-1 */ |
---|
2069 | for (j = 1; j < r3; j++) |
---|
2070 | { |
---|
2071 | // if(k==63&&i==43&&j==27) |
---|
2072 | // printf("i=%d\n", i); |
---|
2073 | //index = k*r2*r3 + i*r3 + j; |
---|
2074 | index ++; |
---|
2075 | pred3D = cur_data_pos[j-1] + last_row_pos[j]+ cur_data_pos[j - dim0_offset] - last_row_pos[j-1] - last_row_pos[j - dim0_offset] - cur_data_pos[j-1 - dim0_offset] + last_row_pos[j-1 - dim0_offset]; |
---|
2076 | type_ = type[index]; |
---|
2077 | if (type_ != 0){ |
---|
2078 | cur_data_pos[j] = pred3D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
2079 | } |
---|
2080 | else{ |
---|
2081 | cur_data_pos[j] = unpredictable_data[unpredictable_count ++]; |
---|
2082 | } |
---|
2083 | } |
---|
2084 | last_row_pos = cur_data_pos; |
---|
2085 | cur_data_pos += dim1_offset; |
---|
2086 | } |
---|
2087 | cur_data_pos += dim0_offset - r2 * dim1_offset; |
---|
2088 | } |
---|
2089 | |
---|
2090 | return unpredictable_count; |
---|
2091 | } |
---|
2092 | |
---|
2093 | size_t decompressDataSeries_float_1D_RA_block(float * data, float mean, size_t dim_0, size_t block_dim_0, double realPrecision, int * type, float * unpredictable_data){ |
---|
2094 | |
---|
2095 | size_t unpredictable_count = 0; |
---|
2096 | |
---|
2097 | float * cur_data_pos = data; |
---|
2098 | size_t type_index = 0; |
---|
2099 | int type_; |
---|
2100 | float last_over_thres = mean; |
---|
2101 | for(size_t i=0; i<block_dim_0; i++){ |
---|
2102 | type_ = type[type_index]; |
---|
2103 | if(type_ == 0){ |
---|
2104 | cur_data_pos[0] = unpredictable_data[unpredictable_count ++]; |
---|
2105 | last_over_thres = cur_data_pos[0]; |
---|
2106 | } |
---|
2107 | else{ |
---|
2108 | cur_data_pos[0] = last_over_thres + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
2109 | last_over_thres = cur_data_pos[0]; |
---|
2110 | } |
---|
2111 | |
---|
2112 | type_index ++; |
---|
2113 | cur_data_pos ++; |
---|
2114 | } |
---|
2115 | |
---|
2116 | return unpredictable_count; |
---|
2117 | } |
---|
2118 | |
---|
2119 | size_t decompressDataSeries_float_2D_RA_block(float * data, float mean, size_t dim_0, size_t dim_1, size_t block_dim_0, size_t block_dim_1, double realPrecision, int * type, float * unpredictable_data){ |
---|
2120 | |
---|
2121 | size_t dim0_offset = dim_1; |
---|
2122 | // printf("SZ_compress_float_3D_MDQ_RA_block real dim: %d %d %d\n", real_block_dims[0], real_block_dims[1], real_block_dims[2]); |
---|
2123 | // fflush(stdout); |
---|
2124 | |
---|
2125 | size_t unpredictable_count = 0; |
---|
2126 | size_t r1, r2; |
---|
2127 | r1 = block_dim_0; |
---|
2128 | r2 = block_dim_1; |
---|
2129 | |
---|
2130 | float * cur_data_pos = data; |
---|
2131 | float * last_row_pos; |
---|
2132 | float pred1D, pred2D; |
---|
2133 | size_t i, j; |
---|
2134 | int type_; |
---|
2135 | // Process Row-0 data 0 |
---|
2136 | pred1D = mean; |
---|
2137 | type_ = type[0]; |
---|
2138 | // printf("Type 0 %d, mean %.4f\n", type_, mean); |
---|
2139 | if (type_ != 0){ |
---|
2140 | cur_data_pos[0] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
2141 | } |
---|
2142 | else{ |
---|
2143 | cur_data_pos[0] = unpredictable_data[unpredictable_count ++]; |
---|
2144 | } |
---|
2145 | |
---|
2146 | /* Process Row-0 data 1*/ |
---|
2147 | pred1D = cur_data_pos[0]; |
---|
2148 | type_ = type[1]; |
---|
2149 | if (type_ != 0){ |
---|
2150 | cur_data_pos[1] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
2151 | } |
---|
2152 | else{ |
---|
2153 | cur_data_pos[1] = unpredictable_data[unpredictable_count ++]; |
---|
2154 | } |
---|
2155 | /* Process Row-0 data 2 --> data r3-1 */ |
---|
2156 | for (j = 2; j < r2; j++){ |
---|
2157 | pred1D = 2*cur_data_pos[j-1] - cur_data_pos[j-2]; |
---|
2158 | type_ = type[j]; |
---|
2159 | if (type_ != 0){ |
---|
2160 | cur_data_pos[j] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
2161 | } |
---|
2162 | else{ |
---|
2163 | cur_data_pos[j] = unpredictable_data[unpredictable_count ++]; |
---|
2164 | } |
---|
2165 | } |
---|
2166 | |
---|
2167 | last_row_pos = cur_data_pos; |
---|
2168 | cur_data_pos += dim0_offset; |
---|
2169 | // printf("SZ_compress_float_3D_MDQ_RA_block row 0 done, cur_data_pos: %ld\n", cur_data_pos - block_ori_data); |
---|
2170 | // fflush(stdout); |
---|
2171 | |
---|
2172 | /* Process Row-1 --> Row-r2-1 */ |
---|
2173 | size_t index; |
---|
2174 | for (i = 1; i < r1; i++) |
---|
2175 | { |
---|
2176 | /* Process row-i data 0 */ |
---|
2177 | index = i*r2; |
---|
2178 | type_ = type[index]; |
---|
2179 | if (type_ != 0){ |
---|
2180 | pred1D = last_row_pos[0]; |
---|
2181 | cur_data_pos[0] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
2182 | } |
---|
2183 | else{ |
---|
2184 | cur_data_pos[0] = unpredictable_data[unpredictable_count ++]; |
---|
2185 | } |
---|
2186 | /* Process row-i data 1 --> data r3-1*/ |
---|
2187 | for (j = 1; j < r2; j++) |
---|
2188 | { |
---|
2189 | index = i*r2+j; |
---|
2190 | pred2D = cur_data_pos[j-1] + last_row_pos[j] - last_row_pos[j-1]; |
---|
2191 | type_ = type[index]; |
---|
2192 | if (type_ != 0){ |
---|
2193 | cur_data_pos[j] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
2194 | } |
---|
2195 | else{ |
---|
2196 | cur_data_pos[j] = unpredictable_data[unpredictable_count ++]; |
---|
2197 | } |
---|
2198 | // printf("pred2D %.2f cur_data %.2f last_row_data %.2f %.2f, result %.2f\n", pred2D, cur_data_pos[j-1], last_row_pos[j], last_row_pos[j-1], cur_data_pos[j]); |
---|
2199 | // getchar(); |
---|
2200 | } |
---|
2201 | last_row_pos = cur_data_pos; |
---|
2202 | cur_data_pos += dim0_offset; |
---|
2203 | } |
---|
2204 | return unpredictable_count; |
---|
2205 | } |
---|
2206 | |
---|
2207 | void decompressDataSeries_float_2D_nonblocked_with_blocked_regression(float** data, size_t r1, size_t r2, unsigned char* comp_data){ |
---|
2208 | |
---|
2209 | size_t dim0_offset = r2; |
---|
2210 | size_t num_elements = r1 * r2; |
---|
2211 | |
---|
2212 | *data = (float*)malloc(sizeof(float)*num_elements); |
---|
2213 | |
---|
2214 | unsigned char * comp_data_pos = comp_data; |
---|
2215 | |
---|
2216 | size_t block_size = bytesToInt_bigEndian(comp_data_pos); |
---|
2217 | comp_data_pos += sizeof(int); |
---|
2218 | // calculate block dims |
---|
2219 | size_t num_x, num_y; |
---|
2220 | SZ_COMPUTE_3D_NUMBER_OF_BLOCKS(r1, num_x, block_size); |
---|
2221 | SZ_COMPUTE_3D_NUMBER_OF_BLOCKS(r2, num_y, block_size); |
---|
2222 | |
---|
2223 | size_t split_index_x, split_index_y; |
---|
2224 | size_t early_blockcount_x, early_blockcount_y; |
---|
2225 | size_t late_blockcount_x, late_blockcount_y; |
---|
2226 | SZ_COMPUTE_BLOCKCOUNT(r1, num_x, split_index_x, early_blockcount_x, late_blockcount_x); |
---|
2227 | SZ_COMPUTE_BLOCKCOUNT(r2, num_y, split_index_y, early_blockcount_y, late_blockcount_y); |
---|
2228 | |
---|
2229 | size_t num_blocks = num_x * num_y; |
---|
2230 | |
---|
2231 | double realPrecision = bytesToDouble(comp_data_pos); |
---|
2232 | comp_data_pos += sizeof(double); |
---|
2233 | unsigned int intervals = bytesToInt_bigEndian(comp_data_pos); |
---|
2234 | comp_data_pos += sizeof(int); |
---|
2235 | |
---|
2236 | updateQuantizationInfo(intervals); |
---|
2237 | |
---|
2238 | unsigned int tree_size = bytesToInt_bigEndian(comp_data_pos); |
---|
2239 | comp_data_pos += sizeof(int); |
---|
2240 | |
---|
2241 | int stateNum = 2*intervals; |
---|
2242 | HuffmanTree* huffmanTree = createHuffmanTree(stateNum); |
---|
2243 | |
---|
2244 | int nodeCount = bytesToInt_bigEndian(comp_data_pos); |
---|
2245 | |
---|
2246 | node root = reconstruct_HuffTree_from_bytes_anyStates(huffmanTree,comp_data_pos+sizeof(int), nodeCount); |
---|
2247 | comp_data_pos += sizeof(int) + tree_size; |
---|
2248 | |
---|
2249 | float mean; |
---|
2250 | unsigned char use_mean; |
---|
2251 | memcpy(&use_mean, comp_data_pos, sizeof(unsigned char)); |
---|
2252 | comp_data_pos += sizeof(unsigned char); |
---|
2253 | memcpy(&mean, comp_data_pos, sizeof(float)); |
---|
2254 | comp_data_pos += sizeof(float); |
---|
2255 | size_t reg_count = 0; |
---|
2256 | |
---|
2257 | unsigned char * indicator; |
---|
2258 | size_t indicator_bitlength = (num_blocks - 1)/8 + 1; |
---|
2259 | convertByteArray2IntArray_fast_1b(num_blocks, comp_data_pos, indicator_bitlength, &indicator); |
---|
2260 | comp_data_pos += indicator_bitlength; |
---|
2261 | for(size_t i=0; i<num_blocks; i++){ |
---|
2262 | if(!indicator[i]) reg_count ++; |
---|
2263 | } |
---|
2264 | //printf("reg_count: %ld\n", reg_count); |
---|
2265 | |
---|
2266 | int coeff_intvRadius[3]; |
---|
2267 | int * coeff_result_type = (int *) malloc(num_blocks*3*sizeof(int)); |
---|
2268 | int * coeff_type[3]; |
---|
2269 | double precision[3]; |
---|
2270 | float * coeff_unpred_data[3]; |
---|
2271 | if(reg_count > 0){ |
---|
2272 | for(int i=0; i<3; i++){ |
---|
2273 | precision[i] = bytesToDouble(comp_data_pos); |
---|
2274 | comp_data_pos += sizeof(double); |
---|
2275 | coeff_intvRadius[i] = bytesToInt_bigEndian(comp_data_pos); |
---|
2276 | comp_data_pos += sizeof(int); |
---|
2277 | unsigned int tree_size = bytesToInt_bigEndian(comp_data_pos); |
---|
2278 | comp_data_pos += sizeof(int); |
---|
2279 | int stateNum = 2*coeff_intvRadius[i]*2; |
---|
2280 | HuffmanTree* huffmanTree = createHuffmanTree(stateNum); |
---|
2281 | int nodeCount = bytesToInt_bigEndian(comp_data_pos); |
---|
2282 | node root = reconstruct_HuffTree_from_bytes_anyStates(huffmanTree, comp_data_pos+sizeof(int), nodeCount); |
---|
2283 | comp_data_pos += sizeof(int) + tree_size; |
---|
2284 | |
---|
2285 | coeff_type[i] = coeff_result_type + i * num_blocks; |
---|
2286 | size_t typeArray_size = bytesToSize(comp_data_pos); |
---|
2287 | decode(comp_data_pos + sizeof(size_t), reg_count, root, coeff_type[i]); |
---|
2288 | comp_data_pos += sizeof(size_t) + typeArray_size; |
---|
2289 | int coeff_unpred_count = bytesToInt_bigEndian(comp_data_pos); |
---|
2290 | comp_data_pos += sizeof(int); |
---|
2291 | coeff_unpred_data[i] = (float *) comp_data_pos; |
---|
2292 | comp_data_pos += coeff_unpred_count * sizeof(float); |
---|
2293 | SZ_ReleaseHuffman(huffmanTree); |
---|
2294 | } |
---|
2295 | } |
---|
2296 | float last_coefficients[3] = {0.0}; |
---|
2297 | int coeff_unpred_data_count[3] = {0}; |
---|
2298 | int coeff_index = 0; |
---|
2299 | updateQuantizationInfo(intervals); |
---|
2300 | |
---|
2301 | size_t total_unpred; |
---|
2302 | memcpy(&total_unpred, comp_data_pos, sizeof(size_t)); |
---|
2303 | comp_data_pos += sizeof(size_t); |
---|
2304 | float * unpred_data = (float *) comp_data_pos; |
---|
2305 | comp_data_pos += total_unpred * sizeof(float); |
---|
2306 | |
---|
2307 | int * result_type = (int *) malloc(num_elements * sizeof(int)); |
---|
2308 | decode(comp_data_pos, num_elements, root, result_type); |
---|
2309 | SZ_ReleaseHuffman(huffmanTree); |
---|
2310 | |
---|
2311 | int intvRadius = exe_params->intvRadius; |
---|
2312 | |
---|
2313 | int * type; |
---|
2314 | |
---|
2315 | float * data_pos = *data; |
---|
2316 | size_t offset_x, offset_y; |
---|
2317 | size_t current_blockcount_x, current_blockcount_y; |
---|
2318 | size_t cur_unpred_count; |
---|
2319 | |
---|
2320 | unsigned char * indicator_pos = indicator; |
---|
2321 | if(use_mean){ |
---|
2322 | type = result_type; |
---|
2323 | for(size_t i=0; i<num_x; i++){ |
---|
2324 | for(size_t j=0; j<num_y; j++){ |
---|
2325 | offset_x = (i < split_index_x) ? i * early_blockcount_x : i * late_blockcount_x + split_index_x; |
---|
2326 | offset_y = (j < split_index_y) ? j * early_blockcount_y : j * late_blockcount_y + split_index_y; |
---|
2327 | data_pos = *data + offset_x * dim0_offset + offset_y; |
---|
2328 | |
---|
2329 | current_blockcount_x = (i < split_index_x) ? early_blockcount_x : late_blockcount_x; |
---|
2330 | current_blockcount_y = (j < split_index_y) ? early_blockcount_y : late_blockcount_y; |
---|
2331 | |
---|
2332 | size_t current_block_elements = current_blockcount_x * current_blockcount_y; |
---|
2333 | if(*indicator_pos){ |
---|
2334 | // decompress by SZ |
---|
2335 | |
---|
2336 | float * block_data_pos = data_pos; |
---|
2337 | float pred; |
---|
2338 | size_t index = 0; |
---|
2339 | int type_; |
---|
2340 | // d11 is current data |
---|
2341 | size_t unpredictable_count = 0; |
---|
2342 | float d00, d01, d10; |
---|
2343 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
2344 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
2345 | type_ = type[index]; |
---|
2346 | if(type_ == intvRadius){ |
---|
2347 | *block_data_pos = mean; |
---|
2348 | } |
---|
2349 | else if(type_ == 0){ |
---|
2350 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
2351 | } |
---|
2352 | else{ |
---|
2353 | d00 = d01 = d10 = 1; |
---|
2354 | if(i == 0 && ii == 0){ |
---|
2355 | d00 = d01 = 0; |
---|
2356 | } |
---|
2357 | if(j == 0 && jj == 0){ |
---|
2358 | d00 = d10 = 0; |
---|
2359 | } |
---|
2360 | if(d00){ |
---|
2361 | d00 = block_data_pos[- dim0_offset - 1]; |
---|
2362 | } |
---|
2363 | if(d01){ |
---|
2364 | d01 = block_data_pos[- dim0_offset]; |
---|
2365 | } |
---|
2366 | if(d10){ |
---|
2367 | d10 = block_data_pos[- 1]; |
---|
2368 | } |
---|
2369 | if(type_ < intvRadius) type_ += 1; |
---|
2370 | pred = d10 + d01 - d00; |
---|
2371 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
2372 | } |
---|
2373 | index ++; |
---|
2374 | block_data_pos ++; |
---|
2375 | } |
---|
2376 | block_data_pos += dim0_offset - current_blockcount_y; |
---|
2377 | } |
---|
2378 | cur_unpred_count = unpredictable_count; |
---|
2379 | } |
---|
2380 | else{ |
---|
2381 | // decompress by regression |
---|
2382 | { |
---|
2383 | //restore regression coefficients |
---|
2384 | float pred; |
---|
2385 | int type_; |
---|
2386 | for(int e=0; e<3; e++){ |
---|
2387 | type_ = coeff_type[e][coeff_index]; |
---|
2388 | if (type_ != 0){ |
---|
2389 | pred = last_coefficients[e]; |
---|
2390 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
2391 | } |
---|
2392 | else{ |
---|
2393 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
2394 | coeff_unpred_data_count[e] ++; |
---|
2395 | } |
---|
2396 | } |
---|
2397 | coeff_index ++; |
---|
2398 | } |
---|
2399 | { |
---|
2400 | float * block_data_pos = data_pos; |
---|
2401 | float pred; |
---|
2402 | int type_; |
---|
2403 | size_t index = 0; |
---|
2404 | size_t unpredictable_count = 0; |
---|
2405 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
2406 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
2407 | type_ = type[index]; |
---|
2408 | if (type_ != 0){ |
---|
2409 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2]; |
---|
2410 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
2411 | } |
---|
2412 | else{ |
---|
2413 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
2414 | } |
---|
2415 | |
---|
2416 | index ++; |
---|
2417 | block_data_pos ++; |
---|
2418 | } |
---|
2419 | block_data_pos += dim0_offset - current_blockcount_y; |
---|
2420 | } |
---|
2421 | cur_unpred_count = unpredictable_count; |
---|
2422 | } |
---|
2423 | } |
---|
2424 | |
---|
2425 | type += current_block_elements; |
---|
2426 | indicator_pos ++; |
---|
2427 | unpred_data += cur_unpred_count; |
---|
2428 | } |
---|
2429 | } |
---|
2430 | } |
---|
2431 | else{ |
---|
2432 | type = result_type; |
---|
2433 | for(size_t i=0; i<num_x; i++){ |
---|
2434 | for(size_t j=0; j<num_y; j++){ |
---|
2435 | offset_x = (i < split_index_x) ? i * early_blockcount_x : i * late_blockcount_x + split_index_x; |
---|
2436 | offset_y = (j < split_index_y) ? j * early_blockcount_y : j * late_blockcount_y + split_index_y; |
---|
2437 | data_pos = *data + offset_x * dim0_offset + offset_y; |
---|
2438 | |
---|
2439 | current_blockcount_x = (i < split_index_x) ? early_blockcount_x : late_blockcount_x; |
---|
2440 | current_blockcount_y = (j < split_index_y) ? early_blockcount_y : late_blockcount_y; |
---|
2441 | |
---|
2442 | size_t current_block_elements = current_blockcount_x * current_blockcount_y; |
---|
2443 | if(*indicator_pos){ |
---|
2444 | // decompress by SZ |
---|
2445 | |
---|
2446 | float * block_data_pos = data_pos; |
---|
2447 | float pred; |
---|
2448 | size_t index = 0; |
---|
2449 | int type_; |
---|
2450 | // d11 is current data |
---|
2451 | size_t unpredictable_count = 0; |
---|
2452 | float d00, d01, d10; |
---|
2453 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
2454 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
2455 | type_ = type[index]; |
---|
2456 | if(type_ == 0){ |
---|
2457 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
2458 | } |
---|
2459 | else{ |
---|
2460 | d00 = d01 = d10 = 1; |
---|
2461 | if(i == 0 && ii == 0){ |
---|
2462 | d00 = d01 = 0; |
---|
2463 | } |
---|
2464 | if(j == 0 && jj == 0){ |
---|
2465 | d00 = d10 = 0; |
---|
2466 | } |
---|
2467 | if(d00){ |
---|
2468 | d00 = block_data_pos[- dim0_offset - 1]; |
---|
2469 | } |
---|
2470 | if(d01){ |
---|
2471 | d01 = block_data_pos[- dim0_offset]; |
---|
2472 | } |
---|
2473 | if(d10){ |
---|
2474 | d10 = block_data_pos[- 1]; |
---|
2475 | } |
---|
2476 | pred = d10 + d01 - d00; |
---|
2477 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
2478 | } |
---|
2479 | index ++; |
---|
2480 | block_data_pos ++; |
---|
2481 | } |
---|
2482 | block_data_pos += dim0_offset - current_blockcount_y; |
---|
2483 | } |
---|
2484 | cur_unpred_count = unpredictable_count; |
---|
2485 | } |
---|
2486 | else{ |
---|
2487 | // decompress by regression |
---|
2488 | { |
---|
2489 | //restore regression coefficients |
---|
2490 | float pred; |
---|
2491 | int type_; |
---|
2492 | for(int e=0; e<3; e++){ |
---|
2493 | type_ = coeff_type[e][coeff_index]; |
---|
2494 | if (type_ != 0){ |
---|
2495 | pred = last_coefficients[e]; |
---|
2496 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
2497 | } |
---|
2498 | else{ |
---|
2499 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
2500 | coeff_unpred_data_count[e] ++; |
---|
2501 | } |
---|
2502 | } |
---|
2503 | coeff_index ++; |
---|
2504 | } |
---|
2505 | { |
---|
2506 | float * block_data_pos = data_pos; |
---|
2507 | float pred; |
---|
2508 | int type_; |
---|
2509 | size_t index = 0; |
---|
2510 | size_t unpredictable_count = 0; |
---|
2511 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
2512 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
2513 | type_ = type[index]; |
---|
2514 | if (type_ != 0){ |
---|
2515 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2]; |
---|
2516 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
2517 | } |
---|
2518 | else{ |
---|
2519 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
2520 | } |
---|
2521 | index ++; |
---|
2522 | block_data_pos ++; |
---|
2523 | } |
---|
2524 | block_data_pos += dim0_offset - current_blockcount_y; |
---|
2525 | } |
---|
2526 | cur_unpred_count = unpredictable_count; |
---|
2527 | } |
---|
2528 | } |
---|
2529 | |
---|
2530 | type += current_block_elements; |
---|
2531 | indicator_pos ++; |
---|
2532 | unpred_data += cur_unpred_count; |
---|
2533 | } |
---|
2534 | } |
---|
2535 | } |
---|
2536 | free(coeff_result_type); |
---|
2537 | |
---|
2538 | free(indicator); |
---|
2539 | free(result_type); |
---|
2540 | } |
---|
2541 | |
---|
2542 | |
---|
2543 | void decompressDataSeries_float_3D_nonblocked_with_blocked_regression(float** data, size_t r1, size_t r2, size_t r3, unsigned char* comp_data){ |
---|
2544 | |
---|
2545 | size_t dim0_offset = r2 * r3; |
---|
2546 | size_t dim1_offset = r3; |
---|
2547 | size_t num_elements = r1 * r2 * r3; |
---|
2548 | |
---|
2549 | *data = (float*)malloc(sizeof(float)*num_elements); |
---|
2550 | |
---|
2551 | unsigned char * comp_data_pos = comp_data; |
---|
2552 | |
---|
2553 | size_t block_size = bytesToInt_bigEndian(comp_data_pos); |
---|
2554 | comp_data_pos += sizeof(int); |
---|
2555 | // calculate block dims |
---|
2556 | size_t num_x, num_y, num_z; |
---|
2557 | SZ_COMPUTE_3D_NUMBER_OF_BLOCKS(r1, num_x, block_size); |
---|
2558 | SZ_COMPUTE_3D_NUMBER_OF_BLOCKS(r2, num_y, block_size); |
---|
2559 | SZ_COMPUTE_3D_NUMBER_OF_BLOCKS(r3, num_z, block_size); |
---|
2560 | |
---|
2561 | size_t split_index_x, split_index_y, split_index_z; |
---|
2562 | size_t early_blockcount_x, early_blockcount_y, early_blockcount_z; |
---|
2563 | size_t late_blockcount_x, late_blockcount_y, late_blockcount_z; |
---|
2564 | SZ_COMPUTE_BLOCKCOUNT(r1, num_x, split_index_x, early_blockcount_x, late_blockcount_x); |
---|
2565 | SZ_COMPUTE_BLOCKCOUNT(r2, num_y, split_index_y, early_blockcount_y, late_blockcount_y); |
---|
2566 | SZ_COMPUTE_BLOCKCOUNT(r3, num_z, split_index_z, early_blockcount_z, late_blockcount_z); |
---|
2567 | |
---|
2568 | size_t num_blocks = num_x * num_y * num_z; |
---|
2569 | |
---|
2570 | double realPrecision = bytesToDouble(comp_data_pos); |
---|
2571 | comp_data_pos += sizeof(double); |
---|
2572 | unsigned int intervals = bytesToInt_bigEndian(comp_data_pos); |
---|
2573 | comp_data_pos += sizeof(int); |
---|
2574 | |
---|
2575 | updateQuantizationInfo(intervals); |
---|
2576 | |
---|
2577 | unsigned int tree_size = bytesToInt_bigEndian(comp_data_pos); |
---|
2578 | comp_data_pos += sizeof(int); |
---|
2579 | |
---|
2580 | int stateNum = 2*intervals; |
---|
2581 | HuffmanTree* huffmanTree = createHuffmanTree(stateNum); |
---|
2582 | |
---|
2583 | int nodeCount = bytesToInt_bigEndian(comp_data_pos); |
---|
2584 | node root = reconstruct_HuffTree_from_bytes_anyStates(huffmanTree,comp_data_pos+sizeof(int), nodeCount); |
---|
2585 | comp_data_pos += sizeof(int) + tree_size; |
---|
2586 | |
---|
2587 | float mean; |
---|
2588 | unsigned char use_mean; |
---|
2589 | memcpy(&use_mean, comp_data_pos, sizeof(unsigned char)); |
---|
2590 | comp_data_pos += sizeof(unsigned char); |
---|
2591 | memcpy(&mean, comp_data_pos, sizeof(float)); |
---|
2592 | comp_data_pos += sizeof(float); |
---|
2593 | size_t reg_count = 0; |
---|
2594 | |
---|
2595 | unsigned char * indicator; |
---|
2596 | size_t indicator_bitlength = (num_blocks - 1)/8 + 1; |
---|
2597 | convertByteArray2IntArray_fast_1b(num_blocks, comp_data_pos, indicator_bitlength, &indicator); |
---|
2598 | comp_data_pos += indicator_bitlength; |
---|
2599 | for(size_t i=0; i<num_blocks; i++){ |
---|
2600 | if(!indicator[i]) reg_count ++; |
---|
2601 | } |
---|
2602 | |
---|
2603 | int coeff_intvRadius[4]; |
---|
2604 | int * coeff_result_type = (int *) malloc(num_blocks*4*sizeof(int)); |
---|
2605 | int * coeff_type[4]; |
---|
2606 | double precision[4]; |
---|
2607 | float * coeff_unpred_data[4]; |
---|
2608 | if(reg_count > 0){ |
---|
2609 | for(int i=0; i<4; i++){ |
---|
2610 | precision[i] = bytesToDouble(comp_data_pos); |
---|
2611 | comp_data_pos += sizeof(double); |
---|
2612 | coeff_intvRadius[i] = bytesToInt_bigEndian(comp_data_pos); |
---|
2613 | comp_data_pos += sizeof(int); |
---|
2614 | unsigned int tree_size = bytesToInt_bigEndian(comp_data_pos); |
---|
2615 | comp_data_pos += sizeof(int); |
---|
2616 | int stateNum = 2*coeff_intvRadius[i]*2; |
---|
2617 | HuffmanTree* huffmanTree = createHuffmanTree(stateNum); |
---|
2618 | int nodeCount = bytesToInt_bigEndian(comp_data_pos); |
---|
2619 | node root = reconstruct_HuffTree_from_bytes_anyStates(huffmanTree, comp_data_pos+sizeof(int), nodeCount); |
---|
2620 | comp_data_pos += sizeof(int) + tree_size; |
---|
2621 | |
---|
2622 | coeff_type[i] = coeff_result_type + i * num_blocks; |
---|
2623 | size_t typeArray_size = bytesToSize(comp_data_pos); |
---|
2624 | decode(comp_data_pos + sizeof(size_t), reg_count, root, coeff_type[i]); |
---|
2625 | comp_data_pos += sizeof(size_t) + typeArray_size; |
---|
2626 | int coeff_unpred_count = bytesToInt_bigEndian(comp_data_pos); |
---|
2627 | comp_data_pos += sizeof(int); |
---|
2628 | coeff_unpred_data[i] = (float *) comp_data_pos; |
---|
2629 | comp_data_pos += coeff_unpred_count * sizeof(float); |
---|
2630 | SZ_ReleaseHuffman(huffmanTree); |
---|
2631 | } |
---|
2632 | } |
---|
2633 | float last_coefficients[4] = {0.0}; |
---|
2634 | int coeff_unpred_data_count[4] = {0}; |
---|
2635 | int coeff_index = 0; |
---|
2636 | updateQuantizationInfo(intervals); |
---|
2637 | |
---|
2638 | size_t total_unpred; |
---|
2639 | memcpy(&total_unpred, comp_data_pos, sizeof(size_t)); |
---|
2640 | comp_data_pos += sizeof(size_t); |
---|
2641 | float * unpred_data = (float *) comp_data_pos; |
---|
2642 | comp_data_pos += total_unpred * sizeof(float); |
---|
2643 | |
---|
2644 | int * result_type = (int *) malloc(num_elements * sizeof(int)); |
---|
2645 | decode(comp_data_pos, num_elements, root, result_type); |
---|
2646 | SZ_ReleaseHuffman(huffmanTree); |
---|
2647 | |
---|
2648 | int intvRadius = exe_params->intvRadius; |
---|
2649 | |
---|
2650 | int * type; |
---|
2651 | float * data_pos = *data; |
---|
2652 | size_t offset_x, offset_y, offset_z; |
---|
2653 | size_t current_blockcount_x, current_blockcount_y, current_blockcount_z; |
---|
2654 | size_t cur_unpred_count; |
---|
2655 | unsigned char * indicator_pos = indicator; |
---|
2656 | if(use_mean){ |
---|
2657 | // type = result_type; |
---|
2658 | |
---|
2659 | // for(size_t i=0; i<num_x; i++){ |
---|
2660 | // for(size_t j=0; j<num_y; j++){ |
---|
2661 | // for(size_t k=0; k<num_z; k++){ |
---|
2662 | // offset_x = (i < split_index_x) ? i * early_blockcount_x : i * late_blockcount_x + split_index_x; |
---|
2663 | // offset_y = (j < split_index_y) ? j * early_blockcount_y : j * late_blockcount_y + split_index_y; |
---|
2664 | // offset_z = (k < split_index_z) ? k * early_blockcount_z : k * late_blockcount_z + split_index_z; |
---|
2665 | // data_pos = *data + offset_x * dim0_offset + offset_y * dim1_offset + offset_z; |
---|
2666 | |
---|
2667 | // current_blockcount_x = (i < split_index_x) ? early_blockcount_x : late_blockcount_x; |
---|
2668 | // current_blockcount_y = (j < split_index_y) ? early_blockcount_y : late_blockcount_y; |
---|
2669 | // current_blockcount_z = (k < split_index_z) ? early_blockcount_z : late_blockcount_z; |
---|
2670 | |
---|
2671 | // // type_offset = offset_x * dim0_offset + offset_y * current_blockcount_x * dim1_offset + offset_z * current_blockcount_x * current_blockcount_y; |
---|
2672 | // // type = result_type + type_offset; |
---|
2673 | // size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
2674 | // // index = i * num_y * num_z + j * num_z + k; |
---|
2675 | |
---|
2676 | // // printf("i j k: %ld %ld %ld\toffset: %ld %ld %ld\tindicator: %ld\n", i, j, k, offset_x, offset_y, offset_z, indicator[index]); |
---|
2677 | // if(*indicator_pos){ |
---|
2678 | // // decompress by SZ |
---|
2679 | // // cur_unpred_count = decompressDataSeries_float_3D_blocked_nonblock_pred(data_pos, r1, r2, r3, current_blockcount_x, current_blockcount_y, current_blockcount_z, i, j, k, realPrecision, type, unpred_data); |
---|
2680 | // float * block_data_pos = data_pos; |
---|
2681 | // float pred; |
---|
2682 | // size_t index = 0; |
---|
2683 | // int type_; |
---|
2684 | // // d111 is current data |
---|
2685 | // size_t unpredictable_count = 0; |
---|
2686 | // float d000, d001, d010, d011, d100, d101, d110; |
---|
2687 | // for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
2688 | // for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
2689 | // for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
2690 | // type_ = type[index]; |
---|
2691 | // if(type_ == intvRadius){ |
---|
2692 | // *block_data_pos = mean; |
---|
2693 | // } |
---|
2694 | // else if(type_ == 0){ |
---|
2695 | // *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
2696 | // } |
---|
2697 | // else{ |
---|
2698 | // d000 = d001 = d010 = d011 = d100 = d101 = d110 = 1; |
---|
2699 | // if(i == 0 && ii == 0){ |
---|
2700 | // d000 = d001 = d010 = d011 = 0; |
---|
2701 | // } |
---|
2702 | // if(j == 0 && jj == 0){ |
---|
2703 | // d000 = d001 = d100 = d101 = 0; |
---|
2704 | // } |
---|
2705 | // if(k == 0 && kk == 0){ |
---|
2706 | // d000 = d010 = d100 = d110 = 0; |
---|
2707 | // } |
---|
2708 | // if(d000){ |
---|
2709 | // d000 = block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
2710 | // } |
---|
2711 | // if(d001){ |
---|
2712 | // d001 = block_data_pos[- dim0_offset - dim1_offset]; |
---|
2713 | // } |
---|
2714 | // if(d010){ |
---|
2715 | // d010 = block_data_pos[- dim0_offset - 1]; |
---|
2716 | // } |
---|
2717 | // if(d011){ |
---|
2718 | // d011 = block_data_pos[- dim0_offset]; |
---|
2719 | // } |
---|
2720 | // if(d100){ |
---|
2721 | // d100 = block_data_pos[- dim1_offset - 1]; |
---|
2722 | // } |
---|
2723 | // if(d101){ |
---|
2724 | // d101 = block_data_pos[- dim1_offset]; |
---|
2725 | // } |
---|
2726 | // if(d110){ |
---|
2727 | // d110 = block_data_pos[- 1]; |
---|
2728 | // } |
---|
2729 | // if(type_ < intvRadius) type_ += 1; |
---|
2730 | // pred = d110 + d101 + d011 - d100 - d010 - d001 + d000; |
---|
2731 | // *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
2732 | // } |
---|
2733 | // index ++; |
---|
2734 | // block_data_pos ++; |
---|
2735 | // } |
---|
2736 | // block_data_pos += dim1_offset - current_blockcount_z; |
---|
2737 | // } |
---|
2738 | // block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
2739 | // } |
---|
2740 | // cur_unpred_count = unpredictable_count; |
---|
2741 | // } |
---|
2742 | // else{ |
---|
2743 | // // decompress by regression |
---|
2744 | // { |
---|
2745 | // //restore regression coefficients |
---|
2746 | // float pred; |
---|
2747 | // int type_; |
---|
2748 | // for(int e=0; e<4; e++){ |
---|
2749 | // // if(i == 0 && j == 0 && k == 19){ |
---|
2750 | // // printf("~\n"); |
---|
2751 | // // } |
---|
2752 | // type_ = coeff_type[e][coeff_index]; |
---|
2753 | // if (type_ != 0){ |
---|
2754 | // pred = last_coefficients[e]; |
---|
2755 | // last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
2756 | // } |
---|
2757 | // else{ |
---|
2758 | // last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
2759 | // coeff_unpred_data_count[e] ++; |
---|
2760 | // } |
---|
2761 | // if(fabs(last_coefficients[e]) > 10000){ |
---|
2762 | // printf("%d %d %d-%d: pred %.4f type %d precision %.4g last_coefficients %.4g\n", i, j, k, e, pred, type_, precision[e], last_coefficients[e]); |
---|
2763 | // exit(0); |
---|
2764 | // } |
---|
2765 | // } |
---|
2766 | // coeff_index ++; |
---|
2767 | // } |
---|
2768 | // { |
---|
2769 | // float * block_data_pos = data_pos; |
---|
2770 | // float pred; |
---|
2771 | // int type_; |
---|
2772 | // size_t index = 0; |
---|
2773 | // size_t unpredictable_count = 0; |
---|
2774 | // for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
2775 | // for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
2776 | // for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
2777 | // if(block_data_pos - (*data) == 19470788){ |
---|
2778 | // printf("dec stop\n"); |
---|
2779 | // } |
---|
2780 | |
---|
2781 | // type_ = type[index]; |
---|
2782 | // if (type_ != 0){ |
---|
2783 | // pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
2784 | // *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
2785 | // } |
---|
2786 | // else{ |
---|
2787 | // *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
2788 | // } |
---|
2789 | // index ++; |
---|
2790 | // block_data_pos ++; |
---|
2791 | // } |
---|
2792 | // block_data_pos += dim1_offset - current_blockcount_z; |
---|
2793 | // } |
---|
2794 | // block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
2795 | // } |
---|
2796 | // cur_unpred_count = unpredictable_count; |
---|
2797 | // } |
---|
2798 | // } |
---|
2799 | |
---|
2800 | // type += current_block_elements; |
---|
2801 | // indicator_pos ++; |
---|
2802 | // unpred_data += cur_unpred_count; |
---|
2803 | // // decomp_unpred += cur_unpred_count; |
---|
2804 | // // printf("block comp done, data_offset from %ld to %ld: diff %ld\n", *data, data_pos, data_pos - *data); |
---|
2805 | // // fflush(stdout); |
---|
2806 | // } |
---|
2807 | // } |
---|
2808 | // } |
---|
2809 | |
---|
2810 | type = result_type; |
---|
2811 | // i == 0 |
---|
2812 | { |
---|
2813 | // j == 0 |
---|
2814 | { |
---|
2815 | // k == 0 |
---|
2816 | { |
---|
2817 | data_pos = *data; |
---|
2818 | |
---|
2819 | current_blockcount_x = early_blockcount_x; |
---|
2820 | current_blockcount_y = early_blockcount_y; |
---|
2821 | current_blockcount_z = early_blockcount_z; |
---|
2822 | size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
2823 | if(*indicator_pos){ |
---|
2824 | // decompress by SZ |
---|
2825 | float * block_data_pos = data_pos; |
---|
2826 | float pred; |
---|
2827 | size_t index = 0; |
---|
2828 | int type_; |
---|
2829 | size_t unpredictable_count = 0; |
---|
2830 | // ii == 0 |
---|
2831 | { |
---|
2832 | // jj == 0 |
---|
2833 | { |
---|
2834 | { |
---|
2835 | // kk == 0 |
---|
2836 | type_ = type[index]; |
---|
2837 | if(type_ == intvRadius){ |
---|
2838 | *block_data_pos = mean; |
---|
2839 | } |
---|
2840 | else if(type_ == 0){ |
---|
2841 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
2842 | } |
---|
2843 | else{ |
---|
2844 | if(type_ < intvRadius) type_ += 1; |
---|
2845 | pred = 0; |
---|
2846 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
2847 | } |
---|
2848 | index ++; |
---|
2849 | block_data_pos ++; |
---|
2850 | } |
---|
2851 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
2852 | type_ = type[index]; |
---|
2853 | if(type_ == intvRadius){ |
---|
2854 | *block_data_pos = mean; |
---|
2855 | } |
---|
2856 | else if(type_ == 0){ |
---|
2857 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
2858 | } |
---|
2859 | else{ |
---|
2860 | if(type_ < intvRadius) type_ += 1; |
---|
2861 | pred = block_data_pos[- 1]; |
---|
2862 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
2863 | } |
---|
2864 | index ++; |
---|
2865 | block_data_pos ++; |
---|
2866 | } |
---|
2867 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
2868 | } |
---|
2869 | for(size_t jj=1; jj<current_blockcount_y; jj++){ |
---|
2870 | { |
---|
2871 | // kk == 0 |
---|
2872 | type_ = type[index]; |
---|
2873 | if(type_ == intvRadius){ |
---|
2874 | *block_data_pos = mean; |
---|
2875 | } |
---|
2876 | else if(type_ == 0){ |
---|
2877 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
2878 | } |
---|
2879 | else{ |
---|
2880 | if(type_ < intvRadius) type_ += 1; |
---|
2881 | pred = block_data_pos[- dim1_offset]; |
---|
2882 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
2883 | } |
---|
2884 | index ++; |
---|
2885 | block_data_pos ++; |
---|
2886 | } |
---|
2887 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
2888 | type_ = type[index]; |
---|
2889 | if(type_ == intvRadius){ |
---|
2890 | *block_data_pos = mean; |
---|
2891 | } |
---|
2892 | else if(type_ == 0){ |
---|
2893 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
2894 | } |
---|
2895 | else{ |
---|
2896 | if(type_ < intvRadius) type_ += 1; |
---|
2897 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] - block_data_pos[- dim1_offset - 1]; |
---|
2898 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
2899 | } |
---|
2900 | index ++; |
---|
2901 | block_data_pos ++; |
---|
2902 | } |
---|
2903 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
2904 | } |
---|
2905 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
2906 | } |
---|
2907 | for(size_t ii=1; ii<current_blockcount_x; ii++){ |
---|
2908 | // jj == 0 |
---|
2909 | { |
---|
2910 | { |
---|
2911 | // kk == 0 |
---|
2912 | type_ = type[index]; |
---|
2913 | if(type_ == intvRadius){ |
---|
2914 | *block_data_pos = mean; |
---|
2915 | } |
---|
2916 | else if(type_ == 0){ |
---|
2917 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
2918 | } |
---|
2919 | else{ |
---|
2920 | if(type_ < intvRadius) type_ += 1; |
---|
2921 | pred = block_data_pos[- dim0_offset]; |
---|
2922 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
2923 | } |
---|
2924 | index ++; |
---|
2925 | block_data_pos ++; |
---|
2926 | } |
---|
2927 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
2928 | type_ = type[index]; |
---|
2929 | if(type_ == intvRadius){ |
---|
2930 | *block_data_pos = mean; |
---|
2931 | } |
---|
2932 | else if(type_ == 0){ |
---|
2933 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
2934 | } |
---|
2935 | else{ |
---|
2936 | if(type_ < intvRadius) type_ += 1; |
---|
2937 | pred = block_data_pos[- 1] + block_data_pos[- dim0_offset] - block_data_pos[- dim0_offset - 1]; |
---|
2938 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
2939 | } |
---|
2940 | index ++; |
---|
2941 | block_data_pos ++; |
---|
2942 | } |
---|
2943 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
2944 | } |
---|
2945 | for(size_t jj=1; jj<current_blockcount_y; jj++){ |
---|
2946 | { |
---|
2947 | // kk == 0 |
---|
2948 | type_ = type[index]; |
---|
2949 | if(type_ == intvRadius){ |
---|
2950 | *block_data_pos = mean; |
---|
2951 | } |
---|
2952 | else if(type_ == 0){ |
---|
2953 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
2954 | } |
---|
2955 | else{ |
---|
2956 | if(type_ < intvRadius) type_ += 1; |
---|
2957 | pred = block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim0_offset - dim1_offset]; |
---|
2958 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
2959 | } |
---|
2960 | index ++; |
---|
2961 | block_data_pos ++; |
---|
2962 | } |
---|
2963 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
2964 | type_ = type[index]; |
---|
2965 | if(type_ == intvRadius){ |
---|
2966 | *block_data_pos = mean; |
---|
2967 | } |
---|
2968 | else if(type_ == 0){ |
---|
2969 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
2970 | } |
---|
2971 | else{ |
---|
2972 | if(type_ < intvRadius) type_ += 1; |
---|
2973 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim1_offset - 1] - block_data_pos[- dim0_offset - 1] - block_data_pos[- dim0_offset - dim1_offset] + block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
2974 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
2975 | } |
---|
2976 | index ++; |
---|
2977 | block_data_pos ++; |
---|
2978 | } |
---|
2979 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
2980 | } |
---|
2981 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
2982 | } |
---|
2983 | cur_unpred_count = unpredictable_count; |
---|
2984 | } |
---|
2985 | else{ |
---|
2986 | // decompress by regression |
---|
2987 | { |
---|
2988 | //restore regression coefficients |
---|
2989 | float pred; |
---|
2990 | int type_; |
---|
2991 | for(int e=0; e<4; e++){ |
---|
2992 | type_ = coeff_type[e][coeff_index]; |
---|
2993 | if (type_ != 0){ |
---|
2994 | pred = last_coefficients[e]; |
---|
2995 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
2996 | } |
---|
2997 | else{ |
---|
2998 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
2999 | coeff_unpred_data_count[e] ++; |
---|
3000 | } |
---|
3001 | } |
---|
3002 | coeff_index ++; |
---|
3003 | } |
---|
3004 | { |
---|
3005 | float * block_data_pos = data_pos; |
---|
3006 | float pred; |
---|
3007 | int type_; |
---|
3008 | size_t index = 0; |
---|
3009 | size_t unpredictable_count = 0; |
---|
3010 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
3011 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
3012 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3013 | type_ = type[index]; |
---|
3014 | if (type_ != 0){ |
---|
3015 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
3016 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3017 | } |
---|
3018 | else{ |
---|
3019 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3020 | } |
---|
3021 | index ++; |
---|
3022 | block_data_pos ++; |
---|
3023 | } |
---|
3024 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3025 | } |
---|
3026 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3027 | } |
---|
3028 | cur_unpred_count = unpredictable_count; |
---|
3029 | } |
---|
3030 | } |
---|
3031 | indicator_pos ++; |
---|
3032 | type += current_block_elements; |
---|
3033 | unpred_data += cur_unpred_count; |
---|
3034 | } // end k == 0 |
---|
3035 | // i == 0 j == 0 k != 0 |
---|
3036 | for(size_t k=1; k<num_z; k++){ |
---|
3037 | offset_z = (k < split_index_z) ? k * early_blockcount_z : k * late_blockcount_z + split_index_z; |
---|
3038 | data_pos = *data + offset_z; |
---|
3039 | |
---|
3040 | current_blockcount_x = early_blockcount_x; |
---|
3041 | current_blockcount_y = early_blockcount_y; |
---|
3042 | current_blockcount_z = (k < split_index_z) ? early_blockcount_z : late_blockcount_z; |
---|
3043 | |
---|
3044 | size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
3045 | if(*indicator_pos){ |
---|
3046 | // decompress by SZ |
---|
3047 | float * block_data_pos = data_pos; |
---|
3048 | float pred; |
---|
3049 | size_t index = 0; |
---|
3050 | int type_; |
---|
3051 | size_t unpredictable_count = 0; |
---|
3052 | // ii == 0 |
---|
3053 | { |
---|
3054 | // jj == 0 |
---|
3055 | { |
---|
3056 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3057 | type_ = type[index]; |
---|
3058 | if(type_ == intvRadius){ |
---|
3059 | *block_data_pos = mean; |
---|
3060 | } |
---|
3061 | else if(type_ == 0){ |
---|
3062 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3063 | } |
---|
3064 | else{ |
---|
3065 | if(type_ < intvRadius) type_ += 1; |
---|
3066 | pred = block_data_pos[- 1]; |
---|
3067 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3068 | } |
---|
3069 | index ++; |
---|
3070 | block_data_pos ++; |
---|
3071 | } |
---|
3072 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3073 | } |
---|
3074 | for(size_t jj=1; jj<current_blockcount_y; jj++){ |
---|
3075 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3076 | type_ = type[index]; |
---|
3077 | if(type_ == intvRadius){ |
---|
3078 | *block_data_pos = mean; |
---|
3079 | } |
---|
3080 | else if(type_ == 0){ |
---|
3081 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3082 | } |
---|
3083 | else{ |
---|
3084 | if(type_ < intvRadius) type_ += 1; |
---|
3085 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] - block_data_pos[- dim1_offset - 1]; |
---|
3086 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3087 | } |
---|
3088 | index ++; |
---|
3089 | block_data_pos ++; |
---|
3090 | } |
---|
3091 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3092 | } |
---|
3093 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3094 | } |
---|
3095 | for(size_t ii=1; ii<current_blockcount_x; ii++){ |
---|
3096 | // jj == 0 |
---|
3097 | { |
---|
3098 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3099 | type_ = type[index]; |
---|
3100 | if(type_ == intvRadius){ |
---|
3101 | *block_data_pos = mean; |
---|
3102 | } |
---|
3103 | else if(type_ == 0){ |
---|
3104 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3105 | } |
---|
3106 | else{ |
---|
3107 | if(type_ < intvRadius) type_ += 1; |
---|
3108 | pred = block_data_pos[- 1] + block_data_pos[- dim0_offset] - block_data_pos[- dim0_offset - 1]; |
---|
3109 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3110 | } |
---|
3111 | index ++; |
---|
3112 | block_data_pos ++; |
---|
3113 | } |
---|
3114 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3115 | } |
---|
3116 | for(size_t jj=1; jj<current_blockcount_y; jj++){ |
---|
3117 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3118 | type_ = type[index]; |
---|
3119 | if(type_ == intvRadius){ |
---|
3120 | *block_data_pos = mean; |
---|
3121 | } |
---|
3122 | else if(type_ == 0){ |
---|
3123 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3124 | } |
---|
3125 | else{ |
---|
3126 | if(type_ < intvRadius) type_ += 1; |
---|
3127 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim1_offset - 1] - block_data_pos[- dim0_offset - 1] - block_data_pos[- dim0_offset - dim1_offset] + block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
3128 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3129 | } |
---|
3130 | index ++; |
---|
3131 | block_data_pos ++; |
---|
3132 | } |
---|
3133 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3134 | } |
---|
3135 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3136 | } |
---|
3137 | cur_unpred_count = unpredictable_count; |
---|
3138 | } |
---|
3139 | else{ |
---|
3140 | // decompress by regression |
---|
3141 | { |
---|
3142 | //restore regression coefficients |
---|
3143 | float pred; |
---|
3144 | int type_; |
---|
3145 | for(int e=0; e<4; e++){ |
---|
3146 | type_ = coeff_type[e][coeff_index]; |
---|
3147 | if (type_ != 0){ |
---|
3148 | pred = last_coefficients[e]; |
---|
3149 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
3150 | } |
---|
3151 | else{ |
---|
3152 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
3153 | coeff_unpred_data_count[e] ++; |
---|
3154 | } |
---|
3155 | } |
---|
3156 | coeff_index ++; |
---|
3157 | } |
---|
3158 | { |
---|
3159 | float * block_data_pos = data_pos; |
---|
3160 | float pred; |
---|
3161 | int type_; |
---|
3162 | size_t index = 0; |
---|
3163 | size_t unpredictable_count = 0; |
---|
3164 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
3165 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
3166 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3167 | type_ = type[index]; |
---|
3168 | if (type_ != 0){ |
---|
3169 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
3170 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3171 | } |
---|
3172 | else{ |
---|
3173 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3174 | } |
---|
3175 | index ++; |
---|
3176 | block_data_pos ++; |
---|
3177 | } |
---|
3178 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3179 | } |
---|
3180 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3181 | } |
---|
3182 | cur_unpred_count = unpredictable_count; |
---|
3183 | } |
---|
3184 | } |
---|
3185 | indicator_pos ++; |
---|
3186 | type += current_block_elements; |
---|
3187 | unpred_data += cur_unpred_count; |
---|
3188 | } |
---|
3189 | }// end j==0 |
---|
3190 | for(size_t j=1; j<num_y; j++){ |
---|
3191 | // k == 0 |
---|
3192 | { |
---|
3193 | offset_y = (j < split_index_y) ? j * early_blockcount_y : j * late_blockcount_y + split_index_y; |
---|
3194 | data_pos = *data + offset_y * dim1_offset; |
---|
3195 | |
---|
3196 | current_blockcount_x = early_blockcount_x; |
---|
3197 | current_blockcount_y = (j < split_index_y) ? early_blockcount_y : late_blockcount_y; |
---|
3198 | current_blockcount_z = early_blockcount_z; |
---|
3199 | size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
3200 | if(*indicator_pos){ |
---|
3201 | // decompress by SZ |
---|
3202 | float * block_data_pos = data_pos; |
---|
3203 | float pred; |
---|
3204 | size_t index = 0; |
---|
3205 | int type_; |
---|
3206 | size_t unpredictable_count = 0; |
---|
3207 | // ii == 0 |
---|
3208 | { |
---|
3209 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
3210 | { |
---|
3211 | // kk == 0 |
---|
3212 | type_ = type[index]; |
---|
3213 | if(type_ == intvRadius){ |
---|
3214 | *block_data_pos = mean; |
---|
3215 | } |
---|
3216 | else if(type_ == 0){ |
---|
3217 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3218 | } |
---|
3219 | else{ |
---|
3220 | if(type_ < intvRadius) type_ += 1; |
---|
3221 | pred = block_data_pos[- dim1_offset]; |
---|
3222 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3223 | } |
---|
3224 | index ++; |
---|
3225 | block_data_pos ++; |
---|
3226 | } |
---|
3227 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
3228 | type_ = type[index]; |
---|
3229 | if(type_ == intvRadius){ |
---|
3230 | *block_data_pos = mean; |
---|
3231 | } |
---|
3232 | else if(type_ == 0){ |
---|
3233 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3234 | } |
---|
3235 | else{ |
---|
3236 | if(type_ < intvRadius) type_ += 1; |
---|
3237 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] - block_data_pos[- dim1_offset - 1]; |
---|
3238 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3239 | } |
---|
3240 | index ++; |
---|
3241 | block_data_pos ++; |
---|
3242 | } |
---|
3243 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3244 | } |
---|
3245 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3246 | } |
---|
3247 | for(size_t ii=1; ii<current_blockcount_x; ii++){ |
---|
3248 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
3249 | { |
---|
3250 | // kk == 0 |
---|
3251 | type_ = type[index]; |
---|
3252 | if(type_ == intvRadius){ |
---|
3253 | *block_data_pos = mean; |
---|
3254 | } |
---|
3255 | else if(type_ == 0){ |
---|
3256 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3257 | } |
---|
3258 | else{ |
---|
3259 | if(type_ < intvRadius) type_ += 1; |
---|
3260 | pred = block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim0_offset - dim1_offset]; |
---|
3261 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3262 | } |
---|
3263 | index ++; |
---|
3264 | block_data_pos ++; |
---|
3265 | } |
---|
3266 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
3267 | type_ = type[index]; |
---|
3268 | if(type_ == intvRadius){ |
---|
3269 | *block_data_pos = mean; |
---|
3270 | } |
---|
3271 | else if(type_ == 0){ |
---|
3272 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3273 | } |
---|
3274 | else{ |
---|
3275 | if(type_ < intvRadius) type_ += 1; |
---|
3276 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim1_offset - 1] - block_data_pos[- dim0_offset - 1] - block_data_pos[- dim0_offset - dim1_offset] + block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
3277 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3278 | } |
---|
3279 | index ++; |
---|
3280 | block_data_pos ++; |
---|
3281 | } |
---|
3282 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3283 | } |
---|
3284 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3285 | } |
---|
3286 | cur_unpred_count = unpredictable_count; |
---|
3287 | } |
---|
3288 | else{ |
---|
3289 | // decompress by regression |
---|
3290 | { |
---|
3291 | //restore regression coefficients |
---|
3292 | float pred; |
---|
3293 | int type_; |
---|
3294 | for(int e=0; e<4; e++){ |
---|
3295 | type_ = coeff_type[e][coeff_index]; |
---|
3296 | if (type_ != 0){ |
---|
3297 | pred = last_coefficients[e]; |
---|
3298 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
3299 | } |
---|
3300 | else{ |
---|
3301 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
3302 | coeff_unpred_data_count[e] ++; |
---|
3303 | } |
---|
3304 | } |
---|
3305 | coeff_index ++; |
---|
3306 | } |
---|
3307 | { |
---|
3308 | float * block_data_pos = data_pos; |
---|
3309 | float pred; |
---|
3310 | int type_; |
---|
3311 | size_t index = 0; |
---|
3312 | size_t unpredictable_count = 0; |
---|
3313 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
3314 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
3315 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3316 | type_ = type[index]; |
---|
3317 | if (type_ != 0){ |
---|
3318 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
3319 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3320 | } |
---|
3321 | else{ |
---|
3322 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3323 | } |
---|
3324 | index ++; |
---|
3325 | block_data_pos ++; |
---|
3326 | } |
---|
3327 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3328 | } |
---|
3329 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3330 | } |
---|
3331 | cur_unpred_count = unpredictable_count; |
---|
3332 | } |
---|
3333 | } |
---|
3334 | indicator_pos ++; |
---|
3335 | type += current_block_elements; |
---|
3336 | unpred_data += cur_unpred_count; |
---|
3337 | } // end k == 0 |
---|
3338 | for(size_t k=1; k<num_z; k++){ |
---|
3339 | offset_y = (j < split_index_y) ? j * early_blockcount_y : j * late_blockcount_y + split_index_y; |
---|
3340 | offset_z = (k < split_index_z) ? k * early_blockcount_z : k * late_blockcount_z + split_index_z; |
---|
3341 | data_pos = *data + offset_y * dim1_offset + offset_z; |
---|
3342 | |
---|
3343 | current_blockcount_x = early_blockcount_x; |
---|
3344 | current_blockcount_y = (j < split_index_y) ? early_blockcount_y : late_blockcount_y; |
---|
3345 | current_blockcount_z = (k < split_index_z) ? early_blockcount_z : late_blockcount_z; |
---|
3346 | |
---|
3347 | size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
3348 | if(*indicator_pos){ |
---|
3349 | // decompress by SZ |
---|
3350 | float * block_data_pos = data_pos; |
---|
3351 | float pred; |
---|
3352 | size_t index = 0; |
---|
3353 | int type_; |
---|
3354 | size_t unpredictable_count = 0; |
---|
3355 | // ii == 0 |
---|
3356 | { |
---|
3357 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
3358 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3359 | type_ = type[index]; |
---|
3360 | if(type_ == intvRadius){ |
---|
3361 | *block_data_pos = mean; |
---|
3362 | } |
---|
3363 | else if(type_ == 0){ |
---|
3364 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3365 | } |
---|
3366 | else{ |
---|
3367 | if(type_ < intvRadius) type_ += 1; |
---|
3368 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] - block_data_pos[- dim1_offset - 1]; |
---|
3369 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3370 | } |
---|
3371 | index ++; |
---|
3372 | block_data_pos ++; |
---|
3373 | } |
---|
3374 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3375 | } |
---|
3376 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3377 | } |
---|
3378 | for(size_t ii=1; ii<current_blockcount_x; ii++){ |
---|
3379 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
3380 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3381 | type_ = type[index]; |
---|
3382 | if(type_ == intvRadius){ |
---|
3383 | *block_data_pos = mean; |
---|
3384 | } |
---|
3385 | else if(type_ == 0){ |
---|
3386 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3387 | } |
---|
3388 | else{ |
---|
3389 | if(type_ < intvRadius) type_ += 1; |
---|
3390 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim1_offset - 1] - block_data_pos[- dim0_offset - 1] - block_data_pos[- dim0_offset - dim1_offset] + block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
3391 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3392 | } |
---|
3393 | index ++; |
---|
3394 | block_data_pos ++; |
---|
3395 | } |
---|
3396 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3397 | } |
---|
3398 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3399 | } |
---|
3400 | cur_unpred_count = unpredictable_count; |
---|
3401 | } |
---|
3402 | else{ |
---|
3403 | // decompress by regression |
---|
3404 | { |
---|
3405 | //restore regression coefficients |
---|
3406 | float pred; |
---|
3407 | int type_; |
---|
3408 | for(int e=0; e<4; e++){ |
---|
3409 | type_ = coeff_type[e][coeff_index]; |
---|
3410 | if (type_ != 0){ |
---|
3411 | pred = last_coefficients[e]; |
---|
3412 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
3413 | } |
---|
3414 | else{ |
---|
3415 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
3416 | coeff_unpred_data_count[e] ++; |
---|
3417 | } |
---|
3418 | } |
---|
3419 | coeff_index ++; |
---|
3420 | } |
---|
3421 | { |
---|
3422 | float * block_data_pos = data_pos; |
---|
3423 | float pred; |
---|
3424 | int type_; |
---|
3425 | size_t index = 0; |
---|
3426 | size_t unpredictable_count = 0; |
---|
3427 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
3428 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
3429 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3430 | type_ = type[index]; |
---|
3431 | if (type_ != 0){ |
---|
3432 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
3433 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3434 | } |
---|
3435 | else{ |
---|
3436 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3437 | } |
---|
3438 | index ++; |
---|
3439 | block_data_pos ++; |
---|
3440 | } |
---|
3441 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3442 | } |
---|
3443 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3444 | } |
---|
3445 | cur_unpred_count = unpredictable_count; |
---|
3446 | } |
---|
3447 | } |
---|
3448 | indicator_pos ++; |
---|
3449 | type += current_block_elements; |
---|
3450 | unpred_data += cur_unpred_count; |
---|
3451 | } |
---|
3452 | } |
---|
3453 | } // end i==0 |
---|
3454 | for(size_t i=1; i<num_x; i++){ |
---|
3455 | // j == 0 |
---|
3456 | { |
---|
3457 | // k == 0 |
---|
3458 | { |
---|
3459 | offset_x = (i < split_index_x) ? i * early_blockcount_x : i * late_blockcount_x + split_index_x; |
---|
3460 | data_pos = *data + offset_x * dim0_offset; |
---|
3461 | |
---|
3462 | current_blockcount_x = (i < split_index_x) ? early_blockcount_x : late_blockcount_x; |
---|
3463 | current_blockcount_y = early_blockcount_y; |
---|
3464 | current_blockcount_z = early_blockcount_z; |
---|
3465 | size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
3466 | if(*indicator_pos){ |
---|
3467 | // decompress by SZ |
---|
3468 | float * block_data_pos = data_pos; |
---|
3469 | float pred; |
---|
3470 | size_t index = 0; |
---|
3471 | int type_; |
---|
3472 | size_t unpredictable_count = 0; |
---|
3473 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
3474 | // jj == 0 |
---|
3475 | { |
---|
3476 | { |
---|
3477 | // kk == 0 |
---|
3478 | type_ = type[index]; |
---|
3479 | if(type_ == intvRadius){ |
---|
3480 | *block_data_pos = mean; |
---|
3481 | } |
---|
3482 | else if(type_ == 0){ |
---|
3483 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3484 | } |
---|
3485 | else{ |
---|
3486 | if(type_ < intvRadius) type_ += 1; |
---|
3487 | pred = block_data_pos[- dim0_offset]; |
---|
3488 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3489 | } |
---|
3490 | index ++; |
---|
3491 | block_data_pos ++; |
---|
3492 | } |
---|
3493 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
3494 | type_ = type[index]; |
---|
3495 | if(type_ == intvRadius){ |
---|
3496 | *block_data_pos = mean; |
---|
3497 | } |
---|
3498 | else if(type_ == 0){ |
---|
3499 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3500 | } |
---|
3501 | else{ |
---|
3502 | if(type_ < intvRadius) type_ += 1; |
---|
3503 | pred = block_data_pos[- 1] + block_data_pos[- dim0_offset] - block_data_pos[- dim0_offset - 1]; |
---|
3504 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3505 | } |
---|
3506 | index ++; |
---|
3507 | block_data_pos ++; |
---|
3508 | } |
---|
3509 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3510 | } |
---|
3511 | for(size_t jj=1; jj<current_blockcount_y; jj++){ |
---|
3512 | { |
---|
3513 | // kk == 0 |
---|
3514 | type_ = type[index]; |
---|
3515 | if(type_ == intvRadius){ |
---|
3516 | *block_data_pos = mean; |
---|
3517 | } |
---|
3518 | else if(type_ == 0){ |
---|
3519 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3520 | } |
---|
3521 | else{ |
---|
3522 | if(type_ < intvRadius) type_ += 1; |
---|
3523 | pred = block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim0_offset - dim1_offset]; |
---|
3524 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3525 | } |
---|
3526 | index ++; |
---|
3527 | block_data_pos ++; |
---|
3528 | } |
---|
3529 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
3530 | type_ = type[index]; |
---|
3531 | if(type_ == intvRadius){ |
---|
3532 | *block_data_pos = mean; |
---|
3533 | } |
---|
3534 | else if(type_ == 0){ |
---|
3535 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3536 | } |
---|
3537 | else{ |
---|
3538 | if(type_ < intvRadius) type_ += 1; |
---|
3539 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim1_offset - 1] - block_data_pos[- dim0_offset - 1] - block_data_pos[- dim0_offset - dim1_offset] + block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
3540 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3541 | } |
---|
3542 | index ++; |
---|
3543 | block_data_pos ++; |
---|
3544 | } |
---|
3545 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3546 | } |
---|
3547 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3548 | } |
---|
3549 | cur_unpred_count = unpredictable_count; |
---|
3550 | } |
---|
3551 | else{ |
---|
3552 | // decompress by regression |
---|
3553 | { |
---|
3554 | //restore regression coefficients |
---|
3555 | float pred; |
---|
3556 | int type_; |
---|
3557 | for(int e=0; e<4; e++){ |
---|
3558 | type_ = coeff_type[e][coeff_index]; |
---|
3559 | if (type_ != 0){ |
---|
3560 | pred = last_coefficients[e]; |
---|
3561 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
3562 | } |
---|
3563 | else{ |
---|
3564 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
3565 | coeff_unpred_data_count[e] ++; |
---|
3566 | } |
---|
3567 | } |
---|
3568 | coeff_index ++; |
---|
3569 | } |
---|
3570 | { |
---|
3571 | float * block_data_pos = data_pos; |
---|
3572 | float pred; |
---|
3573 | int type_; |
---|
3574 | size_t index = 0; |
---|
3575 | size_t unpredictable_count = 0; |
---|
3576 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
3577 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
3578 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3579 | type_ = type[index]; |
---|
3580 | if (type_ != 0){ |
---|
3581 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
3582 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3583 | } |
---|
3584 | else{ |
---|
3585 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3586 | } |
---|
3587 | index ++; |
---|
3588 | block_data_pos ++; |
---|
3589 | } |
---|
3590 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3591 | } |
---|
3592 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3593 | } |
---|
3594 | cur_unpred_count = unpredictable_count; |
---|
3595 | } |
---|
3596 | } |
---|
3597 | indicator_pos ++; |
---|
3598 | type += current_block_elements; |
---|
3599 | unpred_data += cur_unpred_count; |
---|
3600 | } // end k == 0 |
---|
3601 | for(size_t k=1; k<num_z; k++){ |
---|
3602 | offset_x = (i < split_index_x) ? i * early_blockcount_x : i * late_blockcount_x + split_index_x; |
---|
3603 | offset_z = (k < split_index_z) ? k * early_blockcount_z : k * late_blockcount_z + split_index_z; |
---|
3604 | data_pos = *data + offset_x * dim0_offset + offset_z; |
---|
3605 | |
---|
3606 | current_blockcount_x = (i < split_index_x) ? early_blockcount_x : late_blockcount_x; |
---|
3607 | current_blockcount_y = early_blockcount_y; |
---|
3608 | current_blockcount_z = (k < split_index_z) ? early_blockcount_z : late_blockcount_z; |
---|
3609 | size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
3610 | if(*indicator_pos){ |
---|
3611 | // decompress by SZ |
---|
3612 | float * block_data_pos = data_pos; |
---|
3613 | float pred; |
---|
3614 | size_t index = 0; |
---|
3615 | int type_; |
---|
3616 | size_t unpredictable_count = 0; |
---|
3617 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
3618 | // jj == 0 |
---|
3619 | { |
---|
3620 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3621 | type_ = type[index]; |
---|
3622 | if(type_ == intvRadius){ |
---|
3623 | *block_data_pos = mean; |
---|
3624 | } |
---|
3625 | else if(type_ == 0){ |
---|
3626 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3627 | } |
---|
3628 | else{ |
---|
3629 | if(type_ < intvRadius) type_ += 1; |
---|
3630 | pred = block_data_pos[- 1] + block_data_pos[- dim0_offset] - block_data_pos[- dim0_offset - 1]; |
---|
3631 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3632 | } |
---|
3633 | index ++; |
---|
3634 | block_data_pos ++; |
---|
3635 | } |
---|
3636 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3637 | } |
---|
3638 | for(size_t jj=1; jj<current_blockcount_y; jj++){ |
---|
3639 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3640 | type_ = type[index]; |
---|
3641 | if(type_ == intvRadius){ |
---|
3642 | *block_data_pos = mean; |
---|
3643 | } |
---|
3644 | else if(type_ == 0){ |
---|
3645 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3646 | } |
---|
3647 | else{ |
---|
3648 | if(type_ < intvRadius) type_ += 1; |
---|
3649 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim1_offset - 1] - block_data_pos[- dim0_offset - 1] - block_data_pos[- dim0_offset - dim1_offset] + block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
3650 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3651 | } |
---|
3652 | index ++; |
---|
3653 | block_data_pos ++; |
---|
3654 | } |
---|
3655 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3656 | } |
---|
3657 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3658 | } |
---|
3659 | cur_unpred_count = unpredictable_count; |
---|
3660 | } |
---|
3661 | else{ |
---|
3662 | // decompress by regression |
---|
3663 | { |
---|
3664 | //restore regression coefficients |
---|
3665 | float pred; |
---|
3666 | int type_; |
---|
3667 | for(int e=0; e<4; e++){ |
---|
3668 | type_ = coeff_type[e][coeff_index]; |
---|
3669 | if (type_ != 0){ |
---|
3670 | pred = last_coefficients[e]; |
---|
3671 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
3672 | } |
---|
3673 | else{ |
---|
3674 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
3675 | coeff_unpred_data_count[e] ++; |
---|
3676 | } |
---|
3677 | } |
---|
3678 | coeff_index ++; |
---|
3679 | } |
---|
3680 | { |
---|
3681 | float * block_data_pos = data_pos; |
---|
3682 | float pred; |
---|
3683 | int type_; |
---|
3684 | size_t index = 0; |
---|
3685 | size_t unpredictable_count = 0; |
---|
3686 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
3687 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
3688 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3689 | type_ = type[index]; |
---|
3690 | if (type_ != 0){ |
---|
3691 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
3692 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3693 | } |
---|
3694 | else{ |
---|
3695 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3696 | } |
---|
3697 | index ++; |
---|
3698 | block_data_pos ++; |
---|
3699 | } |
---|
3700 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3701 | } |
---|
3702 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3703 | } |
---|
3704 | cur_unpred_count = unpredictable_count; |
---|
3705 | } |
---|
3706 | } |
---|
3707 | indicator_pos ++; |
---|
3708 | type += current_block_elements; |
---|
3709 | unpred_data += cur_unpred_count; |
---|
3710 | } |
---|
3711 | }// end j = 0 |
---|
3712 | for(size_t j=1; j<num_y; j++){ |
---|
3713 | // k == 0 |
---|
3714 | { |
---|
3715 | offset_x = (i < split_index_x) ? i * early_blockcount_x : i * late_blockcount_x + split_index_x; |
---|
3716 | offset_y = (j < split_index_y) ? j * early_blockcount_y : j * late_blockcount_y + split_index_y; |
---|
3717 | data_pos = *data + offset_x * dim0_offset + offset_y * dim1_offset; |
---|
3718 | |
---|
3719 | current_blockcount_x = (i < split_index_x) ? early_blockcount_x : late_blockcount_x; |
---|
3720 | current_blockcount_y = (j < split_index_y) ? early_blockcount_y : late_blockcount_y; |
---|
3721 | current_blockcount_z = early_blockcount_z; |
---|
3722 | size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
3723 | if(*indicator_pos){ |
---|
3724 | // decompress by SZ |
---|
3725 | float * block_data_pos = data_pos; |
---|
3726 | float pred; |
---|
3727 | size_t index = 0; |
---|
3728 | int type_; |
---|
3729 | size_t unpredictable_count = 0; |
---|
3730 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
3731 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
3732 | { |
---|
3733 | // kk == 0 |
---|
3734 | type_ = type[index]; |
---|
3735 | if(type_ == intvRadius){ |
---|
3736 | *block_data_pos = mean; |
---|
3737 | } |
---|
3738 | else if(type_ == 0){ |
---|
3739 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3740 | } |
---|
3741 | else{ |
---|
3742 | if(type_ < intvRadius) type_ += 1; |
---|
3743 | pred = block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim0_offset - dim1_offset]; |
---|
3744 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3745 | } |
---|
3746 | index ++; |
---|
3747 | block_data_pos ++; |
---|
3748 | } |
---|
3749 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
3750 | type_ = type[index]; |
---|
3751 | if(type_ == intvRadius){ |
---|
3752 | *block_data_pos = mean; |
---|
3753 | } |
---|
3754 | else if(type_ == 0){ |
---|
3755 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3756 | } |
---|
3757 | else{ |
---|
3758 | if(type_ < intvRadius) type_ += 1; |
---|
3759 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim1_offset - 1] - block_data_pos[- dim0_offset - 1] - block_data_pos[- dim0_offset - dim1_offset] + block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
3760 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3761 | } |
---|
3762 | index ++; |
---|
3763 | block_data_pos ++; |
---|
3764 | } |
---|
3765 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3766 | } |
---|
3767 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3768 | } |
---|
3769 | cur_unpred_count = unpredictable_count; |
---|
3770 | } |
---|
3771 | else{ |
---|
3772 | // decompress by regression |
---|
3773 | { |
---|
3774 | //restore regression coefficients |
---|
3775 | float pred; |
---|
3776 | int type_; |
---|
3777 | for(int e=0; e<4; e++){ |
---|
3778 | type_ = coeff_type[e][coeff_index]; |
---|
3779 | if (type_ != 0){ |
---|
3780 | pred = last_coefficients[e]; |
---|
3781 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
3782 | } |
---|
3783 | else{ |
---|
3784 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
3785 | coeff_unpred_data_count[e] ++; |
---|
3786 | } |
---|
3787 | } |
---|
3788 | coeff_index ++; |
---|
3789 | } |
---|
3790 | { |
---|
3791 | float * block_data_pos = data_pos; |
---|
3792 | float pred; |
---|
3793 | int type_; |
---|
3794 | size_t index = 0; |
---|
3795 | size_t unpredictable_count = 0; |
---|
3796 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
3797 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
3798 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3799 | type_ = type[index]; |
---|
3800 | if (type_ != 0){ |
---|
3801 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
3802 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3803 | } |
---|
3804 | else{ |
---|
3805 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3806 | } |
---|
3807 | index ++; |
---|
3808 | block_data_pos ++; |
---|
3809 | } |
---|
3810 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3811 | } |
---|
3812 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3813 | } |
---|
3814 | cur_unpred_count = unpredictable_count; |
---|
3815 | } |
---|
3816 | } |
---|
3817 | indicator_pos ++; |
---|
3818 | type += current_block_elements; |
---|
3819 | unpred_data += cur_unpred_count; |
---|
3820 | } // end k == 0 |
---|
3821 | for(size_t k=1; k<num_z; k++){ |
---|
3822 | offset_x = (i < split_index_x) ? i * early_blockcount_x : i * late_blockcount_x + split_index_x; |
---|
3823 | offset_y = (j < split_index_y) ? j * early_blockcount_y : j * late_blockcount_y + split_index_y; |
---|
3824 | offset_z = (k < split_index_z) ? k * early_blockcount_z : k * late_blockcount_z + split_index_z; |
---|
3825 | data_pos = *data + offset_x * dim0_offset + offset_y * dim1_offset + offset_z; |
---|
3826 | |
---|
3827 | current_blockcount_x = (i < split_index_x) ? early_blockcount_x : late_blockcount_x; |
---|
3828 | current_blockcount_y = (j < split_index_y) ? early_blockcount_y : late_blockcount_y; |
---|
3829 | current_blockcount_z = (k < split_index_z) ? early_blockcount_z : late_blockcount_z; |
---|
3830 | |
---|
3831 | size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
3832 | if(*indicator_pos){ |
---|
3833 | // decompress by SZ |
---|
3834 | float * block_data_pos = data_pos; |
---|
3835 | float pred; |
---|
3836 | size_t index = 0; |
---|
3837 | int type_; |
---|
3838 | size_t unpredictable_count = 0; |
---|
3839 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
3840 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
3841 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3842 | type_ = type[index]; |
---|
3843 | if(type_ == intvRadius){ |
---|
3844 | *block_data_pos = mean; |
---|
3845 | } |
---|
3846 | else if(type_ == 0){ |
---|
3847 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3848 | } |
---|
3849 | else{ |
---|
3850 | if(type_ < intvRadius) type_ += 1; |
---|
3851 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim1_offset - 1] - block_data_pos[- dim0_offset - 1] - block_data_pos[- dim0_offset - dim1_offset] + block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
3852 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3853 | } |
---|
3854 | index ++; |
---|
3855 | block_data_pos ++; |
---|
3856 | } |
---|
3857 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3858 | } |
---|
3859 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3860 | } |
---|
3861 | cur_unpred_count = unpredictable_count; |
---|
3862 | } |
---|
3863 | else{ |
---|
3864 | // decompress by regression |
---|
3865 | { |
---|
3866 | //restore regression coefficients |
---|
3867 | float pred; |
---|
3868 | int type_; |
---|
3869 | for(int e=0; e<4; e++){ |
---|
3870 | type_ = coeff_type[e][coeff_index]; |
---|
3871 | if (type_ != 0){ |
---|
3872 | pred = last_coefficients[e]; |
---|
3873 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
3874 | } |
---|
3875 | else{ |
---|
3876 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
3877 | coeff_unpred_data_count[e] ++; |
---|
3878 | } |
---|
3879 | } |
---|
3880 | coeff_index ++; |
---|
3881 | } |
---|
3882 | { |
---|
3883 | float * block_data_pos = data_pos; |
---|
3884 | float pred; |
---|
3885 | int type_; |
---|
3886 | size_t index = 0; |
---|
3887 | size_t unpredictable_count = 0; |
---|
3888 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
3889 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
3890 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
3891 | type_ = type[index]; |
---|
3892 | if (type_ != 0){ |
---|
3893 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
3894 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3895 | } |
---|
3896 | else{ |
---|
3897 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3898 | } |
---|
3899 | index ++; |
---|
3900 | block_data_pos ++; |
---|
3901 | } |
---|
3902 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3903 | } |
---|
3904 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3905 | } |
---|
3906 | cur_unpred_count = unpredictable_count; |
---|
3907 | } |
---|
3908 | } |
---|
3909 | indicator_pos ++; |
---|
3910 | type += current_block_elements; |
---|
3911 | unpred_data += cur_unpred_count; |
---|
3912 | } |
---|
3913 | } |
---|
3914 | } |
---|
3915 | } |
---|
3916 | else{ |
---|
3917 | type = result_type; |
---|
3918 | // i == 0 |
---|
3919 | { |
---|
3920 | // j == 0 |
---|
3921 | { |
---|
3922 | // k == 0 |
---|
3923 | { |
---|
3924 | data_pos = *data; |
---|
3925 | |
---|
3926 | current_blockcount_x = early_blockcount_x; |
---|
3927 | current_blockcount_y = early_blockcount_y; |
---|
3928 | current_blockcount_z = early_blockcount_z; |
---|
3929 | size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
3930 | if(*indicator_pos){ |
---|
3931 | // decompress by SZ |
---|
3932 | float * block_data_pos = data_pos; |
---|
3933 | float pred; |
---|
3934 | size_t index = 0; |
---|
3935 | int type_; |
---|
3936 | size_t unpredictable_count = 0; |
---|
3937 | // ii == 0 |
---|
3938 | { |
---|
3939 | // jj == 0 |
---|
3940 | { |
---|
3941 | { |
---|
3942 | // kk == 0 |
---|
3943 | type_ = type[index]; |
---|
3944 | if(type_ == 0){ |
---|
3945 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3946 | } |
---|
3947 | else{ |
---|
3948 | pred = 0; |
---|
3949 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3950 | } |
---|
3951 | index ++; |
---|
3952 | block_data_pos ++; |
---|
3953 | } |
---|
3954 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
3955 | type_ = type[index]; |
---|
3956 | if(type_ == 0){ |
---|
3957 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3958 | } |
---|
3959 | else{ |
---|
3960 | pred = block_data_pos[- 1]; |
---|
3961 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3962 | } |
---|
3963 | index ++; |
---|
3964 | block_data_pos ++; |
---|
3965 | } |
---|
3966 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3967 | } |
---|
3968 | for(size_t jj=1; jj<current_blockcount_y; jj++){ |
---|
3969 | { |
---|
3970 | // kk == 0 |
---|
3971 | type_ = type[index]; |
---|
3972 | if(type_ == 0){ |
---|
3973 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3974 | } |
---|
3975 | else{ |
---|
3976 | pred = block_data_pos[- dim1_offset]; |
---|
3977 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3978 | } |
---|
3979 | index ++; |
---|
3980 | block_data_pos ++; |
---|
3981 | } |
---|
3982 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
3983 | type_ = type[index]; |
---|
3984 | if(type_ == 0){ |
---|
3985 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
3986 | } |
---|
3987 | else{ |
---|
3988 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] - block_data_pos[- dim1_offset - 1]; |
---|
3989 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
3990 | } |
---|
3991 | index ++; |
---|
3992 | block_data_pos ++; |
---|
3993 | } |
---|
3994 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
3995 | } |
---|
3996 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
3997 | } |
---|
3998 | for(size_t ii=1; ii<current_blockcount_x; ii++){ |
---|
3999 | // jj == 0 |
---|
4000 | { |
---|
4001 | { |
---|
4002 | // kk == 0 |
---|
4003 | type_ = type[index]; |
---|
4004 | if(type_ == 0){ |
---|
4005 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4006 | } |
---|
4007 | else{ |
---|
4008 | pred = block_data_pos[- dim0_offset]; |
---|
4009 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4010 | } |
---|
4011 | index ++; |
---|
4012 | block_data_pos ++; |
---|
4013 | } |
---|
4014 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
4015 | type_ = type[index]; |
---|
4016 | if(type_ == 0){ |
---|
4017 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4018 | } |
---|
4019 | else{ |
---|
4020 | pred = block_data_pos[- 1] + block_data_pos[- dim0_offset] - block_data_pos[- dim0_offset - 1]; |
---|
4021 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4022 | } |
---|
4023 | index ++; |
---|
4024 | block_data_pos ++; |
---|
4025 | } |
---|
4026 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4027 | } |
---|
4028 | for(size_t jj=1; jj<current_blockcount_y; jj++){ |
---|
4029 | { |
---|
4030 | // kk == 0 |
---|
4031 | type_ = type[index]; |
---|
4032 | if(type_ == 0){ |
---|
4033 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4034 | } |
---|
4035 | else{ |
---|
4036 | pred = block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim0_offset - dim1_offset]; |
---|
4037 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4038 | } |
---|
4039 | index ++; |
---|
4040 | block_data_pos ++; |
---|
4041 | } |
---|
4042 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
4043 | type_ = type[index]; |
---|
4044 | if(type_ == 0){ |
---|
4045 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4046 | } |
---|
4047 | else{ |
---|
4048 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim1_offset - 1] - block_data_pos[- dim0_offset - 1] - block_data_pos[- dim0_offset - dim1_offset] + block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
4049 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4050 | } |
---|
4051 | index ++; |
---|
4052 | block_data_pos ++; |
---|
4053 | } |
---|
4054 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4055 | } |
---|
4056 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4057 | } |
---|
4058 | cur_unpred_count = unpredictable_count; |
---|
4059 | } |
---|
4060 | else{ |
---|
4061 | // decompress by regression |
---|
4062 | { |
---|
4063 | //restore regression coefficients |
---|
4064 | float pred; |
---|
4065 | int type_; |
---|
4066 | for(int e=0; e<4; e++){ |
---|
4067 | type_ = coeff_type[e][coeff_index]; |
---|
4068 | if (type_ != 0){ |
---|
4069 | pred = last_coefficients[e]; |
---|
4070 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
4071 | } |
---|
4072 | else{ |
---|
4073 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
4074 | coeff_unpred_data_count[e] ++; |
---|
4075 | } |
---|
4076 | } |
---|
4077 | coeff_index ++; |
---|
4078 | } |
---|
4079 | { |
---|
4080 | float * block_data_pos = data_pos; |
---|
4081 | float pred; |
---|
4082 | int type_; |
---|
4083 | size_t index = 0; |
---|
4084 | size_t unpredictable_count = 0; |
---|
4085 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
4086 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
4087 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4088 | type_ = type[index]; |
---|
4089 | if (type_ != 0){ |
---|
4090 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
4091 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4092 | } |
---|
4093 | else{ |
---|
4094 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4095 | } |
---|
4096 | index ++; |
---|
4097 | block_data_pos ++; |
---|
4098 | } |
---|
4099 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4100 | } |
---|
4101 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4102 | } |
---|
4103 | cur_unpred_count = unpredictable_count; |
---|
4104 | } |
---|
4105 | } |
---|
4106 | indicator_pos ++; |
---|
4107 | type += current_block_elements; |
---|
4108 | unpred_data += cur_unpred_count; |
---|
4109 | } // end k == 0 |
---|
4110 | // i == 0 j == 0 k != 0 |
---|
4111 | for(size_t k=1; k<num_z; k++){ |
---|
4112 | offset_z = (k < split_index_z) ? k * early_blockcount_z : k * late_blockcount_z + split_index_z; |
---|
4113 | data_pos = *data + offset_z; |
---|
4114 | |
---|
4115 | current_blockcount_x = early_blockcount_x; |
---|
4116 | current_blockcount_y = early_blockcount_y; |
---|
4117 | current_blockcount_z = (k < split_index_z) ? early_blockcount_z : late_blockcount_z; |
---|
4118 | |
---|
4119 | size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
4120 | if(*indicator_pos){ |
---|
4121 | // decompress by SZ |
---|
4122 | float * block_data_pos = data_pos; |
---|
4123 | float pred; |
---|
4124 | size_t index = 0; |
---|
4125 | int type_; |
---|
4126 | size_t unpredictable_count = 0; |
---|
4127 | // ii == 0 |
---|
4128 | { |
---|
4129 | // jj == 0 |
---|
4130 | { |
---|
4131 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4132 | type_ = type[index]; |
---|
4133 | if(type_ == 0){ |
---|
4134 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4135 | } |
---|
4136 | else{ |
---|
4137 | pred = block_data_pos[- 1]; |
---|
4138 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4139 | } |
---|
4140 | index ++; |
---|
4141 | block_data_pos ++; |
---|
4142 | } |
---|
4143 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4144 | } |
---|
4145 | for(size_t jj=1; jj<current_blockcount_y; jj++){ |
---|
4146 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4147 | type_ = type[index]; |
---|
4148 | if(type_ == 0){ |
---|
4149 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4150 | } |
---|
4151 | else{ |
---|
4152 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] - block_data_pos[- dim1_offset - 1]; |
---|
4153 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4154 | } |
---|
4155 | index ++; |
---|
4156 | block_data_pos ++; |
---|
4157 | } |
---|
4158 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4159 | } |
---|
4160 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4161 | } |
---|
4162 | for(size_t ii=1; ii<current_blockcount_x; ii++){ |
---|
4163 | // jj == 0 |
---|
4164 | { |
---|
4165 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4166 | type_ = type[index]; |
---|
4167 | if(type_ == 0){ |
---|
4168 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4169 | } |
---|
4170 | else{ |
---|
4171 | pred = block_data_pos[- 1] + block_data_pos[- dim0_offset] - block_data_pos[- dim0_offset - 1]; |
---|
4172 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4173 | } |
---|
4174 | index ++; |
---|
4175 | block_data_pos ++; |
---|
4176 | } |
---|
4177 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4178 | } |
---|
4179 | for(size_t jj=1; jj<current_blockcount_y; jj++){ |
---|
4180 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4181 | type_ = type[index]; |
---|
4182 | if(type_ == 0){ |
---|
4183 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4184 | } |
---|
4185 | else{ |
---|
4186 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim1_offset - 1] - block_data_pos[- dim0_offset - 1] - block_data_pos[- dim0_offset - dim1_offset] + block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
4187 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4188 | } |
---|
4189 | index ++; |
---|
4190 | block_data_pos ++; |
---|
4191 | } |
---|
4192 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4193 | } |
---|
4194 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4195 | } |
---|
4196 | cur_unpred_count = unpredictable_count; |
---|
4197 | } |
---|
4198 | else{ |
---|
4199 | // decompress by regression |
---|
4200 | { |
---|
4201 | //restore regression coefficients |
---|
4202 | float pred; |
---|
4203 | int type_; |
---|
4204 | for(int e=0; e<4; e++){ |
---|
4205 | type_ = coeff_type[e][coeff_index]; |
---|
4206 | if (type_ != 0){ |
---|
4207 | pred = last_coefficients[e]; |
---|
4208 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
4209 | } |
---|
4210 | else{ |
---|
4211 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
4212 | coeff_unpred_data_count[e] ++; |
---|
4213 | } |
---|
4214 | } |
---|
4215 | coeff_index ++; |
---|
4216 | } |
---|
4217 | { |
---|
4218 | float * block_data_pos = data_pos; |
---|
4219 | float pred; |
---|
4220 | int type_; |
---|
4221 | size_t index = 0; |
---|
4222 | size_t unpredictable_count = 0; |
---|
4223 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
4224 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
4225 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4226 | type_ = type[index]; |
---|
4227 | if (type_ != 0){ |
---|
4228 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
4229 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4230 | } |
---|
4231 | else{ |
---|
4232 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4233 | } |
---|
4234 | index ++; |
---|
4235 | block_data_pos ++; |
---|
4236 | } |
---|
4237 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4238 | } |
---|
4239 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4240 | } |
---|
4241 | cur_unpred_count = unpredictable_count; |
---|
4242 | } |
---|
4243 | } |
---|
4244 | indicator_pos ++; |
---|
4245 | type += current_block_elements; |
---|
4246 | unpred_data += cur_unpred_count; |
---|
4247 | } |
---|
4248 | }// end j==0 |
---|
4249 | for(size_t j=1; j<num_y; j++){ |
---|
4250 | // k == 0 |
---|
4251 | { |
---|
4252 | offset_y = (j < split_index_y) ? j * early_blockcount_y : j * late_blockcount_y + split_index_y; |
---|
4253 | data_pos = *data + offset_y * dim1_offset; |
---|
4254 | |
---|
4255 | current_blockcount_x = early_blockcount_x; |
---|
4256 | current_blockcount_y = (j < split_index_y) ? early_blockcount_y : late_blockcount_y; |
---|
4257 | current_blockcount_z = early_blockcount_z; |
---|
4258 | size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
4259 | if(*indicator_pos){ |
---|
4260 | // decompress by SZ |
---|
4261 | float * block_data_pos = data_pos; |
---|
4262 | float pred; |
---|
4263 | size_t index = 0; |
---|
4264 | int type_; |
---|
4265 | size_t unpredictable_count = 0; |
---|
4266 | // ii == 0 |
---|
4267 | { |
---|
4268 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
4269 | { |
---|
4270 | // kk == 0 |
---|
4271 | type_ = type[index]; |
---|
4272 | if(type_ == 0){ |
---|
4273 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4274 | } |
---|
4275 | else{ |
---|
4276 | pred = block_data_pos[- dim1_offset]; |
---|
4277 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4278 | } |
---|
4279 | index ++; |
---|
4280 | block_data_pos ++; |
---|
4281 | } |
---|
4282 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
4283 | type_ = type[index]; |
---|
4284 | if(type_ == 0){ |
---|
4285 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4286 | } |
---|
4287 | else{ |
---|
4288 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] - block_data_pos[- dim1_offset - 1]; |
---|
4289 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4290 | } |
---|
4291 | index ++; |
---|
4292 | block_data_pos ++; |
---|
4293 | } |
---|
4294 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4295 | } |
---|
4296 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4297 | } |
---|
4298 | for(size_t ii=1; ii<current_blockcount_x; ii++){ |
---|
4299 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
4300 | { |
---|
4301 | // kk == 0 |
---|
4302 | type_ = type[index]; |
---|
4303 | if(type_ == 0){ |
---|
4304 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4305 | } |
---|
4306 | else{ |
---|
4307 | pred = block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim0_offset - dim1_offset]; |
---|
4308 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4309 | } |
---|
4310 | index ++; |
---|
4311 | block_data_pos ++; |
---|
4312 | } |
---|
4313 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
4314 | type_ = type[index]; |
---|
4315 | if(type_ == 0){ |
---|
4316 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4317 | } |
---|
4318 | else{ |
---|
4319 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim1_offset - 1] - block_data_pos[- dim0_offset - 1] - block_data_pos[- dim0_offset - dim1_offset] + block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
4320 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4321 | } |
---|
4322 | index ++; |
---|
4323 | block_data_pos ++; |
---|
4324 | } |
---|
4325 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4326 | } |
---|
4327 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4328 | } |
---|
4329 | cur_unpred_count = unpredictable_count; |
---|
4330 | } |
---|
4331 | else{ |
---|
4332 | // decompress by regression |
---|
4333 | { |
---|
4334 | //restore regression coefficients |
---|
4335 | float pred; |
---|
4336 | int type_; |
---|
4337 | for(int e=0; e<4; e++){ |
---|
4338 | type_ = coeff_type[e][coeff_index]; |
---|
4339 | if (type_ != 0){ |
---|
4340 | pred = last_coefficients[e]; |
---|
4341 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
4342 | } |
---|
4343 | else{ |
---|
4344 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
4345 | coeff_unpred_data_count[e] ++; |
---|
4346 | } |
---|
4347 | } |
---|
4348 | coeff_index ++; |
---|
4349 | } |
---|
4350 | { |
---|
4351 | float * block_data_pos = data_pos; |
---|
4352 | float pred; |
---|
4353 | int type_; |
---|
4354 | size_t index = 0; |
---|
4355 | size_t unpredictable_count = 0; |
---|
4356 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
4357 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
4358 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4359 | type_ = type[index]; |
---|
4360 | if (type_ != 0){ |
---|
4361 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
4362 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4363 | } |
---|
4364 | else{ |
---|
4365 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4366 | } |
---|
4367 | index ++; |
---|
4368 | block_data_pos ++; |
---|
4369 | } |
---|
4370 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4371 | } |
---|
4372 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4373 | } |
---|
4374 | cur_unpred_count = unpredictable_count; |
---|
4375 | } |
---|
4376 | } |
---|
4377 | indicator_pos ++; |
---|
4378 | type += current_block_elements; |
---|
4379 | unpred_data += cur_unpred_count; |
---|
4380 | } // end k == 0 |
---|
4381 | for(size_t k=1; k<num_z; k++){ |
---|
4382 | offset_y = (j < split_index_y) ? j * early_blockcount_y : j * late_blockcount_y + split_index_y; |
---|
4383 | offset_z = (k < split_index_z) ? k * early_blockcount_z : k * late_blockcount_z + split_index_z; |
---|
4384 | data_pos = *data + offset_y * dim1_offset + offset_z; |
---|
4385 | |
---|
4386 | current_blockcount_x = early_blockcount_x; |
---|
4387 | current_blockcount_y = (j < split_index_y) ? early_blockcount_y : late_blockcount_y; |
---|
4388 | current_blockcount_z = (k < split_index_z) ? early_blockcount_z : late_blockcount_z; |
---|
4389 | |
---|
4390 | size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
4391 | if(*indicator_pos){ |
---|
4392 | // decompress by SZ |
---|
4393 | float * block_data_pos = data_pos; |
---|
4394 | float pred; |
---|
4395 | size_t index = 0; |
---|
4396 | int type_; |
---|
4397 | size_t unpredictable_count = 0; |
---|
4398 | // ii == 0 |
---|
4399 | { |
---|
4400 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
4401 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4402 | type_ = type[index]; |
---|
4403 | if(type_ == 0){ |
---|
4404 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4405 | } |
---|
4406 | else{ |
---|
4407 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] - block_data_pos[- dim1_offset - 1]; |
---|
4408 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4409 | } |
---|
4410 | index ++; |
---|
4411 | block_data_pos ++; |
---|
4412 | } |
---|
4413 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4414 | } |
---|
4415 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4416 | } |
---|
4417 | for(size_t ii=1; ii<current_blockcount_x; ii++){ |
---|
4418 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
4419 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4420 | type_ = type[index]; |
---|
4421 | if(type_ == 0){ |
---|
4422 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4423 | } |
---|
4424 | else{ |
---|
4425 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim1_offset - 1] - block_data_pos[- dim0_offset - 1] - block_data_pos[- dim0_offset - dim1_offset] + block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
4426 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4427 | } |
---|
4428 | index ++; |
---|
4429 | block_data_pos ++; |
---|
4430 | } |
---|
4431 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4432 | } |
---|
4433 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4434 | } |
---|
4435 | cur_unpred_count = unpredictable_count; |
---|
4436 | } |
---|
4437 | else{ |
---|
4438 | // decompress by regression |
---|
4439 | { |
---|
4440 | //restore regression coefficients |
---|
4441 | float pred; |
---|
4442 | int type_; |
---|
4443 | for(int e=0; e<4; e++){ |
---|
4444 | type_ = coeff_type[e][coeff_index]; |
---|
4445 | if (type_ != 0){ |
---|
4446 | pred = last_coefficients[e]; |
---|
4447 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
4448 | } |
---|
4449 | else{ |
---|
4450 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
4451 | coeff_unpred_data_count[e] ++; |
---|
4452 | } |
---|
4453 | } |
---|
4454 | coeff_index ++; |
---|
4455 | } |
---|
4456 | { |
---|
4457 | float * block_data_pos = data_pos; |
---|
4458 | float pred; |
---|
4459 | int type_; |
---|
4460 | size_t index = 0; |
---|
4461 | size_t unpredictable_count = 0; |
---|
4462 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
4463 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
4464 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4465 | type_ = type[index]; |
---|
4466 | if (type_ != 0){ |
---|
4467 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
4468 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4469 | } |
---|
4470 | else{ |
---|
4471 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4472 | } |
---|
4473 | index ++; |
---|
4474 | block_data_pos ++; |
---|
4475 | } |
---|
4476 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4477 | } |
---|
4478 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4479 | } |
---|
4480 | cur_unpred_count = unpredictable_count; |
---|
4481 | } |
---|
4482 | } |
---|
4483 | indicator_pos ++; |
---|
4484 | type += current_block_elements; |
---|
4485 | unpred_data += cur_unpred_count; |
---|
4486 | } |
---|
4487 | } |
---|
4488 | } // end i==0 |
---|
4489 | for(size_t i=1; i<num_x; i++){ |
---|
4490 | // j == 0 |
---|
4491 | { |
---|
4492 | // k == 0 |
---|
4493 | { |
---|
4494 | offset_x = (i < split_index_x) ? i * early_blockcount_x : i * late_blockcount_x + split_index_x; |
---|
4495 | data_pos = *data + offset_x * dim0_offset; |
---|
4496 | |
---|
4497 | current_blockcount_x = (i < split_index_x) ? early_blockcount_x : late_blockcount_x; |
---|
4498 | current_blockcount_y = early_blockcount_y; |
---|
4499 | current_blockcount_z = early_blockcount_z; |
---|
4500 | size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
4501 | if(*indicator_pos){ |
---|
4502 | // decompress by SZ |
---|
4503 | float * block_data_pos = data_pos; |
---|
4504 | float pred; |
---|
4505 | size_t index = 0; |
---|
4506 | int type_; |
---|
4507 | size_t unpredictable_count = 0; |
---|
4508 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
4509 | // jj == 0 |
---|
4510 | { |
---|
4511 | { |
---|
4512 | // kk == 0 |
---|
4513 | type_ = type[index]; |
---|
4514 | if(type_ == 0){ |
---|
4515 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4516 | } |
---|
4517 | else{ |
---|
4518 | pred = block_data_pos[- dim0_offset]; |
---|
4519 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4520 | } |
---|
4521 | index ++; |
---|
4522 | block_data_pos ++; |
---|
4523 | } |
---|
4524 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
4525 | type_ = type[index]; |
---|
4526 | if(type_ == 0){ |
---|
4527 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4528 | } |
---|
4529 | else{ |
---|
4530 | pred = block_data_pos[- 1] + block_data_pos[- dim0_offset] - block_data_pos[- dim0_offset - 1]; |
---|
4531 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4532 | } |
---|
4533 | index ++; |
---|
4534 | block_data_pos ++; |
---|
4535 | } |
---|
4536 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4537 | } |
---|
4538 | for(size_t jj=1; jj<current_blockcount_y; jj++){ |
---|
4539 | { |
---|
4540 | // kk == 0 |
---|
4541 | type_ = type[index]; |
---|
4542 | if(type_ == 0){ |
---|
4543 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4544 | } |
---|
4545 | else{ |
---|
4546 | pred = block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim0_offset - dim1_offset]; |
---|
4547 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4548 | } |
---|
4549 | index ++; |
---|
4550 | block_data_pos ++; |
---|
4551 | } |
---|
4552 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
4553 | type_ = type[index]; |
---|
4554 | if(type_ == 0){ |
---|
4555 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4556 | } |
---|
4557 | else{ |
---|
4558 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim1_offset - 1] - block_data_pos[- dim0_offset - 1] - block_data_pos[- dim0_offset - dim1_offset] + block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
4559 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4560 | } |
---|
4561 | index ++; |
---|
4562 | block_data_pos ++; |
---|
4563 | } |
---|
4564 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4565 | } |
---|
4566 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4567 | } |
---|
4568 | cur_unpred_count = unpredictable_count; |
---|
4569 | } |
---|
4570 | else{ |
---|
4571 | // decompress by regression |
---|
4572 | { |
---|
4573 | //restore regression coefficients |
---|
4574 | float pred; |
---|
4575 | int type_; |
---|
4576 | for(int e=0; e<4; e++){ |
---|
4577 | type_ = coeff_type[e][coeff_index]; |
---|
4578 | if (type_ != 0){ |
---|
4579 | pred = last_coefficients[e]; |
---|
4580 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
4581 | } |
---|
4582 | else{ |
---|
4583 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
4584 | coeff_unpred_data_count[e] ++; |
---|
4585 | } |
---|
4586 | } |
---|
4587 | coeff_index ++; |
---|
4588 | } |
---|
4589 | { |
---|
4590 | float * block_data_pos = data_pos; |
---|
4591 | float pred; |
---|
4592 | int type_; |
---|
4593 | size_t index = 0; |
---|
4594 | size_t unpredictable_count = 0; |
---|
4595 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
4596 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
4597 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4598 | type_ = type[index]; |
---|
4599 | if (type_ != 0){ |
---|
4600 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
4601 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4602 | } |
---|
4603 | else{ |
---|
4604 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4605 | } |
---|
4606 | index ++; |
---|
4607 | block_data_pos ++; |
---|
4608 | } |
---|
4609 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4610 | } |
---|
4611 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4612 | } |
---|
4613 | cur_unpred_count = unpredictable_count; |
---|
4614 | } |
---|
4615 | } |
---|
4616 | indicator_pos ++; |
---|
4617 | type += current_block_elements; |
---|
4618 | unpred_data += cur_unpred_count; |
---|
4619 | } // end k == 0 |
---|
4620 | for(size_t k=1; k<num_z; k++){ |
---|
4621 | offset_x = (i < split_index_x) ? i * early_blockcount_x : i * late_blockcount_x + split_index_x; |
---|
4622 | offset_z = (k < split_index_z) ? k * early_blockcount_z : k * late_blockcount_z + split_index_z; |
---|
4623 | data_pos = *data + offset_x * dim0_offset + offset_z; |
---|
4624 | |
---|
4625 | current_blockcount_x = (i < split_index_x) ? early_blockcount_x : late_blockcount_x; |
---|
4626 | current_blockcount_y = early_blockcount_y; |
---|
4627 | current_blockcount_z = (k < split_index_z) ? early_blockcount_z : late_blockcount_z; |
---|
4628 | |
---|
4629 | size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
4630 | if(*indicator_pos){ |
---|
4631 | // decompress by SZ |
---|
4632 | float * block_data_pos = data_pos; |
---|
4633 | float pred; |
---|
4634 | size_t index = 0; |
---|
4635 | int type_; |
---|
4636 | size_t unpredictable_count = 0; |
---|
4637 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
4638 | // jj == 0 |
---|
4639 | { |
---|
4640 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4641 | type_ = type[index]; |
---|
4642 | if(type_ == 0){ |
---|
4643 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4644 | } |
---|
4645 | else{ |
---|
4646 | pred = block_data_pos[- 1] + block_data_pos[- dim0_offset] - block_data_pos[- dim0_offset - 1]; |
---|
4647 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4648 | } |
---|
4649 | index ++; |
---|
4650 | block_data_pos ++; |
---|
4651 | } |
---|
4652 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4653 | } |
---|
4654 | for(size_t jj=1; jj<current_blockcount_y; jj++){ |
---|
4655 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4656 | type_ = type[index]; |
---|
4657 | if(type_ == 0){ |
---|
4658 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4659 | } |
---|
4660 | else{ |
---|
4661 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim1_offset - 1] - block_data_pos[- dim0_offset - 1] - block_data_pos[- dim0_offset - dim1_offset] + block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
4662 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4663 | } |
---|
4664 | index ++; |
---|
4665 | block_data_pos ++; |
---|
4666 | } |
---|
4667 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4668 | } |
---|
4669 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4670 | } |
---|
4671 | cur_unpred_count = unpredictable_count; |
---|
4672 | } |
---|
4673 | else{ |
---|
4674 | // decompress by regression |
---|
4675 | { |
---|
4676 | //restore regression coefficients |
---|
4677 | float pred; |
---|
4678 | int type_; |
---|
4679 | for(int e=0; e<4; e++){ |
---|
4680 | type_ = coeff_type[e][coeff_index]; |
---|
4681 | if (type_ != 0){ |
---|
4682 | pred = last_coefficients[e]; |
---|
4683 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
4684 | } |
---|
4685 | else{ |
---|
4686 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
4687 | coeff_unpred_data_count[e] ++; |
---|
4688 | } |
---|
4689 | } |
---|
4690 | coeff_index ++; |
---|
4691 | } |
---|
4692 | { |
---|
4693 | float * block_data_pos = data_pos; |
---|
4694 | float pred; |
---|
4695 | int type_; |
---|
4696 | size_t index = 0; |
---|
4697 | size_t unpredictable_count = 0; |
---|
4698 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
4699 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
4700 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4701 | type_ = type[index]; |
---|
4702 | if (type_ != 0){ |
---|
4703 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
4704 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4705 | } |
---|
4706 | else{ |
---|
4707 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4708 | } |
---|
4709 | index ++; |
---|
4710 | block_data_pos ++; |
---|
4711 | } |
---|
4712 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4713 | } |
---|
4714 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4715 | } |
---|
4716 | cur_unpred_count = unpredictable_count; |
---|
4717 | } |
---|
4718 | } |
---|
4719 | indicator_pos ++; |
---|
4720 | type += current_block_elements; |
---|
4721 | unpred_data += cur_unpred_count; |
---|
4722 | } |
---|
4723 | }// end j = 0 |
---|
4724 | for(size_t j=1; j<num_y; j++){ |
---|
4725 | // k == 0 |
---|
4726 | { |
---|
4727 | offset_x = (i < split_index_x) ? i * early_blockcount_x : i * late_blockcount_x + split_index_x; |
---|
4728 | offset_y = (j < split_index_y) ? j * early_blockcount_y : j * late_blockcount_y + split_index_y; |
---|
4729 | data_pos = *data + offset_x * dim0_offset + offset_y * dim1_offset; |
---|
4730 | |
---|
4731 | current_blockcount_x = (i < split_index_x) ? early_blockcount_x : late_blockcount_x; |
---|
4732 | current_blockcount_y = (j < split_index_y) ? early_blockcount_y : late_blockcount_y; |
---|
4733 | current_blockcount_z = early_blockcount_z; |
---|
4734 | size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
4735 | if(*indicator_pos){ |
---|
4736 | // decompress by SZ |
---|
4737 | float * block_data_pos = data_pos; |
---|
4738 | float pred; |
---|
4739 | size_t index = 0; |
---|
4740 | int type_; |
---|
4741 | size_t unpredictable_count = 0; |
---|
4742 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
4743 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
4744 | { |
---|
4745 | // kk == 0 |
---|
4746 | type_ = type[index]; |
---|
4747 | if(type_ == 0){ |
---|
4748 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4749 | } |
---|
4750 | else{ |
---|
4751 | pred = block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim0_offset - dim1_offset]; |
---|
4752 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4753 | } |
---|
4754 | index ++; |
---|
4755 | block_data_pos ++; |
---|
4756 | } |
---|
4757 | for(size_t kk=1; kk<current_blockcount_z; kk++){ |
---|
4758 | type_ = type[index]; |
---|
4759 | if(type_ == 0){ |
---|
4760 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4761 | } |
---|
4762 | else{ |
---|
4763 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim1_offset - 1] - block_data_pos[- dim0_offset - 1] - block_data_pos[- dim0_offset - dim1_offset] + block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
4764 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4765 | } |
---|
4766 | index ++; |
---|
4767 | block_data_pos ++; |
---|
4768 | } |
---|
4769 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4770 | } |
---|
4771 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4772 | } |
---|
4773 | cur_unpred_count = unpredictable_count; |
---|
4774 | } |
---|
4775 | else{ |
---|
4776 | // decompress by regression |
---|
4777 | { |
---|
4778 | //restore regression coefficients |
---|
4779 | float pred; |
---|
4780 | int type_; |
---|
4781 | for(int e=0; e<4; e++){ |
---|
4782 | type_ = coeff_type[e][coeff_index]; |
---|
4783 | if (type_ != 0){ |
---|
4784 | pred = last_coefficients[e]; |
---|
4785 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
4786 | } |
---|
4787 | else{ |
---|
4788 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
4789 | coeff_unpred_data_count[e] ++; |
---|
4790 | } |
---|
4791 | } |
---|
4792 | coeff_index ++; |
---|
4793 | } |
---|
4794 | { |
---|
4795 | float * block_data_pos = data_pos; |
---|
4796 | float pred; |
---|
4797 | int type_; |
---|
4798 | size_t index = 0; |
---|
4799 | size_t unpredictable_count = 0; |
---|
4800 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
4801 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
4802 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4803 | type_ = type[index]; |
---|
4804 | if (type_ != 0){ |
---|
4805 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
4806 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4807 | } |
---|
4808 | else{ |
---|
4809 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4810 | } |
---|
4811 | index ++; |
---|
4812 | block_data_pos ++; |
---|
4813 | } |
---|
4814 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4815 | } |
---|
4816 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4817 | } |
---|
4818 | cur_unpred_count = unpredictable_count; |
---|
4819 | } |
---|
4820 | } |
---|
4821 | indicator_pos ++; |
---|
4822 | type += current_block_elements; |
---|
4823 | unpred_data += cur_unpred_count; |
---|
4824 | } // end k == 0 |
---|
4825 | for(size_t k=1; k<num_z; k++){ |
---|
4826 | offset_x = (i < split_index_x) ? i * early_blockcount_x : i * late_blockcount_x + split_index_x; |
---|
4827 | offset_y = (j < split_index_y) ? j * early_blockcount_y : j * late_blockcount_y + split_index_y; |
---|
4828 | offset_z = (k < split_index_z) ? k * early_blockcount_z : k * late_blockcount_z + split_index_z; |
---|
4829 | data_pos = *data + offset_x * dim0_offset + offset_y * dim1_offset + offset_z; |
---|
4830 | |
---|
4831 | current_blockcount_x = (i < split_index_x) ? early_blockcount_x : late_blockcount_x; |
---|
4832 | current_blockcount_y = (j < split_index_y) ? early_blockcount_y : late_blockcount_y; |
---|
4833 | current_blockcount_z = (k < split_index_z) ? early_blockcount_z : late_blockcount_z; |
---|
4834 | |
---|
4835 | size_t current_block_elements = current_blockcount_x * current_blockcount_y * current_blockcount_z; |
---|
4836 | if(*indicator_pos){ |
---|
4837 | // decompress by SZ |
---|
4838 | float * block_data_pos = data_pos; |
---|
4839 | float pred; |
---|
4840 | size_t index = 0; |
---|
4841 | int type_; |
---|
4842 | size_t unpredictable_count = 0; |
---|
4843 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
4844 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
4845 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4846 | type_ = type[index]; |
---|
4847 | if(type_ == 0){ |
---|
4848 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4849 | } |
---|
4850 | else{ |
---|
4851 | pred = block_data_pos[- 1] + block_data_pos[- dim1_offset] + block_data_pos[- dim0_offset] - block_data_pos[- dim1_offset - 1] - block_data_pos[- dim0_offset - 1] - block_data_pos[- dim0_offset - dim1_offset] + block_data_pos[- dim0_offset - dim1_offset - 1]; |
---|
4852 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4853 | } |
---|
4854 | index ++; |
---|
4855 | block_data_pos ++; |
---|
4856 | } |
---|
4857 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4858 | } |
---|
4859 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4860 | } |
---|
4861 | cur_unpred_count = unpredictable_count; |
---|
4862 | } |
---|
4863 | else{ |
---|
4864 | // decompress by regression |
---|
4865 | { |
---|
4866 | //restore regression coefficients |
---|
4867 | float pred; |
---|
4868 | int type_; |
---|
4869 | for(int e=0; e<4; e++){ |
---|
4870 | type_ = coeff_type[e][coeff_index]; |
---|
4871 | if (type_ != 0){ |
---|
4872 | pred = last_coefficients[e]; |
---|
4873 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
4874 | } |
---|
4875 | else{ |
---|
4876 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
4877 | coeff_unpred_data_count[e] ++; |
---|
4878 | } |
---|
4879 | } |
---|
4880 | coeff_index ++; |
---|
4881 | } |
---|
4882 | { |
---|
4883 | float * block_data_pos = data_pos; |
---|
4884 | float pred; |
---|
4885 | int type_; |
---|
4886 | size_t index = 0; |
---|
4887 | size_t unpredictable_count = 0; |
---|
4888 | for(size_t ii=0; ii<current_blockcount_x; ii++){ |
---|
4889 | for(size_t jj=0; jj<current_blockcount_y; jj++){ |
---|
4890 | for(size_t kk=0; kk<current_blockcount_z; kk++){ |
---|
4891 | type_ = type[index]; |
---|
4892 | if (type_ != 0){ |
---|
4893 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
4894 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
4895 | } |
---|
4896 | else{ |
---|
4897 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
4898 | } |
---|
4899 | index ++; |
---|
4900 | block_data_pos ++; |
---|
4901 | } |
---|
4902 | block_data_pos += dim1_offset - current_blockcount_z; |
---|
4903 | } |
---|
4904 | block_data_pos += dim0_offset - current_blockcount_y * dim1_offset; |
---|
4905 | } |
---|
4906 | cur_unpred_count = unpredictable_count; |
---|
4907 | } |
---|
4908 | } |
---|
4909 | indicator_pos ++; |
---|
4910 | type += current_block_elements; |
---|
4911 | unpred_data += cur_unpred_count; |
---|
4912 | } |
---|
4913 | } |
---|
4914 | } |
---|
4915 | } |
---|
4916 | |
---|
4917 | #ifdef HAVE_TIMECMPR |
---|
4918 | if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
4919 | memcpy(multisteps->hist_data, (*data), num_elements*sizeof(float)); |
---|
4920 | #endif |
---|
4921 | |
---|
4922 | free(coeff_result_type); |
---|
4923 | |
---|
4924 | free(indicator); |
---|
4925 | free(result_type); |
---|
4926 | } |
---|
4927 | |
---|
4928 | void decompressDataSeries_float_3D_random_access_with_blocked_regression(float** data, size_t r1, size_t r2, size_t r3, unsigned char* comp_data){ |
---|
4929 | |
---|
4930 | size_t dim0_offset = r2 * r3; |
---|
4931 | size_t dim1_offset = r3; |
---|
4932 | size_t num_elements = r1 * r2 * r3; |
---|
4933 | |
---|
4934 | *data = (float*)malloc(sizeof(float)*num_elements); |
---|
4935 | |
---|
4936 | unsigned char * comp_data_pos = comp_data; |
---|
4937 | |
---|
4938 | size_t block_size = bytesToInt_bigEndian(comp_data_pos); |
---|
4939 | comp_data_pos += sizeof(int); |
---|
4940 | // calculate block dims |
---|
4941 | size_t num_x, num_y, num_z; |
---|
4942 | num_x = (r1 - 1) / block_size + 1; |
---|
4943 | num_y = (r2 - 1) / block_size + 1; |
---|
4944 | num_z = (r3 - 1) / block_size + 1; |
---|
4945 | |
---|
4946 | size_t max_num_block_elements = block_size * block_size * block_size; |
---|
4947 | size_t num_blocks = num_x * num_y * num_z; |
---|
4948 | |
---|
4949 | double realPrecision = bytesToDouble(comp_data_pos); |
---|
4950 | comp_data_pos += sizeof(double); |
---|
4951 | unsigned int intervals = bytesToInt_bigEndian(comp_data_pos); |
---|
4952 | comp_data_pos += sizeof(int); |
---|
4953 | |
---|
4954 | updateQuantizationInfo(intervals); |
---|
4955 | |
---|
4956 | unsigned int tree_size = bytesToInt_bigEndian(comp_data_pos); |
---|
4957 | comp_data_pos += sizeof(int); |
---|
4958 | |
---|
4959 | int stateNum = 2*intervals; |
---|
4960 | HuffmanTree* huffmanTree = createHuffmanTree(stateNum); |
---|
4961 | |
---|
4962 | int nodeCount = bytesToInt_bigEndian(comp_data_pos); |
---|
4963 | node root = reconstruct_HuffTree_from_bytes_anyStates(huffmanTree,comp_data_pos+sizeof(int), nodeCount); |
---|
4964 | comp_data_pos += sizeof(int) + tree_size; |
---|
4965 | |
---|
4966 | float mean; |
---|
4967 | unsigned char use_mean; |
---|
4968 | memcpy(&use_mean, comp_data_pos, sizeof(unsigned char)); |
---|
4969 | comp_data_pos += sizeof(unsigned char); |
---|
4970 | memcpy(&mean, comp_data_pos, sizeof(float)); |
---|
4971 | comp_data_pos += sizeof(float); |
---|
4972 | size_t reg_count = 0; |
---|
4973 | |
---|
4974 | unsigned char * indicator; |
---|
4975 | size_t indicator_bitlength = (num_blocks - 1)/8 + 1; |
---|
4976 | convertByteArray2IntArray_fast_1b(num_blocks, comp_data_pos, indicator_bitlength, &indicator); |
---|
4977 | comp_data_pos += indicator_bitlength; |
---|
4978 | for(size_t i=0; i<num_blocks; i++){ |
---|
4979 | if(!indicator[i]) reg_count ++; |
---|
4980 | } |
---|
4981 | |
---|
4982 | int coeff_intvRadius[4]; |
---|
4983 | int * coeff_result_type = (int *) malloc(num_blocks*4*sizeof(int)); |
---|
4984 | int * coeff_type[4]; |
---|
4985 | double precision[4]; |
---|
4986 | float * coeff_unpred_data[4]; |
---|
4987 | if(reg_count > 0){ |
---|
4988 | for(int i=0; i<4; i++){ |
---|
4989 | precision[i] = bytesToDouble(comp_data_pos); |
---|
4990 | comp_data_pos += sizeof(double); |
---|
4991 | coeff_intvRadius[i] = bytesToInt_bigEndian(comp_data_pos); |
---|
4992 | comp_data_pos += sizeof(int); |
---|
4993 | unsigned int tree_size = bytesToInt_bigEndian(comp_data_pos); |
---|
4994 | comp_data_pos += sizeof(int); |
---|
4995 | int stateNum = 2*coeff_intvRadius[i]*2; |
---|
4996 | HuffmanTree* huffmanTree = createHuffmanTree(stateNum); |
---|
4997 | int nodeCount = bytesToInt_bigEndian(comp_data_pos); |
---|
4998 | node root = reconstruct_HuffTree_from_bytes_anyStates(huffmanTree, comp_data_pos+sizeof(int), nodeCount); |
---|
4999 | comp_data_pos += sizeof(int) + tree_size; |
---|
5000 | |
---|
5001 | coeff_type[i] = coeff_result_type + i * num_blocks; |
---|
5002 | size_t typeArray_size = bytesToSize(comp_data_pos); |
---|
5003 | decode(comp_data_pos + sizeof(size_t), reg_count, root, coeff_type[i]); |
---|
5004 | comp_data_pos += sizeof(size_t) + typeArray_size; |
---|
5005 | int coeff_unpred_count = bytesToInt_bigEndian(comp_data_pos); |
---|
5006 | comp_data_pos += sizeof(int); |
---|
5007 | coeff_unpred_data[i] = (float *) comp_data_pos; |
---|
5008 | comp_data_pos += coeff_unpred_count * sizeof(float); |
---|
5009 | SZ_ReleaseHuffman(huffmanTree); |
---|
5010 | } |
---|
5011 | } |
---|
5012 | float last_coefficients[4] = {0.0}; |
---|
5013 | int coeff_unpred_data_count[4] = {0}; |
---|
5014 | int coeff_index = 0; |
---|
5015 | updateQuantizationInfo(intervals); |
---|
5016 | |
---|
5017 | size_t total_unpred; |
---|
5018 | memcpy(&total_unpred, comp_data_pos, sizeof(size_t)); |
---|
5019 | comp_data_pos += sizeof(size_t); |
---|
5020 | float * unpred_data = (float *) comp_data_pos; |
---|
5021 | comp_data_pos += total_unpred * sizeof(float); |
---|
5022 | |
---|
5023 | int * result_type = (int *) malloc(num_blocks*max_num_block_elements * sizeof(int)); |
---|
5024 | decode(comp_data_pos, num_blocks*max_num_block_elements, root, result_type); |
---|
5025 | SZ_ReleaseHuffman(huffmanTree); |
---|
5026 | |
---|
5027 | int intvRadius = exe_params->intvRadius; |
---|
5028 | |
---|
5029 | int * type; |
---|
5030 | float * data_pos = *data; |
---|
5031 | size_t cur_unpred_count; |
---|
5032 | unsigned char * indicator_pos = indicator; |
---|
5033 | int dec_buffer_size = block_size + 1; |
---|
5034 | float * dec_buffer = (float *) malloc(dec_buffer_size*dec_buffer_size*dec_buffer_size*sizeof(float)); |
---|
5035 | memset(dec_buffer, 0, dec_buffer_size*dec_buffer_size*dec_buffer_size*sizeof(float)); |
---|
5036 | float * block_data_pos_x = NULL; |
---|
5037 | float * block_data_pos_y = NULL; |
---|
5038 | float * block_data_pos_z = NULL; |
---|
5039 | int block_dim0_offset = dec_buffer_size*dec_buffer_size; |
---|
5040 | int block_dim1_offset = dec_buffer_size; |
---|
5041 | if(use_mean){ |
---|
5042 | type = result_type; |
---|
5043 | for(size_t i=0; i<num_x; i++){ |
---|
5044 | for(size_t j=0; j<num_y; j++){ |
---|
5045 | for(size_t k=0; k<num_z; k++){ |
---|
5046 | data_pos = dec_buffer + dec_buffer_size*dec_buffer_size + dec_buffer_size + 1; |
---|
5047 | if(*indicator_pos){ |
---|
5048 | // decompress by SZ |
---|
5049 | // cur_unpred_count = decompressDataSeries_float_3D_blocked_nonblock_pred(data_pos, r1, r2, r3, current_blockcount_x, current_blockcount_y, current_blockcount_z, i, j, k, realPrecision, type, unpred_data); |
---|
5050 | float * block_data_pos; |
---|
5051 | float pred; |
---|
5052 | size_t index = 0; |
---|
5053 | int type_; |
---|
5054 | size_t unpredictable_count = 0; |
---|
5055 | for(size_t ii=0; ii<block_size; ii++){ |
---|
5056 | for(size_t jj=0; jj<block_size; jj++){ |
---|
5057 | for(size_t kk=0; kk<block_size; kk++){ |
---|
5058 | block_data_pos = data_pos + ii*block_dim0_offset + jj*block_dim1_offset + kk; |
---|
5059 | type_ = type[index]; |
---|
5060 | if(type_ == 1){ |
---|
5061 | *block_data_pos = mean; |
---|
5062 | } |
---|
5063 | else if(type_ == 0){ |
---|
5064 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
5065 | } |
---|
5066 | else{ |
---|
5067 | pred = block_data_pos[-1] + block_data_pos[-block_dim1_offset]+ block_data_pos[-block_dim0_offset] - block_data_pos[-block_dim1_offset - 1] |
---|
5068 | - block_data_pos[-block_dim0_offset - 1] - block_data_pos[-block_dim0_offset - block_dim1_offset] + block_data_pos[-block_dim0_offset - block_dim1_offset - 1]; |
---|
5069 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
5070 | } |
---|
5071 | index ++; |
---|
5072 | } |
---|
5073 | } |
---|
5074 | } |
---|
5075 | cur_unpred_count = unpredictable_count; |
---|
5076 | } |
---|
5077 | else{ |
---|
5078 | // decompress by regression |
---|
5079 | { |
---|
5080 | //restore regression coefficients |
---|
5081 | float pred; |
---|
5082 | int type_; |
---|
5083 | for(int e=0; e<4; e++){ |
---|
5084 | // if(i == 0 && j == 0 && k == 19){ |
---|
5085 | // printf("~\n"); |
---|
5086 | // } |
---|
5087 | type_ = coeff_type[e][coeff_index]; |
---|
5088 | if (type_ != 0){ |
---|
5089 | pred = last_coefficients[e]; |
---|
5090 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
5091 | } |
---|
5092 | else{ |
---|
5093 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
5094 | coeff_unpred_data_count[e] ++; |
---|
5095 | } |
---|
5096 | } |
---|
5097 | coeff_index ++; |
---|
5098 | } |
---|
5099 | { |
---|
5100 | float pred; |
---|
5101 | int type_; |
---|
5102 | size_t index = 0; |
---|
5103 | size_t unpredictable_count = 0; |
---|
5104 | for(size_t ii=0; ii<block_size; ii++){ |
---|
5105 | for(size_t jj=0; jj<block_size; jj++){ |
---|
5106 | for(size_t kk=0; kk<block_size; kk++){ |
---|
5107 | type_ = type[index]; |
---|
5108 | if (type_ != 0){ |
---|
5109 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
5110 | data_pos[ii*block_dim0_offset + jj*block_dim1_offset + kk] = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
5111 | } |
---|
5112 | else{ |
---|
5113 | data_pos[ii*block_dim0_offset + jj*block_dim1_offset + kk] = unpred_data[unpredictable_count ++]; |
---|
5114 | } |
---|
5115 | index ++; |
---|
5116 | } |
---|
5117 | } |
---|
5118 | } |
---|
5119 | cur_unpred_count = unpredictable_count; |
---|
5120 | } |
---|
5121 | } |
---|
5122 | indicator_pos ++; |
---|
5123 | unpred_data += cur_unpred_count; |
---|
5124 | // decomp_unpred += cur_unpred_count; |
---|
5125 | // printf("block comp done, data_offset from %ld to %ld: diff %ld\n", *data, data_pos, data_pos - *data); |
---|
5126 | // fflush(stdout); |
---|
5127 | type += block_size * block_size * block_size; |
---|
5128 | |
---|
5129 | // mv data back |
---|
5130 | block_data_pos_x = *data + i*block_size * dim0_offset + j*block_size * dim1_offset + k*block_size; |
---|
5131 | for(int ii=0; ii<block_size; ii++){ |
---|
5132 | if(i*block_size + ii >= r1) break; |
---|
5133 | block_data_pos_y = block_data_pos_x; |
---|
5134 | for(int jj=0; jj<block_size; jj++){ |
---|
5135 | if(j*block_size + jj >= r2) break; |
---|
5136 | block_data_pos_z = block_data_pos_y; |
---|
5137 | for(int kk=0; kk<block_size; kk++){ |
---|
5138 | if(k*block_size + kk >= r3) break; |
---|
5139 | *block_data_pos_z = data_pos[ii*dec_buffer_size*dec_buffer_size + jj*dec_buffer_size + kk]; |
---|
5140 | block_data_pos_z ++; |
---|
5141 | } |
---|
5142 | block_data_pos_y += dim1_offset; |
---|
5143 | } |
---|
5144 | block_data_pos_x += dim0_offset; |
---|
5145 | } |
---|
5146 | |
---|
5147 | } |
---|
5148 | } |
---|
5149 | } |
---|
5150 | |
---|
5151 | } |
---|
5152 | else{ |
---|
5153 | type = result_type; |
---|
5154 | for(size_t i=0; i<num_x; i++){ |
---|
5155 | for(size_t j=0; j<num_y; j++){ |
---|
5156 | for(size_t k=0; k<num_z; k++){ |
---|
5157 | data_pos = dec_buffer + dec_buffer_size*dec_buffer_size + dec_buffer_size + 1; |
---|
5158 | if(*indicator_pos){ |
---|
5159 | // decompress by SZ |
---|
5160 | // cur_unpred_count = decompressDataSeries_float_3D_blocked_nonblock_pred(data_pos, r1, r2, r3, current_blockcount_x, current_blockcount_y, current_blockcount_z, i, j, k, realPrecision, type, unpred_data); |
---|
5161 | float * block_data_pos; |
---|
5162 | float pred; |
---|
5163 | size_t index = 0; |
---|
5164 | int type_; |
---|
5165 | size_t unpredictable_count = 0; |
---|
5166 | for(size_t ii=0; ii<block_size; ii++){ |
---|
5167 | for(size_t jj=0; jj<block_size; jj++){ |
---|
5168 | for(size_t kk=0; kk<block_size; kk++){ |
---|
5169 | block_data_pos = data_pos + ii*block_dim0_offset + jj*block_dim1_offset + kk; |
---|
5170 | type_ = type[index]; |
---|
5171 | if(type_ == 0){ |
---|
5172 | *block_data_pos = unpred_data[unpredictable_count ++]; |
---|
5173 | } |
---|
5174 | else{ |
---|
5175 | pred = block_data_pos[-1] + block_data_pos[-block_dim1_offset]+ block_data_pos[-block_dim0_offset] - block_data_pos[-block_dim1_offset - 1] |
---|
5176 | - block_data_pos[-block_dim0_offset - 1] - block_data_pos[-block_dim0_offset - block_dim1_offset] + block_data_pos[-block_dim0_offset - block_dim1_offset - 1]; |
---|
5177 | *block_data_pos = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
5178 | } |
---|
5179 | index ++; |
---|
5180 | } |
---|
5181 | } |
---|
5182 | } |
---|
5183 | cur_unpred_count = unpredictable_count; |
---|
5184 | } |
---|
5185 | else{ |
---|
5186 | // decompress by regression |
---|
5187 | { |
---|
5188 | //restore regression coefficients |
---|
5189 | float pred; |
---|
5190 | int type_; |
---|
5191 | for(int e=0; e<4; e++){ |
---|
5192 | // if(i == 0 && j == 0 && k == 19){ |
---|
5193 | // printf("~\n"); |
---|
5194 | // } |
---|
5195 | type_ = coeff_type[e][coeff_index]; |
---|
5196 | if (type_ != 0){ |
---|
5197 | pred = last_coefficients[e]; |
---|
5198 | last_coefficients[e] = pred + 2 * (type_ - coeff_intvRadius[e]) * precision[e]; |
---|
5199 | } |
---|
5200 | else{ |
---|
5201 | last_coefficients[e] = coeff_unpred_data[e][coeff_unpred_data_count[e]]; |
---|
5202 | coeff_unpred_data_count[e] ++; |
---|
5203 | } |
---|
5204 | } |
---|
5205 | coeff_index ++; |
---|
5206 | } |
---|
5207 | { |
---|
5208 | float pred; |
---|
5209 | int type_; |
---|
5210 | size_t index = 0; |
---|
5211 | size_t unpredictable_count = 0; |
---|
5212 | for(size_t ii=0; ii<block_size; ii++){ |
---|
5213 | for(size_t jj=0; jj<block_size; jj++){ |
---|
5214 | for(size_t kk=0; kk<block_size; kk++){ |
---|
5215 | type_ = type[index]; |
---|
5216 | if (type_ != 0){ |
---|
5217 | pred = last_coefficients[0] * ii + last_coefficients[1] * jj + last_coefficients[2] * kk + last_coefficients[3]; |
---|
5218 | data_pos[ii*block_dim0_offset + jj*block_dim1_offset + kk] = pred + 2 * (type_ - intvRadius) * realPrecision; |
---|
5219 | } |
---|
5220 | else{ |
---|
5221 | data_pos[ii*block_dim0_offset + jj*block_dim1_offset + kk] = unpred_data[unpredictable_count ++]; |
---|
5222 | } |
---|
5223 | index ++; |
---|
5224 | } |
---|
5225 | } |
---|
5226 | } |
---|
5227 | cur_unpred_count = unpredictable_count; |
---|
5228 | } |
---|
5229 | } |
---|
5230 | indicator_pos ++; |
---|
5231 | unpred_data += cur_unpred_count; |
---|
5232 | // decomp_unpred += cur_unpred_count; |
---|
5233 | // printf("block comp done, data_offset from %ld to %ld: diff %ld\n", *data, data_pos, data_pos - *data); |
---|
5234 | // fflush(stdout); |
---|
5235 | type += block_size * block_size * block_size; |
---|
5236 | // mv data back |
---|
5237 | block_data_pos_x = *data + i*block_size * dim0_offset + j*block_size * dim1_offset + k*block_size; |
---|
5238 | for(int ii=0; ii<block_size; ii++){ |
---|
5239 | if(i*block_size + ii >= r1) break; |
---|
5240 | block_data_pos_y = block_data_pos_x; |
---|
5241 | for(int jj=0; jj<block_size; jj++){ |
---|
5242 | if(j*block_size + jj >= r2) break; |
---|
5243 | block_data_pos_z = block_data_pos_y; |
---|
5244 | for(int kk=0; kk<block_size; kk++){ |
---|
5245 | if(k*block_size + kk >= r3) break; |
---|
5246 | *block_data_pos_z = data_pos[ii*dec_buffer_size*dec_buffer_size + jj*dec_buffer_size + kk]; |
---|
5247 | block_data_pos_z ++; |
---|
5248 | } |
---|
5249 | block_data_pos_y += dim1_offset; |
---|
5250 | } |
---|
5251 | block_data_pos_x += dim0_offset; |
---|
5252 | } |
---|
5253 | } |
---|
5254 | } |
---|
5255 | } |
---|
5256 | } |
---|
5257 | free(dec_buffer); |
---|
5258 | free(coeff_result_type); |
---|
5259 | |
---|
5260 | free(indicator); |
---|
5261 | free(result_type); |
---|
5262 | } |
---|