diff --git a/src/HDF5Plugin-Zstandard/zstd_h5plugin.c b/src/HDF5Plugin-Zstandard/zstd_h5plugin.c index 5a3dfd38..a527f1ff 100644 --- a/src/HDF5Plugin-Zstandard/zstd_h5plugin.c +++ b/src/HDF5Plugin-Zstandard/zstd_h5plugin.c @@ -35,8 +35,8 @@ DLL_EXPORT size_t zstd_filter(unsigned int flags, size_t cd_nelmts, aggression = (int)cd_values[0]; else aggression = ZSTD_CLEVEL_DEFAULT; - if (aggression < 1 /*ZSTD_minCLevel()*/) - aggression = 1 /*ZSTD_minCLevel()*/; + if (aggression < ZSTD_minCLevel()) + aggression = ZSTD_minCLevel(); else if (aggression > ZSTD_maxCLevel()) aggression = ZSTD_maxCLevel(); diff --git a/src/hdf5plugin/__init__.py b/src/hdf5plugin/__init__.py index e6cc8e5a..59f4493c 100644 --- a/src/hdf5plugin/__init__.py +++ b/src/hdf5plugin/__init__.py @@ -391,7 +391,7 @@ class Zstd(_FilterRefClass): **hdf5plugin.Zstd()) f.close() - :param int clevel: Compression level from 1 (lowest compression) to 22 (maximum compression). + :param int clevel: Compression level from -131072 (lowest compression) to 22 (maximum compression). Ultra compression extends from 20 through 22. Default: 3. .. code-block:: python @@ -405,11 +405,13 @@ class Zstd(_FilterRefClass): """ filter_id = ZSTD_ID - def __init__(self, clevel=3): - assert 1 <= clevel <= 22 - self.filter_options = (clevel,) - + def __init__(self, clevel=None): + if clevel is not None: + # filter_options are passed as uints: conversion needed to pass negative clevel + clevel = _ctypes.c_uint(clevel).value + self.filter_options = (clevel,) + def _init_filters(): """Initialise and register HDF5 filters with h5py