Changeset 149
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/blosc.c
r148 r149 30 30 31 31 32 /* Codes for flags */ 33 #define DOSHUFFLE 0x1 34 #define MEMCPYED 0x2 35 32 36 33 37 /* Minimal buffer size to be compressed */ … … 84 88 int32_t compress; 85 89 int32_t clevel; 86 int32_t shuffle; 90 int32_t doshuffle; 91 int32_t memcpyed; 87 92 int32_t ntbytes; 88 93 uint32_t nbytes; … … 144 149 size_t typesize = params.typesize; 145 150 146 if (params. shuffle && (typesize > 1)) {151 if (params.doshuffle && (typesize > 1)) { 147 152 /* Shuffle this block (this makes sense only if typesize > 1) */ 148 153 shuffle(typesize, blocksize, src, tmp); … … 216 221 uint8_t *_tmp; 217 222 size_t typesize = params.typesize; 218 size_t shuffle = params.shuffle; 219 220 if (shuffle && (typesize > 1)) { 223 224 if (params.doshuffle && (typesize > 1)) { 221 225 _tmp = tmp; 222 226 } … … 255 259 } /* Closes j < nsplits */ 256 260 257 if ( shuffle && (typesize > 1)) {261 if (params.doshuffle && (typesize > 1)) { 258 262 if ((uintptr_t)dest % 16 == 0) { 259 263 /* 16-bytes aligned dest. SSE2 unshuffle will work. */ … … 522 526 523 527 /* The public routine for compression. See blosc.h for docstrings. */ 524 unsigned int blosc_compress(int clevel, int shuffle, size_t typesize,528 unsigned int blosc_compress(int clevel, int doshuffle, size_t typesize, 525 529 size_t nbytes, const void *src, void *dest, 526 530 size_t maxbytes) … … 553 557 554 558 /* Shuffle */ 555 if ( shuffle != 0 &&shuffle != 1) {559 if (doshuffle != 0 && doshuffle != 1) { 556 560 fprintf(stderr, "`shuffle` parameter must be either 0 or 1!\n"); 557 561 return -10; … … 588 592 ntbytes = _dest - (uint8_t *)dest; 589 593 590 if ( shuffle == 1) {594 if (doshuffle == 1) { 591 595 /* Shuffle is active */ 592 *flags |= 0x1;/* bit 0 set to one in flags */596 *flags |= DOSHUFFLE; /* bit 0 set to one in flags */ 593 597 } 594 598 … … 596 600 params.compress = 1; 597 601 params.clevel = clevel; 598 params. shuffle =shuffle;602 params.doshuffle = doshuffle; 599 603 params.typesize = typesize; 600 604 params.blocksize = blocksize; … … 613 617 /* Last chance for fitting `src` buffer in `dest` */ 614 618 if ((ntbytes == 0) && (nbytes+BLOSC_MAX_OVERHEAD <= maxbytes)) { 615 /* Specify that this buffer is memcpy'ed (bit 2 set to 1 in flags) */616 619 _dest = (uint8_t *)(dest); 617 _dest[2] = 0x2; 620 /* Specify that this buffer is memcpy'ed */ 621 _dest[2] |= MEMCPYED; 618 622 memcpy(dest+BLOSC_MAX_OVERHEAD, src, nbytes); 619 623 ntbytes = nbytes+BLOSC_MAX_OVERHEAD; … … 635 639 uint8_t version, versionlz; /* versions for compressed header */ 636 640 uint8_t flags; /* flags for header */ 637 int32_t shuffle = 0;/* do unshuffle? */641 int32_t doshuffle = 0; /* do unshuffle? */ 638 642 int32_t ntbytes; /* the number of uncompressed bytes */ 639 643 uint32_t nblocks; /* number of total blocks in buffer */ … … 656 660 657 661 /* Check whether this buffer is memcpy'ed */ 658 if (flags == 0x2) {662 if (flags & MEMCPYED) { 659 663 memcpy(dest, src+BLOSC_MAX_OVERHEAD, nbytes); 660 664 return nbytes; … … 681 685 } 682 686 683 if ( (flags & 0x1) == 1) {687 if (flags & DOSHUFFLE) { 684 688 /* Input is shuffled. Unshuffle it. */ 685 shuffle = 1;689 doshuffle = 1; 686 690 } 687 691 … … 689 693 params.compress = 0; 690 694 params.clevel = 0; /* specific for compression */ 691 params. shuffle =shuffle;695 params.doshuffle = doshuffle; 692 696 params.typesize = typesize; 693 697 params.blocksize = blocksize; … … 730 734 /* Return information about a compressed buffer, namely the type size 731 735 (`typesize`), and whether the shuffle filter has been applied or 732 not (` shuffle`). This function should always succeed. */736 not (`doshuffle`). This function should always succeed. */ 733 737 void blosc_cbuffer_metainfo(const void *cbuffer, size_t *typesize, 734 int * shuffle)738 int *doshuffle) 735 739 { 736 740 uint8_t *_src = (uint8_t *)(cbuffer); /* current pos for source buffer */ … … 747 751 748 752 /* Shuffle info */ 749 if ( (flags & 0x1) == 1) {753 if (flags & DOSHUFFLE) { 750 754 /* Input is shuffled. Unshuffle it. */ 751 * shuffle = 1;755 *doshuffle = 1; 752 756 } 753 757 else { 754 * shuffle = 0;758 *doshuffle = 0; 755 759 } 756 760 } -
trunk/src/blosc.h
r148 r149 130 130 Return information about a compressed buffer, namely the type size 131 131 (`typesize`), and whether the shuffle filter has been applied or not 132 (` shuffle`). This function should always succeed.132 (`doshuffle`). This function should always succeed. 133 133 134 134 */ 135 135 136 136 void blosc_cbuffer_metainfo(const void *cbuffer, size_t *typesize, 137 int * shuffle);137 int *doshuffle); 138 138 139 139
Note: See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/images/blosc-logo-small.png)