diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2021-03-25 00:39:37 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2021-03-25 00:39:37 (GMT) |
commit | feb20aac304b39e18c70f88cae2f7cf7d5c82db2 (patch) | |
tree | e15d7e751af4e3c42e77ea955d91db4cf27a71cf /tools/src/h5repack/h5repack_filters.c | |
parent | bdac2ecdbff2c389a222b3d93ff1eb1d23ec6b23 (diff) | |
download | hdf5-feb20aac304b39e18c70f88cae2f7cf7d5c82db2.zip hdf5-feb20aac304b39e18c70f88cae2f7cf7d5c82db2.tar.gz hdf5-feb20aac304b39e18c70f88cae2f7cf7d5c82db2.tar.bz2 |
Formats the source and updates the gcc warning pragmas
Diffstat (limited to 'tools/src/h5repack/h5repack_filters.c')
-rw-r--r-- | tools/src/h5repack/h5repack_filters.c | 311 |
1 files changed, 153 insertions, 158 deletions
diff --git a/tools/src/h5repack/h5repack_filters.c b/tools/src/h5repack/h5repack_filters.c index d1179fb..0570c0f 100644 --- a/tools/src/h5repack/h5repack_filters.c +++ b/tools/src/h5repack/h5repack_filters.c @@ -17,12 +17,12 @@ /* number of members in an array */ #ifndef NELMTS -# define NELMTS(X) (sizeof(X)/sizeof(X[0])) +#define NELMTS(X) (sizeof(X) / sizeof(X[0])) #endif /* minimum of two values */ #undef MIN -#define MIN(a,b) (((a)<(b)) ? (a) : (b)) +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) /*------------------------------------------------------------------------- * Function: aux_copy_obj @@ -32,15 +32,16 @@ * Return: 0 success, -1 failure *------------------------------------------------------------------------- */ -static int aux_copy_obj(hid_t dcpl_id, /* dataset creation property list */ - const char* name, /* object name from traverse list */ - pack_info_t *objout /*OUT*/) /* info about object to filter */ +static int +aux_copy_obj(hid_t dcpl_id, /* dataset creation property list */ + const char * name, /* object name from traverse list */ + pack_info_t *objout /*OUT*/) /* info about object to filter */ { int nfilters; /* number of filters in DCPL */ char f_objname[256]; /* filter objname */ H5D_layout_t layout; - int rank; /* rank of dataset */ - hsize_t chsize[64]; /* chunk size in elements */ + int rank; /* rank of dataset */ + hsize_t chsize[64]; /* chunk size in elements */ int i; unsigned u; int ret_value = 0; @@ -50,8 +51,9 @@ static int aux_copy_obj(hid_t dcpl_id, /* dataset creation property list */ H5TOOLS_GOTO_ERROR((-1), "H5Pget_nfilters failed"); /* copy filter_info_t structure */ for (i = 0; i < nfilters; i++) { - if ((objout->filter[i].filtn = H5Pget_filter2(dcpl_id, (unsigned) i, &objout->filter[i].filt_flag, &objout->filter[i].cd_nelmts, - objout->filter[i].cd_values, sizeof(f_objname), f_objname, NULL)) < 0) + if ((objout->filter[i].filtn = H5Pget_filter2( + dcpl_id, (unsigned)i, &objout->filter[i].filt_flag, &objout->filter[i].cd_nelmts, + objout->filter[i].cd_values, sizeof(f_objname), f_objname, NULL)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pget_filter2 failed"); } @@ -63,7 +65,7 @@ static int aux_copy_obj(hid_t dcpl_id, /* dataset creation property list */ objout->layout = layout; if (layout == H5D_CHUNKED) { - if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize/*out*/)) < 0) + if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize /*out*/)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pget_chunk failed"); objout->chunk.rank = rank; for (u = 0; u < (unsigned)rank; u++) @@ -81,30 +83,33 @@ done: * in the repack options list *------------------------------------------------------------------------- */ -static int aux_find_obj(const char* name, /* object name from traverse list */ - pack_opt_t *options, /* repack options */ - pack_info_t *obj /*OUT*/) /* info about object to filter */ +static int +aux_find_obj(const char * name, /* object name from traverse list */ + pack_opt_t * options, /* repack options */ + pack_info_t *obj /*OUT*/) /* info about object to filter */ { - char *pdest = NULL; - const char *pname = NULL; + char * pdest = NULL; + const char * pname = NULL; unsigned int i; for (i = 0; i < options->op_tbl->nelems; i++) { if (HDstrcmp(options->op_tbl->objs[i].path, name) == 0) { *obj = options->op_tbl->objs[i]; - return (int) i; + return (int)i; } pdest = options->op_tbl->objs[i].path; - if (pdest[0] == '/') pdest++; + if (pdest[0] == '/') + pdest++; pname = name; - if (pname[0] == '/') pname++; + if (pname[0] == '/') + pname++; if (HDstrcmp(pdest, pname) == 0) { *obj = options->op_tbl->objs[i]; - return (int) i; + return (int)i; } - }/*i*/ + } /*i*/ return -1; } @@ -118,9 +123,10 @@ static int aux_find_obj(const char* name, /* object name from traverse list */ * Return: 0 not found, 1 found *------------------------------------------------------------------------- */ -static int aux_assign_obj(const char* name, /* object name from traverse list */ - pack_opt_t *options, /* repack options */ - pack_info_t *obj /*OUT*/) /* info about object to filter */ +static int +aux_assign_obj(const char * name, /* object name from traverse list */ + pack_opt_t * options, /* repack options */ + pack_info_t *obj /*OUT*/) /* info about object to filter */ { int idx, i; pack_info_t tmp; @@ -136,44 +142,44 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */ /* assign the global layout info to the OBJ info */ tmp.layout = options->layout_g; switch (options->layout_g) { - case H5D_CHUNKED: - tmp.chunk.rank = options->chunk_g.rank; - for (i = 0; i < tmp.chunk.rank; i++) - tmp.chunk.chunk_lengths[i] = options->chunk_g.chunk_lengths[i]; - break; - case H5D_LAYOUT_ERROR: - case H5D_COMPACT: - case H5D_CONTIGUOUS: - case H5D_VIRTUAL: - case H5D_NLAYOUTS: - break; - default: - break; - }/*switch*/ + case H5D_CHUNKED: + tmp.chunk.rank = options->chunk_g.rank; + for (i = 0; i < tmp.chunk.rank; i++) + tmp.chunk.chunk_lengths[i] = options->chunk_g.chunk_lengths[i]; + break; + case H5D_LAYOUT_ERROR: + case H5D_COMPACT: + case H5D_CONTIGUOUS: + case H5D_VIRTUAL: + case H5D_NLAYOUTS: + break; + default: + break; + } /*switch*/ } else { tmp.layout = options->op_tbl->objs[idx].layout; switch (tmp.layout) { - case H5D_CHUNKED: - tmp.chunk.rank = options->op_tbl->objs[idx].chunk.rank; - for (i = 0; i < tmp.chunk.rank; i++) - tmp.chunk.chunk_lengths[i] = options->op_tbl->objs[idx].chunk.chunk_lengths[i]; - break; - case H5D_LAYOUT_ERROR: - case H5D_COMPACT: - case H5D_CONTIGUOUS: - case H5D_VIRTUAL: - case H5D_NLAYOUTS: - break; - default: - break; - }/*switch*/ + case H5D_CHUNKED: + tmp.chunk.rank = options->op_tbl->objs[idx].chunk.rank; + for (i = 0; i < tmp.chunk.rank; i++) + tmp.chunk.chunk_lengths[i] = options->op_tbl->objs[idx].chunk.chunk_lengths[i]; + break; + case H5D_LAYOUT_ERROR: + case H5D_COMPACT: + case H5D_CONTIGUOUS: + case H5D_VIRTUAL: + case H5D_NLAYOUTS: + break; + default: + break; + } /*switch*/ } /* applying to all objects */ if (options->all_filter) { /* assign the global filter */ - tmp.nfilters = 1; + tmp.nfilters = 1; tmp.filter[0] = options->filter_g[0]; } /* if all */ else { @@ -197,21 +203,20 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */ /* assign the global layout info to the OBJ info */ tmp.layout = options->layout_g; switch (options->layout_g) { - case H5D_CHUNKED: - tmp.chunk.rank = options->chunk_g.rank; - for (i = 0; i < tmp.chunk.rank; i++) - tmp.chunk.chunk_lengths[i] = - options->chunk_g.chunk_lengths[i]; - break; - case H5D_LAYOUT_ERROR: - case H5D_COMPACT: - case H5D_CONTIGUOUS: - case H5D_VIRTUAL: - case H5D_NLAYOUTS: - break; - default: - break; - }/*switch*/ + case H5D_CHUNKED: + tmp.chunk.rank = options->chunk_g.rank; + for (i = 0; i < tmp.chunk.rank; i++) + tmp.chunk.chunk_lengths[i] = options->chunk_g.chunk_lengths[i]; + break; + case H5D_LAYOUT_ERROR: + case H5D_COMPACT: + case H5D_CONTIGUOUS: + case H5D_VIRTUAL: + case H5D_NLAYOUTS: + break; + default: + break; + } /*switch*/ } } @@ -230,16 +235,17 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */ *------------------------------------------------------------------------- */ -int apply_filters(const char* name, /* object name from traverse list */ - int rank, /* rank of dataset */ - hsize_t *dims, /* dimensions of dataset */ - size_t msize, /* size of type */ - hid_t dcpl_id, /* dataset creation property list */ - pack_opt_t *options, /* repack options */ - int *has_filter) /* (OUT) object NAME has a filter */ +int +apply_filters(const char *name, /* object name from traverse list */ + int rank, /* rank of dataset */ + hsize_t * dims, /* dimensions of dataset */ + size_t msize, /* size of type */ + hid_t dcpl_id, /* dataset creation property list */ + pack_opt_t *options, /* repack options */ + int * has_filter) /* (OUT) object NAME has a filter */ { - int nfilters; /* number of filters in DCPL */ - hsize_t chsize[64]; /* chunk size in elements */ + int nfilters; /* number of filters in DCPL */ + hsize_t chsize[64]; /* chunk size in elements */ H5D_layout_t layout; int i; pack_info_t obj; @@ -269,7 +275,6 @@ int apply_filters(const char* name, /* object name from traverse list */ if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pget_nfilters failed"); - /*------------------------------------------------------------------------- * check if we have filters in the pipeline * we want to replace them with the input filters @@ -281,7 +286,7 @@ int apply_filters(const char* name, /* object name from traverse list */ if (H5Premove_filter(dcpl_id, H5Z_FILTER_ALL) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Premove_filter failed"); } - else if(nfilters) { + else if (nfilters) { *has_filter = 1; if (aux_copy_obj(dcpl_id, name, &filtobj) < 0) H5TOOLS_GOTO_ERROR((-1), "aux_copy_obj failed"); @@ -297,9 +302,9 @@ int apply_filters(const char* name, /* object name from traverse list */ H5TOOLS_GOTO_ERROR((-1), "H5Pget_layout failed"); if (layout == H5D_CHUNKED) { - if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize/*out*/)) < 0) + if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize /*out*/)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pget_chunk failed"); - obj.layout = H5D_CHUNKED; + obj.layout = H5D_CHUNKED; obj.chunk.rank = rank; for (i = 0; i < rank; i++) obj.chunk.chunk_lengths[i] = chsize[i]; @@ -327,7 +332,7 @@ int apply_filters(const char* name, /* object name from traverse list */ if (obj.layout == -1) { /* stripmine info */ hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ - hsize_t sm_nbytes; /*bytes per stripmine */ + hsize_t sm_nbytes; /*bytes per stripmine */ obj.chunk.rank = rank; @@ -339,7 +344,7 @@ int apply_filters(const char* name, /* object name from traverse list */ sm_nbytes = msize; for (i = rank; i > 0; --i) { hsize_t size = 0; - if(sm_nbytes == 0) + if (sm_nbytes == 0) H5TOOLS_GOTO_ERROR((-1), "number of bytes per stripmine must be > 0"); size = H5TOOLS_BUFSIZE / sm_nbytes; if (size == 0) /* datum size > H5TOOLS_BUFSIZE */ @@ -358,19 +363,18 @@ int apply_filters(const char* name, /* object name from traverse list */ H5TOOLS_GOTO_ERROR((-1), "invalid filter"); switch (obj.filter[i].filtn) { - /*------------------------------------------------------------------------- - * H5Z_FILTER_NONE 0 , uncompress if compressed - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_NONE: - break; - - /*------------------------------------------------------------------------- - * H5Z_FILTER_DEFLATE 1 , deflation like gzip - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_DEFLATE: - { + /*------------------------------------------------------------------------- + * H5Z_FILTER_NONE 0 , uncompress if compressed + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_NONE: + break; + + /*------------------------------------------------------------------------- + * H5Z_FILTER_DEFLATE 1 , deflation like gzip + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_DEFLATE: { unsigned aggression; /* the deflate level */ aggression = obj.filter[i].cd_values[0]; @@ -379,19 +383,17 @@ int apply_filters(const char* name, /* object name from traverse list */ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); if (H5Pset_deflate(dcpl_id, aggression) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_deflate failed"); - } - break; + } break; - /*------------------------------------------------------------------------- - * H5Z_FILTER_SZIP 4 , szip compression - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_SZIP: - { + /*------------------------------------------------------------------------- + * H5Z_FILTER_SZIP 4 , szip compression + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_SZIP: { unsigned options_mask; unsigned pixels_per_block; - options_mask = obj.filter[i].cd_values[0]; + options_mask = obj.filter[i].cd_values[0]; pixels_per_block = obj.filter[i].cd_values[1]; /* set up for szip data */ @@ -399,70 +401,64 @@ int apply_filters(const char* name, /* object name from traverse list */ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); if (H5Pset_szip(dcpl_id, options_mask, pixels_per_block) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_szip failed"); - } - break; + } break; - /*------------------------------------------------------------------------- - * H5Z_FILTER_SHUFFLE 2 , shuffle the data - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_SHUFFLE: - if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); - if (H5Pset_shuffle(dcpl_id) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_shuffle failed"); - break; - - /*------------------------------------------------------------------------- - * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_FLETCHER32: - if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); - if (H5Pset_fletcher32(dcpl_id) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_fletcher32 failed"); - break; - /*----------- ------------------------------------------------------------- - * H5Z_FILTER_NBIT , NBIT compression - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_NBIT: - if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); - if (H5Pset_nbit(dcpl_id) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_nbit failed"); - break; - /*----------- ------------------------------------------------------------- - * H5Z_FILTER_SCALEOFFSET , scale+offset compression - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_SCALEOFFSET: - { + /*------------------------------------------------------------------------- + * H5Z_FILTER_SHUFFLE 2 , shuffle the data + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_SHUFFLE: + if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); + if (H5Pset_shuffle(dcpl_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_shuffle failed"); + break; + + /*------------------------------------------------------------------------- + * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_FLETCHER32: + if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); + if (H5Pset_fletcher32(dcpl_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_fletcher32 failed"); + break; + /*----------- ------------------------------------------------------------- + * H5Z_FILTER_NBIT , NBIT compression + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_NBIT: + if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); + if (H5Pset_nbit(dcpl_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_nbit failed"); + break; + /*----------- ------------------------------------------------------------- + * H5Z_FILTER_SCALEOFFSET , scale+offset compression + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_SCALEOFFSET: { H5Z_SO_scale_type_t scale_type; - int scale_factor; + int scale_factor; - scale_type = (H5Z_SO_scale_type_t) obj.filter[i].cd_values[0]; - scale_factor = (int) obj.filter[i].cd_values[1]; + scale_type = (H5Z_SO_scale_type_t)obj.filter[i].cd_values[0]; + scale_factor = (int)obj.filter[i].cd_values[1]; if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); if (H5Pset_scaleoffset(dcpl_id, scale_type, scale_factor) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_scaleoffset failed"); - } - break; - default: - { + } break; + default: { if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); - if (H5Pset_filter(dcpl_id, obj.filter[i].filtn, - obj.filter[i].filt_flag, obj.filter[i].cd_nelmts, - obj.filter[i].cd_values) < 0) + if (H5Pset_filter(dcpl_id, obj.filter[i].filtn, obj.filter[i].filt_flag, + obj.filter[i].cd_nelmts, obj.filter[i].cd_values) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_filter failed"); - } - break; + } break; } /* switch */ - }/*i*/ + } /*i*/ } /*obj.nfilters*/ @@ -474,7 +470,7 @@ int apply_filters(const char* name, /* object name from traverse list */ if (H5Zfilter_avail(filtobj.filter[i].filtn) <= 0) H5TOOLS_GOTO_ERROR((-1), "%d filter unavailable", filtobj.filter[i].filtn); } /* for */ - } /* nfilters */ + } /* nfilters */ /*------------------------------------------------------------------------- * layout @@ -504,4 +500,3 @@ int apply_filters(const char* name, /* object name from traverse list */ done: return ret_value; } - |