IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 3, 2015, 4:10:26 AM (11 years ago)
Author:
eugene
Message:

clarify image vs compression buffer vs compressed pixel sizes to allow hcompress and rice

File:
1 edited

Legend:

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

    r38340 r38355  
    174174  int i, Nbyte;
    175175
    176   if (!strcasecmp(cmptype, "GZIP_1") || !strcasecmp(cmptype, "NONE")) {
    177     if (out_bitpix == 8)  return (1);
    178     if (out_bitpix == 16) return (2);
    179     if (out_bitpix == 32) return (4);
     176  // GZIP_1, GZIP_2 use matched input & output pixels
     177  if (!strcasecmp(cmptype, "GZIP_1") ||
     178      !strcasecmp(cmptype, "GZIP_2") ||
     179      !strcasecmp(cmptype, "NONE")) {
     180    if (out_bitpix ==   8) return (1);
     181    if (out_bitpix ==  16) return (2);
     182    if (out_bitpix ==  32) return (4);
    180183    if (out_bitpix == -32) return (4);
    181184    if (out_bitpix == -64) return (8);
    182185    return (1);
    183186  }
    184   if (!strcasecmp(cmptype, "RICE_1")) {
    185 
     187
     188  // RICE_1 must operate on integer pixels
     189  if (!strcasecmp(cmptype, "RICE_1") ||
     190      !strcasecmp(cmptype, "RICE_ONE")) {
    186191    // if BYTEPIX option is specified, use that for Nbyte
    187192    for (i = 0; i < Noptions; i++) {
     
    191196      }
    192197    }
     198    if (out_bitpix ==   8) return (1);
     199    if (out_bitpix ==  16) return (2);
     200    if (out_bitpix ==  32) return (4);
    193201    return (4);
    194202  }
     203
     204  // PLIO_1 always results in 4-byte ints (not 2 byte ints?)
    195205  if (!strcasecmp(cmptype, "PLIO_1")) {
    196206    return (4);
    197207  }
     208
    198209  if (!strcasecmp(cmptype, "HCOMPRESS_1")) {
    199210    if (out_bitpix == 8)  return (4);
     
    204215}
    205216
     217int gfits_compressed_data_pixsize (char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions) {
     218
     219  int i, Nbyte;
     220
     221  // GZIP_1, GZIP_2 should not be swapped after compression
     222  if (!strcasecmp(cmptype, "GZIP_1") ||
     223      !strcasecmp(cmptype, "GZIP_2") ||
     224      !strcasecmp(cmptype, "NONE")) {
     225    if (out_bitpix ==   8) return (1);
     226    if (out_bitpix ==  16) return (1);
     227    if (out_bitpix ==  32) return (1);
     228    if (out_bitpix == -32) return (1);
     229    if (out_bitpix == -64) return (1);
     230    return (1);
     231  }
     232
     233  // RICE_1 must operate on integer pixels
     234  if (!strcasecmp(cmptype, "RICE_1") ||
     235      !strcasecmp(cmptype, "RICE_ONE")) {
     236    // if BYTEPIX option is specified, use that for Nbyte
     237    for (i = 0; i < Noptions; i++) {
     238      if (!strcmp(optname[i], "BYTEPIX")) {
     239        Nbyte = atoi (optvalue[i]);
     240        return (Nbyte);
     241      }
     242    }
     243    if (out_bitpix ==   8) return (1);
     244    if (out_bitpix ==  16) return (2);
     245    if (out_bitpix ==  32) return (4);
     246    return (4);
     247  }
     248
     249  // PLIO_1 always results in 4-byte ints (not 2 byte ints?)
     250  if (!strcasecmp(cmptype, "PLIO_1")) {
     251    return (4);
     252  }
     253
     254  if (!strcasecmp(cmptype, "HCOMPRESS_1")) {
     255    if (out_bitpix == 8)  return (4);
     256    if (out_bitpix == 16) return (4);
     257    return (8);
     258  }
     259  return (0);
     260}
     261
     262int gfits_uncompressed_data_bitpix (char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions) {
     263
     264  int i, Nbyte;
     265
     266  // GZIP_1, GZIP_2 use matched input & output pixels
     267  if (!strcasecmp(cmptype, "GZIP_1") ||
     268      !strcasecmp(cmptype, "GZIP_2") ||
     269      !strcasecmp(cmptype, "NONE")) {
     270    return (out_bitpix);
     271  }
     272
     273  // RICE_1 must operate on integer pixels
     274  if (!strcasecmp(cmptype, "RICE_1") ||
     275      !strcasecmp(cmptype, "RICE_ONE")) {
     276    // if BYTEPIX option is specified, use that for Nbyte
     277    for (i = 0; i < Noptions; i++) {
     278      if (!strcmp(optname[i], "BYTEPIX")) {
     279        Nbyte = atoi (optvalue[i]);
     280        return (Nbyte*8);
     281      }
     282    }
     283    if (out_bitpix ==   8) return (out_bitpix);
     284    if (out_bitpix ==  16) return (out_bitpix);
     285    if (out_bitpix ==  32) return (out_bitpix);
     286    return (32);
     287  }
     288
     289  // PLIO_1 always results in 4-byte ints (not 2 byte ints?)
     290  if (!strcasecmp(cmptype, "PLIO_1")) {
     291    return (32);
     292  }
     293
     294  if (!strcasecmp(cmptype, "HCOMPRESS_1")) {
     295    if (out_bitpix == 8)  return (32);
     296    if (out_bitpix == 16) return (32);
     297    return (64);
     298  }
     299  return (0);
     300}
     301
    206302int gfits_vartable_heap_pixsize (char format) {
    207303
Note: See TracChangeset for help on using the changeset viewer.