diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-07-30 03:34:17 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-07-30 03:34:17 (GMT) |
commit | 2f28978053f06739f65b1b2d5f4f5435392c07d0 (patch) | |
tree | fc6abd6d0e7c88b5413774c6cf92aea582ae23df | |
parent | fab82e54da0648d6cbf7b770265819b04e70da1b (diff) | |
download | hdf5-2f28978053f06739f65b1b2d5f4f5435392c07d0.zip hdf5-2f28978053f06739f65b1b2d5f4f5435392c07d0.tar.gz hdf5-2f28978053f06739f65b1b2d5f4f5435392c07d0.tar.bz2 |
[svn-r8970] Purpose:
Bug fix.
Description:
Address two problems:
- The computation of the scanline in the szip filter was being
performed in the "can apply" callback routine instead of the
"set local" routine.
- The routine which allocated all the chunks for an entire dataset
(which is invoked when the allocation time is early or late,
rather than incremental) wasn't recording a failed filter in
the information for the chunk, causing the library to believe
that the chunk had the filter applied when it really hadn't.
Solution:
- Move the scanline computation to the "set local" callback.
- Record the filter mask with each chunk created when allocating them.
Platforms tested:
FreeBSD 4.10 (sleipnir) w/szip
Too obscure to require h5committest
-rw-r--r-- | release_docs/RELEASE.txt | 3 | ||||
-rw-r--r-- | src/H5Distore.c | 4 | ||||
-rw-r--r-- | src/H5Zszip.c | 81 | ||||
-rw-r--r-- | test/tmisc.c | 12 |
4 files changed, 45 insertions, 55 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 6fb2578..81991b1 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -102,6 +102,9 @@ Bug Fixes since HDF5-1.6.2 release Library ------- + - Fixed obscure bug where a filter which failed during chunk allocation + could allow library to write uncompressed data to disk but think + the data was compressed. QAK - 2004/07/29 - Fixed bug where I/O to an extendible chunked dataset with zero-sized dimensions would cause library to fail an assertion. QAK - 2004/07/27 diff --git a/src/H5Distore.c b/src/H5Distore.c index 73b7dc7..a1c19c6 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -2336,6 +2336,7 @@ H5D_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, { hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; /* Offset of current chunk */ hsize_t chunk_size; /* Size of chunk in bytes */ + unsigned filter_mask=0; /* Filter mask for chunks that have them */ H5O_pline_t pline; /* I/O pipeline information */ H5O_fill_t fill; /* Fill value information */ H5D_fill_time_t fill_time; /* When to write fill values */ @@ -2457,7 +2458,6 @@ H5D_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, /* Check if there are filters which need to be applied to the chunk */ if (pline.nused>0) { - unsigned filter_mask=0; size_t buf_size=(size_t)chunk_size; size_t nbytes=(size_t)chunk_size; @@ -2496,7 +2496,7 @@ H5D_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, if(!chunk_exists) { /* Initialize the chunk information */ udata.mesg = &dset->layout; - udata.key.filter_mask = 0; + udata.key.filter_mask = filter_mask; udata.addr = HADDR_UNDEF; H5_CHECK_OVERFLOW(chunk_size,hsize_t,size_t); udata.key.nbytes = (size_t)chunk_size; diff --git a/src/H5Zszip.c b/src/H5Zszip.c index 68fcc29..e8f7c07 100644 --- a/src/H5Zszip.c +++ b/src/H5Zszip.c @@ -90,25 +90,14 @@ const 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 */ 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 */ herr_t ret_value=TRUE; /* Return value */ FUNC_ENTER_NOAPI(H5Z_can_apply_szip, FAIL); - /* Get the filter's current parameters */ - if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SZIP,&flags,&cd_nelmts, cd_values,0,NULL)<0) - 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 */ @@ -124,37 +113,6 @@ H5Z_can_apply_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) 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' size if it is smaller than number of pixels per block or - if it is bigger than maximum pixels per scanline, or number blocks per scanline - is bigger than maximum value */ - - /* Check the pixels per block against the 'scanline' size */ - if(scanline<cd_values[H5Z_SZIP_PARM_PPB]) { - - /* Get number of elements in 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); } /* end H5Z_can_apply_szip() */ @@ -184,6 +142,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); @@ -192,18 +151,44 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SZIP,&flags,&cd_nelmts, cd_values,0,NULL)<0) 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) diff --git a/test/tmisc.c b/test/tmisc.c index 48137df..1e5f270 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -240,8 +240,8 @@ unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset #define MISC21_SPACE_RANK 2 #define MISC21_SPACE_DIM0 7639 #define MISC21_SPACE_DIM1 6308 -#define MISC21_CHUNK_DIM0 1024 -#define MISC21_CHUNK_DIM1 1024 +#define MISC21_CHUNK_DIM0 2048 +#define MISC21_CHUNK_DIM1 2048 /**************************************************************** ** @@ -3384,6 +3384,7 @@ test_misc20(void) ** don't exactly match the dataspace. ** ****************************************************************/ +#ifdef H5_HAVE_FILTER_SZIP static void test_misc21(void) { @@ -3411,7 +3412,7 @@ test_misc21(void) /* Set custom DCPL properties */ ret = H5Pset_chunk (dcpl, MISC21_SPACE_RANK, chunk_size); CHECK(ret, FAIL, "H5Pset_chunk"); - ret = H5Pset_deflate (dcpl, 6); + ret = H5Pset_szip (dcpl, H5_SZIP_NN_OPTION_MASK, 8); CHECK(ret, FAIL, "H5Pset_deflate"); ret = H5Pset_alloc_time (dcpl, H5D_ALLOC_TIME_LATE); CHECK(ret, FAIL, "H5Pset_alloc_time"); @@ -3440,6 +3441,7 @@ test_misc21(void) HDfree(buf); } /* end test_misc21() */ +#endif /* H5_HAVE_FILTER_SZIP */ /**************************************************************** ** @@ -3472,9 +3474,9 @@ test_misc(void) test_misc18(); /* Test new object header information in H5G_stat_t struct */ test_misc19(); /* Test incrementing & decrementing ref count on IDs */ test_misc20(); /* Test problems with truncated dimensions in version 2 of storage layout message */ -#ifdef H5_HAVE_FILTER_DEFLATE +#ifdef H5_HAVE_FILTER_SZIP test_misc21(); /* Test that "late" allocation time is treated the same as "incremental", for chunked datasets w/a filters */ -#endif /* H5_HAVE_FILTER_DEFLATE */ +#endif /* H5_HAVE_FILTER_SZIP */ } /* test_misc() */ |