Changeset 9ee2ce3 for thirdparty/SZ/sz/src/szd_float.c
- Timestamp:
- 09/28/18 16:32:55 (6 years ago)
- Branches:
- master, pympi
- Children:
- e6aa0eb
- Parents:
- abca157
- git-author:
- Hal Finkel <hfinkel@…> (09/28/18 16:32:55)
- git-committer:
- Hal Finkel <hfinkel@…> (09/28/18 16:32:55)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
thirdparty/SZ/sz/src/szd_float.c
r2c47b73 r9ee2ce3 1 1 /** 2 2 * @file szd_float.c 3 * @author Sheng Di and Dingwen Tao4 * @date Aug, 201 63 * @author Sheng Di, Dingwen Tao, Xin Liang 4 * @date Aug, 2018 5 5 * @brief 6 6 * (C) 2016 by Mathematics and Computer Science (MCS), Argonne National Laboratory. … … 17 17 #include "szd_float_pwr.h" 18 18 #include "szd_float_ts.h" 19 #include "utility.h" 19 20 20 21 /** … … 36 37 if(cmpSize!=8+4+MetaDataByteLength && cmpSize!=8+8+MetaDataByteLength) //4,8 means two posibilities of SZ_SIZE_TYPE 37 38 { 38 int isZlib = isZlibFormat(cmpBytes[0], cmpBytes[1]);39 confparams_dec->losslessCompressor = is_lossless_compressed_data(cmpBytes, cmpSize); 39 40 if(confparams_dec->szMode!=SZ_TEMPORAL_COMPRESSION) 40 41 { 41 if( isZlib)42 if(confparams_dec->losslessCompressor!=-1) 42 43 confparams_dec->szMode = SZ_BEST_COMPRESSION; 43 44 else … … 54 55 if(targetUncompressSize<MIN_ZLIB_DEC_ALLOMEM_BYTES) //Considering the minimum size 55 56 targetUncompressSize = MIN_ZLIB_DEC_ALLOMEM_BYTES; 56 tmpSize = zlib_uncompress5(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+targetUncompressSize57 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 57 58 //szTmpBytes = (unsigned char*)malloc(sizeof(unsigned char)*tmpSize); 58 59 //memcpy(szTmpBytes, tmpBytes, tmpSize); … … 89 90 } 90 91 } 91 else if (dim == 1) 92 getSnapshotData_float_1D(newData,r1,tdps, errBoundMode); 93 else 94 if (dim == 2) 95 getSnapshotData_float_2D(newData,r2,r1,tdps, errBoundMode); 96 else 97 if (dim == 3) 98 getSnapshotData_float_3D(newData,r3,r2,r1,tdps, errBoundMode); 99 else 100 if (dim == 4) 101 getSnapshotData_float_4D(newData,r4,r3,r2,r1,tdps, errBoundMode); 102 else 92 else 103 93 { 104 printf("Error: currently support only at most 4 dimensions!\n"); 105 status = SZ_DERR; 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 } 106 126 } 107 127 free_TightDataPointStorageF2(tdps); … … 1652 1672 else 1653 1673 { 1654 //decompressDataSeries_float_1D_pwr(data, dataSeriesLength, tdps);1655 decompressDataSeries_float_1D_pwrgroup(data, dataSeriesLength, tdps);1674 decompressDataSeries_float_1D_pwr_pre_log(data, dataSeriesLength, tdps); 1675 //decompressDataSeries_float_1D_pwrgroup(data, dataSeriesLength, tdps); 1656 1676 } 1657 1677 return; … … 1676 1696 decompressDataSeries_float_1D(&decmpData, dataSeriesLength, tdps); 1677 1697 else 1678 decompressDataSeries_float_1D_pwr(&decmpData, dataSeriesLength, tdps); 1698 //decompressDataSeries_float_1D_pwr(&decmpData, dataSeriesLength, tdps); 1699 decompressDataSeries_float_1D_pwr_pre_log(&decmpData, dataSeriesLength, tdps); 1679 1700 // insert the decompressed data 1680 1701 size_t k = 0; … … 1717 1738 else 1718 1739 { 1719 decompressDataSeries_float_2D_pwr(data, r1, r2, tdps); 1740 //decompressDataSeries_float_2D_pwr(data, r1, r2, tdps); 1741 decompressDataSeries_float_2D_pwr_pre_log(data, r1, r2, tdps); 1720 1742 } 1721 1743 … … 1741 1763 decompressDataSeries_float_2D(&decmpData, r1, r2, tdps); 1742 1764 else 1743 decompressDataSeries_float_2D_pwr(&decmpData, r1, r2, tdps); 1765 //decompressDataSeries_float_2D_pwr(&decmpData, r1, r2, tdps); 1766 decompressDataSeries_float_2D_pwr_pre_log(&decmpData, r1, r2, tdps); 1744 1767 // insert the decompressed data 1745 1768 size_t k = 0; … … 1774 1797 decompressDataSeries_float_3D(data, r1, r2, r3, tdps); 1775 1798 else 1776 decompressDataSeries_float_1D_ts(data, r1*r2*r3, multisteps, tdps);1799 decompressDataSeries_float_1D_ts(data, dataSeriesLength, multisteps, tdps); 1777 1800 } 1778 1801 else … … 1782 1805 else 1783 1806 { 1784 decompressDataSeries_float_3D_pwr(data, r1, r2, r3, tdps); 1807 //decompressDataSeries_float_3D_pwr(data, r1, r2, r3, tdps); 1808 decompressDataSeries_float_3D_pwr_pre_log(data, r1, r2, r3, tdps); 1785 1809 } 1786 1810 … … 1806 1830 decompressDataSeries_float_3D(&decmpData, r1, r2, r3, tdps); 1807 1831 else 1808 decompressDataSeries_float_3D_pwr(&decmpData, r1, r2, r3, tdps); 1832 //decompressDataSeries_float_3D_pwr(&decmpData, r1, r2, r3, tdps); 1833 decompressDataSeries_float_3D_pwr_pre_log(&decmpData, r1, r2, r3, tdps); 1809 1834 // insert the decompressed data 1810 1835 size_t k = 0; … … 1847 1872 else 1848 1873 { 1849 decompressDataSeries_float_3D_pwr(data, r1*r2, r3, r4, tdps); 1874 //decompressDataSeries_float_3D_pwr(data, r1*r2, r3, r4, tdps); 1875 decompressDataSeries_float_3D_pwr_pre_log(data, r1*r2, r3, r4, tdps); 1850 1876 //ToDO 1851 1877 //decompressDataSeries_float_4D_pwr(data, r1, r2, r3, r4, tdps); … … 1869 1895 decompressDataSeries_float_4D(&decmpData, r1, r2, r3, r4, tdps); 1870 1896 else 1871 decompressDataSeries_float_3D_pwr(&decmpData, r1*r2, r3, r4, tdps); 1897 //decompressDataSeries_float_3D_pwr(&decmpData, r1*r2, r3, r4, tdps); 1898 decompressDataSeries_float_3D_pwr_pre_log(&decmpData, r1*r2, r3, r4, tdps); 1872 1899 //ToDO 1873 1900 //decompressDataSeries_float_4D_pwr(&decompData, r1, r2, r3, r4, tdps); … … 2178 2205 } 2179 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 }
Note: See TracChangeset
for help on using the changeset viewer.