summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-05-19 19:21:35 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-05-19 19:21:35 (GMT)
commit2f8c23b90390201c1f694d65b854163251dd1452 (patch)
treed17a4a457646bbe5cf4a1c85217a059859fe1e65 /src
parentd41a6634fc958fdb306dbf98be825cb5de81a409 (diff)
downloadhdf5-2f8c23b90390201c1f694d65b854163251dd1452.zip
hdf5-2f8c23b90390201c1f694d65b854163251dd1452.tar.gz
hdf5-2f8c23b90390201c1f694d65b854163251dd1452.tar.bz2
[svn-r6900] Purpose:
Bug fix Description: Fix three (!) bugs in szip filter: - we were using bytes per pixel instead of bits per pixel - we were using the size of the slowest changing dimension instead of the fastest changing dimension to compute the blocks per scanline parameter - we swapped two parameters when setting up szip_options block. Solution: Addressed bugs above. Platforms tested: FreeBSD 4.8 (sleipnir) h5committest not needed
Diffstat (limited to 'src')
-rw-r--r--src/H5Zszip.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/H5Zszip.c b/src/H5Zszip.c
index df27a2f..aa83469 100644
--- a/src/H5Zszip.c
+++ b/src/H5Zszip.c
@@ -88,6 +88,7 @@ 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 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 */
@@ -121,11 +122,12 @@ H5Z_can_apply_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype endianness order");
/* Get dimensions for dataspace */
- if (H5Sget_simple_extent_dims(space_id, dims, NULL)<0)
+ 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" */
- scanline=dims[0];
+ /* (Use the chunk's fastest changing dimension size) */
+ scanline=dims[ndims-1];
/* Range check the scanline's size */
if(scanline > SZ_MAX_PIXELS_PER_SCANLINE)
@@ -162,6 +164,7 @@ H5Z_set_local_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 */
H5T_order_t dtype_order; /* Datatype's endianness order */
herr_t ret_value=SUCCEED; /* Return value */
@@ -176,15 +179,16 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
HGOTO_ERROR(H5E_PLINE, H5E_BADVALUE, FAIL, "incorrect # of szip parameters");
/* Get dimensions for dataspace */
- if (H5Sget_simple_extent_dims(space_id, dims, NULL)<0)
+ 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]=(sizeof(unsigned char)*H5Tget_size(type_id)))==0)
+ 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");
/* Set "local" parameter for this dataset's "pixels-per-scanline" */
- cd_values[H5Z_SZIP_PARM_PPS]=dims[0];
+ /* (Use the chunk's fastest changing dimension size) */
+ cd_values[H5Z_SZIP_PARM_PPS]=dims[ndims-1];
/* Get datatype's endianness order */
if((dtype_order=H5Tget_order(type_id))==H5T_ORDER_ERROR)
@@ -254,10 +258,10 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid deflate aggression level");
/* Copy the filter parameters into the szip parameter block */
- sz_param.options_mask = cd_values[0];
- sz_param.bits_per_pixel = cd_values[1];
- sz_param.pixels_per_block = cd_values[2];
- sz_param.pixels_per_scanline = cd_values[3];
+ sz_param.options_mask = cd_values[H5Z_SZIP_PARM_MASK];
+ sz_param.bits_per_pixel = cd_values[H5Z_SZIP_PARM_BPP];
+ sz_param.pixels_per_block = cd_values[H5Z_SZIP_PARM_PPB];
+ sz_param.pixels_per_scanline = cd_values[H5Z_SZIP_PARM_PPS];
/* Input; uncompress */
if (flags & H5Z_FLAG_REVERSE) {