summaryrefslogtreecommitdiffstats
path: root/hl/tools/gif2h5
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2015-04-22 22:31:12 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2015-04-22 22:31:12 (GMT)
commite0e28a7aae2fabf3ae9d03a1bd5809176935466a (patch)
treea6b840f4c13522aecdd504d16ee5a265e2abad27 /hl/tools/gif2h5
parent65b3bc2a937337239ceede5e39261c6b2ba4dc69 (diff)
downloadhdf5-e0e28a7aae2fabf3ae9d03a1bd5809176935466a.zip
hdf5-e0e28a7aae2fabf3ae9d03a1bd5809176935466a.tar.gz
hdf5-e0e28a7aae2fabf3ae9d03a1bd5809176935466a.tar.bz2
[svn-r26894] Bring revisions #26459 - #26785 from trunk to revise_chunks.
h5committested.
Diffstat (limited to 'hl/tools/gif2h5')
-rw-r--r--hl/tools/gif2h5/Makefile.in5
-rw-r--r--hl/tools/gif2h5/decompress.c2
-rw-r--r--hl/tools/gif2h5/gif2mem.c10
-rw-r--r--hl/tools/gif2h5/h52gifgentst.c8
-rw-r--r--hl/tools/gif2h5/h52giftest.sh.in75
-rw-r--r--hl/tools/gif2h5/hdf2gif.c21
-rw-r--r--hl/tools/gif2h5/hdfgifwr.c8
-rw-r--r--hl/tools/gif2h5/testfiles/REAMDE6
-rw-r--r--hl/tools/gif2h5/testfiles/ex_image2.h5bin0 -> 224533 bytes
9 files changed, 87 insertions, 48 deletions
diff --git a/hl/tools/gif2h5/Makefile.in b/hl/tools/gif2h5/Makefile.in
index d3245ed..3da84e1 100644
--- a/hl/tools/gif2h5/Makefile.in
+++ b/hl/tools/gif2h5/Makefile.in
@@ -420,7 +420,6 @@ AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@
AM_LDFLAGS = @AM_LDFLAGS@ @H5_LDFLAGS@
AM_MAKEFLAGS = @AM_MAKEFLAGS@
AR = @AR@
-AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
@@ -452,7 +451,6 @@ DIRECT_VFD = @DIRECT_VFD@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
-DYNAMIC_DIRS = @DYNAMIC_DIRS@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
@@ -476,11 +474,9 @@ GREP = @GREP@
H5_CFLAGS = @H5_CFLAGS@
H5_CPPFLAGS = @H5_CPPFLAGS@
H5_CXXFLAGS = @H5_CXXFLAGS@
-H5_CXX_SHARED = @H5_CXX_SHARED@
H5_FCFLAGS = @H5_FCFLAGS@
H5_FORTRAN_SHARED = @H5_FORTRAN_SHARED@
H5_LDFLAGS = @H5_LDFLAGS@
-H5_LONE_COLON = @H5_LONE_COLON@
H5_VERSION = @H5_VERSION@
HADDR_T = @HADDR_T@
HAVE_DMALLOC = @HAVE_DMALLOC@
@@ -543,7 +539,6 @@ R_INTEGER = @R_INTEGER@
R_LARGE = @R_LARGE@
SEARCH = @SEARCH@
SED = @SED@
-SETX = @SETX@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SIZE_T = @SIZE_T@
diff --git a/hl/tools/gif2h5/decompress.c b/hl/tools/gif2h5/decompress.c
index d4e4cdc..ef2d78a 100644
--- a/hl/tools/gif2h5/decompress.c
+++ b/hl/tools/gif2h5/decompress.c
@@ -90,7 +90,7 @@ ReadCode(void)
RawCode += (0x10000 * Raster[ByteOffset + 2]);
RawCode >>= (BitOffset % 8);
- BitOffset += CodeSize;
+ BitOffset += (int)CodeSize;
return (RawCode & ReadMask);
}
diff --git a/hl/tools/gif2h5/gif2mem.c b/hl/tools/gif2h5/gif2mem.c
index a2e4893..456a32d 100644
--- a/hl/tools/gif2h5/gif2mem.c
+++ b/hl/tools/gif2h5/gif2mem.c
@@ -153,7 +153,7 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct)
if (ImageCount > ImageArray) {
aTemp = ImageArray;
- ImageArray = (ImageArray << 1) + 1;
+ ImageArray = (BYTE)((ImageArray << 1) + 1);
if (!(gifImageDesc = (GIFIMAGEDESC **)realloc(gifImageDesc,
sizeof(GIFIMAGEDESC *) * ImageArray))) {
printf("Out of memory!");
@@ -220,7 +220,7 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct)
PlainTextCount++;
if (PlainTextCount > PlainTextArray)
- PlainTextArray = (PlainTextArray << 1) + 1;
+ PlainTextArray = (BYTE)((PlainTextArray << 1) + 1);
if (!(gifPlainText = (GIFPLAINTEXT **)realloc(gifPlainText , sizeof(GIFPLAINTEXT *) * PlainTextArray))) {
printf("Out of memory!");
@@ -242,7 +242,7 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct)
CommentCount++;
if (CommentCount > CommentArray)
- CommentArray = (CommentArray << 1) + 1;
+ CommentArray = (BYTE)((CommentArray << 1) + 1);
if (!(gifComment = (GIFCOMMENT **)realloc(gifComment , sizeof(GIFCOMMENT *) * CommentArray))) {
printf("Out of memory!");
@@ -269,7 +269,7 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct)
if (ImageCount > ImageArray) {
aTemp = ImageArray;
- ImageArray = (ImageArray << 1) + 1;
+ ImageArray = (BYTE)((ImageArray << 1) + 1);
if (!(gifGraphicControl = (GIFGRAPHICCONTROL **)realloc(gifGraphicControl , sizeof(GIFGRAPHICCONTROL *) * ImageArray))) {
printf("Out of memory!");
@@ -307,7 +307,7 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct)
ApplicationCount++;
if (ApplicationCount > ApplicationArray)
- ApplicationArray = (ApplicationArray << 1) + 1;
+ ApplicationArray = (BYTE)((ApplicationArray << 1) + 1);
if (!(gifApplication = (GIFAPPLICATION **)realloc(gifApplication , sizeof(GIFAPPLICATION *) * ApplicationArray))) {
printf("Out of memory!");
diff --git a/hl/tools/gif2h5/h52gifgentst.c b/hl/tools/gif2h5/h52gifgentst.c
index ef38c3b..3433d0a 100644
--- a/hl/tools/gif2h5/h52gifgentst.c
+++ b/hl/tools/gif2h5/h52gifgentst.c
@@ -64,7 +64,7 @@ int main(void)
space = WIDTH*HEIGHT / PAL_ENTRIES;
for (i=0, j=0, n=0; i < WIDTH*HEIGHT; i++, j++ )
{
- buf[i] = n;
+ buf[i] = (unsigned char)n;
if ( j > space )
{
n++;
@@ -83,9 +83,9 @@ int main(void)
*/
for ( i=0, n=0; i<PAL_ENTRIES*3; i+=3, n++)
{
- pal[i] =n; /* red */
- pal[i+1]=0; /* green */
- pal[i+2]=255-n; /* blue */
+ pal[i] = (unsigned char)n; /* red */
+ pal[i+1] = (unsigned char)0; /* green */
+ pal[i+2] = (unsigned char)(255-n); /* blue */
}
/* make a palette */
diff --git a/hl/tools/gif2h5/h52giftest.sh.in b/hl/tools/gif2h5/h52giftest.sh.in
index 186b369..7aec219 100644
--- a/hl/tools/gif2h5/h52giftest.sh.in
+++ b/hl/tools/gif2h5/h52giftest.sh.in
@@ -18,6 +18,7 @@
TESTFILE1="$srcdir/testfiles/h52giftst.h5"
TESTFILE2="$srcdir/testfiles/image1.gif"
+TESTFILE3="$srcdir/testfiles/ex_image2.h5"
# initialize errors variable
errors=0
@@ -29,45 +30,69 @@ TESTING() {
-TOOLTEST1()
+# Verify the test runs with success (return code is 0)
+TOOLTEST()
{
- $RUNSERIAL ./h52gif $*
-
- RET=$?
- if [ $RET != 0 ] ; then
- echo "*FAILED*"
- errors="` expr $errors + 1 `";
- else
- echo " PASSED"
- fi
+ # for now, discard any error messages generated.
+ $RUNSERIAL $* > /dev/null 2>&1
+
+ RET=$?
+ if [ $RET = 0 ] ; then
+ echo " PASSED"
+ else
+ echo "*FAILED*"
+ errors="` expr $errors + 1 `";
+ fi
}
-TOOLTEST2()
+# Verify the test runs with failure (return code is not 0)
+# Use for testing if tool can handle error conditions like
+# illegal input, bad arguments, exeeding limits, ...
+TOOLTESTFAIL()
{
- $RUNSERIAL ./gif2h5 $*
-
- RET=$?
- if [ $RET != 0 ] ; then
- echo "*FAILED*"
- errors="` expr $errors + 1 `";
- else
- echo " PASSED"
- fi
+ # for now, discard any error messages generated.
+ $RUNSERIAL $* > /dev/null 2>&1
+
+ RET=$?
+ if [ $RET != 0 ] ; then
+ echo " PASSED"
+ else
+ echo "*FAILED*"
+ errors="` expr $errors + 1 `";
+ fi
}
+# Positive tests for gif2h5
+echo "**validate the gif2h5 tool processes input correctly..."
+TESTING "./gif2h5 image1.gif image1.h5"
+TOOLTEST ./gif2h5 $TESTFILE2 image1.h5
+echo ""
+# Positive tests for h52gif
+echo "**validate the h52gif tool processes input correctly..."
TESTING "./h52gif h52giftst.h5 image1.gif -i image"
-TOOLTEST1 $TESTFILE1 image1.gif -i image
-TESTING "./gif2h5 image1.gif image1.h5"
-TOOLTEST2 $TESTFILE2 image1.h5
+TOOLTEST ./h52gif $TESTFILE1 image1.gif -i image
+echo ""
+# Negative tests.
+echo "**verify the the h52gif tool handle error conditions correctly..."
+# nonexisting dataset name
+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"
+echo ""
+# all done. summarize results.
if test $errors -eq 0 ; then
- echo "All h52gif tests passed."
+ echo "All gif2h5 and h52gif tests passed."
exit 0
else
- echo "h52gif tests failed with $errors errors."
+ echo "Some gif2h5 or h52gif tests failed with $errors errors."
exit 1
fi
diff --git a/hl/tools/gif2h5/hdf2gif.c b/hl/tools/gif2h5/hdf2gif.c
index 090d657..5c342ba 100644
--- a/hl/tools/gif2h5/hdf2gif.c
+++ b/hl/tools/gif2h5/hdf2gif.c
@@ -20,6 +20,8 @@
#include "h5tools.h"
#include "h5tools_utils.h"
+#define IMAGE_WIDTH_MAX 65535 /* unsigned 16bits integer */
+#define IMAGE_HEIGHT_MAX 65535 /* unsigned 16bits integer */
int EndianOrder;
@@ -147,6 +149,17 @@ int main(int argc , char **argv)
if ( H5IMget_image_info( fid, image_name, &width, &height, &planes, interlace, &npals ) < 0 )
goto out;
+ if (width > IMAGE_WIDTH_MAX || height > IMAGE_HEIGHT_MAX){
+ fprintf(stderr, "HDF5 image is too large. Limit is %d by %d.\n", IMAGE_WIDTH_MAX, IMAGE_HEIGHT_MAX);
+ goto out;
+ }
+
+ /* tool can handle single plane images only. */
+ if (planes > 1){
+ fprintf(stderr, "Cannot handle multiple planes image\n");
+ goto out;
+ }
+
Image = (BYTE*) malloc( (size_t) width * (size_t) height );
if ( H5IMread_image( fid, image_name, Image ) < 0 )
@@ -194,9 +207,9 @@ int main(int argc , char **argv)
numcols = 256;
for (i = 0 ; i < numcols ; i++)
{
- Red[i] = 255 - i;
- Green[i] = 255 - i;
- Blue[i] = 255 - i;
+ Red[i] = (BYTE)(255 - i);
+ Green[i] = (BYTE)(255 - i);
+ Blue[i] = (BYTE)(255 - i);
}
}
else
@@ -229,7 +242,7 @@ int main(int argc , char **argv)
if (j==i)
{
/* wasn't found */
- pc2nc[i] = nc;
+ pc2nc[i] = (BYTE)nc;
r1[nc] = Red[i];
g1[nc] = Green[i];
b1[nc] = Blue[i];
diff --git a/hl/tools/gif2h5/hdfgifwr.c b/hl/tools/gif2h5/hdfgifwr.c
index d828226..4c52f4c 100644
--- a/hl/tools/gif2h5/hdfgifwr.c
+++ b/hl/tools/gif2h5/hdfgifwr.c
@@ -270,7 +270,7 @@ nomatch:
ent = c;
if (free_ent < maxmaxcode) {
- CodeTabOf (i) = free_ent++; /* code -> hashtable */
+ CodeTabOf (i) = (unsigned short)free_ent++; /* code -> hashtable */
HashTabOf (i) = fcode;
} else {
cl_block();
@@ -313,9 +313,9 @@ output(int code)
cur_accum &= masks[cur_bits];
if (cur_bits > 0)
- cur_accum |= ((long)code << cur_bits);
+ cur_accum |= (unsigned long)((long)code << cur_bits);
else
- cur_accum = code;
+ cur_accum = (unsigned long)code;
cur_bits += n_bits;
@@ -437,7 +437,7 @@ static char accum[ 256 ];
static void
char_out(int c)
{
- accum[ a_count++ ] = c;
+ accum[ a_count++ ] = (char)c;
if (a_count >= 254)
flush_char();
diff --git a/hl/tools/gif2h5/testfiles/REAMDE b/hl/tools/gif2h5/testfiles/REAMDE
new file mode 100644
index 0000000..a428d47
--- /dev/null
+++ b/hl/tools/gif2h5/testfiles/REAMDE
@@ -0,0 +1,6 @@
+ex_image2.h5
+ Generated by hl/examples/ex_image2.c
+5giftst.h5:
+ Generated by ../h52gifgentst.c
+image1.gif:
+ To be determined.
diff --git a/hl/tools/gif2h5/testfiles/ex_image2.h5 b/hl/tools/gif2h5/testfiles/ex_image2.h5
new file mode 100644
index 0000000..a36df1b
--- /dev/null
+++ b/hl/tools/gif2h5/testfiles/ex_image2.h5
Binary files differ