summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5Zszip.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/H5Zszip.c b/src/H5Zszip.c
index fdd7f48..2133311 100644
--- a/src/H5Zszip.c
+++ b/src/H5Zszip.c
@@ -148,6 +148,9 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
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 */
+ int 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 */
@@ -161,9 +164,30 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
#endif
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*H5Tget_size(type_id)))==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=H5Tget_precision(type_id))==0)
+ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype precision");
+
+ if(dtype_precision<dtype_size) {
+ dtype_offset=H5Tget_offset(type_id);
+ if(dtype_offset != 0) {
+ dtype_precision=dtype_size;
+ }
+ }
+ if (dtype_precision>24) {
+ if (dtype_precision <= 32) {
+ dtype_precision=32;
+ } else if ( dtype_precision <= 64) {
+ dtype_precision=64;
+ }
+ }
+
/* Set "local" parameter for this dataset's "bits-per-pixel" */
- if((cd_values[H5Z_SZIP_PARM_BPP]=(8*sizeof(unsigned char)*H5Tget_size(type_id)))==0)
- HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size")
+ cd_values[H5Z_SZIP_PARM_BPP]=dtype_precision;
/* Get dimensions for dataspace */
if ((ndims=H5Sget_simple_extent_dims(space_id, dims, NULL))<0)