[2c47b73] | 1 | /** |
---|
| 2 | * @file szd_float.c |
---|
| 3 | * @author Sheng Di and Dingwen Tao |
---|
| 4 | * @date Aug, 2016 |
---|
| 5 | * @brief |
---|
| 6 | * (C) 2016 by Mathematics and Computer Science (MCS), Argonne National Laboratory. |
---|
| 7 | * See COPYRIGHT in top-level directory. |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | #include <stdlib.h> |
---|
| 11 | #include <stdio.h> |
---|
| 12 | #include <string.h> |
---|
| 13 | #include "szd_float.h" |
---|
| 14 | #include "TightDataPointStorageF.h" |
---|
| 15 | #include "sz.h" |
---|
| 16 | #include "Huffman.h" |
---|
| 17 | #include "szd_float_pwr.h" |
---|
| 18 | #include "szd_float_ts.h" |
---|
| 19 | |
---|
| 20 | /** |
---|
| 21 | * |
---|
| 22 | * |
---|
| 23 | * @return status SUCCESSFUL (SZ_SCES) or not (other error codes) f |
---|
| 24 | * */ |
---|
| 25 | int SZ_decompress_args_float(float** newData, size_t r5, size_t r4, size_t r3, size_t r2, size_t r1, unsigned char* cmpBytes, size_t cmpSize) |
---|
| 26 | { |
---|
| 27 | int status = SZ_SCES; |
---|
| 28 | size_t dataLength = computeDataLength(r5,r4,r3,r2,r1); |
---|
| 29 | |
---|
| 30 | //unsigned char* tmpBytes; |
---|
| 31 | size_t targetUncompressSize = dataLength <<2; //i.e., *4 |
---|
| 32 | //tmpSize must be "much" smaller than dataLength |
---|
| 33 | size_t i, tmpSize = 8+MetaDataByteLength+exe_params->SZ_SIZE_TYPE; |
---|
| 34 | unsigned char* szTmpBytes; |
---|
| 35 | |
---|
| 36 | if(cmpSize!=8+4+MetaDataByteLength && cmpSize!=8+8+MetaDataByteLength) //4,8 means two posibilities of SZ_SIZE_TYPE |
---|
| 37 | { |
---|
| 38 | int isZlib = isZlibFormat(cmpBytes[0], cmpBytes[1]); |
---|
| 39 | if(confparams_dec->szMode!=SZ_TEMPORAL_COMPRESSION) |
---|
| 40 | { |
---|
| 41 | if(isZlib) |
---|
| 42 | confparams_dec->szMode = SZ_BEST_COMPRESSION; |
---|
| 43 | else |
---|
| 44 | confparams_dec->szMode = SZ_BEST_SPEED; |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | if(confparams_dec->szMode==SZ_BEST_SPEED) |
---|
| 48 | { |
---|
| 49 | tmpSize = cmpSize; |
---|
| 50 | szTmpBytes = cmpBytes; |
---|
| 51 | } |
---|
| 52 | else if(confparams_dec->szMode==SZ_BEST_COMPRESSION || confparams_dec->szMode==SZ_DEFAULT_COMPRESSION || confparams_dec->szMode==SZ_TEMPORAL_COMPRESSION) |
---|
| 53 | { |
---|
| 54 | if(targetUncompressSize<MIN_ZLIB_DEC_ALLOMEM_BYTES) //Considering the minimum size |
---|
| 55 | 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+targetUncompressSize |
---|
| 57 | //szTmpBytes = (unsigned char*)malloc(sizeof(unsigned char)*tmpSize); |
---|
| 58 | //memcpy(szTmpBytes, tmpBytes, tmpSize); |
---|
| 59 | //free(tmpBytes); //release useless memory |
---|
| 60 | } |
---|
| 61 | else |
---|
| 62 | { |
---|
| 63 | printf("Wrong value of confparams_dec->szMode in the double compressed bytes.\n"); |
---|
| 64 | status = SZ_MERR; |
---|
| 65 | return status; |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | else |
---|
| 69 | szTmpBytes = cmpBytes; |
---|
| 70 | //TODO: convert szTmpBytes to data array. |
---|
| 71 | TightDataPointStorageF* tdps; |
---|
| 72 | int errBoundMode = new_TightDataPointStorageF_fromFlatBytes(&tdps, szTmpBytes, tmpSize); |
---|
| 73 | |
---|
| 74 | //writeByteData(tdps->typeArray, tdps->typeArray_size, "decompress-typebytes.tbt"); |
---|
| 75 | int dim = computeDimension(r5,r4,r3,r2,r1); |
---|
| 76 | int floatSize = sizeof(float); |
---|
| 77 | if(tdps->isLossless) |
---|
| 78 | { |
---|
| 79 | *newData = (float*)malloc(floatSize*dataLength); |
---|
| 80 | if(sysEndianType==BIG_ENDIAN_SYSTEM) |
---|
| 81 | { |
---|
| 82 | memcpy(*newData, szTmpBytes+4+MetaDataByteLength+exe_params->SZ_SIZE_TYPE, dataLength*floatSize); |
---|
| 83 | } |
---|
| 84 | else |
---|
| 85 | { |
---|
| 86 | unsigned char* p = szTmpBytes+4+MetaDataByteLength+exe_params->SZ_SIZE_TYPE; |
---|
| 87 | for(i=0;i<dataLength;i++,p+=floatSize) |
---|
| 88 | (*newData)[i] = bytesToFloat(p); |
---|
| 89 | } |
---|
| 90 | } |
---|
| 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 |
---|
| 103 | { |
---|
| 104 | printf("Error: currently support only at most 4 dimensions!\n"); |
---|
| 105 | status = SZ_DERR; |
---|
| 106 | } |
---|
| 107 | free_TightDataPointStorageF2(tdps); |
---|
| 108 | if(confparams_dec->szMode!=SZ_BEST_SPEED && cmpSize!=8+MetaDataByteLength+exe_params->SZ_SIZE_TYPE) |
---|
| 109 | free(szTmpBytes); |
---|
| 110 | return status; |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | void decompressDataSeries_float_1D(float** data, size_t dataSeriesLength, TightDataPointStorageF* tdps) |
---|
| 114 | { |
---|
| 115 | updateQuantizationInfo(tdps->intervals); |
---|
| 116 | size_t i, j, k = 0, p = 0, l = 0; // k is to track the location of residual_bit |
---|
| 117 | // in resiMidBits, p is to track the |
---|
| 118 | // byte_index of resiMidBits, l is for |
---|
| 119 | // leadNum |
---|
| 120 | unsigned char* leadNum; |
---|
| 121 | double interval = tdps->realPrecision*2; |
---|
| 122 | |
---|
| 123 | convertByteArray2IntArray_fast_2b(tdps->exactDataNum, tdps->leadNumArray, tdps->leadNumArray_size, &leadNum); |
---|
| 124 | |
---|
| 125 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
| 126 | |
---|
| 127 | int* type = (int*)malloc(dataSeriesLength*sizeof(int)); |
---|
| 128 | |
---|
| 129 | HuffmanTree* huffmanTree = createHuffmanTree(tdps->stateNum); |
---|
| 130 | decode_withTree(huffmanTree, tdps->typeArray, dataSeriesLength, type); |
---|
| 131 | SZ_ReleaseHuffman(huffmanTree); |
---|
| 132 | |
---|
| 133 | unsigned char preBytes[4]; |
---|
| 134 | unsigned char curBytes[4]; |
---|
| 135 | |
---|
| 136 | memset(preBytes, 0, 4); |
---|
| 137 | |
---|
| 138 | size_t curByteIndex = 0; |
---|
| 139 | int reqBytesLength, resiBitsLength, resiBits; |
---|
| 140 | unsigned char leadingNum; |
---|
| 141 | float medianValue, exactData, predValue; |
---|
| 142 | |
---|
| 143 | reqBytesLength = tdps->reqLength/8; |
---|
| 144 | resiBitsLength = tdps->reqLength%8; |
---|
| 145 | medianValue = tdps->medianValue; |
---|
| 146 | |
---|
| 147 | int type_; |
---|
| 148 | for (i = 0; i < dataSeriesLength; i++) { |
---|
| 149 | type_ = type[i]; |
---|
| 150 | switch (type_) { |
---|
| 151 | case 0: |
---|
| 152 | // compute resiBits |
---|
| 153 | resiBits = 0; |
---|
| 154 | if (resiBitsLength != 0) { |
---|
| 155 | int kMod8 = k % 8; |
---|
| 156 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 157 | if (rightMovSteps > 0) { |
---|
| 158 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 159 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 160 | } else if (rightMovSteps < 0) { |
---|
| 161 | int code1 = getLeftMovingCode(kMod8); |
---|
| 162 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 163 | int leftMovSteps = -rightMovSteps; |
---|
| 164 | rightMovSteps = 8 - leftMovSteps; |
---|
| 165 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 166 | p++; |
---|
| 167 | resiBits = resiBits |
---|
| 168 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 169 | } else // rightMovSteps == 0 |
---|
| 170 | { |
---|
| 171 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 172 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 173 | p++; |
---|
| 174 | } |
---|
| 175 | k += resiBitsLength; |
---|
| 176 | } |
---|
| 177 | |
---|
| 178 | // recover the exact data |
---|
| 179 | memset(curBytes, 0, 4); |
---|
| 180 | leadingNum = leadNum[l++]; |
---|
| 181 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 182 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 183 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 184 | if (resiBitsLength != 0) { |
---|
| 185 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 186 | curBytes[reqBytesLength] = resiByte; |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | exactData = bytesToFloat(curBytes); |
---|
| 190 | (*data)[i] = exactData + medianValue; |
---|
| 191 | memcpy(preBytes,curBytes,4); |
---|
| 192 | break; |
---|
| 193 | default: |
---|
| 194 | //predValue = 2 * (*data)[i-1] - (*data)[i-2]; |
---|
| 195 | predValue = (*data)[i-1]; |
---|
| 196 | (*data)[i] = predValue + (type_-exe_params->intvRadius)*interval; |
---|
| 197 | break; |
---|
| 198 | } |
---|
| 199 | //printf("%.30G\n",(*data)[i]); |
---|
| 200 | } |
---|
| 201 | |
---|
| 202 | #ifdef HAVE_TIMECMPR |
---|
| 203 | if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
| 204 | memcpy(multisteps->hist_data, (*data), dataSeriesLength*sizeof(float)); |
---|
| 205 | #endif |
---|
| 206 | |
---|
| 207 | free(leadNum); |
---|
| 208 | free(type); |
---|
| 209 | return; |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | void decompressDataSeries_float_2D(float** data, size_t r1, size_t r2, TightDataPointStorageF* tdps) |
---|
| 213 | { |
---|
| 214 | updateQuantizationInfo(tdps->intervals); |
---|
| 215 | //printf("tdps->intervals=%d, exe_params->intvRadius=%d\n", tdps->intervals, exe_params->intvRadius); |
---|
| 216 | |
---|
| 217 | size_t j, k = 0, p = 0, l = 0; // k is to track the location of residual_bit |
---|
| 218 | // in resiMidBits, p is to track the |
---|
| 219 | // byte_index of resiMidBits, l is for |
---|
| 220 | // leadNum |
---|
| 221 | size_t dataSeriesLength = r1*r2; |
---|
| 222 | // printf ("%d %d\n", r1, r2); |
---|
| 223 | |
---|
| 224 | unsigned char* leadNum; |
---|
| 225 | double realPrecision = tdps->realPrecision; |
---|
| 226 | |
---|
| 227 | convertByteArray2IntArray_fast_2b(tdps->exactDataNum, tdps->leadNumArray, tdps->leadNumArray_size, &leadNum); |
---|
| 228 | |
---|
| 229 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
| 230 | |
---|
| 231 | int* type = (int*)malloc(dataSeriesLength*sizeof(int)); |
---|
| 232 | |
---|
| 233 | HuffmanTree* huffmanTree = createHuffmanTree(tdps->stateNum); |
---|
| 234 | decode_withTree(huffmanTree, tdps->typeArray, dataSeriesLength, type); |
---|
| 235 | SZ_ReleaseHuffman(huffmanTree); |
---|
| 236 | |
---|
| 237 | unsigned char preBytes[4]; |
---|
| 238 | unsigned char curBytes[4]; |
---|
| 239 | |
---|
| 240 | memset(preBytes, 0, 4); |
---|
| 241 | |
---|
| 242 | size_t curByteIndex = 0; |
---|
| 243 | int reqBytesLength, resiBitsLength, resiBits; |
---|
| 244 | unsigned char leadingNum; |
---|
| 245 | float medianValue, exactData; |
---|
| 246 | int type_; |
---|
| 247 | |
---|
| 248 | reqBytesLength = tdps->reqLength/8; |
---|
| 249 | resiBitsLength = tdps->reqLength%8; |
---|
| 250 | medianValue = tdps->medianValue; |
---|
| 251 | |
---|
| 252 | float pred1D, pred2D; |
---|
| 253 | size_t ii, jj; |
---|
| 254 | |
---|
| 255 | /* Process Row-0, data 0 */ |
---|
| 256 | |
---|
| 257 | // compute resiBits |
---|
| 258 | resiBits = 0; |
---|
| 259 | if (resiBitsLength != 0) { |
---|
| 260 | int kMod8 = k % 8; |
---|
| 261 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 262 | if (rightMovSteps > 0) { |
---|
| 263 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 264 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 265 | } else if (rightMovSteps < 0) { |
---|
| 266 | int code1 = getLeftMovingCode(kMod8); |
---|
| 267 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 268 | int leftMovSteps = -rightMovSteps; |
---|
| 269 | rightMovSteps = 8 - leftMovSteps; |
---|
| 270 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 271 | p++; |
---|
| 272 | resiBits = resiBits |
---|
| 273 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 274 | } else // rightMovSteps == 0 |
---|
| 275 | { |
---|
| 276 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 277 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 278 | p++; |
---|
| 279 | } |
---|
| 280 | k += resiBitsLength; |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | // recover the exact data |
---|
| 284 | memset(curBytes, 0, 4); |
---|
| 285 | leadingNum = leadNum[l++]; |
---|
| 286 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 287 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 288 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 289 | if (resiBitsLength != 0) { |
---|
| 290 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 291 | curBytes[reqBytesLength] = resiByte; |
---|
| 292 | } |
---|
| 293 | |
---|
| 294 | exactData = bytesToFloat(curBytes); |
---|
| 295 | (*data)[0] = exactData + medianValue; |
---|
| 296 | memcpy(preBytes,curBytes,4); |
---|
| 297 | |
---|
| 298 | /* Process Row-0, data 1 */ |
---|
| 299 | type_ = type[1]; |
---|
| 300 | if (type_ != 0) |
---|
| 301 | { |
---|
| 302 | pred1D = (*data)[0]; |
---|
| 303 | (*data)[1] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 304 | } |
---|
| 305 | else |
---|
| 306 | { |
---|
| 307 | // compute resiBits |
---|
| 308 | resiBits = 0; |
---|
| 309 | if (resiBitsLength != 0) { |
---|
| 310 | int kMod8 = k % 8; |
---|
| 311 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 312 | if (rightMovSteps > 0) { |
---|
| 313 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 314 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 315 | } else if (rightMovSteps < 0) { |
---|
| 316 | int code1 = getLeftMovingCode(kMod8); |
---|
| 317 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 318 | int leftMovSteps = -rightMovSteps; |
---|
| 319 | rightMovSteps = 8 - leftMovSteps; |
---|
| 320 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 321 | p++; |
---|
| 322 | resiBits = resiBits |
---|
| 323 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 324 | } else // rightMovSteps == 0 |
---|
| 325 | { |
---|
| 326 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 327 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 328 | p++; |
---|
| 329 | } |
---|
| 330 | k += resiBitsLength; |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | // recover the exact data |
---|
| 334 | memset(curBytes, 0, 4); |
---|
| 335 | leadingNum = leadNum[l++]; |
---|
| 336 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 337 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 338 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 339 | if (resiBitsLength != 0) { |
---|
| 340 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 341 | curBytes[reqBytesLength] = resiByte; |
---|
| 342 | } |
---|
| 343 | |
---|
| 344 | exactData = bytesToFloat(curBytes); |
---|
| 345 | (*data)[1] = exactData + medianValue; |
---|
| 346 | memcpy(preBytes,curBytes,4); |
---|
| 347 | } |
---|
| 348 | |
---|
| 349 | /* Process Row-0, data 2 --> data r2-1 */ |
---|
| 350 | for (jj = 2; jj < r2; jj++) |
---|
| 351 | { |
---|
| 352 | type_ = type[jj]; |
---|
| 353 | if (type_ != 0) |
---|
| 354 | { |
---|
| 355 | pred1D = 2*(*data)[jj-1] - (*data)[jj-2]; |
---|
| 356 | (*data)[jj] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 357 | } |
---|
| 358 | else |
---|
| 359 | { |
---|
| 360 | // compute resiBits |
---|
| 361 | resiBits = 0; |
---|
| 362 | if (resiBitsLength != 0) { |
---|
| 363 | int kMod8 = k % 8; |
---|
| 364 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 365 | if (rightMovSteps > 0) { |
---|
| 366 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 367 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 368 | } else if (rightMovSteps < 0) { |
---|
| 369 | int code1 = getLeftMovingCode(kMod8); |
---|
| 370 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 371 | int leftMovSteps = -rightMovSteps; |
---|
| 372 | rightMovSteps = 8 - leftMovSteps; |
---|
| 373 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 374 | p++; |
---|
| 375 | resiBits = resiBits |
---|
| 376 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 377 | } else // rightMovSteps == 0 |
---|
| 378 | { |
---|
| 379 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 380 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 381 | p++; |
---|
| 382 | } |
---|
| 383 | k += resiBitsLength; |
---|
| 384 | } |
---|
| 385 | |
---|
| 386 | // recover the exact data |
---|
| 387 | memset(curBytes, 0, 4); |
---|
| 388 | leadingNum = leadNum[l++]; |
---|
| 389 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 390 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 391 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 392 | if (resiBitsLength != 0) { |
---|
| 393 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 394 | curBytes[reqBytesLength] = resiByte; |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | exactData = bytesToFloat(curBytes); |
---|
| 398 | (*data)[jj] = exactData + medianValue; |
---|
| 399 | memcpy(preBytes,curBytes,4); |
---|
| 400 | } |
---|
| 401 | } |
---|
| 402 | |
---|
| 403 | size_t index; |
---|
| 404 | /* Process Row-1 --> Row-r1-1 */ |
---|
| 405 | for (ii = 1; ii < r1; ii++) |
---|
| 406 | { |
---|
| 407 | /* Process row-ii data 0 */ |
---|
| 408 | index = ii*r2; |
---|
| 409 | |
---|
| 410 | type_ = type[index]; |
---|
| 411 | if (type_ != 0) |
---|
| 412 | { |
---|
| 413 | pred1D = (*data)[index-r2]; |
---|
| 414 | (*data)[index] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 415 | } |
---|
| 416 | else |
---|
| 417 | { |
---|
| 418 | // compute resiBits |
---|
| 419 | resiBits = 0; |
---|
| 420 | if (resiBitsLength != 0) { |
---|
| 421 | int kMod8 = k % 8; |
---|
| 422 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 423 | if (rightMovSteps > 0) { |
---|
| 424 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 425 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 426 | } else if (rightMovSteps < 0) { |
---|
| 427 | int code1 = getLeftMovingCode(kMod8); |
---|
| 428 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 429 | int leftMovSteps = -rightMovSteps; |
---|
| 430 | rightMovSteps = 8 - leftMovSteps; |
---|
| 431 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 432 | p++; |
---|
| 433 | resiBits = resiBits |
---|
| 434 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 435 | } else // rightMovSteps == 0 |
---|
| 436 | { |
---|
| 437 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 438 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 439 | p++; |
---|
| 440 | } |
---|
| 441 | k += resiBitsLength; |
---|
| 442 | } |
---|
| 443 | |
---|
| 444 | // recover the exact data |
---|
| 445 | memset(curBytes, 0, 4); |
---|
| 446 | leadingNum = leadNum[l++]; |
---|
| 447 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 448 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 449 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 450 | if (resiBitsLength != 0) { |
---|
| 451 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 452 | curBytes[reqBytesLength] = resiByte; |
---|
| 453 | } |
---|
| 454 | |
---|
| 455 | exactData = bytesToFloat(curBytes); |
---|
| 456 | (*data)[index] = exactData + medianValue; |
---|
| 457 | memcpy(preBytes,curBytes,4); |
---|
| 458 | } |
---|
| 459 | |
---|
| 460 | /* Process row-ii data 1 --> r2-1*/ |
---|
| 461 | for (jj = 1; jj < r2; jj++) |
---|
| 462 | { |
---|
| 463 | index = ii*r2+jj; |
---|
| 464 | pred2D = (*data)[index-1] + (*data)[index-r2] - (*data)[index-r2-1]; |
---|
| 465 | |
---|
| 466 | type_ = type[index]; |
---|
| 467 | if (type_ != 0) |
---|
| 468 | { |
---|
| 469 | (*data)[index] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 470 | } |
---|
| 471 | else |
---|
| 472 | { |
---|
| 473 | // compute resiBits |
---|
| 474 | resiBits = 0; |
---|
| 475 | if (resiBitsLength != 0) { |
---|
| 476 | int kMod8 = k % 8; |
---|
| 477 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 478 | if (rightMovSteps > 0) { |
---|
| 479 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 480 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 481 | } else if (rightMovSteps < 0) { |
---|
| 482 | int code1 = getLeftMovingCode(kMod8); |
---|
| 483 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 484 | int leftMovSteps = -rightMovSteps; |
---|
| 485 | rightMovSteps = 8 - leftMovSteps; |
---|
| 486 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 487 | p++; |
---|
| 488 | resiBits = resiBits |
---|
| 489 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 490 | } else // rightMovSteps == 0 |
---|
| 491 | { |
---|
| 492 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 493 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 494 | p++; |
---|
| 495 | } |
---|
| 496 | k += resiBitsLength; |
---|
| 497 | } |
---|
| 498 | |
---|
| 499 | // recover the exact data |
---|
| 500 | memset(curBytes, 0, 4); |
---|
| 501 | leadingNum = leadNum[l++]; |
---|
| 502 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 503 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 504 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 505 | if (resiBitsLength != 0) { |
---|
| 506 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 507 | curBytes[reqBytesLength] = resiByte; |
---|
| 508 | } |
---|
| 509 | |
---|
| 510 | exactData = bytesToFloat(curBytes); |
---|
| 511 | (*data)[index] = exactData + medianValue; |
---|
| 512 | memcpy(preBytes,curBytes,4); |
---|
| 513 | } |
---|
| 514 | } |
---|
| 515 | } |
---|
| 516 | |
---|
| 517 | #ifdef HAVE_TIMECMPR |
---|
| 518 | if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
| 519 | memcpy(multisteps->hist_data, (*data), dataSeriesLength*sizeof(float)); |
---|
| 520 | #endif |
---|
| 521 | |
---|
| 522 | free(leadNum); |
---|
| 523 | free(type); |
---|
| 524 | return; |
---|
| 525 | } |
---|
| 526 | |
---|
| 527 | void decompressDataSeries_float_3D(float** data, size_t r1, size_t r2, size_t r3, TightDataPointStorageF* tdps) |
---|
| 528 | { |
---|
| 529 | updateQuantizationInfo(tdps->intervals); |
---|
| 530 | size_t j, k = 0, p = 0, l = 0; // k is to track the location of residual_bit |
---|
| 531 | // in resiMidBits, p is to track the |
---|
| 532 | // byte_index of resiMidBits, l is for |
---|
| 533 | // leadNum |
---|
| 534 | size_t dataSeriesLength = r1*r2*r3; |
---|
| 535 | size_t r23 = r2*r3; |
---|
| 536 | unsigned char* leadNum; |
---|
| 537 | double realPrecision = tdps->realPrecision; |
---|
| 538 | |
---|
| 539 | //TODO |
---|
| 540 | convertByteArray2IntArray_fast_2b(tdps->exactDataNum, tdps->leadNumArray, tdps->leadNumArray_size, &leadNum); |
---|
| 541 | |
---|
| 542 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
| 543 | int* type = (int*)malloc(dataSeriesLength*sizeof(int)); |
---|
| 544 | |
---|
| 545 | HuffmanTree* huffmanTree = createHuffmanTree(tdps->stateNum); |
---|
| 546 | decode_withTree(huffmanTree, tdps->typeArray, dataSeriesLength, type); |
---|
| 547 | SZ_ReleaseHuffman(huffmanTree); |
---|
| 548 | |
---|
| 549 | unsigned char preBytes[4]; |
---|
| 550 | unsigned char curBytes[4]; |
---|
| 551 | |
---|
| 552 | memset(preBytes, 0, 4); |
---|
| 553 | size_t curByteIndex = 0; |
---|
| 554 | int reqBytesLength, resiBitsLength, resiBits; |
---|
| 555 | unsigned char leadingNum; |
---|
| 556 | float medianValue, exactData; |
---|
| 557 | int type_; |
---|
| 558 | |
---|
| 559 | reqBytesLength = tdps->reqLength/8; |
---|
| 560 | resiBitsLength = tdps->reqLength%8; |
---|
| 561 | medianValue = tdps->medianValue; |
---|
| 562 | |
---|
| 563 | float pred1D, pred2D, pred3D; |
---|
| 564 | size_t ii, jj, kk; |
---|
| 565 | |
---|
| 566 | /////////////////////////// Process layer-0 /////////////////////////// |
---|
| 567 | /* Process Row-0 data 0*/ |
---|
| 568 | // compute resiBits |
---|
| 569 | resiBits = 0; |
---|
| 570 | if (resiBitsLength != 0) { |
---|
| 571 | int kMod8 = k % 8; |
---|
| 572 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 573 | if (rightMovSteps > 0) { |
---|
| 574 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 575 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 576 | } else if (rightMovSteps < 0) { |
---|
| 577 | int code1 = getLeftMovingCode(kMod8); |
---|
| 578 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 579 | int leftMovSteps = -rightMovSteps; |
---|
| 580 | rightMovSteps = 8 - leftMovSteps; |
---|
| 581 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 582 | p++; |
---|
| 583 | resiBits = resiBits |
---|
| 584 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 585 | } else // rightMovSteps == 0 |
---|
| 586 | { |
---|
| 587 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 588 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 589 | p++; |
---|
| 590 | } |
---|
| 591 | k += resiBitsLength; |
---|
| 592 | } |
---|
| 593 | |
---|
| 594 | // recover the exact data |
---|
| 595 | memset(curBytes, 0, 4); |
---|
| 596 | leadingNum = leadNum[l++]; |
---|
| 597 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 598 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 599 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 600 | if (resiBitsLength != 0) { |
---|
| 601 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 602 | curBytes[reqBytesLength] = resiByte; |
---|
| 603 | } |
---|
| 604 | exactData = bytesToFloat(curBytes); |
---|
| 605 | (*data)[0] = exactData + medianValue; |
---|
| 606 | memcpy(preBytes,curBytes,4); |
---|
| 607 | |
---|
| 608 | /* Process Row-0, data 1 */ |
---|
| 609 | pred1D = (*data)[0]; |
---|
| 610 | |
---|
| 611 | type_ = type[1]; |
---|
| 612 | if (type_ != 0) |
---|
| 613 | { |
---|
| 614 | (*data)[1] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 615 | } |
---|
| 616 | else |
---|
| 617 | { |
---|
| 618 | // compute resiBits |
---|
| 619 | resiBits = 0; |
---|
| 620 | if (resiBitsLength != 0) { |
---|
| 621 | int kMod8 = k % 8; |
---|
| 622 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 623 | if (rightMovSteps > 0) { |
---|
| 624 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 625 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 626 | } else if (rightMovSteps < 0) { |
---|
| 627 | int code1 = getLeftMovingCode(kMod8); |
---|
| 628 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 629 | int leftMovSteps = -rightMovSteps; |
---|
| 630 | rightMovSteps = 8 - leftMovSteps; |
---|
| 631 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 632 | p++; |
---|
| 633 | resiBits = resiBits |
---|
| 634 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 635 | } else // rightMovSteps == 0 |
---|
| 636 | { |
---|
| 637 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 638 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 639 | p++; |
---|
| 640 | } |
---|
| 641 | k += resiBitsLength; |
---|
| 642 | } |
---|
| 643 | |
---|
| 644 | // recover the exact data |
---|
| 645 | memset(curBytes, 0, 4); |
---|
| 646 | leadingNum = leadNum[l++]; |
---|
| 647 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 648 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 649 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 650 | if (resiBitsLength != 0) { |
---|
| 651 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 652 | curBytes[reqBytesLength] = resiByte; |
---|
| 653 | } |
---|
| 654 | |
---|
| 655 | exactData = bytesToFloat(curBytes); |
---|
| 656 | (*data)[1] = exactData + medianValue; |
---|
| 657 | memcpy(preBytes,curBytes,4); |
---|
| 658 | } |
---|
| 659 | /* Process Row-0, data 2 --> data r3-1 */ |
---|
| 660 | for (jj = 2; jj < r3; jj++) |
---|
| 661 | { |
---|
| 662 | pred1D = 2*(*data)[jj-1] - (*data)[jj-2]; |
---|
| 663 | |
---|
| 664 | type_ = type[jj]; |
---|
| 665 | if (type_ != 0) |
---|
| 666 | { |
---|
| 667 | (*data)[jj] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 668 | } |
---|
| 669 | else |
---|
| 670 | { |
---|
| 671 | // compute resiBits |
---|
| 672 | resiBits = 0; |
---|
| 673 | if (resiBitsLength != 0) { |
---|
| 674 | int kMod8 = k % 8; |
---|
| 675 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 676 | if (rightMovSteps > 0) { |
---|
| 677 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 678 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 679 | } else if (rightMovSteps < 0) { |
---|
| 680 | int code1 = getLeftMovingCode(kMod8); |
---|
| 681 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 682 | int leftMovSteps = -rightMovSteps; |
---|
| 683 | rightMovSteps = 8 - leftMovSteps; |
---|
| 684 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 685 | p++; |
---|
| 686 | resiBits = resiBits |
---|
| 687 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 688 | } else // rightMovSteps == 0 |
---|
| 689 | { |
---|
| 690 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 691 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 692 | p++; |
---|
| 693 | } |
---|
| 694 | k += resiBitsLength; |
---|
| 695 | } |
---|
| 696 | |
---|
| 697 | // recover the exact data |
---|
| 698 | memset(curBytes, 0, 4); |
---|
| 699 | leadingNum = leadNum[l++]; |
---|
| 700 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 701 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 702 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 703 | if (resiBitsLength != 0) { |
---|
| 704 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 705 | curBytes[reqBytesLength] = resiByte; |
---|
| 706 | } |
---|
| 707 | |
---|
| 708 | exactData = bytesToFloat(curBytes); |
---|
| 709 | (*data)[jj] = exactData + medianValue; |
---|
| 710 | memcpy(preBytes,curBytes,4); |
---|
| 711 | } |
---|
| 712 | } |
---|
| 713 | |
---|
| 714 | size_t index; |
---|
| 715 | /* Process Row-1 --> Row-r2-1 */ |
---|
| 716 | for (ii = 1; ii < r2; ii++) |
---|
| 717 | { |
---|
| 718 | /* Process row-ii data 0 */ |
---|
| 719 | index = ii*r3; |
---|
| 720 | pred1D = (*data)[index-r3]; |
---|
| 721 | |
---|
| 722 | type_ = type[index]; |
---|
| 723 | if (type_ != 0) |
---|
| 724 | { |
---|
| 725 | (*data)[index] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 726 | } |
---|
| 727 | else |
---|
| 728 | { |
---|
| 729 | // compute resiBits |
---|
| 730 | resiBits = 0; |
---|
| 731 | if (resiBitsLength != 0) { |
---|
| 732 | int kMod8 = k % 8; |
---|
| 733 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 734 | if (rightMovSteps > 0) { |
---|
| 735 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 736 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 737 | } else if (rightMovSteps < 0) { |
---|
| 738 | int code1 = getLeftMovingCode(kMod8); |
---|
| 739 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 740 | int leftMovSteps = -rightMovSteps; |
---|
| 741 | rightMovSteps = 8 - leftMovSteps; |
---|
| 742 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 743 | p++; |
---|
| 744 | resiBits = resiBits |
---|
| 745 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 746 | } else // rightMovSteps == 0 |
---|
| 747 | { |
---|
| 748 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 749 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 750 | p++; |
---|
| 751 | } |
---|
| 752 | k += resiBitsLength; |
---|
| 753 | } |
---|
| 754 | |
---|
| 755 | // recover the exact data |
---|
| 756 | memset(curBytes, 0, 4); |
---|
| 757 | leadingNum = leadNum[l++]; |
---|
| 758 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 759 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 760 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 761 | if (resiBitsLength != 0) { |
---|
| 762 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 763 | curBytes[reqBytesLength] = resiByte; |
---|
| 764 | } |
---|
| 765 | |
---|
| 766 | exactData = bytesToFloat(curBytes); |
---|
| 767 | (*data)[index] = exactData + medianValue; |
---|
| 768 | memcpy(preBytes,curBytes,4); |
---|
| 769 | } |
---|
| 770 | |
---|
| 771 | /* Process row-ii data 1 --> r3-1*/ |
---|
| 772 | for (jj = 1; jj < r3; jj++) |
---|
| 773 | { |
---|
| 774 | index = ii*r3+jj; |
---|
| 775 | pred2D = (*data)[index-1] + (*data)[index-r3] - (*data)[index-r3-1]; |
---|
| 776 | |
---|
| 777 | type_ = type[index]; |
---|
| 778 | if (type_ != 0) |
---|
| 779 | { |
---|
| 780 | (*data)[index] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 781 | } |
---|
| 782 | else |
---|
| 783 | { |
---|
| 784 | // compute resiBits |
---|
| 785 | resiBits = 0; |
---|
| 786 | if (resiBitsLength != 0) { |
---|
| 787 | int kMod8 = k % 8; |
---|
| 788 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 789 | if (rightMovSteps > 0) { |
---|
| 790 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 791 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 792 | } else if (rightMovSteps < 0) { |
---|
| 793 | int code1 = getLeftMovingCode(kMod8); |
---|
| 794 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 795 | int leftMovSteps = -rightMovSteps; |
---|
| 796 | rightMovSteps = 8 - leftMovSteps; |
---|
| 797 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 798 | p++; |
---|
| 799 | resiBits = resiBits |
---|
| 800 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 801 | } else // rightMovSteps == 0 |
---|
| 802 | { |
---|
| 803 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 804 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 805 | p++; |
---|
| 806 | } |
---|
| 807 | k += resiBitsLength; |
---|
| 808 | } |
---|
| 809 | |
---|
| 810 | // recover the exact data |
---|
| 811 | memset(curBytes, 0, 4); |
---|
| 812 | leadingNum = leadNum[l++]; |
---|
| 813 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 814 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 815 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 816 | if (resiBitsLength != 0) { |
---|
| 817 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 818 | curBytes[reqBytesLength] = resiByte; |
---|
| 819 | } |
---|
| 820 | |
---|
| 821 | exactData = bytesToFloat(curBytes); |
---|
| 822 | (*data)[index] = exactData + medianValue; |
---|
| 823 | memcpy(preBytes,curBytes,4); |
---|
| 824 | } |
---|
| 825 | } |
---|
| 826 | } |
---|
| 827 | |
---|
| 828 | /////////////////////////// Process layer-1 --> layer-r1-1 /////////////////////////// |
---|
| 829 | |
---|
| 830 | for (kk = 1; kk < r1; kk++) |
---|
| 831 | { |
---|
| 832 | /* Process Row-0 data 0*/ |
---|
| 833 | index = kk*r23; |
---|
| 834 | pred1D = (*data)[index-r23]; |
---|
| 835 | |
---|
| 836 | type_ = type[index]; |
---|
| 837 | if (type_ != 0) |
---|
| 838 | { |
---|
| 839 | (*data)[index] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 840 | } |
---|
| 841 | else |
---|
| 842 | { |
---|
| 843 | // compute resiBits |
---|
| 844 | resiBits = 0; |
---|
| 845 | if (resiBitsLength != 0) { |
---|
| 846 | int kMod8 = k % 8; |
---|
| 847 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 848 | if (rightMovSteps > 0) { |
---|
| 849 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 850 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 851 | } else if (rightMovSteps < 0) { |
---|
| 852 | int code1 = getLeftMovingCode(kMod8); |
---|
| 853 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 854 | int leftMovSteps = -rightMovSteps; |
---|
| 855 | rightMovSteps = 8 - leftMovSteps; |
---|
| 856 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 857 | p++; |
---|
| 858 | resiBits = resiBits |
---|
| 859 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 860 | } else // rightMovSteps == 0 |
---|
| 861 | { |
---|
| 862 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 863 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 864 | p++; |
---|
| 865 | } |
---|
| 866 | k += resiBitsLength; |
---|
| 867 | } |
---|
| 868 | |
---|
| 869 | // recover the exact data |
---|
| 870 | memset(curBytes, 0, 4); |
---|
| 871 | leadingNum = leadNum[l++]; |
---|
| 872 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 873 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 874 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 875 | if (resiBitsLength != 0) { |
---|
| 876 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 877 | curBytes[reqBytesLength] = resiByte; |
---|
| 878 | } |
---|
| 879 | |
---|
| 880 | exactData = bytesToFloat(curBytes); |
---|
| 881 | (*data)[index] = exactData + medianValue; |
---|
| 882 | memcpy(preBytes,curBytes,4); |
---|
| 883 | } |
---|
| 884 | |
---|
| 885 | /* Process Row-0 data 1 --> data r3-1 */ |
---|
| 886 | for (jj = 1; jj < r3; jj++) |
---|
| 887 | { |
---|
| 888 | index = kk*r23+jj; |
---|
| 889 | pred2D = (*data)[index-1] + (*data)[index-r23] - (*data)[index-r23-1]; |
---|
| 890 | |
---|
| 891 | type_ = type[index]; |
---|
| 892 | if (type_ != 0) |
---|
| 893 | { |
---|
| 894 | (*data)[index] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 895 | } |
---|
| 896 | else |
---|
| 897 | { |
---|
| 898 | // compute resiBits |
---|
| 899 | resiBits = 0; |
---|
| 900 | if (resiBitsLength != 0) { |
---|
| 901 | int kMod8 = k % 8; |
---|
| 902 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 903 | if (rightMovSteps > 0) { |
---|
| 904 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 905 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 906 | } else if (rightMovSteps < 0) { |
---|
| 907 | int code1 = getLeftMovingCode(kMod8); |
---|
| 908 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 909 | int leftMovSteps = -rightMovSteps; |
---|
| 910 | rightMovSteps = 8 - leftMovSteps; |
---|
| 911 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 912 | p++; |
---|
| 913 | resiBits = resiBits |
---|
| 914 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 915 | } else // rightMovSteps == 0 |
---|
| 916 | { |
---|
| 917 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 918 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 919 | p++; |
---|
| 920 | } |
---|
| 921 | k += resiBitsLength; |
---|
| 922 | } |
---|
| 923 | |
---|
| 924 | // recover the exact data |
---|
| 925 | memset(curBytes, 0, 4); |
---|
| 926 | leadingNum = leadNum[l++]; |
---|
| 927 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 928 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 929 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 930 | if (resiBitsLength != 0) { |
---|
| 931 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 932 | curBytes[reqBytesLength] = resiByte; |
---|
| 933 | } |
---|
| 934 | |
---|
| 935 | exactData = bytesToFloat(curBytes); |
---|
| 936 | (*data)[index] = exactData + medianValue; |
---|
| 937 | memcpy(preBytes,curBytes,4); |
---|
| 938 | } |
---|
| 939 | } |
---|
| 940 | |
---|
| 941 | /* Process Row-1 --> Row-r2-1 */ |
---|
| 942 | for (ii = 1; ii < r2; ii++) |
---|
| 943 | { |
---|
| 944 | /* Process Row-i data 0 */ |
---|
| 945 | index = kk*r23 + ii*r3; |
---|
| 946 | pred2D = (*data)[index-r3] + (*data)[index-r23] - (*data)[index-r23-r3]; |
---|
| 947 | |
---|
| 948 | type_ = type[index]; |
---|
| 949 | if (type_ != 0) |
---|
| 950 | { |
---|
| 951 | (*data)[index] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 952 | } |
---|
| 953 | else |
---|
| 954 | { |
---|
| 955 | // compute resiBits |
---|
| 956 | resiBits = 0; |
---|
| 957 | if (resiBitsLength != 0) { |
---|
| 958 | int kMod8 = k % 8; |
---|
| 959 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 960 | if (rightMovSteps > 0) { |
---|
| 961 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 962 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 963 | } else if (rightMovSteps < 0) { |
---|
| 964 | int code1 = getLeftMovingCode(kMod8); |
---|
| 965 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 966 | int leftMovSteps = -rightMovSteps; |
---|
| 967 | rightMovSteps = 8 - leftMovSteps; |
---|
| 968 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 969 | p++; |
---|
| 970 | resiBits = resiBits |
---|
| 971 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 972 | } else // rightMovSteps == 0 |
---|
| 973 | { |
---|
| 974 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 975 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 976 | p++; |
---|
| 977 | } |
---|
| 978 | k += resiBitsLength; |
---|
| 979 | } |
---|
| 980 | |
---|
| 981 | // recover the exact data |
---|
| 982 | memset(curBytes, 0, 4); |
---|
| 983 | leadingNum = leadNum[l++]; |
---|
| 984 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 985 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 986 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 987 | if (resiBitsLength != 0) { |
---|
| 988 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 989 | curBytes[reqBytesLength] = resiByte; |
---|
| 990 | } |
---|
| 991 | |
---|
| 992 | exactData = bytesToFloat(curBytes); |
---|
| 993 | (*data)[index] = exactData + medianValue; |
---|
| 994 | memcpy(preBytes,curBytes,4); |
---|
| 995 | } |
---|
| 996 | |
---|
| 997 | /* Process Row-i data 1 --> data r3-1 */ |
---|
| 998 | for (jj = 1; jj < r3; jj++) |
---|
| 999 | { |
---|
| 1000 | index = kk*r23 + ii*r3 + jj; |
---|
| 1001 | pred3D = (*data)[index-1] + (*data)[index-r3] + (*data)[index-r23] |
---|
| 1002 | - (*data)[index-r3-1] - (*data)[index-r23-r3] - (*data)[index-r23-1] + (*data)[index-r23-r3-1]; |
---|
| 1003 | |
---|
| 1004 | type_ = type[index]; |
---|
| 1005 | if (type_ != 0) |
---|
| 1006 | { |
---|
| 1007 | (*data)[index] = pred3D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 1008 | } |
---|
| 1009 | else |
---|
| 1010 | { |
---|
| 1011 | // compute resiBits |
---|
| 1012 | resiBits = 0; |
---|
| 1013 | if (resiBitsLength != 0) { |
---|
| 1014 | int kMod8 = k % 8; |
---|
| 1015 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 1016 | if (rightMovSteps > 0) { |
---|
| 1017 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1018 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 1019 | } else if (rightMovSteps < 0) { |
---|
| 1020 | int code1 = getLeftMovingCode(kMod8); |
---|
| 1021 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1022 | int leftMovSteps = -rightMovSteps; |
---|
| 1023 | rightMovSteps = 8 - leftMovSteps; |
---|
| 1024 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 1025 | p++; |
---|
| 1026 | resiBits = resiBits |
---|
| 1027 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 1028 | } else // rightMovSteps == 0 |
---|
| 1029 | { |
---|
| 1030 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1031 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 1032 | p++; |
---|
| 1033 | } |
---|
| 1034 | k += resiBitsLength; |
---|
| 1035 | } |
---|
| 1036 | |
---|
| 1037 | // recover the exact data |
---|
| 1038 | memset(curBytes, 0, 4); |
---|
| 1039 | leadingNum = leadNum[l++]; |
---|
| 1040 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 1041 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 1042 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 1043 | if (resiBitsLength != 0) { |
---|
| 1044 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 1045 | curBytes[reqBytesLength] = resiByte; |
---|
| 1046 | } |
---|
| 1047 | |
---|
| 1048 | exactData = bytesToFloat(curBytes); |
---|
| 1049 | (*data)[index] = exactData + medianValue; |
---|
| 1050 | memcpy(preBytes,curBytes,4); |
---|
| 1051 | } |
---|
| 1052 | } |
---|
| 1053 | } |
---|
| 1054 | } |
---|
| 1055 | |
---|
| 1056 | #ifdef HAVE_TIMECMPR |
---|
| 1057 | if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
| 1058 | memcpy(multisteps->hist_data, (*data), dataSeriesLength*sizeof(float)); |
---|
| 1059 | #endif |
---|
| 1060 | |
---|
| 1061 | free(leadNum); |
---|
| 1062 | free(type); |
---|
| 1063 | return; |
---|
| 1064 | } |
---|
| 1065 | |
---|
| 1066 | |
---|
| 1067 | void decompressDataSeries_float_4D(float** data, size_t r1, size_t r2, size_t r3, size_t r4, TightDataPointStorageF* tdps) |
---|
| 1068 | { |
---|
| 1069 | updateQuantizationInfo(tdps->intervals); |
---|
| 1070 | size_t j, k = 0, p = 0, l = 0; // k is to track the location of residual_bit |
---|
| 1071 | // in resiMidBits, p is to track the |
---|
| 1072 | // byte_index of resiMidBits, l is for |
---|
| 1073 | // leadNum |
---|
| 1074 | size_t dataSeriesLength = r1*r2*r3*r4; |
---|
| 1075 | size_t r234 = r2*r3*r4; |
---|
| 1076 | size_t r34 = r3*r4; |
---|
| 1077 | // printf ("%d %d %d %d\n", r1, r2, r3, r4); |
---|
| 1078 | unsigned char* leadNum; |
---|
| 1079 | double realPrecision = tdps->realPrecision; |
---|
| 1080 | |
---|
| 1081 | convertByteArray2IntArray_fast_2b(tdps->exactDataNum, tdps->leadNumArray, tdps->leadNumArray_size, &leadNum); |
---|
| 1082 | |
---|
| 1083 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
| 1084 | int* type = (int*)malloc(dataSeriesLength*sizeof(int)); |
---|
| 1085 | |
---|
| 1086 | HuffmanTree* huffmanTree = createHuffmanTree(tdps->stateNum); |
---|
| 1087 | decode_withTree(huffmanTree, tdps->typeArray, dataSeriesLength, type); |
---|
| 1088 | SZ_ReleaseHuffman(huffmanTree); |
---|
| 1089 | |
---|
| 1090 | unsigned char preBytes[4]; |
---|
| 1091 | unsigned char curBytes[4]; |
---|
| 1092 | |
---|
| 1093 | memset(preBytes, 0, 4); |
---|
| 1094 | size_t curByteIndex = 0; |
---|
| 1095 | int reqBytesLength, resiBitsLength, resiBits; |
---|
| 1096 | unsigned char leadingNum; |
---|
| 1097 | float medianValue, exactData; |
---|
| 1098 | int type_; |
---|
| 1099 | |
---|
| 1100 | reqBytesLength = tdps->reqLength/8; |
---|
| 1101 | resiBitsLength = tdps->reqLength%8; |
---|
| 1102 | medianValue = tdps->medianValue; |
---|
| 1103 | |
---|
| 1104 | float pred1D, pred2D, pred3D; |
---|
| 1105 | size_t ii, jj, kk, ll; |
---|
| 1106 | size_t index; |
---|
| 1107 | |
---|
| 1108 | for (ll = 0; ll < r1; ll++) |
---|
| 1109 | { |
---|
| 1110 | |
---|
| 1111 | /////////////////////////// Process layer-0 /////////////////////////// |
---|
| 1112 | /* Process Row-0 data 0*/ |
---|
| 1113 | index = ll*r234; |
---|
| 1114 | |
---|
| 1115 | // compute resiBits |
---|
| 1116 | resiBits = 0; |
---|
| 1117 | if (resiBitsLength != 0) { |
---|
| 1118 | int kMod8 = k % 8; |
---|
| 1119 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 1120 | if (rightMovSteps > 0) { |
---|
| 1121 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1122 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 1123 | } else if (rightMovSteps < 0) { |
---|
| 1124 | int code1 = getLeftMovingCode(kMod8); |
---|
| 1125 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1126 | int leftMovSteps = -rightMovSteps; |
---|
| 1127 | rightMovSteps = 8 - leftMovSteps; |
---|
| 1128 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 1129 | p++; |
---|
| 1130 | resiBits = resiBits |
---|
| 1131 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 1132 | } else // rightMovSteps == 0 |
---|
| 1133 | { |
---|
| 1134 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1135 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 1136 | p++; |
---|
| 1137 | } |
---|
| 1138 | k += resiBitsLength; |
---|
| 1139 | } |
---|
| 1140 | |
---|
| 1141 | // recover the exact data |
---|
| 1142 | memset(curBytes, 0, 4); |
---|
| 1143 | leadingNum = leadNum[l++]; |
---|
| 1144 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 1145 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 1146 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 1147 | if (resiBitsLength != 0) { |
---|
| 1148 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 1149 | curBytes[reqBytesLength] = resiByte; |
---|
| 1150 | } |
---|
| 1151 | exactData = bytesToFloat(curBytes); |
---|
| 1152 | (*data)[index] = exactData + medianValue; |
---|
| 1153 | memcpy(preBytes,curBytes,4); |
---|
| 1154 | |
---|
| 1155 | /* Process Row-0, data 1 */ |
---|
| 1156 | index = ll*r234+1; |
---|
| 1157 | |
---|
| 1158 | pred1D = (*data)[index-1]; |
---|
| 1159 | |
---|
| 1160 | type_ = type[index]; |
---|
| 1161 | if (type_ != 0) |
---|
| 1162 | { |
---|
| 1163 | (*data)[index] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 1164 | } |
---|
| 1165 | else |
---|
| 1166 | { |
---|
| 1167 | // compute resiBits |
---|
| 1168 | resiBits = 0; |
---|
| 1169 | if (resiBitsLength != 0) { |
---|
| 1170 | int kMod8 = k % 8; |
---|
| 1171 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 1172 | if (rightMovSteps > 0) { |
---|
| 1173 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1174 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 1175 | } else if (rightMovSteps < 0) { |
---|
| 1176 | int code1 = getLeftMovingCode(kMod8); |
---|
| 1177 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1178 | int leftMovSteps = -rightMovSteps; |
---|
| 1179 | rightMovSteps = 8 - leftMovSteps; |
---|
| 1180 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 1181 | p++; |
---|
| 1182 | resiBits = resiBits |
---|
| 1183 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 1184 | } else // rightMovSteps == 0 |
---|
| 1185 | { |
---|
| 1186 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1187 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 1188 | p++; |
---|
| 1189 | } |
---|
| 1190 | k += resiBitsLength; |
---|
| 1191 | } |
---|
| 1192 | |
---|
| 1193 | // recover the exact data |
---|
| 1194 | memset(curBytes, 0, 4); |
---|
| 1195 | leadingNum = leadNum[l++]; |
---|
| 1196 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 1197 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 1198 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 1199 | if (resiBitsLength != 0) { |
---|
| 1200 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 1201 | curBytes[reqBytesLength] = resiByte; |
---|
| 1202 | } |
---|
| 1203 | |
---|
| 1204 | exactData = bytesToFloat(curBytes); |
---|
| 1205 | (*data)[index] = exactData + medianValue; |
---|
| 1206 | memcpy(preBytes,curBytes,4); |
---|
| 1207 | } |
---|
| 1208 | |
---|
| 1209 | /* Process Row-0, data 2 --> data r4-1 */ |
---|
| 1210 | for (jj = 2; jj < r4; jj++) |
---|
| 1211 | { |
---|
| 1212 | index = ll*r234+jj; |
---|
| 1213 | |
---|
| 1214 | pred1D = 2*(*data)[index-1] - (*data)[index-2]; |
---|
| 1215 | |
---|
| 1216 | type_ = type[index]; |
---|
| 1217 | if (type_ != 0) |
---|
| 1218 | { |
---|
| 1219 | (*data)[index] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 1220 | } |
---|
| 1221 | else |
---|
| 1222 | { |
---|
| 1223 | // compute resiBits |
---|
| 1224 | resiBits = 0; |
---|
| 1225 | if (resiBitsLength != 0) { |
---|
| 1226 | int kMod8 = k % 8; |
---|
| 1227 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 1228 | if (rightMovSteps > 0) { |
---|
| 1229 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1230 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 1231 | } else if (rightMovSteps < 0) { |
---|
| 1232 | int code1 = getLeftMovingCode(kMod8); |
---|
| 1233 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1234 | int leftMovSteps = -rightMovSteps; |
---|
| 1235 | rightMovSteps = 8 - leftMovSteps; |
---|
| 1236 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 1237 | p++; |
---|
| 1238 | resiBits = resiBits |
---|
| 1239 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 1240 | } else // rightMovSteps == 0 |
---|
| 1241 | { |
---|
| 1242 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1243 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 1244 | p++; |
---|
| 1245 | } |
---|
| 1246 | k += resiBitsLength; |
---|
| 1247 | } |
---|
| 1248 | |
---|
| 1249 | // recover the exact data |
---|
| 1250 | memset(curBytes, 0, 4); |
---|
| 1251 | leadingNum = leadNum[l++]; |
---|
| 1252 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 1253 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 1254 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 1255 | if (resiBitsLength != 0) { |
---|
| 1256 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 1257 | curBytes[reqBytesLength] = resiByte; |
---|
| 1258 | } |
---|
| 1259 | |
---|
| 1260 | exactData = bytesToFloat(curBytes); |
---|
| 1261 | (*data)[index] = exactData + medianValue; |
---|
| 1262 | memcpy(preBytes,curBytes,4); |
---|
| 1263 | } |
---|
| 1264 | } |
---|
| 1265 | |
---|
| 1266 | /* Process Row-1 --> Row-r3-1 */ |
---|
| 1267 | for (ii = 1; ii < r3; ii++) |
---|
| 1268 | { |
---|
| 1269 | /* Process row-ii data 0 */ |
---|
| 1270 | index = ll*r234+ii*r4; |
---|
| 1271 | |
---|
| 1272 | pred1D = (*data)[index-r4]; |
---|
| 1273 | |
---|
| 1274 | type_ = type[index]; |
---|
| 1275 | if (type_ != 0) |
---|
| 1276 | { |
---|
| 1277 | (*data)[index] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 1278 | } |
---|
| 1279 | else |
---|
| 1280 | { |
---|
| 1281 | // compute resiBits |
---|
| 1282 | resiBits = 0; |
---|
| 1283 | if (resiBitsLength != 0) { |
---|
| 1284 | int kMod8 = k % 8; |
---|
| 1285 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 1286 | if (rightMovSteps > 0) { |
---|
| 1287 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1288 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 1289 | } else if (rightMovSteps < 0) { |
---|
| 1290 | int code1 = getLeftMovingCode(kMod8); |
---|
| 1291 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1292 | int leftMovSteps = -rightMovSteps; |
---|
| 1293 | rightMovSteps = 8 - leftMovSteps; |
---|
| 1294 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 1295 | p++; |
---|
| 1296 | resiBits = resiBits |
---|
| 1297 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 1298 | } else // rightMovSteps == 0 |
---|
| 1299 | { |
---|
| 1300 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1301 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 1302 | p++; |
---|
| 1303 | } |
---|
| 1304 | k += resiBitsLength; |
---|
| 1305 | } |
---|
| 1306 | |
---|
| 1307 | // recover the exact data |
---|
| 1308 | memset(curBytes, 0, 4); |
---|
| 1309 | leadingNum = leadNum[l++]; |
---|
| 1310 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 1311 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 1312 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 1313 | if (resiBitsLength != 0) { |
---|
| 1314 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 1315 | curBytes[reqBytesLength] = resiByte; |
---|
| 1316 | } |
---|
| 1317 | |
---|
| 1318 | exactData = bytesToFloat(curBytes); |
---|
| 1319 | (*data)[index] = exactData + medianValue; |
---|
| 1320 | memcpy(preBytes,curBytes,4); |
---|
| 1321 | } |
---|
| 1322 | |
---|
| 1323 | /* Process row-ii data 1 --> r4-1*/ |
---|
| 1324 | for (jj = 1; jj < r4; jj++) |
---|
| 1325 | { |
---|
| 1326 | index = ll*r234+ii*r4+jj; |
---|
| 1327 | |
---|
| 1328 | pred2D = (*data)[index-1] + (*data)[index-r4] - (*data)[index-r4-1]; |
---|
| 1329 | |
---|
| 1330 | type_ = type[index]; |
---|
| 1331 | if (type_ != 0) |
---|
| 1332 | { |
---|
| 1333 | (*data)[index] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 1334 | } |
---|
| 1335 | else |
---|
| 1336 | { |
---|
| 1337 | // compute resiBits |
---|
| 1338 | resiBits = 0; |
---|
| 1339 | if (resiBitsLength != 0) { |
---|
| 1340 | int kMod8 = k % 8; |
---|
| 1341 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 1342 | if (rightMovSteps > 0) { |
---|
| 1343 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1344 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 1345 | } else if (rightMovSteps < 0) { |
---|
| 1346 | int code1 = getLeftMovingCode(kMod8); |
---|
| 1347 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1348 | int leftMovSteps = -rightMovSteps; |
---|
| 1349 | rightMovSteps = 8 - leftMovSteps; |
---|
| 1350 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 1351 | p++; |
---|
| 1352 | resiBits = resiBits |
---|
| 1353 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 1354 | } else // rightMovSteps == 0 |
---|
| 1355 | { |
---|
| 1356 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1357 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 1358 | p++; |
---|
| 1359 | } |
---|
| 1360 | k += resiBitsLength; |
---|
| 1361 | } |
---|
| 1362 | |
---|
| 1363 | // recover the exact data |
---|
| 1364 | memset(curBytes, 0, 4); |
---|
| 1365 | leadingNum = leadNum[l++]; |
---|
| 1366 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 1367 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 1368 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 1369 | if (resiBitsLength != 0) { |
---|
| 1370 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 1371 | curBytes[reqBytesLength] = resiByte; |
---|
| 1372 | } |
---|
| 1373 | |
---|
| 1374 | exactData = bytesToFloat(curBytes); |
---|
| 1375 | (*data)[index] = exactData + medianValue; |
---|
| 1376 | memcpy(preBytes,curBytes,4); |
---|
| 1377 | } |
---|
| 1378 | } |
---|
| 1379 | } |
---|
| 1380 | |
---|
| 1381 | /////////////////////////// Process layer-1 --> layer-r2-1 /////////////////////////// |
---|
| 1382 | |
---|
| 1383 | for (kk = 1; kk < r2; kk++) |
---|
| 1384 | { |
---|
| 1385 | /* Process Row-0 data 0*/ |
---|
| 1386 | index = ll*r234+kk*r34; |
---|
| 1387 | |
---|
| 1388 | pred1D = (*data)[index-r34]; |
---|
| 1389 | |
---|
| 1390 | type_ = type[index]; |
---|
| 1391 | if (type_ != 0) |
---|
| 1392 | { |
---|
| 1393 | (*data)[index] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 1394 | } |
---|
| 1395 | else |
---|
| 1396 | { |
---|
| 1397 | // compute resiBits |
---|
| 1398 | resiBits = 0; |
---|
| 1399 | if (resiBitsLength != 0) { |
---|
| 1400 | int kMod8 = k % 8; |
---|
| 1401 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 1402 | if (rightMovSteps > 0) { |
---|
| 1403 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1404 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 1405 | } else if (rightMovSteps < 0) { |
---|
| 1406 | int code1 = getLeftMovingCode(kMod8); |
---|
| 1407 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1408 | int leftMovSteps = -rightMovSteps; |
---|
| 1409 | rightMovSteps = 8 - leftMovSteps; |
---|
| 1410 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 1411 | p++; |
---|
| 1412 | resiBits = resiBits |
---|
| 1413 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 1414 | } else // rightMovSteps == 0 |
---|
| 1415 | { |
---|
| 1416 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1417 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 1418 | p++; |
---|
| 1419 | } |
---|
| 1420 | k += resiBitsLength; |
---|
| 1421 | } |
---|
| 1422 | |
---|
| 1423 | // recover the exact data |
---|
| 1424 | memset(curBytes, 0, 4); |
---|
| 1425 | leadingNum = leadNum[l++]; |
---|
| 1426 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 1427 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 1428 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 1429 | if (resiBitsLength != 0) { |
---|
| 1430 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 1431 | curBytes[reqBytesLength] = resiByte; |
---|
| 1432 | } |
---|
| 1433 | |
---|
| 1434 | exactData = bytesToFloat(curBytes); |
---|
| 1435 | (*data)[index] = exactData + medianValue; |
---|
| 1436 | memcpy(preBytes,curBytes,4); |
---|
| 1437 | } |
---|
| 1438 | |
---|
| 1439 | /* Process Row-0 data 1 --> data r4-1 */ |
---|
| 1440 | for (jj = 1; jj < r4; jj++) |
---|
| 1441 | { |
---|
| 1442 | index = ll*r234+kk*r34+jj; |
---|
| 1443 | |
---|
| 1444 | pred2D = (*data)[index-1] + (*data)[index-r34] - (*data)[index-r34-1]; |
---|
| 1445 | |
---|
| 1446 | type_ = type[index]; |
---|
| 1447 | if (type_ != 0) |
---|
| 1448 | { |
---|
| 1449 | (*data)[index] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 1450 | } |
---|
| 1451 | else |
---|
| 1452 | { |
---|
| 1453 | // compute resiBits |
---|
| 1454 | resiBits = 0; |
---|
| 1455 | if (resiBitsLength != 0) { |
---|
| 1456 | int kMod8 = k % 8; |
---|
| 1457 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 1458 | if (rightMovSteps > 0) { |
---|
| 1459 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1460 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 1461 | } else if (rightMovSteps < 0) { |
---|
| 1462 | int code1 = getLeftMovingCode(kMod8); |
---|
| 1463 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1464 | int leftMovSteps = -rightMovSteps; |
---|
| 1465 | rightMovSteps = 8 - leftMovSteps; |
---|
| 1466 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 1467 | p++; |
---|
| 1468 | resiBits = resiBits |
---|
| 1469 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 1470 | } else // rightMovSteps == 0 |
---|
| 1471 | { |
---|
| 1472 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1473 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 1474 | p++; |
---|
| 1475 | } |
---|
| 1476 | k += resiBitsLength; |
---|
| 1477 | } |
---|
| 1478 | |
---|
| 1479 | // recover the exact data |
---|
| 1480 | memset(curBytes, 0, 4); |
---|
| 1481 | leadingNum = leadNum[l++]; |
---|
| 1482 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 1483 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 1484 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 1485 | if (resiBitsLength != 0) { |
---|
| 1486 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 1487 | curBytes[reqBytesLength] = resiByte; |
---|
| 1488 | } |
---|
| 1489 | |
---|
| 1490 | exactData = bytesToFloat(curBytes); |
---|
| 1491 | (*data)[index] = exactData + medianValue; |
---|
| 1492 | memcpy(preBytes,curBytes,4); |
---|
| 1493 | } |
---|
| 1494 | } |
---|
| 1495 | |
---|
| 1496 | /* Process Row-1 --> Row-r3-1 */ |
---|
| 1497 | for (ii = 1; ii < r3; ii++) |
---|
| 1498 | { |
---|
| 1499 | /* Process Row-i data 0 */ |
---|
| 1500 | index = ll*r234+kk*r34+ii*r4; |
---|
| 1501 | |
---|
| 1502 | pred2D = (*data)[index-r4] + (*data)[index-r34] - (*data)[index-r34-r4]; |
---|
| 1503 | |
---|
| 1504 | type_ = type[index]; |
---|
| 1505 | if (type_ != 0) |
---|
| 1506 | { |
---|
| 1507 | (*data)[index] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 1508 | } |
---|
| 1509 | else |
---|
| 1510 | { |
---|
| 1511 | // compute resiBits |
---|
| 1512 | resiBits = 0; |
---|
| 1513 | if (resiBitsLength != 0) { |
---|
| 1514 | int kMod8 = k % 8; |
---|
| 1515 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 1516 | if (rightMovSteps > 0) { |
---|
| 1517 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1518 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 1519 | } else if (rightMovSteps < 0) { |
---|
| 1520 | int code1 = getLeftMovingCode(kMod8); |
---|
| 1521 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1522 | int leftMovSteps = -rightMovSteps; |
---|
| 1523 | rightMovSteps = 8 - leftMovSteps; |
---|
| 1524 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 1525 | p++; |
---|
| 1526 | resiBits = resiBits |
---|
| 1527 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 1528 | } else // rightMovSteps == 0 |
---|
| 1529 | { |
---|
| 1530 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1531 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 1532 | p++; |
---|
| 1533 | } |
---|
| 1534 | k += resiBitsLength; |
---|
| 1535 | } |
---|
| 1536 | |
---|
| 1537 | // recover the exact data |
---|
| 1538 | memset(curBytes, 0, 4); |
---|
| 1539 | leadingNum = leadNum[l++]; |
---|
| 1540 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 1541 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 1542 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 1543 | if (resiBitsLength != 0) { |
---|
| 1544 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 1545 | curBytes[reqBytesLength] = resiByte; |
---|
| 1546 | } |
---|
| 1547 | |
---|
| 1548 | exactData = bytesToFloat(curBytes); |
---|
| 1549 | (*data)[index] = exactData + medianValue; |
---|
| 1550 | memcpy(preBytes,curBytes,4); |
---|
| 1551 | } |
---|
| 1552 | |
---|
| 1553 | /* Process Row-i data 1 --> data r4-1 */ |
---|
| 1554 | for (jj = 1; jj < r4; jj++) |
---|
| 1555 | { |
---|
| 1556 | index = ll*r234+kk*r34+ii*r4+jj; |
---|
| 1557 | |
---|
| 1558 | pred3D = (*data)[index-1] + (*data)[index-r4] + (*data)[index-r34] |
---|
| 1559 | - (*data)[index-r4-1] - (*data)[index-r34-r4] - (*data)[index-r34-1] + (*data)[index-r34-r4-1]; |
---|
| 1560 | |
---|
| 1561 | |
---|
| 1562 | type_ = type[index]; |
---|
| 1563 | if (type_ != 0) |
---|
| 1564 | { |
---|
| 1565 | (*data)[index] = pred3D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 1566 | } |
---|
| 1567 | else |
---|
| 1568 | { |
---|
| 1569 | // compute resiBits |
---|
| 1570 | resiBits = 0; |
---|
| 1571 | if (resiBitsLength != 0) { |
---|
| 1572 | int kMod8 = k % 8; |
---|
| 1573 | int rightMovSteps = getRightMovingSteps(kMod8, resiBitsLength); |
---|
| 1574 | if (rightMovSteps > 0) { |
---|
| 1575 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1576 | resiBits = (tdps->residualMidBits[p] & code) >> rightMovSteps; |
---|
| 1577 | } else if (rightMovSteps < 0) { |
---|
| 1578 | int code1 = getLeftMovingCode(kMod8); |
---|
| 1579 | int code2 = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1580 | int leftMovSteps = -rightMovSteps; |
---|
| 1581 | rightMovSteps = 8 - leftMovSteps; |
---|
| 1582 | resiBits = (tdps->residualMidBits[p] & code1) << leftMovSteps; |
---|
| 1583 | p++; |
---|
| 1584 | resiBits = resiBits |
---|
| 1585 | | ((tdps->residualMidBits[p] & code2) >> rightMovSteps); |
---|
| 1586 | } else // rightMovSteps == 0 |
---|
| 1587 | { |
---|
| 1588 | int code = getRightMovingCode(kMod8, resiBitsLength); |
---|
| 1589 | resiBits = (tdps->residualMidBits[p] & code); |
---|
| 1590 | p++; |
---|
| 1591 | } |
---|
| 1592 | k += resiBitsLength; |
---|
| 1593 | } |
---|
| 1594 | |
---|
| 1595 | // recover the exact data |
---|
| 1596 | memset(curBytes, 0, 4); |
---|
| 1597 | leadingNum = leadNum[l++]; |
---|
| 1598 | memcpy(curBytes, preBytes, leadingNum); |
---|
| 1599 | for (j = leadingNum; j < reqBytesLength; j++) |
---|
| 1600 | curBytes[j] = tdps->exactMidBytes[curByteIndex++]; |
---|
| 1601 | if (resiBitsLength != 0) { |
---|
| 1602 | unsigned char resiByte = (unsigned char) (resiBits << (8 - resiBitsLength)); |
---|
| 1603 | curBytes[reqBytesLength] = resiByte; |
---|
| 1604 | } |
---|
| 1605 | |
---|
| 1606 | exactData = bytesToFloat(curBytes); |
---|
| 1607 | (*data)[index] = exactData + medianValue; |
---|
| 1608 | memcpy(preBytes,curBytes,4); |
---|
| 1609 | } |
---|
| 1610 | } |
---|
| 1611 | } |
---|
| 1612 | |
---|
| 1613 | } |
---|
| 1614 | } |
---|
| 1615 | |
---|
| 1616 | //I didn't implement time-based compression for 4D actually. |
---|
| 1617 | //#ifdef HAVE_TIMECMPR |
---|
| 1618 | // if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
| 1619 | // memcpy(multisteps->hist_data, (*data), dataSeriesLength*sizeof(float)); |
---|
| 1620 | //#endif |
---|
| 1621 | |
---|
| 1622 | free(leadNum); |
---|
| 1623 | free(type); |
---|
| 1624 | return; |
---|
| 1625 | } |
---|
| 1626 | |
---|
| 1627 | void getSnapshotData_float_1D(float** data, size_t dataSeriesLength, TightDataPointStorageF* tdps, int errBoundMode) |
---|
| 1628 | { |
---|
| 1629 | size_t i; |
---|
| 1630 | |
---|
| 1631 | if (tdps->allSameData) { |
---|
| 1632 | float value = bytesToFloat(tdps->exactMidBytes); |
---|
| 1633 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
| 1634 | for (i = 0; i < dataSeriesLength; i++) |
---|
| 1635 | (*data)[i] = value; |
---|
| 1636 | } else { |
---|
| 1637 | if (tdps->rtypeArray == NULL) { |
---|
| 1638 | if(errBoundMode < PW_REL) |
---|
| 1639 | { |
---|
| 1640 | #ifdef HAVE_TIMECMPR |
---|
| 1641 | if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
| 1642 | { |
---|
| 1643 | if(multisteps->compressionType == 0) //snapshot |
---|
| 1644 | decompressDataSeries_float_1D(data, dataSeriesLength, tdps); |
---|
| 1645 | else |
---|
| 1646 | decompressDataSeries_float_1D_ts(data, dataSeriesLength, multisteps, tdps); |
---|
| 1647 | } |
---|
| 1648 | else |
---|
| 1649 | #endif |
---|
| 1650 | decompressDataSeries_float_1D(data, dataSeriesLength, tdps); |
---|
| 1651 | } |
---|
| 1652 | else |
---|
| 1653 | { |
---|
| 1654 | //decompressDataSeries_float_1D_pwr(data, dataSeriesLength, tdps); |
---|
| 1655 | decompressDataSeries_float_1D_pwrgroup(data, dataSeriesLength, tdps); |
---|
| 1656 | } |
---|
| 1657 | return; |
---|
| 1658 | } else { |
---|
| 1659 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
| 1660 | // insert the reserved values |
---|
| 1661 | //int[] rtypes = TypeManager.convertByteArray2IntArray_fast_1b( |
---|
| 1662 | // dataSeriesLength, rtypeArray); |
---|
| 1663 | int* rtypes; |
---|
| 1664 | int validLength = computeBitNumRequired(dataSeriesLength); |
---|
| 1665 | decompressBitArraybySimpleLZ77(&rtypes, tdps->rtypeArray, tdps->rtypeArray_size, dataSeriesLength, validLength); |
---|
| 1666 | size_t count = 0; |
---|
| 1667 | for (i = 0; i < dataSeriesLength; i++) { |
---|
| 1668 | if (rtypes[i] == 1) |
---|
| 1669 | (*data)[i] = tdps->reservedValue; |
---|
| 1670 | else |
---|
| 1671 | count++; |
---|
| 1672 | } |
---|
| 1673 | // get the decompressed data |
---|
| 1674 | float* decmpData; |
---|
| 1675 | if(errBoundMode < PW_REL) |
---|
| 1676 | decompressDataSeries_float_1D(&decmpData, dataSeriesLength, tdps); |
---|
| 1677 | else |
---|
| 1678 | decompressDataSeries_float_1D_pwr(&decmpData, dataSeriesLength, tdps); |
---|
| 1679 | // insert the decompressed data |
---|
| 1680 | size_t k = 0; |
---|
| 1681 | for (i = 0; i < dataSeriesLength; i++) { |
---|
| 1682 | if (rtypes[i] == 0) { |
---|
| 1683 | (*data)[i] = decmpData[k++]; |
---|
| 1684 | } |
---|
| 1685 | } |
---|
| 1686 | free(decmpData); |
---|
| 1687 | free(rtypes); |
---|
| 1688 | } |
---|
| 1689 | } |
---|
| 1690 | } |
---|
| 1691 | |
---|
| 1692 | void getSnapshotData_float_2D(float** data, size_t r1, size_t r2, TightDataPointStorageF* tdps, int errBoundMode) |
---|
| 1693 | { |
---|
| 1694 | size_t i; |
---|
| 1695 | size_t dataSeriesLength = r1*r2; |
---|
| 1696 | if (tdps->allSameData) { |
---|
| 1697 | float value = bytesToFloat(tdps->exactMidBytes); |
---|
| 1698 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
| 1699 | for (i = 0; i < dataSeriesLength; i++) |
---|
| 1700 | (*data)[i] = value; |
---|
| 1701 | } else { |
---|
| 1702 | if (tdps->rtypeArray == NULL) { |
---|
| 1703 | if(errBoundMode < PW_REL) |
---|
| 1704 | { |
---|
| 1705 | #ifdef HAVE_TIMECMPR |
---|
| 1706 | if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
| 1707 | { |
---|
| 1708 | if(multisteps->compressionType == 0) |
---|
| 1709 | decompressDataSeries_float_2D(data, r1, r2, tdps); |
---|
| 1710 | else |
---|
| 1711 | decompressDataSeries_float_1D_ts(data, r1*r2, multisteps, tdps); |
---|
| 1712 | } |
---|
| 1713 | else |
---|
| 1714 | #endif |
---|
| 1715 | decompressDataSeries_float_2D(data, r1, r2, tdps); |
---|
| 1716 | } |
---|
| 1717 | else |
---|
| 1718 | { |
---|
| 1719 | decompressDataSeries_float_2D_pwr(data, r1, r2, tdps); |
---|
| 1720 | } |
---|
| 1721 | |
---|
| 1722 | return; |
---|
| 1723 | } else { |
---|
| 1724 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
| 1725 | // insert the reserved values |
---|
| 1726 | //int[] rtypes = TypeManager.convertByteArray2IntArray_fast_1b( |
---|
| 1727 | // dataSeriesLength, rtypeArray); |
---|
| 1728 | int* rtypes; |
---|
| 1729 | int validLength = computeBitNumRequired(dataSeriesLength); |
---|
| 1730 | decompressBitArraybySimpleLZ77(&rtypes, tdps->rtypeArray, tdps->rtypeArray_size, dataSeriesLength, validLength); |
---|
| 1731 | size_t count = 0; |
---|
| 1732 | for (i = 0; i < dataSeriesLength; i++) { |
---|
| 1733 | if (rtypes[i] == 1) |
---|
| 1734 | (*data)[i] = tdps->reservedValue; |
---|
| 1735 | else |
---|
| 1736 | count++; |
---|
| 1737 | } |
---|
| 1738 | // get the decompressed data |
---|
| 1739 | float* decmpData; |
---|
| 1740 | if(errBoundMode < PW_REL) |
---|
| 1741 | decompressDataSeries_float_2D(&decmpData, r1, r2, tdps); |
---|
| 1742 | else |
---|
| 1743 | decompressDataSeries_float_2D_pwr(&decmpData, r1, r2, tdps); |
---|
| 1744 | // insert the decompressed data |
---|
| 1745 | size_t k = 0; |
---|
| 1746 | for (i = 0; i < dataSeriesLength; i++) { |
---|
| 1747 | if (rtypes[i] == 0) { |
---|
| 1748 | (*data)[i] = decmpData[k++]; |
---|
| 1749 | } |
---|
| 1750 | } |
---|
| 1751 | free(decmpData); |
---|
| 1752 | free(rtypes); |
---|
| 1753 | } |
---|
| 1754 | } |
---|
| 1755 | } |
---|
| 1756 | |
---|
| 1757 | void getSnapshotData_float_3D(float** data, size_t r1, size_t r2, size_t r3, TightDataPointStorageF* tdps, int errBoundMode) |
---|
| 1758 | { |
---|
| 1759 | size_t i; |
---|
| 1760 | size_t dataSeriesLength = r1*r2*r3; |
---|
| 1761 | if (tdps->allSameData) { |
---|
| 1762 | float value = bytesToFloat(tdps->exactMidBytes); |
---|
| 1763 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
| 1764 | for (i = 0; i < dataSeriesLength; i++) |
---|
| 1765 | (*data)[i] = value; |
---|
| 1766 | } else { |
---|
| 1767 | if (tdps->rtypeArray == NULL) { |
---|
| 1768 | if(errBoundMode < PW_REL) |
---|
| 1769 | { |
---|
| 1770 | #ifdef HAVE_TIMECMPR |
---|
| 1771 | if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
| 1772 | { |
---|
| 1773 | if(multisteps->compressionType == 0) |
---|
| 1774 | decompressDataSeries_float_3D(data, r1, r2, r3, tdps); |
---|
| 1775 | else |
---|
| 1776 | decompressDataSeries_float_1D_ts(data, r1*r2*r3, multisteps, tdps); |
---|
| 1777 | } |
---|
| 1778 | else |
---|
| 1779 | #endif |
---|
| 1780 | decompressDataSeries_float_3D(data, r1, r2, r3, tdps); |
---|
| 1781 | } |
---|
| 1782 | else |
---|
| 1783 | { |
---|
| 1784 | decompressDataSeries_float_3D_pwr(data, r1, r2, r3, tdps); |
---|
| 1785 | } |
---|
| 1786 | |
---|
| 1787 | return; |
---|
| 1788 | } else { |
---|
| 1789 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
| 1790 | // insert the reserved values |
---|
| 1791 | //int[] rtypes = TypeManager.convertByteArray2IntArray_fast_1b( |
---|
| 1792 | // dataSeriesLength, rtypeArray); |
---|
| 1793 | int* rtypes; |
---|
| 1794 | int validLength = computeBitNumRequired(dataSeriesLength); |
---|
| 1795 | decompressBitArraybySimpleLZ77(&rtypes, tdps->rtypeArray, tdps->rtypeArray_size, dataSeriesLength, validLength); |
---|
| 1796 | size_t count = 0; |
---|
| 1797 | for (i = 0; i < dataSeriesLength; i++) { |
---|
| 1798 | if (rtypes[i] == 1) |
---|
| 1799 | (*data)[i] = tdps->reservedValue; |
---|
| 1800 | else |
---|
| 1801 | count++; |
---|
| 1802 | } |
---|
| 1803 | // get the decompressed data |
---|
| 1804 | float* decmpData; |
---|
| 1805 | if(errBoundMode < PW_REL) |
---|
| 1806 | decompressDataSeries_float_3D(&decmpData, r1, r2, r3, tdps); |
---|
| 1807 | else |
---|
| 1808 | decompressDataSeries_float_3D_pwr(&decmpData, r1, r2, r3, tdps); |
---|
| 1809 | // insert the decompressed data |
---|
| 1810 | size_t k = 0; |
---|
| 1811 | for (i = 0; i < dataSeriesLength; i++) { |
---|
| 1812 | if (rtypes[i] == 0) { |
---|
| 1813 | (*data)[i] = decmpData[k++]; |
---|
| 1814 | } |
---|
| 1815 | } |
---|
| 1816 | free(decmpData); |
---|
| 1817 | free(rtypes); |
---|
| 1818 | } |
---|
| 1819 | } |
---|
| 1820 | } |
---|
| 1821 | |
---|
| 1822 | void getSnapshotData_float_4D(float** data, size_t r1, size_t r2, size_t r3, size_t r4, TightDataPointStorageF* tdps, int errBoundMode) |
---|
| 1823 | { |
---|
| 1824 | size_t i; |
---|
| 1825 | size_t dataSeriesLength = r1*r2*r3*r4; |
---|
| 1826 | if (tdps->allSameData) { |
---|
| 1827 | float value = bytesToFloat(tdps->exactMidBytes); |
---|
| 1828 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
| 1829 | for (i = 0; i < dataSeriesLength; i++) |
---|
| 1830 | (*data)[i] = value; |
---|
| 1831 | } else { |
---|
| 1832 | if (tdps->rtypeArray == NULL) { |
---|
| 1833 | if(errBoundMode < PW_REL) |
---|
| 1834 | { |
---|
| 1835 | #ifdef HAVE_TIMECMPR |
---|
| 1836 | if(confparams_dec->szMode == SZ_TEMPORAL_COMPRESSION) |
---|
| 1837 | { |
---|
| 1838 | if(multisteps->compressionType == 0) |
---|
| 1839 | decompressDataSeries_float_4D(data, r1, r2, r3, r4, tdps); |
---|
| 1840 | else |
---|
| 1841 | decompressDataSeries_float_1D_ts(data, r1*r2*r3*r4, multisteps, tdps); |
---|
| 1842 | } |
---|
| 1843 | else |
---|
| 1844 | #endif |
---|
| 1845 | decompressDataSeries_float_4D(data, r1, r2, r3, r4, tdps); |
---|
| 1846 | } |
---|
| 1847 | else |
---|
| 1848 | { |
---|
| 1849 | decompressDataSeries_float_3D_pwr(data, r1*r2, r3, r4, tdps); |
---|
| 1850 | //ToDO |
---|
| 1851 | //decompressDataSeries_float_4D_pwr(data, r1, r2, r3, r4, tdps); |
---|
| 1852 | } |
---|
| 1853 | return; |
---|
| 1854 | } else { |
---|
| 1855 | *data = (float*)malloc(sizeof(float)*dataSeriesLength); |
---|
| 1856 | int* rtypes; |
---|
| 1857 | int validLength = computeBitNumRequired(dataSeriesLength); |
---|
| 1858 | decompressBitArraybySimpleLZ77(&rtypes, tdps->rtypeArray, tdps->rtypeArray_size, dataSeriesLength, validLength); |
---|
| 1859 | size_t count = 0; |
---|
| 1860 | for (i = 0; i < dataSeriesLength; i++) { |
---|
| 1861 | if (rtypes[i] == 1) |
---|
| 1862 | (*data)[i] = tdps->reservedValue; |
---|
| 1863 | else |
---|
| 1864 | count++; |
---|
| 1865 | } |
---|
| 1866 | // get the decompressed data |
---|
| 1867 | float* decmpData; |
---|
| 1868 | if(errBoundMode < PW_REL) |
---|
| 1869 | decompressDataSeries_float_4D(&decmpData, r1, r2, r3, r4, tdps); |
---|
| 1870 | else |
---|
| 1871 | decompressDataSeries_float_3D_pwr(&decmpData, r1*r2, r3, r4, tdps); |
---|
| 1872 | //ToDO |
---|
| 1873 | //decompressDataSeries_float_4D_pwr(&decompData, r1, r2, r3, r4, tdps); |
---|
| 1874 | // insert the decompressed data |
---|
| 1875 | size_t k = 0; |
---|
| 1876 | for (i = 0; i < dataSeriesLength; i++) { |
---|
| 1877 | if (rtypes[i] == 0) { |
---|
| 1878 | (*data)[i] = decmpData[k++]; |
---|
| 1879 | } |
---|
| 1880 | } |
---|
| 1881 | free(decmpData); |
---|
| 1882 | free(rtypes); |
---|
| 1883 | } |
---|
| 1884 | } |
---|
| 1885 | } |
---|
| 1886 | |
---|
| 1887 | size_t decompressDataSeries_float_3D_RA_block(float * data, float mean, size_t dim_0, size_t dim_1, size_t dim_2, size_t block_dim_0, size_t block_dim_1, size_t block_dim_2, double realPrecision, int * type, float * unpredictable_data){ |
---|
| 1888 | |
---|
| 1889 | size_t dim0_offset = dim_1 * dim_2; |
---|
| 1890 | size_t dim1_offset = dim_2; |
---|
| 1891 | // printf("SZ_compress_float_3D_MDQ_RA_block real dim: %d %d %d\n", real_block_dims[0], real_block_dims[1], real_block_dims[2]); |
---|
| 1892 | // fflush(stdout); |
---|
| 1893 | |
---|
| 1894 | size_t unpredictable_count = 0; |
---|
| 1895 | size_t r1, r2, r3; |
---|
| 1896 | r1 = block_dim_0; |
---|
| 1897 | r2 = block_dim_1; |
---|
| 1898 | r3 = block_dim_2; |
---|
| 1899 | |
---|
| 1900 | float * cur_data_pos = data; |
---|
| 1901 | float * last_row_pos; |
---|
| 1902 | float pred1D, pred2D, pred3D; |
---|
| 1903 | size_t i, j, k; |
---|
| 1904 | size_t r23 = r2*r3; |
---|
| 1905 | int type_; |
---|
| 1906 | // Process Row-0 data 0 |
---|
| 1907 | pred1D = mean; |
---|
| 1908 | type_ = type[0]; |
---|
| 1909 | // printf("Type 0 %d, mean %.4f\n", type_, mean); |
---|
| 1910 | if (type_ != 0){ |
---|
| 1911 | cur_data_pos[0] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 1912 | } |
---|
| 1913 | else{ |
---|
| 1914 | cur_data_pos[0] = unpredictable_data[unpredictable_count ++]; |
---|
| 1915 | } |
---|
| 1916 | |
---|
| 1917 | /* Process Row-0 data 1*/ |
---|
| 1918 | pred1D = cur_data_pos[0]; |
---|
| 1919 | type_ = type[1]; |
---|
| 1920 | if (type_ != 0){ |
---|
| 1921 | cur_data_pos[1] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 1922 | } |
---|
| 1923 | else{ |
---|
| 1924 | cur_data_pos[1] = unpredictable_data[unpredictable_count ++]; |
---|
| 1925 | } |
---|
| 1926 | /* Process Row-0 data 2 --> data r3-1 */ |
---|
| 1927 | for (j = 2; j < r3; j++){ |
---|
| 1928 | pred1D = 2*cur_data_pos[j-1] - cur_data_pos[j-2]; |
---|
| 1929 | type_ = type[j]; |
---|
| 1930 | if (type_ != 0){ |
---|
| 1931 | cur_data_pos[j] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 1932 | } |
---|
| 1933 | else{ |
---|
| 1934 | cur_data_pos[j] = unpredictable_data[unpredictable_count ++]; |
---|
| 1935 | } |
---|
| 1936 | } |
---|
| 1937 | |
---|
| 1938 | last_row_pos = cur_data_pos; |
---|
| 1939 | cur_data_pos += dim1_offset; |
---|
| 1940 | // printf("SZ_compress_float_3D_MDQ_RA_block row 0 done, cur_data_pos: %ld\n", cur_data_pos - block_ori_data); |
---|
| 1941 | // fflush(stdout); |
---|
| 1942 | |
---|
| 1943 | /* Process Row-1 --> Row-r2-1 */ |
---|
| 1944 | size_t index; |
---|
| 1945 | for (i = 1; i < r2; i++) |
---|
| 1946 | { |
---|
| 1947 | /* Process row-i data 0 */ |
---|
| 1948 | index = i*r3; |
---|
| 1949 | pred1D = last_row_pos[0]; |
---|
| 1950 | type_ = type[index]; |
---|
| 1951 | if (type_ != 0){ |
---|
| 1952 | cur_data_pos[0] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 1953 | } |
---|
| 1954 | else{ |
---|
| 1955 | cur_data_pos[0] = unpredictable_data[unpredictable_count ++]; |
---|
| 1956 | } |
---|
| 1957 | /* Process row-i data 1 --> data r3-1*/ |
---|
| 1958 | for (j = 1; j < r3; j++) |
---|
| 1959 | { |
---|
| 1960 | index = i*r3+j; |
---|
| 1961 | pred2D = cur_data_pos[j-1] + last_row_pos[j] - last_row_pos[j-1]; |
---|
| 1962 | type_ = type[index]; |
---|
| 1963 | if (type_ != 0){ |
---|
| 1964 | cur_data_pos[j] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 1965 | } |
---|
| 1966 | else{ |
---|
| 1967 | cur_data_pos[j] = unpredictable_data[unpredictable_count ++]; |
---|
| 1968 | } |
---|
| 1969 | // printf("pred2D %.2f cur_data %.2f last_row_data %.2f %.2f, result %.2f\n", pred2D, cur_data_pos[j-1], last_row_pos[j], last_row_pos[j-1], cur_data_pos[j]); |
---|
| 1970 | // getchar(); |
---|
| 1971 | } |
---|
| 1972 | last_row_pos = cur_data_pos; |
---|
| 1973 | cur_data_pos += dim1_offset; |
---|
| 1974 | } |
---|
| 1975 | cur_data_pos += dim0_offset - r2 * dim1_offset; |
---|
| 1976 | |
---|
| 1977 | // printf("SZ_compress_float_3D_MDQ_RA_block layer 0 done, cur_data_pos: %ld\n", cur_data_pos - block_ori_data); |
---|
| 1978 | // fflush(stdout); |
---|
| 1979 | // exit(0); |
---|
| 1980 | |
---|
| 1981 | /////////////////////////// Process layer-1 --> layer-r1-1 /////////////////////////// |
---|
| 1982 | |
---|
| 1983 | for (k = 1; k < r1; k++) |
---|
| 1984 | { |
---|
| 1985 | // if(idx == 63 && idy == 63 && idz == 63){ |
---|
| 1986 | // printf("SZ_compress_float_3D_MDQ_RA_block layer %d done, cur_data_pos: %ld\n", k-1, cur_data_pos - data); |
---|
| 1987 | // fflush(stdout); |
---|
| 1988 | // } |
---|
| 1989 | /* Process Row-0 data 0*/ |
---|
| 1990 | index = k*r23; |
---|
| 1991 | pred1D = cur_data_pos[- dim0_offset]; |
---|
| 1992 | type_ = type[index]; |
---|
| 1993 | if (type_ != 0){ |
---|
| 1994 | cur_data_pos[0] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 1995 | } |
---|
| 1996 | else{ |
---|
| 1997 | cur_data_pos[0] = unpredictable_data[unpredictable_count ++]; |
---|
| 1998 | } |
---|
| 1999 | /* Process Row-0 data 1 --> data r3-1 */ |
---|
| 2000 | for (j = 1; j < r3; j++) |
---|
| 2001 | { |
---|
| 2002 | //index = k*r2*r3+j; |
---|
| 2003 | index ++; |
---|
| 2004 | pred2D = cur_data_pos[j-1] + cur_data_pos[j - dim0_offset] - cur_data_pos[j - 1 - dim0_offset]; |
---|
| 2005 | type_ = type[index]; |
---|
| 2006 | if (type_ != 0){ |
---|
| 2007 | cur_data_pos[j] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 2008 | } |
---|
| 2009 | else{ |
---|
| 2010 | cur_data_pos[j] = unpredictable_data[unpredictable_count ++]; |
---|
| 2011 | } |
---|
| 2012 | // printf("pred2D %.2f cur_data %.2f %.2f %.2f, result %.2f\n", pred2D, cur_data_pos[j-1], cur_data_pos[j - dim0_offset], cur_data_pos[j - 1 - dim0_offset], cur_data_pos[j]); |
---|
| 2013 | // getchar(); |
---|
| 2014 | } |
---|
| 2015 | last_row_pos = cur_data_pos; |
---|
| 2016 | cur_data_pos += dim1_offset; |
---|
| 2017 | |
---|
| 2018 | // if(idx == 63 && idy == 63 && idz == 63){ |
---|
| 2019 | // printf("SZ_compress_float_3D_MDQ_RA_block layer row 0 done, cur_data_pos: %ld\n", k-1, cur_data_pos - data); |
---|
| 2020 | // fflush(stdout); |
---|
| 2021 | // } |
---|
| 2022 | |
---|
| 2023 | /* Process Row-1 --> Row-r2-1 */ |
---|
| 2024 | for (i = 1; i < r2; i++) |
---|
| 2025 | { |
---|
| 2026 | // if(idx == 63 && idy == 63 && idz == 63){ |
---|
| 2027 | // printf("SZ_compress_float_3D_MDQ_RA_block layer row %d done, cur_data_pos: %ld\n", i-1, cur_data_pos - data); |
---|
| 2028 | // fflush(stdout); |
---|
| 2029 | // } |
---|
| 2030 | /* Process Row-i data 0 */ |
---|
| 2031 | index = k*r23 + i*r3; |
---|
| 2032 | pred2D = last_row_pos[0] + cur_data_pos[- dim0_offset] - last_row_pos[- dim0_offset]; |
---|
| 2033 | type_ = type[index]; |
---|
| 2034 | if (type_ != 0){ |
---|
| 2035 | cur_data_pos[0] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 2036 | } |
---|
| 2037 | else{ |
---|
| 2038 | cur_data_pos[0] = unpredictable_data[unpredictable_count ++]; |
---|
| 2039 | } |
---|
| 2040 | |
---|
| 2041 | /* Process Row-i data 1 --> data r3-1 */ |
---|
| 2042 | for (j = 1; j < r3; j++) |
---|
| 2043 | { |
---|
| 2044 | // if(k==63&&i==43&&j==27) |
---|
| 2045 | // printf("i=%d\n", i); |
---|
| 2046 | //index = k*r2*r3 + i*r3 + j; |
---|
| 2047 | index ++; |
---|
| 2048 | pred3D = cur_data_pos[j-1] + last_row_pos[j]+ cur_data_pos[j - dim0_offset] - last_row_pos[j-1] - last_row_pos[j - dim0_offset] - cur_data_pos[j-1 - dim0_offset] + last_row_pos[j-1 - dim0_offset]; |
---|
| 2049 | type_ = type[index]; |
---|
| 2050 | if (type_ != 0){ |
---|
| 2051 | cur_data_pos[j] = pred3D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 2052 | } |
---|
| 2053 | else{ |
---|
| 2054 | cur_data_pos[j] = unpredictable_data[unpredictable_count ++]; |
---|
| 2055 | } |
---|
| 2056 | } |
---|
| 2057 | last_row_pos = cur_data_pos; |
---|
| 2058 | cur_data_pos += dim1_offset; |
---|
| 2059 | } |
---|
| 2060 | cur_data_pos += dim0_offset - r2 * dim1_offset; |
---|
| 2061 | } |
---|
| 2062 | |
---|
| 2063 | return unpredictable_count; |
---|
| 2064 | } |
---|
| 2065 | |
---|
| 2066 | size_t decompressDataSeries_float_1D_RA_block(float * data, float mean, size_t dim_0, size_t block_dim_0, double realPrecision, int * type, float * unpredictable_data){ |
---|
| 2067 | |
---|
| 2068 | size_t unpredictable_count = 0; |
---|
| 2069 | |
---|
| 2070 | float * cur_data_pos = data; |
---|
| 2071 | size_t type_index = 0; |
---|
| 2072 | int type_; |
---|
| 2073 | float last_over_thres = mean; |
---|
| 2074 | for(size_t i=0; i<block_dim_0; i++){ |
---|
| 2075 | type_ = type[type_index]; |
---|
| 2076 | if(type_ == 0){ |
---|
| 2077 | cur_data_pos[0] = unpredictable_data[unpredictable_count ++]; |
---|
| 2078 | last_over_thres = cur_data_pos[0]; |
---|
| 2079 | } |
---|
| 2080 | else{ |
---|
| 2081 | cur_data_pos[0] = last_over_thres + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 2082 | last_over_thres = cur_data_pos[0]; |
---|
| 2083 | } |
---|
| 2084 | |
---|
| 2085 | type_index ++; |
---|
| 2086 | cur_data_pos ++; |
---|
| 2087 | } |
---|
| 2088 | |
---|
| 2089 | return unpredictable_count; |
---|
| 2090 | } |
---|
| 2091 | |
---|
| 2092 | size_t decompressDataSeries_float_2D_RA_block(float * data, float mean, size_t dim_0, size_t dim_1, size_t block_dim_0, size_t block_dim_1, double realPrecision, int * type, float * unpredictable_data){ |
---|
| 2093 | |
---|
| 2094 | size_t dim0_offset = dim_1; |
---|
| 2095 | // printf("SZ_compress_float_3D_MDQ_RA_block real dim: %d %d %d\n", real_block_dims[0], real_block_dims[1], real_block_dims[2]); |
---|
| 2096 | // fflush(stdout); |
---|
| 2097 | |
---|
| 2098 | size_t unpredictable_count = 0; |
---|
| 2099 | size_t r1, r2; |
---|
| 2100 | r1 = block_dim_0; |
---|
| 2101 | r2 = block_dim_1; |
---|
| 2102 | |
---|
| 2103 | float * cur_data_pos = data; |
---|
| 2104 | float * last_row_pos; |
---|
| 2105 | float pred1D, pred2D; |
---|
| 2106 | size_t i, j; |
---|
| 2107 | int type_; |
---|
| 2108 | // Process Row-0 data 0 |
---|
| 2109 | pred1D = mean; |
---|
| 2110 | type_ = type[0]; |
---|
| 2111 | // printf("Type 0 %d, mean %.4f\n", type_, mean); |
---|
| 2112 | if (type_ != 0){ |
---|
| 2113 | cur_data_pos[0] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 2114 | } |
---|
| 2115 | else{ |
---|
| 2116 | cur_data_pos[0] = unpredictable_data[unpredictable_count ++]; |
---|
| 2117 | } |
---|
| 2118 | |
---|
| 2119 | /* Process Row-0 data 1*/ |
---|
| 2120 | pred1D = cur_data_pos[0]; |
---|
| 2121 | type_ = type[1]; |
---|
| 2122 | if (type_ != 0){ |
---|
| 2123 | cur_data_pos[1] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 2124 | } |
---|
| 2125 | else{ |
---|
| 2126 | cur_data_pos[1] = unpredictable_data[unpredictable_count ++]; |
---|
| 2127 | } |
---|
| 2128 | /* Process Row-0 data 2 --> data r3-1 */ |
---|
| 2129 | for (j = 2; j < r2; j++){ |
---|
| 2130 | pred1D = 2*cur_data_pos[j-1] - cur_data_pos[j-2]; |
---|
| 2131 | type_ = type[j]; |
---|
| 2132 | if (type_ != 0){ |
---|
| 2133 | cur_data_pos[j] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 2134 | } |
---|
| 2135 | else{ |
---|
| 2136 | cur_data_pos[j] = unpredictable_data[unpredictable_count ++]; |
---|
| 2137 | } |
---|
| 2138 | } |
---|
| 2139 | |
---|
| 2140 | last_row_pos = cur_data_pos; |
---|
| 2141 | cur_data_pos += dim0_offset; |
---|
| 2142 | // printf("SZ_compress_float_3D_MDQ_RA_block row 0 done, cur_data_pos: %ld\n", cur_data_pos - block_ori_data); |
---|
| 2143 | // fflush(stdout); |
---|
| 2144 | |
---|
| 2145 | /* Process Row-1 --> Row-r2-1 */ |
---|
| 2146 | size_t index; |
---|
| 2147 | for (i = 1; i < r1; i++) |
---|
| 2148 | { |
---|
| 2149 | /* Process row-i data 0 */ |
---|
| 2150 | index = i*r2; |
---|
| 2151 | type_ = type[index]; |
---|
| 2152 | if (type_ != 0){ |
---|
| 2153 | pred1D = last_row_pos[0]; |
---|
| 2154 | cur_data_pos[0] = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 2155 | } |
---|
| 2156 | else{ |
---|
| 2157 | cur_data_pos[0] = unpredictable_data[unpredictable_count ++]; |
---|
| 2158 | } |
---|
| 2159 | /* Process row-i data 1 --> data r3-1*/ |
---|
| 2160 | for (j = 1; j < r2; j++) |
---|
| 2161 | { |
---|
| 2162 | index = i*r2+j; |
---|
| 2163 | pred2D = cur_data_pos[j-1] + last_row_pos[j] - last_row_pos[j-1]; |
---|
| 2164 | type_ = type[index]; |
---|
| 2165 | if (type_ != 0){ |
---|
| 2166 | cur_data_pos[j] = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 2167 | } |
---|
| 2168 | else{ |
---|
| 2169 | cur_data_pos[j] = unpredictable_data[unpredictable_count ++]; |
---|
| 2170 | } |
---|
| 2171 | // printf("pred2D %.2f cur_data %.2f last_row_data %.2f %.2f, result %.2f\n", pred2D, cur_data_pos[j-1], last_row_pos[j], last_row_pos[j-1], cur_data_pos[j]); |
---|
| 2172 | // getchar(); |
---|
| 2173 | } |
---|
| 2174 | last_row_pos = cur_data_pos; |
---|
| 2175 | cur_data_pos += dim0_offset; |
---|
| 2176 | } |
---|
| 2177 | return unpredictable_count; |
---|
| 2178 | } |
---|
| 2179 | |
---|