Changeset 14889 for trunk/psModules/src/camera/pmFPAfileDefine.c
- Timestamp:
- Sep 19, 2007, 11:37:58 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAfileDefine.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAfileDefine.c
r14647 r14889 79 79 file->fpa = psMemIncrRefCounter(fpa); 80 80 file->camera = psMemIncrRefCounter((psMetadata *)fpa->camera); 81 file->cameraName = psMemIncrRefCounter(config->cameraName); 81 82 } 82 83 … … 97 98 pmFPA *fpa, // Optional FPA to bind 98 99 const char *name, // Name of file rule 99 const char *cameraName, // Name of camera configuration to use100 const char *formatName // Name of camera format to use100 psString cameraName, // Name of camera configuration to use 101 psString formatName // Name of camera format to use 101 102 ) 102 103 { … … 164 165 } else { 165 166 camera = config->camera; 167 cameraName = config->cameraName; 166 168 } 167 169 } else { … … 184 186 } 185 187 file->camera = psMemIncrRefCounter(camera); 188 file->cameraName = psMemIncrRefCounter(cameraName); 186 189 187 190 // Use the format we were told to, the format specified in the file rule, or default to the default format 188 191 if (!formatName || strlen(formatName) == 0) { 189 // select the format list from the selected camera 190 formatName = psMetadataLookupStr(&status, data, "FILE.FORMAT"); 191 if (!formatName || strcmp(formatName, "NONE") == 0) { 192 // Try to get by with the default 193 formatName = config->formatName; 192 if (fpa && fpa->formatName && strlen(fpa->formatName) > 0) { 193 formatName = (psString)fpa->formatName; // Casting away "const" --- it will be copied, so no prob. 194 } else { 195 // select the format list from the selected camera 196 formatName = psMetadataLookupStr(&status, data, "FILE.FORMAT"); 197 if (!formatName || strcmp(formatName, "NONE") == 0) { 198 // Try to get by with the default 199 formatName = config->formatName; 200 } 194 201 } 195 202 } … … 263 270 264 271 return pmFPAfileDefineOutputForFormat(config, fpa, name, NULL, NULL); 272 } 273 274 // define a pmFPAfile, bind to the optional file if supplied 275 pmFPAfile *pmFPAfileDefineOutputFromFile(const pmConfig *config, pmFPAfile *file, const char *name) 276 { 277 PS_ASSERT_PTR_NON_NULL(config, NULL); 278 PS_ASSERT_PTR_NON_NULL(config->files, NULL); 279 PS_ASSERT_PTR_NON_NULL(config->camera, NULL); 280 PS_ASSERT_STRING_NON_EMPTY(name, NULL); 281 282 char *cameraName = NULL, *formatName = NULL; // Name of camera and format 283 pmFPA *fpa = NULL; // FPA for file 284 if (file) { 285 cameraName = file->cameraName; 286 formatName = file->formatName; 287 fpa = file->fpa; 288 } 289 290 return pmFPAfileDefineOutputForFormat(config, fpa, name, cameraName, formatName); 265 291 } 266 292 … … 911 937 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 912 938 913 // Need to look up the format914 bool mdok; // Status of MD lookup915 psMetadata *formats = psMetadataLookupMetadata(&mdok, src->camera, "FORMATS"); // The FORMATS916 if (!mdok || !formats) {917 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find FORMATS in camera configuration %s.\n",918 config->cameraName);919 return NULL;920 }921 psMetadata *format = psMetadataLookupMetadata(&mdok, formats, config->formatName); // The format922 if (!mdok || !format) {923 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find camera format %s within camera %s.\n",924 config->formatName, config->cameraName);925 return NULL;926 }927 928 939 pmFPA *fpa = pmFPAConstruct(src->camera); 929 940 pmFPAfile *file = pmFPAfileDefineOutput (config, fpa, filename); … … 932 943 return NULL; 933 944 } 934 file->src = src; // inherit output elements from this source pmFPA945 file->src = psMemIncrRefCounter(src); // inherit output elements from this source pmFPA 935 946 file->xBin = xBin; 936 947 file->yBin = yBin; 937 948 psFree (fpa); 949 return file; 950 } 951 952 pmFPAfile *pmFPAfileDefineFromFile(const pmConfig *config, pmFPAfile *src, int xBin, int yBin, 953 const char *filename) 954 { 955 PS_ASSERT_PTR_NON_NULL(config, false); 956 PS_ASSERT_PTR_NON_NULL(src, false); 957 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 958 959 pmFPAfile *file = pmFPAfileDefineOutputForFormat(config, NULL, filename, src->cameraName, 960 src->formatName); 961 file->src = psMemIncrRefCounter(src->fpa); // inherit output elements from this source pmFPA 962 file->xBin = xBin; 963 file->yBin = yBin; 938 964 return file; 939 965 } … … 1038 1064 } 1039 1065 1040 file->src = src; // inherit output elements from this source pmFPA1066 file->src = psMemIncrRefCounter(src); // inherit output elements from this source pmFPA 1041 1067 1042 1068 file->mosaicLevel = PM_FPA_LEVEL_CHIP; // don't do any I/O on this at a lower level … … 1083 1109 } 1084 1110 1085 file->src = src; // inherit output elements from this source pmFPA1111 file->src = psMemIncrRefCounter(src); // inherit output elements from this source pmFPA 1086 1112 1087 1113 file->mosaicLevel = PM_FPA_LEVEL_FPA; // don't do any I/O on this at a lower level
Note:
See TracChangeset
for help on using the changeset viewer.
