IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21535 for trunk/psLib


Ignore:
Timestamp:
Feb 18, 2009, 5:15:40 PM (17 years ago)
Author:
Paul Price
Message:

It seems to be impossible for us to directly write out U16 with PLIO
compression: it won't convert on the fly, and we can't convert
ourselves to S16 without introducing negative values (which PLIO can't
tolerate).
Therefore we converted U16 to S32 (and U32 to S64) before passing the
image on to cfitsio for PLIO compression. This is acceptable, so long
as the values used are less than 224 (guaranteed for the U16
original).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/fits/psFitsImage.c

    r21183 r21535  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2009-01-27 06:39:37 $
     9 *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2009-02-19 03:15:40 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    266266    *floatType = PS_FITS_FLOAT_NONE;
    267267
    268     psFitsOptions *options = fits->options;
     268    psFitsOptions *options = fits->options; // Options for FITS writing
     269
     270    // Can't PLIO compress U16,U32,U64 directly, so convert them
     271    if (psFitsCompressionGetType(fits) == PS_FITS_COMPRESS_PLIO && (!options || options->bitpix == 0)) {
     272        switch (image->type.type) {
     273          case PS_TYPE_U16:
     274            return psImageCopy(NULL, image, PS_TYPE_S32);
     275          case PS_TYPE_U32:
     276            return psImageCopy(NULL, image, PS_TYPE_S64);
     277          case PS_TYPE_U64:
     278            // Conversion would result in numerical overflow
     279            psError(PS_ERR_IO, true, "Unable to compress U64 images");
     280            return NULL;
     281          default:
     282            // No action
     283            ;
     284        }
     285    }
     286
    269287    if (!options) {
    270288        return psMemIncrRefCounter((psImage*)image); // Casting away const
Note: See TracChangeset for help on using the changeset viewer.