IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 5, 2015, 7:58:50 PM (11 years ago)
Author:
eugene
Message:

handle zzero,zscale = 0,1 specially to avoid bitlevel errors

File:
1 edited

Legend:

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

    r38366 r38399  
    262262    int k;
    263263    fprintf (stderr, "unc tbl: ");
    264     for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", ftable->buffer[k]); }
     264    for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", ftable->buffer[k]); if (k % 4 == 3) fprintf (stderr, " "); }
    265265    fprintf (stderr, "\n");
    266266  }
     
    279279      int k;
    280280      fprintf (stderr, "unc dat: ");
    281       for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", zdata[k]); }
     281      for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 4 == 3) fprintf (stderr, " "); }
    282282      fprintf (stderr, "\n");
    283283    }
    284284
    285     if (strcasecmp(cmptype, "NONE") &&
    286         strcasecmp(cmptype, "NONE_2") &&
     285    if (strcasecmp(cmptype, "NONE_2") && // strcasecmp(cmptype, "NONE") &&
    287286        strcasecmp(cmptype, "GZIP_1") &&
    288287        strcasecmp(cmptype, "GZIP_2") &&
     
    296295      int k;
    297296      fprintf (stderr, "unc SWP: ");
    298       for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", zdata[k]); }
     297      for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 4 == 3) fprintf (stderr, " "); }
    299298      fprintf (stderr, "\n");
    300299      fprintf (stderr, "Nout  : %d -> ", Nout);
     
    310309      fprintf (stderr, "%d\n", Nout);
    311310      fprintf (stderr, "unc swp: ");
    312       for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", out[k]); }
     311      for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", out[k]); if (k % 4 == 3) fprintf (stderr, " "); }
    313312      fprintf (stderr, "\n");
    314313    }
     
    322321      int k;
    323322      fprintf (stderr, "unc raw: ");
    324       for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", out[k]); }
     323      for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", out[k]); if (k % 4 == 3) fprintf (stderr, " "); }
    325324      fprintf (stderr, "\n");
    326325    }
     
    336335      int k;
    337336      fprintf (stderr, "unc mat: ");
    338       for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", matrix->buffer[k]); }
     337      for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", matrix->buffer[k]); if (k % 4 == 3) fprintf (stderr, " "); }
    339338      fprintf (stderr, "\n");
    340339    }
     
    404403  int offset = 0;
    405404
    406   // we need to set up switches for all of the possible combinations:
    407   // this macro is used at the inner switch to run the actual loop
    408 # define SCALE_AND_DIST_INT(TYPE, SIZE) {                               \
     405  int directCopy = (zzero == 0.0) && (zscale == 1.0);
     406
     407# define SCALE_AND_DIST_INT_PRINT(TYPE, SIZE) {                         \
    409408    TYPE *TILEptr = (TYPE *) &matrix->buffer[SIZE*(offset + start)];    \
    410409    for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {               \
     
    412411        *TILEptr = oblank;                                              \
    413412      } else {                                                          \
    414         *TILEptr = *RAWptr * zscale + zzero;                            \
     413        *TILEptr = directCopy ? *RAWptr : *RAWptr * zscale + zzero;     \
     414        fprintf (stderr, "dis: %08x : %08x\n", *TILEptr, *RAWptr); \
    415415      } } }
    416416
    417417  // we need to set up switches for all of the possible combinations:
    418418  // this macro is used at the inner switch to run the actual loop
    419 # define SCALE_AND_DIST_FLOAT(TYPE, SIZE) {                             \
    420     TYPE *TILEptr = (TYPE *) &matrix->buffer[SIZE*(offset + start)];    \
     419# define SCALE_AND_DIST_INT(OTYPE, OSIZE) {                             \
     420    OTYPE *TILEptr = (OTYPE *) &matrix->buffer[OSIZE*(offset + start)]; \
     421    for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {               \
     422      if (*TILEptr == zblank) {                                         \
     423        *TILEptr = oblank;                                              \
     424      } else {                                                          \
     425        if (directCopy) {                                               \
     426          *TILEptr = *RAWptr;                                           \
     427        } else {                                                        \
     428          *TILEptr = *RAWptr * zscale + zzero;                          \
     429        } } } }
     430
     431  // we need to set up switches for all of the possible combinations:
     432  // this macro is used at the inner switch to run the actual loop
     433# define SCALE_AND_DIST_FLOAT(OTYPE, OSIZE) {                           \
     434    OTYPE *TILEptr = (OTYPE *) &matrix->buffer[OSIZE*(offset + start)]; \
    421435    for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) {               \
    422436      if (!isfinite(*TILEptr)) {                                        \
    423437        *TILEptr = oblank;                                              \
    424438      } else {                                                          \
    425         *TILEptr = *RAWptr * zscale + zzero;                            \
    426       } } }
     439        if (directCopy) {                                               \
     440          *TILEptr = *RAWptr;                                           \
     441        } else {                                                        \
     442          *TILEptr = *RAWptr * zscale + zzero;                          \
     443        } } } }
    427444 
    428445  // this macro sets up the outer switch and calls above macro with all output bitpix options
    429 # define SETUP_RAWSIZE(TYPE, SIZE) {               \
     446# define SETUP_RAWSIZE(ITYPE, ISIZE) {             \
     447    ITYPE *RAWptr = (ITYPE *) &raw[i*ISIZE*Ztile[0]]; \
     448    switch (matrix->bitpix) {                      \
     449      case   8: SCALE_AND_DIST_INT   (char,   1); break; \
     450      case  16: SCALE_AND_DIST_INT   (short,  2); break; \
     451      case  32: SCALE_AND_DIST_INT   (int,    4); break; \
     452      case -32: SCALE_AND_DIST_FLOAT (float,  4); break; \
     453      case -64: SCALE_AND_DIST_FLOAT (double, 8); break; \
     454      default:  abort(); \
     455    } }
     456
     457  // this macro sets up the outer switch and calls above macro with all output bitpix options
     458# define SETUP_RAWSIZE_PRINT(TYPE, SIZE) {                 \
    430459    TYPE *RAWptr = (TYPE *) &raw[i*SIZE*Ztile[0]]; \
    431460    switch (matrix->bitpix) {                      \
    432461      case   8: SCALE_AND_DIST_INT   (char,   1); break; \
    433462      case  16: SCALE_AND_DIST_INT   (short,  2); break; \
    434       case  32: SCALE_AND_DIST_INT   (int,    4); break; \
     463      case  32: SCALE_AND_DIST_INT (int,    4); break; \
    435464      case -32: SCALE_AND_DIST_FLOAT (float,  4); break; \
    436465      case -64: SCALE_AND_DIST_FLOAT (double, 8); break; \
     
    534563      char *srcptr = &matrix->buffer[size*(offset + start) + k];
    535564# endif
    536       char *rawptr = &raw[i*size*Ztile[0] + k*Nraw];   
     565      char *rawptr = &raw[i*Ztile[0] + k*Nraw];
    537566      for (j = 0; j < Ztile[0]; j++, srcptr += size, rawptr ++) {               
    538567        if (FALSE && (i == 0) && (j < 4) && (pass == 0)) {
Note: See TracChangeset for help on using the changeset viewer.