summaryrefslogtreecommitdiffstats
path: root/src/H5Zshuffle.c
diff options
context:
space:
mode:
authorMuQun Yang <ymuqun@hdfgroup.org>2002-11-13 16:35:11 (GMT)
committerMuQun Yang <ymuqun@hdfgroup.org>2002-11-13 16:35:11 (GMT)
commit55de236da8c16b94f6c8bec17cadc3ca69daed90 (patch)
treea2f70b7aa2ff865492edd7725ca9e6e0b54b3814 /src/H5Zshuffle.c
parent9646b2464cff1ed996517fe9c30b046a76739b23 (diff)
downloadhdf5-55de236da8c16b94f6c8bec17cadc3ca69daed90.zip
hdf5-55de236da8c16b94f6c8bec17cadc3ca69daed90.tar.gz
hdf5-55de236da8c16b94f6c8bec17cadc3ca69daed90.tar.bz2
[svn-r6087]
Purpose: Adding internal shuffle filter Description: With the combination of shuffling filter with general compression algorithm, the compression ratio may be improved without adding much encoding and decoding time for many real NASA datasets(especially floating data) and other application datasets(See techNotes). Solution: SHuffle the bytes within the data to utilize the locality. Platforms tested: arabica , eirene, modi4 Misc. update: Update MANIFEST if you add or remove any file. Update release_docs/RELEASE for bug fixes, new features, etc. Update applicable document files too.
Diffstat (limited to 'src/H5Zshuffle.c')
-rw-r--r--src/H5Zshuffle.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/H5Zshuffle.c b/src/H5Zshuffle.c
new file mode 100644
index 0000000..61dcc4f
--- /dev/null
+++ b/src/H5Zshuffle.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright © 1999-2001 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Friday, August 27, 1999
+ */
+#include "H5private.h"
+#include "H5Eprivate.h"
+#include "H5MMprivate.h"
+#include "H5Zprivate.h"
+#include <stdio.h>
+
+#ifdef H5_HAVE_FILTER_SHUFFLE
+
+size_t H5Z_filter_shuffle(unsigned flags,
+ size_t cd_nelmts,
+ const unsigned cd_values[],
+ size_t nbytes,
+ size_t *buf_size,void **buf) {
+
+ size_t i;
+ size_t j;
+ size_t k;
+ size_t ret_value = 0;
+ size_t byte_pos;
+ size_t bytesoftype;
+ void* dest = NULL;
+ char* _src;
+ char* _des;
+ char* _dest;
+ size_t numofelements;
+
+ bytesoftype=cd_values[0];
+ numofelements=nbytes/bytesoftype;
+ _src =(char*)(*buf);
+
+ dest = malloc((size_t)nbytes);
+ _dest =(char*)dest;
+
+ j = 0;
+ k = 0;
+ if(flags & H5Z_FLAG_REVERSE) {
+ for(i=0;i<nbytes;i++) {
+ byte_pos = 1 +j *numofelements;
+ if(byte_pos > nbytes) {
+ k++;
+ j=0;
+ byte_pos=1;
+ }
+ *(_dest+i)=*((char*)(_src+byte_pos-1+k));
+ j++;
+ }
+ free(*buf);
+ *buf = dest;
+ dest = NULL;
+ *buf_size=nbytes;
+ ret_value = nbytes;
+ }
+
+ else {
+ for (i=0;i<nbytes;i++){
+ byte_pos = 1+j * bytesoftype;
+ if(byte_pos >nbytes) {
+ k++;
+ j=0;
+ byte_pos = 1;
+ }
+
+ *(_dest+i)=*(_src+byte_pos-1+k);
+ j++;
+ }
+ free(*buf);
+ *buf = dest;
+ dest = NULL;
+ *buf_size=nbytes;
+ ret_value = nbytes;
+ }
+
+}
+#endif /*H5_HAVE_FILTER_SHUFFLE */