diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2020-05-15 12:02:37 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2020-05-15 12:02:37 (GMT) |
commit | 730d6cc53f3914f951e1177fc29835486b61dcdb (patch) | |
tree | 5e730157957cd611c1ff8fd4a13030c4340e1121 /hl/tools | |
parent | 4328846bde89b58e42f0cc6ba165092f91717b25 (diff) | |
download | hdf5-730d6cc53f3914f951e1177fc29835486b61dcdb.zip hdf5-730d6cc53f3914f951e1177fc29835486b61dcdb.tar.gz hdf5-730d6cc53f3914f951e1177fc29835486b61dcdb.tar.bz2 |
Normalization of high-level library with develop. Also brings the
warnhist script over.
Diffstat (limited to 'hl/tools')
-rw-r--r-- | hl/tools/gif2h5/Makefile.am | 6 | ||||
-rw-r--r-- | hl/tools/gif2h5/decompress.c | 23 | ||||
-rw-r--r-- | hl/tools/gif2h5/h52giftest.sh.in | 14 | ||||
-rw-r--r-- | hl/tools/gif2h5/hdfgifwr.c | 96 | ||||
-rw-r--r-- | hl/tools/h5watch/extend_dset.c | 8 | ||||
-rw-r--r-- | hl/tools/h5watch/h5watchgentest.c | 30 | ||||
-rw-r--r-- | hl/tools/h5watch/swmr_check_compat_vfd.c | 2 |
7 files changed, 103 insertions, 76 deletions
diff --git a/hl/tools/gif2h5/Makefile.am b/hl/tools/gif2h5/Makefile.am index 9ffde58..9de2135 100644 --- a/hl/tools/gif2h5/Makefile.am +++ b/hl/tools/gif2h5/Makefile.am @@ -29,9 +29,9 @@ bin_PROGRAMS=gif2h5 h52gif h52gif_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) gif2h5_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) -gif2h5_SOURCES=gif2hdf.c gif2mem.c decompress.c gifread.c writehdf.c +gif2h5_SOURCES=gif2hdf.c gif2mem.c decompress.c gifread.c writehdf.c -h52gif_SOURCES=hdf2gif.c hdfgifwr.c +h52gif_SOURCES=hdf2gif.c hdfgifwr.c # Programs all depend on the hdf5 library, the tools library, and the HL @@ -42,7 +42,7 @@ if BUILD_TESTS_CONDITIONAL TEST_SCRIPT=h52giftest.sh check_SCRIPTS=$(TEST_SCRIPT) noinst_PROGRAMS=h52gifgentst - h52gifgentst_SOURCES=h52gifgentst.c + h52gifgentst_SOURCES=h52gifgentst.c endif CHECK_CLEANFILES+=*.h5 diff --git a/hl/tools/gif2h5/decompress.c b/hl/tools/gif2h5/decompress.c index 8cd8a8e..129fa60 100644 --- a/hl/tools/gif2h5/decompress.c +++ b/hl/tools/gif2h5/decompress.c @@ -57,12 +57,12 @@ GIFBYTE *Raster; /* The raster data stream, unblocked * /* The hash table used by the decompressor */ -int Prefix[4096]; -int Suffix[4096]; +int *Prefix; +int *Suffix; /* An output array used by the decompressor */ -int OutCode[1025]; +int *OutCode; /* The color map, read from the GIF header */ @@ -159,6 +159,19 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) { int i; + if (!(Prefix = calloc(4096, sizeof(int)))) { + printf("Out of memory"); + exit(EXIT_FAILURE); + } + if (!(Suffix = calloc(4096, sizeof(int)))) { + printf("Out of memory"); + exit(EXIT_FAILURE); + } + if (!(OutCode = calloc(1024, sizeof(int)))) { + printf("Out of memory"); + exit(EXIT_FAILURE); + } + XC = 0; YC = 0; Pass = 0; @@ -309,5 +322,9 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) Code = ReadCode(); } + free(Prefix); + free(Suffix); + free(OutCode); + return Image; } diff --git a/hl/tools/gif2h5/h52giftest.sh.in b/hl/tools/gif2h5/h52giftest.sh.in index 5643e30..02c9e89 100644 --- a/hl/tools/gif2h5/h52giftest.sh.in +++ b/hl/tools/gif2h5/h52giftest.sh.in @@ -70,20 +70,20 @@ echo "" # Positive tests for h52gif echo "**validate the h52gif tool processes input correctly..." -TESTING "./h52gif h52giftst.h5 image1.gif -i image" +TESTING "./h52gif h52giftst.h5 image1.gif -i image" TOOLTEST ./h52gif $TESTFILE1 image1.gif -i image echo "" # Negative tests. echo "**verify that the h52gif tool handles error conditions correctly..." # nonexisting dataset name -TESTING "./h52gif h52giftst.h5 image.gif -i nosuch_image" -TOOLTESTFAIL "./h52gif $TESTFILE1 image.gif -i nosuch_image" +TESTING "./h52gif h52giftst.h5 image.gif -i nosuch_image" +TOOLTESTFAIL "./h52gif $TESTFILE1 image.gif -i nosuch_image" # this test should have failed but it did not. Comment it out for now. -#TESTING "./h52gif h52giftst.h5 image.gif -i palette" -#TOOLTESTFAIL "./h52gif $TESTFILE1 image.gif -i palette" -TESTING "./h52gif h52giftst.h5 image24.gif -i image24bitpixel" -TOOLTESTFAIL "./h52gif $TESTFILE3 image24.gif -i image24bitpixel" +#TESTING "./h52gif h52giftst.h5 image.gif -i palette" +#TOOLTESTFAIL "./h52gif $TESTFILE1 image.gif -i palette" +TESTING "./h52gif h52giftst.h5 image24.gif -i image24bitpixel" +TOOLTESTFAIL "./h52gif $TESTFILE3 image24.gif -i image24bitpixel" echo "" # all done. summarize results. diff --git a/hl/tools/gif2h5/hdfgifwr.c b/hl/tools/gif2h5/hdfgifwr.c index ed3e9e9..d44ff7a 100644 --- a/hl/tools/gif2h5/hdfgifwr.c +++ b/hl/tools/gif2h5/hdfgifwr.c @@ -69,45 +69,6 @@ static void char_init(), char_out(), flush_char(); static byte pc2nc[256]; -/*************************************************************/ -int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap, - byte *gmap, byte *bmap, byte *pc2ncmap, int numcols, - int colorstyle, int BitsPerPixel) -{ - int InitCodeSize; - int i; - byte *pic8 = pic; - - /* Shut compiler up... */ - ptype=ptype; - rmap=rmap; - gmap=gmap; - bmap=bmap; - numcols=numcols; - colorstyle=colorstyle; - - for (i = 0; i < 256; i++) { - pc2nc[i] = pc2ncmap[i]; - } - - if (BitsPerPixel <= 1) - InitCodeSize = 2; - else - InitCodeSize = BitsPerPixel; - - if (!fp) { - fprintf(stderr, "WriteGIF: file not open for writing\n" ); - return (1); - } - - compress(InitCodeSize+1, fp, pic8, w*h); - - if (ferror(fp)) - return -1; - - return 0 ; -} - /***********************************************************************/ static unsigned long cur_accum = 0; static int cur_bits = 0; @@ -123,8 +84,8 @@ static int maxbits = XV_BITS; /* user settable max # bits/code */ static int maxcode; /* maximum code, given n_bits */ static int maxmaxcode = 1 << XV_BITS; /* NEVER generate this */ -static count_int htab [HSIZE]; -static unsigned short codetab [HSIZE]; +static count_int *htab; +static unsigned short *codetab; #define HashTabOf(i) htab[i] #define CodeTabOf(i) codetab[i] @@ -173,6 +134,57 @@ static FILE *g_outfile; static int ClearCode; static int EOFCode; +/*************************************************************/ +int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap, + byte *gmap, byte *bmap, byte *pc2ncmap, int numcols, + int colorstyle, int BitsPerPixel) +{ + int InitCodeSize; + int i; + byte *pic8 = pic; + + if (!(htab = calloc(HSIZE, sizeof(count_int)))) { + fprintf(stderr, "Out of memory"); + return 1; + } + if (!(codetab = calloc(HSIZE, sizeof(unsigned short)))) { + fprintf(stderr, "Out of memory"); + return 1; + } + + /* Shut compiler up... */ + ptype=ptype; + rmap=rmap; + gmap=gmap; + bmap=bmap; + numcols=numcols; + colorstyle=colorstyle; + + for (i = 0; i < 256; i++) { + pc2nc[i] = pc2ncmap[i]; + } + + if (BitsPerPixel <= 1) + InitCodeSize = 2; + else + InitCodeSize = BitsPerPixel; + + if (!fp) { + fprintf(stderr, "WriteGIF: file not open for writing\n"); + return 1; + } + + compress(InitCodeSize+1, fp, pic8, w*h); + + free(htab); + free(codetab); + + if (ferror(fp)) + return -1; + + return 0 ; +} + /********************************************************/ static void compress(int init_bits, FILE *outfile, byte *data, int len) { @@ -194,8 +206,6 @@ static void compress(int init_bits, FILE *outfile, byte *data, int len) /* initialize 'compress' globals */ maxbits = XV_BITS; maxmaxcode = 1<<XV_BITS; - memset(htab, 0, sizeof(htab)); - memset(codetab, 0, sizeof(codetab)); hsize = HSIZE; free_ent = 0; clear_flg = 0; diff --git a/hl/tools/h5watch/extend_dset.c b/hl/tools/h5watch/extend_dset.c index 4dcf25e..6b59ea1 100644 --- a/hl/tools/h5watch/extend_dset.c +++ b/hl/tools/h5watch/extend_dset.c @@ -66,7 +66,7 @@ typedef struct set_t { * * Extending a two-dimensional dataset by action1 and action2. * --action1 and action2 can be a positive # or negative # or 0. - * + * *********************************************************************** */ static herr_t @@ -399,12 +399,12 @@ main(int argc, const char *argv[]) if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { if(extend_dset_one(fname, dname, action1) < 0) goto error; - } else if(!HDstrcmp(dname, DSET_ONE) || - !HDstrcmp(dname, DSET_ALLOC_LATE) || + } else if(!HDstrcmp(dname, DSET_ONE) || + !HDstrcmp(dname, DSET_ALLOC_LATE) || !HDstrcmp(dname, DSET_ALLOC_EARLY)) { if(extend_dset_one(fname, dname, action1) < 0) goto error; - } else if(!HDstrcmp(dname, DSET_TWO) || + } else if(!HDstrcmp(dname, DSET_TWO) || !HDstrcmp(dname, DSET_CMPD_TWO)) { if(extend_dset_two(fname, dname, action1, action2) < 0) goto error; diff --git a/hl/tools/h5watch/h5watchgentest.c b/hl/tools/h5watch/h5watchgentest.c index 18e15fc..19c9876 100644 --- a/hl/tools/h5watch/h5watchgentest.c +++ b/hl/tools/h5watch/h5watchgentest.c @@ -15,23 +15,23 @@ #include "H5HLprivate2.h" /* - * WATCH.h5: file with various types of datasets for testing-- + * WATCH.h5: file with various types of datasets for testing-- * - * The following datasets are chunked, H5D_ALLOC_TIME_INCR, max. dimensional setting: - * DSET_ONE: one-dimensional dataset - * DSET_TWO: two-dimensional dataset - * DSET_CMPD: one-dimensional dataset with compound type + * The following datasets are chunked, H5D_ALLOC_TIME_INCR, max. dimensional setting: + * DSET_ONE: one-dimensional dataset + * DSET_TWO: two-dimensional dataset + * DSET_CMPD: one-dimensional dataset with compound type * DSET_CMPD_ESC: one-dimensional dataset with compound type and member names with - * escape/separator characters - * DSET_CMPD_TWO: two-dimensional dataset with compound type - * - * The following datasets are one-dimensional, chunked, max. dimension setting: - * DSET_ALLOC_EARLY: dataset with H5D_ALLOC_TIME_EARLY - * DSET_ALLOC_LATE: dataset H5D_ALLOC_TIME_LATE - * - * The following datasets are one-dimensional: - * DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE - * DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR + * escape/separator characters + * DSET_CMPD_TWO: two-dimensional dataset with compound type + * + * The following datasets are one-dimensional, chunked, max. dimension setting: + * DSET_ALLOC_EARLY: dataset with H5D_ALLOC_TIME_EARLY + * DSET_ALLOC_LATE: dataset H5D_ALLOC_TIME_LATE + * + * The following datasets are one-dimensional: + * DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE + * DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR */ #define ONE_DIMS0 10 #define MAX_ONE_DIMS0 100 diff --git a/hl/tools/h5watch/swmr_check_compat_vfd.c b/hl/tools/h5watch/swmr_check_compat_vfd.c index 7d11a73..7258c0f 100644 --- a/hl/tools/h5watch/swmr_check_compat_vfd.c +++ b/hl/tools/h5watch/swmr_check_compat_vfd.c @@ -13,7 +13,7 @@ /* Purpose: This is a small program that checks if the HDF5_DRIVER * environment variable is set to a value that supports SWMR. - * + * * It is intended for use in shell scripts. */ |