From 89ed8ceec247d050e6962da876443bb864f08eb5 Mon Sep 17 00:00:00 2001 From: "Robert E. McGrath" Date: Mon, 21 Feb 2005 14:27:56 -0500 Subject: [svn-r10060] Purpose: feature Description: h5dump support for scaleoffset compression Solution: Platforms tested: verbena, shanti,copper64 Misc. update: --- tools/h5dump/h5dump.c | 4 ++++ tools/h5dump/h5dumpgentest.c | 24 ++++++++++++++++++++++++ tools/h5dump/testh5dump.sh.in | 10 +++++++++- tools/lib/h5tools.h | 2 ++ tools/lib/h5tools_filters.c | 26 ++++++++++++++++++++++++++ tools/testfiles/tallfilters.ddl | 1 + tools/testfiles/test_all.h5 | Bin 28062 -> 34408 bytes tools/testfiles/tfilters.h5 | Bin 43384 -> 46272 bytes tools/testfiles/tscaleoffset.ddl | 23 +++++++++++++++++++++++ 9 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 tools/testfiles/tscaleoffset.ddl diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index f241c8f..637dd71 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -2352,6 +2352,10 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) indentation(indent + COL); printf("%s\n", NBIT); break; + case H5Z_FILTER_SCALEOFFSET: + indentation(indent + COL); + printf("%s %s %s %d %s\n", SCALEOFFSET, BEGIN, SCALEOFFSET_MINBIT, cd_values[0], END); + break; default: indentation(indent + COL); if (H5Zfilter_avail(filtn)) diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index 23da7e8..b01d87a 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -4649,6 +4649,24 @@ static void gent_filters(void) ret=make_dset(fid,"nbit",sid,tid,dcpl,buf1); assert(ret>=0); #endif + +/*------------------------------------------------------------------------- + * scaleoffset + *------------------------------------------------------------------------- + */ +#if defined (H5_HAVE_FILTER_SCALEOFFSET) + /* remove the filters from the dcpl */ + ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL); + assert(ret>=0); + + /* set the scaleoffset filter */ + ret=H5Pset_scaleoffset(dcpl,H5Tget_size(H5T_NATIVE_INT)); + assert(ret>=0); + + ret=make_dset(fid,"scaleoffset",sid,H5T_NATIVE_INT,dcpl,buf1); + assert(ret>=0); +#endif + /*------------------------------------------------------------------------- * all filters *------------------------------------------------------------------------- @@ -4684,6 +4702,12 @@ static void gent_filters(void) assert(ret>=0); #endif +#if defined (H5_HAVE_FILTER_NBIT) + /* set the nbit filter */ + ret=H5Pset_nbit(dcpl); + assert(ret>=0); +#endif + ret=make_dset(fid,"all",sid,H5T_NATIVE_INT,dcpl,buf1); assert(ret>=0); diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 215a124..5cd2e46 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -20,6 +20,7 @@ USE_FILTER_DEFLATE="@USE_FILTER_DEFLATE@" USE_FILTER_SHUFFLE="@USE_FILTER_SHUFFLE@" USE_FILTER_FLETCHER32="@USE_FILTER_FLETCHER32@" USE_FILTER_NBIT="@USE_FILTER_NBIT@" +USE_FILTER_SCALEOFFSET="@USE_FILTER_SCALEOFFSET@" DUMPER=h5dump # The tool name DUMPER_BIN=`pwd`/$DUMPER # The path of the tool binary @@ -290,9 +291,16 @@ if test $USE_FILTER_NBIT != "yes"; then else TOOLTEST tnbit.ddl $option fi +# scaleoffset +option="-H -p -d scaleoffset tfilters.h5" +if test $USE_FILTER_SCALEOFFSET != "yes"; then + SKIP $option +else + TOOLTEST tscaleoffset.ddl $option +fi # all option="-H -p -d all tfilters.h5" -if test $USE_FILTER_FLETCHER32 != "yes" -o $USE_FILTER_SZIP != "yes" -o $USE_FILTER_DEFLATE != "yes" -o $USE_FILTER_SHUFFLE != "yes" ; then +if test $USE_FILTER_FLETCHER32 != "yes" -o $USE_FILTER_SZIP != "yes" -o $USE_FILTER_DEFLATE != "yes" -o $USE_FILTER_SHUFFLE != "yes" -o $USE_FILTER_NBIT != "yes" -o $USE_FILTER_SCALEOFFSET != "yes"; then SKIP $option else TOOLTEST tallfilters.ddl $option diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index be6ba36..3fae481 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -483,6 +483,8 @@ extern FILE *rawdatastream; /*output stream for raw data */ #define FLETCHER32 "CHECKSUM FLETCHER32" #define SZIP "COMPRESSION SZIP" #define NBIT "COMPRESSION NBIT" +#define SCALEOFFSET "COMPRESSION SCALEOFFSET" +#define SCALEOFFSET_MINBIT "MIN BITS" #define STORAGE_LAYOUT "STORAGE_LAYOUT" #define CONTIGUOUS "CONTIGUOUS" #define COMPACT "COMPACT" diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c index 863f39c..355ac14 100644 --- a/tools/lib/h5tools_filters.c +++ b/tools/lib/h5tools_filters.c @@ -53,6 +53,7 @@ int h5tools_canreadf(const char* name, /* object name, serves also as boolean pr int have_shuffle=0; int have_fletcher=0; int have_nbit=0; + int have_scaleoffset=0; #ifdef H5_HAVE_FILTER_DEFLATE have_deflate=1; @@ -69,6 +70,9 @@ int h5tools_canreadf(const char* name, /* object name, serves also as boolean pr #ifdef H5_HAVE_FILTER_NBIT have_nbit=1; #endif +#ifdef H5_HAVE_FILTER_SCALEOFFSET + have_scaleoffset=1; +#endif /* get information about filters */ @@ -160,6 +164,18 @@ int h5tools_canreadf(const char* name, /* object name, serves also as boolean pr return 0; } break; +/*------------------------------------------------------------------------- + * H5Z_FILTER_SCALEOFFSET + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_SCALEOFFSET: + if (!have_scaleoffset) + { + if (name) + print_warning(name,"scaleoffset"); + return 0; + } + break; }/*switch*/ }/*for*/ @@ -190,6 +206,7 @@ int h5tools_can_encode( H5Z_filter_t filtn) int have_shuffle=0; int have_fletcher=0; int have_nbit=0; + int have_scaleoffset=0; unsigned int filter_config_flags; #ifdef H5_HAVE_FILTER_DEFLATE @@ -207,6 +224,9 @@ int h5tools_can_encode( H5Z_filter_t filtn) #ifdef H5_HAVE_FILTER_NBIT have_nbit=1; #endif +#ifdef H5_HAVE_FILTER_SCALEOFFSET + have_scaleoffset=1; +#endif switch (filtn) { @@ -265,6 +285,12 @@ int h5tools_can_encode( H5Z_filter_t filtn) return 0; } break; + case H5Z_FILTER_SCALEOFFSET: + if (!have_scaleoffset) + { + return 0; + } + break; }/*switch*/ return 1; diff --git a/tools/testfiles/tallfilters.ddl b/tools/testfiles/tallfilters.ddl index e3121d8..282c085 100644 --- a/tools/testfiles/tallfilters.ddl +++ b/tools/testfiles/tallfilters.ddl @@ -20,6 +20,7 @@ DATASET "all" { } COMPRESSION DEFLATE { LEVEL 5 } CHECKSUM FLETCHER32 + COMPRESSION NBIT } FILLVALUE { FILL_TIME H5D_FILL_TIME_IFSET diff --git a/tools/testfiles/test_all.h5 b/tools/testfiles/test_all.h5 index a2a68fb..5099bb6 100644 Binary files a/tools/testfiles/test_all.h5 and b/tools/testfiles/test_all.h5 differ diff --git a/tools/testfiles/tfilters.h5 b/tools/testfiles/tfilters.h5 index 51a3207..5b5f4bb 100644 Binary files a/tools/testfiles/tfilters.h5 and b/tools/testfiles/tfilters.h5 differ diff --git a/tools/testfiles/tscaleoffset.ddl b/tools/testfiles/tscaleoffset.ddl new file mode 100644 index 0000000..6693f92 --- /dev/null +++ b/tools/testfiles/tscaleoffset.ddl @@ -0,0 +1,23 @@ +############################# +Expected output for 'h5dump -H -p -d scaleoffset tfilters.h5' +############################# +HDF5 "tfilters.h5" { +DATASET "scaleoffset" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 20, 10 ) / ( 20, 10 ) } + STORAGE_LAYOUT { + CHUNKED ( 10, 5 ) + SIZE 152 + } + FILTERS { + COMPRESSION SCALEOFFSET { MIN BITS 4 } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE 0 + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } +} +} -- cgit v0.12