summaryrefslogtreecommitdiffstats
path: root/src/H5Zszip.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /src/H5Zszip.c
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'src/H5Zszip.c')
-rw-r--r--src/H5Zszip.c217
1 files changed, 106 insertions, 111 deletions
diff --git a/src/H5Zszip.c b/src/H5Zszip.c
index c72c499..e9dabf7 100644
--- a/src/H5Zszip.c
+++ b/src/H5Zszip.c
@@ -11,46 +11,43 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#include "H5Zmodule.h" /* This source code file is part of the H5Z module */
-
-
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fprivate.h" /* File access */
-#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Oprivate.h" /* Object headers */
-#include "H5Pprivate.h" /* Property lists */
-#include "H5Sprivate.h" /* Dataspaces */
-#include "H5Tprivate.h" /* Datatypes */
-#include "H5Zpkg.h" /* Data filters */
+#include "H5Zmodule.h" /* This source code file is part of the H5Z module */
+
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* File access */
+#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Oprivate.h" /* Object headers */
+#include "H5Pprivate.h" /* Property lists */
+#include "H5Sprivate.h" /* Dataspaces */
+#include "H5Tprivate.h" /* Datatypes */
+#include "H5Zpkg.h" /* Data filters */
#ifdef H5_HAVE_FILTER_SZIP
#ifdef H5_HAVE_SZLIB_H
-# include "szlib.h"
+#include "szlib.h"
#endif
/* Local function prototypes */
static htri_t H5Z__can_apply_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id);
static herr_t H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id);
-static size_t H5Z__filter_szip(unsigned flags, size_t cd_nelmts,
- const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf);
+static size_t H5Z__filter_szip(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes,
+ size_t *buf_size, void **buf);
/* This message derives from H5Z */
H5Z_class2_t H5Z_SZIP[1] = {{
- H5Z_CLASS_T_VERS, /* H5Z_class_t version */
- H5Z_FILTER_SZIP, /* Filter id number */
- 1, /* Assume encoder present: check before registering */
- 1, /* decoder_present flag (set to true) */
- "szip", /* Filter name for debugging */
- H5Z__can_apply_szip, /* The "can apply" callback */
- H5Z__set_local_szip, /* The "set local" callback */
- H5Z__filter_szip, /* The actual filter function */
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
+ H5Z_FILTER_SZIP, /* Filter id number */
+ 1, /* Assume encoder present: check before registering */
+ 1, /* decoder_present flag (set to true) */
+ "szip", /* Filter name for debugging */
+ H5Z__can_apply_szip, /* The "can apply" callback */
+ H5Z__set_local_szip, /* The "set local" callback */
+ H5Z__filter_szip, /* The actual filter function */
}};
-
-
/*-------------------------------------------------------------------------
* Function: H5Z__can_apply_szip
*
@@ -75,39 +72,38 @@ H5Z_class2_t H5Z_SZIP[1] = {{
static htri_t
H5Z__can_apply_szip(hid_t H5_ATTR_UNUSED dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSED space_id)
{
- const H5T_t *type; /* Datatype */
- unsigned dtype_size; /* Datatype's size (in bits) */
- H5T_order_t dtype_order; /* Datatype's endianness order */
- htri_t ret_value = TRUE; /* Return value */
+ const H5T_t *type; /* Datatype */
+ unsigned dtype_size; /* Datatype's size (in bits) */
+ H5T_order_t dtype_order; /* Datatype's endianness order */
+ htri_t ret_value = TRUE; /* Return value */
FUNC_ENTER_STATIC
/* Get datatype */
- if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
+ if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
/* Get datatype's size, for checking the "bits-per-pixel" */
- if((dtype_size = (8 * H5T_get_size(type))) == 0)
+ if ((dtype_size = (8 * H5T_get_size(type))) == 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size")
/* Range check datatype's size */
- if(dtype_size > 32 && dtype_size != 64)
+ if (dtype_size > 32 && dtype_size != 64)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype size")
/* Get datatype's endianness order */
- if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR)
+ if ((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "can't retrieve datatype endianness order")
/* Range check datatype's endianness order */
/* (Note: this may not handle non-atomic datatypes well) */
- if(dtype_order != H5T_ORDER_LE && dtype_order != H5T_ORDER_BE)
+ if (dtype_order != H5T_ORDER_LE && dtype_order != H5T_ORDER_BE)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype endianness order")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5Z__can_apply_szip() */
-
/*-------------------------------------------------------------------------
* Function: H5Z__set_local_szip
*
@@ -124,52 +120,52 @@ done:
static herr_t
H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
{
- H5P_genplist_t *dcpl_plist; /* Property list pointer */
- const H5T_t *type; /* Datatype */
- const H5S_t *ds; /* Dataspace */
- unsigned flags; /* Filter flags */
- size_t cd_nelmts = H5Z_SZIP_USER_NPARMS; /* Number of filter parameters */
- unsigned cd_values[H5Z_SZIP_TOTAL_NPARMS]; /* Filter parameters */
- hsize_t dims[H5O_LAYOUT_NDIMS]; /* Dataspace (i.e. chunk) dimensions */
- int ndims; /* Number of (chunk) dimensions */
- H5T_order_t dtype_order; /* Datatype's endianness order */
- size_t dtype_size; /* Datatype's size (in bits) */
- size_t dtype_precision; /* Datatype's precision (in bits) */
- size_t dtype_offset; /* Datatype's offset (in bits) */
- hsize_t scanline; /* Size of dataspace's fastest changing dimension */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5P_genplist_t *dcpl_plist; /* Property list pointer */
+ const H5T_t * type; /* Datatype */
+ const H5S_t * ds; /* Dataspace */
+ unsigned flags; /* Filter flags */
+ size_t cd_nelmts = H5Z_SZIP_USER_NPARMS; /* Number of filter parameters */
+ unsigned cd_values[H5Z_SZIP_TOTAL_NPARMS]; /* Filter parameters */
+ hsize_t dims[H5O_LAYOUT_NDIMS]; /* Dataspace (i.e. chunk) dimensions */
+ int ndims; /* Number of (chunk) dimensions */
+ H5T_order_t dtype_order; /* Datatype's endianness order */
+ size_t dtype_size; /* Datatype's size (in bits) */
+ size_t dtype_precision; /* Datatype's precision (in bits) */
+ size_t dtype_offset; /* Datatype's offset (in bits) */
+ hsize_t scanline; /* Size of dataspace's fastest changing dimension */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Get the plist structure */
- if(NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE)))
+ if (NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
/* Get datatype */
- if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
+ if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
/* Get the filter's current parameters */
- if(H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SZIP, &flags, &cd_nelmts, cd_values, 0, NULL, NULL) < 0)
+ if (H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SZIP, &flags, &cd_nelmts, cd_values, 0, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get szip parameters")
/* Get datatype's size, for checking the "bits-per-pixel" */
- if((dtype_size = (8 * H5T_get_size(type))) == 0)
+ if ((dtype_size = (8 * H5T_get_size(type))) == 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size");
/* Get datatype's precision, in case is less than full bits */
- if((dtype_precision = H5T_get_precision(type)) == 0)
+ if ((dtype_precision = H5T_get_precision(type)) == 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype precision");
- if(dtype_precision < dtype_size) {
+ if (dtype_precision < dtype_size) {
dtype_offset = H5T_get_offset(type);
- if(dtype_offset != 0)
+ if (dtype_offset != 0)
dtype_precision = dtype_size;
} /* end if */
- if(dtype_precision > 24) {
- if(dtype_precision <= 32)
+ if (dtype_precision > 24) {
+ if (dtype_precision <= 32)
dtype_precision = 32;
- else if(dtype_precision <= 64)
+ else if (dtype_precision <= 64)
dtype_precision = 64;
} /* end if */
@@ -177,11 +173,11 @@ H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
cd_values[H5Z_SZIP_PARM_BPP] = dtype_precision;
/* Get dataspace */
- if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
+ if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
/* Get dimensions for dataspace */
- if((ndims = H5S_get_simple_extent_dims(ds, dims, NULL)) < 0)
+ if ((ndims = H5S_get_simple_extent_dims(ds, dims, NULL)) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get dataspace dimensions")
/* Set "local" parameter for this dataset's "pixels-per-scanline" */
@@ -194,19 +190,20 @@ H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
SZ_MAX_BLOCKS_PER_SCANLINE blocks per scanline */
/* Check the pixels per block against the 'scanline' size */
- if(scanline < cd_values[H5Z_SZIP_PARM_PPB]) {
- hssize_t npoints; /* Number of points in the dataspace */
+ if (scanline < cd_values[H5Z_SZIP_PARM_PPB]) {
+ hssize_t npoints; /* Number of points in the dataspace */
/* Get number of elements for the dataspace; use
total number of elements in the chunk to define the new 'scanline' size */
- if((npoints = H5S_GET_EXTENT_NPOINTS(ds)) < 0)
+ if ((npoints = H5S_GET_EXTENT_NPOINTS(ds)) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get number of points in the dataspace")
- if(npoints < cd_values[H5Z_SZIP_PARM_PPB])
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "pixels per block greater than total number of elements in the chunk")
+ if (npoints < cd_values[H5Z_SZIP_PARM_PPB])
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "pixels per block greater than total number of elements in the chunk")
scanline = MIN((cd_values[H5Z_SZIP_PARM_PPB] * SZ_MAX_BLOCKS_PER_SCANLINE), npoints);
}
else {
- if(scanline <= SZ_MAX_PIXELS_PER_SCANLINE)
+ if (scanline <= SZ_MAX_PIXELS_PER_SCANLINE)
scanline = MIN((cd_values[H5Z_SZIP_PARM_PPB] * SZ_MAX_BLOCKS_PER_SCANLINE), scanline);
else
scanline = cd_values[H5Z_SZIP_PARM_PPB] * SZ_MAX_BLOCKS_PER_SCANLINE;
@@ -216,18 +213,18 @@ H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
H5_CHECKED_ASSIGN(cd_values[H5Z_SZIP_PARM_PPS], unsigned, scanline, hsize_t);
/* Get datatype's endianness order */
- if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR)
+ if ((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order")
/* Set the correct endianness flag for szip */
/* (Note: this may not handle non-atomic datatypes well) */
- cd_values[H5Z_SZIP_PARM_MASK] &= ~(SZ_LSB_OPTION_MASK|SZ_MSB_OPTION_MASK);
- switch(dtype_order) {
- case H5T_ORDER_LE: /* Little-endian byte order */
+ cd_values[H5Z_SZIP_PARM_MASK] &= ~(SZ_LSB_OPTION_MASK | SZ_MSB_OPTION_MASK);
+ switch (dtype_order) {
+ case H5T_ORDER_LE: /* Little-endian byte order */
cd_values[H5Z_SZIP_PARM_MASK] |= SZ_LSB_OPTION_MASK;
break;
- case H5T_ORDER_BE: /* Big-endian byte order */
+ case H5T_ORDER_BE: /* Big-endian byte order */
cd_values[H5Z_SZIP_PARM_MASK] |= SZ_MSB_OPTION_MASK;
break;
@@ -240,14 +237,13 @@ H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
} /* end switch */
/* Modify the filter's parameters for this dataset */
- if(H5P_modify_filter(dcpl_plist, H5Z_FILTER_SZIP, flags, H5Z_SZIP_TOTAL_NPARMS, cd_values) < 0)
+ if (H5P_modify_filter(dcpl_plist, H5Z_FILTER_SZIP, flags, H5Z_SZIP_TOTAL_NPARMS, cd_values) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local szip parameters")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5Z__set_local_szip() */
-
/*-------------------------------------------------------------------------
* Function: H5Z__filter_szip
*
@@ -263,29 +259,29 @@ done:
*-------------------------------------------------------------------------
*/
static size_t
-H5Z__filter_szip(unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
- size_t nbytes, size_t *buf_size, void **buf)
+H5Z__filter_szip(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes,
+ size_t *buf_size, void **buf)
{
- size_t ret_value = 0; /* Return value */
- size_t size_out = 0; /* Size of output buffer */
- unsigned char *outbuf = NULL; /* Pointer to new output buffer */
- unsigned char *newbuf = NULL; /* Pointer to input buffer */
- SZ_com_t sz_param; /* szip parameter block */
+ size_t ret_value = 0; /* Return value */
+ size_t size_out = 0; /* Size of output buffer */
+ unsigned char *outbuf = NULL; /* Pointer to new output buffer */
+ unsigned char *newbuf = NULL; /* Pointer to input buffer */
+ SZ_com_t sz_param; /* szip parameter block */
FUNC_ENTER_STATIC
/* Sanity check to make certain that we haven't drifted out of date with
* the mask options from the szlib.h header */
- HDassert(H5_SZIP_ALLOW_K13_OPTION_MASK==SZ_ALLOW_K13_OPTION_MASK);
- HDassert(H5_SZIP_CHIP_OPTION_MASK==SZ_CHIP_OPTION_MASK);
- HDassert(H5_SZIP_EC_OPTION_MASK==SZ_EC_OPTION_MASK);
- HDassert(H5_SZIP_LSB_OPTION_MASK==SZ_LSB_OPTION_MASK);
- HDassert(H5_SZIP_MSB_OPTION_MASK==SZ_MSB_OPTION_MASK);
- HDassert(H5_SZIP_NN_OPTION_MASK==SZ_NN_OPTION_MASK);
- HDassert(H5_SZIP_RAW_OPTION_MASK==SZ_RAW_OPTION_MASK);
+ HDassert(H5_SZIP_ALLOW_K13_OPTION_MASK == SZ_ALLOW_K13_OPTION_MASK);
+ HDassert(H5_SZIP_CHIP_OPTION_MASK == SZ_CHIP_OPTION_MASK);
+ HDassert(H5_SZIP_EC_OPTION_MASK == SZ_EC_OPTION_MASK);
+ HDassert(H5_SZIP_LSB_OPTION_MASK == SZ_LSB_OPTION_MASK);
+ HDassert(H5_SZIP_MSB_OPTION_MASK == SZ_MSB_OPTION_MASK);
+ HDassert(H5_SZIP_NN_OPTION_MASK == SZ_NN_OPTION_MASK);
+ HDassert(H5_SZIP_RAW_OPTION_MASK == SZ_RAW_OPTION_MASK);
/* Check arguments */
- if (cd_nelmts!=4)
+ if (cd_nelmts != 4)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid number of filter parameters")
/* Copy the filter parameters into the szip parameter block */
@@ -296,66 +292,65 @@ H5Z__filter_szip(unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
/* Input; uncompress */
if (flags & H5Z_FLAG_REVERSE) {
- uint32_t stored_nalloc; /* Number of bytes the compressed block will expand into */
- size_t nalloc; /* Number of bytes the compressed block will expand into */
+ uint32_t stored_nalloc; /* Number of bytes the compressed block will expand into */
+ size_t nalloc; /* Number of bytes the compressed block will expand into */
/* Get the size of the uncompressed buffer */
newbuf = (unsigned char *)(*buf);
- UINT32DECODE(newbuf,stored_nalloc);
+ UINT32DECODE(newbuf, stored_nalloc);
H5_CHECKED_ASSIGN(nalloc, size_t, stored_nalloc, uint32_t);
/* Allocate space for the uncompressed buffer */
- if(NULL == (outbuf = (unsigned char *)H5MM_malloc(nalloc)))
+ if (NULL == (outbuf = (unsigned char *)H5MM_malloc(nalloc)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for szip decompression")
/* Decompress the buffer */
- size_out=nalloc;
- if(SZ_BufftoBuffDecompress(outbuf, &size_out, newbuf, nbytes-4, &sz_param) != SZ_OK)
+ size_out = nalloc;
+ if (SZ_BufftoBuffDecompress(outbuf, &size_out, newbuf, nbytes - 4, &sz_param) != SZ_OK)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "szip_filter: decompression failed")
- HDassert(size_out==nalloc);
+ HDassert(size_out == nalloc);
/* Free the input buffer */
H5MM_xfree(*buf);
/* Set return values */
- *buf = outbuf;
- outbuf = NULL;
+ *buf = outbuf;
+ outbuf = NULL;
*buf_size = nalloc;
ret_value = size_out;
}
/* Output; compress */
else {
- unsigned char *dst = NULL; /* Temporary pointer to new output buffer */
+ unsigned char *dst = NULL; /* Temporary pointer to new output buffer */
/* Allocate space for the compressed buffer & header (assume data won't get bigger) */
- if(NULL == (dst=outbuf = (unsigned char *)H5MM_malloc(nbytes+4)))
+ if (NULL == (dst = outbuf = (unsigned char *)H5MM_malloc(nbytes + 4)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate szip destination buffer")
/* Encode the uncompressed length */
- H5_CHECK_OVERFLOW(nbytes,size_t,uint32_t);
- UINT32ENCODE(dst,nbytes);
+ H5_CHECK_OVERFLOW(nbytes, size_t, uint32_t);
+ UINT32ENCODE(dst, nbytes);
/* Compress the buffer */
size_out = nbytes;
- if(SZ_OK!= SZ_BufftoBuffCompress(dst, &size_out, *buf, nbytes, &sz_param))
+ if (SZ_OK != SZ_BufftoBuffCompress(dst, &size_out, *buf, nbytes, &sz_param))
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow")
- HDassert(size_out<=nbytes);
+ HDassert(size_out <= nbytes);
/* Free the input buffer */
H5MM_xfree(*buf);
/* Set return values */
- *buf = outbuf;
- outbuf = NULL;
- *buf_size = nbytes+4;
- ret_value = size_out+4;
+ *buf = outbuf;
+ outbuf = NULL;
+ *buf_size = nbytes + 4;
+ ret_value = size_out + 4;
}
done:
- if(outbuf)
+ if (outbuf)
H5MM_xfree(outbuf);
FUNC_LEAVE_NOAPI(ret_value)
}
#endif /* H5_HAVE_FILTER_SZIP */
-