- Timestamp:
- Jun 3, 2015, 7:00:55 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_data.c
r38340 r38356 31 31 32 32 int status; 33 static int Ninsum = 0;34 static int Noutsum = 0;35 33 36 34 // do not actually uncompress : this is used for testing … … 42 40 43 41 if (!strcasecmp(cmptype, "GZIP_1")) { 44 unsigned long tNout = *Nout * out_pixsize; 42 // unsigned long tNout = *Nout * out_pixsize; 43 // input value of *Nout is number of BYTES 44 unsigned long tNout = *Nout; 45 45 46 46 // for GZIP data, I need to check for and remove the header on the first block: … … 53 53 if (status != Z_OK) ESCAPE(FALSE); 54 54 *Nout = tNout / out_pixsize; 55 // output value of *Nout is number of PIXELS 55 56 56 57 // the resulting uncompressed data is byteswapped … … 60 61 } 61 62 62 if (!strcasecmp(cmptype, "RICE_1") ) {63 if (!strcasecmp(cmptype, "RICE_1") || !strcasecmp(cmptype, "RICE_ONE")) { 63 64 int i, blocksize; 64 65 // look for the BLOCKSIZE … … 74 75 } 75 76 76 int Npix; 77 // Npix = *Nout * (out_pixsize / 4.0); 78 Npix = *Nout; 79 80 Ninsum += Nzdata; 81 Noutsum += *Nout; 82 // fprintf (stderr, "%d comp bytes; %d uncomp 'pixels', totals: %d %d\n", Nzdata, Npix, Ninsum, Noutsum); 77 int status = FALSE; 78 int Npix = *Nout / out_pixsize; 79 int k; 83 80 84 81 switch (out_pixsize) { 85 82 case 4: 86 83 // rice decompression from the CFITSIO source tree : we need to tell it the expected number of pixels 87 // is also REQUIRES 4byte output, which is fairly stupid. 88 if (fits_rdecomp ((unsigned char *) zdata, Nzdata, (unsigned int *) outdata, Npix, blocksize)) { 89 fprintf (stderr, "error in rice decompression\n"); 90 return (FALSE); 84 status = fits_rdecomp ((unsigned char *) zdata, Nzdata, (unsigned int *) outdata, Npix, blocksize); 85 break; 86 case 2: 87 if (0) { 88 fprintf (stderr, "Nout: %d, Nrawpix: %d\n", Nzdata, Npix); 89 fprintf (stderr, "cmp out: "); 90 for (k = 0; k < Nzdata; k++) { fprintf (stderr, "0x%02hhx ", zdata[k]); } 91 fprintf (stderr, "\n"); 91 92 } 92 return (TRUE); 93 94 case 2: 95 if (fits_rdecomp_short ((unsigned char *) zdata, Nzdata, (unsigned short *) outdata, Npix, blocksize)) { 96 fprintf (stderr, "error in rice decompression\n"); 97 return (FALSE); 98 } 99 return (TRUE); 100 93 status = fits_rdecomp_short ((unsigned char *) zdata, Nzdata, (unsigned short *) outdata, Npix, blocksize); 94 break; 101 95 case 1: 102 if (fits_rdecomp_byte ((unsigned char *) zdata, Nzdata, (unsigned char *) outdata, Npix, blocksize)) { 103 fprintf (stderr, "error in rice decompression\n"); 104 return (FALSE); 105 } 106 return (TRUE); 107 96 status = fits_rdecomp_byte ((unsigned char *) zdata, Nzdata, (unsigned char *) outdata, Npix, blocksize); 97 break; 108 98 default: 109 99 fprintf (stderr, "invalid output pixel size %d\n", out_pixsize); 110 return (FALSE); 100 status = FALSE; 101 break; 111 102 } 112 103 if (status) { 104 *Nout = 0; 105 return FALSE; 106 } 107 *Nout = Npix; 108 return TRUE; 113 109 } 114 110
Note:
See TracChangeset
for help on using the changeset viewer.
