#include <stddef.h>
#include <math.h>
#include <stdint.h>
#include "common/darktable.h"
Go to the source code of this file.
|
| #define | NORM_MIN 1.52587890625e-05f |
| |
| #define | M_LN10 2.30258509299404568402 |
| |
| #define | M_PI 3.14159265358979323846 |
| |
| #define | M_PI_F 3.14159265358979324f |
| |
| #define | DT_M_PI_F (3.14159265358979324f) |
| |
| #define | DT_M_PI (3.14159265358979324) |
| |
| #define | DT_M_LN2f (0.6931471805599453f) |
| |
| #define | DT_FMA(x, y, z) ((x) * (y) + (z)) |
| |
| #define | PHI 1.61803398874989479F |
| |
| #define | INVPHI 0.61803398874989479F |
| |
| #define | CLAMPS(A, L, H) ((A) > (L) ? ((A) < (H) ? (A) : (H)) : (L)) |
| |
| #define | CLIP(x) (((x) >= 0) ? ((x) <= 1 ? (x) : 1) : 0) |
| |
| #define | MM_CLIP_PS(X) (_mm_min_ps(_mm_max_ps((X), _mm_setzero_ps()), _mm_set1_ps(1.0))) |
| |
| #define | LCLIP(x) ((x < 0) ? 0.0 : (x > 100.0) ? 100.0 : x) |
| |
| #define | CLAMPF(a, mn, mx) ((a) >= (mn) ? ((a) <= (mx) ? (a) : (mx)) : (mn)) |
| |
|
| static float | clamp_range_f (const float x, const float low, const float high) |
| |
| static float | Kahan_sum (const float m, float *const __restrict__ c, const float add) |
| |
| static float | Log2 (float x) |
| |
| static float | Log2Thres (float x, float Thres) |
| |
| static float | fastlog2 (float x) |
| |
| static float | fastlog (float x) |
| |
| static void | mat3mulv (float *const __restrict__ dest, const float *const mat, const float *const __restrict__ v) |
| |
| static void | mat3mul (float *const __restrict__ dest, const float *const __restrict__ m1, const float *const __restrict__ m2) |
| |
| static void | mul_mat_vec_2 (const float *m, const float *p, float *o) |
| |
| | __OMP_DECLARE_SIMD__ (uniform(v_2) aligned(v_1, v_2:16)) static inline float scalar_product(const dt_aligned_pixel_t v_1 |
| |
| | __OMP_SIMD__ (aligned(v_1, v_2:16) reduction(+:acc)) for(size_t c=0 |
| |
| static void | dt_fast_expf_4wide (const float x[4], float result[4]) |
| |
| static float | dt_fast_mexp2f (const float x) |
| |
| static float | fast_mexp2f (const float x) |
| |
| static float | ceil_fast (float x) |
| |
| static float | sinf_fast (float t) |
| |
| static int | ipow (int base, int exp) |
| | Fast integer power, computing base^exp.
|
| |
| static void | dt_vector_sin (const dt_aligned_pixel_t arg, dt_aligned_pixel_t sine) |
| |
| static float | f_inv_sqrtf (const float x) |
| |
|
| const dt_aligned_pixel_t | v_2 |
| |
| c< 3;c++) acc+=v_1[c] *v_2[c];return acc;}static inline float sqf(const float x){ return x *x;}static inline float euclidean_norm(const dt_aligned_pixel_t vector){ return fmaxf(sqrtf(sqf(vector[0])+sqf(vector[1])+sqf(vector[2])), 1.52587890625e-05f);}static inline void downscale_vector(dt_aligned_pixel_t vector, const float scaling){ const int valid=(scaling > 1.52587890625e-05f) &&!isnan(scaling);for(size_t c=0;c< 3;c++) vector[c]=(valid) ? vector[c]/(scaling+1.52587890625e-05f) :vector[c]/1.52587890625e-05f ;}static inline void upscale_vector(dt_aligned_pixel_t vector, const float scaling){ const int valid=(scaling > 1.52587890625e-05f) &&!isnan(scaling);for(size_t c=0;c< 3;c++) vector[c]=(valid) ? vector[c] *(scaling+1.52587890625e-05f) :vector[c] *1.52587890625e-05f ;}static inline float dt_log2f(const float f){ return logf(f)/logf(2.0f);}union float_int { float f;int k;};static inline float dt_fast_hypotf(const float x, const float y){ return sqrtf(x *x+y *y);}static inline float dt_fast_expf(const float x){ const int i1=0x3f800000u;const int i2=0x402DF854u;const int k0=i1+x *(i2 - i1);union float_int u;u.k=k0 > | k0 |
| |
| return u | f |
| |
◆ CLAMPF
| #define CLAMPF |
( |
|
a, |
|
|
|
mn, |
|
|
|
mx |
|
) |
| ((a) >= (mn) ? ((a) <= (mx) ? (a) : (mx)) : (mn)) |
◆ CLAMPS
| #define CLAMPS |
( |
|
A, |
|
|
|
L, |
|
|
|
H |
|
) |
| ((A) > (L) ? ((A) < (H) ? (A) : (H)) : (L)) |
◆ CLIP
| #define CLIP |
( |
|
x | ) |
(((x) >= 0) ? ((x) <= 1 ? (x) : 1) : 0) |
◆ DT_FMA
| #define DT_FMA |
( |
|
x, |
|
|
|
y, |
|
|
|
z |
|
) |
| ((x) * (y) + (z)) |
◆ DT_M_LN2f
| #define DT_M_LN2f (0.6931471805599453f) |
◆ DT_M_PI
| #define DT_M_PI (3.14159265358979324) |
◆ DT_M_PI_F
| #define DT_M_PI_F (3.14159265358979324f) |
◆ INVPHI
| #define INVPHI 0.61803398874989479F |
◆ LCLIP
| #define LCLIP |
( |
|
x | ) |
((x < 0) ? 0.0 : (x > 100.0) ? 100.0 : x) |
◆ M_LN10
| #define M_LN10 2.30258509299404568402 |
◆ M_PI
| #define M_PI 3.14159265358979323846 |
◆ M_PI_F
| #define M_PI_F 3.14159265358979324f |
◆ MM_CLIP_PS
| #define MM_CLIP_PS |
( |
|
X | ) |
(_mm_min_ps(_mm_max_ps((X), _mm_setzero_ps()), _mm_set1_ps(1.0))) |
◆ NORM_MIN
| #define NORM_MIN 1.52587890625e-05f |
◆ PHI
| #define PHI 1.61803398874989479F |
◆ __OMP_DECLARE_SIMD__()
| __OMP_DECLARE_SIMD__ |
( |
uniform(v_2) aligned(v_1, v_2:16) |
| ) |
const |
◆ __OMP_SIMD__()
| __OMP_SIMD__ |
( |
aligned(v_1, v_2:16) reduction(+:acc) |
| ) |
|
|
pure virtual |
◆ ceil_fast()
| static float ceil_fast |
( |
float |
x | ) |
|
|
inlinestatic |
◆ clamp_range_f()
| static float clamp_range_f |
( |
const float |
x, |
|
|
const float |
low, |
|
|
const float |
high |
|
) |
| |
|
inlinestatic |
◆ dt_fast_expf_4wide()
| static void dt_fast_expf_4wide |
( |
const float |
x[4], |
|
|
float |
result[4] |
|
) |
| |
|
inlinestatic |
◆ dt_fast_mexp2f()
| static float dt_fast_mexp2f |
( |
const float |
x | ) |
|
|
inlinestatic |
References f, i, k, k0, and x.
Referenced by gh().
◆ dt_vector_sin()
Compute approximate sines, four at a time. This function behaves correctly for the range [-pi pi] only. It has the following properties:
-
It has exact values for 0, pi/2, pi, -pi/2, -pi
-
It has matching derivatives to sine for these same points
-
Its relative error margin is <= 1% iirc
-
It computational cost is 5 mults + 3 adds + 2 abs
- Parameters
-
- Returns
- sine: guess what
References for_four_channels, M_PI_F, and p.
Referenced by _maketaps_lanczos().
◆ f_inv_sqrtf()
| static float f_inv_sqrtf |
( |
const float |
x | ) |
|
|
inlinestatic |
Fast inverse square root approximation, based on the famous Quake III algorithm, with a Newton-Raphson iteration for improved accuracy. approximation of 1/sqrtf() for x > 0.0f, with a maximum relative error of ~0.0005% at 1.0f
References f, i, and x.
Referenced by _dt_masks_find_best_attachment_point().
◆ fast_mexp2f()
| static float fast_mexp2f |
( |
const float |
x | ) |
|
|
inlinestatic |
◆ fastlog()
| static float fastlog |
( |
float |
x | ) |
|
|
inlinestatic |
◆ fastlog2()
| static float fastlog2 |
( |
float |
x | ) |
|
|
inlinestatic |
◆ ipow()
| static int ipow |
( |
int |
base, |
|
|
int |
exp |
|
) |
| |
|
inlinestatic |
◆ Kahan_sum()
| static float Kahan_sum |
( |
const float |
m, |
|
|
float *const __restrict__ |
c, |
|
|
const float |
add |
|
) |
| |
|
inlinestatic |
◆ Log2()
| static float Log2 |
( |
float |
x | ) |
|
|
inlinestatic |
◆ Log2Thres()
| static float Log2Thres |
( |
float |
x, |
|
|
float |
Thres |
|
) |
| |
|
inlinestatic |
◆ mat3mul()
| static void mat3mul |
( |
float *const __restrict__ |
dest, |
|
|
const float *const __restrict__ |
m1, |
|
|
const float *const __restrict__ |
m2 |
|
) |
| |
|
inlinestatic |
◆ mat3mulv()
| static void mat3mulv |
( |
float *const __restrict__ |
dest, |
|
|
const float *const |
mat, |
|
|
const float *const __restrict__ |
v |
|
) |
| |
|
inlinestatic |
References i, k, v, and x.
Referenced by crop_fitness(), distort_backtransform(), distort_mask(), distort_transform(), do_crop(), do_fit(), homography(), model_fitness(), modify_roi_in(), modify_roi_out(), nmsfit(), and process().
◆ mul_mat_vec_2()
| static void mul_mat_vec_2 |
( |
const float * |
m, |
|
|
const float * |
p, |
|
|
float * |
o |
|
) |
| |
|
inlinestatic |
◆ sinf_fast()
| static float sinf_fast |
( |
float |
t | ) |
|
|
inlinestatic |
Compute an approximate sine. This function behaves correctly for the range [-pi pi] only. It has the following properties:
-
It has exact values for 0, pi/2, pi, -pi/2, -pi
-
It has matching derivatives to sine for these same points
-
Its relative error margin is <= 1% iirc
-
It computational cost is 5 mults + 3 adds + 2 abs
- Parameters
-
- Returns
- guess what
References M_PI, M_PI_F, p, and t.
◆ k0
| c< 3; c++) acc += v_1[c] * v_2[c]; return acc;}static inline float sqf(const float x){ return x * x;}static inline float euclidean_norm(const dt_aligned_pixel_t vector){ return fmaxf(sqrtf(sqf(vector[0]) + sqf(vector[1]) + sqf(vector[2])), 1.52587890625e-05f );}static inline void downscale_vector(dt_aligned_pixel_t vector, const float scaling){ const int valid = (scaling > 1.52587890625e-05f ) && !isnan(scaling); for(size_t c = 0; c < 3; c++) vector[c] = (valid) ? vector[c] / (scaling + 1.52587890625e-05f ) : vector[c] / 1.52587890625e-05f ;}static inline void upscale_vector(dt_aligned_pixel_t vector, const float scaling){ const int valid = (scaling > 1.52587890625e-05f ) && !isnan(scaling); for(size_t c = 0; c < 3; c++) vector[c] = (valid) ? vector[c] * (scaling + 1.52587890625e-05f ) : vector[c] * 1.52587890625e-05f ;}static inline float dt_log2f(const float f){ return logf(f) / logf(2.0f);}union float_int { float f; int k;};static inline float dt_fast_hypotf(const float x, const float y){ return sqrtf(x * x + y * y);}static inline float dt_fast_expf(const float x){ const int i1 = 0x3f800000u; const int i2 = 0x402DF854u; const int k0 = i1 + x * (i2 - i1); union float_int u; u.k = k0 > k0 |
◆ v_2