IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 26, 2004, 2:57:34 PM (22 years ago)
Author:
desonia
Message:

converted native C types to ps Types, where practical.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/image/psImage.c

    r2105 r2204  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-10-14 01:22:59 $
     12 *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-10-27 00:57:31 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2929static void imageFree(psImage* image);
    3030
    31 psImage* psImageAlloc(unsigned int numCols,
    32                       unsigned int numRows,
     31psImage* psImageAlloc(psU32 numCols,
     32                      psU32 numRows,
    3333                      const psElemType type)
    3434{
    35     int area = 0;
    36     int elementSize = PSELEMTYPE_SIZEOF(type);  // element size in bytes
    37     int rowSize = numCols * elementSize;        // row size in bytes.
     35    psS32 area = 0;
     36    psS32 elementSize = PSELEMTYPE_SIZEOF(type);  // element size in bytes
     37    psS32 rowSize = numCols * elementSize;        // row size in bytes.
    3838
    3939    area = numCols * numRows;
     
    5151    p_psMemSetDeallocator(image, (psFreeFcn) imageFree);
    5252
    53     image->data.V = psAlloc(sizeof(void *) * numRows);
     53    image->data.V = psAlloc(sizeof(psPtr ) * numRows);
    5454
    5555    image->rawDataBuffer = psAlloc(area * elementSize);
     
    5757    // set the row pointers.
    5858    image->data.V[0] = image->rawDataBuffer;
    59     for (int i = 1; i < numRows; i++) {
    60         image->data.V[i] = (void *)((int8_t *) image->data.V[i - 1] + rowSize);
    61     }
    62 
    63     *(int *)&image->col0 = 0;
    64     *(int *)&image->row0 = 0;
    65     *(unsigned int *)&image->numCols = numCols;
    66     *(unsigned int *)&image->numRows = numRows;
     59    for (psS32 i = 1; i < numRows; i++) {
     60        image->data.V[i] = (psPtr )((int8_t *) image->data.V[i - 1] + rowSize);
     61    }
     62
     63    *(psS32 *)&image->col0 = 0;
     64    *(psS32 *)&image->row0 = 0;
     65    *(psU32 *)&image->numCols = numCols;
     66    *(psU32 *)&image->numRows = numRows;
    6767    *(psDimen* ) & image->type.dimen = PS_DIMEN_IMAGE;
    6868    *(psElemType* ) & image->type.type = type;
     
    8181    if (image->type.type == PS_TYPE_PTR) {
    8282        // 2-D array of pointers -- must dereference elements
    83         unsigned int oldNumRows = image->numRows;
    84         unsigned int oldNumCols = image->numCols;
    85         psPTR* rowPtr;
    86 
    87         for (unsigned int row = 0; row < oldNumRows; row++) {
     83        psU32 oldNumRows = image->numRows;
     84        psU32 oldNumCols = image->numCols;
     85        psPtr* rowPtr;
     86
     87        for (psU32 row = 0; row < oldNumRows; row++) {
    8888            rowPtr = image->data.PTR[row];
    89             for (unsigned int col = 0; col < oldNumCols; col++) {
     89            for (psU32 col = 0; col < oldNumCols; col++) {
    9090                psMemDecrRefCounter(rowPtr[col]);
    9191            }
     
    105105
    106106psImage* psImageRecycle(psImage* old,
    107                         unsigned int numCols,
    108                         unsigned int numRows,
     107                        psU32 numCols,
     108                        psU32 numRows,
    109109                        const psElemType type)
    110110{
    111     int elementSize = PSELEMTYPE_SIZEOF(type);  // element size in bytes
    112     int rowSize = numCols * elementSize;        // row size in bytes.
     111    psS32 elementSize = PSELEMTYPE_SIZEOF(type);  // element size in bytes
     112    psS32 rowSize = numCols * elementSize;        // row size in bytes.
    113113
    114114    if (old == NULL) {
     
    128128        // 2-D array of pointers -- must
    129129        // dereference
    130         unsigned int oldNumRows = old->numRows;
    131         unsigned int oldNumCols = old->numCols;
    132         psPTR* rowPtr;
    133 
    134         for (unsigned int row = 0; row < oldNumRows; row++) {
     130        psU32 oldNumRows = old->numRows;
     131        psU32 oldNumCols = old->numCols;
     132        psPtr* rowPtr;
     133
     134        for (psU32 row = 0; row < oldNumRows; row++) {
    135135            rowPtr = old->data.PTR[row];
    136             for (unsigned int col = 0; col < oldNumCols; col++) {
     136            for (psU32 col = 0; col < oldNumCols; col++) {
    137137                psMemDecrRefCounter(rowPtr[col]);
    138138                rowPtr[col] = NULL;
     
    149149    old->rawDataBuffer = psRealloc(old->data.V[0],
    150150                                   numCols * numRows * elementSize);
    151     old->data.V = (void **)psRealloc(old->data.V, numRows * sizeof(void *));
     151    old->data.V = (psPtr *)psRealloc(old->data.V, numRows * sizeof(psPtr ));
    152152
    153153    // recreate the row pointers
    154154    old->data.V[0] = old->rawDataBuffer;
    155     for (int i = 1; i < numRows; i++) {
    156         old->data.V[i] = (void *)((int8_t *) old->data.V[i - 1] + rowSize);
    157     }
    158 
    159     *(unsigned int *)&old->numCols = numCols;
    160     *(unsigned int *)&old->numRows = numRows;
     155    for (psS32 i = 1; i < numRows; i++) {
     156        old->data.V[i] = (psPtr )((int8_t *) old->data.V[i - 1] + rowSize);
     157    }
     158
     159    *(psU32 *)&old->numCols = numCols;
     160    *(psU32 *)&old->numRows = numRows;
    161161    *(psElemType* ) & old->type.type = type;
    162162
     
    169169{
    170170    psElemType inDatatype;
    171     int elementSize;
    172     int elements;
    173     int numRows;
    174     int numCols;
     171    psS32 elementSize;
     172    psS32 elements;
     173    psS32 numRows;
     174    psS32 numCols;
    175175
    176176    if (input == NULL || input->data.V == NULL) {
     
    218218    // datatype.
    219219    if (type == inDatatype) {
    220         for (int row=0;row<numRows;row++) {
     220        for (psS32 row=0;row<numRows;row++) {
    221221            memcpy(output->data.V[row], input->data.V[row], elementSize * numCols);
    222222        }
     
    227227        ps##INTYPE *in; \
    228228        ps##OUTTYPE *out; \
    229         for(int row=0;row<numRows;row++) { \
     229        for(psS32 row=0;row<numRows;row++) { \
    230230            in = IN->data.INTYPE[row]; \
    231231            out = OUT->data.OUTTYPE[row]; \
    232             for (int col=0;col<numCols;col++) { \
     232            for (psS32 col=0;col<numCols;col++) { \
    233233                *(out++) = *(in++); \
    234234            } \
     
    331331}
    332332
    333 int psImageFreeChildren(psImage* image)
     333psS32 psImageFreeChildren(psImage* image)
    334334{
    335     int numFreed = 0;
     335    psS32 numFreed = 0;
    336336
    337337    if (image == NULL) {
     
    345345        // orphan the children first
    346346        // (so psFree doesn't try to modify the parent's children array while I'm using it)
    347         for (int i=0;i<numFreed;i++) {
     347        for (psS32 i=0;i<numFreed;i++) {
    348348            children[i]->parent = NULL;
    349349        }
     
    366366                              float y,
    367367                              const psImage* mask,
    368                               unsigned int maskVal,
     368                              psU32 maskVal,
    369369                              psC64 unexposedValue,
    370370                              psImageInterpolateMode mode)
     
    438438        float y, \
    439439        const psImage* mask, \
    440         unsigned int maskVal, \
     440        psU32 maskVal, \
    441441        psF64 unexposedValue) \
    442442{ \
    443     int intX = (int) round((psF64)(x) - 0.5 + FLT_EPSILON); \
    444     int intY = (int) round((psF64)(y) - 0.5 + FLT_EPSILON); \
    445     int lastX = input->numCols - 1; \
    446     int lastY = input->numRows - 1; \
     443    psS32 intX = (psS32) round((psF64)(x) - 0.5 + FLT_EPSILON); \
     444    psS32 intY = (psS32) round((psF64)(y) - 0.5 + FLT_EPSILON); \
     445    psS32 lastX = input->numCols - 1; \
     446    psS32 lastY = input->numRows - 1; \
    447447    \
    448448    if ((intX < 0) || \
     
    463463        float y, \
    464464        const psImage* mask, \
    465         unsigned int maskVal, \
     465        psU32 maskVal, \
    466466        psC64 unexposedValue) \
    467467{ \
    468     int intX = (int) round((psF64)(x) - 0.5); \
    469     int intY = (int) round((psF64)(y) - 0.5); \
    470     int lastX = input->numCols - 1; \
    471     int lastY = input->numRows - 1; \
     468    psS32 intX = (psS32) round((psF64)(x) - 0.5); \
     469    psS32 intY = (psS32) round((psF64)(y) - 0.5); \
     470    psS32 lastX = input->numCols - 1; \
     471    psS32 lastY = input->numRows - 1; \
    472472    \
    473473    if ((intX < 0) || \
     
    501501        float y, \
    502502        const psImage* mask, \
    503         unsigned int maskVal, \
     503        psU32 maskVal, \
    504504        psF64 unexposedValue) \
    505505{ \
     
    508508    psF64 fracX = x - 0.5 - floorX; \
    509509    psF64 fracY = y - 0.5 - floorY; \
    510     int intFloorX = (int) floorX; \
    511     int intFloorY = (int) floorY; \
    512     int lastX = input->numCols - 1; \
    513     int lastY = input->numRows - 1; \
     510    psS32 intFloorX = (psS32) floorX; \
     511    psS32 intFloorY = (psS32) floorY; \
     512    psS32 lastX = input->numCols - 1; \
     513    psS32 lastY = input->numRows - 1; \
    514514    ps##TYPE V00; \
    515515    ps##TYPE V01; \
    516516    ps##TYPE V10; \
    517517    ps##TYPE V11; \
    518     bool valid00 = false; \
    519     bool valid01 = false; \
    520     bool valid10 = false; \
    521     bool valid11 = false; \
     518    psBool valid00 = false; \
     519    psBool valid01 = false; \
     520    psBool valid10 = false; \
     521    psBool valid11 = false; \
    522522    \
    523523    if (intFloorY >= 0 && intFloorY <= lastY) { \
     
    556556    \
    557557    psF64 V0; \
    558     bool valid0 = true; \
     558    psBool valid0 = true; \
    559559    if (valid00 && valid10) { \
    560560        V0 = V00*(1-fracX)+V10*fracX; \
     
    568568    \
    569569    psF64 V1; \
    570     bool valid1 = true; \
     570    psBool valid1 = true; \
    571571    if (valid01 && valid11) { \
    572572        V1 = V01*(1-fracX)+V11*fracX; \
     
    595595        float y, \
    596596        const psImage* mask, \
    597         unsigned int maskVal, \
     597        psU32 maskVal, \
    598598        psC64 unexposedValue) \
    599599{ \
     
    602602    psF64 fracX = x - 0.5 - floorX; \
    603603    psF64 fracY = y - 0.5 - floorY; \
    604     int intFloorX = (int) floorX; \
    605     int intFloorY = (int) floorY; \
    606     int lastX = input->numCols - 1; \
    607     int lastY = input->numRows - 1; \
     604    psS32 intFloorX = (psS32) floorX; \
     605    psS32 intFloorY = (psS32) floorY; \
     606    psS32 lastX = input->numCols - 1; \
     607    psS32 lastY = input->numRows - 1; \
    608608    ps##TYPE V00; \
    609609    ps##TYPE V01; \
    610610    ps##TYPE V10; \
    611611    ps##TYPE V11; \
    612     bool valid00 = false; \
    613     bool valid01 = false; \
    614     bool valid10 = false; \
    615     bool valid11 = false; \
     612    psBool valid00 = false; \
     613    psBool valid01 = false; \
     614    psBool valid10 = false; \
     615    psBool valid11 = false; \
    616616    \
    617617    if (intFloorY >= 0 && intFloorY <= lastY) { \
     
    650650    \
    651651    psC64 V0; \
    652     bool valid0 = true; \
     652    psBool valid0 = true; \
    653653    if (valid00 && valid10) { \
    654654        V0 = V00*(1-fracX)+V10*fracX; \
     
    662662    \
    663663    psC64 V1; \
    664     bool valid1 = true; \
     664    psBool valid1 = true; \
    665665    if (valid01 && valid11) { \
    666666        V0 = V01*(1-fracX)+V11*fracX; \
Note: See TracChangeset for help on using the changeset viewer.