[2c47b73] | 1 | /** |
---|
| 2 | * @file szd_uint16.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_uint16.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_uint16(uint16_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(uint16_t)+exe_params->SZ_SIZE_TYPE; |
---|
| 33 | unsigned char* szTmpBytes; |
---|
| 34 | |
---|
| 35 | if(cmpSize!=4+2+4+MetaDataByteLength && cmpSize!=4+2+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(uint16_t); |
---|
| 71 | if(tdps->isLossless) |
---|
| 72 | { |
---|
| 73 | *newData = (uint16_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] = bytesToUInt16_bigEndian(p); |
---|
| 83 | } |
---|
| 84 | } |
---|
| 85 | else if (dim == 1) |
---|
| 86 | getSnapshotData_uint16_1D(newData,r1,tdps, errBoundMode); |
---|
| 87 | else |
---|
| 88 | if (dim == 2) |
---|
| 89 | getSnapshotData_uint16_2D(newData,r2,r1,tdps, errBoundMode); |
---|
| 90 | else |
---|
| 91 | if (dim == 3) |
---|
| 92 | getSnapshotData_uint16_3D(newData,r3,r2,r1,tdps, errBoundMode); |
---|
| 93 | else |
---|
| 94 | if (dim == 4) |
---|
| 95 | getSnapshotData_uint16_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(uint16_t)+exe_params->SZ_SIZE_TYPE+MetaDataByteLength) |
---|
| 103 | free(szTmpBytes); |
---|
| 104 | return status; |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | void decompressDataSeries_uint16_1D(uint16_t** data, size_t dataSeriesLength, TightDataPointStorageI* tdps) |
---|
| 109 | { |
---|
| 110 | updateQuantizationInfo(tdps->intervals); |
---|
| 111 | double interval = tdps->realPrecision*2; |
---|
| 112 | |
---|
| 113 | *data = (uint16_t*)malloc(sizeof(uint16_t)*dataSeriesLength); |
---|
| 114 | |
---|
| 115 | int* type = (int*)malloc(dataSeriesLength*sizeof(int)); |
---|
| 116 | |
---|
| 117 | HuffmanTree* huffmanTree = createHuffmanTree(tdps->stateNum); |
---|
| 118 | decode_withTree(huffmanTree, tdps->typeArray, dataSeriesLength, type); |
---|
| 119 | SZ_ReleaseHuffman(huffmanTree); |
---|
| 120 | |
---|
| 121 | //sdi:Debug |
---|
| 122 | //writeUShortData(type, dataSeriesLength, "decompressStateBytes.sb"); |
---|
| 123 | |
---|
| 124 | long predValue, tmp; |
---|
| 125 | uint16_t minValue, exactData; |
---|
| 126 | |
---|
| 127 | minValue = tdps->minValue; |
---|
| 128 | |
---|
| 129 | int exactByteSize = tdps->exactByteSize; |
---|
| 130 | unsigned char* exactDataBytePointer = tdps->exactDataBytes; |
---|
| 131 | |
---|
| 132 | unsigned char curBytes[8] = {0,0,0,0,0,0,0,0}; |
---|
| 133 | |
---|
| 134 | int rightShiftBits = computeRightShiftBits(exactByteSize, SZ_UINT16); |
---|
| 135 | if(rightShiftBits<0) |
---|
| 136 | { |
---|
| 137 | printf("Error: rightShift < 0!\n"); |
---|
| 138 | exit(0); |
---|
| 139 | } |
---|
| 140 | int type_; |
---|
| 141 | for (size_t i = 0; i < dataSeriesLength; i++) { |
---|
| 142 | type_ = type[i]; |
---|
| 143 | switch (type_) { |
---|
| 144 | case 0: |
---|
| 145 | // recover the exact data |
---|
| 146 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 147 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 148 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 149 | exactDataBytePointer += exactByteSize; |
---|
| 150 | (*data)[i] = exactData + minValue; |
---|
| 151 | break; |
---|
| 152 | default: |
---|
| 153 | //predValue = 2 * (*data)[i-1] - (*data)[i-2]; |
---|
| 154 | predValue = (*data)[i-1]; |
---|
| 155 | tmp = predValue + (type_-exe_params->intvRadius)*interval; |
---|
| 156 | if(tmp >= SZ_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 157 | (*data)[i] = tmp; |
---|
| 158 | else if(tmp < SZ_UINT16_MIN) |
---|
| 159 | (*data)[i] = SZ_UINT16_MIN; |
---|
| 160 | else |
---|
| 161 | (*data)[i] = SZ_UINT16_MAX; |
---|
| 162 | break; |
---|
| 163 | } |
---|
| 164 | //printf("%.30G\n",(*data)[i]); |
---|
| 165 | } |
---|
| 166 | free(type); |
---|
| 167 | return; |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | void decompressDataSeries_uint16_2D(uint16_t** data, size_t r1, size_t r2, TightDataPointStorageI* tdps) |
---|
| 171 | { |
---|
| 172 | updateQuantizationInfo(tdps->intervals); |
---|
| 173 | //printf("tdps->intervals=%d, exe_params->intvRadius=%d\n", tdps->intervals, exe_params->intvRadius); |
---|
| 174 | |
---|
| 175 | size_t dataSeriesLength = r1*r2; |
---|
| 176 | // printf ("%d %d\n", r1, r2); |
---|
| 177 | |
---|
| 178 | double realPrecision = tdps->realPrecision; |
---|
| 179 | |
---|
| 180 | *data = (uint16_t*)malloc(sizeof(uint16_t)*dataSeriesLength); |
---|
| 181 | |
---|
| 182 | int* type = (int*)malloc(dataSeriesLength*sizeof(int)); |
---|
| 183 | |
---|
| 184 | HuffmanTree* huffmanTree = createHuffmanTree(tdps->stateNum); |
---|
| 185 | decode_withTree(huffmanTree, tdps->typeArray, dataSeriesLength, type); |
---|
| 186 | SZ_ReleaseHuffman(huffmanTree); |
---|
| 187 | |
---|
| 188 | uint16_t minValue, exactData; |
---|
| 189 | |
---|
| 190 | minValue = tdps->minValue; |
---|
| 191 | |
---|
| 192 | int exactByteSize = tdps->exactByteSize; |
---|
| 193 | unsigned char* exactDataBytePointer = tdps->exactDataBytes; |
---|
| 194 | |
---|
| 195 | unsigned char curBytes[8] = {0,0,0,0,0,0,0,0}; |
---|
| 196 | |
---|
| 197 | int rightShiftBits = computeRightShiftBits(exactByteSize, SZ_UINT16); |
---|
| 198 | |
---|
| 199 | long pred1D, pred2D, tmp; |
---|
| 200 | size_t ii, jj; |
---|
| 201 | |
---|
| 202 | /* Process Row-0, data 0 */ |
---|
| 203 | |
---|
| 204 | // recover the exact data |
---|
| 205 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 206 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 207 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 208 | exactDataBytePointer += exactByteSize; |
---|
| 209 | (*data)[0] = exactData + minValue; |
---|
| 210 | |
---|
| 211 | /* Process Row-0, data 1 */ |
---|
| 212 | int type_ = type[1]; |
---|
| 213 | if (type_ != 0) |
---|
| 214 | { |
---|
| 215 | pred1D = (*data)[0]; |
---|
| 216 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 217 | if(tmp >= SZ_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 218 | (*data)[1] = tmp; |
---|
| 219 | else if(tmp < SZ_UINT16_MIN) |
---|
| 220 | (*data)[1] = SZ_UINT16_MIN; |
---|
| 221 | else |
---|
| 222 | (*data)[1] = SZ_UINT16_MAX; |
---|
| 223 | |
---|
| 224 | } |
---|
| 225 | else |
---|
| 226 | { |
---|
| 227 | // recover the exact data |
---|
| 228 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 229 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 230 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 231 | exactDataBytePointer += exactByteSize; |
---|
| 232 | (*data)[1] = exactData + minValue; |
---|
| 233 | } |
---|
| 234 | |
---|
| 235 | /* Process Row-0, data 2 --> data r2-1 */ |
---|
| 236 | for (jj = 2; jj < r2; jj++) |
---|
| 237 | { |
---|
| 238 | type_ = type[jj]; |
---|
| 239 | if (type_ != 0) |
---|
| 240 | { |
---|
| 241 | pred1D = 2*(*data)[jj-1] - (*data)[jj-2]; |
---|
| 242 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 243 | if(tmp >= SZ_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 244 | (*data)[jj] = tmp; |
---|
| 245 | else if(tmp < SZ_UINT16_MIN) |
---|
| 246 | (*data)[jj] = SZ_UINT16_MIN; |
---|
| 247 | else |
---|
| 248 | (*data)[jj] = SZ_UINT16_MAX; |
---|
| 249 | } |
---|
| 250 | else |
---|
| 251 | { |
---|
| 252 | // recover the exact data |
---|
| 253 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 254 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 255 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 256 | exactDataBytePointer += exactByteSize; |
---|
| 257 | (*data)[jj] = exactData + minValue; |
---|
| 258 | } |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | size_t index; |
---|
| 262 | /* Process Row-1 --> Row-r1-1 */ |
---|
| 263 | for (ii = 1; ii < r1; ii++) |
---|
| 264 | { |
---|
| 265 | /* Process row-ii data 0 */ |
---|
| 266 | index = ii*r2; |
---|
| 267 | |
---|
| 268 | type_ = type[index]; |
---|
| 269 | if (type_ != 0) |
---|
| 270 | { |
---|
| 271 | pred1D = (*data)[index-r2]; |
---|
| 272 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 273 | if(tmp >= SZ_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 274 | (*data)[index] = tmp; |
---|
| 275 | else if(tmp < SZ_UINT16_MIN) |
---|
| 276 | (*data)[index] = SZ_UINT16_MIN; |
---|
| 277 | else |
---|
| 278 | (*data)[index] = SZ_UINT16_MAX; |
---|
| 279 | } |
---|
| 280 | else |
---|
| 281 | { |
---|
| 282 | // recover the exact data |
---|
| 283 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 284 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 285 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 286 | exactDataBytePointer += exactByteSize; |
---|
| 287 | (*data)[index] = exactData + minValue; |
---|
| 288 | } |
---|
| 289 | |
---|
| 290 | /* Process row-ii data 1 --> r2-1*/ |
---|
| 291 | for (jj = 1; jj < r2; jj++) |
---|
| 292 | { |
---|
| 293 | index = ii*r2+jj; |
---|
| 294 | pred2D = (*data)[index-1] + (*data)[index-r2] - (*data)[index-r2-1]; |
---|
| 295 | |
---|
| 296 | type_ = type[index]; |
---|
| 297 | if (type_ != 0) |
---|
| 298 | { |
---|
| 299 | tmp = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 300 | if(tmp >= SZ_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 301 | (*data)[index] = tmp; |
---|
| 302 | else if(tmp < SZ_UINT16_MIN) |
---|
| 303 | (*data)[index] = SZ_UINT16_MIN; |
---|
| 304 | else |
---|
| 305 | (*data)[index] = SZ_UINT16_MAX; |
---|
| 306 | } |
---|
| 307 | else |
---|
| 308 | { |
---|
| 309 | // recover the exact data |
---|
| 310 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 311 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 312 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 313 | exactDataBytePointer += exactByteSize; |
---|
| 314 | (*data)[index] = exactData + minValue; |
---|
| 315 | } |
---|
| 316 | } |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | free(type); |
---|
| 320 | return; |
---|
| 321 | } |
---|
| 322 | |
---|
| 323 | void decompressDataSeries_uint16_3D(uint16_t** data, size_t r1, size_t r2, size_t r3, TightDataPointStorageI* tdps) |
---|
| 324 | { |
---|
| 325 | updateQuantizationInfo(tdps->intervals); |
---|
| 326 | size_t dataSeriesLength = r1*r2*r3; |
---|
| 327 | size_t r23 = r2*r3; |
---|
| 328 | // printf ("%d %d %d\n", r1, r2, r3); |
---|
| 329 | double realPrecision = tdps->realPrecision; |
---|
| 330 | |
---|
| 331 | *data = (uint16_t*)malloc(sizeof(uint16_t)*dataSeriesLength); |
---|
| 332 | int* type = (int*)malloc(dataSeriesLength*sizeof(int)); |
---|
| 333 | |
---|
| 334 | HuffmanTree* huffmanTree = createHuffmanTree(tdps->stateNum); |
---|
| 335 | decode_withTree(huffmanTree, tdps->typeArray, dataSeriesLength, type); |
---|
| 336 | SZ_ReleaseHuffman(huffmanTree); |
---|
| 337 | |
---|
| 338 | uint16_t minValue, exactData; |
---|
| 339 | |
---|
| 340 | minValue = tdps->minValue; |
---|
| 341 | |
---|
| 342 | int exactByteSize = tdps->exactByteSize; |
---|
| 343 | unsigned char* exactDataBytePointer = tdps->exactDataBytes; |
---|
| 344 | |
---|
| 345 | unsigned char curBytes[8] = {0,0,0,0,0,0,0,0}; |
---|
| 346 | |
---|
| 347 | int rightShiftBits = computeRightShiftBits(exactByteSize, SZ_UINT16); |
---|
| 348 | |
---|
| 349 | long pred1D, pred2D, pred3D, tmp; |
---|
| 350 | size_t ii, jj, kk; |
---|
| 351 | |
---|
| 352 | /////////////////////////// Process layer-0 /////////////////////////// |
---|
| 353 | /* Process Row-0 data 0*/ |
---|
| 354 | |
---|
| 355 | // recover the exact data |
---|
| 356 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 357 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 358 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 359 | exactDataBytePointer += exactByteSize; |
---|
| 360 | (*data)[0] = exactData + minValue; |
---|
| 361 | |
---|
| 362 | /* Process Row-0, data 1 */ |
---|
| 363 | pred1D = (*data)[0]; |
---|
| 364 | |
---|
| 365 | int type_ = type[1]; |
---|
| 366 | if (type_ != 0) |
---|
| 367 | { |
---|
| 368 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 369 | if(tmp >= SZ_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 370 | (*data)[1] = tmp; |
---|
| 371 | else if(tmp < SZ_UINT16_MIN) |
---|
| 372 | (*data)[1] = SZ_UINT16_MIN; |
---|
| 373 | else |
---|
| 374 | (*data)[1] = SZ_UINT16_MAX; |
---|
| 375 | } |
---|
| 376 | else |
---|
| 377 | { |
---|
| 378 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 379 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 380 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 381 | exactDataBytePointer += exactByteSize; |
---|
| 382 | (*data)[1] = exactData + minValue; |
---|
| 383 | } |
---|
| 384 | /* Process Row-0, data 2 --> data r3-1 */ |
---|
| 385 | for (jj = 2; jj < r3; jj++) |
---|
| 386 | { |
---|
| 387 | pred1D = 2*(*data)[jj-1] - (*data)[jj-2]; |
---|
| 388 | |
---|
| 389 | type_ = type[jj]; |
---|
| 390 | if (type_ != 0) |
---|
| 391 | { |
---|
| 392 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 393 | if(tmp >= SZ_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 394 | (*data)[jj] = tmp; |
---|
| 395 | else if(tmp < SZ_UINT16_MIN) |
---|
| 396 | (*data)[jj] = SZ_UINT16_MIN; |
---|
| 397 | else |
---|
| 398 | (*data)[jj] = SZ_UINT16_MAX; } |
---|
| 399 | else |
---|
| 400 | { |
---|
| 401 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 402 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 403 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 404 | exactDataBytePointer += exactByteSize; |
---|
| 405 | (*data)[jj] = exactData + minValue; |
---|
| 406 | } |
---|
| 407 | } |
---|
| 408 | |
---|
| 409 | size_t index; |
---|
| 410 | /* Process Row-1 --> Row-r2-1 */ |
---|
| 411 | for (ii = 1; ii < r2; ii++) |
---|
| 412 | { |
---|
| 413 | /* Process row-ii data 0 */ |
---|
| 414 | index = ii*r3; |
---|
| 415 | pred1D = (*data)[index-r3]; |
---|
| 416 | |
---|
| 417 | type_ = type[index]; |
---|
| 418 | if (type_ != 0) |
---|
| 419 | { |
---|
| 420 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 421 | if(tmp >= SZ_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 422 | (*data)[index] = tmp; |
---|
| 423 | else if(tmp < SZ_UINT16_MIN) |
---|
| 424 | (*data)[index] = SZ_UINT16_MIN; |
---|
| 425 | else |
---|
| 426 | (*data)[index] = SZ_UINT16_MAX; |
---|
| 427 | } |
---|
| 428 | else |
---|
| 429 | { |
---|
| 430 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 431 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 432 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 433 | exactDataBytePointer += exactByteSize; |
---|
| 434 | (*data)[index] = exactData + minValue; |
---|
| 435 | } |
---|
| 436 | |
---|
| 437 | /* Process row-ii data 1 --> r3-1*/ |
---|
| 438 | for (jj = 1; jj < r3; jj++) |
---|
| 439 | { |
---|
| 440 | index = ii*r3+jj; |
---|
| 441 | pred2D = (*data)[index-1] + (*data)[index-r3] - (*data)[index-r3-1]; |
---|
| 442 | |
---|
| 443 | type_ = type[index]; |
---|
| 444 | if (type_ != 0) |
---|
| 445 | { |
---|
| 446 | tmp = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 447 | if(tmp >= SZ_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 448 | (*data)[index] = tmp; |
---|
| 449 | else if(tmp < SZ_UINT16_MIN) |
---|
| 450 | (*data)[index] = SZ_UINT16_MIN; |
---|
| 451 | else |
---|
| 452 | (*data)[index] = SZ_UINT16_MAX; |
---|
| 453 | } |
---|
| 454 | else |
---|
| 455 | { |
---|
| 456 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 457 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 458 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 459 | exactDataBytePointer += exactByteSize; |
---|
| 460 | (*data)[index] = exactData + minValue; |
---|
| 461 | } |
---|
| 462 | } |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | /////////////////////////// Process layer-1 --> layer-r1-1 /////////////////////////// |
---|
| 466 | |
---|
| 467 | for (kk = 1; kk < r1; kk++) |
---|
| 468 | { |
---|
| 469 | /* Process Row-0 data 0*/ |
---|
| 470 | index = kk*r23; |
---|
| 471 | pred1D = (*data)[index-r23]; |
---|
| 472 | |
---|
| 473 | type_ = type[index]; |
---|
| 474 | if (type_ != 0) |
---|
| 475 | { |
---|
| 476 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 477 | if(tmp >= SZ_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 478 | (*data)[index] = tmp; |
---|
| 479 | else if(tmp < SZ_UINT16_MIN) |
---|
| 480 | (*data)[index] = SZ_UINT16_MIN; |
---|
| 481 | else |
---|
| 482 | (*data)[index] = SZ_UINT16_MAX; |
---|
| 483 | } |
---|
| 484 | else |
---|
| 485 | { |
---|
| 486 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 487 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 488 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 489 | exactDataBytePointer += exactByteSize; |
---|
| 490 | (*data)[index] = exactData + minValue; |
---|
| 491 | } |
---|
| 492 | |
---|
| 493 | /* Process Row-0 data 1 --> data r3-1 */ |
---|
| 494 | for (jj = 1; jj < r3; jj++) |
---|
| 495 | { |
---|
| 496 | index = kk*r23+jj; |
---|
| 497 | pred2D = (*data)[index-1] + (*data)[index-r23] - (*data)[index-r23-1]; |
---|
| 498 | |
---|
| 499 | type_ = type[index]; |
---|
| 500 | if (type_ != 0) |
---|
| 501 | { |
---|
| 502 | tmp = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 503 | if(tmp >= SZ_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 504 | (*data)[index] = tmp; |
---|
| 505 | else if(tmp < SZ_UINT16_MIN) |
---|
| 506 | (*data)[index] = SZ_UINT16_MIN; |
---|
| 507 | else |
---|
| 508 | (*data)[index] = SZ_UINT16_MAX; |
---|
| 509 | } |
---|
| 510 | else |
---|
| 511 | { |
---|
| 512 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 513 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 514 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 515 | exactDataBytePointer += exactByteSize; |
---|
| 516 | (*data)[index] = exactData + minValue; |
---|
| 517 | } |
---|
| 518 | } |
---|
| 519 | |
---|
| 520 | /* Process Row-1 --> Row-r2-1 */ |
---|
| 521 | for (ii = 1; ii < r2; ii++) |
---|
| 522 | { |
---|
| 523 | /* Process Row-i data 0 */ |
---|
| 524 | index = kk*r23 + ii*r3; |
---|
| 525 | pred2D = (*data)[index-r3] + (*data)[index-r23] - (*data)[index-r23-r3]; |
---|
| 526 | |
---|
| 527 | type_ = type[index]; |
---|
| 528 | if (type_ != 0) |
---|
| 529 | { |
---|
| 530 | tmp = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 531 | if(tmp >= SZ_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 532 | (*data)[index] = tmp; |
---|
| 533 | else if(tmp < SZ_UINT16_MIN) |
---|
| 534 | (*data)[index] = SZ_UINT16_MIN; |
---|
| 535 | else |
---|
| 536 | (*data)[index] = SZ_UINT16_MAX; |
---|
| 537 | } |
---|
| 538 | else |
---|
| 539 | { |
---|
| 540 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 541 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 542 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 543 | exactDataBytePointer += exactByteSize; |
---|
| 544 | (*data)[index] = exactData + minValue; |
---|
| 545 | } |
---|
| 546 | |
---|
| 547 | /* Process Row-i data 1 --> data r3-1 */ |
---|
| 548 | for (jj = 1; jj < r3; jj++) |
---|
| 549 | { |
---|
| 550 | index = kk*r23 + ii*r3 + jj; |
---|
| 551 | pred3D = (*data)[index-1] + (*data)[index-r3] + (*data)[index-r23] |
---|
| 552 | - (*data)[index-r3-1] - (*data)[index-r23-r3] - (*data)[index-r23-1] + (*data)[index-r23-r3-1]; |
---|
| 553 | |
---|
| 554 | type_ = type[index]; |
---|
| 555 | if (type_ != 0) |
---|
| 556 | { |
---|
| 557 | tmp = pred3D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 558 | if(tmp >= SZ_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 559 | (*data)[index] = tmp; |
---|
| 560 | else if(tmp < SZ_UINT16_MIN) |
---|
| 561 | (*data)[index] = SZ_UINT16_MIN; |
---|
| 562 | else |
---|
| 563 | (*data)[index] = SZ_UINT16_MAX; |
---|
| 564 | } |
---|
| 565 | else |
---|
| 566 | { |
---|
| 567 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 568 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 569 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 570 | exactDataBytePointer += exactByteSize; |
---|
| 571 | (*data)[index] = exactData + minValue; |
---|
| 572 | } |
---|
| 573 | } |
---|
| 574 | } |
---|
| 575 | } |
---|
| 576 | |
---|
| 577 | free(type); |
---|
| 578 | return; |
---|
| 579 | } |
---|
| 580 | |
---|
| 581 | |
---|
| 582 | void decompressDataSeries_uint16_4D(uint16_t** data, size_t r1, size_t r2, size_t r3, size_t r4, TightDataPointStorageI* tdps) |
---|
| 583 | { |
---|
| 584 | updateQuantizationInfo(tdps->intervals); |
---|
| 585 | size_t dataSeriesLength = r1*r2*r3*r4; |
---|
| 586 | size_t r234 = r2*r3*r4; |
---|
| 587 | size_t r34 = r3*r4; |
---|
| 588 | |
---|
| 589 | double realPrecision = tdps->realPrecision; |
---|
| 590 | |
---|
| 591 | *data = (uint16_t*)malloc(sizeof(uint16_t)*dataSeriesLength); |
---|
| 592 | int* type = (int*)malloc(dataSeriesLength*sizeof(int)); |
---|
| 593 | |
---|
| 594 | HuffmanTree* huffmanTree = createHuffmanTree(tdps->stateNum); |
---|
| 595 | decode_withTree(huffmanTree, tdps->typeArray, dataSeriesLength, type); |
---|
| 596 | SZ_ReleaseHuffman(huffmanTree); |
---|
| 597 | |
---|
| 598 | uint16_t minValue, exactData; |
---|
| 599 | |
---|
| 600 | minValue = tdps->minValue; |
---|
| 601 | |
---|
| 602 | int exactByteSize = tdps->exactByteSize; |
---|
| 603 | unsigned char* exactDataBytePointer = tdps->exactDataBytes; |
---|
| 604 | |
---|
| 605 | unsigned char curBytes[8] = {0,0,0,0,0,0,0,0}; |
---|
| 606 | |
---|
| 607 | int rightShiftBits = computeRightShiftBits(exactByteSize, SZ_UINT16); |
---|
| 608 | |
---|
| 609 | int type_; |
---|
| 610 | |
---|
| 611 | long pred1D, pred2D, pred3D, tmp; |
---|
| 612 | size_t ii, jj, kk, ll; |
---|
| 613 | size_t index; |
---|
| 614 | |
---|
| 615 | for (ll = 0; ll < r1; ll++) |
---|
| 616 | { |
---|
| 617 | /////////////////////////// Process layer-0 /////////////////////////// |
---|
| 618 | /* Process Row-0 data 0*/ |
---|
| 619 | index = ll*r234; |
---|
| 620 | |
---|
| 621 | // recover the exact data |
---|
| 622 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 623 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 624 | exactData = (uint16_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_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 638 | (*data)[index] = tmp; |
---|
| 639 | else if(tmp < SZ_UINT16_MIN) |
---|
| 640 | (*data)[index] = SZ_UINT16_MIN; |
---|
| 641 | else |
---|
| 642 | (*data)[index] = SZ_UINT16_MAX; |
---|
| 643 | } |
---|
| 644 | else |
---|
| 645 | { |
---|
| 646 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 647 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 648 | exactData = (uint16_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_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 665 | (*data)[index] = tmp; |
---|
| 666 | else if(tmp < SZ_UINT16_MIN) |
---|
| 667 | (*data)[index] = SZ_UINT16_MIN; |
---|
| 668 | else |
---|
| 669 | (*data)[index] = SZ_UINT16_MAX; |
---|
| 670 | } |
---|
| 671 | else |
---|
| 672 | { |
---|
| 673 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 674 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 675 | exactData = (uint16_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_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 694 | (*data)[index] = tmp; |
---|
| 695 | else if(tmp < SZ_UINT16_MIN) |
---|
| 696 | (*data)[index] = SZ_UINT16_MIN; |
---|
| 697 | else |
---|
| 698 | (*data)[index] = SZ_UINT16_MAX; |
---|
| 699 | } |
---|
| 700 | else |
---|
| 701 | { |
---|
| 702 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 703 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 704 | exactData = (uint16_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_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 721 | (*data)[index] = tmp; |
---|
| 722 | else if(tmp < SZ_UINT16_MIN) |
---|
| 723 | (*data)[index] = SZ_UINT16_MIN; |
---|
| 724 | else |
---|
| 725 | (*data)[index] = SZ_UINT16_MAX; |
---|
| 726 | } |
---|
| 727 | else |
---|
| 728 | { |
---|
| 729 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 730 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 731 | exactData = (uint16_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_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 752 | (*data)[index] = tmp; |
---|
| 753 | else if(tmp < SZ_UINT16_MIN) |
---|
| 754 | (*data)[index] = SZ_UINT16_MIN; |
---|
| 755 | else |
---|
| 756 | (*data)[index] = SZ_UINT16_MAX; |
---|
| 757 | } |
---|
| 758 | else |
---|
| 759 | { |
---|
| 760 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 761 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 762 | exactData = (uint16_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_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 779 | (*data)[index] = tmp; |
---|
| 780 | else if(tmp < SZ_UINT16_MIN) |
---|
| 781 | (*data)[index] = SZ_UINT16_MIN; |
---|
| 782 | else |
---|
| 783 | (*data)[index] = SZ_UINT16_MAX; |
---|
| 784 | } |
---|
| 785 | else |
---|
| 786 | { |
---|
| 787 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 788 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 789 | exactData = (uint16_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_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 808 | (*data)[index] = tmp; |
---|
| 809 | else if(tmp < SZ_UINT16_MIN) |
---|
| 810 | (*data)[index] = SZ_UINT16_MIN; |
---|
| 811 | else |
---|
| 812 | (*data)[index] = SZ_UINT16_MAX; |
---|
| 813 | } |
---|
| 814 | else |
---|
| 815 | { |
---|
| 816 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 817 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 818 | exactData = (uint16_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 | |
---|
| 832 | type_ = type[index]; |
---|
| 833 | if (type_ != 0) |
---|
| 834 | { |
---|
| 835 | tmp = pred3D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 836 | if(tmp >= SZ_UINT16_MIN&&tmp<SZ_UINT16_MAX) |
---|
| 837 | (*data)[index] = tmp; |
---|
| 838 | else if(tmp < SZ_UINT16_MIN) |
---|
| 839 | (*data)[index] = SZ_UINT16_MIN; |
---|
| 840 | else |
---|
| 841 | (*data)[index] = SZ_UINT16_MAX; |
---|
| 842 | } |
---|
| 843 | else |
---|
| 844 | { |
---|
| 845 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 846 | exactData = bytesToUInt16_bigEndian(curBytes); |
---|
| 847 | exactData = (uint16_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_uint16_1D(uint16_t** data, size_t dataSeriesLength, TightDataPointStorageI* tdps, int errBoundMode) |
---|
| 861 | { |
---|
| 862 | size_t i; |
---|
| 863 | |
---|
| 864 | if (tdps->allSameData) { |
---|
| 865 | uint16_t value = bytesToUInt16_bigEndian(tdps->exactDataBytes); |
---|
| 866 | *data = (uint16_t*)malloc(sizeof(uint16_t)*dataSeriesLength); |
---|
| 867 | for (i = 0; i < dataSeriesLength; i++) |
---|
| 868 | (*data)[i] = value; |
---|
| 869 | } else { |
---|
| 870 | decompressDataSeries_uint16_1D(data, dataSeriesLength, tdps); |
---|
| 871 | } |
---|
| 872 | } |
---|
| 873 | |
---|
| 874 | void getSnapshotData_uint16_2D(uint16_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 | uint16_t value = bytesToUInt16_bigEndian(tdps->exactDataBytes); |
---|
| 880 | *data = (uint16_t*)malloc(sizeof(uint16_t)*dataSeriesLength); |
---|
| 881 | for (i = 0; i < dataSeriesLength; i++) |
---|
| 882 | (*data)[i] = value; |
---|
| 883 | } else { |
---|
| 884 | decompressDataSeries_uint16_2D(data, r1, r2, tdps); |
---|
| 885 | } |
---|
| 886 | } |
---|
| 887 | |
---|
| 888 | void getSnapshotData_uint16_3D(uint16_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 | uint16_t value = bytesToUInt16_bigEndian(tdps->exactDataBytes); |
---|
| 894 | *data = (uint16_t*)malloc(sizeof(uint16_t)*dataSeriesLength); |
---|
| 895 | for (i = 0; i < dataSeriesLength; i++) |
---|
| 896 | (*data)[i] = value; |
---|
| 897 | } else { |
---|
| 898 | decompressDataSeries_uint16_3D(data, r1, r2, r3, tdps); |
---|
| 899 | } |
---|
| 900 | } |
---|
| 901 | |
---|
| 902 | void getSnapshotData_uint16_4D(uint16_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 | uint16_t value = bytesToUInt16_bigEndian(tdps->exactDataBytes); |
---|
| 908 | *data = (uint16_t*)malloc(sizeof(uint16_t)*dataSeriesLength); |
---|
| 909 | for (i = 0; i < dataSeriesLength; i++) |
---|
| 910 | (*data)[i] = value; |
---|
| 911 | } else { |
---|
| 912 | decompressDataSeries_uint16_4D(data, r1, r2, r3, r4, tdps); |
---|
| 913 | } |
---|
| 914 | } |
---|