H5Zpublic.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2. * Copyright by The HDF Group. *
  3. * Copyright by the Board of Trustees of the University of Illinois. *
  4. * All rights reserved. *
  5. * *
  6. * This file is part of HDF5. The full HDF5 copyright notice, including *
  7. * terms governing use, modification, and redistribution, is contained in *
  8. * the COPYING file, which can be found at the root of the source code *
  9. * distribution tree, or in https://www.hdfgroup.org/licenses. *
  10. * If you do not have access to either file, you may request a copy from *
  11. * help@hdfgroup.org. *
  12. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  13. /* Programmer: Robb Matzke
  14. * Thursday, April 16, 1998
  15. */
  16. #ifndef H5Zpublic_H
  17. #define H5Zpublic_H
  18. /* Public headers needed by this file */
  19. #include "H5public.h"
  20. /**
  21. * \brief Filter identifiers
  22. *
  23. * \details Values 0 through 255 are for filters defined by the HDF5 library.
  24. * Values 256 through 511 are available for testing new filters.
  25. * Subsequent values should be obtained from the HDF5 development team
  26. * at mailto:help@hdfgroup.org. These values will never change because
  27. * they appear in the HDF5 files.
  28. */
  29. typedef int H5Z_filter_t;
  30. /* Filter IDs */
  31. /**
  32. * no filter
  33. */
  34. #define H5Z_FILTER_ERROR (-1)
  35. /**
  36. * reserved indefinitely
  37. */
  38. #define H5Z_FILTER_NONE 0
  39. /**
  40. * deflation like gzip
  41. */
  42. #define H5Z_FILTER_DEFLATE 1
  43. /**
  44. * shuffle the data
  45. */
  46. #define H5Z_FILTER_SHUFFLE 2
  47. /**
  48. * fletcher32 checksum of EDC
  49. */
  50. #define H5Z_FILTER_FLETCHER32 3
  51. /**
  52. * szip compression
  53. */
  54. #define H5Z_FILTER_SZIP 4
  55. /**
  56. * nbit compression
  57. */
  58. #define H5Z_FILTER_NBIT 5
  59. /**
  60. * scale+offset compression
  61. */
  62. #define H5Z_FILTER_SCALEOFFSET 6
  63. /**
  64. * filter ids below this value are reserved for library use
  65. */
  66. #define H5Z_FILTER_RESERVED 256
  67. /**
  68. * maximum filter id
  69. */
  70. #define H5Z_FILTER_MAX 65535
  71. /* General macros */
  72. /**
  73. * Symbol to remove all filters in H5Premove_filter()
  74. */
  75. #define H5Z_FILTER_ALL 0
  76. /**
  77. * Maximum number of filters allowed in a pipeline
  78. *
  79. * \internal (should probably be allowed to be an unlimited amount, but
  80. * currently each filter uses a bit in a 32-bit field, so the format
  81. * would have to be changed to accommodate that)
  82. */
  83. #define H5Z_MAX_NFILTERS 32
  84. /* Flags for filter definition (stored) */
  85. /**
  86. * definition flag mask
  87. */
  88. #define H5Z_FLAG_DEFMASK 0x00ff
  89. /**
  90. * filter is mandatory
  91. */
  92. #define H5Z_FLAG_MANDATORY 0x0000
  93. /**
  94. * filter is optional
  95. */
  96. #define H5Z_FLAG_OPTIONAL 0x0001
  97. /* Additional flags for filter invocation (not stored) */
  98. /**
  99. * invocation flag mask
  100. */
  101. #define H5Z_FLAG_INVMASK 0xff00
  102. /**
  103. * reverse direction; read
  104. */
  105. #define H5Z_FLAG_REVERSE 0x0100
  106. /**
  107. * skip EDC filters for read
  108. */
  109. #define H5Z_FLAG_SKIP_EDC 0x0200
  110. /* Special parameters for szip compression */
  111. /* [These are aliases for the similar definitions in szlib.h, which we can't
  112. * include directly due to the duplication of various symbols with the zlib.h
  113. * header file] */
  114. /**
  115. * \ingroup SZIP */
  116. #define H5_SZIP_ALLOW_K13_OPTION_MASK 1
  117. /**
  118. * \ingroup SZIP */
  119. #define H5_SZIP_CHIP_OPTION_MASK 2
  120. /**
  121. * \ingroup SZIP */
  122. #define H5_SZIP_EC_OPTION_MASK 4
  123. /**
  124. * \ingroup SZIP */
  125. #define H5_SZIP_NN_OPTION_MASK 32
  126. /**
  127. * \ingroup SZIP */
  128. #define H5_SZIP_MAX_PIXELS_PER_BLOCK 32
  129. /* Macros for the shuffle filter */
  130. /**
  131. * \ingroup SHUFFLE
  132. * Number of parameters that users can set for the shuffle filter
  133. */
  134. #define H5Z_SHUFFLE_USER_NPARMS 0
  135. /**
  136. * \ingroup SHUFFLE
  137. * Total number of parameters for the shuffle filter
  138. */
  139. #define H5Z_SHUFFLE_TOTAL_NPARMS 1
  140. /* Macros for the szip filter */
  141. /**
  142. * \ingroup SZIP
  143. * Number of parameters that users can set for SZIP
  144. */
  145. #define H5Z_SZIP_USER_NPARMS 2
  146. /**
  147. * \ingroup SZIP
  148. * Total number of parameters for SZIP filter
  149. */
  150. #define H5Z_SZIP_TOTAL_NPARMS 4
  151. /**
  152. * \ingroup SZIP
  153. * "User" parameter for option mask
  154. */
  155. #define H5Z_SZIP_PARM_MASK 0
  156. /**
  157. * \ingroup SZIP
  158. * "User" parameter for pixels-per-block
  159. */
  160. #define H5Z_SZIP_PARM_PPB 1
  161. /**
  162. * \ingroup SZIP
  163. * "Local" parameter for bits-per-pixel
  164. */
  165. #define H5Z_SZIP_PARM_BPP 2
  166. /**
  167. * \ingroup SZIP
  168. * "Local" parameter for pixels-per-scanline
  169. */
  170. #define H5Z_SZIP_PARM_PPS 3
  171. /* Macros for the nbit filter */
  172. /**
  173. * \ingroup NBIT
  174. * Number of parameters that users can set for the N-bit filter
  175. */
  176. #define H5Z_NBIT_USER_NPARMS 0 /* Number of parameters that users can set */
  177. /* Macros for the scale offset filter */
  178. /**
  179. * \ingroup SCALEOFFSET
  180. * Number of parameters that users can set for the scale-offset filter
  181. */
  182. #define H5Z_SCALEOFFSET_USER_NPARMS 2
  183. /* Special parameters for ScaleOffset filter*/
  184. /**
  185. * \ingroup SCALEOFFSET */
  186. #define H5Z_SO_INT_MINBITS_DEFAULT 0
  187. /**
  188. * \ingroup SCALEOFFSET */
  189. typedef enum H5Z_SO_scale_type_t {
  190. H5Z_SO_FLOAT_DSCALE = 0,
  191. H5Z_SO_FLOAT_ESCALE = 1,
  192. H5Z_SO_INT = 2
  193. } H5Z_SO_scale_type_t;
  194. /**
  195. * \ingroup FLETCHER32
  196. * Values to decide if EDC is enabled for reading data
  197. */
  198. typedef enum H5Z_EDC_t {
  199. H5Z_ERROR_EDC = -1, /**< error value */
  200. H5Z_DISABLE_EDC = 0,
  201. H5Z_ENABLE_EDC = 1,
  202. H5Z_NO_EDC = 2 /**< sentinel */
  203. } H5Z_EDC_t;
  204. /* Bit flags for H5Zget_filter_info */
  205. #define H5Z_FILTER_CONFIG_ENCODE_ENABLED (0x0001)
  206. #define H5Z_FILTER_CONFIG_DECODE_ENABLED (0x0002)
  207. /**
  208. * Return values for filter callback function
  209. */
  210. typedef enum H5Z_cb_return_t {
  211. H5Z_CB_ERROR = -1, /**< error value */
  212. H5Z_CB_FAIL = 0, /**< I/O should fail if filter fails. */
  213. H5Z_CB_CONT = 1, /**< I/O continues if filter fails. */
  214. H5Z_CB_NO = 2 /**< sentinel */
  215. } H5Z_cb_return_t;
  216. //! <!-- [H5Z_filter_func_t_snip] -->
  217. /**
  218. * Filter callback function definition
  219. */
  220. typedef H5Z_cb_return_t (*H5Z_filter_func_t)(H5Z_filter_t filter, void *buf, size_t buf_size, void *op_data);
  221. //! <!-- [H5Z_filter_func_t_snip] -->
  222. #ifdef __cplusplus
  223. extern "C" {
  224. #endif
  225. /**
  226. * \ingroup H5Z
  227. *
  228. * \brief Determines whether a filter is available
  229. *
  230. * \param[in] id Filter identifier
  231. * \return \htri_t
  232. *
  233. * \details H5Zfilter_avail() determines whether the filter specified in \p id
  234. * is available to the application.
  235. *
  236. * \since 1.6.0
  237. */
  238. H5_DLL htri_t H5Zfilter_avail(H5Z_filter_t id);
  239. /**
  240. * \ingroup H5Z
  241. *
  242. * \brief Retrieves information about a filter
  243. *
  244. * \param[in] filter Filter identifier
  245. * \param[out] filter_config_flags A bit field encoding the returned filter
  246. * information
  247. * \return \herr_t
  248. *
  249. * \details H5Zget_filter_info() retrieves information about a filter. At
  250. * present, this means that the function retrieves a filter's
  251. * configuration flags, indicating whether the filter is configured to
  252. * decode data, to encode data, neither, or both.
  253. *
  254. * If \p filter_config_flags is not set to NULL prior to the function
  255. * call, the returned parameter contains a bit field specifying the
  256. * available filter configuration. The configuration flag values can
  257. * then be determined through a series of bitwise AND operations, as
  258. * described below.
  259. *
  260. * Valid filter configuration flags include the following:
  261. * <table>
  262. * <tr><td>#H5Z_FILTER_CONFIG_ENCODE_ENABLED</td>
  263. * <td>Encoding is enabled for this filter</td></tr>
  264. * <tr><td>#H5Z_FILTER_CONFIG_DECODE_ENABLED</td>
  265. * <td>Decoding is enabled for this filter</td></tr>
  266. * </table>
  267. *
  268. * A bitwise AND of the returned \p filter_config_flags and a valid
  269. * filter configuration flag will reveal whether the related
  270. * configuration option is available. For example, if the value of
  271. * \code
  272. * H5Z_FILTER_CONFIG_ENCODE_ENABLED & filter_config_flags
  273. * \endcode
  274. * is true, i.e., greater than 0 (zero), the queried filter
  275. * is configured to encode data; if the value is \c FALSE, i.e., equal to
  276. * 0 (zero), the filter is not so configured.
  277. *
  278. * If a filter is not encode-enabled, the corresponding \c H5Pset_*
  279. * function will return an error if the filter is added to a dataset
  280. * creation property list (which is required if the filter is to be
  281. * used to encode that dataset). For example, if the
  282. * #H5Z_FILTER_CONFIG_ENCODE_ENABLED flag is not returned for the SZIP
  283. * filter, #H5Z_FILTER_SZIP, a call to H5Pset_szip() will fail.
  284. *
  285. * If a filter is not decode-enabled, the application will not be able
  286. * to read an existing file encoded with that filter.
  287. *
  288. * This function should be called, and the returned \p
  289. * filter_config_flags analyzed, before calling any other function,
  290. * such as H5Pset_szip() , that might require a particular filter
  291. * configuration.
  292. *
  293. * \since 1.6.3
  294. */
  295. H5_DLL herr_t H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags);
  296. #ifdef __cplusplus
  297. }
  298. #endif
  299. #endif /* _H5Zpublic_H */