summaryrefslogtreecommitdiffstats
path: root/src/H5Zszip.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Zszip.c')
-rw-r--r--src/H5Zszip.c84
1 files changed, 33 insertions, 51 deletions
diff --git a/src/H5Zszip.c b/src/H5Zszip.c
index 37c5316..fdd7f48 100644
--- a/src/H5Zszip.c
+++ b/src/H5Zszip.c
@@ -96,29 +96,14 @@ H5Z_class_t H5Z_SZIP[1] = {{
static herr_t
H5Z_can_apply_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
{
- 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 */
- hssize_t npoints; /* Number of points in the dataspace */
unsigned dtype_size; /* Datatype's size (in bits) */
H5T_order_t dtype_order; /* Datatype's endianness order */
- hsize_t scanline; /* Size of dataspace's fastest changing dimension */
herr_t ret_value=TRUE; /* Return value */
FUNC_ENTER_NOAPI(H5Z_can_apply_szip, FAIL)
- /* Get the filter's current parameters */
-#ifdef H5_WANT_H5_V1_6_COMPAT
- if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SZIP,&flags,&cd_nelmts, cd_values,0,NULL)<0)
-#else
- if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SZIP,&flags,&cd_nelmts, cd_values,0,NULL,NULL)<0)
-#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=(sizeof(unsigned char)*H5Tget_size(type_id)))==0)
+ if((dtype_size=(8*H5Tget_size(type_id)))==0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size")
/* Range check datatype's size */
@@ -133,36 +118,6 @@ H5Z_can_apply_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
/* (Note: this may not handle non-atomic datatypes well) */
if(dtype_order != H5T_ORDER_LE && dtype_order != H5T_ORDER_BE)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype endianness order")
- /* Get dimensions for dataspace */
- if ((ndims=H5Sget_simple_extent_dims(space_id, dims, NULL))<0)
- HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get dataspace dimensions")
-
- /* Get "local" parameter for this dataset's "pixels-per-scanline" */
- /* (Use the chunk's fastest changing dimension size) */
- assert(ndims>0);
- scanline=dims[ndims-1];
-
- /* Adjust scanline if it is smaller than number of pixels per block or
- if it is bigger than maximum pixels per scanline, or there are more than
- 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]) {
-
- /* Get number of elements for the dataspace; use
- total number of elements in the chunk to define the new 'scanline' size */
- if ((npoints=H5Sget_simple_extent_npoints(space_id))<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, FALSE, "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);
- HGOTO_DONE(TRUE);
-
- }
- 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;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -193,6 +148,7 @@ 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 */
+ hsize_t scanline; /* Size of dataspace's fastest changing dimension */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5Z_set_local_szip, FAIL)
@@ -205,18 +161,44 @@ 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 dimensions for dataspace */
- if ((ndims=H5Sget_simple_extent_dims(space_id, dims, NULL))<0)
- HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get dataspace dimensions")
-
/* 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")
+ /* Get dimensions for dataspace */
+ if ((ndims=H5Sget_simple_extent_dims(space_id, 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" */
/* (Use the chunk's fastest changing dimension size) */
assert(ndims>0);
- H5_ASSIGN_OVERFLOW(cd_values[H5Z_SZIP_PARM_PPS],dims[ndims-1],hsize_t,unsigned);
+ scanline=dims[ndims-1];
+
+ /* Adjust scanline if it is smaller than number of pixels per block or
+ if it is bigger than maximum pixels per scanline, or there are more than
+ 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 */
+
+ /* Get number of elements for the dataspace; use
+ total number of elements in the chunk to define the new 'scanline' size */
+ if ((npoints=H5Sget_simple_extent_npoints(space_id))<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, FALSE, "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)
+ 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;
+ } /* end else */
+
+ /* Assign the final value to the scanline */
+ H5_ASSIGN_OVERFLOW(cd_values[H5Z_SZIP_PARM_PPS],scanline,hsize_t,unsigned);
/* Get datatype's endianness order */
if((dtype_order=H5Tget_order(type_id))==H5T_ORDER_ERROR)