Exemplo n.º 1
0
 /**
  * \brief Uncompress compressed data \p m_cdata to \p data m_rdata.
  *
  * \p m_rdata must point to writable storage space and
  * \p m_rdata_size must specify the legal space.
  *
  * \returns true on success
  */
 bool bloscDecompress()
 {
     assert( m_rdata && m_cdata );
     
     size_t blosc_nbytes, blosc_cbytes, blosc_blocksize; 
     
     // calculate necessary buffer sizes
     blosc_cbuffer_sizes( m_cdata, &blosc_nbytes, &blosc_cbytes, &blosc_blocksize );
     
     // uncompressed data must fit into
     if( blosc_nbytes != m_rdata_size )
     {
         m_err.set( MSG_ERRCOMPRESSION );
         return false;
     }
     
     // decompress directly into items memory space
     if( blosc_decompress( m_cdata, m_rdata, m_rdata_size ) <= 0 )
     {
         m_err.set( MSG_ERRCOMPRESSION );
         return false;
     } 
     
     return true;
 }
Exemplo n.º 2
0
static const char *test_cbuffer_sizes() {
  size_t nbytes_, cbytes_, blocksize;

  blosc_cbuffer_sizes(dest, &nbytes_, &cbytes_, &blocksize);
  mu_assert("ERROR: nbytes incorrect(1)", nbytes == size);
  mu_assert("ERROR: nbytes incorrect(2)", nbytes_ == nbytes);
  mu_assert("ERROR: cbytes incorrect", cbytes == cbytes_);
  mu_assert("ERROR: blocksize incorrect", blocksize >= 128);
  return 0;
}
Exemplo n.º 3
0
    size_t
    BloscWrapper::reserveNeededToDecompress(void* src) {

        size_t nbytes;
        size_t cbytes;
        size_t blocksize;

        // figure out how much space we need
        blosc_cbuffer_sizes(src, &nbytes, &cbytes, &blocksize);

        return nbytes;
    }
Exemplo n.º 4
0
/*  Read blosc header from input and fetch the uncompressed size into nbytes.
 *  Also makes sure that value of the compressed bytes from the header is the
 *  same as the cbytes provided by the input.
 *
 *  Returns 1 on success and 0 on failure with a Python exception set.
 *
 *  */
static int
get_nbytes(void * input, size_t cbytes, size_t * nbytes)
{
    size_t cbytes2, blocksize;

    /* Get the length of the uncompressed buffer */
    blosc_cbuffer_sizes(input, nbytes, &cbytes2, &blocksize);
    if ((size_t)cbytes != cbytes2) {
      blosc_error((int)cbytes,
                  ": not a Blosc buffer or header info is corrupted");
      return 0;
    }
    return 1;
}