Skip to content
Snippets Groups Projects
Commit 377a2f35 authored by Jens Henrik Goebbert's avatar Jens Henrik Goebbert
Browse files

more work on compress

parent f3386558
Branches
No related tags found
No related merge requests found
...@@ -509,25 +509,31 @@ H5Z_filter_sz(unsigned int flags, ...@@ -509,25 +509,31 @@ H5Z_filter_sz(unsigned int flags,
// compress data // compress data
} else { } else {
// 00 - version >> 4; /* major version */
// 01 - version & 0x000f; /* minor version */
// 02 - dsize; /* bytes per element */
// 03 - ndims; /* number of dimensions */
// -------------
// 04 - size of dim 1
// 05 - size of dim 2
// 06 - size of dim 3
// 07 - size of dim 4
// 08 - size of dim 5
// -------------
// x+00 - params.errorBoundMode = REL;
// x+01 - params.absErrBound_ppm
// x+02 - params.relBoundRatio_ppm
// x+03 - params.gzipMode
// x+04 - threshold = 64 (no compression below 64 byte)
// compression parameter (0 == no compression) // compression parameter (0 == no compression)
// uint minbits = cd_values[4+ndims +0]; // minimum number of bits per 4^d values in d dimensions (= maxbits for fixed rate) sz_params params;
// uint maxbits = cd_values[4+ndims +1]; // maximum number of bits per 4^d values in d dimensions params.errorBoundMode = cd_values[4+ndims +0];
// uint maxprec = cd_values[4+ndims +2]; // maximum number of bits of precision per value (0 for fixed rate) params.absErrBound = cd_values[4+ndims +1] * 1e-6;
// int minexp = cd_values[4+ndims +3]; // minimum bit plane coded (soft error tolerance = 2^minexp; -1024 for fixed rate) params.relBoundRatio = cd_values[4+ndims +2] * 1e-6;
params.gzipMode = cd_values[4+ndims +3];
// // correct compression parameters if zero initialized
// uint blocksize = 1u << (2 * ndims); // number of floating-point values per block uint8_t header_bytes = 22;
// if(minbits <= 0 || minbits > 4096) minbits = blocksize * CHAR_BIT * typesize; // {1, ..., 4096} == 12 bits
// if(maxbits <= 0 || maxbits > 4096) maxbits = blocksize * CHAR_BIT * typesize; // {1, ..., 4096} == 12 bits
// if(maxprec <= 0 || maxprec > 64) maxprec = CHAR_BIT * typesize; // {1, ..., 64} == 6 bits
// if(minexp < -1074) minexp = -1074; // {-1074, ..., 1023} == 12 bits
// if(minexp > 1023) minexp = 1023;
// set compression parameters
// params.minbits = minbits;
// params.maxbits = maxbits;
// params.maxprec = maxprec;
// params.minexp = minexp;
// max.(!) size of compressed data // max.(!) size of compressed data
size_t buf_size_maxout = buf_size_in; size_t buf_size_maxout = buf_size_in;
...@@ -537,14 +543,14 @@ H5Z_filter_sz(unsigned int flags, ...@@ -537,14 +543,14 @@ H5Z_filter_sz(unsigned int flags,
} }
// allocate for header + compressed data // allocate for header + compressed data
tmp_buf = malloc(buf_size_maxout +22); tmp_buf = malloc(buf_size_maxout +header_bytes);
if (tmp_buf == NULL) { if (tmp_buf == NULL) {
PUSH_ERR("H5Z_filter_sz", H5E_CALLBACK, "Could not allocate output buffer."); PUSH_ERR("H5Z_filter_sz", H5E_CALLBACK, "Could not allocate output buffer.");
return 0; return 0;
} }
// ptr to data (skipping header) // ptr to data (skipping header)
sz_buf = (char*) tmp_buf +36; sz_buf = (char*) tmp_buf +header_bytes;
// int SZ_compress_args( // int SZ_compress_args(
// int dataType, SZ_FLOAT or SZ_DOUBLE (float not supported, yet) // int dataType, SZ_FLOAT or SZ_DOUBLE (float not supported, yet)
...@@ -557,6 +563,12 @@ H5Z_filter_sz(unsigned int flags, ...@@ -557,6 +563,12 @@ H5Z_filter_sz(unsigned int flags,
// int r5, int r4, int r3, int r2, int r1); =0 if dim not required // int r5, int r4, int r3, int r2, int r1); =0 if dim not required
// return 1 on failure, 0 on success // return 1 on failure, 0 on success
// if(SZ_compress_args() != 0) { // if(SZ_compress_args() != 0) {
((typesize == 8) ? SZ_DOUBLE : SZ_FLOAT), /* dataType */
(char*) sz_buf, /* compressed data */
nbytes header_bytes, /* length of the compressed data stream */
out_buf, /* decompressed floating-point data */
n[4], n[3], n[2], n[1], n[0] /* size of dimension 5-1 */
// PUSH_ERR("H5Z_filter_sz", H5E_CALLBACK, "compression failed"); // PUSH_ERR("H5Z_filter_sz", H5E_CALLBACK, "compression failed");
// free(out_buf); // free(out_buf);
// return 0; // return 0;
...@@ -569,18 +581,20 @@ H5Z_filter_sz(unsigned int flags, ...@@ -569,18 +581,20 @@ H5Z_filter_sz(unsigned int flags,
// (int)buf_size_out); // (int)buf_size_out);
#endif #endif
// add 36byte header // add 22byte header
sz_write_int32 ((char*) tmp_buf + 0, ( int32_t) params.sol_ID);
sz_write_int32 ((char*) tmp_buf + 4, ( int32_t) params.offset);
sz_write_int32 ((char*) tmp_buf + 8, ( int32_t) params.gzipMode); sz_write_uint8 ((char*) tmp_buf + 1, ( uint8_t) params.dataEndianType
sz_write_int32 ((char*) tmp_buf +12, ( int32_t) params.maxSegmentNum); sz_write_uint8 ((char*) tmp_buf + 2, ( uint8_t) params.errorBoundMode
sz_write_int32 ((char*) tmp_buf +16, ( int32_t) params.spaceFillingCurveTransform); sz_write_int32 ((char*) tmp_buf + 3, ( int32_t) params.absErrBound
sz_write_int32 ((char*) tmp_buf +20, ( int32_t) params.reOrgSize); sz_write_int32 ((char*) tmp_buf + 7, ( int32_t) params.relBoundRatio
sz_write_int32 ((char*) tmp_buf +24, ( int32_t) params.errorBoundMode); sz_write_uint8 ((char*) tmp_buf + 11, ( uint8_t) params.gzipMode
sz_write_int32 ((char*) tmp_buf +28, ( int32_t) params.absErrBound); sz_write_uint8 ((char*) tmp_buf + 12, ( uint8_t) params.offset
sz_write_int32 ((char*) tmp_buf +32, ( int32_t) params.relBoundRatio); sz_write_int32 ((char*) tmp_buf + 13, ( int32_t) params.maxSegmentNum
sz_write_uint8 ((char*) tmp_buf + 17, ( uint8_t) params.spaceFillingCurveTransform
nbytes_out = buf_size_out +36; sz_write_int32 ((char*) tmp_buf + 18, ( int32_t) params.reOrgSize
nbytes_out = buf_size_out +header_bytes;
// realloc (free partly) if required // realloc (free partly) if required
// if(buf_size_out < buf_size_maxout) { // if(buf_size_out < buf_size_maxout) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment