History

avfilter/vf_lensfun: display list of possible values if user supplied none

Paul B Mahol committed 5 years ago

Commit d16293e1 parent 8b78eb31 file · +21 −12Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/vf_lensfun.c+21−12
@@ -136,27 +136,36 @@ static av_cold int init(AVFilterContext *ctx) · 135 unmodified lines
136136 const lfCamera **cameras;
137137 const lfLens **lenses;
138138
139− if (!lensfun->make) {
140− av_log(ctx, AV_LOG_FATAL, "Option \"make\" not specified\n");
141− return AVERROR(EINVAL);
142− } else if (!lensfun->model) {
143− av_log(ctx, AV_LOG_FATAL, "Option \"model\" not specified\n");
139+ db = lf_db_create();
140+ if (lf_db_load(db) != LF_NO_ERROR) {
141+ lf_db_destroy(db);
142+ av_log(ctx, AV_LOG_FATAL, "Failed to load lensfun database\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);
144154 return AVERROR(EINVAL);
145155 } else if (!lensfun->lens_model) {
156+ const lfLens *const *lenses = lf_db_get_lenses(db);
157+
146158 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);
147163 return AVERROR(EINVAL);
148164 }
149165
150166 lensfun->lens = lf_lens_create();
151167 lensfun->camera = lf_camera_create();
152168
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−
160169 cameras = lf_db_find_cameras(db, lensfun->make, lensfun->model);
161170 if (cameras && *cameras) {
162171 lf_camera_copy(lensfun->camera, *cameras);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t