Skip to content

Commit

Permalink
Upgrade the included LZF filter
Browse files Browse the repository at this point in the history
This is the LZF filter included in h5py 3.12.1.

Require h5py>=2.5.0 so that h5py provides H5PLget_plugin_type() and
H5PLget_plugin_info(). Updating the requirements should not be an issue
as h5py 2.4.0 was released in January 2015 while h5py 2.5.0 was released
in April 2015.
  • Loading branch information
DimitriPapadopoulos committed Dec 6, 2024
1 parent 4b3dc9f commit dcf868b
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 109 deletions.
7 changes: 3 additions & 4 deletions lzf/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Copyright Notice and Statement for LZF filter

Copyright (c) 2008-2009 Andrew Collette
http://h5py.alfven.org
http://h5py.org
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand All @@ -16,8 +16,8 @@ b. Redistributions in binary form must reproduce the above copyright
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
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
Expand All @@ -31,4 +31,3 @@ 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.

34 changes: 21 additions & 13 deletions lzf/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ is released under the BSD license (see LICENSE.txt for details).
Using the filter from HDF5
--------------------------

There is exactly one new public function declared in lzf_filter.h, with
the following signature:
With HDF5 version 1.8.11 or later the filter can be loaded dynamically by the
HDF5 library. The filter needs to be compiled as a plugin as described below
that is placed in the default plugin path /usr/local/hdf5/lib/plugin/. The
plugin path can be overridden with the environment variable HDF5_PLUGIN_PATH.

With older HDF5 versions, or when statically linking the filter to your program,
the filter must be registered manually. There is exactly one new public function
declared in lzf_filter.h, with the following signature:

int register_lzf(void)

Expand All @@ -38,17 +44,23 @@ version of the LZF compression library. Since the filter is stateless, it's
recommended to statically link the entire thing into your program; for
example:

$ gcc -O2 -lhdf5 lzf/*.c lzf_filter.c myprog.c -o myprog
$ gcc -O2 lzf/*.c lzf_filter.c myprog.c -lhdf5 -o myprog

It can also be built as a shared library, although you will have to install
the resulting library somewhere the runtime linker can find it:

$ gcc -O2 -lhdf5 -fPIC -shared lzf/*.c lzf_filter.c -o liblzf_filter.so
$ gcc -O2 -fPIC -shared lzf/*.c lzf_filter.c -lhdf5 -o liblzf_filter.so

A similar procedure should be used for building C++ code. As in these
examples, using option -O1 or higher is strongly recommended for increased
performance.

With HDF5 version 1.8.11 or later the filter can be dynamically loaded as a
plugin. The filter is built as a shared library that is *not* linked against
the HDF5 library:

$ gcc -O2 -fPIC -shared lzf/*.c lzf_filter.c -o liblzf_filter.so


Contact
-------
Expand All @@ -58,11 +70,13 @@ goal of h5py is to provide access to the majority of the HDF5 C API and feature
set from Python. The most recent version of h5py (1.1) includes the LZF
filter by default.

* Downloads and bug tracker: http://h5py.googlecode.com
* Downloads: https://pypi.org/project/h5py/

* Main web site and documentation: http://h5py.alfven.org
* Issue tracker: https://github.com/h5py/h5py

* Contact email: h5py at alfven dot org
* Main web site and documentation: http://h5py.org

* Discussion forum: https://forum.hdfgroup.org/c/hdf5/h5py


History of changes
Expand All @@ -76,9 +90,3 @@ Revision 2

Revision 1
Initial release.






7 changes: 3 additions & 4 deletions lzf/example.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright (C) 2009 Andrew Collette
http://h5py.alfven.org
http://h5py.org
License: BSD (see LICENSE.txt)
Example program demonstrating use of the LZF filter from C code.
Expand All @@ -13,7 +13,7 @@
$ ./example
Success!
$ h5ls -v test_lzf.hdf5
$ h5ls -v test_lzf.hdf5
Opened "test_lzf.hdf5" with sec2 driver.
dset Dataset {100/100, 100/100, 100/100}
Location: 0:1:0:976
Expand Down Expand Up @@ -79,7 +79,7 @@ int main(){

dset = H5Dcreate(fid, "dset", H5T_NATIVE_FLOAT, sid, plist);
if(dset<0) goto failed;

r = H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data);
if(r<0) goto failed;

Expand All @@ -103,4 +103,3 @@ int main(){

return return_code;
}

13 changes: 6 additions & 7 deletions lzf/lzf/lzf.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/*
* Copyright (c) 2000-2008 Marc Alexander Lehmann <[email protected]>
*
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
*
* 2. 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.
*
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
Expand Down Expand Up @@ -73,7 +73,7 @@
* and lzf_c.c.
*
*/
unsigned int
unsigned int
lzf_compress (const void *const in_data, unsigned int in_len,
void *out_data, unsigned int out_len);

Expand All @@ -92,9 +92,8 @@ lzf_compress (const void *const in_data, unsigned int in_len,
*
* This function is very fast, about as fast as a copying loop.
*/
unsigned int
unsigned int
lzf_decompress (const void *const in_data, unsigned int in_len,
void *out_data, unsigned int out_len);

#endif

17 changes: 8 additions & 9 deletions lzf/lzf/lzfP.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/*
* Copyright (c) 2000-2007 Marc Alexander Lehmann <[email protected]>
*
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
*
* 2. 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.
*
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
Expand Down Expand Up @@ -99,15 +99,15 @@

/*
* Avoid assigning values to errno variable? for some embedding purposes
* (linux kernel for example), this is neccessary. NOTE: this breaks
* (linux kernel for example), this is necessary. NOTE: this breaks
* the documentation in lzf.h.
*/
#ifndef AVOID_ERRNO
# define AVOID_ERRNO 0
#endif

/*
* Wether to pass the LZF_STATE variable as argument, or allocate it
* Whether to pass the LZF_STATE variable as argument, or allocate it
* on the stack. For small-stack environments, define this to 1.
* NOTE: this breaks the prototype in lzf.h.
*/
Expand All @@ -116,11 +116,11 @@
#endif

/*
* Wether to add extra checks for input validity in lzf_decompress
* Whether to add extra checks for input validity in lzf_decompress
* and return EINVAL if the input stream has been corrupted. This
* only shields against overflowing the input buffer and will not
* detect most corrupted streams.
* This check is not normally noticable on modern hardware
* This check is not normally noticeable on modern hardware
* (<1% slowdown), but might slow down older cpus considerably.
*/

Expand Down Expand Up @@ -163,4 +163,3 @@ typedef const u8 *LZF_STATE[1 << (HLOG)];
#endif

#endif

9 changes: 4 additions & 5 deletions lzf/lzf/lzf_c.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/*
* Copyright (c) 2000-2008 Marc Alexander Lehmann <[email protected]>
*
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
*
* 2. 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.
*
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
Expand Down Expand Up @@ -293,4 +293,3 @@ lzf_compress (const void *const in_data, unsigned int in_len,

return op - (u8 *)out_data;
}

11 changes: 5 additions & 6 deletions lzf/lzf/lzf_d.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/*
* Copyright (c) 2000-2007 Marc Alexander Lehmann <[email protected]>
*
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
*
* 2. 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.
*
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
Expand Down Expand Up @@ -56,7 +56,7 @@
#endif
*/

unsigned int
unsigned int
lzf_decompress (const void *const in_data, unsigned int in_len,
void *out_data, unsigned int out_len)
{
Expand Down Expand Up @@ -151,4 +151,3 @@ lzf_decompress (const void *const in_data, unsigned int in_len,

return op - (u8 *)out_data;
}

Loading

0 comments on commit dcf868b

Please sign in to comment.