[2c47b73] | 1 | /** |
---|
| 2 | * @file szd_uint8.c |
---|
| 3 | * @author Sheng Di |
---|
| 4 | * @date Aug, 2017 |
---|
| 5 | * @brief |
---|
| 6 | * (C) 2017 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 <math.h> |
---|
| 14 | #include "TightDataPointStorageI.h" |
---|
| 15 | #include "sz.h" |
---|
| 16 | #include "szd_uint8.h" |
---|
| 17 | #include "Huffman.h" |
---|
| 18 | |
---|
| 19 | /** |
---|
| 20 | * |
---|
| 21 | * |
---|
| 22 | * @return status SUCCESSFUL (SZ_SCES) or not (other error codes) f |
---|
| 23 | * */ |
---|
| 24 | int SZ_decompress_args_uint8(uint8_t** newData, size_t r5, size_t r4, size_t r3, size_t r2, size_t r1, unsigned char* cmpBytes, size_t cmpSize) |
---|
| 25 | { |
---|
| 26 | int status = SZ_SCES; |
---|
| 27 | size_t dataLength = computeDataLength(r5,r4,r3,r2,r1); |
---|
| 28 | |
---|
| 29 | //unsigned char* tmpBytes; |
---|
| 30 | size_t targetUncompressSize = dataLength <<2; //i.e., *4 |
---|
| 31 | //tmpSize must be "much" smaller than dataLength |
---|
| 32 | size_t i, tmpSize = 3+MetaDataByteLength+1+sizeof(uint8_t)+exe_params->SZ_SIZE_TYPE; |
---|
| 33 | unsigned char* szTmpBytes; |
---|
| 34 | |
---|
| 35 | if(cmpSize!=4+1+4+MetaDataByteLength && cmpSize!=4+1+8+MetaDataByteLength) |
---|
| 36 | { |
---|
| 37 | int isZlib = isZlibFormat(cmpBytes[0], cmpBytes[1]); |
---|
| 38 | if(isZlib) |
---|
| 39 | confparams_dec->szMode = SZ_BEST_COMPRESSION; |
---|
| 40 | else |
---|
| 41 | confparams_dec->szMode = SZ_BEST_SPEED; |
---|
| 42 | if(confparams_dec->szMode==SZ_BEST_SPEED) |
---|
| 43 | { |
---|
| 44 | tmpSize = cmpSize; |
---|
| 45 | szTmpBytes = cmpBytes; |
---|
| 46 | } |
---|
| 47 | else if(confparams_dec->szMode==SZ_BEST_COMPRESSION || confparams_dec->szMode==SZ_DEFAULT_COMPRESSION) |
---|
| 48 | { |
---|
| 49 | if(targetUncompressSize<MIN_ZLIB_DEC_ALLOMEM_BYTES) //Considering the minimum size |
---|
| 50 | targetUncompressSize = MIN_ZLIB_DEC_ALLOMEM_BYTES; |
---|
| 51 | 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 |
---|
| 52 | //szTmpBytes = (unsigned char*)malloc(sizeof(unsigned char)*tmpSize); |
---|
| 53 | //memcpy(szTmpBytes, tmpBytes, tmpSize); |
---|
| 54 | //free(tmpBytes); //release useless memory |
---|
| 55 | } |
---|
| 56 | else |
---|
| 57 | { |
---|
| 58 | printf("Wrong value of confparams_dec->szMode in the double compressed bytes.\n"); |
---|
| 59 | status = SZ_MERR; |
---|
| 60 | return status; |
---|
| 61 | } |
---|
| 62 | } |
---|
| 63 | else |
---|
| 64 | szTmpBytes = cmpBytes; |
---|
| 65 | //TODO: convert szTmpBytes to data array. |
---|
| 66 | TightDataPointStorageI* tdps; |
---|
| 67 | int errBoundMode = new_TightDataPointStorageI_fromFlatBytes(&tdps, szTmpBytes, tmpSize); |
---|
| 68 | //writeByteData(tdps->typeArray, tdps->typeArray_size, "decompress-typebytes.tbt"); |
---|
| 69 | int dim = computeDimension(r5,r4,r3,r2,r1); |
---|
| 70 | int intSize = sizeof(uint8_t); |
---|
| 71 | if(tdps->isLossless) |
---|
| 72 | { |
---|
| 73 | *newData = (uint8_t*)malloc(intSize*dataLength); |
---|
| 74 | if(sysEndianType==BIG_ENDIAN_SYSTEM) |
---|
| 75 | { |
---|
| 76 | memcpy(*newData, szTmpBytes+4+MetaDataByteLength+exe_params->SZ_SIZE_TYPE, dataLength*intSize); |
---|
| 77 | } |
---|
| 78 | else |
---|
| 79 | { |
---|
| 80 | unsigned char* p = szTmpBytes+4+MetaDataByteLength+exe_params->SZ_SIZE_TYPE; |
---|
| 81 | for(i=0;i<dataLength;i++,p+=intSize) |
---|
| 82 | (*newData)[i] = *p; |
---|
| 83 | } |
---|
| 84 | } |
---|
| 85 | else if (dim == 1) |
---|
| 86 | getSnapshotData_uint8_1D(newData,r1,tdps, errBoundMode); |
---|
| 87 | else |
---|
| 88 | if (dim == 2) |
---|
| 89 | getSnapshotData_uint8_2D(newData,r2,r1,tdps, errBoundMode); |
---|
| 90 | else |
---|
| 91 | if (dim == 3) |
---|
| 92 | getSnapshotData_uint8_3D(newData,r3,r2,r1,tdps, errBoundMode); |
---|
| 93 | else |
---|
| 94 | if (dim == 4) |
---|
| 95 | getSnapshotData_uint8_4D(newData,r4,r3,r2,r1,tdps, errBoundMode); |
---|
| 96 | else |
---|
| 97 | { |
---|
| 98 | printf("Error: currently support only at most 4 dimensions!\n"); |
---|
| 99 | status = SZ_DERR; |
---|
| 100 | } |
---|
| 101 | free_TightDataPointStorageI2(tdps); |
---|
| 102 | if(confparams_dec->szMode!=SZ_BEST_SPEED && cmpSize!=4+sizeof(uint8_t)+exe_params->SZ_SIZE_TYPE+MetaDataByteLength) |
---|
| 103 | free(szTmpBytes); |
---|
| 104 | return status; |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | void decompressDataSeries_uint8_1D(uint8_t** data, size_t dataSeriesLength, TightDataPointStorageI* tdps) |
---|
| 109 | { |
---|
| 110 | updateQuantizationInfo(tdps->intervals); |
---|
| 111 | size_t i; |
---|
| 112 | double interval = tdps->realPrecision*2; |
---|
| 113 | |
---|
| 114 | *data = (uint8_t*)malloc(sizeof(uint8_t)*dataSeriesLength); |
---|
| 115 | |
---|
| 116 | int* type = (int*)malloc(dataSeriesLength*sizeof(int)); |
---|
| 117 | |
---|
| 118 | HuffmanTree* huffmanTree = createHuffmanTree(tdps->stateNum); |
---|
| 119 | decode_withTree(huffmanTree, tdps->typeArray, dataSeriesLength, type); |
---|
| 120 | SZ_ReleaseHuffman(huffmanTree); |
---|
| 121 | |
---|
| 122 | //sdi:Debug |
---|
| 123 | //writeUShortData(type, dataSeriesLength, "decompressStateBytes.sb"); |
---|
| 124 | |
---|
| 125 | long predValue, tmp; |
---|
| 126 | uint8_t minValue, exactData; |
---|
| 127 | |
---|
| 128 | minValue = tdps->minValue; |
---|
| 129 | |
---|
| 130 | int exactByteSize = tdps->exactByteSize; |
---|
| 131 | unsigned char* exactDataBytePointer = tdps->exactDataBytes; |
---|
| 132 | |
---|
| 133 | unsigned char curBytes[8] = {0,0,0,0,0,0,0,0}; |
---|
| 134 | |
---|
| 135 | int rightShiftBits = computeRightShiftBits(exactByteSize, SZ_UINT8); |
---|
| 136 | if(rightShiftBits<0) |
---|
| 137 | { |
---|
| 138 | printf("Error: rightShift < 0!\n"); |
---|
| 139 | exit(0); |
---|
| 140 | } |
---|
| 141 | int type_; |
---|
| 142 | for (i = 0; i < dataSeriesLength; i++) { |
---|
| 143 | type_ = type[i]; |
---|
| 144 | switch (type_) { |
---|
| 145 | case 0: |
---|
| 146 | // recover the exact data |
---|
| 147 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 148 | exactData = curBytes[0]; |
---|
| 149 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 150 | exactDataBytePointer += exactByteSize; |
---|
| 151 | (*data)[i] = exactData + minValue; |
---|
| 152 | break; |
---|
| 153 | default: |
---|
| 154 | //predValue = 2 * (*data)[i-1] - (*data)[i-2]; |
---|
| 155 | predValue = (*data)[i-1]; |
---|
| 156 | tmp = predValue + (type_-exe_params->intvRadius)*interval; |
---|
| 157 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 158 | (*data)[i] = tmp; |
---|
| 159 | else if(tmp < SZ_UINT8_MIN) |
---|
| 160 | (*data)[i] = SZ_UINT8_MIN; |
---|
| 161 | else |
---|
| 162 | (*data)[i] = SZ_UINT8_MAX; |
---|
| 163 | break; |
---|
| 164 | } |
---|
| 165 | //printf("%.30G\n",(*data)[i]); |
---|
| 166 | } |
---|
| 167 | free(type); |
---|
| 168 | return; |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | void decompressDataSeries_uint8_2D(uint8_t** data, size_t r1, size_t r2, TightDataPointStorageI* tdps) |
---|
| 172 | { |
---|
| 173 | updateQuantizationInfo(tdps->intervals); |
---|
| 174 | //printf("tdps->intervals=%d, exe_params->intvRadius=%d\n", tdps->intervals, exe_params->intvRadius); |
---|
| 175 | |
---|
| 176 | size_t dataSeriesLength = r1*r2; |
---|
| 177 | // printf ("%d %d\n", r1, r2); |
---|
| 178 | |
---|
| 179 | double realPrecision = tdps->realPrecision; |
---|
| 180 | |
---|
| 181 | *data = (uint8_t*)malloc(sizeof(uint8_t)*dataSeriesLength); |
---|
| 182 | |
---|
| 183 | int* type = (int*)malloc(dataSeriesLength*sizeof(int)); |
---|
| 184 | |
---|
| 185 | HuffmanTree* huffmanTree = createHuffmanTree(tdps->stateNum); |
---|
| 186 | decode_withTree(huffmanTree, tdps->typeArray, dataSeriesLength, type); |
---|
| 187 | SZ_ReleaseHuffman(huffmanTree); |
---|
| 188 | |
---|
| 189 | uint8_t minValue, exactData; |
---|
| 190 | |
---|
| 191 | minValue = tdps->minValue; |
---|
| 192 | |
---|
| 193 | int exactByteSize = tdps->exactByteSize; |
---|
| 194 | unsigned char* exactDataBytePointer = tdps->exactDataBytes; |
---|
| 195 | |
---|
| 196 | unsigned char curBytes[8] = {0,0,0,0,0,0,0,0}; |
---|
| 197 | |
---|
| 198 | int rightShiftBits = computeRightShiftBits(exactByteSize, SZ_UINT8); |
---|
| 199 | |
---|
| 200 | long pred1D, pred2D, tmp; |
---|
| 201 | size_t ii, jj; |
---|
| 202 | |
---|
| 203 | /* Process Row-0, data 0 */ |
---|
| 204 | |
---|
| 205 | // recover the exact data |
---|
| 206 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 207 | exactData = curBytes[0]; |
---|
| 208 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 209 | exactDataBytePointer += exactByteSize; |
---|
| 210 | (*data)[0] = exactData + minValue; |
---|
| 211 | |
---|
| 212 | /* Process Row-0, data 1 */ |
---|
| 213 | int type_ = type[1]; |
---|
| 214 | if (type_ != 0) |
---|
| 215 | { |
---|
| 216 | pred1D = (*data)[0]; |
---|
| 217 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 218 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 219 | (*data)[1] = tmp; |
---|
| 220 | else if(tmp < SZ_UINT8_MIN) |
---|
| 221 | (*data)[1] = SZ_UINT8_MIN; |
---|
| 222 | else |
---|
| 223 | (*data)[1] = SZ_UINT8_MAX; |
---|
| 224 | |
---|
| 225 | } |
---|
| 226 | else |
---|
| 227 | { |
---|
| 228 | // recover the exact data |
---|
| 229 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 230 | exactData = curBytes[0]; |
---|
| 231 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 232 | exactDataBytePointer += exactByteSize; |
---|
| 233 | (*data)[1] = exactData + minValue; |
---|
| 234 | } |
---|
| 235 | |
---|
| 236 | /* Process Row-0, data 2 --> data r2-1 */ |
---|
| 237 | for (jj = 2; jj < r2; jj++) |
---|
| 238 | { |
---|
| 239 | type_ = type[jj]; |
---|
| 240 | if (type_ != 0) |
---|
| 241 | { |
---|
| 242 | pred1D = 2*(*data)[jj-1] - (*data)[jj-2]; |
---|
| 243 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 244 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 245 | (*data)[jj] = tmp; |
---|
| 246 | else if(tmp < SZ_UINT8_MIN) |
---|
| 247 | (*data)[jj] = SZ_UINT8_MIN; |
---|
| 248 | else |
---|
| 249 | (*data)[jj] = SZ_UINT8_MAX; |
---|
| 250 | } |
---|
| 251 | else |
---|
| 252 | { |
---|
| 253 | // recover the exact data |
---|
| 254 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 255 | exactData = curBytes[0]; |
---|
| 256 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 257 | exactDataBytePointer += exactByteSize; |
---|
| 258 | (*data)[jj] = exactData + minValue; |
---|
| 259 | } |
---|
| 260 | } |
---|
| 261 | |
---|
| 262 | size_t index; |
---|
| 263 | /* Process Row-1 --> Row-r1-1 */ |
---|
| 264 | for (ii = 1; ii < r1; ii++) |
---|
| 265 | { |
---|
| 266 | /* Process row-ii data 0 */ |
---|
| 267 | index = ii*r2; |
---|
| 268 | |
---|
| 269 | type_ = type[index]; |
---|
| 270 | if (type_ != 0) |
---|
| 271 | { |
---|
| 272 | pred1D = (*data)[index-r2]; |
---|
| 273 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 274 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 275 | (*data)[index] = tmp; |
---|
| 276 | else if(tmp < SZ_UINT8_MIN) |
---|
| 277 | (*data)[index] = SZ_UINT8_MIN; |
---|
| 278 | else |
---|
| 279 | (*data)[index] = SZ_UINT8_MAX; |
---|
| 280 | } |
---|
| 281 | else |
---|
| 282 | { |
---|
| 283 | // recover the exact data |
---|
| 284 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 285 | exactData = curBytes[0]; |
---|
| 286 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 287 | exactDataBytePointer += exactByteSize; |
---|
| 288 | (*data)[index] = exactData + minValue; |
---|
| 289 | } |
---|
| 290 | |
---|
| 291 | /* Process row-ii data 1 --> r2-1*/ |
---|
| 292 | for (jj = 1; jj < r2; jj++) |
---|
| 293 | { |
---|
| 294 | index = ii*r2+jj; |
---|
| 295 | pred2D = (*data)[index-1] + (*data)[index-r2] - (*data)[index-r2-1]; |
---|
| 296 | |
---|
| 297 | type_ = type[index]; |
---|
| 298 | if (type_ != 0) |
---|
| 299 | { |
---|
| 300 | tmp = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 301 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 302 | (*data)[index] = tmp; |
---|
| 303 | else if(tmp < SZ_UINT8_MIN) |
---|
| 304 | (*data)[index] = SZ_UINT8_MIN; |
---|
| 305 | else |
---|
| 306 | (*data)[index] = SZ_UINT8_MAX; |
---|
| 307 | } |
---|
| 308 | else |
---|
| 309 | { |
---|
| 310 | // recover the exact data |
---|
| 311 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 312 | exactData = curBytes[0]; |
---|
| 313 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 314 | exactDataBytePointer += exactByteSize; |
---|
| 315 | (*data)[index] = exactData + minValue; |
---|
| 316 | } |
---|
| 317 | } |
---|
| 318 | } |
---|
| 319 | |
---|
| 320 | free(type); |
---|
| 321 | return; |
---|
| 322 | } |
---|
| 323 | |
---|
| 324 | void decompressDataSeries_uint8_3D(uint8_t** data, size_t r1, size_t r2, size_t r3, TightDataPointStorageI* tdps) |
---|
| 325 | { |
---|
| 326 | updateQuantizationInfo(tdps->intervals); |
---|
| 327 | size_t dataSeriesLength = r1*r2*r3; |
---|
| 328 | size_t r23 = r2*r3; |
---|
| 329 | // printf ("%d %d %d\n", r1, r2, r3); |
---|
| 330 | double realPrecision = tdps->realPrecision; |
---|
| 331 | |
---|
| 332 | *data = (uint8_t*)malloc(sizeof(uint8_t)*dataSeriesLength); |
---|
| 333 | int* type = (int*)malloc(dataSeriesLength*sizeof(int)); |
---|
| 334 | |
---|
| 335 | HuffmanTree* huffmanTree = createHuffmanTree(tdps->stateNum); |
---|
| 336 | decode_withTree(huffmanTree, tdps->typeArray, dataSeriesLength, type); |
---|
| 337 | SZ_ReleaseHuffman(huffmanTree); |
---|
| 338 | |
---|
| 339 | uint8_t minValue, exactData; |
---|
| 340 | |
---|
| 341 | minValue = tdps->minValue; |
---|
| 342 | |
---|
| 343 | int exactByteSize = tdps->exactByteSize; |
---|
| 344 | unsigned char* exactDataBytePointer = tdps->exactDataBytes; |
---|
| 345 | |
---|
| 346 | unsigned char curBytes[8] = {0,0,0,0,0,0,0,0}; |
---|
| 347 | |
---|
| 348 | int rightShiftBits = computeRightShiftBits(exactByteSize, SZ_UINT8); |
---|
| 349 | |
---|
| 350 | long pred1D, pred2D, pred3D, tmp; |
---|
| 351 | size_t ii, jj, kk; |
---|
| 352 | |
---|
| 353 | /////////////////////////// Process layer-0 /////////////////////////// |
---|
| 354 | /* Process Row-0 data 0*/ |
---|
| 355 | |
---|
| 356 | // recover the exact data |
---|
| 357 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 358 | exactData = curBytes[0]; |
---|
| 359 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 360 | exactDataBytePointer += exactByteSize; |
---|
| 361 | (*data)[0] = exactData + minValue; |
---|
| 362 | |
---|
| 363 | /* Process Row-0, data 1 */ |
---|
| 364 | pred1D = (*data)[0]; |
---|
| 365 | |
---|
| 366 | int type_ = type[1]; |
---|
| 367 | if (type_ != 0) |
---|
| 368 | { |
---|
| 369 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 370 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 371 | (*data)[1] = tmp; |
---|
| 372 | else if(tmp < SZ_UINT8_MIN) |
---|
| 373 | (*data)[1] = SZ_UINT8_MIN; |
---|
| 374 | else |
---|
| 375 | (*data)[1] = SZ_UINT8_MAX; |
---|
| 376 | } |
---|
| 377 | else |
---|
| 378 | { |
---|
| 379 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 380 | exactData = curBytes[0]; |
---|
| 381 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 382 | exactDataBytePointer += exactByteSize; |
---|
| 383 | (*data)[1] = exactData + minValue; |
---|
| 384 | } |
---|
| 385 | /* Process Row-0, data 2 --> data r3-1 */ |
---|
| 386 | for (jj = 2; jj < r3; jj++) |
---|
| 387 | { |
---|
| 388 | pred1D = 2*(*data)[jj-1] - (*data)[jj-2]; |
---|
| 389 | |
---|
| 390 | type_ = type[jj]; |
---|
| 391 | if (type_ != 0) |
---|
| 392 | { |
---|
| 393 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 394 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 395 | (*data)[jj] = tmp; |
---|
| 396 | else if(tmp < SZ_UINT8_MIN) |
---|
| 397 | (*data)[jj] = SZ_UINT8_MIN; |
---|
| 398 | else |
---|
| 399 | (*data)[jj] = SZ_UINT8_MAX; } |
---|
| 400 | else |
---|
| 401 | { |
---|
| 402 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 403 | exactData = curBytes[0]; |
---|
| 404 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 405 | exactDataBytePointer += exactByteSize; |
---|
| 406 | (*data)[jj] = exactData + minValue; |
---|
| 407 | } |
---|
| 408 | } |
---|
| 409 | |
---|
| 410 | size_t index; |
---|
| 411 | /* Process Row-1 --> Row-r2-1 */ |
---|
| 412 | for (ii = 1; ii < r2; ii++) |
---|
| 413 | { |
---|
| 414 | /* Process row-ii data 0 */ |
---|
| 415 | index = ii*r3; |
---|
| 416 | pred1D = (*data)[index-r3]; |
---|
| 417 | |
---|
| 418 | type_ = type[index]; |
---|
| 419 | if (type_ != 0) |
---|
| 420 | { |
---|
| 421 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 422 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 423 | (*data)[index] = tmp; |
---|
| 424 | else if(tmp < SZ_UINT8_MIN) |
---|
| 425 | (*data)[index] = SZ_UINT8_MIN; |
---|
| 426 | else |
---|
| 427 | (*data)[index] = SZ_UINT8_MAX; |
---|
| 428 | } |
---|
| 429 | else |
---|
| 430 | { |
---|
| 431 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 432 | exactData = curBytes[0]; |
---|
| 433 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 434 | exactDataBytePointer += exactByteSize; |
---|
| 435 | (*data)[index] = exactData + minValue; |
---|
| 436 | } |
---|
| 437 | |
---|
| 438 | /* Process row-ii data 1 --> r3-1*/ |
---|
| 439 | for (jj = 1; jj < r3; jj++) |
---|
| 440 | { |
---|
| 441 | index = ii*r3+jj; |
---|
| 442 | pred2D = (*data)[index-1] + (*data)[index-r3] - (*data)[index-r3-1]; |
---|
| 443 | |
---|
| 444 | type_ = type[index]; |
---|
| 445 | if (type_ != 0) |
---|
| 446 | { |
---|
| 447 | tmp = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 448 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 449 | (*data)[index] = tmp; |
---|
| 450 | else if(tmp < SZ_UINT8_MIN) |
---|
| 451 | (*data)[index] = SZ_UINT8_MIN; |
---|
| 452 | else |
---|
| 453 | (*data)[index] = SZ_UINT8_MAX; |
---|
| 454 | } |
---|
| 455 | else |
---|
| 456 | { |
---|
| 457 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 458 | exactData = curBytes[0]; |
---|
| 459 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 460 | exactDataBytePointer += exactByteSize; |
---|
| 461 | (*data)[index] = exactData + minValue; |
---|
| 462 | } |
---|
| 463 | } |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | /////////////////////////// Process layer-1 --> layer-r1-1 /////////////////////////// |
---|
| 467 | |
---|
| 468 | for (kk = 1; kk < r1; kk++) |
---|
| 469 | { |
---|
| 470 | /* Process Row-0 data 0*/ |
---|
| 471 | index = kk*r23; |
---|
| 472 | pred1D = (*data)[index-r23]; |
---|
| 473 | |
---|
| 474 | type_ = type[index]; |
---|
| 475 | if (type_ != 0) |
---|
| 476 | { |
---|
| 477 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 478 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 479 | (*data)[index] = tmp; |
---|
| 480 | else if(tmp < SZ_UINT8_MIN) |
---|
| 481 | (*data)[index] = SZ_UINT8_MIN; |
---|
| 482 | else |
---|
| 483 | (*data)[index] = SZ_UINT8_MAX; |
---|
| 484 | } |
---|
| 485 | else |
---|
| 486 | { |
---|
| 487 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 488 | exactData = curBytes[0]; |
---|
| 489 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 490 | exactDataBytePointer += exactByteSize; |
---|
| 491 | (*data)[index] = exactData + minValue; |
---|
| 492 | } |
---|
| 493 | |
---|
| 494 | /* Process Row-0 data 1 --> data r3-1 */ |
---|
| 495 | for (jj = 1; jj < r3; jj++) |
---|
| 496 | { |
---|
| 497 | index = kk*r23+jj; |
---|
| 498 | pred2D = (*data)[index-1] + (*data)[index-r23] - (*data)[index-r23-1]; |
---|
| 499 | |
---|
| 500 | type_ = type[index]; |
---|
| 501 | if (type_ != 0) |
---|
| 502 | { |
---|
| 503 | tmp = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 504 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 505 | (*data)[index] = tmp; |
---|
| 506 | else if(tmp < SZ_UINT8_MIN) |
---|
| 507 | (*data)[index] = SZ_UINT8_MIN; |
---|
| 508 | else |
---|
| 509 | (*data)[index] = SZ_UINT8_MAX; |
---|
| 510 | } |
---|
| 511 | else |
---|
| 512 | { |
---|
| 513 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 514 | exactData = curBytes[0]; |
---|
| 515 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 516 | exactDataBytePointer += exactByteSize; |
---|
| 517 | (*data)[index] = exactData + minValue; |
---|
| 518 | } |
---|
| 519 | } |
---|
| 520 | |
---|
| 521 | /* Process Row-1 --> Row-r2-1 */ |
---|
| 522 | for (ii = 1; ii < r2; ii++) |
---|
| 523 | { |
---|
| 524 | /* Process Row-i data 0 */ |
---|
| 525 | index = kk*r23 + ii*r3; |
---|
| 526 | pred2D = (*data)[index-r3] + (*data)[index-r23] - (*data)[index-r23-r3]; |
---|
| 527 | |
---|
| 528 | type_ = type[index]; |
---|
| 529 | if (type_ != 0) |
---|
| 530 | { |
---|
| 531 | tmp = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 532 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 533 | (*data)[index] = tmp; |
---|
| 534 | else if(tmp < SZ_UINT8_MIN) |
---|
| 535 | (*data)[index] = SZ_UINT8_MIN; |
---|
| 536 | else |
---|
| 537 | (*data)[index] = SZ_UINT8_MAX; |
---|
| 538 | } |
---|
| 539 | else |
---|
| 540 | { |
---|
| 541 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 542 | exactData = curBytes[0]; |
---|
| 543 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 544 | exactDataBytePointer += exactByteSize; |
---|
| 545 | (*data)[index] = exactData + minValue; |
---|
| 546 | } |
---|
| 547 | |
---|
| 548 | /* Process Row-i data 1 --> data r3-1 */ |
---|
| 549 | for (jj = 1; jj < r3; jj++) |
---|
| 550 | { |
---|
| 551 | index = kk*r23 + ii*r3 + jj; |
---|
| 552 | pred3D = (*data)[index-1] + (*data)[index-r3] + (*data)[index-r23] |
---|
| 553 | - (*data)[index-r3-1] - (*data)[index-r23-r3] - (*data)[index-r23-1] + (*data)[index-r23-r3-1]; |
---|
| 554 | |
---|
| 555 | type_ = type[index]; |
---|
| 556 | if (type_ != 0) |
---|
| 557 | { |
---|
| 558 | tmp = pred3D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 559 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 560 | (*data)[index] = tmp; |
---|
| 561 | else if(tmp < SZ_UINT8_MIN) |
---|
| 562 | (*data)[index] = SZ_UINT8_MIN; |
---|
| 563 | else |
---|
| 564 | (*data)[index] = SZ_UINT8_MAX; |
---|
| 565 | } |
---|
| 566 | else |
---|
| 567 | { |
---|
| 568 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 569 | exactData = curBytes[0]; |
---|
| 570 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 571 | exactDataBytePointer += exactByteSize; |
---|
| 572 | (*data)[index] = exactData + minValue; |
---|
| 573 | } |
---|
| 574 | } |
---|
| 575 | } |
---|
| 576 | } |
---|
| 577 | |
---|
| 578 | free(type); |
---|
| 579 | return; |
---|
| 580 | } |
---|
| 581 | |
---|
| 582 | |
---|
| 583 | void decompressDataSeries_uint8_4D(uint8_t** data, size_t r1, size_t r2, size_t r3, size_t r4, TightDataPointStorageI* tdps) |
---|
| 584 | { |
---|
| 585 | updateQuantizationInfo(tdps->intervals); |
---|
| 586 | size_t dataSeriesLength = r1*r2*r3*r4; |
---|
| 587 | size_t r234 = r2*r3*r4; |
---|
| 588 | size_t r34 = r3*r4; |
---|
| 589 | |
---|
| 590 | double realPrecision = tdps->realPrecision; |
---|
| 591 | |
---|
| 592 | *data = (uint8_t*)malloc(sizeof(uint8_t)*dataSeriesLength); |
---|
| 593 | int* type = (int*)malloc(dataSeriesLength*sizeof(int)); |
---|
| 594 | |
---|
| 595 | HuffmanTree* huffmanTree = createHuffmanTree(tdps->stateNum); |
---|
| 596 | decode_withTree(huffmanTree, tdps->typeArray, dataSeriesLength, type); |
---|
| 597 | SZ_ReleaseHuffman(huffmanTree); |
---|
| 598 | |
---|
| 599 | uint8_t minValue, exactData; |
---|
| 600 | |
---|
| 601 | minValue = tdps->minValue; |
---|
| 602 | |
---|
| 603 | int exactByteSize = tdps->exactByteSize; |
---|
| 604 | unsigned char* exactDataBytePointer = tdps->exactDataBytes; |
---|
| 605 | |
---|
| 606 | unsigned char curBytes[8] = {0,0,0,0,0,0,0,0}; |
---|
| 607 | |
---|
| 608 | int rightShiftBits = computeRightShiftBits(exactByteSize, SZ_UINT8); |
---|
| 609 | |
---|
| 610 | int type_; |
---|
| 611 | |
---|
| 612 | long pred1D, pred2D, pred3D, tmp; |
---|
| 613 | size_t ii, jj, kk, ll; |
---|
| 614 | size_t index; |
---|
| 615 | |
---|
| 616 | for (ll = 0; ll < r1; ll++) |
---|
| 617 | { |
---|
| 618 | /////////////////////////// Process layer-0 /////////////////////////// |
---|
| 619 | /* Process Row-0 data 0*/ |
---|
| 620 | index = ll*r234; |
---|
| 621 | // recover the exact data |
---|
| 622 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 623 | exactData = curBytes[0]; |
---|
| 624 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 625 | exactDataBytePointer += exactByteSize; |
---|
| 626 | (*data)[index] = exactData + minValue; |
---|
| 627 | |
---|
| 628 | /* Process Row-0, data 1 */ |
---|
| 629 | index = ll*r234+1; |
---|
| 630 | |
---|
| 631 | pred1D = (*data)[index-1]; |
---|
| 632 | |
---|
| 633 | type_ = type[index]; |
---|
| 634 | if (type_ != 0) |
---|
| 635 | { |
---|
| 636 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 637 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 638 | (*data)[index] = tmp; |
---|
| 639 | else if(tmp < SZ_UINT8_MIN) |
---|
| 640 | (*data)[index] = SZ_UINT8_MIN; |
---|
| 641 | else |
---|
| 642 | (*data)[index] = SZ_UINT8_MAX; |
---|
| 643 | } |
---|
| 644 | else |
---|
| 645 | { |
---|
| 646 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 647 | exactData = curBytes[0]; |
---|
| 648 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 649 | exactDataBytePointer += exactByteSize; |
---|
| 650 | (*data)[index] = exactData + minValue; |
---|
| 651 | } |
---|
| 652 | |
---|
| 653 | /* Process Row-0, data 2 --> data r4-1 */ |
---|
| 654 | for (jj = 2; jj < r4; jj++) |
---|
| 655 | { |
---|
| 656 | index = ll*r234+jj; |
---|
| 657 | |
---|
| 658 | pred1D = 2*(*data)[index-1] - (*data)[index-2]; |
---|
| 659 | |
---|
| 660 | type_ = type[index]; |
---|
| 661 | if (type_ != 0) |
---|
| 662 | { |
---|
| 663 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 664 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 665 | (*data)[index] = tmp; |
---|
| 666 | else if(tmp < SZ_UINT8_MIN) |
---|
| 667 | (*data)[index] = SZ_UINT8_MIN; |
---|
| 668 | else |
---|
| 669 | (*data)[index] = SZ_UINT8_MAX; |
---|
| 670 | } |
---|
| 671 | else |
---|
| 672 | { |
---|
| 673 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 674 | exactData = curBytes[0]; |
---|
| 675 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 676 | exactDataBytePointer += exactByteSize; |
---|
| 677 | (*data)[index] = exactData + minValue; |
---|
| 678 | } |
---|
| 679 | } |
---|
| 680 | |
---|
| 681 | /* Process Row-1 --> Row-r3-1 */ |
---|
| 682 | for (ii = 1; ii < r3; ii++) |
---|
| 683 | { |
---|
| 684 | /* Process row-ii data 0 */ |
---|
| 685 | index = ll*r234+ii*r4; |
---|
| 686 | |
---|
| 687 | pred1D = (*data)[index-r4]; |
---|
| 688 | |
---|
| 689 | type_ = type[index]; |
---|
| 690 | if (type_ != 0) |
---|
| 691 | { |
---|
| 692 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 693 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 694 | (*data)[index] = tmp; |
---|
| 695 | else if(tmp < SZ_UINT8_MIN) |
---|
| 696 | (*data)[index] = SZ_UINT8_MIN; |
---|
| 697 | else |
---|
| 698 | (*data)[index] = SZ_UINT8_MAX; |
---|
| 699 | } |
---|
| 700 | else |
---|
| 701 | { |
---|
| 702 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 703 | exactData = curBytes[0]; |
---|
| 704 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 705 | exactDataBytePointer += exactByteSize; |
---|
| 706 | (*data)[index] = exactData + minValue; |
---|
| 707 | } |
---|
| 708 | |
---|
| 709 | /* Process row-ii data 1 --> r4-1*/ |
---|
| 710 | for (jj = 1; jj < r4; jj++) |
---|
| 711 | { |
---|
| 712 | index = ll*r234+ii*r4+jj; |
---|
| 713 | |
---|
| 714 | pred2D = (*data)[index-1] + (*data)[index-r4] - (*data)[index-r4-1]; |
---|
| 715 | |
---|
| 716 | type_ = type[index]; |
---|
| 717 | if (type_ != 0) |
---|
| 718 | { |
---|
| 719 | tmp = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 720 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 721 | (*data)[index] = tmp; |
---|
| 722 | else if(tmp < SZ_UINT8_MIN) |
---|
| 723 | (*data)[index] = SZ_UINT8_MIN; |
---|
| 724 | else |
---|
| 725 | (*data)[index] = SZ_UINT8_MAX; |
---|
| 726 | } |
---|
| 727 | else |
---|
| 728 | { |
---|
| 729 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 730 | exactData = curBytes[0]; |
---|
| 731 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 732 | exactDataBytePointer += exactByteSize; |
---|
| 733 | (*data)[index] = exactData + minValue; |
---|
| 734 | } |
---|
| 735 | } |
---|
| 736 | } |
---|
| 737 | |
---|
| 738 | /////////////////////////// Process layer-1 --> layer-r2-1 /////////////////////////// |
---|
| 739 | |
---|
| 740 | for (kk = 1; kk < r2; kk++) |
---|
| 741 | { |
---|
| 742 | /* Process Row-0 data 0*/ |
---|
| 743 | index = ll*r234+kk*r34; |
---|
| 744 | |
---|
| 745 | pred1D = (*data)[index-r34]; |
---|
| 746 | |
---|
| 747 | type_ = type[index]; |
---|
| 748 | if (type_ != 0) |
---|
| 749 | { |
---|
| 750 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 751 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 752 | (*data)[index] = tmp; |
---|
| 753 | else if(tmp < SZ_UINT8_MIN) |
---|
| 754 | (*data)[index] = SZ_UINT8_MIN; |
---|
| 755 | else |
---|
| 756 | (*data)[index] = SZ_UINT8_MAX; |
---|
| 757 | } |
---|
| 758 | else |
---|
| 759 | { |
---|
| 760 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 761 | exactData = curBytes[0]; |
---|
| 762 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 763 | exactDataBytePointer += exactByteSize; |
---|
| 764 | (*data)[index] = exactData + minValue; |
---|
| 765 | } |
---|
| 766 | |
---|
| 767 | /* Process Row-0 data 1 --> data r4-1 */ |
---|
| 768 | for (jj = 1; jj < r4; jj++) |
---|
| 769 | { |
---|
| 770 | index = ll*r234+kk*r34+jj; |
---|
| 771 | |
---|
| 772 | pred2D = (*data)[index-1] + (*data)[index-r34] - (*data)[index-r34-1]; |
---|
| 773 | |
---|
| 774 | type_ = type[index]; |
---|
| 775 | if (type_ != 0) |
---|
| 776 | { |
---|
| 777 | tmp = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 778 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 779 | (*data)[index] = tmp; |
---|
| 780 | else if(tmp < SZ_UINT8_MIN) |
---|
| 781 | (*data)[index] = SZ_UINT8_MIN; |
---|
| 782 | else |
---|
| 783 | (*data)[index] = SZ_UINT8_MAX; |
---|
| 784 | } |
---|
| 785 | else |
---|
| 786 | { |
---|
| 787 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 788 | exactData = curBytes[0]; |
---|
| 789 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 790 | exactDataBytePointer += exactByteSize; |
---|
| 791 | (*data)[index] = exactData + minValue; |
---|
| 792 | } |
---|
| 793 | } |
---|
| 794 | |
---|
| 795 | /* Process Row-1 --> Row-r3-1 */ |
---|
| 796 | for (ii = 1; ii < r3; ii++) |
---|
| 797 | { |
---|
| 798 | /* Process Row-i data 0 */ |
---|
| 799 | index = ll*r234+kk*r34+ii*r4; |
---|
| 800 | |
---|
| 801 | pred2D = (*data)[index-r4] + (*data)[index-r34] - (*data)[index-r34-r4]; |
---|
| 802 | |
---|
| 803 | type_ = type[index]; |
---|
| 804 | if (type_ != 0) |
---|
| 805 | { |
---|
| 806 | tmp = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 807 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 808 | (*data)[index] = tmp; |
---|
| 809 | else if(tmp < SZ_UINT8_MIN) |
---|
| 810 | (*data)[index] = SZ_UINT8_MIN; |
---|
| 811 | else |
---|
| 812 | (*data)[index] = SZ_UINT8_MAX; |
---|
| 813 | } |
---|
| 814 | else |
---|
| 815 | { |
---|
| 816 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 817 | exactData = curBytes[0]; |
---|
| 818 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 819 | exactDataBytePointer += exactByteSize; |
---|
| 820 | (*data)[index] = exactData + minValue; |
---|
| 821 | } |
---|
| 822 | |
---|
| 823 | /* Process Row-i data 1 --> data r4-1 */ |
---|
| 824 | for (jj = 1; jj < r4; jj++) |
---|
| 825 | { |
---|
| 826 | index = ll*r234+kk*r34+ii*r4+jj; |
---|
| 827 | |
---|
| 828 | pred3D = (*data)[index-1] + (*data)[index-r4] + (*data)[index-r34] |
---|
| 829 | - (*data)[index-r4-1] - (*data)[index-r34-r4] - (*data)[index-r34-1] + (*data)[index-r34-r4-1]; |
---|
| 830 | |
---|
| 831 | type_ = type[index]; |
---|
| 832 | if (type_ != 0) |
---|
| 833 | { |
---|
| 834 | tmp = pred3D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 835 | if(tmp >= SZ_UINT8_MIN&&tmp<SZ_UINT8_MAX) |
---|
| 836 | (*data)[index] = tmp; |
---|
| 837 | else if(tmp < SZ_UINT8_MIN) |
---|
| 838 | (*data)[index] = SZ_UINT8_MIN; |
---|
| 839 | else |
---|
| 840 | (*data)[index] = SZ_UINT8_MAX; |
---|
| 841 | } |
---|
| 842 | else |
---|
| 843 | { |
---|
| 844 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 845 | exactData = curBytes[0]; |
---|
| 846 | exactData = (uint8_t)exactData >> rightShiftBits; |
---|
| 847 | exactDataBytePointer += exactByteSize; |
---|
| 848 | (*data)[index] = exactData + minValue; |
---|
| 849 | } |
---|
| 850 | } |
---|
| 851 | } |
---|
| 852 | } |
---|
| 853 | } |
---|
| 854 | |
---|
| 855 | free(type); |
---|
| 856 | return; |
---|
| 857 | } |
---|
| 858 | |
---|
| 859 | void getSnapshotData_uint8_1D(uint8_t** data, size_t dataSeriesLength, TightDataPointStorageI* tdps, int errBoundMode) |
---|
| 860 | { |
---|
| 861 | size_t i; |
---|
| 862 | |
---|
| 863 | if (tdps->allSameData) { |
---|
| 864 | uint8_t value = tdps->exactDataBytes[0]; |
---|
| 865 | *data = (uint8_t*)malloc(sizeof(uint8_t)*dataSeriesLength); |
---|
| 866 | for (i = 0; i < dataSeriesLength; i++) |
---|
| 867 | (*data)[i] = value; |
---|
| 868 | } else { |
---|
| 869 | decompressDataSeries_uint8_1D(data, dataSeriesLength, tdps); |
---|
| 870 | } |
---|
| 871 | } |
---|
| 872 | |
---|
| 873 | void getSnapshotData_uint8_2D(uint8_t** data, size_t r1, size_t r2, TightDataPointStorageI* tdps, int errBoundMode) |
---|
| 874 | { |
---|
| 875 | size_t i; |
---|
| 876 | size_t dataSeriesLength = r1*r2; |
---|
| 877 | if (tdps->allSameData) { |
---|
| 878 | uint8_t value = tdps->exactDataBytes[0]; |
---|
| 879 | *data = (uint8_t*)malloc(sizeof(uint8_t)*dataSeriesLength); |
---|
| 880 | for (i = 0; i < dataSeriesLength; i++) |
---|
| 881 | (*data)[i] = value; |
---|
| 882 | } else { |
---|
| 883 | decompressDataSeries_uint8_2D(data, r1, r2, tdps); |
---|
| 884 | } |
---|
| 885 | } |
---|
| 886 | |
---|
| 887 | void getSnapshotData_uint8_3D(uint8_t** data, size_t r1, size_t r2, size_t r3, TightDataPointStorageI* tdps, int errBoundMode) |
---|
| 888 | { |
---|
| 889 | size_t i; |
---|
| 890 | size_t dataSeriesLength = r1*r2*r3; |
---|
| 891 | if (tdps->allSameData) { |
---|
| 892 | uint8_t value = tdps->exactDataBytes[0]; |
---|
| 893 | *data = (uint8_t*)malloc(sizeof(uint8_t)*dataSeriesLength); |
---|
| 894 | for (i = 0; i < dataSeriesLength; i++) |
---|
| 895 | (*data)[i] = value; |
---|
| 896 | } else { |
---|
| 897 | decompressDataSeries_uint8_3D(data, r1, r2, r3, tdps); |
---|
| 898 | } |
---|
| 899 | } |
---|
| 900 | |
---|
| 901 | void getSnapshotData_uint8_4D(uint8_t** data, size_t r1, size_t r2, size_t r3, size_t r4, TightDataPointStorageI* tdps, int errBoundMode) |
---|
| 902 | { |
---|
| 903 | size_t i; |
---|
| 904 | size_t dataSeriesLength = r1*r2*r3*r4; |
---|
| 905 | if (tdps->allSameData) { |
---|
| 906 | uint8_t value = tdps->exactDataBytes[0]; |
---|
| 907 | *data = (uint8_t*)malloc(sizeof(uint8_t)*dataSeriesLength); |
---|
| 908 | for (i = 0; i < dataSeriesLength; i++) |
---|
| 909 | (*data)[i] = value; |
---|
| 910 | } else { |
---|
| 911 | decompressDataSeries_uint8_4D(data, r1, r2, r3, r4, tdps); |
---|
| 912 | } |
---|
| 913 | } |
---|