Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/bshuf_h5filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ size_t bshuf_h5_filter(unsigned int flags, size_t cd_nelmts,
}
size = nbytes_uncomp / elem_size;

out_buf = malloc(buf_size_out);
out_buf = H5allocate_memory(buf_size_out, false);
if (out_buf == NULL) {
PUSH_ERR("bshuf_h5_filter", H5E_CALLBACK,
"Could not allocate output buffer.");
Expand All @@ -166,24 +166,31 @@ size_t bshuf_h5_filter(unsigned int flags, size_t cd_nelmts,
bshuf_write_uint64_BE(out_buf, nbytes_uncomp);
bshuf_write_uint32_BE((char*) out_buf + 8, block_size * elem_size);
err = bshuf_compress_lz4(in_buf, (char*) out_buf + 12, size,
elem_size, block_size); nbytes_out = err + 12; } } else {
if (flags & H5Z_FLAG_REVERSE) {
elem_size, block_size);
nbytes_out = err + 12;
}
} else {
if (flags & H5Z_FLAG_REVERSE) {
// Bit unshuffle.
err = bshuf_bitunshuffle(in_buf, out_buf, size, elem_size,
block_size); } else {
block_size);
} else {
// Bit shuffle.
err = bshuf_bitshuffle(in_buf, out_buf, size, elem_size,
block_size); } nbytes_out = nbytes; }
block_size);
}
nbytes_out = nbytes;
}
//printf("nb_in %d, nb_uncomp %d, nb_out %d, buf_out %d, block %d\n",
//nbytes, nbytes_uncomp, nbytes_out, buf_size_out, block_size);

if (err < 0) {
sprintf(msg, "Error in bitshuffle with error code %d.", err);
PUSH_ERR("bshuf_h5_filter", H5E_CALLBACK, msg);
free(out_buf);
H5free_memory(out_buf);
return 0;
} else {
free(*buf);
H5free_memory(*buf);
*buf = out_buf;
*buf_size = buf_size_out;

Expand Down
2 changes: 1 addition & 1 deletion src/bshuf_h5filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#define BSHUF_H5_COMPRESS_LZ4 2


extern H5Z_class_t bshuf_H5Filter[1];
H5_DLLVAR H5Z_class_t bshuf_H5Filter[1];


/* ---- bshuf_register_h5filter ----
Expand Down