Changeset 38334
- Timestamp:
- May 29, 2015, 5:24:53 PM (11 years ago)
- Location:
- branches/eam_branches/ohana.20150429/src/libfits
- Files:
-
- 2 added
- 8 edited
-
Makefile (modified) (2 diffs)
-
extern/gzip.c (modified) (5 diffs)
-
matrix/F_compress_data.c (modified) (3 diffs)
-
matrix/F_uncompress_M.c (modified) (1 diff)
-
matrix/F_uncompress_data.c (modified) (3 diffs)
-
table/F_compress_T.c (modified) (3 diffs)
-
table/F_table_varlength.c (modified) (2 diffs)
-
table/F_uncompress_T.c (modified) (1 diff)
-
test/tablecomp.c (added)
-
test/zlib.c (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/libfits/Makefile
r38329 r38334 13 13 INC = $(HOME)/include 14 14 MAN = $(HOME)/doc 15 TEST = $(HOME)/test 16 TESTBIN = $(HOME)/test 15 17 include ../../Makefile.Common 16 18 … … 19 21 FULL_CPPFLAGS = $(BASE_CPPFLAGS) -I$(EXT) 20 22 FULL_LDFLAGS = $(BASE_LDFLAGS) -lohana 23 24 TEST_CFLAGS = $(BASE_CFLAGS) 25 TEST_CPPFLAGS = $(BASE_CPPFLAGS) 26 TEST_LDFLAGS = $(BASE_LDFLAGS) -lFITS -lohana -ltap_ohana 27 28 TESTPROG = tablecomp zlib 29 $(TESTPROG) : % : $(TESTBIN)/% 30 test: $(TESTPROG) 21 31 22 32 install: $(DESTLIB)/libFITS.a $(DESTLIB)/libFITS.$(DLLTYPE) $(DESTMAN)/fits.1 -
branches/eam_branches/ohana.20150429/src/libfits/extern/gzip.c
r38329 r38334 120 120 { 121 121 z_stream stream; 122 int err;122 int i, err; 123 123 124 124 stream.next_in = (Bytef*)source; … … 135 135 stream.opaque = Z_NULL; 136 136 137 if (0) { 138 fprintf (stderr, "inp unc: "); 139 for (i = 0; i < sourceLen; i++) { 140 fprintf (stderr, "0x%02hhx ", source[i]); 141 } 142 fprintf (stderr, "\n"); 143 } 144 137 145 // err = inflateInit2(&stream, -15); 138 146 err = inflateInit(&stream); 147 if (0) fprintf (stderr, "inp buffers unc 0: %d => %d => %d\n", stream.avail_in, stream.avail_out, (int) stream.total_out); 148 139 149 if (err != Z_OK) return err; 140 150 141 151 err = inflate(&stream, Z_FINISH); 152 if (0) fprintf (stderr, "out buffers unc 1: %d => %d => %d\n", stream.avail_in, stream.avail_out, (int) stream.total_out); 142 153 if (err != Z_STREAM_END) { 143 154 inflateEnd(&stream); 144 if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 145 return Z_DATA_ERROR; 155 if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) return Z_DATA_ERROR; 146 156 return err; 147 157 } 158 if (0) fprintf (stderr, "out buffers unc 2: %d => %d => %d\n", stream.avail_in, stream.avail_out, (int) stream.total_out); 159 160 if (0) { 161 fprintf (stderr, "out unc: "); 162 for (i = 0; i < stream.total_out; i++) { 163 fprintf (stderr, "0x%02hhx ", dest[i]); 164 } 165 fprintf (stderr, "\n"); 166 } 167 148 168 assert (stream.total_out <= *destLen); 149 169 *destLen = stream.total_out; … … 156 176 { 157 177 z_stream stream; 158 int err;178 int i, err; 159 179 160 180 stream.next_in = (Bytef*)source; … … 172 192 stream.opaque = Z_NULL; 173 193 194 if (0) { 195 fprintf (stderr, "inp cmp: "); 196 for (i = 0; i < sourceLen; i++) { 197 fprintf (stderr, "0x%02hhx ", source[i]); 198 } 199 fprintf (stderr, "\n"); 200 } 201 174 202 // the '5' is the compression level: make this a user argument 175 203 err = deflateInit(&stream, 5); 204 if (0) fprintf (stderr, "inp buffers cmp 0: %d => %d => %d\n", stream.avail_in, stream.avail_out, (int) stream.total_out); 205 176 206 if (err != Z_OK) return err; 177 207 … … 179 209 // the compression occur in a series of steps 180 210 err = deflate(&stream, Z_FINISH); 211 if (0) fprintf (stderr, "out buffers cmp 1: %d => %d => %d\n", stream.avail_in, stream.avail_out, (int) stream.total_out); 212 181 213 if (err != Z_STREAM_END) { 182 deflateEnd(&stream); 183 return err; 184 } 214 err = deflateEnd(&stream); 215 return Z_BUF_ERROR; 216 } 217 if (0) fprintf (stderr, "out buffers cmp 2: %d => %d => %d\n", stream.avail_in, stream.avail_out, (int) stream.total_out); 218 219 if (0) { 220 fprintf (stderr, "out cmp: "); 221 for (i = 0; i < stream.total_out; i++) { 222 fprintf (stderr, "0x%02hhx ", dest[i]); 223 } 224 fprintf (stderr, "\n"); 225 } 226 185 227 assert (stream.total_out <= *destLen); 186 228 *destLen = stream.total_out; -
branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_data.c
r38329 r38334 27 27 int gfits_compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); 28 28 29 static int pass = 0;30 31 29 int gfits_compress_data (char *zdata, int *Nzdata, char *cmptype, 32 30 char **optname, char **optvalue, int Nopt, … … 34 32 35 33 int status; 34 35 // do not actually compress : this is used for testing 36 if (!strcasecmp(cmptype, "NONE")) { 37 unsigned long Nbytes = Nrawpix * rawpix_size; 38 39 memcpy (zdata, rawdata, Nbytes); 40 *Nzdata = Nbytes; 41 return (TRUE); 42 } 36 43 37 44 if (!strcasecmp(cmptype, "GZIP_1")) { … … 49 56 fprintf (stderr, "error in compress (GZIP)\n"); 50 57 return (FALSE); 51 }52 53 // test of deflate (vs I/O)54 {55 char *srcbuf, *tgtbuf;56 ALLOCATE (srcbuf, char, destLen);57 memcpy (srcbuf, zdata, destLen);58 59 ALLOCATE (tgtbuf, char, Nbytes);60 61 uLongf Ndeflate = Nbytes;62 status = gfits_uncompress ((Bytef *) tgtbuf, &Ndeflate, (Bytef *) zdata, destLen);63 if (status != Z_OK) {64 fprintf (stderr, "error in uncompress (GZIP) : %d vs %d\n", status, Z_OK);65 return (FALSE);66 }67 68 myAssert (Ndeflate == Nbytes, "invalid output size?");69 70 int i;71 for (i = 0; i < Ndeflate; i++) {72 myAssert (rawdata[i] == tgtbuf[i], "data mismatch?");73 }74 75 }76 77 if (pass == 0) {78 int i;79 for (i = 0; i < 32; i++) {80 fprintf (stderr, "0x%02hhx ", zdata[i]);81 }82 fprintf (stderr, "\n");83 pass = 1;84 58 } 85 59 return (TRUE); -
branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_M.c
r38329 r38334 197 197 198 198 // find the COMPRESSED_DATA column (format should be 1PB, 1PI, 1PJ) 199 // is it required that this be the only column? 199 200 for (i = 1; TRUE; i++) { 200 201 snprintf (key, 10, "TTYPE%d", i); -
branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_data.c
r38329 r38334 26 26 int gfits_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); 27 27 28 static int pass = 0;29 30 28 int gfits_uncompress_data (char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int out_pixsize) { 31 29 … … 33 31 static int Ninsum = 0; 34 32 static int Noutsum = 0; 33 34 // do not actually uncompress : this is used for testing 35 if (!strcasecmp(cmptype, "NONE")) { 36 memcpy (outdata, zdata, Nzdata); 37 *Nout = Nzdata / out_pixsize; 38 return (TRUE); 39 } 35 40 36 41 if (!strcasecmp(cmptype, "GZIP_1")) { … … 40 45 // XXX maybe not anymore 41 46 // gfits_gz_stripheader ((unsigned char *)zdata, &Nzdata); 42 43 if (pass == 0) {44 int i;45 for (i = 0; i < 32; i++) {46 fprintf (stderr, "0x%02hhx ", zdata[i]);47 }48 fprintf (stderr, "\n");49 pass = 1;50 }51 47 52 48 // uncompress does not require us to know the expected number of pixel; it tells us the number -
branches/eam_branches/ohana.20150429/src/libfits/table/F_compress_T.c
r38329 r38334 56 56 57 57 TableField *fields = NULL; 58 ALLOCATE (fields, TableField, Nfields);58 ALLOCATE_ZERO (fields, TableField, Nfields); 59 59 for (i = 0; i < Nfields; i++) { 60 60 snprintf (keyword, 80, "TTYPE%d", i+1); … … 129 129 130 130 fields[i].offset = offset; 131 offset += fields[i]. offset;131 offset += fields[i].rowsize; 132 132 } 133 133 134 134 // allocate the intermediate storage buffers 135 int Nzdata_alloc = max_width*ztilelen + 100; 135 136 ALLOCATE (raw, char, max_width*ztilelen); 136 ALLOCATE (zdata, char, max_width*ztilelen);137 ALLOCATE (zdata, char, Nzdata_alloc); 137 138 138 139 // compress the data : copy into a tile, compress the tile, then add to the output table … … 153 154 154 155 int Nraw = Nrows*fields[j].Nvalues; // number of pixels 155 int Nzdata = max_width*ztilelen; // available space, replaced with actual output size on compression156 int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression 156 157 if (!gfits_compress_data (zdata, &Nzdata, fields[j].zctype, NULL, NULL, 0, raw, Nraw, fields[j].pixsize)) ESCAPE(A); 157 158 -
branches/eam_branches/ohana.20150429/src/libfits/table/F_table_varlength.c
r38329 r38334 128 128 Nx = ftable->header->Naxis[0]; 129 129 130 # ifdef BYTE_SWAP131 char *pchar, tmp;132 pchar = &ftable->buffer[row*Nx + column->offset];133 SWAP_WORD;134 pchar = &ftable->buffer[row*Nx + column->offset + 4];135 SWAP_WORD;136 # endif137 138 130 if (column->mode == 'P') { 139 131 int *ptr; … … 156 148 // for varlength columns to the heap. To start, assume we have defined the cartesian 157 149 // portion of the table correctly, and are only extending the heap. 158 159 // XXX NOTE: this function assumes the table data is currently in local byte swap order.160 // swap before writing out161 150 162 151 int gfits_varlength_column_add_data (FTable *table, char *data, off_t Ndata, int row, VarLengthColumn *column) { -
branches/eam_branches/ohana.20150429/src/libfits/table/F_uncompress_T.c
r38329 r38334 68 68 69 69 fields[i].offset = offset; 70 offset += fields[i]. offset;70 offset += fields[i].rowsize; 71 71 72 72 if (!gfits_varlength_column_define (srctable, &fields[i].zdef, i + 1)) ESCAPE(A);
Note:
See TracChangeset
for help on using the changeset viewer.
