NetCDF  4.9.2
netcdf_filter.h
Go to the documentation of this file.
1 /* Copyright 2018, UCAR/Unidata and OPeNDAP, Inc.
2  See the COPYRIGHT file for more information. */
5 /*
6  * In order to use any of the netcdf_XXX.h files, it is necessary
7  * to include netcdf.h followed by any netcdf_XXX.h files.
8  * Various things (like EXTERNL) are defined in netcdf.h
9  * to make them available for use by the netcdf_XXX.h files.
10 */
11 
12 #ifndef NETCDF_FILTER_H
13 #define NETCDF_FILTER_H 1
14 
15 /* API for libdispatch/dfilter.c
16 */
17 
18 /* Must match values in <H5Zpublic.h> */
19 #ifndef H5Z_FILTER_DEFLATE
20 #define H5Z_FILTER_DEFLATE 1
21 #define H5Z_FILTER_SHUFFLE 2
22 #define H5Z_FILTER_FLETCHER32 3
23 #endif
24 
25 #ifndef H5Z_FILTER_SZIP
26 #define H5Z_FILTER_SZIP 4
27 #define H5_SZIP_ALLOW_K13_OPTION_MASK 1
28 #define H5_SZIP_CHIP_OPTION_MASK 2
29 #define H5_SZIP_EC_OPTION_MASK 4
30 #define H5_SZIP_LSB_OPTION_MASK 8
31 #define H5_SZIP_MSB_OPTION_MASK 16
32 #define H5_SZIP_NN_OPTION_MASK 32
33 #define H5_SZIP_MAX_PIXELS_PER_BLOCK 32
34 #define H5_SZIP_RAW_OPTION_MASK 128
35 
36 #define NC_SZIP_EC 4
37 #define NC_SZIP_NN 32
38 #endif
39 
40 #define H5_SZIP_ALL_MASKS (H5_SZIP_CHIP_OPTION_MASK|H5_SZIP_EC_OPTION_MASK|H5_SZIP_NN_OPTION_MASK)
41 
43 #define NC_MAX_PIXELS_PER_BLOCK 32
44 
45 /* Other Standard Filters */
46 #ifndef H5Z_FILTER_ZSTD
47 #define H5Z_FILTER_ZSTD 32015
48 #endif
49 #ifndef H5Z_FILTER_BZIP2
50 #define H5Z_FILTER_BZIP2 307
51 #endif
52 #ifndef H5Z_FILTER_BLOSC
53 #define H5Z_FILTER_BLOSC 32001
54 #endif
55 #ifndef BLOSC_SHUFFLE
56 enum BLOSC_SHUFFLE {
57 BLOSC_NOSHUFFLE=0, /* no shuffle */
58 BLOSC_SHUFFLE=1, /* byte-wise shuffle */
59 BLOSC_BITSHUFFLE=2 /* bit-wise shuffle */
60 };
61 #endif
62 
63 /*Assumes use of c-blosc library */
64 #ifndef BLOSC_BLOSCLZ
65 enum BLOSC_SUBCOMPRESSORS {BLOSC_LZ=0, BLOSC_LZ4=1, BLOSC_LZ4HC=2, BLOSC_SNAPPY=3, BLOSC_ZLIB=4, BLOSC_ZSTD=5};
66 #endif
67 
68 #if defined(__cplusplus)
69 extern "C" {
70 #endif
71 
72 /**************************************************/
73 /* HDF5 Format filter functions */
74 
75 /*Define a filter for a variable */
76 EXTERNL int
77 nc_def_var_filter(int ncid, int varid, unsigned int id, size_t nparams, const unsigned int* parms);
78 
79 /* Learn about the first defined filter filter on a variable */
80 EXTERNL int
81 nc_inq_var_filter(int ncid, int varid, unsigned int* idp, size_t* nparams, unsigned int* params);
82 
83 /* Support inquiry about all the filters associated with a variable */
84 /* As is usual, it is expected that this will be called twice:
85  once to get the number of filters, and then a second time to read the ids */
86 EXTERNL int nc_inq_var_filter_ids(int ncid, int varid, size_t* nfilters, unsigned int* filterids);
87 
88 /* Learn about the filter with specified id wrt a variable */
89 EXTERNL int nc_inq_var_filter_info(int ncid, int varid, unsigned int id, size_t* nparams, unsigned int* params);
90 
91 /* End HDF5 Format Declarations */
92 
93 /**************************************************/
94 /* Allow user to interrogate if a filter is available*/
95 /* Would prefer to get list of all known filters, but HDF5 does not support that */
96 
97 /* See if filter is available */
98 EXTERNL int nc_inq_filter_avail(int ncid, unsigned id);
99 
100 /**************************************************/
101 /* Functions for accessing standardized filters */
102 
103 EXTERNL int nc_def_var_bzip2(int ncid, int varid, int level);
104 EXTERNL int nc_inq_var_bzip2(int ncid, int varid, int* hasfilterp, int *levelp);
105 
106 /* Note use of 'zstandard' instead of 'zstd' */
107 EXTERNL int nc_def_var_zstandard(int ncid, int varid, int level);
108 EXTERNL int nc_inq_var_zstandard(int ncid, int varid, int* hasfilterp, int *levelp);
109 
110 EXTERNL int nc_def_var_blosc(int ncid, int varid, unsigned subcompressor, unsigned level, unsigned blocksize, unsigned addshuffle);
111 EXTERNL int nc_inq_var_blosc(int ncid, int varid, int* hasfilterp, unsigned* subcompressorp, unsigned* levelp, unsigned* blocksizep, unsigned* addshufflep);
112 
113 #if defined(__cplusplus)
114 }
115 #endif
116 /**************************************************/
117 
118 #endif /* NETCDF_FILTER_H */
EXTERNL int nc_def_var_blosc(int ncid, int varid, unsigned subcompressor, unsigned level, unsigned blocksize, unsigned addshuffle)
Turn on blosc for a variable.
Definition: dfilter.c:477
EXTERNL int nc_inq_var_filter_info(int ncid, int varid, unsigned int id, size_t *nparams, unsigned int *params)
Find the the param info about filter (if any) associated with a variable and with specified id.
Definition: dfilter.c:94
EXTERNL int nc_inq_var_filter(int ncid, int varid, unsigned int *idp, size_t *nparams, unsigned int *params)
Find the first filter (if any) associated with a variable.
Definition: dfilter.c:171
EXTERNL int nc_inq_var_filter_ids(int ncid, int varid, size_t *nfilters, unsigned int *filterids)
Find the set of filters (if any) associated with a variable.
Definition: dfilter.c:58
#define EXTERNL
Needed for DLL build.
Definition: netcdf.h:556
EXTERNL int nc_def_var_zstandard(int ncid, int varid, int level)
Turn on Zstandard compression for a variable.
Definition: dfilter.c:400
EXTERNL int nc_def_var_bzip2(int ncid, int varid, int level)
Turn on bzip2 compression for a variable.
Definition: dfilter.c:332
EXTERNL int nc_inq_filter_avail(int ncid, unsigned id)
Test if filter is available.
Definition: dfilter.c:213
EXTERNL int nc_def_var_filter(int ncid, int varid, unsigned int id, size_t nparams, const unsigned int *parms)
Define a new variable filter Assumes HDF5 format using unsigned ints.
Definition: dfilter.c:124
EXTERNL int nc_inq_var_blosc(int ncid, int varid, int *hasfilterp, unsigned *subcompressorp, unsigned *levelp, unsigned *blocksizep, unsigned *addshufflep)
Learn whether Blosc compression is on for a variable, and, if so, the settings.
Definition: dfilter.c:527
EXTERNL int nc_inq_var_bzip2(int ncid, int varid, int *hasfilterp, int *levelp)
Learn whether bzip2 compression is on for a variable, and, if so, the level setting.
Definition: dfilter.c:363
EXTERNL int nc_inq_var_zstandard(int ncid, int varid, int *hasfilterp, int *levelp)
Learn whether Zstandard compression is on for a variable, and, if so, the level setting.
Definition: dfilter.c:436