diff options
-rw-r--r-- | src/H5Zszip.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/H5Zszip.c b/src/H5Zszip.c index 5eafec1..0ea7423 100644 --- a/src/H5Zszip.c +++ b/src/H5Zszip.c @@ -83,7 +83,13 @@ H5Z_class_t H5Z_SZIP[1] = {{ * Programmer: Quincey Koziol * Monday, April 7, 2003 * - * Modifications: + * Modifications: Used new logic to set the size of the scanline parameter. + * Now SZIP compression can be applied to the chunk + * of any shape and size with only one restriction: the number + * of elements in the chunk has to be not less than number + * of elements (pixels) in the block (cd_values[H5Z_SZIP_PARM_PPB] + * parameter). + * Elena Pourmal, July 20, 2004 * *------------------------------------------------------------------------- */ @@ -94,7 +100,8 @@ H5Z_can_apply_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) 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 */ + 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 */ @@ -126,7 +133,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") @@ -135,18 +141,28 @@ H5Z_can_apply_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) /* (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 */ + + /* 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); + goto done; - /* Range check the pixels per block against the 'scanline' size */ - if(scanline<cd_values[H5Z_SZIP_PARM_PPB]) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "pixels per block greater than scanline"); + } - /* Range check the scanline's size */ + /* Check the scanline's size against the maximum value and adjust 'scanline' + size if necessary */ if(scanline > SZ_MAX_PIXELS_PER_SCANLINE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid scanline size") - - /* Range check the scanline's number of blocks */ - if((scanline/cd_values[H5Z_SZIP_PARM_PPB]) > SZ_MAX_BLOCKS_PER_SCANLINE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid number of blocks per scanline") + scanline = cd_values[H5Z_SZIP_PARM_PPB] * SZ_MAX_BLOCKS_PER_SCANLINE; done: FUNC_LEAVE_NOAPI(ret_value) |