- Timestamp:
- May 25, 2015, 8:08:57 PM (11 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_M.c
r38278 r38322 221 221 ntile[i] = (matrix->Naxis[i] % ztile[i]) ? (matrix->Naxis[i] / ztile[i] + 1) : (matrix->Naxis[i] / ztile[i]); 222 222 max_tile_size *= ztile[i]; 223 224 // ztile[i] is the default (or max) tile size in the i-th dimension 225 // ntile[i] is the number of tiles in the i-th dimension 226 // otile[i] is the current output tile counter in the i-th dimension 223 227 } 224 228 … … 282 286 } 283 287 return (TRUE); 284 }285 286 // gfits_varlength returns a pointer to a chunk of Nzdata of data elements starting at zdata.287 288 // XXX need to have an API to send the user data289 290 // XXX need to byte-swap the table column; this needs to be worked out more clearly291 // in the APIs: do the table read / column extract functions swap or not?. we have292 // put the byte-swapping in gifts_varlength_column_pointer, but this is fairly weak.293 294 // XXX inconsistency between data element size between compressed data, uncompressed data,295 // and output pixel data.....296 297 // true sizes of this tile (in pixels)298 off_t gfits_tile_size (Matrix *matrix, int *otile, int *ztile) {299 300 off_t i, Npixels, Ndimen;301 302 Npixels = 1;303 for (i = 0; i < matrix->Naxes; i++) {304 Ndimen = MIN ((matrix->Naxis[i] - otile[i]*ztile[i]), ztile[i]);305 Npixels *= Ndimen;306 }307 308 return (Npixels);309 288 } 310 289 … … 424 403 } 425 404 426 int gfits_byteswap_zdata (char *zdata, int Nzdata, int pixsize) {427 428 # define DOSWAP(A,B) { char tmp = A; A = B; B = tmp; }429 430 # ifdef BYTE_SWAP431 432 int i;433 434 switch (pixsize) {435 case 1:436 break;437 438 case 2:439 for (i = 0; i < 2*Nzdata; i+=2) {440 DOSWAP (zdata[i+0], zdata[i+1]);441 }442 break;443 444 case 4:445 for (i = 0; i < 4*Nzdata; i+=4) {446 DOSWAP (zdata[i+0], zdata[i+3]);447 DOSWAP (zdata[i+1], zdata[i+2]);448 }449 break;450 451 case 8:452 for (i = 0; i < 8*Nzdata; i+=8) {453 DOSWAP (zdata[i+0], zdata[i+7]);454 DOSWAP (zdata[i+1], zdata[i+6]);455 DOSWAP (zdata[i+2], zdata[i+5]);456 DOSWAP (zdata[i+3], zdata[i+4]);457 }458 break;459 }460 # endif461 return (TRUE);462 }463 464 int gfits_extension_is_compressed (Header *header) {465 466 int has_extension, has_extname, has_zimage, zimage;467 char extname[80], extension[80];468 469 has_extension = gfits_scan (header, "XTENSION", "%s", 1, extension);470 has_extname = gfits_scan (header, "EXTNAME", "%s", 1, extname);471 has_zimage = gfits_scan_alt (header, "ZIMAGE", "%t", 1, &zimage);472 473 if (has_extension && !strcmp (extension, "IMAGE")) return (FALSE);474 if (has_zimage && zimage) return (TRUE);475 if (has_extname) {476 if (!strcmp (extname, "COMPRESSED_IMAGE")) return (TRUE);477 }478 479 return (FALSE);480 }481 482 int gfits_compressed_is_primary (Header *header) {483 484 int zimage = FALSE;485 // int ztension = FALSE;486 487 int has_zimage = gfits_scan_alt (header, "ZIMAGE", "%t", 1, &zimage);488 // int has_ztension = gfits_scan_alt (header, "ZTENSION", "%t", 1, &ztension);489 490 if (has_zimage && zimage) return (TRUE);491 492 return (FALSE);493 }494 495 int gfits_uncompressed_data_pixsize (char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions) {496 497 int i, Nbyte;498 499 if (!strcasecmp(cmptype, "GZIP_1")) {500 if (out_bitpix == 8) return (1);501 if (out_bitpix == 16) return (2);502 if (out_bitpix == 32) return (4);503 if (out_bitpix == -32) return (4);504 if (out_bitpix == -64) return (8);505 return (1);506 }507 if (!strcasecmp(cmptype, "RICE_1")) {508 509 // if BYTEPIX option is specified, use that for Nbyte510 for (i = 0; i < Noptions; i++) {511 if (!strcmp(optname[i], "BYTEPIX")) {512 Nbyte = atoi (optvalue[i]);513 return (Nbyte);514 }515 }516 517 return (4);518 }519 if (!strcasecmp(cmptype, "PLIO_1")) {520 return (4);521 }522 if (!strcasecmp(cmptype, "HCOMPRESS_1")) {523 if (out_bitpix == 8) return (4);524 if (out_bitpix == 16) return (4);525 return (8);526 }527 return (0);528 }529 530 int gfits_vartable_heap_pixsize (char format) {531 532 if (format == 'B') {533 return (1);534 }535 if (format == 'I') {536 return (2);537 }538 if (format == 'J') {539 return (4);540 }541 fprintf (stderr, "invalid size for compressed data: %c\n", format);542 abort ();543 }
Note:
See TracChangeset
for help on using the changeset viewer.
