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