IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 28, 2009, 11:21:56 AM (17 years ago)
Author:
eugene
Message:

always handle psVectorStats false return status (is an error); check for NAN results and handle as possible

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImagePixelExtract.c

    r21183 r23989  
    419419        }
    420420
    421 #define PSIMAGE_CUT_VERTICAL(TYPE) \
    422     case PS_TYPE_##TYPE: { \
    423             psVectorMaskType* maskVecData = NULL; \
    424             for (psS32 c = col0; c < col1; c++) { \
    425                 ps##TYPE *imgData = input->data.TYPE[row0] + c; \
    426                 ps##TYPE *imgVecData = imgVec->data.TYPE; \
    427                 if (maskVec != NULL) { \
     421#define PSIMAGE_CUT_VERTICAL(TYPE)                                      \
     422        case PS_TYPE_##TYPE: {                                          \
     423            psVectorMaskType* maskVecData = NULL;                       \
     424            for (psS32 c = col0; c < col1; c++) {                       \
     425                ps##TYPE *imgData = input->data.TYPE[row0] + c;         \
     426                ps##TYPE *imgVecData = imgVec->data.TYPE;               \
     427                if (maskVec != NULL) {                                  \
    428428                    maskVecData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA; \
    429429                    maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[row0][c]; /* XXX double check this... */ \
    430430                    /** old entry: maskData = (psMaskType* )(mask->data.PS_TYPE_IMAGE_MASK_DATA[row0]) + c; */ \
    431                 } \
    432                 for (psS32 r = row0; r < row1; r++) { \
    433                    *imgVecData = *imgData; \
    434                     imgVecData ++; \
    435                     imgData += inCols; \
    436                     if (maskVecData != NULL) { \
    437                         *maskVecData = (*maskData & maskVal); \
    438                         maskVecData ++; \
    439                         maskData += inCols; \
    440                     } \
    441                 } \
    442                 psVectorStats(myStats, imgVec, NULL, maskVec, 0xff); \
    443                 *outData = psStatsGetValue(myStats, statistic); \
    444                 if (outPosition != NULL) { \
    445                     outPosition->x = c; \
    446                     outPosition->y = row0; \
    447                     outPosition += delta; \
    448                 } \
    449                 outData += delta; \
    450             } \
    451             break; \
     431                }                                                       \
     432                for (psS32 r = row0; r < row1; r++) {                   \
     433                    *imgVecData = *imgData;                             \
     434                    imgVecData ++;                                      \
     435                    imgData += inCols;                                  \
     436                    if (maskVecData != NULL) {                          \
     437                        *maskVecData = (*maskData & maskVal);           \
     438                        maskVecData ++;                                 \
     439                        maskData += inCols;                             \
     440                    }                                                   \
     441                }                                                       \
     442                if (!psVectorStats(myStats, imgVec, NULL, maskVec, 0xff)) { \
     443                    psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); \
     444                    psFree(out);                                        \
     445                    out = NULL;                                         \
     446                    break;                                              \
     447                }                                                       \
     448                *outData = psStatsGetValue(myStats, statistic);         \
     449                if (outPosition != NULL) {                              \
     450                    outPosition->x = c;                                 \
     451                    outPosition->y = row0;                              \
     452                    outPosition += delta;                               \
     453                }                                                       \
     454                outData += delta;                                       \
     455            }                                                           \
     456            break;                                                      \
    452457        }
    453458
     
    466471                char* typeStr;
    467472                PS_TYPE_NAME(typeStr,type);
    468                 psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    469                         _("Specified psImage type, %s, is not supported."),
    470                         typeStr);
     473                psError(PS_ERR_BAD_PARAMETER_TYPE, true, _("Specified psImage type, %s, is not supported."), typeStr);
    471474                psFree(out);
    472475                out = NULL;
     
    534537            }
    535538
    536             psVectorStats(myStats, imgVec, NULL, maskVec, 0xff);
     539            if (!psVectorStats(myStats, imgVec, NULL, maskVec, 0xff)) {
     540                psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     541                psFree (out);
     542                out = NULL;
     543                break;
     544            }
    537545            *outData = psStatsGetValue(myStats, statistic);
    538546            if (outPosition != NULL) {
     
    933941
    934942    for (psS32 r = 0; r < numOut; r++) {
    935         psVectorStats(myStats, buffer[r], NULL, bufferMask[r], 0xff);
     943        if (!psVectorStats(myStats, buffer[r], NULL, bufferMask[r], 0xff)){
     944            psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     945            psFree(out);
     946            out = NULL;
     947            break;
     948        }
    936949        outData[r] = psStatsGetValue(myStats, statistic);
    937950    }
Note: See TracChangeset for help on using the changeset viewer.