IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23724


Ignore:
Timestamp:
Apr 7, 2009, 12:45:31 PM (17 years ago)
Author:
eugene
Message:

handle images compressed with CFITSIO gzip compression

Location:
trunk/Ohana/src/libfits
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libfits/Makefile

    r16093 r23724  
    6060$(EXT)/fits_hdecompress.$(ARCH).o \
    6161$(EXT)/pliocomp.$(ARCH).o \
    62 $(EXT)/ricecomp.$(ARCH).o
     62$(EXT)/ricecomp.$(ARCH).o \
     63$(EXT)/gzip.$(ARCH).o
    6364
    6465OBJS = $(HEADER_OBJ) $(MATRIX_OBJ) $(TABLE_OBJ) $(EXTERN_OBJ)
  • trunk/Ohana/src/libfits/matrix/F_compress_M.c

    r20652 r23724  
    248248    // XXX not certain this is the correct place to do the swap (or if zdata_pixsize is
    249249    // the correct size to guide the swap)
    250     if (!gfits_byteswap_zdata (zdata, Nzdata, zdata_pixsize)) return (FALSE);
     250
     251    if (strcasecmp(cmptype, "GZIP_1")) {
     252      if (!gfits_byteswap_zdata (zdata, Nzdata, zdata_pixsize)) return (FALSE);
     253    }
    251254
    252255    // gfits_uncompress_data uncompresses from zdata to the temporary output buffer which must be allocated
     
    496499
    497500  if (!strcasecmp(cmptype, "GZIP_1")) {
    498     return (4);
     501    if (out_bitpix == 8)  return (1);
     502    if (out_bitpix == 16) return (2);
     503    if (out_bitpix == 32) return (4);
     504    if (out_bitpix == -32) return (4);
     505    if (out_bitpix == -64) return (8);
     506    return (1);
    499507  }
    500508  if (!strcasecmp(cmptype, "RICE_1")) {
  • trunk/Ohana/src/libfits/matrix/F_uncompress_data.c

    r18272 r23724  
    2222int pl_l2pi (short *ll_src, int xs, int *px_dst, int npix);
    2323
     24/* functions defined in gzip.c */
     25int gfits_gz_stripheader (unsigned char *data, int *ndata);
     26int gfits_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
     27
    2428int gfits_uncompress_data (char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int out_pixsize) {
    2529
     
    3034  if (!strcasecmp(cmptype, "GZIP_1")) {
    3135    unsigned long tNout = *Nout * out_pixsize;
     36
     37    // for GZIP data, I need to check for and remove the header on the first block:
     38    gfits_gz_stripheader ((unsigned char *)zdata, &Nzdata);
     39
    3240    // uncompress does not require us to know the expected number of pixel; it tells us the number
    33     status = uncompress ((Bytef *) outdata, &tNout, (Bytef *) zdata, Nzdata);
     41    status = gfits_uncompress ((Bytef *) outdata, &tNout, (Bytef *) zdata, Nzdata);
    3442    if (status != Z_OK) {
    3543      fprintf (stderr, "error in uncompress (GZIP)\n");
    3644      return (FALSE);
    3745    }
    38     *Nout = tNout;
     46
     47    // the resulting uncompressed data is byteswapped
     48    if (!gfits_byteswap_zdata (outdata, tNout, out_pixsize)) return (FALSE);
     49
     50    *Nout = tNout / out_pixsize;
    3951    return (TRUE);
    4052  }
Note: See TracChangeset for help on using the changeset viewer.