diff options
-rw-r--r-- | src/H5Pdcpl.c | 4 | ||||
-rw-r--r-- | src/H5Ppublic.h | 2 | ||||
-rw-r--r-- | src/H5Zpublic.h | 12 | ||||
-rw-r--r-- | src/H5Zscaleoffset.c | 451 | ||||
-rw-r--r-- | test/dsets.c | 12 | ||||
-rw-r--r-- | tools/h5dump/h5dumpgentest.c | 2 | ||||
-rw-r--r-- | tools/h5repack/h5repack_filters.c | 2 | ||||
-rw-r--r-- | tools/h5repack/testh5repack_make.c | 2 |
8 files changed, 243 insertions, 244 deletions
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 6981686..34935b9 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -1293,7 +1293,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pset_scaleoffset(hid_t plist_id, H5_SO_scale_type scale_type, int scale_factor) +H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_factor) { H5O_pline_t pline; H5P_genplist_t *plist; /* Property list pointer */ @@ -1307,7 +1307,7 @@ H5Pset_scaleoffset(hid_t plist_id, H5_SO_scale_type scale_type, int scale_factor if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); - if(scale_type!=0 && scale_type!=1 && scale_type!=2) + if(scale_type!=H5Z_SO_FLOAT_DSCALE && scale_type!=H5Z_SO_FLOAT_ESCALE && scale_type!=H5Z_SO_INT) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "invalid scale type"); /* Get the plist structure */ diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index e6f5a7f..1240d2d 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -268,7 +268,7 @@ 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); H5_DLL herr_t H5Pset_shuffle(hid_t plist_id); H5_DLL herr_t H5Pset_nbit(hid_t plist_id); -H5_DLL herr_t H5Pset_scaleoffset(hid_t plist_id, H5_SO_scale_type scale_type, int scale_factor); +H5_DLL herr_t H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_factor); H5_DLL herr_t H5Pset_fletcher32(hid_t plist_id); H5_DLL herr_t H5Pset_edc_check(hid_t plist_id, H5Z_EDC_t check); H5_DLL H5Z_EDC_t H5Pget_edc_check(hid_t plist_id); diff --git a/src/H5Zpublic.h b/src/H5Zpublic.h index c6fd426..a559174 100644 --- a/src/H5Zpublic.h +++ b/src/H5Zpublic.h @@ -61,12 +61,12 @@ typedef int H5Z_filter_t; #define H5_SZIP_MAX_PIXELS_PER_BLOCK 32 /* Special parameters for ScaleOffset filter*/ -#define H5_SO_INT_MINBITS_DEFAULT 0 -typedef enum H5_SO_scale_type { - H5_SO_FLOAT_DSCALE = 0, - H5_SO_FLOAT_ESCALE = 1, - H5_SO_INT = 2 -} H5_SO_scale_type; +#define H5Z_SO_INT_MINBITS_DEFAULT 0 +typedef enum H5Z_SO_scale_type_t { + H5Z_SO_FLOAT_DSCALE = 0, + H5Z_SO_FLOAT_ESCALE = 1, + H5Z_SO_INT = 2 +} H5Z_SO_scale_type_t; /* Current version of the H5Z_class_t struct */ #define H5Z_CLASS_T_VERS (1) diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c index e579577..c8e7177 100644 --- a/src/H5Zscaleoffset.c +++ b/src/H5Zscaleoffset.c @@ -24,15 +24,15 @@ #ifdef H5_HAVE_FILTER_SCALEOFFSET -/* Struct of parameters needed for compressing/decompressing one atomic datatype */ +/* Struct of parameters needed for compressing/decompressing one atomic datatype */ typedef struct { size_t size; /* datatype size */ uint32_t minbits; /* minimum bits to compress one value of such datatype */ unsigned mem_order; /* current memory endianness order */ -} parms_atomic; +} parms_atomic; enum H5Z_scaleoffset_type {t_bad=0, t_uchar=1, t_ushort, t_uint, t_ulong, t_ulong_long, - t_schar, t_short, t_int, t_long, t_long_long, + t_schar, t_short, t_int, t_long, t_long_long, t_float, t_double}; /* Local function prototypes */ @@ -40,7 +40,7 @@ static double H5Z_scaleoffset_rnd(double val); static herr_t H5Z_can_apply_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id); static enum H5Z_scaleoffset_type H5Z_scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dtype_sign); -static herr_t H5Z_scaleoffset_set_parms_fillval(hid_t dcpl_id, hid_t type_id, +static herr_t H5Z_scaleoffset_set_parms_fillval(hid_t dcpl_id, hid_t type_id, enum H5Z_scaleoffset_type type, unsigned cd_values[], int need_convert); static herr_t H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id); static size_t H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, @@ -55,7 +55,7 @@ static void H5Z_scaleoffset_postdecompress_i(void *data, unsigned d_nelmts, uint32_t minbits, unsigned long_long minval); static herr_t H5Z_scaleoffset_precompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_type type, unsigned filavail, const void *filval_buf, - uint32_t *minbits, unsigned long_long *minval, double D_val); + uint32_t *minbits, unsigned long_long *minval, double D_val); static herr_t H5Z_scaleoffset_postdecompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_type type, unsigned filavail, const void *filval_buf, uint32_t minbits, unsigned long_long minval, double D_val); @@ -66,11 +66,11 @@ static void H5Z_scaleoffset_decompress_one_byte(unsigned char *data, size_t data static void H5Z_scaleoffset_compress_one_byte(unsigned char *data, size_t data_offset, int k, int begin_i, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p, int dtype_len); -static void H5Z_scaleoffset_decompress_one_atomic(unsigned char *data, size_t data_offset, +static void H5Z_scaleoffset_decompress_one_atomic(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p); -static void H5Z_scaleoffset_compress_one_atomic(unsigned char *data, size_t data_offset, +static void H5Z_scaleoffset_compress_one_atomic(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p); -static void H5Z_scaleoffset_decompress(unsigned char *data, unsigned d_nelmts, +static void H5Z_scaleoffset_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, parms_atomic p); static void H5Z_scaleoffset_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, size_t buffer_size, parms_atomic p); @@ -316,7 +316,7 @@ H5Z_class_t H5Z_SCALEOFFSET[1] = {{ \ if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ H5Z_scaleoffset_get_filval_1(i, type, filval_buf, filval) \ - if(*minbits == H5_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */\ + if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */\ H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ H5Z_scaleoffset_check_1(type, max, min, minbits) \ span = max - min + 1; \ @@ -327,7 +327,7 @@ H5Z_class_t H5Z_SCALEOFFSET[1] = {{ for(i = 0; i < d_nelmts; i++) \ buf[i] = (buf[i] == filval)?(((type)1 << *minbits) - 1):(buf[i] - min); \ } else { /* fill value undefined */ \ - if(*minbits == H5_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */\ + if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */\ H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ H5Z_scaleoffset_check_1(type, max, min, minbits) \ span = max - min + 1; \ @@ -348,7 +348,7 @@ H5Z_class_t H5Z_SCALEOFFSET[1] = {{ \ if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ H5Z_scaleoffset_get_filval_1(i, type, filval_buf, filval) \ - if(*minbits == H5_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */\ + if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */\ H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ H5Z_scaleoffset_check_2(type, max, min, minbits) \ span = max - min + 1; \ @@ -359,7 +359,7 @@ H5Z_class_t H5Z_SCALEOFFSET[1] = {{ for(i = 0; i < d_nelmts; i++) \ buf[i] = (buf[i] == filval) ? (type)(((unsigned type)1 << *minbits) - 1) : (buf[i] - min); \ } else { /* fill value undefined */ \ - if(*minbits == H5_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */\ + if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */\ H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ H5Z_scaleoffset_check_2(type, max, min, minbits) \ span = max - min + 1; \ @@ -567,7 +567,7 @@ H5Z_class_t H5Z_SCALEOFFSET[1] = {{ /*------------------------------------------------------------------------- * Function: H5Z_can_apply_scaleoffset * - * Purpose: Check the parameters for scaleoffset compression for + * Purpose: Check the parameters for scaleoffset compression for * validity and whether they fit a particular dataset. * * Return: Success: Non-negative @@ -576,7 +576,7 @@ H5Z_class_t H5Z_SCALEOFFSET[1] = {{ * Programmer: Xiaowen Wu * Friday, February 4, 2005 * - * Modifications: + * Modifications: * *------------------------------------------------------------------------- */ @@ -618,51 +618,51 @@ done: * * Purpose: Get the specific integer type based on datatype size and sign * or floating-point type based on size - * + * * Return: Success: id number of integer type - * Failure: 0 + * Failure: 0 * * Programmer: Xiaowen Wu * Wednesday, April 13, 2005 * * Modifications: - * + * *------------------------------------------------------------------------- */ -static enum H5Z_scaleoffset_type +static enum H5Z_scaleoffset_type H5Z_scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dtype_sign) { enum H5Z_scaleoffset_type type; /* integer type */ enum H5Z_scaleoffset_type ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5Z_scaleoffset_get_type) - + if(dtype_class==H5Z_SCALEOFFSET_CLS_INTEGER) { if(dtype_sign==H5Z_SCALEOFFSET_SGN_NONE) { /* unsigned integer */ if (dtype_size == sizeof(unsigned char)) type = t_uchar; - else if(dtype_size == sizeof(unsigned short)) type = t_ushort; - else if(dtype_size == sizeof(unsigned int)) type = t_uint; + else if(dtype_size == sizeof(unsigned short)) type = t_ushort; + else if(dtype_size == sizeof(unsigned int)) type = t_uint; else if(dtype_size == sizeof(unsigned long)) type = t_ulong; - else if(dtype_size == sizeof(unsigned long_long)) type = t_ulong_long; - else + else if(dtype_size == sizeof(unsigned long_long)) type = t_ulong_long; + else HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype") } if(dtype_sign==H5Z_SCALEOFFSET_SGN_2) { /* signed integer */ if (dtype_size == sizeof(signed char)) type = t_schar; - else if(dtype_size == sizeof(short)) type = t_short; - else if(dtype_size == sizeof(int)) type = t_int; + else if(dtype_size == sizeof(short)) type = t_short; + else if(dtype_size == sizeof(int)) type = t_int; else if(dtype_size == sizeof(long)) type = t_long; - else if(dtype_size == sizeof(long_long)) type = t_long_long; - else + else if(dtype_size == sizeof(long_long)) type = t_long_long; + else HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype") } } if(dtype_class==H5Z_SCALEOFFSET_CLS_FLOAT) { if(dtype_size == sizeof(float)) type = t_float; - else if(dtype_size == sizeof(double)) type = t_double; - else + else if(dtype_size == sizeof(double)) type = t_double; + else HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype") } @@ -677,7 +677,7 @@ done: /*------------------------------------------------------------------------- * Function: H5Z_scaleoffset_set_parms_fillval * - * Purpose: Get the fill value of the dataset and store in cd_values[] + * Purpose: Get the fill value of the dataset and store in cd_values[] * * Return: Success: Non-negative * Failure: Negative @@ -685,11 +685,11 @@ done: * Programmer: Xiaowen Wu * Monday, March 7, 2005 * - * Modifications: + * Modifications: * *------------------------------------------------------------------------- */ -static herr_t H5Z_scaleoffset_set_parms_fillval(hid_t dcpl_id, hid_t type_id, +static herr_t H5Z_scaleoffset_set_parms_fillval(hid_t dcpl_id, hid_t type_id, enum H5Z_scaleoffset_type type, unsigned cd_values[], int need_convert) { herr_t ret_value=SUCCEED; /* Return value */ @@ -697,34 +697,34 @@ static herr_t H5Z_scaleoffset_set_parms_fillval(hid_t dcpl_id, hid_t type_id, FUNC_ENTER_NOAPI(H5Z_scaleoffset_set_parms_fillval, FAIL) if(type == t_uchar) - H5Z_scaleoffset_set_filval_3(unsigned char, dcpl_id, type_id, + H5Z_scaleoffset_set_filval_3(unsigned char, dcpl_id, type_id, cd_values, need_convert) - else if(type == t_ushort) - H5Z_scaleoffset_set_filval_1(unsigned short, dcpl_id, type_id, + else if(type == t_ushort) + H5Z_scaleoffset_set_filval_1(unsigned short, dcpl_id, type_id, cd_values, need_convert) - else if(type == t_uint) - H5Z_scaleoffset_set_filval_1(unsigned int, dcpl_id, type_id, + else if(type == t_uint) + H5Z_scaleoffset_set_filval_1(unsigned int, dcpl_id, type_id, cd_values, need_convert) - else if(type == t_ulong) - H5Z_scaleoffset_set_filval_1(unsigned long, dcpl_id, type_id, + else if(type == t_ulong) + H5Z_scaleoffset_set_filval_1(unsigned long, dcpl_id, type_id, cd_values, need_convert) - else if(type == t_ulong_long) - H5Z_scaleoffset_set_filval_1(unsigned long_long, dcpl_id, type_id, + else if(type == t_ulong_long) + H5Z_scaleoffset_set_filval_1(unsigned long_long, dcpl_id, type_id, cd_values, need_convert) - else if(type == t_schar) - H5Z_scaleoffset_set_filval_3(signed char, dcpl_id, type_id, + else if(type == t_schar) + H5Z_scaleoffset_set_filval_3(signed char, dcpl_id, type_id, cd_values, need_convert) else if(type == t_short) - H5Z_scaleoffset_set_filval_2(short, dcpl_id, type_id, + H5Z_scaleoffset_set_filval_2(short, dcpl_id, type_id, cd_values, need_convert) - else if(type == t_int) - H5Z_scaleoffset_set_filval_2(int, dcpl_id, type_id, + else if(type == t_int) + H5Z_scaleoffset_set_filval_2(int, dcpl_id, type_id, cd_values, need_convert) - else if(type == t_long) - H5Z_scaleoffset_set_filval_2(long, dcpl_id, type_id, + else if(type == t_long) + H5Z_scaleoffset_set_filval_2(long, dcpl_id, type_id, cd_values, need_convert) - else if(type == t_long_long) - H5Z_scaleoffset_set_filval_2(long_long, dcpl_id, type_id, + else if(type == t_long_long) + H5Z_scaleoffset_set_filval_2(long_long, dcpl_id, type_id, cd_values, need_convert) else if(type == t_float) H5Z_scaleoffset_set_filval_4(float, dcpl_id, type_id, @@ -751,7 +751,7 @@ done: * Friday, February 4, 2005 * * Modifications: - * + * *------------------------------------------------------------------------- */ static herr_t @@ -826,7 +826,7 @@ H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad integer sign") } /* end switch */ } - + /* Get datatype's endianness order */ if((dtype_order=H5Tget_order(type_id))==H5T_ORDER_ERROR) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order") @@ -895,19 +895,19 @@ done: * * Purpose: Implement an I/O filter for storing packed integer * data using scale and offset method. - * + * * Return: Success: Size of buffer filtered - * Failure: 0 + * Failure: 0 * * Programmer: Xiaowen Wu * Monday, February 7, 2005 * * Modifications: - * + * *------------------------------------------------------------------------- */ static size_t -H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], +H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf) { size_t ret_value = 0; /* return value */ @@ -916,7 +916,7 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu unsigned dtype_class; /* datatype class */ unsigned dtype_sign; /* integer datatype sign */ unsigned filavail; /* flag indicating if fill value is defined or not */ - H5_SO_scale_type scale_type = 0;/* scale type */ + H5Z_SO_scale_type_t scale_type = 0;/* scale type */ int scale_factor = 0; /* scale factor */ double D_val = 0.0; /* decimal scale factor */ uint32_t minbits = 0; /* minimum number of bits to store values */ @@ -928,7 +928,7 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu unsigned buf_offset = 21; /* buffer offset because of parameters stored in file */ unsigned i; /* index */ parms_atomic p; /* paramters needed for compress/decompress functions */ - + FUNC_ENTER_NOAPI(H5Z_filter_scaleoffset, 0) /* check arguments */ @@ -962,36 +962,36 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu scale_type = cd_values[H5Z_SCALEOFFSET_PARM_SCALETYPE]; /* check and assign proper values set by user to related parameters - * scale type can be H5_SO_FLOAT_DSCALE (0), H5_SO_FLOAT_ESCALE (1) or H5_SO_INT (other) - * H5_SO_FLOAT_DSCALE : floating-point type, variable-minimum-bits method, + * scale type can be H5Z_SO_FLOAT_DSCALE (0), H5Z_SO_FLOAT_ESCALE (1) or H5Z_SO_INT (other) + * H5Z_SO_FLOAT_DSCALE : floating-point type, variable-minimum-bits method, * scale factor is decimal scale factor - * H5_SO_FLOAT_ESCALE : floating-point type, fixed-minimum-bits method, + * H5Z_SO_FLOAT_ESCALE : floating-point type, fixed-minimum-bits method, * scale factor is the fixed minimum number of bits - * H5_SO_INT : integer type, scale_factor is minimum number of bits + * H5Z_SO_INT : integer type, scale_factor is minimum number of bits */ if(dtype_class==H5Z_SCALEOFFSET_CLS_FLOAT) { /* floating-point type */ - if(scale_type!=H5_SO_FLOAT_DSCALE && scale_type!=H5_SO_FLOAT_ESCALE) + if(scale_type!=H5Z_SO_FLOAT_DSCALE && scale_type!=H5Z_SO_FLOAT_ESCALE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid scale type") - } + } if(dtype_class==H5Z_SCALEOFFSET_CLS_INTEGER) { /* integer type */ - if(scale_type!=H5_SO_INT) + if(scale_type!=H5Z_SO_INT) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid scale type") - /* if scale_factor is less than 0 for integer, library will reset it to 0 - * in this case, library will calculate the minimum-bits + /* if scale_factor is less than 0 for integer, library will reset it to 0 + * in this case, library will calculate the minimum-bits */ if(scale_factor < 0) scale_factor = 0; } /* fixed-minimum-bits method is not implemented and is forbidden */ - if(scale_type==H5_SO_FLOAT_ESCALE) + if(scale_type==H5Z_SO_FLOAT_ESCALE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "E-scaling method not supported") - if(scale_type==H5_SO_FLOAT_DSCALE) { /* floating-point type, variable-minimum-bits */ + if(scale_type==H5Z_SO_FLOAT_DSCALE) { /* floating-point type, variable-minimum-bits */ D_val = (double)scale_factor; } else { /* integer type, or floating-point type with fixed-minimum-bits method */ - if(scale_factor>cd_values[H5Z_SCALEOFFSET_PARM_SIZE]*8) + if(scale_factor>cd_values[H5Z_SCALEOFFSET_PARM_SIZE]*8) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "minimum number of bits exceeds maximum") /* no need to process data */ @@ -1046,11 +1046,11 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for scaleoffset decompression") /* special case: minbits equal to full precision */ - if(minbits == p.size * 8) { + if(minbits == p.size * 8) { HDmemcpy(outbuf, (unsigned char*)(*buf)+buf_offset, size_out); /* convert to dataset datatype endianness order if needed */ - if(need_convert) + if(need_convert) H5Z_scaleoffset_convert(outbuf, d_nelmts, p.size); *buf = outbuf; @@ -1060,11 +1060,11 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu goto done; } - /* decompress the buffer if minbits not equal to zero */ - if(minbits != 0) - H5Z_scaleoffset_decompress(outbuf, d_nelmts, (unsigned char*)(*buf)+buf_offset, p); - else { - /* fill value is not defined and all data elements have the same value */ + /* decompress the buffer if minbits not equal to zero */ + if(minbits != 0) + H5Z_scaleoffset_decompress(outbuf, d_nelmts, (unsigned char*)(*buf)+buf_offset, p); + else { + /* fill value is not defined and all data elements have the same value */ for(i = 0; i < size_out; i++) outbuf[i] = 0; } @@ -1074,26 +1074,26 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu /* postprocess after decompression */ if(dtype_class==H5Z_SCALEOFFSET_CLS_INTEGER) - H5Z_scaleoffset_postdecompress_i(outbuf, d_nelmts, type, filavail, + H5Z_scaleoffset_postdecompress_i(outbuf, d_nelmts, type, filavail, &cd_values[H5Z_SCALEOFFSET_PARM_FILVAL], minbits, minval); if(dtype_class==H5Z_SCALEOFFSET_CLS_FLOAT) - if(scale_type==0) { /* variable-minimum-bits method */ - if(H5Z_scaleoffset_postdecompress_fd(outbuf, d_nelmts, type, filavail, + if(scale_type==0) { /* variable-minimum-bits method */ + if(H5Z_scaleoffset_postdecompress_fd(outbuf, d_nelmts, type, filavail, &cd_values[H5Z_SCALEOFFSET_PARM_FILVAL], minbits, minval, D_val)==FAIL) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "post-decompression failed") } /* after postprocess, convert to dataset datatype endianness order if needed */ - if(need_convert) + if(need_convert) H5Z_scaleoffset_convert(outbuf, d_nelmts, p.size); } /* output; compress */ - else { + else { assert(nbytes == d_nelmts * p.size); /* before preprocess, convert to memory endianness order if needed */ - if(need_convert) + if(need_convert) H5Z_scaleoffset_convert(*buf, d_nelmts, p.size); /* before preprocess, get memory type */ @@ -1102,11 +1102,11 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu /* preprocess before compression */ if(dtype_class==H5Z_SCALEOFFSET_CLS_INTEGER) - H5Z_scaleoffset_precompress_i(*buf, d_nelmts, type, filavail, + H5Z_scaleoffset_precompress_i(*buf, d_nelmts, type, filavail, &cd_values[H5Z_SCALEOFFSET_PARM_FILVAL], &minbits, &minval); - + if(dtype_class==H5Z_SCALEOFFSET_CLS_FLOAT) - if(scale_type==0) { /* variable-minimum-bits method */ + if(scale_type==0) { /* variable-minimum-bits method */ if(H5Z_scaleoffset_precompress_fd(*buf, d_nelmts, type, filavail, &cd_values[H5Z_SCALEOFFSET_PARM_FILVAL], &minbits, &minval, D_val)==FAIL) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "pre-compression failed") @@ -1147,10 +1147,10 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu goto done; } - /* compress the buffer if minbits not equal to zero - * minbits equal to zero only when fill value is not defined and - * all data elements have the same value - */ + /* compress the buffer if minbits not equal to zero + * minbits equal to zero only when fill value is not defined and + * all data elements have the same value + */ if(minbits != 0) H5Z_scaleoffset_compress(*buf, d_nelmts, outbuf+buf_offset, size_out-buf_offset, p); } @@ -1174,13 +1174,13 @@ done: * assume one byte has 8 bit * assume padding bit is 0 * assume size of unsigned char is one byte - * assume one data item of certain datatype is stored continously in bytes - * atomic datatype is treated on byte basis + * assume one data item of certain datatype is stored continously in bytes + * atomic datatype is treated on byte basis */ /* change byte order of input buffer either from little-endian to big-endian - * or from big-endian to little-endian 2/21/2005 + * or from big-endian to little-endian 2/21/2005 */ static void H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, unsigned dtype_size) { @@ -1200,28 +1200,28 @@ static void H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, unsigned dtype } /* Round a floating-point value to the nearest integer value 4/19/05 */ -/* rounding to the bigger absolute value if val is in the middle, +/* rounding to the bigger absolute value if val is in the middle, 0.5 -> 1, -0.5 ->-1 5/9/05, KY */ -static double H5Z_scaleoffset_rnd(double val) -{ - double u_val, l_val; - - u_val = HDceil(val); +static double H5Z_scaleoffset_rnd(double val) +{ + double u_val, l_val; + + u_val = HDceil(val); l_val = HDfloor(val); if(val > 0) { - if((u_val - val)<=(val - l_val)) return u_val; - else return l_val; - } + if((u_val - val)<=(val - l_val)) return u_val; + else return l_val; + } else { - if((val - l_val)<=(u_val - val)) return l_val; - else return u_val; - } -} + if((val - l_val)<=(u_val - val)) return l_val; + else return u_val; + } +} /* return ceiling of floating-point log2 function - * receive unsigned integer as argument 3/10/2005 + * receive unsigned integer as argument 3/10/2005 */ static unsigned H5Z_scaleoffset_log2(unsigned long_long num) { @@ -1236,120 +1236,119 @@ static unsigned H5Z_scaleoffset_log2(unsigned long_long num) } /* precompress for integer type */ -static void -H5Z_scaleoffset_precompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_type type, +static void +H5Z_scaleoffset_precompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_type type, unsigned filavail, const void *filval_buf, uint32_t *minbits, unsigned long_long *minval) { if(type == t_uchar) - H5Z_scaleoffset_precompress_1(unsigned char, data, d_nelmts, + H5Z_scaleoffset_precompress_1(unsigned char, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_ushort) - H5Z_scaleoffset_precompress_1(unsigned short, data, d_nelmts, + else if(type == t_ushort) + H5Z_scaleoffset_precompress_1(unsigned short, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_uint) - H5Z_scaleoffset_precompress_1(unsigned int, data, d_nelmts, + else if(type == t_uint) + H5Z_scaleoffset_precompress_1(unsigned int, data, d_nelmts, filavail, filval_buf, minbits, minval) else if(type == t_ulong) - H5Z_scaleoffset_precompress_1(unsigned long, data, d_nelmts, + H5Z_scaleoffset_precompress_1(unsigned long, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_ulong_long) - H5Z_scaleoffset_precompress_1(unsigned long_long, data, d_nelmts, + else if(type == t_ulong_long) + H5Z_scaleoffset_precompress_1(unsigned long_long, data, d_nelmts, filavail, filval_buf, minbits, minval) else if(type == t_schar) { - signed char *buf = data, min = 0, max = 0, filval = 0; - unsigned char span; unsigned i; - - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ - H5Z_scaleoffset_get_filval_1(i, signed char, filval_buf, filval); - if(*minbits == H5_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, -calculate max, min, and minbits */ + signed char *buf = data, min = 0, max = 0, filval = 0; + unsigned char span; unsigned i; + + if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ + H5Z_scaleoffset_get_filval_1(i, signed char, filval_buf, filval); + if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */ H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) - if((unsigned char)(max - min) > (unsigned char)(~(unsigned char)0 - 2)) - { *minbits = sizeof(signed char)*8; return; } - span = max - min + 1; + if((unsigned char)(max - min) > (unsigned char)(~(unsigned char)0 - 2)) + { *minbits = sizeof(signed char)*8; return; } + span = max - min + 1; *minbits = H5Z_scaleoffset_log2((unsigned long_long)(span+1)); - } else /* minbits already set, only calculate min */ - H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) - if(*minbits != sizeof(signed char)*8) /* change values if minbits != full precision */ - for(i = 0; i < d_nelmts; i++) - buf[i] = (buf[i] == filval)?(((unsigned char)1 << *minbits) - 1):(buf[i] - min); - } else { /* fill value undefined */ - if(*minbits == H5_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */ - H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) + } else /* minbits already set, only calculate min */ + H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) + if(*minbits != sizeof(signed char)*8) /* change values if minbits != full precision */ + for(i = 0; i < d_nelmts; i++) + buf[i] = (buf[i] == filval)?(((unsigned char)1 << *minbits) - 1):(buf[i] - min); + } else { /* fill value undefined */ + if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */ + H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) if((unsigned char)(max - min) > (unsigned char)(~(unsigned char)0 - 2)) { *minbits = sizeof(signed char)*8; *minval = min; return; - } - span = max - min + 1; + } + span = max - min + 1; *minbits = H5Z_scaleoffset_log2((unsigned long_long)span); - } else /* minbits already set, only calculate min */ - H5Z_scaleoffset_min_2(i, d_nelmts, buf, min) - if(*minbits != sizeof(signed char)*8) /* change values if minbits != full precision */ - for(i = 0; i < d_nelmts; i++) buf[i] -= min; - } - *minval = min; - } + } else /* minbits already set, only calculate min */ + H5Z_scaleoffset_min_2(i, d_nelmts, buf, min) + if(*minbits != sizeof(signed char)*8) /* change values if minbits != full precision */ + for(i = 0; i < d_nelmts; i++) buf[i] -= min; + } + *minval = min; + } else if(type == t_short) - H5Z_scaleoffset_precompress_2(short, data, d_nelmts, + H5Z_scaleoffset_precompress_2(short, data, d_nelmts, filavail, filval_buf, minbits, minval) else if(type == t_int) - H5Z_scaleoffset_precompress_2(int, data, d_nelmts, + H5Z_scaleoffset_precompress_2(int, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_long) - H5Z_scaleoffset_precompress_2(long, data, d_nelmts, + else if(type == t_long) + H5Z_scaleoffset_precompress_2(long, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_long_long) - H5Z_scaleoffset_precompress_2(long_long, data, d_nelmts, + else if(type == t_long_long) + H5Z_scaleoffset_precompress_2(long_long, data, d_nelmts, filavail, filval_buf, minbits, minval) } /* postdecompress for integer type */ -static void -H5Z_scaleoffset_postdecompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_type type, +static void +H5Z_scaleoffset_postdecompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_type type, unsigned filavail, const void *filval_buf, uint32_t minbits, unsigned long_long minval) { long_long sminval = *(long_long*)&minval; /* for signed integer types */ - if(type == t_uchar) - H5Z_scaleoffset_postdecompress_1(unsigned char, data, d_nelmts, filavail, + if(type == t_uchar) + H5Z_scaleoffset_postdecompress_1(unsigned char, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_ushort) - H5Z_scaleoffset_postdecompress_1(unsigned short, data, d_nelmts, filavail, + else if(type == t_ushort) + H5Z_scaleoffset_postdecompress_1(unsigned short, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_uint) - H5Z_scaleoffset_postdecompress_1(unsigned int, data, d_nelmts, filavail, + else if(type == t_uint) + H5Z_scaleoffset_postdecompress_1(unsigned int, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_ulong) - H5Z_scaleoffset_postdecompress_1(unsigned long, data, d_nelmts, filavail, + else if(type == t_ulong) + H5Z_scaleoffset_postdecompress_1(unsigned long, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_ulong_long) - H5Z_scaleoffset_postdecompress_1(unsigned long_long, data, d_nelmts, filavail, + else if(type == t_ulong_long) + H5Z_scaleoffset_postdecompress_1(unsigned long_long, data, d_nelmts, filavail, filval_buf, minbits, minval) else if(type == t_schar) { signed char *buf = data, filval = 0; unsigned i; if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ H5Z_scaleoffset_get_filval_1(i, signed char, filval_buf, filval) - for(i = 0; i < d_nelmts; i++) + for(i = 0; i < d_nelmts; i++) buf[i] = (buf[i] == (((unsigned char)1 << minbits) - 1))?filval:(buf[i] + sminval); } else /* fill value undefined */ for(i = 0; i < d_nelmts; i++) buf[i] += sminval; - } - else if(type == t_short) - H5Z_scaleoffset_postdecompress_2(short, data, d_nelmts, filavail, + } + else if(type == t_short) + H5Z_scaleoffset_postdecompress_2(short, data, d_nelmts, filavail, filval_buf, minbits, sminval) - else if(type == t_int) - H5Z_scaleoffset_postdecompress_2(int, data, d_nelmts, filavail, + else if(type == t_int) + H5Z_scaleoffset_postdecompress_2(int, data, d_nelmts, filavail, filval_buf, minbits, sminval) - else if(type == t_long) - H5Z_scaleoffset_postdecompress_2(long, data, d_nelmts, filavail, + else if(type == t_long) + H5Z_scaleoffset_postdecompress_2(long, data, d_nelmts, filavail, filval_buf, minbits, sminval) - else if(type == t_long_long) - H5Z_scaleoffset_postdecompress_2(long_long, data, d_nelmts, filavail, + else if(type == t_long_long) + H5Z_scaleoffset_postdecompress_2(long_long, data, d_nelmts, filavail, filval_buf, minbits, sminval) } -/* precompress for floating-point type, variable-minimum-bits method +/* precompress for floating-point type, variable-minimum-bits method success: non-negative, failure: negative 4/15/05 */ static herr_t H5Z_scaleoffset_precompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_type type, @@ -1359,18 +1358,18 @@ unsigned filavail, const void *filval_buf, uint32_t *minbits, unsigned long_long FUNC_ENTER_NOAPI(H5Z_scaleoffset_precompress_fd, FAIL) - if(type == t_float) - H5Z_scaleoffset_precompress_3(float, data, d_nelmts, + if(type == t_float) + H5Z_scaleoffset_precompress_3(float, data, d_nelmts, filavail, filval_buf, minbits, minval, D_val) - else if(type == t_double) - H5Z_scaleoffset_precompress_3(double, data, d_nelmts, + else if(type == t_double) + H5Z_scaleoffset_precompress_3(double, data, d_nelmts, filavail, filval_buf, minbits, minval, D_val) done: FUNC_LEAVE_NOAPI(ret_value) } -/* postdecompress for floating-point type, variable-minimum-bits method +/* postdecompress for floating-point type, variable-minimum-bits method success: non-negative, failure: negative 4/15/05 */ static herr_t H5Z_scaleoffset_postdecompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_type type, @@ -1381,23 +1380,23 @@ unsigned filavail, const void *filval_buf, uint32_t minbits, unsigned long_long FUNC_ENTER_NOAPI(H5Z_scaleoffset_postdecompress_fd, FAIL) - if(type == t_float) - H5Z_scaleoffset_postdecompress_3(float, data, d_nelmts, filavail, + if(type == t_float) + H5Z_scaleoffset_postdecompress_3(float, data, d_nelmts, filavail, filval_buf, minbits, sminval, D_val) - else if(type == t_double) - H5Z_scaleoffset_postdecompress_3(double, data, d_nelmts, filavail, + else if(type == t_double) + H5Z_scaleoffset_postdecompress_3(double, data, d_nelmts, filavail, filval_buf, minbits, sminval, D_val) done: FUNC_LEAVE_NOAPI(ret_value) -} +} static void H5Z_scaleoffset_next_byte(size_t *j, int *buf_len) { ++(*j); *buf_len = 8 * sizeof(unsigned char); } -static void H5Z_scaleoffset_decompress_one_byte(unsigned char *data, size_t data_offset, int k, +static void H5Z_scaleoffset_decompress_one_byte(unsigned char *data, size_t data_offset, int k, int begin_i, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p, int dtype_len) { int dat_len; /* dat_len is the number of bits to be copied in each data byte */ @@ -1405,12 +1404,12 @@ int begin_i, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p, int /* initialize value and bits of unsigned char to be copied */ val = buffer[*j]; - if(k == begin_i) + if(k == begin_i) dat_len = 8 - (dtype_len - p.minbits) % 8; - else + else dat_len = 8; - if(*buf_len > dat_len) { + if(*buf_len > dat_len) { data[data_offset + k] = ((val >> (*buf_len - dat_len)) & ~(~0 << dat_len)); *buf_len -= dat_len; @@ -1424,12 +1423,12 @@ int begin_i, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p, int val = buffer[*j]; data[data_offset + k] |= ((val >> (*buf_len - dat_len)) & ~(~0 << dat_len)); - *buf_len -= dat_len; + *buf_len -= dat_len; } } -static void H5Z_scaleoffset_decompress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p) +static void H5Z_scaleoffset_decompress_one_atomic(unsigned char *data, size_t data_offset, + unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p) { /* begin_i: the index of byte having first significant bit */ int k, begin_i, dtype_len; @@ -1441,41 +1440,41 @@ static void H5Z_scaleoffset_decompress_one_atomic(unsigned char *data, size_t da if(p.mem_order == H5Z_SCALEOFFSET_ORDER_LE) { /* little endian */ begin_i = p.size - 1 - (dtype_len - p.minbits) / 8; - for(k = begin_i; k >= 0; k--) - H5Z_scaleoffset_decompress_one_byte(data, data_offset, k, begin_i, + for(k = begin_i; k >= 0; k--) + H5Z_scaleoffset_decompress_one_byte(data, data_offset, k, begin_i, buffer, j, buf_len, p, dtype_len); } if(p.mem_order == H5Z_SCALEOFFSET_ORDER_BE) { /* big endian */ begin_i = (dtype_len - p.minbits) / 8; - for(k = begin_i; k <= p.size - 1; k++) - H5Z_scaleoffset_decompress_one_byte(data, data_offset, k, begin_i, + for(k = begin_i; k <= p.size - 1; k++) + H5Z_scaleoffset_decompress_one_byte(data, data_offset, k, begin_i, buffer, j, buf_len, p, dtype_len); - } + } } -static void H5Z_scaleoffset_decompress(unsigned char *data, unsigned d_nelmts, - unsigned char *buffer, parms_atomic p) +static void H5Z_scaleoffset_decompress(unsigned char *data, unsigned d_nelmts, + unsigned char *buffer, parms_atomic p) { - /* i: index of data, j: index of buffer, + /* i: index of data, j: index of buffer, buf_len: number of bits to be filled in current byte */ size_t i, j; - int buf_len; + int buf_len; - /* must initialize to zeros */ - for(i = 0; i < d_nelmts*p.size; i++) data[i] = 0; - - /* initialization before the loop */ - j = 0; - buf_len = sizeof(unsigned char) * 8; + /* must initialize to zeros */ + for(i = 0; i < d_nelmts*p.size; i++) data[i] = 0; + + /* initialization before the loop */ + j = 0; + buf_len = sizeof(unsigned char) * 8; /* decompress */ - for(i = 0; i < d_nelmts; i++) + for(i = 0; i < d_nelmts; i++) H5Z_scaleoffset_decompress_one_atomic(data, i*p.size, buffer, &j, &buf_len, p); } -static void H5Z_scaleoffset_compress_one_byte(unsigned char *data, size_t data_offset, int k, +static void H5Z_scaleoffset_compress_one_byte(unsigned char *data, size_t data_offset, int k, int begin_i, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p, int dtype_len) { int dat_len; /* dat_len is the number of bits to be copied in each data byte */ @@ -1483,12 +1482,12 @@ int begin_i, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p, int /* initialize value and bits of unsigned char to be copied */ val = data[data_offset + k]; - if(k == begin_i) + if(k == begin_i) dat_len = 8 - (dtype_len - p.minbits) % 8; else dat_len = 8; - if(*buf_len > dat_len) { + if(*buf_len > dat_len) { buffer[*j] |= (val & ~(~0 << dat_len)) << (*buf_len - dat_len); *buf_len -= dat_len; } else { @@ -1498,12 +1497,12 @@ int begin_i, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p, int if(dat_len == 0) return; buffer[*j] = (val & ~(~0 << dat_len)) << (*buf_len - dat_len); - *buf_len -= dat_len; + *buf_len -= dat_len; } } -static void H5Z_scaleoffset_compress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p) +static void H5Z_scaleoffset_compress_one_atomic(unsigned char *data, size_t data_offset, + unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p) { /* begin_i: the index of byte having first significant bit */ int k, begin_i, dtype_len; @@ -1515,38 +1514,38 @@ static void H5Z_scaleoffset_compress_one_atomic(unsigned char *data, size_t data if(p.mem_order == H5Z_SCALEOFFSET_ORDER_LE) { /* little endian */ begin_i = p.size - 1 - (dtype_len - p.minbits) / 8; - for(k = begin_i; k >= 0; k--) - H5Z_scaleoffset_compress_one_byte(data, data_offset, k, begin_i, + for(k = begin_i; k >= 0; k--) + H5Z_scaleoffset_compress_one_byte(data, data_offset, k, begin_i, buffer, j, buf_len, p, dtype_len); } if(p.mem_order == H5Z_SCALEOFFSET_ORDER_BE) { /* big endian */ begin_i = (dtype_len - p.minbits) / 8; - for(k = begin_i; k <= p.size - 1; k++) - H5Z_scaleoffset_compress_one_byte(data, data_offset, k, begin_i, + for(k = begin_i; k <= p.size - 1; k++) + H5Z_scaleoffset_compress_one_byte(data, data_offset, k, begin_i, buffer, j, buf_len, p, dtype_len); - } + } } -static void H5Z_scaleoffset_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, - size_t buffer_size, parms_atomic p) +static void H5Z_scaleoffset_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, + size_t buffer_size, parms_atomic p) { - /* i: index of data, j: index of buffer, + /* i: index of data, j: index of buffer, buf_len: number of bits to be filled in current byte */ size_t i, j; - int buf_len; + int buf_len; /* must initialize buffer to be zeros */ - for(j = 0; j < buffer_size; j++) + for(j = 0; j < buffer_size; j++) buffer[j] = 0; - /* initialization before the loop */ - j = 0; - buf_len = sizeof(unsigned char) * 8; + /* initialization before the loop */ + j = 0; + buf_len = sizeof(unsigned char) * 8; /* compress */ - for(i = 0; i < d_nelmts; i++) + for(i = 0; i < d_nelmts; i++) H5Z_scaleoffset_compress_one_atomic(data, i*p.size, buffer, &j, &buf_len, p); } #endif /* H5_HAVE_FILTER_SCALEOFFSET */ diff --git a/test/dsets.c b/test/dsets.c index effdc41..197202b 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -3800,7 +3800,7 @@ test_scaleoffset_int(hid_t file) /* Set up to use scaleoffset filter, let library calculate minbits */ if (H5Pset_chunk(dc, 2, chunk_size)<0) goto error; - if (H5Pset_scaleoffset(dc, H5_SO_INT,H5_SO_INT_MINBITS_DEFAULT)<0) goto error; + if (H5Pset_scaleoffset(dc, H5Z_SO_INT,H5Z_SO_INT_MINBITS_DEFAULT)<0) goto error; /* Create the dataset */ if ((dataset = H5Dcreate(file, DSET_SCALEOFFSET_INT_NAME, datatype, @@ -3936,7 +3936,7 @@ test_scaleoffset_int_2(hid_t file) /* Set up to use scaleoffset filter, let library calculate minbits */ if (H5Pset_chunk(dc, 2, chunk_size)<0) goto error; - if (H5Pset_scaleoffset(dc, H5_SO_INT,H5_SO_INT_MINBITS_DEFAULT)<0) goto error; + if (H5Pset_scaleoffset(dc, H5Z_SO_INT,H5Z_SO_INT_MINBITS_DEFAULT)<0) goto error; /* Create the dataset */ if ((dataset = H5Dcreate(file, DSET_SCALEOFFSET_INT_NAME_2, datatype, @@ -4079,7 +4079,7 @@ test_scaleoffset_float(hid_t file) * use variable-minimum-bits method */ if (H5Pset_chunk(dc, 2, chunk_size)<0) goto error; - if (H5Pset_scaleoffset(dc, H5_SO_FLOAT_DSCALE,3)<0) goto error; + if (H5Pset_scaleoffset(dc, H5Z_SO_FLOAT_DSCALE,3)<0) goto error; /* Create the dataset */ if ((dataset = H5Dcreate(file, DSET_SCALEOFFSET_FLOAT_NAME, datatype, @@ -4217,7 +4217,7 @@ test_scaleoffset_float_2(hid_t file) * use variable-minimum-bits method */ if (H5Pset_chunk(dc, 2, chunk_size)<0) goto error; - if (H5Pset_scaleoffset(dc, H5_SO_FLOAT_DSCALE,3)<0) goto error; + if (H5Pset_scaleoffset(dc, H5Z_SO_FLOAT_DSCALE,3)<0) goto error; /* Create the dataset */ if ((dataset = H5Dcreate(file, DSET_SCALEOFFSET_FLOAT_NAME_2, datatype, @@ -4359,7 +4359,7 @@ test_scaleoffset_double(hid_t file) * use variable-minimum-bits method */ if (H5Pset_chunk(dc, 2, chunk_size)<0) goto error; - if (H5Pset_scaleoffset(dc, H5_SO_FLOAT_DSCALE,7)<0) goto error; + if (H5Pset_scaleoffset(dc, H5Z_SO_FLOAT_DSCALE,7)<0) goto error; /* Create the dataset */ if ((dataset = H5Dcreate(file, DSET_SCALEOFFSET_DOUBLE_NAME, datatype, @@ -4497,7 +4497,7 @@ test_scaleoffset_double_2(hid_t file) * use variable-minimum-bits method */ if (H5Pset_chunk(dc, 2, chunk_size)<0) goto error; - if (H5Pset_scaleoffset(dc, H5_SO_FLOAT_DSCALE,7)<0) goto error; + if (H5Pset_scaleoffset(dc, H5Z_SO_FLOAT_DSCALE,7)<0) goto error; /* Create the dataset */ if ((dataset = H5Dcreate(file, DSET_SCALEOFFSET_DOUBLE_NAME_2, datatype, diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index 0dcde7f..4f1c0f5 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -4664,7 +4664,7 @@ static void gent_filters(void) assert(ret>=0); /* set the scaleoffset filter */ - ret=H5Pset_scaleoffset(dcpl,2,H5Tget_size(H5T_NATIVE_INT)); + ret=H5Pset_scaleoffset(dcpl,H5Z_SO_INT,H5Tget_size(H5T_NATIVE_INT)); assert(ret>=0); ret=make_dset(fid,"scaleoffset",sid,H5T_NATIVE_INT,dcpl,buf1); diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c index 1eea971..db3277b 100644 --- a/tools/h5repack/h5repack_filters.c +++ b/tools/h5repack/h5repack_filters.c @@ -392,7 +392,7 @@ int apply_filters(const char* name, /* object name from traverse list */ /* The following line needs to be changed in the future, H5_SO_INT needs to be passed as a parameter, it can be either H5_SO_FLOAT_DSCALE or H5_SO_INT. KY, 2005/8/31 */ - if (H5Pset_scaleoffset(dcpl_id,H5_SO_INT,aggression)<0) + if (H5Pset_scaleoffset(dcpl_id,H5Z_SO_INT,aggression)<0) return -1; break; } /* switch */ diff --git a/tools/h5repack/testh5repack_make.c b/tools/h5repack/testh5repack_make.c index 757f11f..5213043 100644 --- a/tools/h5repack/testh5repack_make.c +++ b/tools/h5repack/testh5repack_make.c @@ -786,7 +786,7 @@ int make_scaleoffset(hid_t loc_id) H5Tclose(dtid); goto out; } - if (H5Pset_scaleoffset(dcpl,H5_SO_INT,31)<0) + if (H5Pset_scaleoffset(dcpl,H5Z_SO_INT,31)<0) { H5Tclose(dtid); goto out; |