30 # define C_TYPEDEF(t,c)
32 # define C_TYPEDEF(t,c) typedef t c c;
49 #define LF_VERSION_MAJOR 0
51 #define LF_VERSION_MINOR 3
53 #define LF_VERSION_MICRO 2
55 #define LF_VERSION_BUGFIX 0
57 #define LF_VERSION ((LF_VERSION_MAJOR << 24) | (LF_VERSION_MINOR << 16) | (LF_VERSION_MICRO << 8) | LF_VERSION_BUGFIX)
60 #define LF_MAX_DATABASE_VERSION 1
62 #if defined CONF_LENSFUN_STATIC
66 # ifdef CONF_SYMBOL_VISIBILITY
67 # if defined PLATFORM_WINDOWS
68 # define LF_EXPORT __declspec(dllexport)
69 # elif defined CONF_COMPILER_GCC || __clang__
70 # define LF_EXPORT __attribute__((visibility("default")))
72 # error "I don't know how to change symbol visibility for your compiler"
75 # if defined PLATFORM_WINDOWS || defined _MSC_VER
76 # define LF_EXPORT __declspec(dllimport)
83 #ifndef CONF_LENSFUN_INTERNAL
86 # define DEPRECATED __attribute__((deprecated))
87 # elif defined(_MSC_VER)
88 # define DEPRECATED __declspec(deprecated)
90 # pragma message("WARNING: You need to implement DEPRECATED for this compiler")
221 lfMount &operator = (
const lfMount &other);
238 void SetName (
const char *val,
const char *lang = NULL);
245 void AddCompat (
const char *val);
337 lfCamera (
const lfCamera &other);
347 lfCamera &operator = (
const lfCamera &other);
359 void SetMaker (
const char *val,
const char *lang = NULL);
371 void SetModel (
const char *val,
const char *lang = NULL);
383 void SetVariant (
const char *val,
const char *lang = NULL);
390 void SetMount (
const char *val);
853 lfLens (
const lfLens &other);
863 lfLens &operator = (
const lfLens &other);
875 void SetMaker (
const char *val,
const char *lang = NULL);
887 void SetModel (
const char *val,
const char *lang = NULL);
896 void AddMount (
const char *val);
913 bool RemoveCalibDistortion (
int idx);
931 bool RemoveCalibTCA (
int idx);
948 bool RemoveCalibVignetting (
int idx);
965 bool RemoveCalibCrop (
int idx);
1007 bool RemoveCalibRealFocal (
int idx);
1017 void GuessParameters ();
1041 static const char *GetDistortionModelDesc (
1058 static const char *GetTCAModelDesc (
1076 static const char *GetVignettingModelDesc (
1094 static const char *GetCropDesc (
1108 static const char *GetLensTypeDesc (
lfLensType type,
const char **details);
1141 bool InterpolateVignetting (
1390 bool LoadDirectory (
const char *dirname);
1413 lfError Load (
const char *filename);
1429 lfError Load (
const char *errcontext,
const char *data,
size_t data_size);
1438 lfError Save (
const char *filename)
const;
1453 lfError Save (
const char *filename,
1456 const lfLens *
const *lenses)
const;
1470 static char *Save (
const lfMount *
const *mounts,
1472 const lfLens *
const *lenses);
1498 const lfCamera **FindCameras (
const char *maker,
const char *model)
const;
1520 const lfCamera **FindCamerasExt (
const char *maker,
const char *model,
1521 int sflags = 0)
const;
1530 const lfCamera *
const *GetCameras ()
const;
1569 const lfLens **FindLenses (
const lfCamera *camera,
const char *maker,
1570 const char *model,
int sflags = 0)
const;
1589 const lfLens **FindLenses (
const lfLens *lens,
int sflags = 0)
const;
1598 const lfLens *
const *GetLenses ()
const;
1607 const lfMount *FindMount (
const char *mount)
const;
1616 const char *MountName (
const char *mount)
const;
1625 const lfMount *
const *GetMounts ()
const;
1632 void AddMount (
lfMount *mount);
1646 void AddLens (
lfLens *lens);
1688 const
char *data,
size_t data_size);
1697 const
lfLens *const *lenses);
1702 const
lfLens *const *lenses);
1706 const
lfDatabase *db, const
char *maker, const
char *model);
1710 const
lfDatabase *db, const
char *maker, const
char *model,
int sflags);
1718 const
char *lens,
int sflags);
1814 #define LF_CR_1(a) (LF_CR_ ## a)
1816 #define LF_CR_2(a,b) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4))
1818 #define LF_CR_3(a,b,c) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1819 ((LF_CR_ ## c) << 8))
1821 #define LF_CR_4(a,b,c,d) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1822 ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12))
1824 #define LF_CR_5(a,b,c,d,e) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1825 ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1826 ((LF_CR_ ## e) << 16))
1828 #define LF_CR_6(a,b,c,d,e,f) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1829 ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1830 ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20))
1832 #define LF_CR_7(a,b,c,d,e,f,g) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1833 ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1834 ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
1835 ((LF_CR_ ## g) << 24))
1837 #define LF_CR_8(a,b,c,d,e,f,g,h) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1838 ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1839 ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
1840 ((LF_CR_ ## g) << 24) | ((LF_CR_ ## h) << 28))
1884 void *pixels,
int comp_role,
int count);
1903 struct lfCallbackData
1911 typedef struct {
float angle, dist; } lfPoint;
2048 static lfModifier *Create (
const lfLens *lens,
float crop,
int width,
int height);
2097 float distance,
float scale,
lfLensType targeom,
int flags,
bool reverse);
2123 void *data,
size_t data_size);
2143 void *data,
size_t data_size);
2162 void *data,
size_t data_size);
2178 bool AddSubpixelCallbackTCA (
lfLensCalibTCA &model,
bool reverse =
false);
2195 bool reverse =
false);
2244 bool AddCoordCallbackScale (
float scale,
bool reverse =
false);
2259 float GetAutoScale (
bool reverse);
2290 bool ApplyColorModification (
void *pixels,
float x,
float y,
int width,
int height,
2291 int comp_role,
int row_stride)
const;
2323 bool ApplyGeometryDistortion (
float xu,
float yu,
int width,
int height,
2357 bool ApplySubpixelDistortion (
float xu,
float yu,
int width,
int height,
2390 bool ApplySubpixelGeometryDistortion (
float xu,
float yu,
int width,
int height,
2424 float GetRealFocalLength (
const lfLens *lens,
float focal);
2426 void AddCallback (
void *arr, lfCallbackData *d,
2427 int priority,
void *data,
size_t data_size);
2442 double AutoscaleResidualDistance (
float *coord)
const;
2457 float GetTransformedDistance (lfPoint point)
const;
2459 static void ModifyCoord_UnTCA_Linear (
void *data,
float *iocoord,
int count);
2460 static void ModifyCoord_TCA_Linear (
void *data,
float *iocoord,
int count);
2461 static void ModifyCoord_UnTCA_Poly3 (
void *data,
float *iocoord,
int count);
2462 static void ModifyCoord_TCA_Poly3 (
void *data,
float *iocoord,
int count);
2464 static void ModifyCoord_UnDist_Poly3 (
void *data,
float *iocoord,
int count);
2465 static void ModifyCoord_Dist_Poly3 (
void *data,
float *iocoord,
int count);
2466 #ifdef VECTORIZATION_SSE
2467 static void ModifyCoord_Dist_Poly3_SSE (
void *data,
float *iocoord,
int count);
2469 static void ModifyCoord_UnDist_Poly5 (
void *data,
float *iocoord,
int count);
2470 static void ModifyCoord_Dist_Poly5 (
void *data,
float *iocoord,
int count);
2471 static void ModifyCoord_UnDist_PTLens (
void *data,
float *iocoord,
int count);
2472 static void ModifyCoord_Dist_PTLens (
void *data,
float *iocoord,
int count);
2473 #ifdef VECTORIZATION_SSE
2474 static void ModifyCoord_UnDist_PTLens_SSE (
void *data,
float *iocoord,
int count);
2475 static void ModifyCoord_Dist_PTLens_SSE (
void *data,
float *iocoord,
int count);
2477 static void ModifyCoord_Geom_FishEye_Rect (
void *data,
float *iocoord,
int count);
2478 static void ModifyCoord_Geom_Panoramic_Rect (
void *data,
float *iocoord,
int count);
2479 static void ModifyCoord_Geom_ERect_Rect (
void *data,
float *iocoord,
int count);
2480 static void ModifyCoord_Geom_Rect_FishEye (
void *data,
float *iocoord,
int count);
2481 static void ModifyCoord_Geom_Panoramic_FishEye (
void *data,
float *iocoord,
int count);
2482 static void ModifyCoord_Geom_ERect_FishEye (
void *data,
float *iocoord,
int count);
2483 static void ModifyCoord_Geom_Rect_Panoramic (
void *data,
float *iocoord,
int count);
2484 static void ModifyCoord_Geom_FishEye_Panoramic (
void *data,
float *iocoord,
int count);
2485 static void ModifyCoord_Geom_ERect_Panoramic (
void *data,
float *iocoord,
int count);
2486 static void ModifyCoord_Geom_Rect_ERect (
void *data,
float *iocoord,
int count);
2487 static void ModifyCoord_Geom_FishEye_ERect (
void *data,
float *iocoord,
int count);
2488 static void ModifyCoord_Geom_Panoramic_ERect (
void *data,
float *iocoord,
int count);
2489 static void ModifyCoord_Geom_Orthographic_ERect (
void *data,
float *iocoord,
int count);
2490 static void ModifyCoord_Geom_ERect_Orthographic (
void *data,
float *iocoord,
int count);
2491 static void ModifyCoord_Geom_Stereographic_ERect (
void *data,
float *iocoord,
int count);
2492 static void ModifyCoord_Geom_ERect_Stereographic (
void *data,
float *iocoord,
int count);
2493 static void ModifyCoord_Geom_Equisolid_ERect (
void *data,
float *iocoord,
int count);
2494 static void ModifyCoord_Geom_ERect_Equisolid (
void *data,
float *iocoord,
int count);
2495 static void ModifyCoord_Geom_Thoby_ERect (
void *data,
float *iocoord,
int count);
2496 static void ModifyCoord_Geom_ERect_Thoby (
void *data,
float *iocoord,
int count);
2497 #ifdef VECTORIZATION_SSE
2498 static void ModifyColor_DeVignetting_PA_SSE (
2499 void *data,
float _x,
float _y,
lf_f32 *pixels,
int comp_role,
int count);
2501 #ifdef VECTORIZATION_SSE2
2502 static void ModifyColor_DeVignetting_PA_SSE2 (
2503 void *data,
float _x,
float _y,
lf_u16 *pixels,
int comp_role,
int count);
2506 template<
typename T>
static void ModifyColor_Vignetting_PA (
2507 void *data,
float x,
float y, T *rgb,
int comp_role,
int count);
2508 template<
typename T>
static void ModifyColor_DeVignetting_PA (
2509 void *data,
float x,
float y, T *rgb,
int comp_role,
int count);
2511 static void ModifyCoord_Scale (
void *data,
float *iocoord,
int count);
2516 double CenterX, CenterY;
2518 double NormScale, NormUnScale;
2521 double NormalizedInMillimeters;
2524 double AspectRatioCorrection;
2527 void *SubpixelCallbacks;
2529 void *ColorCallbacks;
2531 void *CoordCallbacks;
2545 const
lfLens *lens,
float crop,
int width,
int height);
2553 float focal,
float aperture,
float distance,
float scale,
2559 void *data,
size_t data_size);
2564 void *data,
size_t data_size);
2569 void *data,
size_t data_size);
2598 lfModifier *modifier,
float xu,
float yu,
int width,
int height,
float *res);
2602 lfModifier *modifier,
void *pixels,
float x,
float y,
int width,
int height,
2603 int comp_role,
int row_stride);
2607 lfModifier *modifier,
float xu,
float yu,
int width,
int height,
float *res);
2611 lfModifier *modifier,
float xu,
float yu,
int width,
int height,
float *res);