Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hdf5plugins
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
goebbert
hdf5plugins
Commits
377a2f35
Commit
377a2f35
authored
Aug 25, 2016
by
Jens Henrik Goebbert
Browse files
Options
Downloads
Patches
Plain Diff
more work on compress
parent
f3386558
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
hdf5plugin_sz/src/sz_h5filter.cpp
+46
-32
46 additions, 32 deletions
hdf5plugin_sz/src/sz_h5filter.cpp
with
46 additions
and
32 deletions
hdf5plugin_sz/src/sz_h5filter.cpp
+
46
−
32
View file @
377a2f35
...
@@ -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) {
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment