pax_global_header00006660000000000000000000000064146303221260014511gustar00rootroot0000000000000052 comment=949947a5516bb987570c900c51866a7a50fb2dd7 hdf5-blosc-1.0.1/000077500000000000000000000000001463032212600134365ustar00rootroot00000000000000hdf5-blosc-1.0.1/.gitignore000066400000000000000000000004411463032212600154250ustar00rootroot00000000000000# Object files *.o *.ko *.obj *.elf # Precompiled Headers *.gch *.pch # Libraries *.lib *.a *.la *.lo # Shared objects (inc. Windows DLLs) *.dll *.so *.so.* *.dylib # Executables *.exe *.out *.app *.i*86 *.x86_64 *.hex # Debug files *.dSYM/ # Anything in the 'build' folder. build/ hdf5-blosc-1.0.1/.travis.yml000066400000000000000000000004141463032212600155460ustar00rootroot00000000000000language: c os: - linux - osx compiler: - gcc - clang before_install: ./travis-before-install.sh install: sudo apt-get install libhdf5-serial-dev before_script: - mkdir build - cd build - cmake .. script: - cmake --build . --config Release - ctest hdf5-blosc-1.0.1/CMakeLists.txt000066400000000000000000000061621463032212600162030ustar00rootroot00000000000000cmake_minimum_required(VERSION 2.8.10) cmake_policy(SET CMP0074 NEW) project(blosc_hdf5) include(ExternalProject) include(GNUInstallDirs) # options option(BUILD_TESTS "Build test programs form the blosc filter" ON) option(BUILD_PLUGIN "Build dynamically loadable plugin for HDF5 version > 1.8.11" ON) if(BUILD_PLUGIN) set(PLUGIN_INSTALL_PATH "/usr/local/hdf5/lib/plugin" CACHE PATH "Where to install the dynamic HDF5-plugin") endif(BUILD_PLUGIN) set(BLOSC_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/blosc") set(BLOSC_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/blosc") set(BLOSC_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${BLOSC_INSTALL_DIR}) message("BLOSC_PREFIX='${BLOSC_PREFIX}'") message("BLOSC_INSTALL_DIR='${BLOSC_INSTALL_DIR}'") message("BLOSC_CMAKE_ARGS='${BLOSC_CMAKE_ARGS}'") message("GIT_EXECUTABLE='${GIT_EXECUTABLE}'") ExternalProject_Add(project_blosc PREFIX ${BLOSC_PREFIX} GIT_REPOSITORY https://github.com/Blosc/c-blosc.git GIT_TAG main INSTALL_DIR ${BLOSC_INSTALL_DIR} CMAKE_ARGS ${BLOSC_CMAKE_ARGS} ) # sources set(SOURCES src/blosc_filter.c) set(PLUGIN_SOURCES src/blosc_filter.c src/blosc_plugin.c ) # dependencies if(MSVC) # FindHDF5.cmake does not find Windows installations. Try to # use an environment variable instead until the official "find" # file can be updated for Windows. # # Note that you have to set this environment variable by hand. file(TO_CMAKE_PATH "$ENV{HDF5_DIR}" HDF5_HINT) set(HDF5_DIR ${HDF5_HINT} CACHE STRING "Path to HDF5 CMake config directory.") find_package(HDF5 REQUIRED HINTS ${HDF5_DIR}) else(MSVC) find_package(HDF5 REQUIRED) endif(MSVC) include_directories(${HDF5_INCLUDE_DIRS}) # add blosc libraries add_library(blosc_shared SHARED IMPORTED) set_property(TARGET blosc_shared PROPERTY IMPORTED_LOCATION ${BLOSC_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}blosc${CMAKE_SHARED_LIBRARY_SUFFIX}) add_dependencies(blosc_shared project_blosc) include_directories(${BLOSC_INSTALL_DIR}/include) add_library(blosc_filter_shared SHARED ${SOURCES}) set_target_properties( blosc_filter_shared PROPERTIES OUTPUT_NAME blosc_filter) target_link_libraries(blosc_filter_shared blosc_shared ${HDF5_LIBRARIES}) if(BUILD_PLUGIN) add_library(blosc_plugin_shared SHARED ${PLUGIN_SOURCES}) set_target_properties( blosc_plugin_shared PROPERTIES OUTPUT_NAME H5Zblosc) target_link_libraries(blosc_plugin_shared blosc_shared ${HDF5_LIBRARIES}) install(TARGETS blosc_plugin_shared DESTINATION ${PLUGIN_INSTALL_PATH} COMPONENT HDF5_FILTER_DEV) endif(BUILD_PLUGIN) # install install(FILES src/blosc_filter.h DESTINATION include COMPONENT HDF5_FILTER_DEV) install(TARGETS blosc_filter_shared DESTINATION lib COMPONENT HDF5_FILTER_DEV) # test message("LINK LIBRARIES='blosc_filter_shared ${HDF5_LIBRARIES}'") if(BUILD_TESTS) enable_testing() set(CMAKE_THREAD_PREFER_PTHREAD TRUE) find_package(Threads REQUIRED) set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT}) add_executable(example src/example.c) target_link_libraries(example blosc_filter_shared ${HDF5_LIBRARIES} ${LIBS}) add_test(test_hdf5_filter example) endif(BUILD_TESTS) hdf5-blosc-1.0.1/LICENSES/000077500000000000000000000000001463032212600146435ustar00rootroot00000000000000hdf5-blosc-1.0.1/LICENSES/BLOSC.txt000066400000000000000000000021741463032212600162520ustar00rootroot00000000000000Blosc - A blocking, shuffling and lossless compression library Copyright (C) 2009-2015 Francesc Alted Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. hdf5-blosc-1.0.1/LICENSES/BLOSC_HDF5.txt000066400000000000000000000021751463032212600170210ustar00rootroot00000000000000Blosc for HDF5 - An HDF5 filter that uses the Blosc compressor. Copyright (C) 2009-2015 Francesc Alted Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. hdf5-blosc-1.0.1/LICENSES/H5PY.txt000066400000000000000000000030371463032212600161340ustar00rootroot00000000000000Copyright Notice and Statement for the h5py Project Copyright (c) 2008 Andrew Collette http://h5py.alfven.org All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: a. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. b. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. c. Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. hdf5-blosc-1.0.1/README.rst000066400000000000000000000111761463032212600151330ustar00rootroot00000000000000===================== Blosc filter for HDF5 ===================== :Travis CI: |travis| :And...: |powered| .. |travis| image:: https://travis-ci.org/Blosc/hdf5-blosc.png?branch=master :target: https://travis-ci.org/Blosc/hdf5-blosc .. |powered| image:: http://b.repl.ca/v1/Powered--By-Blosc-blue.png :target: https://blosc.org This is a filter for HDF5 that uses the Blosc compressor; by installing this filter, you can read and write HDF5 files with Blosc-compressed datasets. You need to be a bit careful before using this filter because you should not activate the shuffle right in HDF5, but rather from Blosc itself. This is because Blosc uses an SIMD shuffle internally which is much faster. Installing the Blosc filter plugin ================================== Instead of just linking this Blosc filter into your HDF5 application, it is possible to install it as a system-wide HDF5 plugin (with HDF5 1.8.11 or later). This is useful because it allows *every* HDF5-using program on your system to transparently read Blosc-compressed HDF5 files. As described in the `HDF5 plugin documentation `_, you just need to compile the Blosc plugin into a shared library and copy it to the plugin directory (which defaults to ``/usr/local/hdf5/lib/plugin`` on non-Windows systems). Following the ``cmake`` instructions below produces a ``libH5Zblosc.so`` shared library file (or ``.dylib``/``.dll`` on Mac/Windows), that you can copy to the HDF5 plugin directory. To *write* Blosc-compressed HDF5 files, on the other hand, an HDF5 using program must be specially modified to enable the Blosc filter when writing HDF5 datasets, as described below. Linking the Blosc filter directly into your program =================================================== Instead of (or in addition to) installing the Blosc plugin system-wide as described above, you can also link the Blosc filter directly into your application. Although this only makes the Blosc filter available in your application (as opposed to other HDF5-using applications), it is useful in cases where installing the plugin is inconvenient. Compile the Blosc filter as described above, but link ``libblosc_filter.a`` (generated by ``make``) directly into your program. In order to register Blosc in your HDF5 application, you then need to call a function in blosc_filter.h, with the following signature:: int register_blosc(char **version, char **date) Calling this will register the filter with the HDF5 library and will return info about the Blosc release in `**version` and `**date` char pointers. A non-negative return value indicates success. If the registration fails, an error is pushed onto the current error stack and a negative value is returned. An example C program ('src/example.c') is included which demonstrates the proper use of the filter. This filter has been tested against HDF5 versions 1.6.5 through 1.8.10. It is released under the MIT license (see LICENSE.txt for details). Using the Blosc filter in your application ========================================== Assuming the filter is installed (either by a system-wide plugin or registered directly in your program as described above), your application can transparently *read* HDF5 files with Blosc-compressed datasets. (The HDF5 library will detect that the dataset is Blosc-compressed and invoke the filter automatically). To *write* an HDF5 file with a Blosc-compressed dataset, you call the `H5Pset_filter `_ function on the property list of the dataset you are creating, and pass ``FILTER_BLOSC`` (defined in ``blosc_filter.h``) for the ``filter_id`` parameter. In addition, HDF5 only supports compression for "chunked" datasets; this just means that you need to call `H5Pset_chunk `_ to specify a chunk size (e.g. 1MB chunks), and the subsequent chunking of the dataset I/O is performed transparently by HDF5. Compiling ========= The filter consists of a single 'src/blosc_filter.c' source file and 'src/blosc_filter.h' header, which will need the Blosc library installed to work. It is simplest to just use the provided ``cmake`` build scripts, which compile and both the filter and the Blosc library into a library for you Assuming you have `cmake `_ and other standard Unix build tools installed, do:: mkdir build cd build cmake .. make This generates the library/plugin files required above in the ``build`` directory. Acknowledgments =============== See THANKS.rst. ---- **Enjoy data!** hdf5-blosc-1.0.1/RELEASE_NOTES.txt000066400000000000000000000012201463032212600162220ustar00rootroot00000000000000============================== Release notes for HDF5-Blosc ============================== :Author: Francesc Alted :Contact: francesc@blosc.org :URL: http://www.blosc.org Changes from 1.0.0 to 1.0.1 =========================== - Fix warnings related to const for blosc_filter.c. Thanks to @matchy233. Closes #34. - Fix build on systems where the libdir is lib64 instead of lib. Thanks to Lehman Garrison. Changes from 0.0.1 to 1.0.0 =========================== - Dropped support for HDF5 1.6.x - Dropped support for C-Blosc < 1.8.0 - CMake has been configured to build the HDF5 plugin by default. Thanks to HÃ¥kon Strandenes. Closes #3. hdf5-blosc-1.0.1/appveyor.yml000066400000000000000000000022661463032212600160340ustar00rootroot00000000000000# AppVeyor CI build configuration for Blosc/hdf5-blosc # https://github.com/Blosc/hdf5-blosc init: # Before cloning the repo, configure git to handle line endings correctly. - git config --global core.autocrlf input # TODO: Need to download, unpack the HDF5 binaries and headers # In the environment matrix below, make sure we also build against both HDF5 1.8 and 1.10 # TODO: Download, unpack, build c-blosc from sources. version: '{build}' environment: CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_env.cmd" VS150COMNTOOLS: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\Common7\\Tools\\" matrix: - GENERATOR: "Visual Studio 10 2010" CONFIG: Release - GENERATOR: "Visual Studio 10 2010 Win64" CONFIG: Release - GENERATOR: "Visual Studio 12 2013" CONFIG: Release - GENERATOR: "Visual Studio 12 Win64" CONFIG: Release - GENERATOR: "Visual Studio 14 2015 Win64" CONFIG: Release build_script: - cmake "-G%GENERATOR%" -H. -B_builds - cmake --build _builds --config "%CONFIG%" test_script: - ps: cd _builds - ctest -VV -C "%CONFIG%" hdf5-blosc-1.0.1/src/000077500000000000000000000000001463032212600142255ustar00rootroot00000000000000hdf5-blosc-1.0.1/src/blosc_filter.c000066400000000000000000000177341463032212600170540ustar00rootroot00000000000000/* Copyright (C) 2010-2016 Francesc Alted http://blosc.org License: MIT (see LICENSE.txt) Filter program that allows the use of the Blosc filter in HDF5. This is based on the LZF filter interface (http://h5py.alfven.org) by Andrew Collette. */ #include #include #include #include #include "hdf5.h" #include "blosc_filter.h" #if defined(__GNUC__) #define PUSH_ERR(func, minor, str, ...) H5Epush(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLINE, minor, str, ##__VA_ARGS__) #elif defined(_MSC_VER) #define PUSH_ERR(func, minor, str, ...) H5Epush(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLINE, minor, str, __VA_ARGS__) #else /* This version is portable but it's better to use compiler-supported approaches for handling the trailing comma issue when possible. */ #define PUSH_ERR(func, minor, ...) H5Epush(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLINE, minor, __VA_ARGS__) #endif /* defined(__GNUC__) */ #define GET_FILTER(a, b, c, d, e, f, g) H5Pget_filter_by_id(a,b,c,d,e,f,g,NULL) size_t blosc_filter(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t* buf_size, void** buf); herr_t blosc_set_local(hid_t dcpl, hid_t type, hid_t space); /* Register the filter, passing on the HDF5 return value */ int register_blosc(char **version, char **date){ int retval; H5Z_class_t filter_class = { H5Z_CLASS_T_VERS, (H5Z_filter_t)(FILTER_BLOSC), 1, 1, "blosc", NULL, (H5Z_set_local_func_t)(blosc_set_local), (H5Z_func_t)(blosc_filter) }; retval = H5Zregister(&filter_class); if(retval<0){ PUSH_ERR("register_blosc", H5E_CANTREGISTER, "Can't register Blosc filter"); } if (version != NULL && date != NULL) { *version = strdup(BLOSC_VERSION_STRING); *date = strdup(BLOSC_VERSION_DATE); } return 1; /* lib is available */ } /* Filter setup. Records the following inside the DCPL: 1. If version information is not present, set slots 0 and 1 to the filter revision and Blosc version, respectively. 2. Compute the type size in bytes and store it in slot 2. 3. Compute the chunk size in bytes and store it in slot 3. */ herr_t blosc_set_local(hid_t dcpl, hid_t type, hid_t space) { int ndims; int i; herr_t r; unsigned int typesize, basetypesize; unsigned int bufsize; hsize_t chunkdims[32]; unsigned int flags; size_t nelements = 8; unsigned int values[] = {0, 0, 0, 0, 0, 0, 0, 0}; hid_t super_type; H5T_class_t classt; r = GET_FILTER(dcpl, FILTER_BLOSC, &flags, &nelements, values, 0, NULL); if (r < 0) return -1; if (nelements < 4) nelements = 4; /* First 4 slots reserved. */ /* Set Blosc info in first two slots */ values[0] = FILTER_BLOSC_VERSION; values[1] = BLOSC_VERSION_FORMAT; ndims = H5Pget_chunk(dcpl, 32, chunkdims); if (ndims < 0) return -1; if (ndims > 32) { PUSH_ERR("blosc_set_local", H5E_CALLBACK, "Chunk rank exceeds limit"); return -1; } typesize = H5Tget_size(type); if (typesize == 0) return -1; /* Get the size of the base type, even for ARRAY types */ classt = H5Tget_class(type); if (classt == H5T_ARRAY) { /* Get the array base component */ super_type = H5Tget_super(type); basetypesize = H5Tget_size(super_type); /* Release resources */ H5Tclose(super_type); } else { basetypesize = typesize; } /* Limit large typesizes (they are pretty expensive to shuffle and, in addition, Blosc does not handle typesizes larger than 256 bytes). */ if (basetypesize > BLOSC_MAX_TYPESIZE) basetypesize = 1; values[2] = basetypesize; /* Get the size of the chunk */ bufsize = typesize; for (i = 0; i < ndims; i++) { bufsize *= chunkdims[i]; } values[3] = bufsize; #ifdef BLOSC_DEBUG fprintf(stderr, "Blosc: Computed buffer size %d\n", bufsize); #endif r = H5Pmodify_filter(dcpl, FILTER_BLOSC, flags, nelements, values); if (r < 0) return -1; return 1; } /* The filter function */ size_t blosc_filter(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t* buf_size, void** buf) { void* outbuf = NULL; int status = 0; /* Return code from Blosc routines */ size_t typesize; size_t outbuf_size; int clevel = 5; /* Compression level default */ int doshuffle = 1; /* Shuffle default */ int compcode; /* Blosc compressor */ int code; const char* compname = "blosclz"; /* The compressor by default */ const char* complist; char errmsg[256]; /* Filter params that are always set */ typesize = cd_values[2]; /* The datatype size */ outbuf_size = cd_values[3]; /* Precomputed buffer guess */ /* Optional params */ if (cd_nelmts >= 5) { clevel = cd_values[4]; /* The compression level */ } if (cd_nelmts >= 6) { doshuffle = cd_values[5]; /* BLOSC_SHUFFLE, BLOSC_BITSHUFFLE */ /* bitshuffle is only meant for production in >= 1.8.0 */ #if ((BLOSC_VERSION_MAJOR <= 1) && (BLOSC_VERSION_MINOR < 8)) if (doshuffle == BLOSC_BITSHUFFLE) { PUSH_ERR("blosc_filter", H5E_CALLBACK, "this Blosc library version is not supported. Please update to >= 1.8"); goto failed; } #endif } if (cd_nelmts >= 7) { compcode = cd_values[6]; /* The Blosc compressor used */ /* Check that we actually have support for the compressor code */ complist = blosc_list_compressors(); code = blosc_compcode_to_compname(compcode, &compname); if (code == -1) { PUSH_ERR("blosc_filter", H5E_CALLBACK, "this Blosc library does not have support for " "the '%s' compressor, but only for: %s", compname, complist); goto failed; } } /* We're compressing */ if (!(flags & H5Z_FLAG_REVERSE)) { /* Allocate an output buffer exactly as long as the input data; if the result is larger, we simply return 0. The filter is flagged as optional, so HDF5 marks the chunk as uncompressed and proceeds. */ outbuf_size = (*buf_size); #ifdef BLOSC_DEBUG fprintf(stderr, "Blosc: Compress %zd chunk w/buffer %zd\n", nbytes, outbuf_size); #endif outbuf = malloc(outbuf_size); if (outbuf == NULL) { PUSH_ERR("blosc_filter", H5E_CALLBACK, "Can't allocate compression buffer"); goto failed; } blosc_set_compressor(compname); status = blosc_compress(clevel, doshuffle, typesize, nbytes, *buf, outbuf, nbytes); if (status < 0) { PUSH_ERR("blosc_filter", H5E_CALLBACK, "Blosc compression error"); goto failed; } /* We're decompressing */ } else { /* declare dummy variables */ size_t cbytes, blocksize; free(outbuf); /* Extract the exact outbuf_size from the buffer header. * * NOTE: the guess value got from "cd_values" corresponds to the * uncompressed chunk size but it should not be used in a general * cases since other filters in the pipeline can modify the buffere * size. */ blosc_cbuffer_sizes(*buf, &outbuf_size, &cbytes, &blocksize); #ifdef BLOSC_DEBUG fprintf(stderr, "Blosc: Decompress %zd chunk w/buffer %zd\n", nbytes, outbuf_size); #endif outbuf = malloc(outbuf_size); if (outbuf == NULL) { PUSH_ERR("blosc_filter", H5E_CALLBACK, "Can't allocate decompression buffer"); goto failed; } status = blosc_decompress(*buf, outbuf, outbuf_size); if (status <= 0) { /* decompression failed */ PUSH_ERR("blosc_filter", H5E_CALLBACK, "Blosc decompression error"); goto failed; } /* if !status */ } /* compressing vs decompressing */ if (status != 0) { free(*buf); *buf = outbuf; *buf_size = outbuf_size; return status; /* Size of compressed/decompressed data */ } failed: free(outbuf); return 0; } /* End filter function */ hdf5-blosc-1.0.1/src/blosc_filter.h000066400000000000000000000010441463032212600170440ustar00rootroot00000000000000#ifndef FILTER_BLOSC_H #define FILTER_BLOSC_H #ifdef __cplusplus extern "C" { #endif #include "blosc.h" /* Filter revision number, starting at 1 */ /* #define FILTER_BLOSC_VERSION 1 */ #define FILTER_BLOSC_VERSION 2 /* multiple compressors since Blosc 1.3 */ /* Filter ID registered with the HDF Group */ #define FILTER_BLOSC 32001 /* Registers the filter with the HDF5 library. */ #if defined(_MSC_VER) __declspec(dllexport) #endif /* defined(_MSC_VER) */ int register_blosc(char **version, char **date); #ifdef __cplusplus } #endif #endif hdf5-blosc-1.0.1/src/blosc_plugin.c000066400000000000000000000024051463032212600170520ustar00rootroot00000000000000/* * Dynamically loaded filter plugin for HDF5 blosc filter. * * Author: Kiyoshi Masui * Created: 2014 * * For compiling, use: * $ h5cc -fPIC -shared blosc_plugin.c blosc_filter.c -o libH5Zblosc.so -lblosc * */ #include #define H5Z_class_t_vers 2 #include "blosc_plugin.h" #include "blosc_filter.h" /* Prototypes for filter function in blosc_filter.c. */ size_t blosc_filter(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t* buf_size, void** buf); herr_t blosc_set_local(hid_t dcpl, hid_t type, hid_t space); H5Z_class_t blosc_H5Filter[1] = { { H5Z_CLASS_T_VERS, (H5Z_filter_t)(FILTER_BLOSC), 1, /* encoder_present flag (set to true) */ 1, /* decoder_present flag (set to true) */ "blosc", /* Filter info */ NULL, /* The "can apply" callback */ (H5Z_set_local_func_t)(blosc_set_local), /* The "set local" callback */ (H5Z_func_t)(blosc_filter), /* The filter function */ } }; H5PL_type_t H5PLget_plugin_type(void) { return H5PL_TYPE_FILTER; } const void* H5PLget_plugin_info(void) { return blosc_H5Filter; } hdf5-blosc-1.0.1/src/blosc_plugin.h000066400000000000000000000013301463032212600170530ustar00rootroot00000000000000/* * Dynamically loaded filter plugin for HDF5 blosc filter. * * Author: Kiyoshi Masui * Created: 2014 * * * Header file * ----------- * * This provides dynamically loaded HDF5 filter functionality (introduced * in HDF5-1.8.11, May 2013) to the blosc HDF5 filter. * * Usage: compile as a shared library and install either to the default * search location for HDF5 filter plugins (on Linux * /usr/local/hdf5/lib/plugin) or to a location pointed to by the * HDF5_PLUGIN_PATH environment variable. * */ #ifndef PLUGIN_BLOSC_H #define PLUGIN_BLOSC_H #include "H5PLextern.h" H5PL_type_t H5PLget_plugin_type(void); const void* H5PLget_plugin_info(void); #endif // PLUGIN_BLOSC_H hdf5-blosc-1.0.1/src/example.c000066400000000000000000000066001463032212600160260ustar00rootroot00000000000000/* Copyright (C) 2010 Francesc Alted http://blosc.org License: MIT (see LICENSE.txt) Example program demonstrating use of the Blosc filter from C code. This is based on the LZF example (http://h5py.alfven.org) by Andrew Collette. To compile this program: h5cc blosc_filter.c example.c -o example -lblosc -lpthread To run: $ ./example Blosc version info: 1.3.0 ($Date:: 2014-01-11 #$) Success! $ h5ls -v example.h5 Opened "example.h5" with sec2 driver. dset Dataset {100/100, 100/100, 100/100} Location: 1:800 Links: 1 Chunks: {1, 100, 100} 40000 bytes Storage: 4000000 logical bytes, 126002 allocated bytes, 3174.55% utilization Filter-0: blosc-32001 OPT {2, 2, 4, 40000, 4, 1, 2} Type: native float */ #include #include "hdf5.h" #include "blosc_filter.h" #define SIZE 100*100*100 #define SHAPE {100,100,100} #define CHUNKSHAPE {1,100,100} int main(){ static float data[SIZE]; static float data_out[SIZE]; const hsize_t shape[] = SHAPE; const hsize_t chunkshape[] = CHUNKSHAPE; char *version, *date; int r, i; unsigned int cd_values[7]; int return_code = 1; hid_t fid, sid, dset, plist = 0; for(i=0; i0) H5Dclose(dset); if(sid>0) H5Sclose(sid); if(plist>0) H5Pclose(plist); if(fid>0) H5Fclose(fid); return return_code; } hdf5-blosc-1.0.1/travis-before-install.sh000077500000000000000000000006171463032212600202150ustar00rootroot00000000000000#/bin/sh -f # things to do for travis-ci in the before_install section if ( test "`uname -s`" = "Darwin" ) then #cmake v2.8.12 is installed on the Mac workers now #brew update #brew install cmake echo else #install a newer cmake since at this time Travis only has version 2.8.7 sudo add-apt-repository --yes ppa:kalakris/cmake sudo apt-get update -qq sudo apt-get install cmake fi