IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37018


Ignore:
Timestamp:
Jul 16, 2014, 2:45:18 PM (12 years ago)
Author:
eugene
Message:

after testing for memory corruption issues, return the code to the way it was (leave in some commented-out tests)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140610/psLib/src/fits/psFitsImage.c

    r36537 r37018  
    345345        if (newScaleZero) {
    346346            // Choose an appropriate BSCALE and BZERO
    347           if (!psFitsScaleDetermine(bscale, bzero, boffset, bsoften, blank, image, mask, maskVal, fits)) {
    348                 // We can't have the write dying for this reason --- try to save it somehow!
    349                 psWarning("Unable to determine BSCALE and BZERO for image --- refusing to quantise.");
    350                 psErrorClear();
    351                 return psMemIncrRefCounter((psImage*)image);
    352             }
     347            if (!psFitsScaleDetermine(bscale, bzero, boffset, bsoften, blank, image, mask, maskVal, fits)) {
     348                // We can't have the write dying for this reason --- try to save it somehow!
     349                psWarning("Unable to determine BSCALE and BZERO for image --- refusing to quantise.");
     350                psErrorClear();
     351                return psMemIncrRefCounter((psImage*)image);
     352            }
    353353        } else {
    354             // Don't want to muck with the current BSCALE and BZERO.  Get the current values and use those.
    355             int status = 0;                 // Status of cfitsio
    356             if (fits_read_key_dbl(fits->fd, "BSCALE", bscale, NULL, &status) && status != KEY_NO_EXIST) {
     354            // Don't want to muck with the current BSCALE and BZERO.  Get the current values and use those.
     355            int status = 0;                 // Status of cfitsio
     356            if (fits_read_key_dbl(fits->fd, "BSCALE", bscale, NULL, &status) && status != KEY_NO_EXIST) {
    357357                psFitsError(status, true, "Unable to read header.");
    358358                return NULL;
     
    371371        }
    372372
    373         return psFitsScaleForDisk(image, fits, *bscale, *bzero, *boffset, *bsoften, rng);
     373        // XXX this test triggers the pswarp memory corruption problem.  you need to include "psThread.h" above to activate this
     374        // for (int nx = 0; nx < 3; nx++) {
     375        //     psList *pending = psThreadGetPendingQueue();
     376        //     if (pending && pending->head) {
     377        //      fprintf (stderr, "thread jobs are still pending...\n");
     378        //     }
     379        //     // XXX can we mess up the memory?
     380        //     psImage *temp1 = psImageAlloc(image->numCols, image->numRows, PS_TYPE_F32);
     381        //     fprintf (stderr, "corruption check set 1\n");
     382        //     psMemCheckCorruption (stderr, true);
     383        //     psImageInit (temp1, 2.0);
     384        //     psFree (temp1);
     385        //     fprintf (stderr, "corruption check set 2\n");
     386        //     psMemCheckCorruption (stderr, true);
     387        // }
     388
     389        // fprintf (stderr, "corruption check psFitsInsertImageWithMask\n");
     390        // psMemCheckCorruption (stderr, true);
     391
     392        psImage *out = psFitsScaleForDisk(image, fits, *bscale, *bzero, *boffset, *bsoften, rng);
     393        return out;
    374394    }
    375395
     
    638658    long blank = 0;                     // Blank (undefined) value for image
    639659    psFitsFloat floatType;              // Custom floating-point convention type
    640     psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &boffset, &bsoften, &blank, &floatType, fits, image,
    641                                                    mask, maskVal, NULL, true); // Image to write out
     660
     661    psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &boffset, &bsoften, &blank, &floatType,
     662                                                   fits, image, mask, maskVal, NULL, true); // Image to write out
     663
    642664    if (!diskImage) {
    643665        psError(PS_ERR_UNKNOWN, false, "Unable to convert image to desired disk format.");
     
    666688        goto INSERT_DONE;
    667689    }
     690
    668691    if (cfitsioBzero != 0.0) {
    669692        psAssert(bzero == 0.0 && bscale == 1.0,
     
    840863        }
    841864    }
     865
    842866    if (psFitsError(status, true, "Could not write image to file.")) {
    843867        success = false;
     
    856880 INSERT_DONE:
    857881    psFree(diskImage);
     882
    858883    if (compress) {
    859884        // Restore compression state
     
    906931    psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &boffset, &bsoften, &blank, &floatType, fits, input,
    907932                                                   mask, maskVal, NULL, false); // Image to write out
     933   
    908934    if (!diskImage) {
    909935        psError(PS_ERR_UNKNOWN, false, "Unable to convert image to desired disk format.");
     
    932958        goto UPDATE_DONE;
    933959    }
     960
    934961    if (cfitsioBzero != 0.0) {
    935962        psAssert(bzero == 0.0 && bscale == 1.0,
     
    9791006        goto UPDATE_DONE;
    9801007    }
    981 
     1008   
    9821009    // We only want cfitsio to do the scale and zero if the type conversion requires it (e.g., input type is
    9831010    // an unsigned integer type).  In all other cases, we have already converted the image to use the
Note: See TracChangeset for help on using the changeset viewer.