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_M.c

    r38355 r38356  
    22# include <gfitsio.h>
    33# include <zlib.h>
     4# define VERBOSE_DUMP 0
    45
    56# define ESCAPE { \
     
    242243  // zdata_pixsize = gfits_vartable_heap_pixsize (zdef.format); XXX
    243244
    244   // size of a pixel in the final image (not needed)
    245   // idata_pixsize = abs(header[0].bitpix) / 8;
    246 
    247245  // size of a pixel in the output from the decompression routine
    248246  int cmp_pixsize = gfits_compressed_data_pixsize (cmptype, header[0].bitpix, optname, optvalue, Noptions);
     
    250248  int raw_pixsize = gfits_uncompressed_data_pixsize (cmptype, header[0].bitpix, optname, optvalue, Noptions);
    251249
     250  // size of a pixel in the final image (not needed)
     251  // int tile_pixsize = abs(header[0].bitpix) / 8;
     252  // fprintf (stderr, "raw_pixsize: %d, cmp_pixsize: %d, tile_pixsize: %d, raw_bitpix: %d\n", raw_pixsize, cmp_pixsize, tile_pixsize, raw_bitpix);
     253
    252254  int Nout_alloc = raw_pixsize*max_tile_size;
    253255  ALLOCATE (out, char, Nout_alloc);
     
    255257  off_t row;
    256258
    257   if (0) {
     259  if (VERBOSE_DUMP) {
    258260    int k;
    259261    fprintf (stderr, "unc tbl: ");
     
    273275    if (!zdata) ESCAPE;
    274276
    275     if (strcasecmp(cmptype, "GZIP_1")) {
    276       if (!gfits_byteswap_zdata (zdata, Nzdata, cmp_pixsize)) ESCAPE;
    277     }
    278 
    279     if (0 && (row == 0)) {
     277    if (VERBOSE_DUMP && (row == 0)) {
    280278      int k;
    281279      fprintf (stderr, "unc dat: ");
     
    284282    }
    285283
     284    if (strcasecmp(cmptype, "GZIP_1")) {
     285      // Nzdata is number of bytes
     286      if (!gfits_byteswap_zdata (zdata, Nzdata, cmp_pixsize)) ESCAPE;
     287    }
     288
     289    if (VERBOSE_DUMP && (row == 0)) {
     290      int k;
     291      fprintf (stderr, "unc SWP: ");
     292      for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", zdata[k]); }
     293      fprintf (stderr, "\n");
     294      fprintf (stderr, "Nout  : %d -> ", Nout);
     295    }
     296   
    286297    // gfits_uncompress_data uncompresses from zdata to the temporary output buffer which must be allocated
    287298    // XXX the tile must not be > 2GB
     299    // Nout going in is number of bytes
    288300    if (!gfits_uncompress_data ((char *)zdata, Nzdata, cmptype, optname, optvalue, Noptions, out, &Nout, raw_pixsize)) ESCAPE;
    289301
    290     if (0 && (row == 0)) {
     302    if (VERBOSE_DUMP && (row == 0)) {
    291303      int k;
     304      fprintf (stderr, "%d\n", Nout);
    292305      fprintf (stderr, "unc swp: ");
    293306      for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", out[k]); }
     
    296309   
    297310    if (!strcasecmp(cmptype, "GZIP_1")) {
    298       if (!gfits_byteswap_zdata (out, Nout, raw_pixsize)) ESCAPE;
     311      // Nout is number of pixels
     312      if (!gfits_byteswap_zdata (out, Nout * raw_pixsize, raw_pixsize)) ESCAPE;
    299313    }
    300314   
    301     if (0 && (row == 0)) {
     315    if (VERBOSE_DUMP && (row == 0)) {
    302316      int k;
    303317      fprintf (stderr, "unc raw: ");
     
    309323    if (!gfits_distribute_data (matrix, out, Nout, raw_bitpix, otile, oblank, ztile, zblank, zscale, zzero)) ESCAPE;
    310324
    311     if (0 && (row == 0)) {
     325    if (VERBOSE_DUMP && (row == 0)) {
    312326      int k;
    313327      fprintf (stderr, "unc mat: ");
Note: See TracChangeset for help on using the changeset viewer.