IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 13, 2008, 5:30:53 PM (18 years ago)
Author:
Paul Price
Message:

Only lock if running threaded.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmSubtraction.c

    r19059 r19061  
    215215                                  region.y0 - size, region.y1 + size); // Add a border
    216216
    217     // Casting away const
    218     psMutexLock((psImage*)image);
     217    bool threaded = pmSubtractionThreaded(); // Are we running threaded?
     218
     219    // Casting away const for image, mask
     220    if (threaded) {
     221        psMutexLock((psImage*)image);
     222    }
    219223    psImage *subImage = psImageSubset((psImage*)image, border); // Subimage to convolve
    220     psMutexUnlock((psImage*)image);
    221 
    222     // Casting away const
    223     psMutexLock((psImage*)mask);
     224    if (threaded) {
     225        psMutexUnlock((psImage*)image);
     226        psMutexLock((psImage*)mask);
     227    }
    224228    psImage *subMask = mask ? psImageSubset((psImage*)mask, border) : NULL; // Subimage mask
    225     psMutexUnlock((psImage*)mask);
     229    if (threaded) {
     230        psMutexUnlock((psImage*)mask);
     231    }
    226232
    227233    psImage *convolved = psImageConvolveFFT(NULL, subImage, subMask, maskVal, kernel); // Convolution
    228234
    229     psMutexLock((psImage*)image);
     235    if (threaded) {
     236        psMutexLock((psImage*)image);
     237    }
    230238    psFree(subImage);
    231     psMutexUnlock((psImage*)image);
    232 
    233     psMutexLock((psImage*)mask);
     239    if (threaded) {
     240        psMutexUnlock((psImage*)image);
     241        psMutexLock((psImage*)mask);
     242    }
    234243    psFree(subMask);
    235     psMutexUnlock((psImage*)mask);
     244    if (threaded) {
     245        psMutexUnlock((psImage*)mask);
     246    }
    236247
    237248    // Now, we have to chop off the borders, and stick it in where it belongs
     
    239250    psImage *subConv = psImageSubset(convolved, psRegionSet(size, -size, size, -size)); // Cut off the edges
    240251
    241     psMutexLock(target);
     252    if (threaded) {
     253        psMutexLock(target);
     254    }
    242255    psImage *subTarget = psImageSubset(target, region); // Target for this subregion
    243     psMutexUnlock(target);
     256    if (threaded) {
     257        psMutexUnlock(target);
     258    }
    244259    if (background != 0.0) {
    245260        psBinaryOp(subTarget, subConv, "+", psScalarAlloc(background, PS_TYPE_F32));
     
    252267    psFree(subConv);
    253268    psFree(convolved);
    254     psMutexLock(target);
     269    if (threaded) {
     270        psMutexLock(target);
     271    }
    255272    psFree(subTarget);
    256     psMutexUnlock(target);
     273    if (threaded) {
     274        psMutexUnlock(target);
     275    }
    257276    return;
    258277}
Note: See TracChangeset for help on using the changeset viewer.