[2c47b73] | 1 | /** |
---|
| 2 | * @file szd_int16.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_int16.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_int16(int16_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(int16_t)+exe_params->SZ_SIZE_TYPE; |
---|
| 34 | unsigned char* szTmpBytes; |
---|
| 35 | |
---|
[9ee2ce3] | 36 | if(cmpSize!=4+2+4+MetaDataByteLength && cmpSize!=4+2+8+MetaDataByteLength) |
---|
[2c47b73] | 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(int16_t); |
---|
| 72 | if(tdps->isLossless) |
---|
| 73 | { |
---|
| 74 | *newData = (int16_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] = bytesToInt16_bigEndian(p); |
---|
| 84 | } |
---|
| 85 | } |
---|
| 86 | else if (dim == 1) |
---|
| 87 | getSnapshotData_int16_1D(newData,r1,tdps, errBoundMode); |
---|
| 88 | else |
---|
| 89 | if (dim == 2) |
---|
| 90 | getSnapshotData_int16_2D(newData,r2,r1,tdps, errBoundMode); |
---|
| 91 | else |
---|
| 92 | if (dim == 3) |
---|
| 93 | getSnapshotData_int16_3D(newData,r3,r2,r1,tdps, errBoundMode); |
---|
| 94 | else |
---|
| 95 | if (dim == 4) |
---|
| 96 | getSnapshotData_int16_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(int16_t)+exe_params->SZ_SIZE_TYPE+MetaDataByteLength) |
---|
| 104 | free(szTmpBytes); |
---|
| 105 | return status; |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | void decompressDataSeries_int16_1D(int16_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 = (int16_t*)malloc(sizeof(int16_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 | int16_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_INT16); |
---|
| 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 = bytesToInt16_bigEndian(curBytes); |
---|
| 150 | exactData = (uint16_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_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 159 | (*data)[i] = tmp; |
---|
| 160 | else if(tmp < SZ_INT16_MIN) |
---|
| 161 | (*data)[i] = SZ_INT16_MIN; |
---|
| 162 | else |
---|
| 163 | (*data)[i] = SZ_INT16_MAX; |
---|
| 164 | break; |
---|
| 165 | } |
---|
| 166 | //printf("%.30G\n",(*data)[i]); |
---|
| 167 | } |
---|
| 168 | free(type); |
---|
| 169 | return; |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | void decompressDataSeries_int16_2D(int16_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 = (int16_t*)malloc(sizeof(int16_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 | int16_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_INT16); |
---|
| 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 = bytesToInt16_bigEndian(curBytes); |
---|
| 209 | exactData = (uint16_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_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 220 | (*data)[1] = tmp; |
---|
| 221 | else if(tmp < SZ_INT16_MIN) |
---|
| 222 | (*data)[1] = SZ_INT16_MIN; |
---|
| 223 | else |
---|
| 224 | (*data)[1] = SZ_INT16_MAX; |
---|
| 225 | |
---|
| 226 | } |
---|
| 227 | else |
---|
| 228 | { |
---|
| 229 | // recover the exact data |
---|
| 230 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 231 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 232 | exactData = (uint16_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_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 246 | (*data)[jj] = tmp; |
---|
| 247 | else if(tmp < SZ_INT16_MIN) |
---|
| 248 | (*data)[jj] = SZ_INT16_MIN; |
---|
| 249 | else |
---|
| 250 | (*data)[jj] = SZ_INT16_MAX; |
---|
| 251 | } |
---|
| 252 | else |
---|
| 253 | { |
---|
| 254 | // recover the exact data |
---|
| 255 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 256 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 257 | exactData = (uint16_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_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 276 | (*data)[index] = tmp; |
---|
| 277 | else if(tmp < SZ_INT16_MIN) |
---|
| 278 | (*data)[index] = SZ_INT16_MIN; |
---|
| 279 | else |
---|
| 280 | (*data)[index] = SZ_INT16_MAX; |
---|
| 281 | } |
---|
| 282 | else |
---|
| 283 | { |
---|
| 284 | // recover the exact data |
---|
| 285 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 286 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 287 | exactData = (uint16_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_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 303 | (*data)[index] = tmp; |
---|
| 304 | else if(tmp < SZ_INT16_MIN) |
---|
| 305 | (*data)[index] = SZ_INT16_MIN; |
---|
| 306 | else |
---|
| 307 | (*data)[index] = SZ_INT16_MAX; |
---|
| 308 | } |
---|
| 309 | else |
---|
| 310 | { |
---|
| 311 | // recover the exact data |
---|
| 312 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 313 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 314 | exactData = (uint16_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_int16_3D(int16_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 = (int16_t*)malloc(sizeof(int16_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 | int16_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_INT16); |
---|
| 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 = bytesToInt16_bigEndian(curBytes); |
---|
| 360 | exactData = (uint16_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_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 372 | (*data)[1] = tmp; |
---|
| 373 | else if(tmp < SZ_INT16_MIN) |
---|
| 374 | (*data)[1] = SZ_INT16_MIN; |
---|
| 375 | else |
---|
| 376 | (*data)[1] = SZ_INT16_MAX; |
---|
| 377 | } |
---|
| 378 | else |
---|
| 379 | { |
---|
| 380 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 381 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 382 | exactData = (uint16_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_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 396 | (*data)[jj] = tmp; |
---|
| 397 | else if(tmp < SZ_INT16_MIN) |
---|
| 398 | (*data)[jj] = SZ_INT16_MIN; |
---|
| 399 | else |
---|
| 400 | (*data)[jj] = SZ_INT16_MAX; } |
---|
| 401 | else |
---|
| 402 | { |
---|
| 403 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 404 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 405 | exactData = (uint16_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_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 424 | (*data)[index] = tmp; |
---|
| 425 | else if(tmp < SZ_INT16_MIN) |
---|
| 426 | (*data)[index] = SZ_INT16_MIN; |
---|
| 427 | else |
---|
| 428 | (*data)[index] = SZ_INT16_MAX; |
---|
| 429 | } |
---|
| 430 | else |
---|
| 431 | { |
---|
| 432 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 433 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 434 | exactData = (uint16_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_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 450 | (*data)[index] = tmp; |
---|
| 451 | else if(tmp < SZ_INT16_MIN) |
---|
| 452 | (*data)[index] = SZ_INT16_MIN; |
---|
| 453 | else |
---|
| 454 | (*data)[index] = SZ_INT16_MAX; |
---|
| 455 | } |
---|
| 456 | else |
---|
| 457 | { |
---|
| 458 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 459 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 460 | exactData = (uint16_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_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 480 | (*data)[index] = tmp; |
---|
| 481 | else if(tmp < SZ_INT16_MIN) |
---|
| 482 | (*data)[index] = SZ_INT16_MIN; |
---|
| 483 | else |
---|
| 484 | (*data)[index] = SZ_INT16_MAX; |
---|
| 485 | } |
---|
| 486 | else |
---|
| 487 | { |
---|
| 488 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 489 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 490 | exactData = (uint16_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_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 506 | (*data)[index] = tmp; |
---|
| 507 | else if(tmp < SZ_INT16_MIN) |
---|
| 508 | (*data)[index] = SZ_INT16_MIN; |
---|
| 509 | else |
---|
| 510 | (*data)[index] = SZ_INT16_MAX; |
---|
| 511 | } |
---|
| 512 | else |
---|
| 513 | { |
---|
| 514 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 515 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 516 | exactData = (uint16_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_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 534 | (*data)[index] = tmp; |
---|
| 535 | else if(tmp < SZ_INT16_MIN) |
---|
| 536 | (*data)[index] = SZ_INT16_MIN; |
---|
| 537 | else |
---|
| 538 | (*data)[index] = SZ_INT16_MAX; |
---|
| 539 | } |
---|
| 540 | else |
---|
| 541 | { |
---|
| 542 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 543 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 544 | exactData = (uint16_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_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 561 | (*data)[index] = tmp; |
---|
| 562 | else if(tmp < SZ_INT16_MIN) |
---|
| 563 | (*data)[index] = SZ_INT16_MIN; |
---|
| 564 | else |
---|
| 565 | (*data)[index] = SZ_INT16_MAX; |
---|
| 566 | } |
---|
| 567 | else |
---|
| 568 | { |
---|
| 569 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 570 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 571 | exactData = (uint16_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_int16_4D(int16_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 = (int16_t*)malloc(sizeof(int16_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 | int16_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_INT16); |
---|
| 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 | |
---|
| 623 | // recover the exact data |
---|
| 624 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 625 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 626 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 627 | exactDataBytePointer += exactByteSize; |
---|
| 628 | (*data)[index] = exactData + minValue; |
---|
| 629 | |
---|
| 630 | /* Process Row-0, data 1 */ |
---|
| 631 | index = ll*r234+1; |
---|
| 632 | |
---|
| 633 | pred1D = (*data)[index-1]; |
---|
| 634 | |
---|
| 635 | type_ = type[index]; |
---|
| 636 | if (type_ != 0) |
---|
| 637 | { |
---|
| 638 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 639 | if(tmp >= SZ_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 640 | (*data)[index] = tmp; |
---|
| 641 | else if(tmp < SZ_INT16_MIN) |
---|
| 642 | (*data)[index] = SZ_INT16_MIN; |
---|
| 643 | else |
---|
| 644 | (*data)[index] = SZ_INT16_MAX; |
---|
| 645 | } |
---|
| 646 | else |
---|
| 647 | { |
---|
| 648 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 649 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 650 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 651 | exactDataBytePointer += exactByteSize; |
---|
| 652 | (*data)[index] = exactData + minValue; |
---|
| 653 | } |
---|
| 654 | |
---|
| 655 | /* Process Row-0, data 2 --> data r4-1 */ |
---|
| 656 | for (jj = 2; jj < r4; jj++) |
---|
| 657 | { |
---|
| 658 | index = ll*r234+jj; |
---|
| 659 | |
---|
| 660 | pred1D = 2*(*data)[index-1] - (*data)[index-2]; |
---|
| 661 | |
---|
| 662 | type_ = type[index]; |
---|
| 663 | if (type_ != 0) |
---|
| 664 | { |
---|
| 665 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 666 | if(tmp >= SZ_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 667 | (*data)[index] = tmp; |
---|
| 668 | else if(tmp < SZ_INT16_MIN) |
---|
| 669 | (*data)[index] = SZ_INT16_MIN; |
---|
| 670 | else |
---|
| 671 | (*data)[index] = SZ_INT16_MAX; |
---|
| 672 | } |
---|
| 673 | else |
---|
| 674 | { |
---|
| 675 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 676 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 677 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 678 | exactDataBytePointer += exactByteSize; |
---|
| 679 | (*data)[index] = exactData + minValue; |
---|
| 680 | } |
---|
| 681 | } |
---|
| 682 | |
---|
| 683 | /* Process Row-1 --> Row-r3-1 */ |
---|
| 684 | for (ii = 1; ii < r3; ii++) |
---|
| 685 | { |
---|
| 686 | /* Process row-ii data 0 */ |
---|
| 687 | index = ll*r234+ii*r4; |
---|
| 688 | |
---|
| 689 | pred1D = (*data)[index-r4]; |
---|
| 690 | |
---|
| 691 | type_ = type[index]; |
---|
| 692 | if (type_ != 0) |
---|
| 693 | { |
---|
| 694 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 695 | if(tmp >= SZ_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 696 | (*data)[index] = tmp; |
---|
| 697 | else if(tmp < SZ_INT16_MIN) |
---|
| 698 | (*data)[index] = SZ_INT16_MIN; |
---|
| 699 | else |
---|
| 700 | (*data)[index] = SZ_INT16_MAX; |
---|
| 701 | } |
---|
| 702 | else |
---|
| 703 | { |
---|
| 704 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 705 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 706 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 707 | exactDataBytePointer += exactByteSize; |
---|
| 708 | (*data)[index] = exactData + minValue; |
---|
| 709 | } |
---|
| 710 | |
---|
| 711 | /* Process row-ii data 1 --> r4-1*/ |
---|
| 712 | for (jj = 1; jj < r4; jj++) |
---|
| 713 | { |
---|
| 714 | index = ll*r234+ii*r4+jj; |
---|
| 715 | |
---|
| 716 | pred2D = (*data)[index-1] + (*data)[index-r4] - (*data)[index-r4-1]; |
---|
| 717 | |
---|
| 718 | type_ = type[index]; |
---|
| 719 | if (type_ != 0) |
---|
| 720 | { |
---|
| 721 | tmp = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 722 | if(tmp >= SZ_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 723 | (*data)[index] = tmp; |
---|
| 724 | else if(tmp < SZ_INT16_MIN) |
---|
| 725 | (*data)[index] = SZ_INT16_MIN; |
---|
| 726 | else |
---|
| 727 | (*data)[index] = SZ_INT16_MAX; |
---|
| 728 | } |
---|
| 729 | else |
---|
| 730 | { |
---|
| 731 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 732 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 733 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 734 | exactDataBytePointer += exactByteSize; |
---|
| 735 | (*data)[index] = exactData + minValue; |
---|
| 736 | } |
---|
| 737 | } |
---|
| 738 | } |
---|
| 739 | |
---|
| 740 | /////////////////////////// Process layer-1 --> layer-r2-1 /////////////////////////// |
---|
| 741 | |
---|
| 742 | for (kk = 1; kk < r2; kk++) |
---|
| 743 | { |
---|
| 744 | /* Process Row-0 data 0*/ |
---|
| 745 | index = ll*r234+kk*r34; |
---|
| 746 | |
---|
| 747 | pred1D = (*data)[index-r34]; |
---|
| 748 | |
---|
| 749 | type_ = type[index]; |
---|
| 750 | if (type_ != 0) |
---|
| 751 | { |
---|
| 752 | tmp = pred1D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 753 | if(tmp >= SZ_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 754 | (*data)[index] = tmp; |
---|
| 755 | else if(tmp < SZ_INT16_MIN) |
---|
| 756 | (*data)[index] = SZ_INT16_MIN; |
---|
| 757 | else |
---|
| 758 | (*data)[index] = SZ_INT16_MAX; |
---|
| 759 | } |
---|
| 760 | else |
---|
| 761 | { |
---|
| 762 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 763 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 764 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 765 | exactDataBytePointer += exactByteSize; |
---|
| 766 | (*data)[index] = exactData + minValue; |
---|
| 767 | } |
---|
| 768 | |
---|
| 769 | /* Process Row-0 data 1 --> data r4-1 */ |
---|
| 770 | for (jj = 1; jj < r4; jj++) |
---|
| 771 | { |
---|
| 772 | index = ll*r234+kk*r34+jj; |
---|
| 773 | |
---|
| 774 | pred2D = (*data)[index-1] + (*data)[index-r34] - (*data)[index-r34-1]; |
---|
| 775 | |
---|
| 776 | type_ = type[index]; |
---|
| 777 | if (type_ != 0) |
---|
| 778 | { |
---|
| 779 | tmp = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 780 | if(tmp >= SZ_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 781 | (*data)[index] = tmp; |
---|
| 782 | else if(tmp < SZ_INT16_MIN) |
---|
| 783 | (*data)[index] = SZ_INT16_MIN; |
---|
| 784 | else |
---|
| 785 | (*data)[index] = SZ_INT16_MAX; |
---|
| 786 | } |
---|
| 787 | else |
---|
| 788 | { |
---|
| 789 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 790 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 791 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 792 | exactDataBytePointer += exactByteSize; |
---|
| 793 | (*data)[index] = exactData + minValue; |
---|
| 794 | } |
---|
| 795 | } |
---|
| 796 | |
---|
| 797 | /* Process Row-1 --> Row-r3-1 */ |
---|
| 798 | for (ii = 1; ii < r3; ii++) |
---|
| 799 | { |
---|
| 800 | /* Process Row-i data 0 */ |
---|
| 801 | index = ll*r234+kk*r34+ii*r4; |
---|
| 802 | |
---|
| 803 | pred2D = (*data)[index-r4] + (*data)[index-r34] - (*data)[index-r34-r4]; |
---|
| 804 | |
---|
| 805 | type_ = type[index]; |
---|
| 806 | if (type_ != 0) |
---|
| 807 | { |
---|
| 808 | tmp = pred2D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 809 | if(tmp >= SZ_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 810 | (*data)[index] = tmp; |
---|
| 811 | else if(tmp < SZ_INT16_MIN) |
---|
| 812 | (*data)[index] = SZ_INT16_MIN; |
---|
| 813 | else |
---|
| 814 | (*data)[index] = SZ_INT16_MAX; |
---|
| 815 | } |
---|
| 816 | else |
---|
| 817 | { |
---|
| 818 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 819 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 820 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 821 | exactDataBytePointer += exactByteSize; |
---|
| 822 | (*data)[index] = exactData + minValue; |
---|
| 823 | } |
---|
| 824 | |
---|
| 825 | /* Process Row-i data 1 --> data r4-1 */ |
---|
| 826 | for (jj = 1; jj < r4; jj++) |
---|
| 827 | { |
---|
| 828 | index = ll*r234+kk*r34+ii*r4+jj; |
---|
| 829 | |
---|
| 830 | pred3D = (*data)[index-1] + (*data)[index-r4] + (*data)[index-r34] |
---|
| 831 | - (*data)[index-r4-1] - (*data)[index-r34-r4] - (*data)[index-r34-1] + (*data)[index-r34-r4-1]; |
---|
| 832 | |
---|
| 833 | |
---|
| 834 | type_ = type[index]; |
---|
| 835 | if (type_ != 0) |
---|
| 836 | { |
---|
| 837 | tmp = pred3D + 2 * (type_ - exe_params->intvRadius) * realPrecision; |
---|
| 838 | if(tmp >= SZ_INT16_MIN&&tmp<SZ_INT16_MAX) |
---|
| 839 | (*data)[index] = tmp; |
---|
| 840 | else if(tmp < SZ_INT16_MIN) |
---|
| 841 | (*data)[index] = SZ_INT16_MIN; |
---|
| 842 | else |
---|
| 843 | (*data)[index] = SZ_INT16_MAX; |
---|
| 844 | } |
---|
| 845 | else |
---|
| 846 | { |
---|
| 847 | memcpy(curBytes, exactDataBytePointer, exactByteSize); |
---|
| 848 | exactData = bytesToInt16_bigEndian(curBytes); |
---|
| 849 | exactData = (uint16_t)exactData >> rightShiftBits; |
---|
| 850 | exactDataBytePointer += exactByteSize; |
---|
| 851 | (*data)[index] = exactData + minValue; |
---|
| 852 | } |
---|
| 853 | } |
---|
| 854 | } |
---|
| 855 | } |
---|
| 856 | } |
---|
| 857 | |
---|
| 858 | free(type); |
---|
| 859 | return; |
---|
| 860 | } |
---|
| 861 | |
---|
| 862 | void getSnapshotData_int16_1D(int16_t** data, size_t dataSeriesLength, TightDataPointStorageI* tdps, int errBoundMode) |
---|
| 863 | { |
---|
| 864 | size_t i; |
---|
| 865 | |
---|
| 866 | if (tdps->allSameData) { |
---|
| 867 | int16_t value = bytesToInt16_bigEndian(tdps->exactDataBytes); |
---|
| 868 | *data = (int16_t*)malloc(sizeof(int16_t)*dataSeriesLength); |
---|
| 869 | for (i = 0; i < dataSeriesLength; i++) |
---|
| 870 | (*data)[i] = value; |
---|
| 871 | } else { |
---|
| 872 | decompressDataSeries_int16_1D(data, dataSeriesLength, tdps); |
---|
| 873 | } |
---|
| 874 | } |
---|
| 875 | |
---|
| 876 | void getSnapshotData_int16_2D(int16_t** data, size_t r1, size_t r2, TightDataPointStorageI* tdps, int errBoundMode) |
---|
| 877 | { |
---|
| 878 | size_t i; |
---|
| 879 | size_t dataSeriesLength = r1*r2; |
---|
| 880 | if (tdps->allSameData) { |
---|
| 881 | int16_t value = bytesToInt16_bigEndian(tdps->exactDataBytes); |
---|
| 882 | *data = (int16_t*)malloc(sizeof(int16_t)*dataSeriesLength); |
---|
| 883 | for (i = 0; i < dataSeriesLength; i++) |
---|
| 884 | (*data)[i] = value; |
---|
| 885 | } else { |
---|
| 886 | decompressDataSeries_int16_2D(data, r1, r2, tdps); |
---|
| 887 | } |
---|
| 888 | } |
---|
| 889 | |
---|
| 890 | void getSnapshotData_int16_3D(int16_t** data, size_t r1, size_t r2, size_t r3, TightDataPointStorageI* tdps, int errBoundMode) |
---|
| 891 | { |
---|
| 892 | size_t i; |
---|
| 893 | size_t dataSeriesLength = r1*r2*r3; |
---|
| 894 | if (tdps->allSameData) { |
---|
| 895 | int16_t value = bytesToInt16_bigEndian(tdps->exactDataBytes); |
---|
| 896 | *data = (int16_t*)malloc(sizeof(int16_t)*dataSeriesLength); |
---|
| 897 | for (i = 0; i < dataSeriesLength; i++) |
---|
| 898 | (*data)[i] = value; |
---|
| 899 | } else { |
---|
| 900 | decompressDataSeries_int16_3D(data, r1, r2, r3, tdps); |
---|
| 901 | } |
---|
| 902 | } |
---|
| 903 | |
---|
| 904 | void getSnapshotData_int16_4D(int16_t** data, size_t r1, size_t r2, size_t r3, size_t r4, TightDataPointStorageI* tdps, int errBoundMode) |
---|
| 905 | { |
---|
| 906 | size_t i; |
---|
| 907 | size_t dataSeriesLength = r1*r2*r3*r4; |
---|
| 908 | if (tdps->allSameData) { |
---|
| 909 | int16_t value = bytesToInt16_bigEndian(tdps->exactDataBytes); |
---|
| 910 | *data = (int16_t*)malloc(sizeof(int16_t)*dataSeriesLength); |
---|
| 911 | for (i = 0; i < dataSeriesLength; i++) |
---|
| 912 | (*data)[i] = value; |
---|
| 913 | } else { |
---|
| 914 | decompressDataSeries_int16_4D(data, r1, r2, r3, r4, tdps); |
---|
| 915 | } |
---|
| 916 | } |
---|