From 2491ee240d8d63dda5216cfef6d8a484cac74868 Mon Sep 17 00:00:00 2001 From: "Robert E. McGrath" Date: Wed, 4 Aug 2004 10:59:02 -0500 Subject: [svn-r9009] Purpose: Update Szip to accept 'n-bit' data Description: See earlier checkins. Solution: Platforms tested: Misc. update: --- src/H5Zszip.c | 28 ++++++++++++++++++++++++++-- 1 file 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_precision24) { + 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) -- cgit v0.12