IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19271


Ignore:
Timestamp:
Aug 28, 2008, 3:15:07 PM (18 years ago)
Author:
Paul Price
Message:

Reducing (and asserting on) bounds for copy. There's some memory
corruption going on here somewhere when threaded.

File:
1 edited

Legend:

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

    r19170 r19271  
    369369
    370370        if (box > 0) {
     371            int colMin = region.x0, colMax = region.x1, rowMin = region.y0, rowMax = region.y1; // Bounds
     372
    371373            bool threaded = pmSubtractionThreaded(); // Are we running threaded?
    372374            if (threaded) {
    373375                psMutexLock(subMask);
    374376            }
    375             psImage *image = psImageSubset(subMask, psRegionSet(region.x0 + xMin, region.x1 + xMax,
    376                                                                 region.y0 + yMin, region.y1 + yMax));
     377            psImage *image = psImageSubset(subMask, psRegionSet(colMin - box, colMax + box,
     378                                                                rowMin - box, rowMax + box));
    377379            if (threaded) {
    378380                psMutexUnlock(subMask);
     
    390392            }
    391393
    392             int colMin = region.x0, colMax = region.x1, rowMin = region.y0, rowMax = region.y1; // Bounds
    393394            int numBytes = (colMax - colMin) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK); // Number of bytes to copy
     395            psAssert(convolved->numCols - 2 * box == colMax - colMin, "Bad number of columns");
     396            psAssert(convolved->numRows - 2 * box == rowMax - rowMin, "Bad number of rows");
    394397
    395398            // Since we're copying back into the source, we need to lock
     
    397400                psMutexLock(subMask);
    398401            }
    399             for (int yTarget = rowMin, ySource = -yMin; yTarget < rowMax; yTarget++, ySource++) {
     402            for (int yTarget = rowMin, ySource = box; yTarget < rowMax; yTarget++, ySource++) {
    400403                memcpy(&subMask->data.PS_TYPE_MASK_DATA[yTarget][colMin],
    401                        &convolved->data.PS_TYPE_MASK_DATA[ySource][-xMin], numBytes);
     404                       &convolved->data.PS_TYPE_MASK_DATA[ySource][box], numBytes);
    402405            }
    403406            if (threaded) {
Note: See TracChangeset for help on using the changeset viewer.