Unified · Split
| @@ -136,27 +136,36 @@ static av_cold int init(AVFilterContext *ctx) · 135 unmodified lines | |||
| 136 | const lfCamera **cameras; | 136 | const lfCamera **cameras; |
| 137 | const lfLens **lenses; | 137 | const lfLens **lenses; |
| 138 | 138 | ||
| 139 | if (!lensfun->make) { | 139 | db = lf_db_create(); |
| 140 | av_log(ctx, AV_LOG_FATAL, "Option \"make\" not specified\n"); | 140 | if (lf_db_load(db) != LF_NO_ERROR) { |
| 141 | return AVERROR(EINVAL); | 141 | lf_db_destroy(db); |
| 142 | } else if (!lensfun->model) { | 142 | av_log(ctx, AV_LOG_FATAL, "Failed to load lensfun database\n"); |
| 143 | av_log(ctx, AV_LOG_FATAL, "Option \"model\" not specified\n"); | 143 | return AVERROR_INVALIDDATA; |
| 144 | } | ||
| 145 | |||
| 146 | if (!lensfun->make || !lensfun->model) { | ||
| 147 | const lfCamera *const *cameras = lf_db_get_cameras(db); | ||
| 148 | |||
| 149 | av_log(ctx, AV_LOG_FATAL, "Option \"make\" or option \"model\" not specified\n"); | ||
| 150 | av_log(ctx, AV_LOG_INFO, "Available values for \"make\" and \"model\":\n"); | ||
| 151 | for (int i = 0; cameras && cameras[i]; i++) | ||
| 152 | av_log(ctx, AV_LOG_INFO, "\t%s\t%s\n", cameras[i]->Maker, cameras[i]->Model); | ||
| 153 | lf_db_destroy(db); | ||
| 144 | return AVERROR(EINVAL); | 154 | return AVERROR(EINVAL); |
| 145 | } else if (!lensfun->lens_model) { | 155 | } else if (!lensfun->lens_model) { |
| 156 | const lfLens *const *lenses = lf_db_get_lenses(db); | ||
| 157 | |||
| 146 | av_log(ctx, AV_LOG_FATAL, "Option \"lens_model\" not specified\n"); | 158 | av_log(ctx, AV_LOG_FATAL, "Option \"lens_model\" not specified\n"); |
| 159 | av_log(ctx, AV_LOG_INFO, "Available values for \"lens_model\":\n"); | ||
| 160 | for (int i = 0; lenses && lenses[i]; i++) | ||
| 161 | av_log(ctx, AV_LOG_INFO, "\t%s\t(make %s)\n", lenses[i]->Model, lenses[i]->Maker); | ||
| 162 | lf_db_destroy(db); | ||
| 147 | return AVERROR(EINVAL); | 163 | return AVERROR(EINVAL); |
| 148 | } | 164 | } |
| 149 | 165 | ||
| 150 | lensfun->lens = lf_lens_create(); | 166 | lensfun->lens = lf_lens_create(); |
| 151 | lensfun->camera = lf_camera_create(); | 167 | lensfun->camera = lf_camera_create(); |
| 152 | 168 | ||
| 153 | db = lf_db_create(); | ||
| 154 | if (lf_db_load(db) != LF_NO_ERROR) { | ||
| 155 | lf_db_destroy(db); | ||
| 156 | av_log(ctx, AV_LOG_FATAL, "Failed to load lensfun database\n"); | ||
| 157 | return AVERROR_INVALIDDATA; | ||
| 158 | } | ||
| 159 | |||
| 160 | cameras = lf_db_find_cameras(db, lensfun->make, lensfun->model); | 169 | cameras = lf_db_find_cameras(db, lensfun->make, lensfun->model); |
| 161 | if (cameras && *cameras) { | 170 | if (cameras && *cameras) { |
| 162 | lf_camera_copy(lensfun->camera, *cameras); | 171 | lf_camera_copy(lensfun->camera, *cameras); |