diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2005-08-13 20:53:35 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2005-08-13 20:53:35 (GMT) |
commit | 6b45f5172ccb4311e0be9ae15da3758abb6b0e67 (patch) | |
tree | 5a7a112fe7a8a98c6fecb45b513789d15962eb3d /hl/tools/gif2h5 | |
parent | 6562465a2c2a58cfbc2f47bf60bb538f7a783933 (diff) | |
download | hdf5-6b45f5172ccb4311e0be9ae15da3758abb6b0e67.zip hdf5-6b45f5172ccb4311e0be9ae15da3758abb6b0e67.tar.gz hdf5-6b45f5172ccb4311e0be9ae15da3758abb6b0e67.tar.bz2 |
[svn-r11245] Purpose:
Code cleanup
Description:
Trim trailing whitespace, which is making 'diff'ing the two branches
difficult.
Solution:
Ran this script in each directory:
foreach f (*.[ch] *.cpp)
sed 's/[[:blank:]]*$//' $f > sed.out && mv sed.out $f
end
Platforms tested:
FreeBSD 4.11 (sleipnir)
Too minor to require h5committest
Diffstat (limited to 'hl/tools/gif2h5')
-rw-r--r-- | hl/tools/gif2h5/decompress.c | 30 | ||||
-rw-r--r-- | hl/tools/gif2h5/gif.h | 12 | ||||
-rw-r--r-- | hl/tools/gif2h5/gif2mem.c | 42 | ||||
-rw-r--r-- | hl/tools/gif2h5/gifread.c | 50 | ||||
-rw-r--r-- | hl/tools/gif2h5/hdf2gif.c | 16 | ||||
-rw-r--r-- | hl/tools/gif2h5/hdfgifwr.c | 18 | ||||
-rw-r--r-- | hl/tools/gif2h5/readhdf.c | 12 | ||||
-rw-r--r-- | hl/tools/gif2h5/writehdf.c | 12 |
8 files changed, 96 insertions, 96 deletions
diff --git a/hl/tools/gif2h5/decompress.c b/hl/tools/gif2h5/decompress.c index 410778f..2ebf28d 100644 --- a/hl/tools/gif2h5/decompress.c +++ b/hl/tools/gif2h5/decompress.c @@ -81,7 +81,7 @@ int numused; * our location in the Raster array as a BIT Offset. We compute the BYTE * Offset WORDo the raster array by dividing this by 8, pick up three BYTEs, * compute the bit Offset WORDo our 24-bit chunk, shift to bring the desired - * code to the bottom, then mask it off and return it. + * code to the bottom, then mask it off and return it. */ static int ReadCode(void) @@ -166,39 +166,39 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) { int i; - XC = 0; + XC = 0; YC = 0; Pass = 0; OutCount = 0; BitOffset = 0; - + DataMask = (1 << ((GifHead->PackedField & 0x07) +1)) -1; Raster = GifImageDesc->GIFImage; /* Check for image seperator */ - + /* Now read in values from the image descriptor */ IWidth = GifImageDesc->ImageWidth; IHeight = GifImageDesc->ImageHeight; Interlace = GifImageDesc->PackedField & 0x40; - + /* * Note that I ignore the possible existence of a local color map. I'm * told there aren't many files around that use them, and the spec says * it's defined for future use. This could lead to an error reading some - * files. + * files. */ - + /* * Start reading the raster data. First we get the WORDial code size and * compute decompressor constant values, based on this code size. */ - + CodeSize = GifImageDesc->CodeSize; ClearCode = (1 << CodeSize); EOFCode = ClearCode + 1; FreeCode = FirstFree = ClearCode + 2; - + /* * The GIF spec has it that the code size is the code size used to compute * the above values is the code size given in the file, but the code size @@ -218,19 +218,19 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) */ /* Allocate the Image */ - + if (!(Image = (BYTE *)malloc((size_t)IWidth*(size_t)IHeight))) { printf("Out of memory"); exit(-1); } - + BytesPerScanline = IWidth; - + /* * Decompress the file, continuing until you see the GIF EOF code. One * obvious enhancement is to add checking for corrupt files here. */ - + Code = ReadCode(); while (Code != EOFCode) { @@ -269,7 +269,7 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) */ while (CurCode > DataMask) { if (OutCount > 1024) { - /*return error message*/ + /*return error message*/ } OutCode[OutCount++] = Suffix[CurCode]; @@ -316,5 +316,5 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) Code = ReadCode(); } - return Image; + return Image; } diff --git a/hl/tools/gif2h5/gif.h b/hl/tools/gif2h5/gif.h index 282085f..ad60968 100644 --- a/hl/tools/gif2h5/gif.h +++ b/hl/tools/gif2h5/gif.h @@ -47,8 +47,8 @@ typedef unsigned char boolean; ** Set EndianOrder = 0 if machine is little endian ** EndianOrder = 1 if machine is big endian. */ -extern int EndianOrder; - +extern int EndianOrder; + /* ** The GIF header format. ** @@ -63,9 +63,9 @@ typedef struct _GifHeader { /* Offset Description */ BYTE ApplicationCount; BYTE PlainTextCount; BYTE HDFPalette[256][3]; - BYTE HeaderDump[6]; /* BYTE array to dump header contents */ + BYTE HeaderDump[6]; /* BYTE array to dump header contents */ BYTE LSDDump[7]; /* Logical Screen Descriptor dump */ -} GIFHEAD; +} GIFHEAD; /* @@ -122,9 +122,9 @@ typedef struct _GifCommentExtension { /* ** GIF to HDF Memory Struct -** Purpose : The gif to hdf structure is used to pass all the +** Purpose : The gif to hdf structure is used to pass all the ** gif data to the memory, which gets caught by the hdf driver -** Its the drivers job to put the data in the appropriate places +** Its the drivers job to put the data in the appropriate places ** in the HDF file. ** I have assumed that the ImageDescriptors and GraphicControls follow ** one another, ie. I have not associated them with each other. The driver diff --git a/hl/tools/gif2h5/gif2mem.c b/hl/tools/gif2h5/gif2mem.c index 01aa5a2..0695995 100644 --- a/hl/tools/gif2h5/gif2mem.c +++ b/hl/tools/gif2h5/gif2mem.c @@ -100,7 +100,7 @@ Gif2Mem(BYTE *MemGif) /* Read the GIF image file header information */ ReadGifHeader(gifHead, &MemGif); - + /* Check for FILE stream error */ #if 0 if (ferror(fpGif)) @@ -121,7 +121,7 @@ Gif2Mem(BYTE *MemGif) for (;;) { Identifier = *MemGif++; - + switch (Identifier) { case 0x3B: /* Trailer */ /* @@ -140,16 +140,16 @@ Gif2Mem(BYTE *MemGif) GifMemoryStruct.GifApplicationExtension = gifApplication; GifMemoryStruct.GifCommentExtension = gifComment; GifMemoryStruct.GifGraphicControlExtension = gifGraphicControl; - + /* return the struct */ return GifMemoryStruct; case 0x2C: /* Image Descriptor */ /* * If there was no image descriptor before this increase image - * count. If an imagedescriptor was present, reset GCEflag + * count. If an imagedescriptor was present, reset GCEflag */ - if (GCEflag == 0) + if (GCEflag == 0) ImageCount++; else GCEflag = 0; @@ -180,17 +180,17 @@ Gif2Mem(BYTE *MemGif) printf("Out of memory!"); exit(-1); } - + if (ReadGifImageDesc(gifImageDesc[ImageCount-1], &MemGif) == -1) fputs("Error reading Image Descriptor information\n", stderr); - + /* Decompress the Image */ gifImageDesc[ImageCount-1]->Image = Decompress(gifImageDesc[ImageCount-1], gifHead); free(gifImageDesc[ImageCount-1]->GIFImage); - /* + /* * Convert the local palette into an HDF compatible palette In * case the local color table is present, it is written out as * the HDFPalette If it is absent the global table is written @@ -213,8 +213,8 @@ Gif2Mem(BYTE *MemGif) } break; - - case 0x21: /* Extension Block */ + + case 0x21: /* Extension Block */ Label = *MemGif++; switch (Label) { @@ -240,7 +240,7 @@ Gif2Mem(BYTE *MemGif) "Error reading Plain Text Extension information.\n"); break; - + case 0xFE: /* Comment Extension */ CommentCount++; @@ -251,19 +251,19 @@ Gif2Mem(BYTE *MemGif) printf("Out of memory!"); exit(-1); } - + if(!(gifComment[CommentCount - 1] = (GIFCOMMENT *)malloc(sizeof(GIFCOMMENT)))) { printf("Out of memory!"); exit(-1); } - + if (ReadGifComment(gifComment[CommentCount - 1], &MemGif)) fprintf(stderr, "Error reading Comment Extension information\n"); break; - + case 0xF9: /* Graphic Control Extension */ if (GCEflag == 0 ) ImageCount++; @@ -289,17 +289,17 @@ Gif2Mem(BYTE *MemGif) gifImageDesc[j] = NULL; } } - + if(!(gifGraphicControl[ImageCount-1] = (GIFGRAPHICCONTROL*)malloc(sizeof(GIFGRAPHICCONTROL)))) { printf("Out of memory!"); exit(-1); } - - + + if (ReadGifGraphicControl(gifGraphicControl[ImageCount-1], &MemGif)) fprintf(stderr, "Error reading Graphic Control Extension information\n"); - + if (!*MemGif++ == 0) fprintf(stderr, "Error reading Graphic Control Extension\n"); @@ -311,18 +311,18 @@ Gif2Mem(BYTE *MemGif) if (ApplicationCount > ApplicationArray) ApplicationArray = (ApplicationArray << 1) + 1; - + if (!(gifApplication = (GIFAPPLICATION **)realloc(gifApplication , sizeof(GIFAPPLICATION *) * ApplicationArray))) { printf("Out of memory!"); exit(-1); } - + if(!(gifApplication[ApplicationCount - 1] = (GIFAPPLICATION *)malloc(sizeof(GIFAPPLICATION)))) { printf("Out of memory!"); exit(-1); } - + if (ReadGifApplication(gifApplication[ApplicationCount - 1], &MemGif)) fprintf(stderr, "Error reading Application Extension information\n"); diff --git a/hl/tools/gif2h5/gifread.c b/hl/tools/gif2h5/gifread.c index b135617..5f4aba0 100644 --- a/hl/tools/gif2h5/gifread.c +++ b/hl/tools/gif2h5/gifread.c @@ -11,16 +11,16 @@ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include <stdio.h> -#include <stdlib.h> +#include <stdio.h> +#include <stdlib.h> -#include "gif.h" +#include "gif.h" int EndianOrder; static BYTE *ReadDataSubBlocks(BYTE **MemGif2, WORD *DSize); -WORD +WORD GetWord(BYTE *MemGif) { WORD w; @@ -39,7 +39,7 @@ GetWord(BYTE *MemGif) BYTE GetByte(BYTE *MemGif) -{ +{ return *MemGif; } @@ -69,7 +69,7 @@ ReadGifHeader(GIFHEAD *GifHead, /* Pointer to GIF header structure */ printf("The file does not appear to be a valid GIF file.\n"); exit(-1); } - + for (i = 0 ; i < 7 ; i++) { GifHead->LSDDump[i] = *(*MemGif2)++; } @@ -84,7 +84,7 @@ ReadGifHeader(GIFHEAD *GifHead, /* Pointer to GIF header structure */ /* Read the Global Color Table */ - /* + /* * There are some changes made here apart from just reading in the * global color table as would seem intuitively obvious. The colors * are stored in the bottom part of the palette as opposed to the top @@ -100,7 +100,7 @@ ReadGifHeader(GIFHEAD *GifHead, /* Pointer to GIF header structure */ /* Check for a FILE stream error */ #if 0 if (ferror(FpGif)) - return -1; + return -1; #endif /* 0 */ return 0; /* No FILE stream error occured */ @@ -136,11 +136,11 @@ ReadGifImageDesc( for (i = 0 ; i < 9 ; i++) { GifImageDesc->GIDDump[i] = *(*MemGif2)++; } - + /* ** Get the relevant fields. I need ImageWidth and Height actively hence I have ** taken information from those fields. I intend to keep the GifImageDesc data - ** structure as it is so that anyone needing the rest of the fields can do so + ** structure as it is so that anyone needing the rest of the fields can do so ** quickly. */ @@ -160,10 +160,10 @@ ReadGifImageDesc( GifImageDesc->ImageHeight = (WORD) (GifImageDesc->GIDDump[6] & 0xFF); GifImageDesc->ImageHeight = ((WORD) (GifImageDesc->GIDDump[7] & 0xFF)) | (GifImageDesc->ImageWidth << 0x08); - + } - + GifImageDesc->PackedField = GifImageDesc->GIDDump[8]; /* Interlace = GifImageDesc->PackedField & 0x20; */ @@ -193,7 +193,7 @@ ReadGifImageDesc( printf("Out of memory"); exit(-1); } - + TempPtr = GifImageDesc->GIFImage; do @@ -258,7 +258,7 @@ ReadGifPlainText( if (!(GifPlainText->PlainTextData = ReadDataSubBlocks(MemGif2 , &(GifPlainText->DataSize)))) return(1); - /* + /* GifPlainText->Terminator = 0; */ @@ -299,7 +299,7 @@ ReadGifApplication( /* GifApplication->Terminator = 0; */ - + /* Check for a FILE stream error */ /* if (ferror(FpGif)) @@ -325,13 +325,13 @@ ReadGifComment( BYTE **MemGif2 /* GIF image file input FILE stream */ ) { - + /* Read in the Plain Text data sub-blocks */ if (!(GifComment->CommentData = ReadDataSubBlocks(MemGif2 , &(GifComment->DataSize)))) return(1); GifComment->Terminator = 0; - + return(0); /* No FILE stream error occured */ } @@ -357,9 +357,9 @@ ReadDataSubBlocks(BYTE **MemGif2, /* GIF image file input FILE stream int tempcount = 0; bufSize = 0; /* The output buffer is empty */ - + dataSize = *(*MemGif2)++; /* Get the size of the first sub-block */ - + /* Allocate initial data buffer */ if (!(ptr1 = ptr2 = (BYTE *) malloc((size_t)dataSize + 1))) { printf("Out of memory. Allocation of memory for data sub-blocks for\neither Comment, Plain Text or Application Extensions failed"); @@ -376,23 +376,23 @@ ReadDataSubBlocks(BYTE **MemGif2, /* GIF image file input FILE stream #endif /* COMMENTED_OUT */ while (dataSize--) /* Read/write the Plain Text data */ *ptr1++ = *(*MemGif2)++; - + /* Check if there is another data sub-block */ if ((dataSize = *(*MemGif2)++) == 0) break; /* Block Terminator encountered */ - + /* Increase the buffer size to accomodate the next sub-block */ if (!(ptr1 = ptr2 = (BYTE *) realloc(ptr2, bufSize + dataSize + 1))) return((BYTE *) NULL); - + ptr1 += bufSize; /* Move pointer to the end of the data */ - - + + } *ptr1++ = '\0'; - + return(ptr2); /* Return a pointer to the sub-block data */ } diff --git a/hl/tools/gif2h5/hdf2gif.c b/hl/tools/gif2h5/hdf2gif.c index 51ec144..52e57f7 100644 --- a/hl/tools/gif2h5/hdf2gif.c +++ b/hl/tools/gif2h5/hdf2gif.c @@ -64,7 +64,7 @@ usage(void) FILE *fpGif = NULL; int main(int argc , char **argv) { - + hsize_t dim_sizes[2]; BYTE *Image; @@ -180,7 +180,7 @@ int main(int argc , char **argv) return -1; } - + /* we shall always have a palette - read hdf will see to that */ has_local_palette = true; @@ -188,12 +188,12 @@ int main(int argc , char **argv) idx = 0x0001; b = (BYTE *) &idx; EndianOrder = (b[0] ? 1:0); - + if (!(fpGif = fopen(GIFName , "wb"))) { printf("Error opening gif file for output. Aborting.\n"); return -1; } - + /* hardwire n_images to 1 for now. */ n_images = number_of_images; @@ -249,7 +249,7 @@ int main(int argc , char **argv) Blue[i] = GlobalPalette[i][2]; } } - + for (i = 0; i < 256; i++) { pc2nc[i] = r1[i] = g1[i] = b1[i] = 0; } @@ -288,7 +288,7 @@ int main(int argc , char **argv) #ifdef UNUSED CountDown = w * h; /* # of pixels we'll be doing */ #endif /* UNUSED */ - + if (BitsPerPixel <= 1) InitCodeSize = 2; else @@ -305,7 +305,7 @@ int main(int argc , char **argv) /* * If it is the first image we do all the header stuff that isn't - * required for the rest of the images. + * required for the rest of the images. */ if (idx == 0) { /* Write out the GIF header and logical screen descriptor */ @@ -379,7 +379,7 @@ int main(int argc , char **argv) i = hdfWriteGIF(fpGif , Image , 0 , (int)dim_sizes[0] , (int)dim_sizes[1] , r1, g1 , b1 , pc2nc , 256 , 8 , BitsPerPixel); - fputc(0x00, fpGif); + fputc(0x00, fpGif); free(Image); } diff --git a/hl/tools/gif2h5/hdfgifwr.c b/hl/tools/gif2h5/hdfgifwr.c index a18b81f..b1b5be5 100644 --- a/hl/tools/gif2h5/hdfgifwr.c +++ b/hl/tools/gif2h5/hdfgifwr.c @@ -13,13 +13,13 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * hdfgifwr.c - handles writing of GIF files. - * - * Contains: + * hdfgifwr.c - handles writing of GIF files. + * + * Contains: * hdfWriteGIF(fp, pic, ptype, w, h, rmap, gmap, bmap, numcols, colorstyle, * comment) * - * Note: slightly brain-damaged, in that it'll only write non-interlaced + * Note: slightly brain-damaged, in that it'll only write non-interlaced * GIF files (in the interests of speed, or something) */ @@ -44,7 +44,7 @@ * James A. Woods (decvax!ihnp4!ames!jaw) * Joe Orost (decvax!vax135!petsd!joe) *****************************************************************/ - + #include <stdio.h> #include <stdlib.h> @@ -125,7 +125,7 @@ int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap, Background = 0; #endif /* UNUSED */ - for (i = 0; i < 256; i++) { + for (i = 0; i < 256; i++) { pc2nc[i] = pc2ncmap[i]; #ifdef UNUSED r1[i] = rmap[i]; @@ -325,7 +325,7 @@ probe: continue; } - if ((long)HashTabOf (i) >= 0) + if ((long)HashTabOf (i) >= 0) goto probe; nomatch: @@ -380,7 +380,7 @@ output(int code) cur_accum |= ((long)code << cur_bits); else cur_accum = code; - + cur_bits += n_bits; while( cur_bits >= 8 ) { @@ -406,7 +406,7 @@ output(int code) maxcode = MAXCODE(n_bits); } } - + if (code == EOFCode) { /* At EOF, write the rest of the buffer */ while( cur_bits > 0 ) { diff --git a/hl/tools/gif2h5/readhdf.c b/hl/tools/gif2h5/readhdf.c index 2720d4d..3fc454c 100644 --- a/hl/tools/gif2h5/readhdf.c +++ b/hl/tools/gif2h5/readhdf.c @@ -30,17 +30,17 @@ cleanup(BYTE *ptr) ** BYTE palette[256][3] - the corresponding palette ** hsize_t* image_size - the size of each dimension of the image ** -** Future Notes: -** The way readHDF works right now is that it expects the user +** Future Notes: +** The way readHDF works right now is that it expects the user ** to know the exact path to the HDF image. Thus it does not ** parse the HDF file looking for image datasets and corresponding -** palettes. Also it takes in the default palette for the image +** palettes. Also it takes in the default palette for the image ** specified, if the palette is missing, it makes a default greyscale ** palette and throws it in. ** */ int ReadHDF(BYTE** data, BYTE palette[256][3], hsize_t *image_size, - CHAR *h5_file, CHAR *dset_name, CHAR *pal_name) + CHAR *h5_file, CHAR *dset_name, CHAR *pal_name) { hid_t fHfile; /* H5 file to open */ hid_t dspace; /* dataspace identifier for the the dataset */ @@ -130,7 +130,7 @@ int ReadHDF(BYTE** data, BYTE palette[256][3], hsize_t *image_size, pal_exist = 0; return -1; } - + pal_dtype = H5Dget_type(pal_set); if (dtype < 0) { fprintf(stderr , "Unable to open palette datatype\n"); @@ -151,7 +151,7 @@ int ReadHDF(BYTE** data, BYTE palette[256][3], hsize_t *image_size, pal_exist = 0; return -1; } - + /* get the dimension size of the palette. */ if (H5Sget_simple_extent_dims(pal_space , loc_pal_size , NULL) !=2 ) { fprintf(stderr , "Unable to get dimension info\n"); diff --git a/hl/tools/gif2h5/writehdf.c b/hl/tools/gif2h5/writehdf.c index d343aae..8d7405e 100644 --- a/hl/tools/gif2h5/writehdf.c +++ b/hl/tools/gif2h5/writehdf.c @@ -49,11 +49,11 @@ static int write_text_attribute(hid_t dataset_id , const char *attr_name, attr_dataspace_id , H5P_DEFAULT); /* write out the attribute data */ - if (H5Awrite(attr_attr_id , attr_type_id , attr_value) < 0) + if (H5Awrite(attr_attr_id , attr_type_id , attr_value) < 0) return -1; /* close the attribute */ - if (H5Aclose(attr_attr_id) < 0) + if (H5Aclose(attr_attr_id) < 0) return -1; /* close the dataspace */ @@ -192,12 +192,12 @@ WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName , char *GIFFileName) return -1; } - /* write the reference out */ + /* write the reference out */ if (H5Dwrite(ref_dataset_id , H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL , H5P_DEFAULT, &pal_ref) < 0) { fprintf(stderr , "Unable to write Palette Reference"); return -1; } - + /* close dataset */ if (H5Dclose(ref_dataset_id) < 0) { fprintf(stderr , "Unable to close palette dataset.\n"); @@ -271,7 +271,7 @@ WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName , char *GIFFileName) /* This info is available at http://hdf.ncsa.uiuc.edu/HDF5/doc/ImageSpec.html */ /* The following attributes must be set for each image: ** --------------------------------------- - ** Attribute Name Value + ** Attribute Name Value ** CLASS IMAGE ** IMAGE_VERSION 1.0 ** IMAGE_SUBCLASS IMAGE_BITMAP @@ -324,7 +324,7 @@ WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName , char *GIFFileName) ** Attribute: PALETTE ** Value : Reference to Palette *****************************************/ - + /**** MAKE SURE PALETTE EXISTS!!! ****/ if (gifHead.PackedField & 0x80) { /* global palette exists */ |