Changeset 148


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

Introduced BLOSC_MAX_OVERHEAD symbol that is the maximum overhead introduced by Blosc during compression.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bench/bench.c

    r147 r148  
    164164  memcpy(srccpy, src, size); 
    165165  for (j = 0; j < nchunks; j++) { 
    166     /* 16 additional bytes should be enough for encoding everything */ 
    167     dest[j] = malloc(size+16); 
     166    dest[j] = malloc(size+BLOSC_MAX_OVERHEAD); 
    168167  } 
    169168 
     
    212211      for (j = 0; j < nchunks; j++) { 
    213212        cbytes = blosc_compress(clevel, doshuffle, elsize, size, src, 
    214                                 dest[j], size); 
     213                                dest[j], size+BLOSC_MAX_OVERHEAD); 
    215214      } 
    216215    } 
  • trunk/src/blosc.c

    r147 r148  
    612612 
    613613  /* Last chance for fitting `src` buffer in `dest` */ 
    614   if ((ntbytes == 0) && (nbytes+16 <= maxbytes)) { 
     614  if ((ntbytes == 0) && (nbytes+BLOSC_MAX_OVERHEAD <= maxbytes)) { 
    615615    /* Specify that this buffer is memcpy'ed (bit 2 set to 1 in flags) */ 
    616616    _dest = (uint8_t *)(dest); 
    617617    _dest[2] = 0x2; 
    618     memcpy(dest+16, src, nbytes); 
    619     ntbytes = nbytes+16; 
     618    memcpy(dest+BLOSC_MAX_OVERHEAD, src, nbytes); 
     619    ntbytes = nbytes+BLOSC_MAX_OVERHEAD; 
    620620  } 
    621621 
     
    657657  /* Check whether this buffer is memcpy'ed */ 
    658658  if (flags == 0x2) { 
    659     memcpy(dest, src+16, nbytes); 
     659    memcpy(dest, src+BLOSC_MAX_OVERHEAD, nbytes); 
    660660    return nbytes; 
    661661  } 
  • trunk/src/blosc.h

    r147 r148  
    2727#define BLOSC_VERSION_CFORMAT (BLOSC_VERSION_FORMAT << 8) & (BLOSCLZ_VERSION_FORMAT) 
    2828 
     29/* The maximum overhead during compression in bytes */ 
     30#define BLOSC_MAX_OVERHEAD 16 
    2931 
    3032/** 
     
    5860 
    5961  The `dest` buffer must have at least the size of `maxbytes`.  Blosc 
    60   guarantees that if you set `maxbytes` at least to `nbytes` + 16, the 
    61   compression will always succeed.  The `src` buffer and the `dest` 
    62   buffer can not overlap. 
     62  guarantees that if you set `maxbytes` to, at least, 
     63  (`nbytes`+BLOSC_MAX_OVERHEAD), the compression will always succeed. 
     64  The `src` buffer and the `dest` buffer can not overlap. 
    6365 
    6466  If `src` buffer cannot be compressed into `maxbytes`, the return 
Note: See TracChangeset for help on using the changeset viewer.