Changeset 39457 for trunk/Ohana/src/libfits/matrix/F_compress_data.c
- Timestamp:
- Mar 11, 2016, 10:23:42 PM (10 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/libfits/matrix/F_compress_data.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana
-
Property svn:mergeinfo
set to
/branches/eam_branches/ohana.20160226 merged eligible
-
Property svn:mergeinfo
set to
-
trunk/Ohana/src/libfits/matrix/F_compress_data.c
r38986 r39457 2 2 # include <gfitsio.h> 3 3 # include <zlib.h> 4 5 /* functions defined in ricecomp.c */ 6 int fits_rcomp(int a[], int nx, unsigned char *c, int clen, int nblock); 7 int fits_rcomp_short(short a[], int nx, unsigned char *c, int clen, int nblock); 8 int fits_rcomp_byte(char a[], int nx, unsigned char *c, int clen, int nblock); 9 int fits_rdecomp (unsigned char *c, int clen, unsigned int array[], int nx, int nblock); 10 int fits_rdecomp_short (unsigned char *c, int clen, unsigned short array[], int nx, int nblock); 11 int fits_rdecomp_byte (unsigned char *c, int clen, unsigned char array[], int nx, int nblock); 12 13 /* functions defined in fits_hcompress.c */ 14 # define LONGLONG long long 15 int fits_hcompress(int *a, int ny, int nx, int scale, char *output, long *nbytes, int *status); 16 int fits_hcompress64(LONGLONG *a, int ny, int nx, int scale, char *output, long *nbytes, int *status); 17 18 /* functions defined in fits_hdeccompress.c */ 19 int fits_hdecompress(unsigned char *input, int smooth, int *a, int *ny, int *nx, int *scale, int *status); 20 int fits_hdecompress64(unsigned char *input, int smooth, LONGLONG *a, int *ny, int *nx, int *scale, int *status); 21 22 /* functions defined in pliocomp.c */ 23 int pl_p2li (int *pxsrc, int xs, short *lldst, int npix); 24 int pl_l2pi (short *ll_src, int xs, int *px_dst, int npix); 25 26 /* functions defined in gzip.c */ 27 int gfits_gz_stripheader (unsigned char *data, int *ndata); 28 int gfits_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); 29 int gfits_compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); 4 # include <gfits_compress.h> 30 5 31 6 # define ESCAPE(RET) { fprintf (stderr, "gzip error in %s @ %s:%d\n", __func__, __FILE__, __LINE__); return (RET); } … … 33 8 // XXX I'm putting Nx and Ny on the argument list -- only used by hcompress 34 9 // with a little work, these could go on the option list 35 int gfits_compress_data (char *zdata, int *Nzdata, char *cmptype, 36 char **optname, char **optvalue, int Nopt, 37 char *rawdata, int Nrawpix, int rawpix_size, 38 int Nx, int Ny) { 10 int gfits_compress_data (char *zdata, unsigned long int *Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *rawdata, unsigned long int Nrawpix, int rawpix_size, int Nx, int Ny) { 39 11 40 int Nout;41 12 int status; 42 13 … … 68 39 69 40 if (!strcasecmp(cmptype, "RICE_1") || !strcasecmp(cmptype, "RICE_ONE")) { 41 long int Nout; 70 42 int i, blocksize; 71 43 // look for the BLOCKSIZE … … 85 57 // fprintf (stderr, "%d comp bytes; %d uncomp 'pixels', totals: %d %d\n", Nzdata, Npix, Ninsum, Noutsum); 86 58 87 int k;88 89 59 switch (rawpix_size) { 90 60 case 4: … … 98 68 99 69 if (0) { 100 fprintf (stderr, "Nout: %d, Nrawpix: %d\n", Nout, Nrawpix); 70 long int k; 71 fprintf (stderr, "Nout: %lu, Nrawpix: %lu\n", Nout, Nrawpix); 101 72 fprintf (stderr, "cmp inp: "); 102 73 for (k = 0; k < Nout; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 2) fprintf (stderr, " "); } … … 119 90 return (FALSE); 120 91 } 121 if (Nout > *Nzdata) {122 fprintf (stderr, "buffer overrun! % d out, %davailable\n", Nout, *Nzdata);92 if (Nout > (long int) *Nzdata) { 93 fprintf (stderr, "buffer overrun! %ld out, %lu available\n", Nout, *Nzdata); 123 94 return FALSE; 124 95 } 125 *Nzdata = Nout;96 *Nzdata = (unsigned long int) Nout; 126 97 return TRUE; 127 98 } … … 129 100 if (!strcasecmp(cmptype, "PLIO_1")) { 130 101 // note the fortan starting point: zdata is decremented at start 131 Nout = pl_p2li ((int *) rawdata, 1, (short *) zdata, Nrawpix);102 int Nout = pl_p2li ((int *) rawdata, 1, (short *) zdata, Nrawpix); 132 103 *Nzdata = Nout; 133 104 if (!Nout) return (FALSE);
Note:
See TracChangeset
for help on using the changeset viewer.
