- Timestamp:
- Jun 5, 2015, 7:58:50 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_M.c
r38366 r38399 204 204 int k; 205 205 fprintf (stderr, "cmp mat: "); 206 for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", matrix->buffer[k]); }206 for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", matrix->buffer[k]); if (k % 4 == 3) fprintf (stderr, " "); } 207 207 fprintf (stderr, "\n"); 208 208 fprintf (stderr, "cmp raw: "); 209 for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", raw[k]); }209 for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", raw[k]); if (k % 4 == 3) fprintf (stderr, " "); } 210 210 fprintf (stderr, "\n"); 211 211 } … … 221 221 int k; 222 222 fprintf (stderr, "cmp swp: "); 223 for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", raw[k]); }223 for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", raw[k]); if (k % 4 == 3) fprintf (stderr, " "); } 224 224 fprintf (stderr, "\n"); 225 225 fprintf (stderr, "Nzdata: %d -> ", Nzdata); … … 233 233 fprintf (stderr, "%d\n", Nzdata); 234 234 fprintf (stderr, "cmp SWP: "); 235 for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", zdata[k]); }235 for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 4 == 3) fprintf (stderr, " "); } 236 236 fprintf (stderr, "\n"); 237 237 } … … 240 240 // compression modes require swapping after compression (compresssion & decompression 241 241 // operate on native ENDIAN) 242 if (strcasecmp(zcmptype, "NONE") && 243 strcasecmp(zcmptype, "NONE_2") && 242 if (strcasecmp(zcmptype, "NONE_2") && // strcasecmp(zcmptype, "NONE") && 244 243 strcasecmp(zcmptype, "GZIP_1") && 245 244 strcasecmp(zcmptype, "GZIP_2") && … … 253 252 int k; 254 253 fprintf (stderr, "cmp dat: "); 255 for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", zdata[k]); }254 for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 4 == 3) fprintf (stderr, " "); } 256 255 fprintf (stderr, "\n"); 257 256 } … … 266 265 int k; 267 266 fprintf (stderr, "cmp tbl: "); 268 for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", ftable->buffer[k]); }267 for (k = 0; k < 64; k++) { fprintf (stderr, "%02hhx", ftable->buffer[k]); if (k % 4 == 3) fprintf (stderr, " "); } 269 268 fprintf (stderr, "\n"); 270 269 } … … 339 338 offset = 0; 340 339 340 int directCopy = (zzero == 0.0) && (zscale == 1.0); 341 341 342 // we need to set up switches for all of the possible combinations: 342 343 // this macro is used at the inner switch to run the actual loop 343 # define SCALE_AND_DIST_INT (TYPE, SIZE) {\344 # define SCALE_AND_DIST_INT_PRINT(TYPE, SIZE, INTYPE) { \ 344 345 TYPE *TILEptr = (TYPE *) &matrix->buffer[SIZE*(offset + start)]; \ 345 346 for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) { \ … … 347 348 *RAWptr = zblank; \ 348 349 } else { \ 349 *RAWptr = (*TILEptr - zzero) / zscale; \ 350 /* *RAWptr = directCopy ? *TILEptr : (*TILEptr - zzero) / zscale; */ \ 351 *RAWptr = *TILEptr; \ 352 fprintf (stderr, "col: %s to %s : %08x : %08x\n", #TYPE, #INTYPE, *TILEptr, *RAWptr); \ 350 353 } } } 351 354 352 355 // we need to set up switches for all of the possible combinations: 353 356 // this macro is used at the inner switch to run the actual loop 354 # define SCALE_AND_DIST_FLOAT(TYPE, SIZE) { \ 355 TYPE *TILEptr = (TYPE *) &matrix->buffer[SIZE*(offset + start)]; \ 357 # define SCALE_AND_DIST_INT(OTYPE, OSIZE) { \ 358 OTYPE *TILEptr = (OTYPE *) &matrix->buffer[OSIZE*(offset + start)]; \ 359 for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) { \ 360 if (*TILEptr == oblank) { \ 361 *RAWptr = zblank; \ 362 } else { \ 363 if (directCopy) { \ 364 *RAWptr = *TILEptr; \ 365 } else { \ 366 *RAWptr = (*TILEptr - zzero) / zscale; \ 367 } } } } 368 369 // we need to set up switches for all of the possible combinations: 370 // this macro is used at the inner switch to run the actual loop 371 # define SCALE_AND_DIST_FLOAT(OTYPE, OSIZE) { \ 372 OTYPE *TILEptr = (OTYPE *) &matrix->buffer[OSIZE*(offset + start)]; \ 356 373 for (j = 0; j < Ztile[0]; j++, TILEptr++, RAWptr++) { \ 357 374 if (!isfinite(*TILEptr)) { \ 358 375 *RAWptr = zblank; \ 359 376 } else { \ 360 *RAWptr = (*TILEptr - zzero) / zscale; \ 361 } } } 377 if (directCopy) { \ 378 *RAWptr = *TILEptr; \ 379 } else { \ 380 *RAWptr = (*TILEptr - zzero) / zscale; \ 381 } } } } 362 382 363 383 // this macro sets up the outer switch and calls above the macro with all RAW buffer bitpix options 364 384 // 365 # define SETUP_RAWSIZE (TYPE, SIZE) { \385 # define SETUP_RAWSIZE_PRINT(TYPE, SIZE) { \ 366 386 TYPE *RAWptr = (TYPE *) &raw[i*SIZE*Ztile[0]]; \ 387 switch (matrix->bitpix) { \ 388 case 8: SCALE_AND_DIST_INT (char, 1); break; \ 389 case 16: SCALE_AND_DIST_INT (short, 2); break; \ 390 case 32: SCALE_AND_DIST_INT_PRINT (int, 4, TYPE); break; \ 391 case -32: SCALE_AND_DIST_FLOAT (float, 4); break; \ 392 case -64: SCALE_AND_DIST_FLOAT (double, 8); break; \ 393 default: abort(); \ 394 } } 395 396 // this macro sets up the outer switch and calls above the macro with all RAW buffer bitpix options 397 // 398 # define SETUP_RAWSIZE(ITYPE, ISIZE) { \ 399 ITYPE *RAWptr = (ITYPE *) &raw[i*ISIZE*Ztile[0]]; \ 367 400 switch (matrix->bitpix) { \ 368 401 case 8: SCALE_AND_DIST_INT (char, 1); break; \ … … 475 508 char *srcptr = &matrix->buffer[size*(offset + start) + k]; 476 509 # endif 477 char *rawptr = &raw[i* size*Ztile[0] + k*Nraw];510 char *rawptr = &raw[i*Ztile[0] + k*Nraw]; 478 511 for (j = 0; j < Ztile[0]; j++, srcptr += size, rawptr ++) { 479 512 if (FALSE && (i == 0) && (j < 4) && (pass == 0)) {
Note:
See TracChangeset
for help on using the changeset viewer.
