IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 11, 2016, 10:23:42 PM (10 years ago)
Author:
eugene
Message:

modify to pass with extremely pedantic build; force consistency for signed vs unsigned and int sizes; various relastro updates

Location:
trunk/Ohana
Files:
21 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

  • trunk/Ohana/src/libfits/extern/gzip.c

    r38986 r39457  
    122122
    123123  z_stream stream;
    124   int i, err;
     124  int err;
    125125 
    126126  stream.next_in = (Bytef*)source;
     
    140140  if (EXTRA_VERBOSE) {
    141141    fprintf (stderr, "inp cmp: ");
     142    unsigned long int i;
    142143    for (i = 0; i < sourceLen; i++) {
    143144      fprintf (stderr, "0x%02hhx ", source[i]);
     
    165166  if (EXTRA_VERBOSE) {
    166167    fprintf (stderr, "out cmp: ");
     168    unsigned long int i;
    167169    for (i = 0; i < stream.total_out; i++) {
    168170      fprintf (stderr, "0x%02hhx ", dest[i]);
     
    182184
    183185  z_stream stream;
    184   int i, err;
     186  int err;
    185187 
    186188  stream.next_in = (Bytef*)source;
     
    200202  if (EXTRA_VERBOSE) {
    201203    fprintf (stderr, "inp unc: ");
     204    unsigned long int i;
    202205    for (i = 0; i < sourceLen; i++) {
    203206      fprintf (stderr, "0x%02hhx ", source[i]);
     
    226229  if (EXTRA_VERBOSE) {
    227230    fprintf (stderr, "out unc: ");
     231    unsigned long int i;
    228232    for (i = 0; i < stream.total_out; i++) {
    229233      fprintf (stderr, "0x%02hhx ", dest[i]);
  • trunk/Ohana/src/libfits/header/F_write_H.c

    r38553 r39457  
    2525    myAssert (myBlock->startblock == OHANA_MEMMAGIC, "bad memory");
    2626    myAssert (myBlock->endblock == OHANA_MEMMAGIC, "bad memory");
    27     myAssert (myBlock->size >= header[0].datasize, "overflow");
     27    myAssert (myBlock->size >= (size_t) header[0].datasize, "overflow");
    2828  }
    2929# endif
  • trunk/Ohana/src/libfits/include/gfitsio.h

    r39394 r39457  
    193193
    194194int     gfits_uncompress_image         PROTO((Header *header, Matrix *matrix, FTable *ftable));
    195 int     gfits_uncompress_data          PROTO((char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int Nout_alloc, int out_pixsize));
    196 int     gfits_distribute_data          PROTO((Matrix *matrix, char *data, int Ndata, int bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero));
    197 
    198 int     gfits_compress_data            PROTO((char *zdata, int *Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *rawdata, int Nraw, int raw_pixsize, int Nx, int Ny));
    199 int     gfits_compress_image           PROTO((Header *header, Matrix *matrix, FTable *ftable, int *Ztile, char *zcmptype));
    200 int     gfits_collect_data             PROTO((Matrix *matrix, char *raw, int Nraw, int raw_pixsize, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero));
     195int     gfits_uncompress_data          PROTO((char *zdata, unsigned long int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, unsigned long int *Nout, unsigned long int Nout_alloc, int out_pixsize));
     196int     gfits_distribute_data          PROTO((Matrix *matrix, char *data, unsigned long int Ndata, int bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero));
     197
     198int     gfits_compress_data            PROTO((char *zdata, unsigned long int *Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *rawdata, unsigned long int Nraw, int raw_pixsize, int Nx, int Ny));
     199int     gfits_compress_image           PROTO((Header *header, Matrix *matrix, FTable *ftable, unsigned long int *Ztile, char *zcmptype));
     200int     gfits_collect_data             PROTO((Matrix *matrix, char *raw, unsigned long int Nraw, int raw_pixsize, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero));
    201201
    202202int     gfits_copy_keywords_compress   PROTO((Header *srchead, Header *tgthead));
    203203int     gfits_swap_raw                 PROTO((Matrix *matrix));
    204204
    205 off_t   gfits_tile_size                PROTO((Matrix *matrix, int *otile, int *ztile));
    206 int     gfits_imtile_maxsize           PROTO((Matrix *matrix, int *ztile));
    207 int     gfits_imtile_count             PROTO((Matrix *matrix, int *ztile, int *ntile));
     205off_t   gfits_tile_size                PROTO((Matrix *matrix, int *otile, unsigned long int *ztile));
     206int     gfits_imtile_maxsize           PROTO((Matrix *matrix, unsigned long int *ztile));
     207int     gfits_imtile_count             PROTO((Matrix *matrix, unsigned long int *ztile, int *ntile));
    208208int     gfits_imtile_start             PROTO((Matrix *matrix, int *otile));
    209 int     gfits_imtile_next              PROTO((Matrix *matrix, int *ztile, int *ntile, int *otile));
     209int     gfits_imtile_next              PROTO((Matrix *matrix, unsigned long int *ztile, int *ntile, int *otile));
    210210
    211211int     gfits_extension_is_compressed_image  PROTO((Header *header));
    212212int     gfits_extension_is_compressed_table  PROTO((Header *header));
    213 int     gfits_byteswap_zdata            PROTO((char *zdata, int Nzdata, int pixsize));
     213int     gfits_byteswap_zdata            PROTO((char *zdata, off_t Nzdata, int pixsize));
    214214int     gfits_compressed_data_pixsize   PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions));
    215215int     gfits_uncompressed_data_pixsize PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions));
     
    279279int     gfits_write_Theader            PROTO((char *filename, Header *header));
    280280
    281 int     gfits_compress_table           PROTO((FTable *srctable, FTable *tgttable, int ztilelen, char *zcmptype));
     281int     gfits_compress_table           PROTO((FTable *srctable, FTable *tgttable, unsigned long int ztilelen, char *zcmptype));
    282282int     gfits_uncompress_table         PROTO((FTable *srctable, FTable *tgttable));
    283283
  • trunk/Ohana/src/libfits/matrix/F_compress_M.c

    r38441 r39457  
    44# define VERBOSE_DUMP 0
    55
    6 int gfits_collect_gzp2 (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero);
     6int gfits_collect_gzp2 (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero);
    77
    88// the user needs to specify the various compression options:
     
    2323# define ESCAPE { fprintf (stderr, "error in %s @ line %d\n", __func__, __LINE__); goto escape; }
    2424
    25 int gfits_compress_image (Header *header, Matrix *matrix, FTable *ftable, int *Ztile, char *zcmptype) {
     25int gfits_compress_image (Header *header, Matrix *matrix, FTable *ftable, unsigned long int *Ztile, char *zcmptype) {
    2626
    2727  int i;
     
    3333  char *zdata = NULL;
    3434
    35   int *ztile = Ztile;
     35  unsigned long int *ztile = Ztile;
    3636
    3737  Header *theader = ftable->header;
     
    4141  // determine the number of tiles (from ztile[] and image size)
    4242  if (!ztile) {
    43     ALLOCATE (ztile, int, matrix->Naxes);
     43    ALLOCATE (ztile, unsigned long int, matrix->Naxes);
    4444    ztile[0] = matrix->Naxis[0];
    4545    for (i = 1; i < matrix->Naxes; i++) ztile[i] = 1;
     
    9999  for (i = 0; i < header->Naxes; i++) {
    100100    snprintf (keyword, 10, "ZTILE%d", i + 1);
    101     if (!gfits_modify (theader, keyword, "%d", 1, ztile[i])) ESCAPE;
     101    if (!gfits_modify (theader, keyword, "%lu", 1, ztile[i])) ESCAPE;
    102102  }
    103103
     
    157157
    158158  // size (in pixels) of the largest tile
    159   int max_tile_size = gfits_imtile_maxsize (matrix, ztile);
     159  unsigned long int max_tile_size = gfits_imtile_maxsize (matrix, ztile);
    160160
    161161  // size of a pixel in the raw pixel buffer (before compression)
     
    179179
    180180  // allocate the buffer for compression work
    181   int Nzdata_alloc = raw_pixsize*max_tile_size + 100;
     181  unsigned long int Nzdata_alloc = raw_pixsize*max_tile_size + 100;
    182182  ALLOCATE (raw,   char, raw_pixsize*max_tile_size);
    183183  ALLOCATE (zdata, char, Nzdata_alloc);
     
    191191
    192192    // size of the current tile in pixels
    193     int Nraw = gfits_tile_size (matrix, otile, ztile);
     193    unsigned long int Nraw = gfits_tile_size (matrix, otile, ztile);
    194194
    195195    // copy the raw pixels from their native matrix locations to the temporary output buffer
     
    216216      if (!gfits_byteswap_zdata (raw, Nraw * raw_pixsize, raw_pixsize)) ESCAPE;
    217217    }
    218     int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression
     218    unsigned long int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression
    219219
    220220    if (VERBOSE_DUMP && (i == 0)) {
     
    223223      for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", raw[k]); if (k % 4 == 3) fprintf (stderr, " "); }
    224224      fprintf (stderr, "\n");
    225       fprintf (stderr, "Nzdata: %d -> ", Nzdata);
     225      fprintf (stderr, "Nzdata: %lu -> ", Nzdata);
    226226    }
    227227
     
    231231    if (VERBOSE_DUMP && (i == 0)) {
    232232      int k;
    233       fprintf (stderr, "%d\n", Nzdata);
     233      fprintf (stderr, "%lu\n", Nzdata);
    234234      fprintf (stderr, "cmp SWP: ");
    235235      for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 4 == 3) fprintf (stderr, " "); }
     
    290290
    291291int gfits_copy_keywords_compress (Header *srchead, Header *tgthead) {
    292 
     292  OHANA_UNUSED_PARAM(tgthead);
     293  OHANA_UNUSED_PARAM(srchead);
     294
     295# if (0)
    293296  int i;
    294297
    295298  for (i = 0; i < srchead->datasize; i += FT_LINE_LENGTH) {
    296299  }
     300# endif
     301
    297302  return TRUE;
    298303}
     
    303308// * ztile gives the size of the i-th dimension of the current tile
    304309// * raw_bitpix defines the size and type of the raw buffer
    305 int gfits_collect_data (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero) {
    306 
    307   int i, j, start, offset, coord, Nline;
    308   int *counter = NULL;
    309   int *Ztile = NULL;
    310 
    311   ALLOCATE (counter, int, matrix->Naxes); // counter for current row in tile to copy
    312   ALLOCATE (Ztile, int, matrix->Naxes); // true sizes of this tile (in pixels)
     310int gfits_collect_data (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero) {
     311
     312  int i, k, start, offset, coord, Nline;
     313  unsigned int *counter = NULL;
     314  unsigned long int *Ztile = NULL;
     315
     316  ALLOCATE (counter, unsigned int, matrix->Naxes); // counter for current row in tile to copy
     317  ALLOCATE (Ztile, unsigned long int, matrix->Naxes); // true sizes of this tile (in pixels)
    313318 
    314319  for (i = 0; i < matrix->Naxes; i++) {
     
    343348  // this macro is used at the inner switch to run the actual loop
    344349# define SCALE_AND_DIST_INT_PRINT(TYPE, SIZE, INTYPE) {                 \
     350    unsigned long int j;                                                \
    345351    TYPE *TILEptr = (TYPE *) &matrix->buffer[SIZE*(offset + start)];    \
    346352    for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {               \
     
    356362  // this macro is used at the inner switch to run the actual loop
    357363# define SCALE_AND_DIST_INT(OTYPE, OSIZE) {                             \
     364    unsigned long int j;                                                \
    358365    OTYPE *TILEptr = (OTYPE *) &matrix->buffer[OSIZE*(offset + start)]; \
    359366    for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {               \
     
    370377  // this macro is used at the inner switch to run the actual loop
    371378# define SCALE_AND_DIST_FLOAT(OTYPE, OSIZE) {                           \
     379    unsigned long int j;                                                \
    372380    OTYPE *TILEptr = (OTYPE *) &matrix->buffer[OSIZE*(offset + start)]; \
    373381    for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {               \
     
    419427
    420428    // update the counters, carrying to the next dimension if needed
    421     for (j = 1; j < matrix->Naxes; j++) {
    422       counter[j] ++;
    423       if (counter[j] == Ztile[j]) {
    424         counter[j] = 0;
     429    for (k = 1; k < matrix->Naxes; k++) {
     430      counter[k] ++;
     431      if (counter[k] == Ztile[k]) {
     432        counter[k] = 0;
    425433      } else {
    426434        break;
    427435      }
    428436    }
    429     if (j == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
     437    if (k == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
    430438
    431439    // Naxes = 3
     
    435443    // determine the offset of the next line relative to the start position
    436444    offset = counter[matrix->Naxes - 1];
    437     for (j = matrix->Naxes - 2; j >= 0; j--) {
    438       offset = offset*matrix->Naxis[j] + counter[j];
     445    for (k = matrix->Naxes - 2; k >= 0; k--) {
     446      offset = offset*matrix->Naxis[k] + counter[k];
    439447    }     
    440448  }
     
    453461// * ztile gives the size of the i-th dimension of the current tile
    454462// * raw_bitpix defines the size and type of the raw buffer
    455 int gfits_collect_gzp2 (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero) {
    456 
    457   int i, j, k;
    458   int *counter = NULL;
    459   int *Ztile = NULL;
    460 
    461   ALLOCATE (counter, int, matrix->Naxes); // counter for current row in tile to copy
    462   ALLOCATE (Ztile, int, matrix->Naxes); // true sizes of this tile (in pixels)
     463int gfits_collect_gzp2 (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero) {
     464  OHANA_UNUSED_PARAM(oblank);
     465  OHANA_UNUSED_PARAM(zblank);
     466  OHANA_UNUSED_PARAM(zzero);
     467  OHANA_UNUSED_PARAM(zscale);
     468
     469  unsigned long int i, j;
     470  unsigned int *counter = NULL;
     471  unsigned long int *Ztile = NULL;
     472
     473  ALLOCATE (counter, unsigned int, matrix->Naxes); // counter for current row in tile to copy
     474  ALLOCATE (Ztile, unsigned long int, matrix->Naxes); // true sizes of this tile (in pixels)
    463475 
    464   for (i = 0; i < matrix->Naxes; i++) {
    465     counter[i] = 0;
    466     Ztile[i] = MIN ((matrix->Naxis[i] - otile[i]*ztile[i]), ztile[i]);
     476  int k;
     477  for (k = 0; k < matrix->Naxes; k++) {
     478    counter[k] = 0;
     479    Ztile[k] = MIN ((matrix->Naxis[k] - otile[k]*ztile[k]), ztile[k]);
    467480  }
    468481
    469482  // number of lines in the tile (in pixels)
    470   int Nline = 1;
    471   int Npix = matrix->Naxis[0];
    472   for (i = 1; i < matrix->Naxes; i++) {
    473     Nline *= Ztile[i];
    474     Npix  *= matrix->Naxis[i];
     483  unsigned long int Nline = 1;
     484  unsigned long int Npix = matrix->Naxis[0];
     485  for (k = 1; k < matrix->Naxes; k++) {
     486    Nline *= Ztile[k];
     487    Npix  *= matrix->Naxis[k];
    475488  }
    476489
     
    482495  // start = otile[0]*ztile[0] + Naxis[0]*(otile[1]*ztile[1] + Naxis[1]*(otile[2]*ztile[2] + ...));
    483496  int start = otile[matrix->Naxes-1]*ztile[matrix->Naxes-1];
    484   for (i = matrix->Naxes - 2; i >= 0; i--) {
    485     int coord = otile[i]*ztile[i];
    486     start = start*matrix->Naxis[i] + coord;
     497  for (k = matrix->Naxes - 2; k >= 0; k--) {
     498    unsigned long int coord = otile[k]*ztile[k];
     499    start = start*matrix->Naxis[k] + coord;
    487500  }
    488501 
     
    519532
    520533      // update the counters, carrying to the next dimension if needed
    521       for (j = 1; j < matrix->Naxes; j++) {
    522         counter[j] ++;
    523         if (counter[j] == Ztile[j]) {
    524           counter[j] = 0;
     534      int axis;
     535      for (axis = 1; axis < matrix->Naxes; axis++) {
     536        counter[axis] ++;
     537        if (counter[axis] == Ztile[axis]) {
     538          counter[axis] = 0;
    525539        } else {
    526540          break;
    527541        }
    528542      }
    529       if (j == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
     543      if (axis == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
    530544
    531545      // Naxes = 3
     
    535549      // determine the offset of the next line relative to the start position
    536550      offset = counter[matrix->Naxes - 1];
    537       for (j = matrix->Naxes - 2; j >= 0; j--) {
    538         offset = offset*matrix->Naxis[j] + counter[j];
     551      for (axis = matrix->Naxes - 2; axis >= 0; axis--) {
     552        offset = offset*matrix->Naxis[axis] + counter[axis];
    539553      }     
    540554    }
  • trunk/Ohana/src/libfits/matrix/F_compress_data.c

    r38986 r39457  
    22# include <gfitsio.h>
    33# 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>
    305
    316# define ESCAPE(RET) { fprintf (stderr, "gzip error in %s @ %s:%d\n", __func__, __FILE__, __LINE__); return (RET); }
     
    338// XXX I'm putting Nx and Ny on the argument list -- only used by hcompress
    349// 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) {
     10int 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) {
    3911
    40   int Nout;
    4112  int status;
    4213
     
    6839
    6940  if (!strcasecmp(cmptype, "RICE_1") || !strcasecmp(cmptype, "RICE_ONE")) {
     41    long int Nout;
    7042    int i, blocksize;
    7143    // look for the BLOCKSIZE
     
    8557    // fprintf (stderr, "%d comp bytes; %d uncomp 'pixels', totals: %d %d\n", Nzdata, Npix, Ninsum, Noutsum);
    8658
    87     int k;
    88 
    8959    switch (rawpix_size) {
    9060      case 4:
     
    9868
    9969        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);
    10172          fprintf (stderr, "cmp inp: ");
    10273          for (k = 0; k < Nout; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 2) fprintf (stderr, " "); }
     
    11990      return (FALSE);
    12091    }
    121     if (Nout > *Nzdata) {
    122       fprintf (stderr, "buffer overrun! %d out, %d available\n", Nout, *Nzdata);
     92    if (Nout > (long int) *Nzdata) {
     93      fprintf (stderr, "buffer overrun! %ld out, %lu available\n", Nout, *Nzdata);
    12394      return FALSE;
    12495    }
    125     *Nzdata = Nout;
     96    *Nzdata = (unsigned long int) Nout;
    12697    return TRUE;
    12798  }
     
    129100  if (!strcasecmp(cmptype, "PLIO_1")) {
    130101    // 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);
    132103    *Nzdata = Nout;
    133104    if (!Nout) return (FALSE);
  • trunk/Ohana/src/libfits/matrix/F_compress_utils.c

    r38441 r39457  
    1717
    1818typedef struct {
    19   int *ztile; // max size of a tile (edge tiles may be smaller)
     19  unsigned long int *ztile; // max size of a tile (edge tiles may be smaller)
    2020  int *otile; // counter for current tile (eg, for (2,3,0) otile[0] = 2, otile[1] = 3, otile[2] = 0)
    2121  int *ntile; // number of tiles in dimension [i]
     
    2323
    2424// advance the otile counter.
    25 int gfits_imtile_next (Matrix *matrix, int *ztile, int *ntile, int *otile) {
     25int gfits_imtile_next (Matrix *matrix, unsigned long int *ztile, int *ntile, int *otile) {
     26  OHANA_UNUSED_PARAM(ztile);
    2627
    2728  int i;
     
    5354
    5455// how many tiles needed for this image (given ztile[])
    55 int gfits_imtile_count (Matrix *matrix, int *ztile, int *ntile) {
     56int gfits_imtile_count (Matrix *matrix, unsigned long int *ztile, int *ntile) {
    5657
    5758  int i;
     
    6768
    6869// how many tiles needed for this image (given ztile[])
    69 int gfits_imtile_maxsize (Matrix *matrix, int *ztile) {
     70int gfits_imtile_maxsize (Matrix *matrix, unsigned long int *ztile) {
    7071
    7172  int i;
    7273
    73   int max_tile_size = 1;
     74  unsigned long int max_tile_size = 1;
    7475  for (i = 0; i < matrix->Naxes; i++) {
    7576    max_tile_size *= ztile[i];
     
    8081
    8182// true sizes of this tile (in pixels)
    82 off_t gfits_tile_size (Matrix *matrix, int *otile, int *ztile) {
     83off_t gfits_tile_size (Matrix *matrix, int *otile, unsigned long int *ztile) {
    8384
    8485  off_t i, Npixels, Ndimen;
     
    9394}
    9495
    95 int gfits_byteswap_zdata (char *zdata, int Nzdata, int pixsize) {
     96int gfits_byteswap_zdata (char *zdata, off_t Nzdata, int pixsize) {
    9697
    9798# define DOSWAP(A,B) { char tmp = A; A = B; B = tmp; }
     
    99100# ifdef BYTE_SWAP
    100101
    101   int i;
     102  off_t i;
    102103
    103104  // fprintf (stderr, "swapping %d bytes in pix of size %d bytes...\n", Nzdata, pixsize);
  • trunk/Ohana/src/libfits/matrix/F_convert_format.c

    r38062 r39457  
    1919  in  = (inMode  *) matrix[0].buffer;                   \
    2020  for (i = 0; i < Npixels; i++, out++, in++)            \
    21     if (*in == inBlank) {                               \
     21    if (*in == (inMode) inBlank) {                      \
    2222      *out = (MY_NAN);                                  \
    2323    } else {                                            \
     
    3232  in  = (inMode  *) matrix[0].buffer;           \
    3333  for (i = 0; i < Npixels; i++, out++, in++)    \
    34     if (*in == inBlank) {                       \
     34    if (*in == (inMode) inBlank) {                      \
    3535      *out = (MY_NAN);                          \
    3636    } else {                                    \
     
    4545  in  = (inMode  *)matrix[0].buffer + Npixels - 1;      \
    4646  for (i = 0; i < Npixels; i++, out--, in--)            \
    47     if (*in == inBlank) {                               \
     47    if (*in == (inMode) inBlank) {                              \
    4848      *out = (MY_NAN);                                  \
    4949    } else {                                            \
  • trunk/Ohana/src/libfits/matrix/F_uncompress_M.c

    r38989 r39457  
    44# define VERBOSE_DUMP 0
    55
    6 int gfits_distribute_gzp2 (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero);
    7 
    8 # define ESCAPE { \
    9   fprintf (stderr, "error in %s @ line %d\n", __func__, __LINE__); \
    10   if (ztile != NULL) free (ztile); \
    11   if (optname != NULL) { \
    12     for (j = 0; j < Noptions; j++) { \
    13       free (optname[j]); \
    14       free (optvalue[j]); \
    15     } \
    16     free (optname); \
    17     free (optvalue); \
    18   } \
    19   if (out != NULL) free (out); \
    20   if (otile != NULL) free (otile); \
    21   if (ntile != NULL) free (ntile); \
    22   return (FALSE); }
    23 
    24 # define MOD_KEYWORD(ZNAME,NAME,TYPE,IN,OUT) { \
     6int gfits_distribute_gzp2 (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero);
     7
     8# define ESCAPE {                                                       \
     9    fprintf (stderr, "error in %s @ line %d\n", __func__, __LINE__);    \
     10    if (ztile != NULL) free (ztile);                                    \
     11    if (optname != NULL) {                                              \
     12      int opt;                                                          \
     13      for (opt = 0; opt < Noptions; opt++) {                            \
     14        free (optname[opt]);                                            \
     15        free (optvalue[opt]);                                           \
     16      }                                                                 \
     17      free (optname);                                                   \
     18      free (optvalue);                                                  \
     19    }                                                                   \
     20    if (out != NULL) free (out);                                        \
     21    if (otile != NULL) free (otile);                                    \
     22    if (ntile != NULL) free (ntile);                                    \
     23    return (FALSE); }
     24
     25# define MOD_KEYWORD(ZNAME,NAME,TYPE,IN,OUT) {     \
    2526    if (gfits_scan (header, ZNAME, TYPE, 1, IN)) { \
    26       gfits_modify (header, NAME, TYPE, 1, OUT); \
    27     } \
     27      gfits_modify (header, NAME, TYPE, 1, OUT);   \
     28    }                                              \
    2829    gfits_delete (header, ZNAME, 1); }
    2930
    30 # define MOD_KEYWORD_ALT(ZNAME,NAME,TYPE,IN,OUT) { \
     31# define MOD_KEYWORD_ALT(ZNAME,NAME,TYPE,IN,OUT) {     \
    3132    if (gfits_scan_alt (header, ZNAME, TYPE, 1, IN)) { \
    32       gfits_modify_alt (header, NAME, TYPE, 1, OUT); \
    33     } \
     33      gfits_modify_alt (header, NAME, TYPE, 1, OUT);   \
     34    }                                                  \
    3435    gfits_delete (header, ZNAME, 1); }
    3536
    36 # define MOD_KEYWORD_REQUIRED(ZNAME,NAME,TYPE,IN,OUT) { \
    37   if (!gfits_scan (header, ZNAME, TYPE, 1, IN)) ESCAPE; \
    38   gfits_delete (header, ZNAME, 1); \
    39   gfits_modify (header, NAME, TYPE, 1, OUT); }
     37# define MOD_KEYWORD_REQUIRED(ZNAME,NAME,TYPE,IN,OUT) {         \
     38    if (!gfits_scan (header, ZNAME, TYPE, 1, IN)) ESCAPE;       \
     39    gfits_delete (header, ZNAME, 1);                            \
     40    gfits_modify (header, NAME, TYPE, 1, OUT); }
    4041
    4142int gfits_uncompress_image (Header *header, Matrix *matrix, FTable *ftable) {
    4243
     44  int status, zimage;
    4345  off_t Nzdata, Nzrows, zcol;
    44   int i, j, status, zimage, Nout, max_tile_size;
     46  unsigned long int max_tile_size;
    4547  char cmptype[80];
    4648  char zaxis[10], naxis[10], key[10], word[81], exttype[81], checksum[81], datasum[81];
     
    4951  float zscale, zzero;
    5052
    51   int *ztile = NULL;
     53  unsigned long int *ztile = NULL;
    5254  int *otile = NULL;
    5355  int *ntile = NULL;
     
    7779  MOD_KEYWORD_REQUIRED ("ZNAXIS",  "NAXIS",  "%d", &header->Naxes,  header->Naxes);
    7880
    79   for (i = 0; i < header->Naxes; i++) {
    80     snprintf (zaxis, 10, "ZNAXIS%d", i + 1);
    81     snprintf (naxis, 10, "NAXIS%d", i + 1);
    82     MOD_KEYWORD_REQUIRED (zaxis,  naxis,  OFF_T_FMT,  &header->Naxis[i],  header->Naxis[i]);
     81  int axis;
     82  for (axis = 0; axis < header->Naxes; axis++) {
     83    snprintf (zaxis, 10, "ZNAXIS%d", axis + 1);
     84    snprintf (naxis, 10, "NAXIS%d", axis + 1);
     85    MOD_KEYWORD_REQUIRED (zaxis,  naxis,  OFF_T_FMT,  &header->Naxis[axis],  header->Naxis[axis]);
    8386  }   
    8487
     
    8689  // the actual tile size may be smaller at the edge of a dimension.  if the ZTILEn
    8790  // entries are not found, default to [Nx,1,1,...]
    88   ALLOCATE (ztile, int, header->Naxes);
    89   if (!gfits_scan (header, "ZTILE1", "%d", 1, &ztile[0])) {
     91  ALLOCATE (ztile, unsigned long int, header->Naxes);
     92  if (!gfits_scan (header, "ZTILE1", "%lu", 1, &ztile[0])) {
    9093    ztile[0] = header->Naxis[0];
    91     for (i = 1; i < header->Naxes; i++) {
    92       ztile[i] = 1;
     94    for (axis = 1; axis < header->Naxes; axis++) {
     95      ztile[axis] = 1;
    9396    }
    9497  } else {
    9598    gfits_delete (header, "ZTILE1", 1);
    96     for (i = 1; i < header->Naxes; i++) {
    97       snprintf (key, 10, "ZTILE%d", i + 1);
    98       if (!gfits_scan (header, key, "%d", 1, &ztile[i])) ESCAPE;
     99    for (axis = 1; axis < header->Naxes; axis++) {
     100      snprintf (key, 10, "ZTILE%d", axis + 1);
     101      if (!gfits_scan (header, key, "%lu", 1, &ztile[axis])) ESCAPE;
    99102      gfits_delete (header, key, 1);
    100103    }
     
    199202  // find the COMPRESSED_DATA column (format should be 1PB, 1PI, 1PJ)
    200203  // is it required that this be the only column?
    201   for (i = 1; TRUE; i++) {
    202     snprintf (key, 10, "TTYPE%d", i);
     204  int colnum;
     205  for (colnum = 1; TRUE; colnum++) {
     206    snprintf (key, 10, "TTYPE%d", colnum);
    203207    if (!gfits_scan (ftable->header, key, "%s", 1, word)) ESCAPE;
    204208    if (!strcmp (word, "COMPRESSED_DATA")) break;
    205209  }
    206   zcol = i;
     210  zcol = colnum;
    207211
    208212  if (!gfits_varlength_column_define (ftable, &zdef, zcol)) ESCAPE;
     
    220224  ALLOCATE (ntile, int, matrix->Naxes);
    221225  max_tile_size = 1;
    222   for (i = 0; i < matrix->Naxes; i++) {
    223     otile[i] = 0;
    224     ntile[i] = (matrix->Naxis[i] % ztile[i]) ? (matrix->Naxis[i] / ztile[i] + 1) : (matrix->Naxis[i] / ztile[i]);
    225     max_tile_size *= ztile[i];
    226 
    227     // ztile[i] is the default (or max) tile size in the i-th dimension
    228     // ntile[i] is the number of tiles in the i-th dimension
    229     // otile[i] is the current output tile counter in the i-th dimension
     226  for (axis = 0; axis < matrix->Naxes; axis++) {
     227    otile[axis] = 0;
     228    ntile[axis] = (matrix->Naxis[axis] % ztile[axis]) ? (matrix->Naxis[axis] / ztile[axis] + 1) : (matrix->Naxis[axis] / ztile[axis]);
     229    max_tile_size *= ztile[axis];
     230
     231    // ztile[axis] is the default (or max) tile size in the i-th dimension
     232    // ntile[axis] is the number of tiles in the i-th dimension
     233    // otile[axis] is the current output tile counter in the i-th dimension
    230234  }
    231235
     
    254258  // fprintf (stderr, "raw_pixsize: %d, cmp_pixsize: %d, tile_pixsize: %d, raw_bitpix: %d\n", raw_pixsize, cmp_pixsize, tile_pixsize, raw_bitpix);
    255259
    256   int Nout_alloc = raw_pixsize*max_tile_size;
     260  unsigned long int Nout_alloc = raw_pixsize*max_tile_size;
    257261  ALLOCATE (out, char, Nout_alloc);
    258262
     
    271275
    272276    // expected output size for this tile
    273     Nout = raw_pixsize*gfits_tile_size (matrix, otile, ztile);
     277    unsigned long Nout = raw_pixsize*gfits_tile_size (matrix, otile, ztile);
    274278
    275279    zdata = gfits_varlength_column_pointer (ftable, &zdef, row, &Nzdata);
     
    297301      for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 4 == 3) fprintf (stderr, " "); }
    298302      fprintf (stderr, "\n");
    299       fprintf (stderr, "Nout  : %d -> ", Nout);
     303      fprintf (stderr, "Nout  : %lu -> ", Nout);
    300304    }
    301305   
     
    307311    if (VERBOSE_DUMP && (row == 0)) {
    308312      int k;
    309       fprintf (stderr, "%d\n", Nout);
     313      fprintf (stderr, "%lu\n", Nout);
    310314      fprintf (stderr, "unc swp: ");
    311315      for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", out[k]); if (k % 4 == 3) fprintf (stderr, " "); }
     
    315319    if (!strcasecmp(cmptype, "GZIP_1")) {
    316320      // Nout is number of pixels
    317       if (!gfits_byteswap_zdata (out, Nout * raw_pixsize, raw_pixsize)) ESCAPE;
     321      if (!gfits_byteswap_zdata (out, (off_t) (Nout * raw_pixsize), raw_pixsize)) ESCAPE;
    318322    }
    319323   
     
    340344
    341345    // update the tile counters, carrying to the next dimension if needed
    342     for (j = 0; j < matrix->Naxes; j++) {
    343       otile[j] ++;
    344       if (otile[j] == ntile[j]) {
    345         otile[j] = 0;
     346    for (axis = 0; axis < matrix->Naxes; axis++) {
     347      otile[axis] ++;
     348      if (otile[axis] == ntile[axis]) {
     349        otile[axis] = 0;
    346350      } else {
    347351        break;
     
    352356  FREE (ztile);
    353357  if (optname != NULL) {
    354     for (j = 0; j < Noptions; j++) {
    355       FREE (optname[j]);
    356       FREE (optvalue[j]);
     358    int opt;
     359    for (opt = 0; opt < Noptions; opt++) {
     360      FREE (optname[opt]);
     361      FREE (optvalue[opt]);
    357362    }
    358363    FREE (optname);
     
    366371
    367372// bitpix is the input data size/type
    368 int gfits_distribute_data (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero) {
    369 
    370   int i, j;
    371   int *counter = NULL;
    372   int *Ztile = NULL;
    373 
    374   ALLOCATE (counter, int, matrix->Naxes);
    375   ALLOCATE (Ztile, int, matrix->Naxes);
     373int gfits_distribute_data (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero) {
     374
     375  int axis;
     376  unsigned int *counter = NULL;
     377  unsigned long int *Ztile = NULL;
     378
     379  ALLOCATE (counter, unsigned int, matrix->Naxes);
     380  ALLOCATE (Ztile, unsigned long int, matrix->Naxes);
    376381
    377382  // counter for current row in tile to copy
    378383  // true sizes of this tile (in pixels)
    379   for (i = 0; i < matrix->Naxes; i++) {
    380     counter[i] = 0;
    381     Ztile[i] = MIN ((matrix->Naxis[i] - otile[i]*ztile[i]), ztile[i]);
     384  for (axis = 0; axis < matrix->Naxes; axis++) {
     385    counter[axis] = 0;
     386    Ztile[axis] = MIN ((matrix->Naxis[axis] - otile[axis]*ztile[axis]), ztile[axis]);
    382387  }
    383388
    384389  // number of lines in the tile (in pixels)
    385   int Nline = 1;
    386   for (i = 1; i < matrix->Naxes; i++) {
    387     Nline *= Ztile[i];
     390  unsigned long int Nline = 1;
     391  for (axis = 1; axis < matrix->Naxes; axis++) {
     392    Nline *= Ztile[axis];
    388393  }
    389394
     
    394399  // start = otile[0]*ztile[0] + otile[1]*ztile[1]*Naxis[0] + otile[2]*ztile[2]*Naxis[0]*Naxis[1] + ...;
    395400  // start = otile[0]*ztile[0] + Naxis[0]*(otile[1]*ztile[1] + Naxis[1]*(otile[2]*ztile[2] + ...));
    396   int start = otile[matrix->Naxes-1]*ztile[matrix->Naxes-1];
    397   for (i = matrix->Naxes - 2; i >= 0; i--) {
    398     int coord = otile[i]*ztile[i];
    399     start = start*matrix->Naxis[i] + coord;
     401  unsigned long int start = otile[matrix->Naxes-1]*ztile[matrix->Naxes-1];
     402  for (axis = matrix->Naxes - 2; axis >= 0; axis--) {
     403    unsigned long int coord = otile[axis]*ztile[axis];
     404    start = start*matrix->Naxis[axis] + coord;
    400405  }
    401406 
    402407  // pixel offset in output array relative to tile start
    403   int offset = 0;
     408  unsigned long int offset = 0;
    404409
    405410  int directCopy = (zzero == 0.0) && (zscale == 1.0);
    406411
    407412# define SCALE_AND_DIST_INT_PRINT(TYPE, SIZE) {                         \
     413    unsigned long j;                                                    \
    408414    TYPE *TILEptr = (TYPE *) &matrix->buffer[SIZE*(offset + start)];    \
    409415    for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {               \
     
    418424  // this macro is used at the inner switch to run the actual loop
    419425# define SCALE_AND_DIST_INT(OTYPE, OSIZE) {                             \
     426    unsigned long j;                                                    \
    420427    OTYPE *TILEptr = (OTYPE *) &matrix->buffer[OSIZE*(offset + start)]; \
    421428    for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {               \
     
    432439  // this macro is used at the inner switch to run the actual loop
    433440# define SCALE_AND_DIST_FLOAT(OTYPE, OSIZE) {                           \
     441    unsigned long j;                                                    \
    434442    OTYPE *TILEptr = (OTYPE *) &matrix->buffer[OSIZE*(offset + start)]; \
    435443    for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {               \
     
    461469      case   8: SCALE_AND_DIST_INT   (char,   1); break; \
    462470      case  16: SCALE_AND_DIST_INT   (short,  2); break; \
    463       case  32: SCALE_AND_DIST_INT (int,    4); break; \
     471      case  32: SCALE_AND_DIST_INT   (int,    4); break; \
    464472      case -32: SCALE_AND_DIST_FLOAT (float,  4); break; \
    465473      case -64: SCALE_AND_DIST_FLOAT (double, 8); break; \
     
    468476
    469477  // loop over lines in the tile
     478  unsigned long int i;
    470479  for (i = 0; i < Nline; i++) {
    471480    switch (raw_bitpix) {
     
    479488
    480489    // update the counters, carrying to the next dimension if needed
    481     for (j = 1; j < matrix->Naxes; j++) {
    482       counter[j] ++;
    483       if (counter[j] == Ztile[j]) {
    484         counter[j] = 0;
     490    for (axis = 1; axis < matrix->Naxes; axis++) {
     491      counter[axis] ++;
     492      if (counter[axis] == Ztile[axis]) {
     493        counter[axis] = 0;
    485494      } else {
    486495        break;
    487496      }
    488497    }
    489     if (j == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
     498    if (axis == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
    490499
    491500    // Naxes = 3
     
    495504    // determine the offset of the next line relative to the start position
    496505    offset = counter[matrix->Naxes - 1];
    497     for (j = matrix->Naxes - 2; j >= 0; j--) {
    498       offset = offset*matrix->Naxis[j] + counter[j];
     506    for (axis = matrix->Naxes - 2; axis >= 0; axis--) {
     507      offset = offset*matrix->Naxis[axis] + counter[axis];
    499508    }     
    500509  }
     
    506515
    507516// bitpix is the input data size/type
    508 int gfits_distribute_gzp2 (Matrix *matrix, char *raw, int Nraw, int raw_bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero) {
    509 
    510   int i, j, k;
    511   int *counter = NULL;
    512   int *Ztile = NULL;
    513 
    514   ALLOCATE (counter, int, matrix->Naxes);
    515   ALLOCATE (Ztile, int, matrix->Naxes);
     517int gfits_distribute_gzp2 (Matrix *matrix, char *raw, unsigned long int Nraw, int raw_bitpix, int *otile, int oblank, unsigned long int *ztile, int zblank, float zscale, float zzero) {
     518  OHANA_UNUSED_PARAM(oblank);
     519  OHANA_UNUSED_PARAM(zblank);
     520  OHANA_UNUSED_PARAM(zzero);
     521  OHANA_UNUSED_PARAM(zscale);
     522
     523  int axis;
     524  unsigned int *counter = NULL;
     525  unsigned long int *Ztile = NULL;
     526
     527  ALLOCATE (counter, unsigned int, matrix->Naxes);
     528  ALLOCATE (Ztile, unsigned long int, matrix->Naxes);
    516529
    517530  // counter for current row in tile to copy
    518531  // true sizes of this tile (in pixels)
    519   for (i = 0; i < matrix->Naxes; i++) {
    520     counter[i] = 0;
    521     Ztile[i] = MIN ((matrix->Naxis[i] - otile[i]*ztile[i]), ztile[i]);
     532  for (axis = 0; axis < matrix->Naxes; axis++) {
     533    counter[axis] = 0;
     534    Ztile[axis] = MIN ((matrix->Naxis[axis] - otile[axis]*ztile[axis]), ztile[axis]);
    522535  }
    523536
    524537  // number of lines in the tile (in pixels)
    525   int Nline = 1;
    526   int Npix = matrix->Naxis[0];
    527   for (i = 1; i < matrix->Naxes; i++) {
    528     Nline *= Ztile[i];
    529     Npix  *= matrix->Naxis[i];
     538  unsigned long int Nline = 1;
     539  unsigned long int Npix = matrix->Naxis[0];
     540  for (axis = 1; axis < matrix->Naxes; axis++) {
     541    Nline *= Ztile[axis];
     542    Npix  *= matrix->Naxis[axis];
    530543  }
    531544
     
    536549  // start = otile[0]*ztile[0] + otile[1]*ztile[1]*Naxis[0] + otile[2]*ztile[2]*Naxis[0]*Naxis[1] + ...;
    537550  // start = otile[0]*ztile[0] + Naxis[0]*(otile[1]*ztile[1] + Naxis[1]*(otile[2]*ztile[2] + ...));
    538   int start = otile[matrix->Naxes-1]*ztile[matrix->Naxes-1];
    539   for (i = matrix->Naxes - 2; i >= 0; i--) {
    540     int coord = otile[i]*ztile[i];
    541     start = start*matrix->Naxis[i] + coord;
     551  unsigned long int start = otile[matrix->Naxes-1]*ztile[matrix->Naxes-1];
     552  for (axis = matrix->Naxes - 2; axis >= 0; axis--) {
     553    unsigned long int coord = otile[axis]*ztile[axis];
     554    start = start*matrix->Naxis[axis] + coord;
    542555  }
    543556 
     
    553566
    554567  // pixel offset in output array relative to tile start
    555   int offset = 0;
     568  unsigned long int offset = 0;
    556569
    557570  static int pass = 0;
     571  int k;
    558572  for (k = 0; k < size; k++) {
     573    unsigned long int i;
    559574    for (i = 0; i < Nline; i++) {
    560575# ifdef BYTE_SWAP     
     
    564579# endif
    565580      char *rawptr = &raw[i*Ztile[0] + k*Nraw];
     581      unsigned long j;
    566582      for (j = 0; j < Ztile[0]; j++, srcptr += size, rawptr ++) {               
    567583        if (FALSE && (i == 0) && (j < 4) && (pass == 0)) {
     
    574590
    575591      // update the counters, carrying to the next dimension if needed
    576       for (j = 1; j < matrix->Naxes; j++) {
    577         counter[j] ++;
    578         if (counter[j] == Ztile[j]) {
    579           counter[j] = 0;
     592      for (axis = 1; axis < matrix->Naxes; axis++) {
     593        counter[axis] ++;
     594        if (counter[axis] == Ztile[axis]) {
     595          counter[axis] = 0;
    580596        } else {
    581597          break;
    582598        }
    583599      }
    584       if (j == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
     600      if (axis == matrix->Naxes) assert (i == Nline - 1); // we should be done here...
    585601
    586602      // Naxes = 3
     
    590606      // determine the offset of the next line relative to the start position
    591607      offset = counter[matrix->Naxes - 1];
    592       for (j = matrix->Naxes - 2; j >= 0; j--) {
    593         offset = offset*matrix->Naxis[j] + counter[j];
     608      for (axis = matrix->Naxes - 2; axis >= 0; axis--) {
     609        offset = offset*matrix->Naxis[axis] + counter[axis];
    594610      }     
    595611    }
  • trunk/Ohana/src/libfits/matrix/F_uncompress_data.c

    r38441 r39457  
    22# include <gfitsio.h>
    33# 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_rdecomp (unsigned char *c, int clen, unsigned int array[], int nx, int nblock);
    8 int fits_rdecomp_short (unsigned char *c, int clen, unsigned short array[], int nx, int nblock);
    9 int fits_rdecomp_byte (unsigned char *c, int clen, unsigned char array[], int nx, int nblock);
    10 
    11 /* functions defined in fits_hcompress.c */
    12 # define LONGLONG long long
    13 int fits_hcompress(int *a, int ny, int nx, int scale, char *output, long *nbytes, int *status);
    14 int fits_hcompress64(LONGLONG *a, int ny, int nx, int scale, char *output, long *nbytes, int *status);
    15 
    16 /* functions defined in fits_hdeccompress.c */
    17 int fits_hdecompress(unsigned char *input, int smooth, int *a, int *ny, int *nx, int *scale, int *status);
    18 int fits_hdecompress64(unsigned char *input, int smooth, LONGLONG *a, int *ny, int *nx, int *scale, int *status);
    19 
    20 /* functions defined in pliocomp.c */
    21 int pl_p2li (int *pxsrc, int xs, short *lldst, int npix);
    22 int pl_l2pi (short *ll_src, int xs, int *px_dst, int npix);
    23 
    24 /* functions defined in gzip.c */
    25 int gfits_gz_stripheader (unsigned char *data, int *ndata);
    26 int gfits_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
     4# include <gfits_compress.h>
    275
    286# define ESCAPE(RET) { fprintf (stderr, "gzip error in %s @ %s:%d\n", __func__, __FILE__, __LINE__); return (RET); }
    297
    30 int gfits_uncompress_data (char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int Nout_alloc, int out_pixsize) {
     8int gfits_uncompress_data (char *zdata, unsigned long Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, unsigned long int *Nout, unsigned long int Nout_alloc, int out_pixsize) {
    319
    3210  int status;
     
    7856
    7957    int status = FALSE;
    80     int Npix = *Nout / out_pixsize;
    81     int k;
     58    unsigned long int Npix = *Nout / out_pixsize;
    8259
    8360    switch (out_pixsize) {
     
    8865      case 2:
    8966        if (0) {
    90           fprintf (stderr, "Nout: %d, Nrawpix: %d\n", Nzdata, Npix);
     67          unsigned long int k;
     68          fprintf (stderr, "Nout: %lu, Nrawpix: %lu\n", Nzdata, Npix);
    9169          fprintf (stderr, "cmp out: ");
    9270          for (k = 0; k < Nzdata; k++) { fprintf (stderr, "0x%02hhx ", zdata[k]); }
     
    11290 
    11391  if (!strcasecmp(cmptype, "PLIO_1")) {
     92    int Ntru = *Nout;
    11493    int Npix;
    115     Npix = pl_l2pi ((short *) zdata, 1, (int *) outdata, *Nout);
    116     if (Npix != *Nout) {
     94    Npix = pl_l2pi ((short *) zdata, 1, (int *) outdata, Ntru);
     95    if (Npix != Ntru) {
    11796      fprintf (stderr, "error in plio decompression\n");
    11897      return (FALSE);
     
    122101
    123102  if (!strcasecmp(cmptype, "HCOMPRESS_1")) {
     103    unsigned long int Ntru = *Nout;
    124104    int Nx, Ny, scale;
    125105    status = 0;
     
    132112    // fprintf (stderr, "decompression yields image %d x %d (scale: %d)\n", Nx, Ny, scale);
    133113   
    134     if (Nx * Ny != *Nout) {
     114    unsigned long Npix = Nx * Ny;
     115    if (Npix != Ntru) {
    135116      fprintf (stderr, "error in hdecompress: mismatched output size\n");
    136117      return (FALSE);
  • trunk/Ohana/src/libfits/table/F_compress_T.c

    r39358 r39457  
    2323# define ESCAPE { fprintf (stderr, "error in %s @ line %d\n", __func__, __LINE__); goto escape; }
    2424
    25 int gfits_collect_table_data (FTable *table, TableField *field, char *raw, int row_start, int Nrows);
    26 int gfits_collect_table_gzp2 (FTable *table, TableField *field, char *raw, int row_start, int Nrows);
     25int gfits_collect_table_data (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows);
     26int gfits_collect_table_gzp2 (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows);
    2727
    2828static float timeSum1 = 0.0;
     
    5151}
    5252
    53 int gfits_compress_table (FTable *srctable, FTable *tgttable, int ztilelen, char *zcmptype) {
    54 
    55   int i, j;
     53int gfits_compress_table (FTable *srctable, FTable *tgttable, unsigned long int ztilelen, char *zcmptype) {
    5654
    5755  char keyword[81];
     
    6967  gettimeofday (&startTimer, (void *) NULL);
    7068
    71   int Ntile, ztilelast;
     69  unsigned long int Ntile, ztilelast;
    7270  if (!ztilelen) ztilelen = srcheader->Naxis[1];
    7371
     
    104102
    105103  ALLOCATE_ZERO (fields, TableField, Nfields);
    106   for (i = 0; i < Nfields; i++) {
    107     snprintf (keyword, 80, "TTYPE%d", i+1);
    108     if (!gfits_scan (srcheader, keyword, "%s", 1, fields[i].ttype)) ESCAPE;
    109     if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[i].ttype_cmt)) ESCAPE;
     104
     105  for (int field = 0; field < Nfields; field++) {
     106    snprintf (keyword, 80, "TTYPE%d", field+1);
     107    if (!gfits_scan (srcheader, keyword, "%s", 1, fields[field].ttype)) ESCAPE;
     108    if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[field].ttype_cmt)) ESCAPE;
    110109
    111110    // TUNIT is not mandatory
    112     snprintf (keyword, 80, "TUNIT%d", i+1);
    113     if (!gfits_scan (srcheader, keyword, "%s", 1, fields[i].tunit)) {
    114       fields[i].tunit[0] = 0;
     111    snprintf (keyword, 80, "TUNIT%d", field+1);
     112    if (!gfits_scan (srcheader, keyword, "%s", 1, fields[field].tunit)) {
     113      fields[field].tunit[0] = 0;
    115114    } else {
    116       if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[i].tunit_cmt)) ESCAPE;
     115      if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[field].tunit_cmt)) ESCAPE;
    117116    }
    118117   
    119     snprintf (keyword, 80, "TFORM%d", i+1);
    120     if (!gfits_scan (srcheader, keyword, "%s", 1, fields[i].tformat)) ESCAPE;
    121     if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[i].tformat_cmt)) ESCAPE;
     118    snprintf (keyword, 80, "TFORM%d", field+1);
     119    if (!gfits_scan (srcheader, keyword, "%s", 1, fields[field].tformat)) ESCAPE;
     120    if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[field].tformat_cmt)) ESCAPE;
    122121
    123122    // for now we set all fields to the requested type.  since I do not yet know the column data types I cannot yet assign automatic cmptypes
    124     strcpy (fields[i].zctype, zcmptype);
     123    strcpy (fields[field].zctype, zcmptype);
    125124
    126125    // by using "P" format, we are limited to 32bit pointers (2GB heap)
    127     if (!gfits_define_bintable_column (tgtheader, "1QB(0)", fields[i].ttype, fields[i].ttype_cmt, fields[i].tunit, 1.0, 0.0)) ESCAPE;
     126    if (!gfits_define_bintable_column (tgtheader, "1QB(0)", fields[field].ttype, fields[field].ttype_cmt, fields[field].tunit, 1.0, 0.0)) ESCAPE;
    128127  }   
    129128
     
    137136  char *tmpbuffer = NULL;
    138137  ALLOCATE_ZERO (tmpbuffer, char, 16*Ntile); // need space for Ntile entries, each of width 16 bytes (2 long)
    139   for (i = 0; i < Nfields; i++) {
    140     if (!gfits_set_bintable_column (tgtheader, tgttable, fields[i].ttype, tmpbuffer, Ntile)) ESCAPE;
     138  for (int field = 0; field < Nfields; field++) {
     139    if (!gfits_set_bintable_column (tgtheader, tgttable, fields[field].ttype, tmpbuffer, Ntile)) ESCAPE;
    141140  }
    142141  free (tmpbuffer);
     
    146145
    147146  // define compression-specific keywords, update header as needed.
    148   if (!gfits_modify (tgtheader, "ZTILELEN", "%d", 1, ztilelen)) ESCAPE;
     147  if (!gfits_modify (tgtheader, "ZTILELEN", "%lu", 1, ztilelen)) ESCAPE;
    149148
    150149  if (!gfits_modify (tgtheader, "ZNAXIS1", OFF_T_FMT, 1, srcheader->Naxis[0])) ESCAPE;
     
    163162  int offset = 0; // bytes from first column of first field to the current field (accumulate to set)
    164163
    165   for (i = 0; i < Nfields; i++) {
    166     snprintf (keyword, 81, "ZFORM%d", i+1);
    167     if (!gfits_modify (tgtheader, keyword, "%s", 1, fields[i].tformat)) ESCAPE;
    168     if (!gfits_varlength_column_define (tgttable, &fields[i].zdef, i+1)) ESCAPE;
    169     if (!gfits_bintable_format (fields[i].tformat, fields[i].datatype, &fields[i].Nvalues, &fields[i].pixsize)) ESCAPE; //
    170     fields[i].rowsize = fields[i].Nvalues*fields[i].pixsize;
    171     max_width = MAX(max_width, fields[i].rowsize);
    172 
    173     if (!strcasecmp (fields[i].zctype, "AUTO")) {
    174       if (!strcmp (fields[i].datatype, "short") ||
    175           !strcmp (fields[i].datatype, "float") ||
    176           !strcmp (fields[i].datatype, "double")||
    177           !strcmp (fields[i].datatype, "int64_t")) {
    178         strcpy (fields[i].zctype, "GZIP_2");
     164  for (int field = 0; field < Nfields; field++) {
     165    snprintf (keyword, 81, "ZFORM%d", field+1);
     166    if (!gfits_modify (tgtheader, keyword, "%s", 1, fields[field].tformat)) ESCAPE;
     167    if (!gfits_varlength_column_define (tgttable, &fields[field].zdef, field+1)) ESCAPE;
     168    if (!gfits_bintable_format (fields[field].tformat, fields[field].datatype, &fields[field].Nvalues, &fields[field].pixsize)) ESCAPE; //
     169    fields[field].rowsize = fields[field].Nvalues*fields[field].pixsize;
     170    max_width = MAX(max_width, fields[field].rowsize);
     171
     172    if (!strcasecmp (fields[field].zctype, "AUTO")) {
     173      if (!strcmp (fields[field].datatype, "short") ||
     174          !strcmp (fields[field].datatype, "float") ||
     175          !strcmp (fields[field].datatype, "double")||
     176          !strcmp (fields[field].datatype, "int64_t")) {
     177        strcpy (fields[field].zctype, "GZIP_2");
    179178        goto got_cmptype;
    180179      }
    181       if (!strcmp (fields[i].datatype, "int")) {
    182         strcpy (fields[i].zctype, "RICE_1");
     180      if (!strcmp (fields[field].datatype, "int")) {
     181        strcpy (fields[field].zctype, "RICE_1");
    183182        goto got_cmptype;
    184183      }
    185       if (!strcmp (fields[i].datatype, "byte") ||
    186           !strcmp (fields[i].datatype, "char")) {
    187         strcpy (fields[i].zctype, "GZIP_1");
     184      if (!strcmp (fields[field].datatype, "byte") ||
     185          !strcmp (fields[field].datatype, "char")) {
     186        strcpy (fields[field].zctype, "GZIP_1");
    188187        goto got_cmptype;
    189188      }
     
    193192
    194193    // OVERRIDE: RICE can only be used on integer fields
    195     if (!strcasecmp (fields[i].zctype, "RICE_1") || !strcasecmp (fields[i].zctype, "RICE_ONE")) {
    196       if (!strcmp (fields[i].datatype, "float") || !strcmp (fields[i].datatype, "double") || !strcmp (fields[i].datatype, "int64_t")) {
    197         strcpy (fields[i].zctype, "GZIP_2");
     194    if (!strcasecmp (fields[field].zctype, "RICE_1") || !strcasecmp (fields[field].zctype, "RICE_ONE")) {
     195      if (!strcmp (fields[field].datatype, "float") || !strcmp (fields[field].datatype, "double") || !strcmp (fields[field].datatype, "int64_t")) {
     196        strcpy (fields[field].zctype, "GZIP_2");
    198197      }
    199198    }
    200199
    201200    // OVERRIDE: GZIP_2 invalid for B (use GZIP_1)
    202     if (!strcasecmp (fields[i].zctype, "GZIP_2") && !strcmp (fields[i].datatype, "byte")) {
    203       strcpy (fields[i].zctype, "GZIP_1");
     201    if (!strcasecmp (fields[field].zctype, "GZIP_2") && !strcmp (fields[field].datatype, "byte")) {
     202      strcpy (fields[field].zctype, "GZIP_1");
    204203    }
    205204
    206205    // compression type per column (XXX for now we are just using zcmptype, as set above)
    207     snprintf (keyword, 81, "ZCTYP%d", i+1);
    208     if (!gfits_modify (tgtheader, keyword, "%s", 1, fields[i].zctype)) ESCAPE;
    209 
    210     fields[i].offset = offset;
    211     offset += fields[i].rowsize;
     206    snprintf (keyword, 81, "ZCTYP%d", field+1);
     207    if (!gfits_modify (tgtheader, keyword, "%s", 1, fields[field].zctype)) ESCAPE;
     208
     209    fields[field].offset = offset;
     210    offset += fields[field].rowsize;
    212211  }
    213212
    214213  // allocate the intermediate storage buffers
    215   int Nzdata_alloc = 2*max_width*ztilelen + 100;
     214  unsigned long int Nzdata_alloc = 2*max_width*ztilelen + 100;
    216215  ALLOCATE (raw,   char, max_width*ztilelen);
    217216  ALLOCATE (zdata, char, Nzdata_alloc);
     
    229228  // compress the data : copy into a tile, compress the tile, then add to the output table
    230229  // each tile -> 1 row of the output table
    231   for (i = 0; i < Ntile; i++) {
    232 
    233     for (j = 0; j < Nfields; j++) {
    234 
    235       gettimeofday (&startTimer, (void *) NULL);
    236 
    237       int Nrows = (i == Ntile - 1) ? ztilelast : ztilelen;
    238       int row_start = i*ztilelen;
     230  for (unsigned long int tile = 0; tile < Ntile; tile++) {
     231
     232    for (int field = 0; field < Nfields; field++) {
     233
     234      gettimeofday (&startTimer, (void *) NULL);
     235
     236      unsigned long int Nrows = (tile == Ntile - 1) ? ztilelast : ztilelen;
     237      unsigned long int row_start = tile*ztilelen;
    239238      // ^- first row for this tile & field
    240239      // NOTE: assumes each tile has the same length, ex the last (true for now)
    241240
    242241      // copy the raw pixels from their native matrix locations to the temporary output buffer
    243       if (!strcasecmp(fields[j].zctype, "GZIP_2") || !strcasecmp(fields[j].zctype, "NONE_2")) {
    244         if (!gfits_collect_table_gzp2 (srctable, &fields[j], raw, row_start, Nrows)) ESCAPE;
     242      if (!strcasecmp(fields[field].zctype, "GZIP_2") || !strcasecmp(fields[field].zctype, "NONE_2")) {
     243        if (!gfits_collect_table_gzp2 (srctable, &fields[field], raw, row_start, Nrows)) ESCAPE;
    245244      } else {
    246         if (!gfits_collect_table_data (srctable, &fields[j], raw, row_start, Nrows)) ESCAPE;
     245        if (!gfits_collect_table_data (srctable, &fields[field], raw, row_start, Nrows)) ESCAPE;
    247246      }
    248247     
     
    256255 
    257256      if (VERBOSE_DUMP) {
    258         int k;
    259257        fprintf (stderr, "c1: ");
    260         for (k = 0; k < Nrows*fields[j].Nvalues*fields[j].pixsize; k++) {
     258        for (unsigned long int k = 0; k < Nrows*fields[field].Nvalues*fields[field].pixsize; k++) {
    261259          fprintf (stderr, "%02hhx", raw[k]);
    262260          if (k % 2) fprintf (stderr, " ");
     
    269267      // optname, optvalue = NULL, Noptions = 0
    270268     
    271       int Nraw = Nrows*fields[j].Nvalues; // number of pixels
    272       if (!strcasecmp(fields[j].zctype, "GZIP_1")) {
    273         if (!gfits_byteswap_zdata (raw, Nraw * fields[j].pixsize, fields[j].pixsize)) ESCAPE;
     269      unsigned long int Nraw = Nrows*fields[field].Nvalues; // number of pixels
     270      if (!strcasecmp(fields[field].zctype, "GZIP_1")) {
     271        if (!gfits_byteswap_zdata (raw, Nraw * fields[field].pixsize, fields[field].pixsize)) ESCAPE;
    274272      }
    275273
     
    281279 
    282280      if (VERBOSE_DUMP) {
    283         int k;
    284281        fprintf (stderr, "c2: ");
    285         for (k = 0; k < Nrows*fields[j].Nvalues*fields[j].pixsize; k++) {
     282        for (unsigned long int k = 0; k < Nrows*fields[field].Nvalues*fields[field].pixsize; k++) {
    286283          fprintf (stderr, "%02hhx", raw[k]);
    287284          if (k % 2) fprintf (stderr, " ");
     
    291288      }
    292289
    293       int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression
    294       if (!gfits_compress_data (zdata, &Nzdata, fields[j].zctype, NULL, NULL, 0, raw, Nraw, fields[j].pixsize, 0, 0)) ESCAPE;
     290      unsigned long int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression
     291      if (!gfits_compress_data (zdata, &Nzdata, fields[field].zctype, NULL, NULL, 0, raw, Nraw, fields[field].pixsize, 0, 0)) ESCAPE;
    295292     
    296293      // XXX TIMER 2c
     
    301298 
    302299      if (VERBOSE_DUMP) {
    303         int k;
    304300        fprintf (stderr, "c3: ");
    305         for (k = 0; k < Nzdata; k++) {
     301        for (unsigned long int k = 0; k < Nzdata; k++) {
    306302          fprintf (stderr, "%02hhx", zdata[k]);
    307303          if (k % 2) fprintf (stderr, " ");
     
    311307      }
    312308
    313       if (strcasecmp(fields[j].zctype, "NONE_2") && // NONE and NONE_1 not swapped?
    314           strcasecmp(fields[j].zctype, "GZIP_1") &&
    315           strcasecmp(fields[j].zctype, "GZIP_2") &&
    316           strcasecmp(fields[j].zctype, "RICE_1") &&
    317           strcasecmp(fields[j].zctype, "RICE_ONE")) {
    318         if (!gfits_byteswap_zdata (zdata, Nzdata, fields[j].pixsize)) ESCAPE;
     309      if (strcasecmp(fields[field].zctype, "NONE_2") && // NONE and NONE_1 not swapped?
     310          strcasecmp(fields[field].zctype, "GZIP_1") &&
     311          strcasecmp(fields[field].zctype, "GZIP_2") &&
     312          strcasecmp(fields[field].zctype, "RICE_1") &&
     313          strcasecmp(fields[field].zctype, "RICE_ONE")) {
     314        if (!gfits_byteswap_zdata (zdata, Nzdata, fields[field].pixsize)) ESCAPE;
    319315      }
    320316
     
    326322 
    327323      if (VERBOSE_DUMP) {
    328         int k;
    329324        fprintf (stderr, "c4: ");
    330         for (k = 0; k < Nzdata; k++) {
     325        for (unsigned long int k = 0; k < Nzdata; k++) {
    331326          fprintf (stderr, "%02hhx", zdata[k]);
    332327          if (k % 2) fprintf (stderr, " ");
     
    336331      }
    337332
    338       if (!gfits_varlength_column_add_data (tgttable, zdata, Nzdata, i, &fields[j].zdef)) ESCAPE;
     333      if (!gfits_varlength_column_add_data (tgttable, zdata, Nzdata, tile, &fields[field].zdef)) ESCAPE;
    339334      // XXX TIMER 2e
    340335      gettimeofday (&stopTimer, (void *) NULL);
     
    347342  if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
    348343
    349   for (i = 0; i < Nfields; i++) {
    350     if (!gfits_varlength_column_finish (tgttable, &fields[i].zdef)) ESCAPE;
     344  for (int field = 0; field < Nfields; field++) {
     345    if (!gfits_varlength_column_finish (tgttable, &fields[field].zdef)) ESCAPE;
    351346  }
    352347
     
    375370// raw_pixsize is the bytes / pixel for the input matrix
    376371// place the raw image bytes for the current tile into the tile buffer
    377 int gfits_collect_table_data (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
    378 
    379   off_t i;
     372int gfits_collect_table_data (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows) {
    380373
    381374  // we are copying NN rows into the column which starts at XX and has MM bytes per row
     
    388381
    389382  if (VERBOSE) fprintf (stderr, "distribute: ");
    390   for (i = 0; i < Nrows; i++, tblbuffer += Nx) {
     383  for (unsigned long i = 0; i < Nrows; i++, tblbuffer += Nx) {
    391384    memcpy (&raw[i*rowsize], tblbuffer, rowsize);
    392385# if (VERBOSE)
    393     int j; for (j = 0; j < field->rowsize; j++) fprintf (stderr, "0x%02hhx ", table->buffer[Nx*row + field->offset + j]);
     386    for (int j = 0; j < field->rowsize; j++) fprintf (stderr, "0x%02hhx ", table->buffer[Nx*row + field->offset + j]);
    394387# endif
    395388  }
     
    399392}
    400393
    401 int gfits_collect_table_data_alt (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
    402 
    403   off_t i;
     394int gfits_collect_table_data_alt (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows) {
    404395
    405396  // we are copying NN rows of the column which starts at XX and has MM bytes per row
     
    408399
    409400  if (VERBOSE) fprintf (stderr, "collect: ");
    410   for (i = 0; i < Nrows; i++) {
     401  for (unsigned long i = 0; i < Nrows; i++) {
    411402    int row = row_start + i;
    412403    memcpy (&raw[i*field->rowsize], &table->buffer[Nx*row + field->offset], field->rowsize);
     
    420411}
    421412
    422 int gfits_collect_table_gzp2 (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
    423 
    424   off_t i, j, k;
     413int gfits_collect_table_gzp2 (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows) {
    425414
    426415  // we are copying NN rows into the column which starts at XX and has MM bytes per row
     
    433422  char *rawptr = raw;
    434423
    435   for (k = 0; k < field->pixsize; k++) {
     424  for (off_t k = 0; k < field->pixsize; k++) {
    436425# ifdef BYTE_SWAP     
    437426    char *tblptr_start = &table->buffer[Nx*row_start + offset + (pixsize - k - 1)];
     
    439428    char *tblptr_start = &table->buffer[Nx*row_start + offset + k];
    440429# endif
    441     for (i = 0; i < Nrows; i++, tblptr_start += Nx) {
     430    for (unsigned long int i = 0; i < Nrows; i++, tblptr_start += Nx) {
    442431      char *tblptr = tblptr_start;
    443       for (j = 0; j < Nvalues; j++, tblptr += pixsize, rawptr++) {
     432      for (off_t j = 0; j < Nvalues; j++, tblptr += pixsize, rawptr++) {
    444433        *rawptr = *tblptr;
    445434      }
     
    449438}
    450439
    451 int gfits_collect_table_gzp2_alt (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
    452 
    453   off_t i, j, k;
     440int gfits_collect_table_gzp2_alt (FTable *table, TableField *field, char *raw, unsigned long int row_start, unsigned long int Nrows) {
    454441
    455442  // we are copying NN rows into the column which starts at XX and has MM bytes per row
     
    457444  off_t Nx = table->header->Naxis[0];
    458445
    459   for (k = 0; k < field->pixsize; k++) {
    460     for (i = 0; i < Nrows; i++) {
    461       int row = row_start + i;
     446  for (off_t k = 0; k < field->pixsize; k++) {
     447    for (unsigned long int i = 0; i < Nrows; i++) {
     448      unsigned long int row = row_start + i;
    462449      char *rawptr = &raw[i*field->Nvalues + k*Nrows*field->Nvalues];
    463450# ifdef BYTE_SWAP     
     
    466453      char *tblptr = &table->buffer[Nx*row + field->offset + k];
    467454# endif
    468       for (j = 0; j < field->Nvalues; j++, tblptr += field->pixsize, rawptr++) {
     455      for (off_t j = 0; j < field->Nvalues; j++, tblptr += field->pixsize, rawptr++) {
    469456        *rawptr = *tblptr;
    470         myAssert (rawptr - raw < Nrows*field->Nvalues*field->pixsize, "oops");
     457        myAssert (rawptr >= raw, "oops");
     458        myAssert ((unsigned long int)(rawptr - raw) < Nrows*field->Nvalues*field->pixsize, "oops");
    471459        myAssert (tblptr - table->buffer < table->header->Naxis[0]*table->header->Naxis[1], "oops");
    472460      }
  • trunk/Ohana/src/libfits/table/F_set_column.c

    r39394 r39457  
    109109  if (CHECK_MEMBLOCKS) {
    110110    OhanaMemblock *ref = (OhanaMemblock *) array - 1;
    111     fprintf (stderr, "ref: "OFF_T_FMT", array: "OFF_T_FMT"\n", (off_t) ref, (off_t) array);
     111    fprintf (stderr, "ref: 0x%08lx, array: 0x%08lx, size: %ld, (%s@%d : %s), freed: %1d, Nalloc: %d\n", (long int) ref, (long int) array, ref->size, ref->file, ref->line, ref->func, ref->freed, ref->Nalloc);
    112112    if (!ref->nextBlock && !ref->prevBlock) abort();
    113113  }
     
    120120  if (CHECK_MEMBLOCKS) {
    121121    OhanaMemblock *ref = (OhanaMemblock *) array - 1;
    122     fprintf (stderr, "ref: "OFF_T_FMT", array: "OFF_T_FMT"\n", (off_t) ref, (off_t) array);
     122    fprintf (stderr, "ref: 0x%08lx, array: 0x%08lx, size: %ld, (%s@%d : %s), freed: %1d, Nalloc: %d\n", (long int) ref, (long int) array, ref->size, ref->file, ref->line, ref->func, ref->freed, ref->Nalloc);
    123123    if (!ref->nextBlock && !ref->prevBlock) abort();
    124124  }
     
    212212  if (CHECK_MEMBLOCKS) {
    213213    OhanaMemblock *ref = (OhanaMemblock *) array - 1;
    214     fprintf (stderr, "ref: "OFF_T_FMT", array: "OFF_T_FMT"\n", (off_t) ref, (off_t) array);
     214    fprintf (stderr, "ref: 0x%08lx, array: 0x%08lx, size: %ld, (%s@%d : %s), freed: %1d, Nalloc: %d\n", (long int) ref, (long int) array, ref->size, ref->file, ref->line, ref->func, ref->freed, ref->Nalloc);
    215215    if (!ref->nextBlock && !ref->prevBlock) abort();
    216216  }
     
    241241  if (CHECK_MEMBLOCKS) {
    242242    OhanaMemblock *ref = (OhanaMemblock *) array - 1;
    243     fprintf (stderr, "ref: "OFF_T_FMT", array: "OFF_T_FMT"\n", (off_t) ref, (off_t) array);
     243    fprintf (stderr, "ref: 0x%08lx, array: 0x%08lx, size: %ld, (%s@%d : %s), freed: %1d, Nalloc: %d\n", (long int) ref, (long int) array, ref->size, ref->file, ref->line, ref->func, ref->freed, ref->Nalloc);
    244244    if (!ref->nextBlock && !ref->prevBlock) abort();
    245245  }
  • trunk/Ohana/src/libfits/table/F_table_varlength.c

    r39340 r39457  
    187187    ptr[0] = Ndata;
    188188    ptr[1] = heap_offset - table->heap_start;
     189    // fprintf (stderr, "row: %d, Ndata: %d, maxlen: %d, Ndata: %d, ptr1: %d\n", (int) row, (int) Ndata, (int) column->maxlen, (int) Ndata, (int) (heap_offset - table->heap_start));
    189190  }
    190191
  • trunk/Ohana/src/libfits/table/F_uncompress_T.c

    r39358 r39457  
    1313int gfits_dump_raw_table (FTable *table, char *message) {
    1414# if (VERBOSE_DUMP)
    15   int i;
    1615  fprintf (stderr, "%s data:\n", message);
    17   for (i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) {
     16  for (int i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) {
    1817    // for (i = 0; i < 16; i++) {
    1918    fprintf (stderr, "%02hhx", table->buffer[i]);
     
    2221  }
    2322  fprintf (stderr, "\n");
     23# else
     24  OHANA_UNUSED_PARAM(table);
     25  OHANA_UNUSED_PARAM(message);
    2426# endif
    2527  return TRUE;
     
    2830int gfits_dump_cmp_table (FTable *table, char *message) {
    2931# if (VERBOSE_DUMP)
    30   int i;
    3132  fprintf (stderr, "%s pntr:\n", message);
    32   for (i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) {
     33  for (int i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) {
    3334    fprintf (stderr, "%02hhx", table->buffer[i]);
    3435    if (i % 2) fprintf (stderr, " ");
     
    3839
    3940  fprintf (stderr, "%s data:\n", message);
    40   for (i = 0; i < table->header->pcount; i++) {
     41  for (int i = 0; i < table->header->pcount; i++) {
    4142    fprintf (stderr, "%02hhx", table->buffer[table->heap_start + i]);
    4243    if (i % 2) fprintf (stderr, " ");
     
    4445  }
    4546  fprintf (stderr, "\n");
     47# else
     48  OHANA_UNUSED_PARAM(table);
     49  OHANA_UNUSED_PARAM(message);
    4650# endif
    4751  return TRUE;
     
    7781int gfits_uncompress_table (FTable *srctable, FTable *tgttable) {
    7882
    79   int i;
    80 
    8183  char keyword[256];
    8284
     
    114116
    115117  ALLOCATE (fields, TableField, Nfields);
    116   for (i = 0; i < Nfields; i++) {
     118  for (int i = 0; i < Nfields; i++) {
    117119    snprintf (keyword, 80, "TTYPE%d", i+1);
    118120    if (!gfits_scan (srcheader, keyword, "%s", 1, fields[i].ttype)) ESCAPE;
     
    170172  // calling with an empty data array, data values are not actually copied (this is done
    171173  // below after decompression)
    172   for (i = 0; i < Nfields; i++) {
     174  for (int i = 0; i < Nfields; i++) {
    173175    if (!gfits_set_bintable_column (tgtheader, tgttable, fields[i].ttype, NULL, Ny)) ESCAPE;
    174176  }
     
    200202  gettimeofday (&startTimer, (void *) NULL);
    201203
    202   off_t row;
    203   for (row = 0; row < srcheader->Naxis[1]; row++) {
    204 
    205     for (i = 0; i < Nfields; i++) {
     204  for (off_t row = 0; row < srcheader->Naxis[1]; row++) {
     205
     206    for (int i = 0; i < Nfields; i++) {
    206207
    207208      // gfits_uncompress_data can take values specific to the compression mode
     
    218219   
    219220      if (VERBOSE_DUMP) {
    220         int k;
    221221        fprintf (stderr, "u4: ");
    222         for (k = 0; k < Nzdata; k++) {
     222        for (int k = 0; k < Nzdata; k++) {
    223223          fprintf (stderr, "%02hhx", zdata[k]);
    224224          if (k % 2) fprintf (stderr, " ");
     
    250250 
    251251      if (VERBOSE_DUMP) {
    252         int k;
    253252        fprintf (stderr, "u3: ");
    254         for (k = 0; k < Nzdata; k++) {
     253        for (int k = 0; k < Nzdata; k++) {
    255254          fprintf (stderr, "%02hhx", zdata[k]);
    256255          if (k % 2) fprintf (stderr, " ");
     
    266265      gettimeofday (&startTimer, (void *) NULL);
    267266 
    268       int Nrows = (row == Ntile - 1) ? ztilelast : ztilelen;
    269       int Nraw = Nrows*fields[i].Nvalues*fields[i].pixsize; // expected number of bytes
     267      unsigned long int Nrows = (row == Ntile - 1) ? ztilelast : ztilelen;
     268      unsigned long int Nraw = Nrows*fields[i].Nvalues*fields[i].pixsize; // expected number of bytes
    270269      if (!gfits_uncompress_data (zdata, Nzdata, fields[i].zctype, NULL, NULL, 0, raw, &Nraw, Nraw_alloc, fields[i].pixsize)) ESCAPE;
    271270
    272271      if (VERBOSE_DUMP) {
    273         int k;
    274272        fprintf (stderr, "u2: ");
    275         for (k = 0; k < Nraw*fields[i].pixsize; k++) {
     273        for (unsigned long int k = 0; k < Nraw*fields[i].pixsize; k++) {
    276274          fprintf (stderr, "%02hhx", raw[k]);
    277275          if (k % 2) fprintf (stderr, " ");
     
    299297 
    300298      if (VERBOSE_DUMP) {
    301         int k;
    302299        fprintf (stderr, "u1: ");
    303         for (k = 0; k < Nraw*fields[i].pixsize; k++) {
     300        for (unsigned long int k = 0; k < Nraw*fields[i].pixsize; k++) {
    304301          fprintf (stderr, "%02hhx", raw[k]);
    305302          if (k % 2) fprintf (stderr, " ");
     
    356353int gfits_distribute_table_data (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
    357354
    358   off_t i;
    359 
    360355  // we are copying NN rows into the column which starts at XX and has MM bytes per row
    361356
     
    367362
    368363  if (VERBOSE) fprintf (stderr, "distribute: ");
    369   for (i = 0; i < Nrows; i++, tblbuffer += Nx) {
     364  for (off_t i = 0; i < Nrows; i++, tblbuffer += Nx) {
    370365    memcpy (tblbuffer, &raw[i*rowsize], rowsize);
    371366# if (VERBOSE)
    372     int j; for (j = 0; j < field->rowsize; j++) fprintf (stderr, "0x%02hhx ", table->buffer[Nx*row + field->offset + j]);
     367    for (int j = 0; j < field->rowsize; j++) fprintf (stderr, "0x%02hhx ", table->buffer[Nx*row + field->offset + j]);
    373368# endif
    374369  }
     
    379374
    380375int gfits_distribute_table_gzp2 (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
    381 
    382   off_t i, j, k;
    383376
    384377  // we are copying NN rows into the column which starts at XX and has MM bytes per row
     
    391384  char *rawptr = raw;
    392385
    393   for (k = 0; k < field->pixsize; k++) {
     386  for (off_t k = 0; k < field->pixsize; k++) {
    394387# ifdef BYTE_SWAP     
    395388    char *tblptr_start = &table->buffer[Nx*row_start + offset + (pixsize - k - 1)];
     
    397390    char *tblptr_start = &table->buffer[Nx*row_start + offset + k];
    398391# endif
    399     for (i = 0; i < Nrows; i++, tblptr_start += Nx) {
     392    for (off_t i = 0; i < Nrows; i++, tblptr_start += Nx) {
    400393      char *tblptr = tblptr_start;
    401       for (j = 0; j < Nvalues; j++, tblptr += pixsize, rawptr++) {
     394      for (off_t j = 0; j < Nvalues; j++, tblptr += pixsize, rawptr++) {
    402395        *tblptr = *rawptr;
    403396      }
     
    409402int gfits_distribute_table_gzp2_alt (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
    410403 
    411   off_t i, j, k;
    412  
    413404  // we are copying NN rows into the column which starts at XX and has MM bytes per row
    414405 
    415406  off_t Nx = table->header->Naxis[0];
    416407 
    417   for (k = 0; k < field->pixsize; k++) {
    418     for (i = 0; i < Nrows; i++) {
     408  for (off_t k = 0; k < field->pixsize; k++) {
     409    for (off_t i = 0; i < Nrows; i++) {
    419410      int row = row_start + i;
    420411      char *rawptr = &raw[i*field->Nvalues + k*Nrows*field->Nvalues];
     
    424415      char *tblptr = &table->buffer[Nx*row + field->offset + k];
    425416# endif
    426       for (j = 0; j < field->Nvalues; j++, tblptr += field->pixsize, rawptr++) {
     417      for (off_t j = 0; j < field->Nvalues; j++, tblptr += field->pixsize, rawptr++) {
    427418        *tblptr = *rawptr;
    428419      }
  • trunk/Ohana/src/libfits/table/F_write_T.c

    r38553 r39457  
    2727    myAssert (myBlock->startblock == OHANA_MEMMAGIC, "bad memory");
    2828    myAssert (myBlock->endblock == OHANA_MEMMAGIC, "bad memory");
    29     myAssert (myBlock->size >= table[0].datasize, "overflow");
     29    myAssert (myBlock->size >= (size_t) table[0].datasize, "overflow");
    3030  }
    3131# endif
  • trunk/Ohana/src/libfits/table/F_write_TH.c

    r38553 r39457  
    2727    myAssert (myBlock->startblock == OHANA_MEMMAGIC, "bad memory");
    2828    myAssert (myBlock->endblock == OHANA_MEMMAGIC, "bad memory");
    29     myAssert (myBlock->size >= header[0].datasize, "overflow");
     29    myAssert (myBlock->size >= (size_t) header[0].datasize, "overflow");
    3030  }
    3131# endif
  • trunk/Ohana/src/libfits/test/imagecomp.c

    r38553 r39457  
    1717static int NY = 10;
    1818
    19 int main (int argc, char **argv) {
     19int main (void) {
    2020 
    2121  plan_tests (3*3*234);
     
    196196  }     
    197197
    198   int Ztile[2] = {NX, NY};
    199   ok (gfits_compress_image (&rawheader, &rawmatrix, &ftable, (int *) &Ztile, zcmptype), "compressed image");
     198  unsigned long int Ztile[2] = {NX, NY};
     199  ok (gfits_compress_image (&rawheader, &rawmatrix, &ftable, (unsigned long int *) &Ztile, zcmptype), "compressed image");
    200200  // ok (gfits_compress_image (&rawheader, &rawmatrix, &ftable, NULL, zcmptype), "compressed image");
    201201  ok (gfits_uncompress_image (&outheader, &outmatrix, &ftable), "uncompressed image");
  • trunk/Ohana/src/libfits/test/keywords.c

    r39321 r39457  
    1515  tmp = Pout[3]; Pout[3] = Pout[4]; Pout[4] = tmp; }
    1616
    17 int main (int argc, char **argv) {
     17int main (void) {
    1818 
    1919  plan_tests (14);
     
    2121  diag ("libfits keyword tests");
    2222
    23   int i, err;
    24   double srcbuf[NSRC], tgtbuf[NTGT], outbuf[NOUT];
    25  
    2623  {
    2724   
     
    9693    ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
    9794
    98     ok (gfits_modify (&header, "D_LONG3", "%Ld", 1, (long long) 0x100), "wrote a keyword");
    99     ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
     95    // this is not ISO C99:
     96    // ok (gfits_modify (&header, "D_LONG3", "%Ld", 1, (long long) 0x100), "wrote a keyword");
     97    // ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
    10098
    10199    // set one of each of the few numerical types (unsigned ints)
     
    109107    ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
    110108
    111     ok (gfits_modify (&header, "DU_LONG3", "%Lu", 1, (long long) 0x100), "wrote a keyword");
    112     ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
     109    // ok (gfits_modify (&header, "DU_LONG3", "%Lu", 1, (long long) 0x100), "wrote a keyword");
     110    // ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
    113111
    114112    ok (gfits_modify (&header, "D_SHORT", "%hd", 1, 0x20), "wrote a keyword");
     
    229227    ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
    230228
    231     ok (gfits_scan (&header, "D_LONG3", "%Ld", 1, &Kvalue), "read a keyword");
    232     ok (Kvalue == 0x100, "got the right value");
    233     ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
     229    // ok (gfits_scan (&header, "D_LONG3", "%Ld", 1, &Kvalue), "read a keyword");
     230    // ok (Kvalue == 0x100, "got the right value");
     231    // ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
    234232
    235233    // set one of each of the few numerical types (unsigned ints)
     
    246244    ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
    247245
    248     ok (gfits_scan (&header, "DU_LONG3", "%Lu", 1, &Ulonglong), "read a keyword");
    249     ok (Ulonglong == 0x100, "got the right value");
    250     ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
     246    // ok (gfits_scan (&header, "DU_LONG3", "%Lu", 1, &Ulonglong), "read a keyword");
     247    // ok (Ulonglong == 0x100, "got the right value");
     248    // ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");
    251249
    252250    ok (gfits_scan (&header, "D_SHORT", "%hd", 1, &Ishort), "read a keyword");
  • trunk/Ohana/src/libfits/test/ricetest.c

    r38404 r39457  
    11# include <ohana.h>
    22# include <gfitsio.h>
     3# include <gfits_compress.h>
    34# include "tap_ohana.h"
    45
     
    67# define NBYTE 4*NPIX
    78
    8 int main (int argc, char **argv) {
     9int main (void) {
    910 
    1011  plan_tests (45);
     
    1213  diag ("libfits ricetest.c tests");
    1314
    14   // buffers to store max array
    15   char rawdata[NBYTE];
    16   char cmpdata[NBYTE];
    17   char outdata[NBYTE];
    18 
    1915  // ok (1, "failure");
    2016
    2117  if (1) {
     18    // buffers to store max array
     19    char rawdata[NBYTE];
     20    unsigned char outdata[NBYTE];
     21    unsigned char cmpdata[NBYTE];
    2222    char *rawvalue = (char *) rawdata;
    2323    char *outvalue = (char *) outdata;
     
    4646
    4747  if (1) {
     48    // buffers to store max array
     49    char rawdata[NBYTE];
     50    unsigned short outdata[NBYTE];
     51    unsigned char cmpdata[NBYTE];
     52
    4853    short *rawvalue = (short *) rawdata;
    4954    short *outvalue = (short *) outdata;
     
    7277
    7378  if (1) {
     79    // buffers to store max array
     80    char rawdata[NBYTE];
     81    unsigned int outdata[NBYTE];
     82    unsigned char cmpdata[NBYTE];
     83
    7484    int *rawvalue = (int *) rawdata;
    7585    int *outvalue = (int *) outdata;
  • trunk/Ohana/src/libfits/test/tablecomp.c

    r38553 r39457  
    1010char *cmptype[] = {"NONE", "NONE_1", "NONE_2", "GZIP_1", "GZIP_2", "RICE_1", "RICE_ONE", "AUTO", NULL};
    1111
    12 int main (int argc, char **argv) {
    13  
    14   plan_tests (668);
     12int main (void) {
     13 
     14  plan_tests (668+428);
    1515
    1616  diag ("libfits tablecomp.c tests");
     
    2828    test_compress_empty (cmptype[i]);
    2929    ok (ohana_memcheck (TRUE), "no memory corruption");
     30    ohana_memdump (TRUE);
    3031  }
    3132
     
    8990    ok (gfits_compress_table (&ftable, &cmptable, 10, zcmptype), "compressed table");
    9091
     92    if (0) { int ix, iy;
     93      for (ix = 0; ix < 12; ix++) {
     94        for (iy = 0; iy < 16; iy++) {
     95          fprintf (stderr, "%x ", (int) cmptable.buffer[ix*16 + iy]);
     96        }
     97      }
     98    }
     99
     100    Header rawheader;
     101    FTable rawtable;
     102    rawtable.header = &rawheader;
     103    ok (gfits_uncompress_table (&cmptable, &rawtable), "uncompressed table");
     104
     105    gfits_free_header (&cmpheader);
     106    gfits_free_table (&cmptable);
     107
     108    outheader = &rawheader;
     109    outtable  = &rawtable;
     110  }
     111
     112  char type[16];
     113  int Ncol;
     114  off_t Nrow;
     115
     116  char    *VAL_B_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_B", type, &Nrow, &Ncol); ok (!strcmp (type, "byte"),    "read byte    table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
     117  short   *VAL_I_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_I", type, &Nrow, &Ncol); ok (!strcmp (type, "short"),   "read short   table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
     118  int     *VAL_J_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_J", type, &Nrow, &Ncol); ok (!strcmp (type, "int"),     "read int     table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
     119  int64_t *VAL_K_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_K", type, &Nrow, &Ncol); ok (!strcmp (type, "int64_t"), "read int64_t table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
     120  float   *VAL_E_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_E", type, &Nrow, &Ncol); ok (!strcmp (type, "float"),   "read float   table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
     121  double  *VAL_D_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_D", type, &Nrow, &Ncol); ok (!strcmp (type, "double"),  "read double  table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
     122
     123  // count mismatched values
     124  int NVAL_B_bad = 0;
     125  int NVAL_I_bad = 0;
     126  int NVAL_J_bad = 0;
     127  int NVAL_K_bad = 0;
     128  int NVAL_E_bad = 0;
     129  int NVAL_D_bad = 0;
     130
     131  // for (i = 0; i < Nval; i++) {
     132  //   fprintf (stderr, "%0llx : %0llx\n", (long long) VAL_K[i], (long long) VAL_K_t[i]);
     133  // }
     134
     135  for (i = 0; i < Nval; i++) {
     136    if (VAL_B[i] != VAL_B_t[i]) NVAL_B_bad++;
     137    if (VAL_I[i] != VAL_I_t[i]) NVAL_I_bad++;
     138    if (VAL_J[i] != VAL_J_t[i]) NVAL_J_bad++;
     139    if (VAL_K[i] != VAL_K_t[i]) NVAL_K_bad++;
     140    if (VAL_E[i] != VAL_E_t[i]) NVAL_E_bad++;
     141    if (VAL_D[i] != VAL_D_t[i]) NVAL_D_bad++;
     142  }
     143
     144  ok (!NVAL_B_bad, "byte    values match (input vs output)");
     145  ok (!NVAL_I_bad, "short   values match (input vs output)");
     146  ok (!NVAL_J_bad, "int     values match (input vs output)");
     147  ok (!NVAL_K_bad, "int64_t values match (input vs output)");
     148  ok (!NVAL_E_bad, "float   values match (input vs output)");
     149  ok (!NVAL_D_bad, "double  values match (input vs output)");
     150
     151  free (VAL_B);
     152  free (VAL_I);
     153  free (VAL_J);
     154  free (VAL_K);
     155  free (VAL_E);
     156  free (VAL_D);
     157
     158  free (VAL_B_t);
     159  free (VAL_I_t);
     160  free (VAL_J_t);
     161  free (VAL_K_t);
     162  free (VAL_E_t);
     163  free (VAL_D_t);
     164
     165  gfits_free_header (&header);
     166  gfits_free_table (&ftable);
     167  if (zcmptype) {
     168    gfits_free_header (outheader);
     169    gfits_free_table (outtable);
     170  }
     171  return TRUE;
     172}
     173
     174int test_compress_fullrange (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE"
     175
     176  Header header;
     177  FTable ftable;
     178
     179  diag ("--- starting test_compress with zcmptype %s ---", zcmptype);
     180  ok (gfits_init_header (&header), "inited the header");
     181  ok (gfits_init_table (&ftable), "inited the table");
     182
     183  ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header");
     184
     185  ok (gfits_define_bintable_column (&header, "B", "VAL_B", "byte",   "none", 1.0, 0.0), "defined byte column");
     186  ok (gfits_define_bintable_column (&header, "I", "VAL_I", "short",  "none", 1.0, 0.0), "defined short column");
     187  ok (gfits_define_bintable_column (&header, "J", "VAL_J", "int",    "none", 1.0, 0.0),  "defined int column");
     188  ok (gfits_define_bintable_column (&header, "K", "VAL_K", "long",   "none", 1.0, 0.0),  "defined long column");
     189  ok (gfits_define_bintable_column (&header, "E", "VAL_E", "float",  "degree", 1.0, 0.0),   "defined float column");
     190  ok (gfits_define_bintable_column (&header, "D", "VAL_D", "double", "degree", 1.0, 0.0),   "defined double column");
     191 
     192  // generate the output array that carries the data
     193  ok (gfits_create_table (&header, &ftable), "created the basic table");
     194
     195  int Nval = 1000;
     196  char    *VAL_B;  ALLOCATE (VAL_B, char,    Nval);
     197  short   *VAL_I;  ALLOCATE (VAL_I, short,   Nval);
     198  int     *VAL_J;  ALLOCATE (VAL_J, int,     Nval);
     199  int64_t *VAL_K;  ALLOCATE (VAL_K, int64_t, Nval);
     200  float   *VAL_E;  ALLOCATE (VAL_E, float,   Nval);
     201  double  *VAL_D;  ALLOCATE (VAL_D, double,  Nval);
     202 
     203  long A = time(NULL);
     204  srand48(A);
     205
     206  int i;
     207  for (i = 0; i < Nval; i++) {
     208    VAL_B[i] =       0xff & lrand48();
     209    VAL_I[i] =     0xffff & lrand48();
     210    VAL_J[i] = 0xffffffff & lrand48();
     211    VAL_K[i] = (((int64_t)lrand48()) << 32) + (int64_t)lrand48();
     212    VAL_E[i] = FLT_MAX * (2.0*drand48() - 1.0);
     213    VAL_D[i] = DBL_MAX * (2.0*drand48() - 1.0);
     214  }     
     215
     216  // add the columns to the output array
     217  ok (gfits_set_bintable_column (&header, &ftable, "VAL_B", VAL_B, Nval), "set byte   table column");
     218  ok (gfits_set_bintable_column (&header, &ftable, "VAL_I", VAL_I, Nval), "set short  table column");
     219  ok (gfits_set_bintable_column (&header, &ftable, "VAL_J", VAL_J, Nval), "set int    table column");
     220  ok (gfits_set_bintable_column (&header, &ftable, "VAL_K", VAL_K, Nval), "set long   table column");
     221  ok (gfits_set_bintable_column (&header, &ftable, "VAL_E", VAL_E, Nval), "set float  table column");
     222  ok (gfits_set_bintable_column (&header, &ftable, "VAL_D", VAL_D, Nval), "set double table column");
     223
     224  Header *outheader = &header;
     225  FTable *outtable = &ftable;
     226
     227  if (zcmptype) {
     228    Header cmpheader;
     229    FTable cmptable;
     230    cmptable.header = &cmpheader;
     231    ok (gfits_compress_table (&ftable, &cmptable, 10, zcmptype), "compressed table");
     232
    91233    Header rawheader;
    92234    FTable rawtable;
     
    120262  int NVAL_D_bad = 0;
    121263
    122   // for (i = 0; i < Nval; i++) {
    123   //   fprintf (stderr, "%0llx : %0llx\n", (long long) VAL_K[i], (long long) VAL_K_t[i]);
    124   // }
    125 
    126264  for (i = 0; i < Nval; i++) {
    127265    if (VAL_B[i] != VAL_B_t[i]) NVAL_B_bad++;
     
    140278  ok (!NVAL_D_bad, "double  values match (input vs output)");
    141279
     280  free (VAL_B);
     281  free (VAL_I);
     282  free (VAL_J);
     283  free (VAL_K);
     284  free (VAL_E);
     285  free (VAL_D);
     286
     287  free (VAL_B_t);
     288  free (VAL_I_t);
     289  free (VAL_J_t);
     290  free (VAL_K_t);
     291  free (VAL_E_t);
     292  free (VAL_D_t);
     293
    142294  gfits_free_header (&header);
    143295  gfits_free_table (&ftable);
     
    149301}
    150302
    151 int test_compress_fullrange (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE"
     303int test_compress_single_full (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE"
     304
     305  Header header;
     306  FTable ftable;
     307
     308  diag ("--- starting test_compress with zcmptype %s ---", zcmptype);
     309  ok (gfits_init_header (&header), "inited the header");
     310  ok (gfits_init_table (&ftable), "inited the table");
     311
     312  ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header");
     313
     314  ok (gfits_define_bintable_column (&header, "I", "SEQ", "seq", "none", 1.0, 0.0), "defined short column");
     315 
     316  // generate the output array that carries the data
     317  ok (gfits_create_table (&header, &ftable), "created the basic table");
     318
     319  int Nval = 1000;
     320  short *SEQ;  ALLOCATE (SEQ, short,  Nval);
     321 
     322  int i;
     323  for (i = 0; i < Nval; i++) {
     324    SEQ[i] = i;
     325  }     
     326
     327  // add the columns to the output array
     328  ok (gfits_set_bintable_column (&header, &ftable, "SEQ", SEQ, Nval), "set short  table column");
     329
     330  Header *outheader = &header;
     331  FTable *outtable = &ftable;
     332
     333  if (zcmptype) {
     334    Header cmpheader;
     335    FTable cmptable;
     336    cmptable.header = &cmpheader;
     337    ok (gfits_compress_table (&ftable, &cmptable, 0, zcmptype), "compressed table");
     338
     339    Header rawheader;
     340    FTable rawtable;
     341    rawtable.header = &rawheader;
     342    ok (gfits_uncompress_table (&cmptable, &rawtable), "uncompressed table");
     343   
     344    gfits_free_header (&cmpheader);
     345    gfits_free_table (&cmptable);
     346
     347    outheader = &rawheader;
     348    outtable  = &rawtable;
     349  }
     350
     351  char type[16];
     352  int Ncol;
     353  off_t Nrow;
     354
     355  short  *SEQ_t = gfits_get_bintable_column_data (outheader, outtable, "SEQ", type, &Nrow, &Ncol); ok (!strcmp (type, "short"),  "read short  table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
     356
     357  // count mismatched values
     358  int Nseq = 0;
     359  for (i = 0; i < Nval; i++) {
     360    if (SEQ[i] != SEQ_t[i]) Nseq++;
     361  }
     362
     363  ok (!Nseq,   "short  values match (input vs output)");
     364
     365  gfits_free_header (&header);
     366  gfits_free_table (&ftable);
     367  if (zcmptype) {
     368    gfits_free_header (outheader);
     369    gfits_free_table (outtable);
     370  }
     371  return TRUE;
     372}
     373
     374int test_compress_empty (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE"
    152375
    153376  Header header;
     
    170393  ok (gfits_create_table (&header, &ftable), "created the basic table");
    171394
    172   int Nval = 1000;
     395  int Nval = 0;
    173396  char    *VAL_B;  ALLOCATE (VAL_B, char,    Nval);
    174397  short   *VAL_I;  ALLOCATE (VAL_I, short,   Nval);
     
    178401  double  *VAL_D;  ALLOCATE (VAL_D, double,  Nval);
    179402 
    180   long A = time(NULL);
    181   srand48(A);
    182 
    183403  int i;
    184404  for (i = 0; i < Nval; i++) {
    185     VAL_B[i] =       0xff & lrand48();
    186     VAL_I[i] =     0xffff & lrand48();
    187     VAL_J[i] = 0xffffffff & lrand48();
    188     VAL_K[i] = (((int64_t)lrand48()) << 32) + (int64_t)lrand48();
    189     VAL_E[i] = FLT_MAX * (2.0*drand48() - 1.0);
    190     VAL_D[i] = DBL_MAX * (2.0*drand48() - 1.0);
     405    VAL_B[i] = (i % 255) - 128;
     406    VAL_I[i] = i;
     407    VAL_J[i] = 10000*i + 100*i;
     408    VAL_K[i] = 10000*i + 330*i;
     409    VAL_E[i] = 0.1*i;
     410    VAL_D[i] = 1.001*i;
    191411  }     
    192412
     
    206426    FTable cmptable;
    207427    cmptable.header = &cmpheader;
    208     ok (gfits_compress_table (&ftable, &cmptable, 10, zcmptype), "compressed table");
     428    ok (gfits_compress_table (&ftable, &cmptable, 0, zcmptype), "compressed table");
    209429
    210430    Header rawheader;
     
    239459  int NVAL_D_bad = 0;
    240460
     461  // for (i = 0; i < Nval; i++) {
     462  //   fprintf (stderr, "%0llx : %0llx\n", (long long) VAL_K[i], (long long) VAL_K_t[i]);
     463  // }
     464
    241465  for (i = 0; i < Nval; i++) {
    242466    if (VAL_B[i] != VAL_B_t[i]) NVAL_B_bad++;
     
    255479  ok (!NVAL_D_bad, "double  values match (input vs output)");
    256480
     481  free (VAL_B);
     482  free (VAL_I);
     483  free (VAL_J);
     484  free (VAL_K);
     485  free (VAL_E);
     486  free (VAL_D);
     487
     488  free (VAL_B_t);
     489  free (VAL_I_t);
     490  free (VAL_J_t);
     491  free (VAL_K_t);
     492  free (VAL_E_t);
     493  free (VAL_D_t);
     494
    257495  gfits_free_header (&header);
    258496  gfits_free_table (&ftable);
     
    264502}
    265503
    266 int test_compress_single_full (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE"
    267 
    268   Header header;
    269   FTable ftable;
    270 
    271   diag ("--- starting test_compress with zcmptype %s ---", zcmptype);
    272   ok (gfits_init_header (&header), "inited the header");
    273   ok (gfits_init_table (&ftable), "inited the table");
    274 
    275   ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header");
    276 
    277   ok (gfits_define_bintable_column (&header, "I", "SEQ", "seq", "none", 1.0, 0.0), "defined short column");
    278  
    279   // generate the output array that carries the data
    280   ok (gfits_create_table (&header, &ftable), "created the basic table");
    281 
    282   int Nval = 1000;
    283   short *SEQ;  ALLOCATE (SEQ, short,  Nval);
    284  
    285   int i;
    286   for (i = 0; i < Nval; i++) {
    287     SEQ[i] = i;
    288   }     
    289 
    290   // add the columns to the output array
    291   ok (gfits_set_bintable_column (&header, &ftable, "SEQ", SEQ, Nval), "set short  table column");
    292 
    293   Header *outheader = &header;
    294   FTable *outtable = &ftable;
    295 
    296   if (zcmptype) {
    297     Header cmpheader;
    298     FTable cmptable;
    299     cmptable.header = &cmpheader;
    300     ok (gfits_compress_table (&ftable, &cmptable, 0, zcmptype), "compressed table");
    301 
    302     Header rawheader;
    303     FTable rawtable;
    304     rawtable.header = &rawheader;
    305     ok (gfits_uncompress_table (&cmptable, &rawtable), "uncompressed table");
    306    
    307     gfits_free_header (&cmpheader);
    308     gfits_free_table (&cmptable);
    309 
    310     outheader = &rawheader;
    311     outtable  = &rawtable;
    312   }
    313 
    314   char type[16];
    315   int Ncol;
    316   off_t Nrow;
    317 
    318   short  *SEQ_t = gfits_get_bintable_column_data (outheader, outtable, "SEQ", type, &Nrow, &Ncol); ok (!strcmp (type, "short"),  "read short  table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
    319 
    320   // count mismatched values
    321   int Nseq = 0;
    322   for (i = 0; i < Nval; i++) {
    323     if (SEQ[i] != SEQ_t[i]) Nseq++;
    324   }
    325 
    326   ok (!Nseq,   "short  values match (input vs output)");
    327 
    328   gfits_free_header (&header);
    329   gfits_free_table (&ftable);
    330   if (zcmptype) {
    331     gfits_free_header (outheader);
    332     gfits_free_table (outtable);
    333   }
    334   return TRUE;
    335 }
    336 
    337 int test_compress_empty (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE"
    338 
    339   Header header;
    340   FTable ftable;
    341 
    342   diag ("--- starting test_compress with zcmptype %s ---", zcmptype);
    343   ok (gfits_init_header (&header), "inited the header");
    344   ok (gfits_init_table (&ftable), "inited the table");
    345 
    346   ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header");
    347 
    348   ok (gfits_define_bintable_column (&header, "B", "VAL_B", "byte",   "none", 1.0, 0.0), "defined byte column");
    349   ok (gfits_define_bintable_column (&header, "I", "VAL_I", "short",  "none", 1.0, 0.0), "defined short column");
    350   ok (gfits_define_bintable_column (&header, "J", "VAL_J", "int",    "none", 1.0, 0.0),  "defined int column");
    351   ok (gfits_define_bintable_column (&header, "K", "VAL_K", "long",   "none", 1.0, 0.0),  "defined long column");
    352   ok (gfits_define_bintable_column (&header, "E", "VAL_E", "float",  "degree", 1.0, 0.0),   "defined float column");
    353   ok (gfits_define_bintable_column (&header, "D", "VAL_D", "double", "degree", 1.0, 0.0),   "defined double column");
    354  
    355   // generate the output array that carries the data
    356   ok (gfits_create_table (&header, &ftable), "created the basic table");
    357 
    358   int Nval = 0;
    359   char    *VAL_B;  ALLOCATE (VAL_B, char,    Nval);
    360   short   *VAL_I;  ALLOCATE (VAL_I, short,   Nval);
    361   int     *VAL_J;  ALLOCATE (VAL_J, int,     Nval);
    362   int64_t *VAL_K;  ALLOCATE (VAL_K, int64_t, Nval);
    363   float   *VAL_E;  ALLOCATE (VAL_E, float,   Nval);
    364   double  *VAL_D;  ALLOCATE (VAL_D, double,  Nval);
    365  
    366   int i;
    367   for (i = 0; i < Nval; i++) {
    368     VAL_B[i] = (i % 255) - 128;
    369     VAL_I[i] = i;
    370     VAL_J[i] = 10000*i + 100*i;
    371     VAL_K[i] = 10000*i + 330*i;
    372     VAL_E[i] = 0.1*i;
    373     VAL_D[i] = 1.001*i;
    374   }     
    375 
    376   // add the columns to the output array
    377   ok (gfits_set_bintable_column (&header, &ftable, "VAL_B", VAL_B, Nval), "set byte   table column");
    378   ok (gfits_set_bintable_column (&header, &ftable, "VAL_I", VAL_I, Nval), "set short  table column");
    379   ok (gfits_set_bintable_column (&header, &ftable, "VAL_J", VAL_J, Nval), "set int    table column");
    380   ok (gfits_set_bintable_column (&header, &ftable, "VAL_K", VAL_K, Nval), "set long   table column");
    381   ok (gfits_set_bintable_column (&header, &ftable, "VAL_E", VAL_E, Nval), "set float  table column");
    382   ok (gfits_set_bintable_column (&header, &ftable, "VAL_D", VAL_D, Nval), "set double table column");
    383 
    384   Header *outheader = &header;
    385   FTable *outtable = &ftable;
    386 
    387   if (zcmptype) {
    388     Header cmpheader;
    389     FTable cmptable;
    390     cmptable.header = &cmpheader;
    391     ok (gfits_compress_table (&ftable, &cmptable, 0, zcmptype), "compressed table");
    392 
    393     Header rawheader;
    394     FTable rawtable;
    395     rawtable.header = &rawheader;
    396     ok (gfits_uncompress_table (&cmptable, &rawtable), "uncompressed table");
    397    
    398     gfits_free_header (&cmpheader);
    399     gfits_free_table (&cmptable);
    400 
    401     outheader = &rawheader;
    402     outtable  = &rawtable;
    403   }
    404 
    405   char type[16];
    406   int Ncol;
    407   off_t Nrow;
    408 
    409   char    *VAL_B_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_B", type, &Nrow, &Ncol); ok (!strcmp (type, "byte"),    "read byte    table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
    410   short   *VAL_I_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_I", type, &Nrow, &Ncol); ok (!strcmp (type, "short"),   "read short   table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
    411   int     *VAL_J_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_J", type, &Nrow, &Ncol); ok (!strcmp (type, "int"),     "read int     table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
    412   int64_t *VAL_K_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_K", type, &Nrow, &Ncol); ok (!strcmp (type, "int64_t"), "read int64_t table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
    413   float   *VAL_E_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_E", type, &Nrow, &Ncol); ok (!strcmp (type, "float"),   "read float   table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
    414   double  *VAL_D_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_D", type, &Nrow, &Ncol); ok (!strcmp (type, "double"),  "read double  table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
    415 
    416   // count mismatched values
    417   int NVAL_B_bad = 0;
    418   int NVAL_I_bad = 0;
    419   int NVAL_J_bad = 0;
    420   int NVAL_K_bad = 0;
    421   int NVAL_E_bad = 0;
    422   int NVAL_D_bad = 0;
    423 
    424   // for (i = 0; i < Nval; i++) {
    425   //   fprintf (stderr, "%0llx : %0llx\n", (long long) VAL_K[i], (long long) VAL_K_t[i]);
    426   // }
    427 
    428   for (i = 0; i < Nval; i++) {
    429     if (VAL_B[i] != VAL_B_t[i]) NVAL_B_bad++;
    430     if (VAL_I[i] != VAL_I_t[i]) NVAL_I_bad++;
    431     if (VAL_J[i] != VAL_J_t[i]) NVAL_J_bad++;
    432     if (VAL_K[i] != VAL_K_t[i]) NVAL_K_bad++;
    433     if (VAL_E[i] != VAL_E_t[i]) NVAL_E_bad++;
    434     if (VAL_D[i] != VAL_D_t[i]) NVAL_D_bad++;
    435   }
    436 
    437   ok (!NVAL_B_bad, "byte    values match (input vs output)");
    438   ok (!NVAL_I_bad, "short   values match (input vs output)");
    439   ok (!NVAL_J_bad, "int     values match (input vs output)");
    440   ok (!NVAL_K_bad, "int64_t values match (input vs output)");
    441   ok (!NVAL_E_bad, "float   values match (input vs output)");
    442   ok (!NVAL_D_bad, "double  values match (input vs output)");
    443 
    444   gfits_free_header (&header);
    445   gfits_free_table (&ftable);
    446   if (zcmptype) {
    447     gfits_free_header (outheader);
    448     gfits_free_table (outtable);
    449   }
    450   return TRUE;
    451 }
    452 
    453 
     504
  • trunk/Ohana/src/libfits/test/zlib.c

    r38442 r39457  
    1616  tmp = Pout[3]; Pout[3] = Pout[4]; Pout[4] = tmp; }
    1717
    18 int main (int argc, char **argv) {
     18int main (void) {
    1919 
    2020  plan_tests (14);
     
    3030  {
    3131    z_stream zdn;
    32     zdn.next_in = (char *) srcbuf;
     32    zdn.next_in = (unsigned char *) srcbuf;
    3333    zdn.avail_in = NSRC * sizeof(double);
    34     zdn.next_out = (char *) tgtbuf;
     34    zdn.next_out = (unsigned char *) tgtbuf;
    3535    zdn.avail_out = NTGT * sizeof(double);
    3636 
     
    8383  {
    8484    z_stream zup;
    85     zup.next_in = (char *) tgtbuf;
     85    zup.next_in = (unsigned char *) tgtbuf;
    8686    zup.avail_in = NTGT * sizeof(double);
    87     zup.next_out = (char *) outbuf;
     87    zup.next_out = (unsigned char *) outbuf;
    8888    zup.avail_out = NOUT * sizeof(double);
    8989 
     
    120120  {
    121121    z_stream zdn;
    122     zdn.next_in = (char *) srcbuf;
     122    zdn.next_in = (unsigned char *) srcbuf;
    123123    zdn.avail_in = NSRC * sizeof(double);
    124     zdn.next_out = (char *) tgtbuf;
     124    zdn.next_out = (unsigned char *) tgtbuf;
    125125    zdn.avail_out = NTGT * sizeof(double);
    126126 
     
    174174  {
    175175    z_stream zup;
    176     zup.next_in = (char *) tgtbuf;
     176    zup.next_in = (unsigned char *) tgtbuf;
    177177    zup.avail_in = NTGT * sizeof(double);
    178     zup.next_out = (char *) outbuf;
     178    zup.next_out = (unsigned char *) outbuf;
    179179    zup.avail_out = NOUT * sizeof(double);
    180180 
Note: See TracChangeset for help on using the changeset viewer.