summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Laird <jlaird@hdfgroup.org>2004-07-01 17:38:04 (GMT)
committerJames Laird <jlaird@hdfgroup.org>2004-07-01 17:38:04 (GMT)
commiteab58732d86e9219fa9f41f9ab2e30fae94e4a7d (patch)
tree333b5f2c50c267c14611e042724a7f28d5156ab7 /src
parent3f500747fa0f4379e8e03b82f6d679628d55a8c3 (diff)
downloadhdf5-eab58732d86e9219fa9f41f9ab2e30fae94e4a7d.zip
hdf5-eab58732d86e9219fa9f41f9ab2e30fae94e4a7d.tar.gz
hdf5-eab58732d86e9219fa9f41f9ab2e30fae94e4a7d.tar.bz2
[svn-r8781]
Purpose: HDF5 now supports SZIP with no encoder. Description: SZIP can be configured to have both encoder and decoder or just to have the decoder. HDF5 can now query the configuration of any filter, and will throw errors if users try to write using a filter with encoding disabled. Solution: Added H5Zget_filter_info function, changed API for H5Pget_filter and H5P_get_filter_by_id. See SZIP RFC. Platforms tested: Copper (fortran, C++, parallel), Sleipnir (C++), Arabica (fortran, C++), Verbena (fortran, C++) Misc. update:
Diffstat (limited to 'src')
-rw-r--r--src/H5D.c67
-rw-r--r--src/H5Dio.c23
-rw-r--r--src/H5Dpkg.h1
-rw-r--r--src/H5Edefin.h2
-rw-r--r--src/H5Einit.h10
-rw-r--r--src/H5Epubgen.h4
-rw-r--r--src/H5Eterm.h2
-rw-r--r--src/H5MPprivate.h1
-rw-r--r--src/H5P.c1
-rw-r--r--src/H5Pdcpl.c74
-rw-r--r--src/H5Ppublic.h14
-rw-r--r--src/H5Z.c62
-rw-r--r--src/H5Zdeflate.c3
-rw-r--r--src/H5Zfletcher32.c3
-rw-r--r--src/H5Zpkg.h3
-rw-r--r--src/H5Zpublic.h14
-rw-r--r--src/H5Zshuffle.c7
-rw-r--r--src/H5Zszip.c22
-rw-r--r--src/H5config.h.in3
-rw-r--r--src/H5err.txt1
20 files changed, 287 insertions, 30 deletions
diff --git a/src/H5D.c b/src/H5D.c
index 7d1652d..5aa1076 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -2017,6 +2017,10 @@ done:
* whether we're working with an external file or not. Between the
* two, there is a conditional call to allocate space which isn't
* part of updating the cache.
+ *
+ * Nat Furrer and James Laird
+ * June 7, 2004
+ * Added checked_filters flag
*
*-------------------------------------------------------------------------
*/
@@ -2065,6 +2069,12 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space
if(NULL == (new_dset = H5D_new(dcpl_id,TRUE,has_vl_type)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ /*
+ * Set the dataset's checked_filters flag to enable writing.
+ * Make sure that H5Z_can_apply is called at the beginning of this function!
+ */
+ new_dset->checked_filters = TRUE;
+
/* Make the "set local" filter callbacks for this dataset */
if(H5Z_set_local(new_dset->dcpl_id,type_id)<0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set local filter parameters")
@@ -2209,7 +2219,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space
assert((unsigned)(new_dset->layout.u.chunk.ndims) <= NELMTS(new_dset->layout.u.chunk.dim));
new_dset->layout.u.chunk.addr = HADDR_UNDEF; /* Initialize to no address */
-
+
/*
* Chunked storage allows any type of data space extension, so we
* don't even bother checking.
@@ -2267,7 +2277,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "compact dataset size is bigger than header message maximum size")
} /* end case */
break;
-
+
default:
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet")
} /* end switch */
@@ -2288,6 +2298,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space
if (H5G_insert(loc, name, &new_dset->ent, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to name dataset")
+
/* Success */
ret_value = new_dset;
@@ -2810,10 +2821,14 @@ done:
*
* Modifications:
*
- * Raymond Lu
- * Tuesday, October 2, 2001
- * Changed the way to retrieve property for generic property
- * list.
+ * Raymond Lu
+ * Tuesday, October 2, 2001
+ * Changed the way to retrieve property for generic property
+ * list.
+ *
+ * Nat Furrer and James Laird
+ * June 7, 2004
+ * Added check for filter encode capability
*
*-------------------------------------------------------------------------
*/
@@ -2822,6 +2837,8 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id)
{
int changed; /* Flag to indicate that the dataspace was successfully extended */
H5S_t *space = NULL; /* Dataset's dataspace */
+ H5D_fill_value_t fill_status;
+ H5D_fill_time_t fill_time;
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5D_extend, FAIL)
@@ -2830,6 +2847,44 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id)
assert (dataset);
assert (size);
+ /* Check if the filters in the DCPL will need to encode, and if so, can they?
+ * Filters need encoding if fill value is defined and a fill policy is set that requires
+ * writing on an extend.
+ */
+ if(! dataset->checked_filters)
+ {
+
+ if(H5P_is_fill_value_defined(&(dataset->fill), &fill_status) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill value from dataset.");
+
+ if(fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED)
+ {
+ if( H5Pget_fill_time(dataset->dcpl_id, &fill_time) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill time from dataset.");
+
+ if(fill_time == H5D_FILL_TIME_ALLOC ||
+ (fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_USER_DEFINED) )
+ {
+ /* Filters must have encoding enabled. Ensure that all filters can be applied */
+ hid_t type_id;
+
+ type_id = H5I_register(H5I_DATATYPE, dataset->type);
+ if(type_id < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data type")
+
+ if(H5Z_can_apply(dataset->dcpl_id, type_id) <0)
+ {
+ H5I_remove(type_id);
+ HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters")
+ }
+
+ if(H5I_remove(type_id) == NULL)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to release data type id")
+ dataset->checked_filters = TRUE;
+ }
+ }
+ }
+
/*
* NOTE: Restrictions on extensions were checked when the dataset was
* created. All extensions are allowed here since none should be
diff --git a/src/H5Dio.c b/src/H5Dio.c
index 9cecda7..9585cd8 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -836,6 +836,8 @@ done:
* Removed the must_convert parameter and move preconditions to
* H5S_<foo>_opt_possible() routine
*
+ * Nat Furrer and James Laird, 2004/6/7
+ * Added check for filter encode capability
*-------------------------------------------------------------------------
*/
static herr_t
@@ -863,6 +865,27 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
assert(mem_type);
assert(buf);
+ /* All filters in the DCPL must have encoding enabled. */
+ if(! dataset->checked_filters)
+ {
+ hid_t type_id;
+
+ type_id = H5I_register(H5I_DATATYPE, dataset->type);
+ if(type_id < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data type")
+
+ if(H5Z_can_apply(dataset->dcpl_id, type_id) <0)
+ {
+ H5I_remove(type_id);
+ HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters")
+ }
+
+ if(H5I_remove(type_id) == NULL)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to release data type id")
+
+ dataset->checked_filters = TRUE;
+ }
+
/* If MPI based VFD is used, no VL datatype support yet. */
/* This is because they use the global heap in the file and we don't */
/* support parallel access of that yet */
diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h
index b72a13d..18af011 100644
--- a/src/H5Dpkg.h
+++ b/src/H5Dpkg.h
@@ -83,6 +83,7 @@ struct H5D_t {
hid_t dcpl_id; /* dataset creation property id */
H5D_dcpl_cache_t dcpl_cache; /* Cached DCPL values */
H5O_layout_t layout; /* data layout */
+ hbool_t checked_filters;/* TRUE if dataset passes can_apply check */
/* Cache some frequently accessed values from the DCPL */
H5O_efl_t efl; /* External file list information */
diff --git a/src/H5Edefin.h b/src/H5Edefin.h
index da79308..2d70e0d 100644
--- a/src/H5Edefin.h
+++ b/src/H5Edefin.h
@@ -90,6 +90,8 @@ hid_t H5E_NOFILTER_g = FAIL; /* Requested filter is not available */
hid_t H5E_CALLBACK_g = FAIL; /* Callback failed */
hid_t H5E_CANAPPLY_g = FAIL; /* Error from filter 'can apply' callback */
hid_t H5E_SETLOCAL_g = FAIL; /* Error from filter 'set local' callback */
+hid_t H5E_NOENCODER_g = FAIL; /* Filter present but encoder not enabled */
+hid_t H5E_NODECODER_g = FAIL; /* Filter present but decoder not enabled */
/* Datatype conversion errors */
hid_t H5E_CANTCONVERT_g = FAIL; /* Can't convert datatypes */
diff --git a/src/H5Einit.h b/src/H5Einit.h
index f35e11f..92b7158 100644
--- a/src/H5Einit.h
+++ b/src/H5Einit.h
@@ -320,6 +320,16 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "Error from filter 'set local' callback
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_SETLOCAL_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
+assert(H5E_NOENCODER_g==(-1));
+if((msg = H5E_create_msg(cls, H5E_MINOR, "Error from filter 'no encoder' callback"))==NULL)
+ HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
+if((H5E_NOENCODER_g = H5I_register(H5I_ERROR_MSG, msg))<0)
+ HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
+assert(H5E_NODECODER_g==(-1));
+if((msg = H5E_create_msg(cls, H5E_MINOR, "Error from filter 'no decoder' callback"))==NULL)
+ HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
+if((H5E_NODECODER_g = H5I_register(H5I_ERROR_MSG, msg))<0)
+ HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
/* Datatype conversion errors */
assert(H5E_CANTCONVERT_g==(-1));
diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h
index 86baeb6..958e91c 100644
--- a/src/H5Epubgen.h
+++ b/src/H5Epubgen.h
@@ -147,10 +147,14 @@ H5_DLLVAR hid_t H5E_CANTALLOC_g; /* Can't allocate from file */
#define H5E_CALLBACK (H5OPEN H5E_CALLBACK_g)
#define H5E_CANAPPLY (H5OPEN H5E_CANAPPLY_g)
#define H5E_SETLOCAL (H5OPEN H5E_SETLOCAL_g)
+#define H5E_NOENCODER (H5OPEN H5E_NOENCODER_g)
+#define H5E_NODECODER (H5OPEN H5E_NODECODER_g)
H5_DLLVAR hid_t H5E_NOFILTER_g; /* Requested filter is not available */
H5_DLLVAR hid_t H5E_CALLBACK_g; /* Callback failed */
H5_DLLVAR hid_t H5E_CANAPPLY_g; /* Error from filter 'can apply' callback */
H5_DLLVAR hid_t H5E_SETLOCAL_g; /* Error from filter 'set local' callback */
+H5_DLLVAR hid_t H5E_NOENCODER_g; /* Filter present, but encoding disabled */
+H5_DLLVAR hid_t H5E_NODECODER_g; /* Filter present, but decoding disabled */
/* Datatype conversion errors */
#define H5E_CANTCONVERT (H5OPEN H5E_CANTCONVERT_g)
diff --git a/src/H5Eterm.h b/src/H5Eterm.h
index 1789039..2acd75d 100644
--- a/src/H5Eterm.h
+++ b/src/H5Eterm.h
@@ -92,6 +92,8 @@ H5E_NOFILTER_g=
H5E_CALLBACK_g=
H5E_CANAPPLY_g=
H5E_SETLOCAL_g=
+H5E_NOENCODER_g=
+H5E_NODECODER_g=
/* Datatype conversion errors */
H5E_CANTCONVERT_g=
diff --git a/src/H5MPprivate.h b/src/H5MPprivate.h
index 867507e..2062f61 100644
--- a/src/H5MPprivate.h
+++ b/src/H5MPprivate.h
@@ -415,6 +415,7 @@
#define color_H5Zregister "red"
#define color_H5Zfilter_avail "red"
#define color_H5Zunregister "red"
+#define color_H5Zget_filter_info "red"
#else
#define MPE_LOG_VARS(func_name) /* void */
diff --git a/src/H5P.c b/src/H5P.c
index 7d608c3..7e6be49 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -5735,4 +5735,3 @@ H5Pclose_class(hid_t cls_id)
done:
FUNC_LEAVE_API(ret_value);
} /* H5Pclose_class() */
-
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c
index fb5f9a9..48abd21 100644
--- a/src/H5Pdcpl.c
+++ b/src/H5Pdcpl.c
@@ -501,6 +501,8 @@ done:
* failed; the filter will not participate in the pipeline
* during an H5Dread() of the chunk. If this bit is clear and
* the filter fails then the entire I/O operation fails.
+ * If this bit is set but encoding is disabled for a filter,
+ * attempting to write will generate an error.
*
* Note: This function currently supports only the permanent filter
* pipeline. That is, PLIST_ID must be a dataset creation
@@ -577,6 +579,8 @@ done:
* failed; the filter will not participate in the pipeline
* during an H5Dread() of the chunk. If this bit is clear and
* the filter fails then the entire I/O operation fails.
+ * If this bit is set but encoding is disabled for a filter,
+ * attempting to write will generate an error.
*
* Note: This function currently supports only the permanent filter
* pipeline. That is, PLIST_ID must be a dataset creation
@@ -695,10 +699,11 @@ done:
* dataset creation or transfer property list. On input,
* CD_NELMTS indicates the number of entries in the CD_VALUES
* array allocated by the caller while on exit it contains the
- * number of values defined by the filter. The IDX should be a
- * value between zero and N-1 as described for H5Pget_nfilters()
- * and the function will return failure if the filter number is
- * out or range.
+ * number of values defined by the filter. FILTER_CONFIG is a bit
+ * field contaning encode/decode flags from H5Zpublic.h. The IDX
+ * should be a value between zero and N-1 as described for
+ * H5Pget_nfilters() and the function will return failure if the
+ * filter number is out of range.
*
* Return: Success: Filter identification number.
*
@@ -712,7 +717,11 @@ done:
* Raymond Lu
* Tuesday, October 2, 2001
* Changed the way to check paramter and set property for
- * generic property list.
+ * generic property list.
+ *
+ * James Laird and Nat Furrer
+ * Tuesday, June 15, 2004
+ * Function now retrieves filter_config flags.
*
*-------------------------------------------------------------------------
*/
@@ -725,7 +734,8 @@ H5Pget_filter(hid_t plist_id, int idx, unsigned int *flags/*out*/,
H5Z_filter_t
H5Pget_filter(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/,
size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/,
- size_t namelen, char name[]/*out*/)
+ size_t namelen, char name[]/*out*/,
+ unsigned int *filter_config /*out*/)
#endif /* H5_WANT_H5_V1_6_COMPAT */
{
H5O_pline_t pline; /* Filter pipeline */
@@ -808,7 +818,13 @@ H5Pget_filter(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/,
else
name[0] = '\0';
}
-
+
+#ifndef H5_WANT_H5_V1_6_COMPAT
+ /* Get filter configuration, assume filter ID has already been checked */
+ if(filter_config != NULL)
+ H5Zget_filter_info(filter->id, filter_config);
+#endif
+
/* Set return value */
ret_value=filter->id;
@@ -821,14 +837,15 @@ done:
* Function: H5Pget_filter_by_id
*
* Purpose: This is an additional query counterpart of H5Pset_filter() and
- * returns information about a particular filter in a permanent
+ * returns information about a particular filter in a permanent
* or transient pipeline depending on whether PLIST_ID is a
* dataset creation or transfer property list. On input,
* CD_NELMTS indicates the number of entries in the CD_VALUES
* array allocated by the caller while on exit it contains the
- * number of values defined by the filter. The ID should be the
- * filter ID to retrieve the parameters for. If the filter is not
- * set for the property list, an error will be returned.
+ * number of values defined by the filter. FILTER_CONFIG is a bit
+ * field contaning encode/decode flags from H5Zpublic.h. The ID
+ * should be the filter ID to retrieve the parameters for. If the
+ * filter is not set for the property list, an error will be returned.
*
* Return: Success: Non-negative
* Failure: Negative
@@ -837,13 +854,23 @@ done:
* Friday, April 5, 2003
*
* Modifications:
+ * James Laird and Nat Furrer
+ * Tuesday, June 15, 2004
+ * Function now retrieves filter_config flags.
*
*-------------------------------------------------------------------------
*/
+#ifdef H5_WANT_H5_V1_6_COMPAT
herr_t
H5Pget_filter_by_id(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/,
size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/,
size_t namelen, char name[]/*out*/)
+#else
+herr_t
+H5Pget_filter_by_id(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/,
+ size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/,
+ size_t namelen, char name[]/*out*/, unsigned int *filter_config)
+#endif /* H5_WANT_H5_V1_6_COMPAT */
{
H5O_pline_t pline; /* Filter pipeline */
H5Z_filter_info_t *filter; /* Pointer to filter information */
@@ -911,7 +938,13 @@ H5Pget_filter_by_id(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/,
else
name[0] = '\0';
}
-
+
+#ifndef H5_WANT_H5_V1_6_COMPAT
+ /* Get filter configuration, assume filter ID has already been checked */
+ if(filter_config != NULL)
+ H5Zget_filter_info(id, filter_config);
+#endif
+
done:
FUNC_LEAVE_API(ret_value);
} /* end H5Pget_filter_by_id() */
@@ -1032,6 +1065,10 @@ done:
* Tuesday, April 1, 2003
*
* Modifications:
+ * Nat Furrer and James Laird
+ * June 30, 2004
+ * Now ensures that SZIP encoding is enabled
+ * SZIP defaults to k13 compression
*
*-------------------------------------------------------------------------
*/
@@ -1041,11 +1078,18 @@ H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block)
H5O_pline_t pline;
H5P_genplist_t *plist; /* Property list pointer */
unsigned cd_values[2]; /* Filter parameters */
+ unsigned int config_flags;
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_szip, FAIL);
H5TRACE3("e","iIuIu",plist_id,options_mask,pixels_per_block);
-
+
+ if(H5Zget_filter_info(H5Z_FILTER_SZIP, &config_flags) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't get filter info")
+
+ if(! (config_flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED))
+ HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled.");
+
/* Check arguments */
if ((pixels_per_block%2)==1)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "pixels_per_block is not even");
@@ -1056,6 +1100,10 @@ H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block)
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
+ /* Always set K13 compression (and un-set CHIP compression) */
+ options_mask &= (~H5_SZIP_CHIP_OPTION_MASK);
+ options_mask |= H5_SZIP_ALLOW_K13_OPTION_MASK;
+
/* Always set "raw" (no szip header) flag for data */
options_mask |= H5_SZIP_RAW_OPTION_MASK;
diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h
index 4d1e027..89d3f6c 100644
--- a/src/H5Ppublic.h
+++ b/src/H5Ppublic.h
@@ -242,13 +242,23 @@ H5_DLL H5Z_filter_t H5Pget_filter(hid_t plist_id, unsigned filter,
unsigned int *flags/*out*/,
size_t *cd_nelmts/*out*/,
unsigned cd_values[]/*out*/,
- size_t namelen, char name[]);
+ size_t namelen, char name[],
+ unsigned int *filter_config /*out*/);
#endif /* H5_WANT_H5_V1_6_COMPAT */
+#ifdef H5_WANT_H5_V1_6_COMPAT
H5_DLL H5Z_filter_t H5Pget_filter_by_id(hid_t plist_id, H5Z_filter_t id,
unsigned int *flags/*out*/,
size_t *cd_nelmts/*out*/,
unsigned cd_values[]/*out*/,
- size_t namelen, char name[]);
+ size_t namelen, char name[]/*out*/);
+#else /* H5_WANT_H5_V1_6_COMPAT */
+H5_DLL H5Z_filter_t H5Pget_filter_by_id(hid_t plist_id, H5Z_filter_t id,
+ unsigned int *flags/*out*/,
+ size_t *cd_nelmts/*out*/,
+ unsigned cd_values[]/*out*/,
+ size_t namelen, char name[]/*out*/,
+ unsigned int *filter_config/*out*/);
+#endif /* H5_WANT_H5_V1_6_COMPAT */
H5_DLL htri_t H5Pall_filters_avail(hid_t plist_id);
H5_DLL herr_t H5Pset_deflate(hid_t plist_id, unsigned aggression);
H5_DLL herr_t H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block);
diff --git a/src/H5Z.c b/src/H5Z.c
index bf3998f..78a80fa 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -216,6 +216,13 @@ H5Zregister(const H5Z_class_t *cls)
/* Check args */
if (cls==NULL)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter class")
+
+ /* Check H5Z_class_t version number; this is where a function to convert
+ * from an outdated version should be called.
+ */
+ if(cls->version != H5Z_CLASS_T_VERS)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5Z_class_t version number");
+
if (cls->id<0 || cls->id>H5Z_FILTER_MAX)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number")
if (cls->id<H5Z_FILTER_RESERVED)
@@ -519,6 +526,11 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty
/* Make correct callback */
switch(prelude_type) {
case H5Z_PRELUDE_CAN_APPLY:
+ /* Check if filter is configured to be able to encode */
+ if(! fclass->encoder_present)
+ HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled.");
+
+
/* Check if there is a "can apply" callback */
if(fclass->can_apply) {
/* Make callback to filter's "can apply" function */
@@ -600,7 +612,7 @@ herr_t
H5Z_can_apply (hid_t dcpl_id, hid_t type_id)
{
herr_t ret_value=SUCCEED; /* Return value */
-
+
FUNC_ENTER_NOAPI(H5Z_can_apply,FAIL)
assert (H5I_GENPROP_LST==H5I_get_type(dcpl_id));
@@ -608,7 +620,7 @@ H5Z_can_apply (hid_t dcpl_id, hid_t type_id)
/* Make "can apply" callbacks for filters in pipeline */
if(H5Z_prelude_callback(dcpl_id, type_id, H5Z_PRELUDE_CAN_APPLY)<0)
- HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "filter parameters not appropriate")
+ HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "unable to apply filter")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1157,3 +1169,49 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter)
done:
FUNC_LEAVE_NOAPI(ret_value)
}
+
+/*-------------------------------------------------------------------------
+ * Function: H5Zget_filter_info
+ *
+ * Purpose: Gets information about a pipeline data filter and stores it
+ * in filter_config_flags.
+ *
+ * Return: zero on success / negative on failure
+ *
+ * Programmer: James Laird and Nat Furrer
+ * Monday, June 7, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags)
+{
+ herr_t ret_value=SUCCEED;
+ H5Z_class_t * fclass;
+
+ FUNC_ENTER_API(H5Zget_filter_info, FAIL)
+
+ fclass = H5Z_find(filter);
+
+#ifdef H5_WANT_H5_V1_6_COMPAT
+ if(fclass == NULL && filter_config_flags != NULL)
+ *filter_config_flags = 0;
+#else
+ if(fclass == NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Filter not defined")
+#endif /* H5_WANT_H5_V1_6_COMPAT */
+
+ if(filter_config_flags != NULL)
+ {
+ *filter_config_flags = 0;
+
+ if(fclass->encoder_present)
+ *filter_config_flags |= H5Z_FILTER_CONFIG_ENCODE_ENABLED;
+ if(fclass->decoder_present)
+ *filter_config_flags |= H5Z_FILTER_CONFIG_DECODE_ENABLED;
+ }
+
+done:
+ FUNC_LEAVE_API(ret_value)
+}
diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c
index 3202221..16890b0 100644
--- a/src/H5Zdeflate.c
+++ b/src/H5Zdeflate.c
@@ -40,7 +40,10 @@ static size_t H5Z_filter_deflate (unsigned flags, size_t cd_nelmts,
/* This message derives from H5Z */
const H5Z_class_t H5Z_DEFLATE[1] = {{
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
H5Z_FILTER_DEFLATE, /* Filter id number */
+ 1, /* encoder_present flag (set to true) */
+ 1, /* decoder_present flag (set to true) */
"deflate", /* Filter name for debugging */
NULL, /* The "can apply" callback */
NULL, /* The "set local" callback */
diff --git a/src/H5Zfletcher32.c b/src/H5Zfletcher32.c
index dfd69cf..38fda53 100644
--- a/src/H5Zfletcher32.c
+++ b/src/H5Zfletcher32.c
@@ -37,7 +37,10 @@ static size_t H5Z_filter_fletcher32 (unsigned flags, size_t cd_nelmts,
/* This message derives from H5Z */
const H5Z_class_t H5Z_FLETCHER32[1] = {{
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
H5Z_FILTER_FLETCHER32, /* Filter id number */
+ 1, /* encoder_present flag (set to true) */
+ 1, /* decoder_present flag (set to true) */
"fletcher32", /* Filter name for debugging */
NULL, /* The "can apply" callback */
NULL, /* The "set local" callback */
diff --git a/src/H5Zpkg.h b/src/H5Zpkg.h
index 4643bbc..7f9fd84 100644
--- a/src/H5Zpkg.h
+++ b/src/H5Zpkg.h
@@ -47,10 +47,11 @@ H5_DLLVAR const H5Z_class_t H5Z_FLETCHER32[1];
/*
* szip filter
*/
-H5_DLLVAR const H5Z_class_t H5Z_SZIP[1];
+H5_DLLVAR H5Z_class_t H5Z_SZIP[1];
#endif /* H5_HAVE_FILTER_SZIP */
/* Package-local function prototypes */
+H5_DLL void H5Z_update_class_vers(H5Z_class_t * old_vers, H5Z_class_t * curr_vers);
#endif /* _H5Zpkg_H */
diff --git a/src/H5Zpublic.h b/src/H5Zpublic.h
index ee7ad3c..83c2ada 100644
--- a/src/H5Zpublic.h
+++ b/src/H5Zpublic.h
@@ -58,6 +58,9 @@ typedef int H5Z_filter_t;
#define H5_SZIP_NN_OPTION_MASK 32
#define H5_SZIP_MAX_PIXELS_PER_BLOCK 32
+/* Current version of the H5Z_class_t struct */
+#define H5Z_CLASS_T_VERS (1)
+
/* Values to decide if EDC is enabled for reading data */
typedef enum H5Z_EDC_t {
H5Z_ERROR_EDC = -1, /* error value */
@@ -66,6 +69,10 @@ typedef enum H5Z_EDC_t {
H5Z_NO_EDC = 2 /* must be the last */
} H5Z_EDC_t;
+/* Bit flags for H5Zget_filter_info */
+#define H5Z_FILTER_CONFIG_ENCODE_ENABLED (0x0001)
+#define H5Z_FILTER_CONFIG_DECODE_ENABLED (0x0002)
+
/* Return values for filter callback function */
typedef enum H5Z_cb_return_t {
H5Z_CB_ERROR = -1,
@@ -77,7 +84,7 @@ typedef enum H5Z_cb_return_t {
/* Filter callback function definition */
typedef H5Z_cb_return_t (*H5Z_filter_func_t)(H5Z_filter_t filter, void* buf,
size_t buf_size, void* op_data);
-
+
/* Structure for filter callback property */
typedef struct H5Z_cb_t {
H5Z_filter_func_t func;
@@ -157,7 +164,10 @@ typedef size_t (*H5Z_func_t)(unsigned int flags, size_t cd_nelmts,
* contain a pointers to the filter function and timing statistics.
*/
typedef struct H5Z_class_t {
+ int version; /* Version number of the H5Z_class_t struct */
H5Z_filter_t id; /* Filter ID number */
+ unsigned encoder_present; /* Does this filter have an encoder? */
+ unsigned decoder_present; /* Does this filter have a decoder? */
const char *name; /* Comment for debugging */
H5Z_can_apply_func_t can_apply; /* The "can apply" callback for a filter */
H5Z_set_local_func_t set_local; /* The "set local" callback for a filter */
@@ -167,7 +177,7 @@ typedef struct H5Z_class_t {
H5_DLL herr_t H5Zregister(const H5Z_class_t *cls);
H5_DLL herr_t H5Zunregister(H5Z_filter_t id);
H5_DLL htri_t H5Zfilter_avail(H5Z_filter_t id);
-
+H5_DLL herr_t H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags);
#ifdef __cplusplus
}
diff --git a/src/H5Zshuffle.c b/src/H5Zshuffle.c
index 36b6f23..75c7c48 100644
--- a/src/H5Zshuffle.c
+++ b/src/H5Zshuffle.c
@@ -34,7 +34,10 @@ static size_t H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts,
/* This message derives from H5Z */
const H5Z_class_t H5Z_SHUFFLE[1] = {{
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
H5Z_FILTER_SHUFFLE, /* Filter id number */
+ 1, /* encoder_present flag (set to true) */
+ 1, /* decoder_present flag (set to true) */
"shuffle", /* Filter name for debugging */
NULL, /* The "can apply" callback */
H5Z_set_local_shuffle, /* The "set local" callback */
@@ -75,7 +78,11 @@ H5Z_set_local_shuffle(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id)
FUNC_ENTER_NOAPI(H5Z_set_local_shuffle, FAIL)
/* Get the filter's current parameters */
+#ifdef H5_WANT_H5_V1_6_COMPAT
if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SHUFFLE,&flags,&cd_nelmts, cd_values,0,NULL)<0)
+#else
+ if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SHUFFLE,&flags,&cd_nelmts, cd_values,0,NULL,NULL)<0)
+#endif
HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get shuffle parameters")
/* Set "local" parameter for this dataset */
diff --git a/src/H5Zszip.c b/src/H5Zszip.c
index 6683776..5eafec1 100644
--- a/src/H5Zszip.c
+++ b/src/H5Zszip.c
@@ -40,9 +40,16 @@ static size_t H5Z_filter_szip (unsigned flags, size_t cd_nelmts,
const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf);
/* This message derives from H5Z */
-const H5Z_class_t H5Z_SZIP[1] = {{
+H5Z_class_t H5Z_SZIP[1] = {{
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
H5Z_FILTER_SZIP, /* Filter id number */
- "szip", /* Filter name for debugging */
+#ifdef H5_SZIP_CAN_ENCODE
+ 1, /* Encoder present */
+#else
+ 0, /* Encoder disabled */
+#endif
+ 1, /* decoder_present flag (set to true) */
+ "szip", /* Filter name for debugging */
H5Z_can_apply_szip, /* The "can apply" callback */
H5Z_set_local_szip, /* The "set local" callback */
H5Z_filter_szip, /* The actual filter function */
@@ -96,8 +103,12 @@ H5Z_can_apply_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
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)
- HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get szip parameters")
+#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)
@@ -171,7 +182,11 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
FUNC_ENTER_NOAPI(H5Z_set_local_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 dimensions for dataspace */
@@ -328,5 +343,6 @@ done:
H5MM_xfree(outbuf);
FUNC_LEAVE_NOAPI(ret_value)
}
+
#endif /* H5_HAVE_FILTER_SZIP */
diff --git a/src/H5config.h.in b/src/H5config.h.in
index 48af1ba..2aa53c4 100644
--- a/src/H5config.h.in
+++ b/src/H5config.h.in
@@ -517,6 +517,9 @@
PTHREAD_SCOPE_SYSTEM) call. */
#undef SYSTEM_SCOPE_THREADS
+/* Define if szip encoder is present */
+#undef SZIP_CAN_ENCODE
+
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
diff --git a/src/H5err.txt b/src/H5err.txt
index 2f26e7d..802cccf 100644
--- a/src/H5err.txt
+++ b/src/H5err.txt
@@ -204,3 +204,4 @@ MINOR, PIPELINE, H5E_NOFILTER, Requested filter is not available
MINOR, PIPELINE, H5E_CALLBACK, Callback failed
MINOR, PIPELINE, H5E_CANAPPLY, Error from filter 'can apply' callback
MINOR, PIPELINE, H5E_SETLOCAL, Error from filter 'set local' callback
+MINOR, PIPELINE, H5E_NOENCODER, Filter present but encoding disabled