IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 8, 2008, 8:09:07 AM (18 years ago)
Author:
Paul Price
Message:

Fixing to match slight differences in psThread

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmBias.c

    r18893 r18960  
    1919#include "pmBias.h"
    2020
    21 bool pmBiasSubtractScan_Threaded (psThreadJob *job) {
     21bool pmBiasSubtractScan_Threaded(const psThreadJob *job)
     22{
     23    PS_ASSERT_THREAD_JOB_NON_NULL(job, false);
    2224    pmReadout *in = job->args->data[0];
    2325    pmReadout *sub = job->args->data[1];
     
    6365// image.  The bias image is subtracted in place from the input image.
    6466bool pmBiasSubtractFrame(pmReadout *in, // Input readout
    65                         pmReadout *sub, // Readout to be subtracted from input
    66                         float scale   // Scale to apply before subtracting
     67                        pmReadout *sub, // Readout to be subtracted from input
     68                        float scale   // Scale to apply before subtracting
    6769    )
    6870{
     
    121123    bool threaded = true;
    122124    int scanRows = pmDetrendGetScanRows();
    123     if (scanRows == 0) { 
    124         threaded = false;
    125         scanRows = inImage->numRows;
     125    if (scanRows == 0) {
     126        threaded = false;
     127        scanRows = inImage->numRows;
    126128    }
    127129
     
    129131      int rowStop = PS_MIN (rowStart + scanRows, inImage->numRows);
    130132
    131 # define PS_ARRAY_ADD_SCALAR(ARRAY, VALUE, TYPE) { \
    132       psScalar *scalar = psScalarAlloc(VALUE, TYPE); \
    133       psArrayAdd(ARRAY, 1, scalar); \
    134       psFree (scalar); }
    135      
    136133      if (threaded) {
    137           // allocate a job, construct the arguments for this job
    138           psThreadJob *job = psThreadJobAlloc ("PSMODULES_DETREND_BIAS");
    139           psArrayAdd (job->args, 1, in);
    140           psArrayAdd (job->args, 1, sub);
    141           PS_ARRAY_ADD_SCALAR (job->args, scale, PS_TYPE_F32);
    142           PS_ARRAY_ADD_SCALAR (job->args, xOffset, PS_TYPE_S32);
    143           PS_ARRAY_ADD_SCALAR (job->args, yOffset, PS_TYPE_S32);
    144           PS_ARRAY_ADD_SCALAR (job->args, rowStart, PS_TYPE_S32);
    145           PS_ARRAY_ADD_SCALAR (job->args, rowStop, PS_TYPE_S32);
    146 
    147           // ppImageDetrendReadout(config, options, view)
    148           if (!psThreadJobAddPending (job)) {
    149               return false;
    150           }
     134          // allocate a job, construct the arguments for this job
     135          psThreadJob *job = psThreadJobAlloc ("PSMODULES_DETREND_BIAS");
     136          psArrayAdd (job->args, 1, in);
     137          psArrayAdd (job->args, 1, sub);
     138          PS_ARRAY_ADD_SCALAR (job->args, scale, PS_TYPE_F32);
     139          PS_ARRAY_ADD_SCALAR (job->args, xOffset, PS_TYPE_S32);
     140          PS_ARRAY_ADD_SCALAR (job->args, yOffset, PS_TYPE_S32);
     141          PS_ARRAY_ADD_SCALAR (job->args, rowStart, PS_TYPE_S32);
     142          PS_ARRAY_ADD_SCALAR (job->args, rowStop, PS_TYPE_S32);
     143
     144          // ppImageDetrendReadout(config, options, view)
     145          if (!psThreadJobAddPending (job)) {
     146              psFree(job);
     147              return false;
     148          }
     149          psFree(job);
    151150      } else {
    152           pmBiasSubtractScan (in, sub, scale, xOffset, yOffset, rowStart, rowStop);
     151          pmBiasSubtractScan (in, sub, scale, xOffset, yOffset, rowStart, rowStop);
    153152      }
    154153    }
    155154
    156155    if (threaded) {
    157         // wait here for the threaded jobs to finish
    158         if (!psThreadPoolWait ()) {
    159             psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
    160             return false;
    161         }
    162         fprintf (stderr, "success for threaded jobs\n");
    163 
    164         // each job records its own goodPixel values; sum them here
    165         // we have only supplied one type of job, so we can assume the types here
    166         psThreadJob *job = NULL;
    167         while ((job = psThreadJobGetDone()) != NULL) {
    168             psFree (job);
    169         }
     156        // wait here for the threaded jobs to finish
     157        if (!psThreadPoolWait(false)) {
     158            psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
     159            return false;
     160        }
     161        fprintf (stderr, "success for threaded jobs\n");
     162
     163        // each job records its own goodPixel values; sum them here
     164        // we have only supplied one type of job, so we can assume the types here
     165        psThreadJob *job = NULL;
     166        while ((job = psThreadJobGetDone()) != NULL) {
     167            psFree (job);
     168        }
    170169    }
    171170
Note: See TracChangeset for help on using the changeset viewer.