summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5tools_filters.c
diff options
context:
space:
mode:
authorRobert E. McGrath <mcgrath@ncsa.uiuc.edu>2004-11-02 19:14:14 (GMT)
committerRobert E. McGrath <mcgrath@ncsa.uiuc.edu>2004-11-02 19:14:14 (GMT)
commit25c1e28ffd660e713f97b65e70620c7128f46f1f (patch)
treead6abf34988df6351d4b579a7b87be6f822ca247 /tools/lib/h5tools_filters.c
parent8c0c4f945db726fcddd2a40e4f617cdf6aac6be8 (diff)
downloadhdf5-25c1e28ffd660e713f97b65e70620c7128f46f1f.zip
hdf5-25c1e28ffd660e713f97b65e70620c7128f46f1f.tar.gz
hdf5-25c1e28ffd660e713f97b65e70620c7128f46f1f.tar.bz2
[svn-r9496] Purpose:
Fix SZIP filter to dynmically detect encoder. Description: Solution: See: http://hdf.ncsa.uiuc.edu/RFC/SZIP/Szip_dynamic_12_Oct.pdf Changes to h5repack tests, contingent on detecting SZIP encoder. Note new program: testh5repack_detect_szip Checks fo rencoder, prints out "yes" or "no". Used by hrepack.sh to detect encoder. Can also be used for windows tests. This is only used as part of the tests. Had to modify Makefile to build and clean this program.
Diffstat (limited to 'tools/lib/h5tools_filters.c')
-rw-r--r--tools/lib/h5tools_filters.c92
1 files changed, 91 insertions, 1 deletions
diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c
index 368283f..3370409 100644
--- a/tools/lib/h5tools_filters.c
+++ b/tools/lib/h5tools_filters.c
@@ -150,5 +150,95 @@ int h5tools_canreadf(const char* name, /* object name, serves also as boolean pr
}
+/*-------------------------------------------------------------------------
+ * Function: h5tools_canwritef
+ *
+ * Purpose: check if the filter is available and can write data.
+ * At this time, all filters that are available can write data,
+ * except SZIP, which may be configured decoder-only.
+ *
+ * Return: 1, can write, 0, cannot, -1 error
+ *
+ * Programmer:
+ *
+ * Date: October 5, 2004
+ *
+ *-------------------------------------------------------------------------
+ */
+int h5tools_can_encode( H5Z_filter_t filtn)
+{
-
+ int have_deflate=0; /* assume initially we do not have filters */
+ int have_szip=0;
+ int have_shuffle=0;
+ int have_fletcher=0;
+ herr_t status;
+ unsigned int filter_config_flags;
+
+#ifdef H5_HAVE_FILTER_DEFLATE
+ have_deflate=1;
+#endif
+#ifdef H5_HAVE_FILTER_SZIP
+ have_szip=1;
+#endif
+#ifdef H5_HAVE_FILTER_SHUFFLE
+ have_shuffle=1;
+#endif
+#ifdef H5_HAVE_FILTER_FLETCHER32
+ have_fletcher=1;
+#endif
+
+ switch (filtn)
+ {
+ /* user defined filter */
+ default:
+ return 0;
+ break;
+ case H5Z_FILTER_DEFLATE:
+ if (!have_deflate)
+ {
+ return 0;
+ }
+ break;
+ case H5Z_FILTER_SZIP:
+ if (!have_szip)
+ {
+ return 0;
+ }
+ status =H5Zget_filter_info(filtn, &filter_config_flags);
+ if ((filter_config_flags &
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
+ /* filter present but neither encode nor decode is supported (???) */
+ return -1;
+ } else if ((filter_config_flags &
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
+ H5Z_FILTER_CONFIG_DECODE_ENABLED) {
+ /* decoder only: read but not write */
+ return 0;
+ } else if ((filter_config_flags &
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
+ H5Z_FILTER_CONFIG_ENCODE_ENABLED) {
+ /* encoder only: write but not read (???) */
+ return -1;
+ } else if ((filter_config_flags &
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) {
+ return 1;
+ }
+ break;
+ case H5Z_FILTER_SHUFFLE:
+ if (!have_shuffle)
+ {
+ return 0;
+ }
+ break;
+ case H5Z_FILTER_FLETCHER32:
+ if (!have_fletcher)
+ {
+ return 0;
+ }
+ break;
+ }/*switch*/
+
+ return 1;
+}