Changeset 149


Ignore:
Timestamp:
06/08/10 04:21:32 (3 years ago)
Author:
faltet
Message:

Added symbol codes for compression flags.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/blosc.c

    r148 r149  
    3030 
    3131 
     32/* Codes for flags */ 
     33#define DOSHUFFLE 0x1 
     34#define MEMCPYED  0x2 
     35 
    3236 
    3337/* Minimal buffer size to be compressed */ 
     
    8488  int32_t compress; 
    8589  int32_t clevel; 
    86   int32_t shuffle; 
     90  int32_t doshuffle; 
     91  int32_t memcpyed; 
    8792  int32_t ntbytes; 
    8893  uint32_t nbytes; 
     
    144149  size_t typesize = params.typesize; 
    145150 
    146   if (params.shuffle && (typesize > 1)) { 
     151  if (params.doshuffle && (typesize > 1)) { 
    147152    /* Shuffle this block (this makes sense only if typesize > 1) */ 
    148153    shuffle(typesize, blocksize, src, tmp); 
     
    216221  uint8_t *_tmp; 
    217222  size_t typesize = params.typesize; 
    218   size_t shuffle = params.shuffle; 
    219  
    220   if (shuffle && (typesize > 1)) { 
     223 
     224  if (params.doshuffle && (typesize > 1)) { 
    221225    _tmp = tmp; 
    222226  } 
     
    255259  } /* Closes j < nsplits */ 
    256260 
    257   if (shuffle && (typesize > 1)) { 
     261  if (params.doshuffle && (typesize > 1)) { 
    258262    if ((uintptr_t)dest % 16 == 0) { 
    259263      /* 16-bytes aligned dest.  SSE2 unshuffle will work. */ 
     
    522526 
    523527/* The public routine for compression.  See blosc.h for docstrings. */ 
    524 unsigned int blosc_compress(int clevel, int shuffle, size_t typesize, 
     528unsigned int blosc_compress(int clevel, int doshuffle, size_t typesize, 
    525529                            size_t nbytes, const void *src, void *dest, 
    526530                            size_t maxbytes) 
     
    553557 
    554558  /* Shuffle */ 
    555   if (shuffle != 0 && shuffle != 1) { 
     559  if (doshuffle != 0 && doshuffle != 1) { 
    556560    fprintf(stderr, "`shuffle` parameter must be either 0 or 1!\n"); 
    557561    return -10; 
     
    588592  ntbytes = _dest - (uint8_t *)dest; 
    589593 
    590   if (shuffle == 1) { 
     594  if (doshuffle == 1) { 
    591595    /* Shuffle is active */ 
    592     *flags |= 0x1;                         /* bit 0 set to one in flags */ 
     596    *flags |= DOSHUFFLE;                   /* bit 0 set to one in flags */ 
    593597  } 
    594598 
     
    596600  params.compress = 1; 
    597601  params.clevel = clevel; 
    598   params.shuffle = shuffle; 
     602  params.doshuffle = doshuffle; 
    599603  params.typesize = typesize; 
    600604  params.blocksize = blocksize; 
     
    613617  /* Last chance for fitting `src` buffer in `dest` */ 
    614618  if ((ntbytes == 0) && (nbytes+BLOSC_MAX_OVERHEAD <= maxbytes)) { 
    615     /* Specify that this buffer is memcpy'ed (bit 2 set to 1 in flags) */ 
    616619    _dest = (uint8_t *)(dest); 
    617     _dest[2] = 0x2; 
     620    /* Specify that this buffer is memcpy'ed */ 
     621    _dest[2] |= MEMCPYED; 
    618622    memcpy(dest+BLOSC_MAX_OVERHEAD, src, nbytes); 
    619623    ntbytes = nbytes+BLOSC_MAX_OVERHEAD; 
     
    635639  uint8_t version, versionlz;    /* versions for compressed header */ 
    636640  uint8_t flags;                 /* flags for header */ 
    637   int32_t shuffle = 0;           /* do unshuffle? */ 
     641  int32_t doshuffle = 0;         /* do unshuffle? */ 
    638642  int32_t ntbytes;               /* the number of uncompressed bytes */ 
    639643  uint32_t nblocks;              /* number of total blocks in buffer */ 
     
    656660 
    657661  /* Check whether this buffer is memcpy'ed */ 
    658   if (flags == 0x2) { 
     662  if (flags & MEMCPYED) { 
    659663    memcpy(dest, src+BLOSC_MAX_OVERHEAD, nbytes); 
    660664    return nbytes; 
     
    681685  } 
    682686 
    683   if ((flags & 0x1) == 1) { 
     687  if (flags & DOSHUFFLE) { 
    684688    /* Input is shuffled.  Unshuffle it. */ 
    685     shuffle = 1; 
     689    doshuffle = 1; 
    686690  } 
    687691 
     
    689693  params.compress = 0; 
    690694  params.clevel = 0;            /* specific for compression */ 
    691   params.shuffle = shuffle; 
     695  params.doshuffle = doshuffle; 
    692696  params.typesize = typesize; 
    693697  params.blocksize = blocksize; 
     
    730734/* Return information about a compressed buffer, namely the type size 
    731735   (`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. */ 
    733737void blosc_cbuffer_metainfo(const void *cbuffer, size_t *typesize, 
    734                             int *shuffle) 
     738                            int *doshuffle) 
    735739{ 
    736740  uint8_t *_src = (uint8_t *)(cbuffer);  /* current pos for source buffer */ 
     
    747751 
    748752  /* Shuffle info */ 
    749   if ((flags & 0x1) == 1) { 
     753  if (flags & DOSHUFFLE) { 
    750754    /* Input is shuffled.  Unshuffle it. */ 
    751     *shuffle = 1; 
     755    *doshuffle = 1; 
    752756  } 
    753757  else { 
    754     *shuffle = 0; 
     758    *doshuffle = 0; 
    755759  } 
    756760} 
  • trunk/src/blosc.h

    r148 r149  
    130130  Return information about a compressed buffer, namely the type size 
    131131  (`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. 
    133133 
    134134*/ 
    135135 
    136136void blosc_cbuffer_metainfo(const void *cbuffer, size_t *typesize, 
    137                             int *shuffle); 
     137                            int *doshuffle); 
    138138 
    139139 
Note: See TracChangeset for help on using the changeset viewer.