LensSerious 0.1
Lens-correction mathematics as data, not as a library of callbacks
Loading...
Searching...
No Matches
lensserious_db.h
Go to the documentation of this file.
1/*
2 LensSerious — reading the lens database.
3
4 Copyright (C) 2026 Aurélien PIERRE. License: LGPL-3.0-or-later.
5*/
6
48#ifndef LENSSERIOUS_DB_H
49#define LENSSERIOUS_DB_H
50
51#include "lensserious.h"
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
68size_t ls_db_normalize(const char *in, char *out, size_t out_size);
69
85int ls_db_tokenize(const char *norm, char *out_tokens, int max, int stride);
86
88unsigned ls_db_token_hash(const char *token);
89
100size_t ls_db_token_digest(const char *norm, unsigned char *out, size_t out_size);
101
103typedef struct ls_db_t ls_db_t;
104
106typedef struct ls_camera_t
107{
112 long long id;
116 long long mount_id;
118
128ls_db_t *ls_db_open(const char *path);
129
131void ls_db_close(ls_db_t *db);
132
134const char *ls_db_error(const ls_db_t *db);
135
137int ls_db_schema_version(const ls_db_t *db);
138
141int ls_db_meta(ls_db_t *db, const char *key, char *out, size_t out_size);
142
157int ls_db_find_camera(ls_db_t *db, const char *maker, const char *model, ls_camera_t *out);
158
174int ls_db_find_lens(ls_db_t *db, const char *maker, const char *model, float crop,
175 ls_lens_t *out);
176
178typedef struct ls_db_match_t
179{
180 long long lens_id;
181 float score;
183
214int ls_db_match_lens(ls_db_t *db, const char *maker, const char *model, long long mount_id,
215 float crop, ls_db_match_t *out, int max);
216
218int ls_db_lens_by_id(ls_db_t *db, long long lens_id, ls_lens_t *out);
219
224int ls_db_lens_fits_mount(ls_db_t *db, long long lens_id, long long mount_id);
225
234int ls_db_list_lenses(ls_db_t *db, long long *out_ids, int max);
235
237int ls_db_lens_name(ls_db_t *db, long long lens_id, char *maker, size_t maker_size,
238 char *model, size_t model_size);
239
248int ls_db_lens_range(ls_db_t *db, long long lens_id, float *min_focal, float *max_focal,
249 float *min_aperture, float *max_aperture);
250
264int ls_db_lens_mounts(ls_db_t *db, long long lens_id, char *out, size_t out_size);
265
274int ls_db_list_cameras(ls_db_t *db, long long *out_ids, int max);
275
286int ls_db_camera_name(ls_db_t *db, long long camera_id, char *maker, size_t maker_size,
287 char *model, size_t model_size, char *variant, size_t variant_size);
288
290int ls_db_camera_by_id(ls_db_t *db, long long camera_id, ls_camera_t *out);
291
305int ls_db_mount_name(ls_db_t *db, long long mount_id, char *out, size_t out_size);
306
320int ls_db_lenses_for_mount(ls_db_t *db, long long mount_id, long long *out_ids, int max);
321
322#ifdef __cplusplus
323}
324#endif
325
326#endif /* LENSSERIOUS_DB_H */
What this is, and what it deliberately is not.
int ls_db_lenses_for_mount(ls_db_t *db, long long mount_id, long long *out_ids, int max)
The lenses made for one mount.
int ls_db_find_lens(ls_db_t *db, const char *maker, const char *model, float crop, ls_lens_t *out)
Find a lens by maker and model, and fill out with its coefficients.
int ls_db_match_lens(ls_db_t *db, const char *maker, const char *model, long long mount_id, float crop, ls_db_match_t *out, int max)
Find the lenses a free-text name most likely refers to.
int ls_db_meta(ls_db_t *db, const char *key, char *out, size_t out_size)
A meta value by key (built_utc, source, lensfun_db_version, ...).
struct ls_db_match_t ls_db_match_t
void ls_db_close(ls_db_t *db)
Release a handle. Safe on NULL.
int ls_db_list_cameras(ls_db_t *db, long long *out_ids, int max)
Enumerate camera ids, for a GUI's camera picker.
int ls_db_list_lenses(ls_db_t *db, long long *out_ids, int max)
Enumerate lens ids, oldest-inserted first, for tests and for a GUI's lens picker.
int ls_db_tokenize(const char *norm, char *out_tokens, int max, int stride)
The tokens ls_db_match_lens() compares, from an already-normalised name.
int ls_db_lens_fits_mount(ls_db_t *db, long long lens_id, long long mount_id)
Does a lens fit a camera's mount, upstream's compatibility table included?
int ls_db_lens_by_id(ls_db_t *db, long long lens_id, ls_lens_t *out)
Load a lens by its database id, for a caller that already resolved one.
int ls_db_mount_name(ls_db_t *db, long long mount_id, char *out, size_t out_size)
A mount's name.
int ls_db_lens_mounts(ls_db_t *db, long long lens_id, char *out, size_t out_size)
The mounts a lens is made for, joined with ", ".
int ls_db_lens_range(ls_db_t *db, long long lens_id, float *min_focal, float *max_focal, float *min_aperture, float *max_aperture)
The lens's focal and aperture range, for a picker that lists it.
int ls_db_schema_version(const ls_db_t *db)
Schema version of the open file, or -1. Bumped when the layout changes.
struct ls_camera_t ls_camera_t
int ls_db_lens_name(ls_db_t *db, long long lens_id, char *maker, size_t maker_size, char *model, size_t model_size)
The lens's maker/model, as stored.
int ls_db_camera_by_id(ls_db_t *db, long long camera_id, ls_camera_t *out)
Load a camera by its database id, for a caller that already resolved one.
size_t ls_db_token_digest(const char *norm, unsigned char *out, size_t out_size)
Pack a normalised name's tokens into the digest stored in lens_name.tokens.
unsigned ls_db_token_hash(const char *token)
FNV-1a of a token, the hash the stored digest and the matcher both use.
ls_db_t * ls_db_open(const char *path)
Open a database for reading.
int ls_db_find_camera(ls_db_t *db, const char *maker, const char *model, ls_camera_t *out)
Find a camera by maker and model.
int ls_db_camera_name(ls_db_t *db, long long camera_id, char *maker, size_t maker_size, char *model, size_t model_size, char *variant, size_t variant_size)
A camera's maker, model and variant, as stored.
size_t ls_db_normalize(const char *in, char *out, size_t out_size)
The comparison form of a name: ASCII case-folded, punctuation dropped, runs of whitespace collapsed t...
const char * ls_db_error(const ls_db_t *db)
The last error on db, as a string owned by db, or NULL.
long long mount_id
long long lens_id