IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 3, 2015, 7:00:55 AM (11 years ago)
Author:
eugene
Message:

get the input / output / compressed pixels sizes right and get the byteswaps right

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_data.c

    r38340 r38356  
    3131
    3232  int status;
    33   static int Ninsum = 0;
    34   static int Noutsum = 0;
    3533
    3634  // do not actually uncompress : this is used for testing
     
    4240
    4341  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;
    4545
    4646    // for GZIP data, I need to check for and remove the header on the first block:
     
    5353    if (status != Z_OK) ESCAPE(FALSE);
    5454    *Nout = tNout / out_pixsize;
     55    // output value of *Nout is number of PIXELS
    5556
    5657    // the resulting uncompressed data is byteswapped
     
    6061  }
    6162
    62   if (!strcasecmp(cmptype, "RICE_1")) {
     63  if (!strcasecmp(cmptype, "RICE_1") || !strcasecmp(cmptype, "RICE_ONE")) {
    6364    int i, blocksize;
    6465    // look for the BLOCKSIZE
     
    7475    }
    7576
    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;
    8380
    8481    switch (out_pixsize) {
    8582      case 4:
    8683        // 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");
    9192        }
    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;
    10195      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;
    10898      default:
    10999        fprintf (stderr, "invalid output pixel size %d\n", out_pixsize);
    110         return (FALSE);
     100        status = FALSE;
     101        break;
    111102    }
    112    
     103    if (status) {
     104      *Nout = 0;
     105      return FALSE;
     106    }
     107    *Nout = Npix;
     108    return TRUE;
    113109  }
    114110 
Note: See TracChangeset for help on using the changeset viewer.