IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 1, 2009, 7:13:00 PM (18 years ago)
Author:
eugene
Message:

convert mask references to abstract psImageMaskType and psVectorMaskType as needed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20081230/psModules/src/config/pmConfigMask.c

    r19870 r21079  
    4545};
    4646// Default values in case a bad mask name and its fallback is not defined
    47 static const psMaskType defaultMask[] = { 0x00, // DETECTOR
    48                                           0x00, // DARK
    49                                           0x01, // FLAT
    50                                           0x01, // BLANK
    51                                           0x00, // RANGE
    52                                           0x01, // SAT
    53                                           0x01, // LOW
    54                                           0x01, // CONV
    55                                           0x00, // CR
    56                                           0x00  // GHOST
     47static const psImageMaskType defaultMask[] = { 0x00, // DETECTOR
     48                                               0x00, // DARK
     49                                               0x01, // FLAT
     50                                               0x01, // BLANK
     51                                               0x00, // RANGE
     52                                               0x01, // SAT
     53                                               0x01, // LOW
     54                                               0x01, // CONV
     55                                               0x00, // CR
     56                                               0x00  // GHOST
    5757};
    5858// Other mask names to ensure exist; these shouldn't be combined in the MASK.VALUE
     
    6262};
    6363
    64 static bool maskSetValues(psMaskType *outMaskValue, // Value of MASK.VALUE, returned
    65                           psMaskType *outMarkValue, // Value of MARK.VALUE, returned
     64static bool maskSetValues(psImageMaskType *outMaskValue, // Value of MASK.VALUE, returned
     65                          psImageMaskType *outMarkValue, // Value of MARK.VALUE, returned
    6666                          psMetadata *source  // Source of mask bits
    6767                          )
     
    7070
    7171    // Ensure all the bad mask names exist, and set the value to catch all bad pixels
    72     psMaskType maskValue = 0;           // Value to mask to catch all the bad pixels
     72    psImageMaskType maskValue = 0;           // Value to mask to catch all the bad pixels
    7373    for (int i = 0; badMaskNames[i]; i++) {
    7474        const char *name = badMaskNames[i]; // Name for mask
     
    7676
    7777        bool mdok;                      // Status of MD lookup
    78         psMaskType value = psMetadataLookupU8(&mdok, source, name); // Value of mask
     78        psImageMaskType value = psMetadataLookupImageMask(&mdok, source, name); // Value of mask
    7979        if (!value) {
    8080            if (fallback) {
    81                 value = psMetadataLookupU8(&mdok, source, fallback);
     81                value = psMetadataLookupImageMask(&mdok, source, fallback);
    8282            }
    8383            if (!value) {
    8484                value = defaultMask[i];
    8585            }
    86             psMetadataAddU8(source, PS_LIST_TAIL, name, PS_META_REPLACE, NULL, value);
     86            psMetadataAddImageMask(source, PS_LIST_TAIL, name, PS_META_REPLACE, NULL, value);
    8787        }
    8888        maskValue |= value;
     
    9393        const char *name = otherMaskNames[i]; // Name for mask
    9494        bool mdok;                      // Status of MD lookup
    95         psMaskType value = psMetadataLookupU8(&mdok, source, name); // Value of mask
     95        psImageMaskType value = psMetadataLookupImageMask(&mdok, source, name); // Value of mask
    9696        if (!value) {
    97             psMetadataAddU8(source, PS_LIST_TAIL, name, PS_META_REPLACE, NULL, 0x00);
     97            psMetadataAddImageMask(source, PS_LIST_TAIL, name, PS_META_REPLACE, NULL, 0x00);
    9898        }
    9999    }
    100100
    101101    // search for an unset bit to use for MARK:
    102     psMaskType markValue = 0x80;
    103 
    104     int nBits = sizeof(psMaskType) * 8;
     102    psImageMaskType markValue = 0x00;
     103    psImageMaskType markTrial = 0x01;
     104
     105    int nBits = sizeof(psImageMaskType) * 8;
    105106    for (int i = 0; !markValue && (i < nBits); i++) {
    106         if (maskValue & markValue) {
    107             markValue >>= 1;
     107        if (maskValue & markTrial) {
     108            markTrial <<= 1;
    108109        } else {
    109             markValue = markValue;
     110            markValue = markTrial;
    110111        }
    111112    }
     
    116117
    117118    // update the list with the results
    118     psMetadataAddU8(source, PS_LIST_TAIL, "MASK.VALUE", PS_META_REPLACE, NULL, maskValue);
    119     psMetadataAddU8(source, PS_LIST_TAIL, "MARK.VALUE", PS_META_REPLACE, NULL, markValue);
     119    psMetadataAddImageMask(source, PS_LIST_TAIL, "MASK.VALUE", PS_META_REPLACE, NULL, maskValue);
     120    psMetadataAddImageMask(source, PS_LIST_TAIL, "MARK.VALUE", PS_META_REPLACE, NULL, markValue);
    120121
    121122    if (outMaskValue) {
     
    130131
    131132// Get a mask value by name(s)
    132 static psMaskType maskGet(psMetadata *source, // Source of masks
    133                           const char *masks // Mask values to get
    134                           )
    135 {
    136     psMaskType mask = 0;                // Mask value, to return
     133static psImageMaskType maskGet(psMetadata *source, // Source of masks
     134                               const char *masks // Mask values to get
     135                               )
     136{
     137    psImageMaskType mask = 0;                // Mask value, to return
    137138
    138139    psArray *names = psStringSplitArray(masks, " ,;", false); // Array of symbolic names
     
    140141        const char *name = names->data[i]; // Symbolic name of interest
    141142        bool mdok;                      // Status of MD lookup
    142         psMaskType value = psMetadataLookupU8(&mdok, source, name);
     143        psImageMaskType value = psMetadataLookupImageMask(&mdok, source, name);
    143144        if (!mdok) {
    144145            // Try and generate the value if we can
     
    148149                    return 0;
    149150                }
    150                 value = psMetadataLookupU8(&mdok, source, name);
     151                value = psMetadataLookupImageMask(&mdok, source, name);
    151152                psAssert(mdok, "Should have generated mask value");
    152153            } else {
     
    187188
    188189#if 0
    189 bool pmFPAMaskSetValues(psMaskType *outMaskValue, psMaskType *outMarkValue, pmFPA *fpa)
     190bool pmFPAMaskSetValues(psImageMaskType *outMaskValue, psImageMaskType *outMarkValue, pmFPA *fpa)
    190191{
    191192    PS_ASSERT_PTR_NON_NULL(fpa, false);
     
    194195}
    195196
    196 psMaskType pmFPAMaskGet(const pmFPA *fpa, const char *masks, const pmConfig *config)
     197psImageMaskType pmFPAMaskGet(const pmFPA *fpa, const char *masks, const pmConfig *config)
    197198{
    198199    PS_ASSERT_PTR_NON_NULL(fpa, 0);
     
    206207}
    207208
    208 bool pmFPAMaskSet(pmFPA *fpa, const char *maskName, psMaskType maskValue)
     209bool pmFPAMaskSet(pmFPA *fpa, const char *maskName, psImageMaskType maskValue)
    209210{
    210211    PS_ASSERT_PTR_NON_NULL(fpa, 0);
     
    214215        fpa->masks = psMetadataAlloc();
    215216    }
    216     return psMetadataAddU8(fpa->masks, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue);
     217    return psMetadataAddImageMask(fpa->masks, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue);
    217218}
    218219
     
    250251            continue;
    251252        }
    252         psU8 bit = psMetadataLookupU8(&mdok, header, valuekey);
     253        psImageMaskType bit = psMetadataLookupImageMask(&mdok, header, valuekey);
    253254        if (!mdok) {
    254255            psWarning("Unable to find header keyword %s when parsing mask", namekey);
     
    267268            }
    268269        } else {
    269             psMetadataAddU8(fpa->masks, PS_LIST_TAIL, name, 0, NULL, bit);
     270            psMetadataAddImageMask(fpa->masks, PS_LIST_TAIL, name, 0, NULL, bit);
    270271        }
    271272    }
     
    286287        }
    287288        if (!psMetadataLookup(fpa->masks, item->name)) {
    288             psMetadataAddU8(fpa->masks, PS_LIST_TAIL, item->name, 0, item->comment,
     289            psMetadataAddImageMask(fpa->masks, PS_LIST_TAIL, item->name, 0, item->comment,
    289290                            item->data.PS_TYPE_MASK_DATA);
    290291        }
     
    322323
    323324        psMetadataAddStr(header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name);
    324         psMetadataAddU8(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.PS_TYPE_MASK_DATA);
     325        psMetadataAddImageMask(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.PS_TYPE_MASK_DATA);
    325326        numMask++;
    326327    }
     
    333334
    334335
    335 psMaskType pmConfigMaskGet(const char *masks, const pmConfig *config)
     336psImageMaskType pmConfigMaskGet(const char *masks, const pmConfig *config)
    336337{
    337338    psAssert(config, "Require configuration");
     
    348349
    349350
    350 bool pmConfigMaskSet(const pmConfig *config, const char *maskName, psMaskType maskValue)
     351bool pmConfigMaskSet(const pmConfig *config, const char *maskName, psImageMaskType maskValue)
    351352{
    352353    psAssert(config, "Require configuration");
     
    359360    }
    360361
    361     return psMetadataAddU8(recipe, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue);
     362    return psMetadataAddImageMask(recipe, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue);
    362363}
    363364
     
    381382    // versions so that it won't complain later
    382383    if (!psMetadataLookup(recipe, "MASK.VALUE")) {
    383         psMetadataAddU8(recipe, PS_LIST_TAIL, "MASK.VALUE", 0, "Bits to mask", 0);
     384        psMetadataAddImageMask(recipe, PS_LIST_TAIL, "MASK.VALUE", 0, "Bits to mask", 0);
    384385    }
    385386    if (!psMetadataLookup(recipe, "MARK.VALUE")) {
    386         psMetadataAddU8(recipe, PS_LIST_TAIL, "MARK.VALUE", 0, "Bits for marking", 0);
     387        psMetadataAddImageMask(recipe, PS_LIST_TAIL, "MARK.VALUE", 0, "Bits for marking", 0);
    387388    }
    388389
     
    408409            continue;
    409410        }
    410         psU8 bit = psMetadataLookupU8(&status, header, valuekey);
     411        psImageMaskType bit = psMetadataLookupImageMask(&status, header, valuekey);
    411412        if (!status) {
    412413            psWarning("Unable to find header keyword %s when parsing mask", namekey);
     
    427428
    428429        if (already) {
    429             if (item && item->data.U8 != bit) {
     430            if (item && item->data.PS_TYPE_IMAGE_MASK_DATA != bit) {
    430431                psWarning("New mask recipe entry doesn't match previously loaded entry: %x vs %x",
    431                           bit, item->data.U8);
     432                          bit, item->data.PS_TYPE_IMAGE_MASK_DATA);
    432433            }
    433434        } else {
     
    437438        if (!item) {
    438439            psWarning("Mask recipe entry %s not in recipe\n", name);
    439             psMetadataAddU8(recipe, PS_LIST_TAIL, name, 0, "Bitmask bit value", bit);
     440            psMetadataAddImageMask(recipe, PS_LIST_TAIL, name, 0, "Bitmask bit value", bit);
    440441        } else {
    441             item->data.U8 = bit;
     442            item->data.PS_TYPE_IMAGE_MASK_DATA = bit;
    442443        }
    443444
     
    481482        }
    482483
    483         if (item->type != PS_DATA_U8) {
     484        if (item->type != PS_TYPE_IMAGE_MASK) {
    484485            psWarning("mask recipe entry %s is not a bit value\n", item->name);
    485486            continue;
     
    490491
    491492        psMetadataAddStr(header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name);
    492         psMetadataAddU8(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.U8);
     493        psMetadataAddImageMask(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.PS_TYPE_IMAGE_MASK_DATA);
    493494        nMask++;
    494495    }
     
    500501
    501502
    502 bool pmConfigMaskSetBits(psMaskType *outMaskValue, psMaskType *outMarkValue, const pmConfig *config)
     503bool pmConfigMaskSetBits(psImageMaskType *outMaskValue, psImageMaskType *outMarkValue, const pmConfig *config)
    503504{
    504505    PS_ASSERT_PTR_NON_NULL(config, false);
Note: See TracChangeset for help on using the changeset viewer.