Changeset 9ee2ce3 for thirdparty/SZ/sz/src/TightDataPointStorageF.c
- Timestamp:
- 09/28/18 16:32:55 (6 years ago)
- Branches:
- master, pympi
- Children:
- e6aa0eb
- Parents:
- abca157
- git-author:
- Hal Finkel <hfinkel@…> (09/28/18 16:32:55)
- git-committer:
- Hal Finkel <hfinkel@…> (09/28/18 16:32:55)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
thirdparty/SZ/sz/src/TightDataPointStorageF.c
r2c47b73 r9ee2ce3 47 47 (*this)->pwrErrBoundBytes = NULL; 48 48 (*this)->pwrErrBoundBytes_size = 0; 49 50 (*this)->raBytes = NULL; 51 (*this)->raBytes_size = 0; 49 52 } 50 53 … … 82 85 int mode = confparams_dec->szMode; 83 86 int predictionMode = confparams_dec->predictionMode; 87 int losslessCompressor = confparams_dec->losslessCompressor; 84 88 if(confparams_dec!=NULL) 85 89 free(confparams_dec); 86 90 confparams_dec = params; 87 91 confparams_dec->szMode = mode; 92 confparams_dec->losslessCompressor = losslessCompressor; 93 88 94 if(mode==SZ_TEMPORAL_COMPRESSION) 89 95 { … … 93 99 94 100 index += MetaDataByteLength; 101 102 int isRandomAccess = (sameRByte >> 7) & 0x01; 95 103 96 104 unsigned char dsLengthBytes[8]; … … 118 126 else 119 127 (*this)->allSameData = 0; 128 if(isRandomAccess == 1) 129 { 130 (*this)->raBytes_size = flatBytesLength - 3 - 1 - MetaDataByteLength - exe_params->SZ_SIZE_TYPE; 131 (*this)->raBytes = &(flatBytes[index]); 132 return errorBoundMode; 133 } 120 134 121 135 int rtype_ = sameRByte & 0x08; //=00001000 … … 166 180 for(i = 0;i<exe_params->SZ_SIZE_TYPE;i++) 167 181 byteBuf[i] = flatBytes[index++]; 168 (*this)->rtypeArray_size = bytesToSize(byteBuf);//(ST) 182 (*this)->rtypeArray_size = bytesToSize(byteBuf);//(ST) 169 183 } 170 184 else … … 200 214 } 201 215 216 int minLogValueSize = 0; 217 if(errorBoundMode>=PW_REL) 218 minLogValueSize = 4; 219 202 220 if ((*this)->rtypeArray != NULL) 203 221 { 204 222 (*this)->residualMidBits_size = flatBytesLength - 3 - 1 - MetaDataByteLength - exe_params->SZ_SIZE_TYPE - 4 - radExpoL - segmentL - pwrErrBoundBytesL - 4 - 4 - 1 - 8 205 - exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - 4 - (*this)->rtypeArray_size206 - (*this)->typeArray_size - (*this)->leadNumArray_size223 - exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - minLogValueSize - exe_params->SZ_SIZE_TYPE - 4 - (*this)->rtypeArray_size 224 - minLogValueSize - (*this)->typeArray_size - (*this)->leadNumArray_size 207 225 - (*this)->exactMidBytes_size - pwrErrBoundBytes_size; 208 226 for (i = 0; i < (*this)->rtypeArray_size; i++) … … 212 230 { 213 231 (*this)->residualMidBits_size = flatBytesLength - 3 - 1 - MetaDataByteLength - exe_params->SZ_SIZE_TYPE - 4 - radExpoL - segmentL - pwrErrBoundBytesL - 4 - 4 - 1 - 8 214 - exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - (*this)->typeArray_size232 - exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - minLogValueSize - (*this)->typeArray_size 215 233 - (*this)->leadNumArray_size - (*this)->exactMidBytes_size - pwrErrBoundBytes_size; 216 } 234 } 235 236 if(errorBoundMode>=PW_REL) 237 { 238 (*this)->minLogValue = bytesToFloat(&flatBytes[index]); 239 index+=4; 240 } 217 241 218 242 (*this)->typeArray = &flatBytes[index]; … … 419 443 bytes[k++] = exactMidBytesLength[i]; 420 444 445 if(confparams_cpr->errorBoundMode>=PW_REL) 446 { 447 floatToBytes(exactMidBytesLength, tdps->minLogValue); 448 for(i=0;i<4;i++) 449 bytes[k++] = exactMidBytesLength[i]; 450 } 451 421 452 memcpy(&(bytes[k]), tdps->typeArray, tdps->typeArray_size); 422 453 k += tdps->typeArray_size; … … 520 551 memcpy(&(bytes[k]), tdps->rtypeArray, tdps->rtypeArray_size); 521 552 k += tdps->rtypeArray_size; 553 554 if(confparams_cpr->errorBoundMode>=PW_REL) 555 { 556 floatToBytes(exactMidBytesLength, tdps->minLogValue); 557 for(i=0;i<4;i++) 558 bytes[k++] = exactMidBytesLength[i]; 559 } 560 522 561 memcpy(&(bytes[k]), tdps->typeArray, tdps->typeArray_size); 523 562 k += tdps->typeArray_size; … … 575 614 for (i = 0; i < tdps->exactMidBytes_size; i++) 576 615 (*bytes)[k++] = tdps->exactMidBytes[i]; 616 617 *size = totalByteLength; 618 } 619 else if (tdps->rtypeArray == NULL) 620 { 621 size_t residualMidBitsLength = tdps->residualMidBits == NULL ? 0 : tdps->residualMidBits_size; 622 size_t segmentL = 0, radExpoL = 0, pwrBoundArrayL = 0; 623 int minLogValueSize = 0; 624 if(confparams_cpr->errorBoundMode>=PW_REL) 625 { 626 segmentL = exe_params->SZ_SIZE_TYPE; 627 radExpoL = 1; 628 pwrBoundArrayL = 4; 629 minLogValueSize = 4; 630 } 631 632 size_t totalByteLength = 3 + 1 + MetaDataByteLength + exe_params->SZ_SIZE_TYPE + 4 + radExpoL + segmentL + pwrBoundArrayL + 4 + 4 + 1 + 8 633 + exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + minLogValueSize 634 + tdps->typeArray_size + tdps->leadNumArray_size 635 + tdps->exactMidBytes_size + residualMidBitsLength + tdps->pwrErrBoundBytes_size; 636 637 *bytes = (unsigned char *)malloc(sizeof(unsigned char)*totalByteLength); 638 639 convertTDPStoBytes_float(tdps, *bytes, dsLengthBytes, sameByte); 640 641 *size = totalByteLength; 642 } 643 else //the case with reserved value 644 { 645 size_t residualMidBitsLength = tdps->residualMidBits == NULL ? 0 : tdps->residualMidBits_size; 646 size_t segmentL = 0, radExpoL = 0, pwrBoundArrayL = 0; 647 int minLogValueSize = 0; 648 if(confparams_cpr->errorBoundMode>=PW_REL) 649 { 650 segmentL = exe_params->SZ_SIZE_TYPE; 651 radExpoL = 1; 652 pwrBoundArrayL = 4; 653 minLogValueSize = 4; 654 } 655 656 size_t totalByteLength = 3 + 1 + MetaDataByteLength + exe_params->SZ_SIZE_TYPE + 4 + radExpoL + segmentL + pwrBoundArrayL + 4 + 4 + 1 + 8 657 + exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + 4 + tdps->rtypeArray_size 658 + minLogValueSize + tdps->typeArray_size + tdps->leadNumArray_size 659 + tdps->exactMidBytes_size + residualMidBitsLength + tdps->pwrErrBoundBytes_size; 660 661 sameByte = (unsigned char) (sameByte | 0x08); // 00001000, the 4th bit 662 // denotes whether it is 663 // with "reserved value" 664 665 if(confparams_cpr->errorBoundMode>=PW_REL) 666 sameByte = (unsigned char) (sameByte | 0x10); // 00001000, the 5th bit 667 668 *bytes = (unsigned char*)malloc(sizeof(unsigned char)*totalByteLength); 669 670 convertTDPStoBytes_float_reserve(tdps, *bytes, dsLengthBytes, sameByte); 671 672 *size = totalByteLength; 673 } 674 } 675 676 void convertTDPStoFlatBytes_float_args(TightDataPointStorageF *tdps, unsigned char* bytes, size_t *size) 677 { 678 size_t i, k = 0; 679 unsigned char dsLengthBytes[8]; 680 681 if(exe_params->SZ_SIZE_TYPE==4) 682 intToBytes_bigEndian(dsLengthBytes, tdps->dataSeriesLength);//4 683 else 684 longToBytes_bigEndian(dsLengthBytes, tdps->dataSeriesLength);//8 685 686 unsigned char sameByte = tdps->allSameData==1?(unsigned char)1:(unsigned char)0; 687 sameByte = sameByte | (confparams_cpr->szMode << 1); 688 if(tdps->isLossless) 689 sameByte = (unsigned char) (sameByte | 0x10); 690 if(confparams_cpr->errorBoundMode>=PW_REL) 691 sameByte = (unsigned char) (sameByte | 0x20); // 00100000, the 5th bit 692 if(exe_params->SZ_SIZE_TYPE==8) 693 sameByte = (unsigned char) (sameByte | 0x40); // 01000000, the 6th bit 694 695 if(tdps->allSameData==1) 696 { 697 size_t totalByteLength = 3 + 1 + MetaDataByteLength + exe_params->SZ_SIZE_TYPE + tdps->exactMidBytes_size; 698 //*bytes = (unsigned char *)malloc(sizeof(unsigned char)*totalByteLength); 699 700 for (i = 0; i < 3; i++)//3 701 bytes[k++] = versionNumber[i]; 702 bytes[k++] = sameByte; 703 704 convertSZParamsToBytes(confparams_cpr, &(bytes[k])); 705 k = k + MetaDataByteLength; 706 707 for (i = 0; i < exe_params->SZ_SIZE_TYPE; i++) 708 bytes[k++] = dsLengthBytes[i]; 709 for (i = 0; i < tdps->exactMidBytes_size; i++) 710 bytes[k++] = tdps->exactMidBytes[i]; 577 711 578 712 *size = totalByteLength; … … 594 728 + tdps->exactMidBytes_size + residualMidBitsLength + tdps->pwrErrBoundBytes_size; 595 729 596 *bytes = (unsigned char *)malloc(sizeof(unsigned char)*totalByteLength);597 598 convertTDPStoBytes_float(tdps, *bytes, dsLengthBytes, sameByte);599 600 *size = totalByteLength;601 }602 else //the case with reserved value603 {604 size_t residualMidBitsLength = tdps->residualMidBits == NULL ? 0 : tdps->residualMidBits_size;605 size_t segmentL = 0, radExpoL = 0, pwrBoundArrayL = 0;606 if(confparams_cpr->errorBoundMode>=PW_REL)607 {608 segmentL = exe_params->SZ_SIZE_TYPE;609 radExpoL = 1;610 pwrBoundArrayL = 4;611 }612 613 size_t totalByteLength = 3 + 1 + MetaDataByteLength + exe_params->SZ_SIZE_TYPE + 4 + radExpoL + segmentL + pwrBoundArrayL + 4 + 4 + 1 + 8614 + exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + 4 + tdps->rtypeArray_size615 + tdps->typeArray_size + tdps->leadNumArray_size616 + tdps->exactMidBytes_size + residualMidBitsLength + tdps->pwrErrBoundBytes_size;617 618 sameByte = (unsigned char) (sameByte | 0x08); // 00001000, the 4th bit619 // denotes whether it is620 // with "reserved value"621 622 if(confparams_cpr->errorBoundMode>=PW_REL)623 sameByte = (unsigned char) (sameByte | 0x10); // 00001000, the 5th bit624 625 *bytes = (unsigned char*)malloc(sizeof(unsigned char)*totalByteLength);626 627 convertTDPStoBytes_float_reserve(tdps, *bytes, dsLengthBytes, sameByte);628 629 *size = totalByteLength;630 }631 }632 633 void convertTDPStoFlatBytes_float_args(TightDataPointStorageF *tdps, unsigned char* bytes, size_t *size)634 {635 size_t i, k = 0;636 unsigned char dsLengthBytes[8];637 638 if(exe_params->SZ_SIZE_TYPE==4)639 intToBytes_bigEndian(dsLengthBytes, tdps->dataSeriesLength);//4640 else641 longToBytes_bigEndian(dsLengthBytes, tdps->dataSeriesLength);//8642 643 unsigned char sameByte = tdps->allSameData==1?(unsigned char)1:(unsigned char)0;644 sameByte = sameByte | (confparams_cpr->szMode << 1);645 if(tdps->isLossless)646 sameByte = (unsigned char) (sameByte | 0x10);647 if(confparams_cpr->errorBoundMode>=PW_REL)648 sameByte = (unsigned char) (sameByte | 0x20); // 00100000, the 5th bit649 if(exe_params->SZ_SIZE_TYPE==8)650 sameByte = (unsigned char) (sameByte | 0x40); // 01000000, the 6th bit651 652 if(tdps->allSameData==1)653 {654 size_t totalByteLength = 3 + 1 + MetaDataByteLength + exe_params->SZ_SIZE_TYPE + tdps->exactMidBytes_size;655 //*bytes = (unsigned char *)malloc(sizeof(unsigned char)*totalByteLength);656 657 for (i = 0; i < 3; i++)//3658 bytes[k++] = versionNumber[i];659 bytes[k++] = sameByte;660 661 convertSZParamsToBytes(confparams_cpr, &(bytes[k]));662 k = k + MetaDataByteLength;663 664 for (i = 0; i < exe_params->SZ_SIZE_TYPE; i++)665 bytes[k++] = dsLengthBytes[i];666 for (i = 0; i < tdps->exactMidBytes_size; i++)667 bytes[k++] = tdps->exactMidBytes[i];668 669 *size = totalByteLength;670 }671 else if (tdps->rtypeArray == NULL)672 {673 size_t residualMidBitsLength = tdps->residualMidBits == NULL ? 0 : tdps->residualMidBits_size;674 size_t segmentL = 0, radExpoL = 0, pwrBoundArrayL = 0;675 if(confparams_cpr->errorBoundMode>=PW_REL)676 {677 segmentL = exe_params->SZ_SIZE_TYPE;678 radExpoL = 1;679 pwrBoundArrayL = 4;680 }681 682 size_t totalByteLength = 3 + 1 + MetaDataByteLength + exe_params->SZ_SIZE_TYPE + 4 + radExpoL + segmentL + pwrBoundArrayL + 4 + 4 + 1 + 8683 + exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE684 + tdps->typeArray_size + tdps->leadNumArray_size685 + tdps->exactMidBytes_size + residualMidBitsLength + tdps->pwrErrBoundBytes_size;686 687 730 convertTDPStoBytes_float(tdps, bytes, dsLengthBytes, sameByte); 688 731 … … 722 765 * */ 723 766 void free_TightDataPointStorageF(TightDataPointStorageF *tdps) 724 { 767 { 725 768 if(tdps->rtypeArray!=NULL) 726 769 free(tdps->rtypeArray);
Note: See TracChangeset
for help on using the changeset viewer.