Skip to content

Commit

Permalink
Change inline to static inline
Browse files Browse the repository at this point in the history
  • Loading branch information
drkoller authored and aurelienpierre committed Jul 1, 2021
1 parent 7375153 commit f0d8710
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 156 deletions.
4 changes: 2 additions & 2 deletions data/kernels/blendop.cl
Expand Up @@ -331,8 +331,8 @@ blendif_factor_rgb_hsl(const float4 input, const float4 output,
}


inline float4 rgb_to_JzCzhz(float4 rgb, constant dt_colorspaces_iccprofile_info_cl_t *profile_info,
read_only image2d_t profile_lut, const int use_work_profile)
static inline float4 rgb_to_JzCzhz(float4 rgb, constant dt_colorspaces_iccprofile_info_cl_t *profile_info,
read_only image2d_t profile_lut, const int use_work_profile)
{
float4 xyz = rgb;
if(use_work_profile != 0)
Expand Down
40 changes: 21 additions & 19 deletions data/kernels/channelmixer.cl
Expand Up @@ -43,17 +43,17 @@ typedef enum dt_adaptation_t
#define FALSE 0
#define NORM_MIN 1e-6f

inline float sqf(const float x)
static inline float sqf(const float x)
{
return x * x;
}

inline float euclidean_norm(const float4 input)
static inline float euclidean_norm(const float4 input)
{
return fmax(native_sqrt(sqf(input.x) + sqf(input.y) + sqf(input.z)), NORM_MIN);
}

inline float4 gamut_mapping(const float4 input, const float compression, const int clip)
static inline float4 gamut_mapping(const float4 input, const float compression, const int clip)
{
// Get the sum XYZ
float sum = input.x + input.y + input.z;
Expand Down Expand Up @@ -100,8 +100,8 @@ inline float4 gamut_mapping(const float4 input, const float compression, const i
return dt_xyY_to_XYZ(xyY);
}

inline float4 luma_chroma(const float4 input, const float4 saturation, const float4 lightness,
const dt_iop_channelmixer_rgb_version_t version)
static inline float4 luma_chroma(const float4 input, const float4 saturation, const float4 lightness,
const dt_iop_channelmixer_rgb_version_t version)
{
float4 output;

Expand Down Expand Up @@ -199,22 +199,23 @@ inline float4 luma_chroma(const float4 input, const float4 saturation, const flo
}})


inline void downscale_vector(float4 *const vector, const float scaling)
static inline void downscale_vector(float4 *const vector, const float scaling)
{
const int valid = (scaling > NORM_MIN) && !isnan(scaling);
*vector /= (valid) ? (scaling + NORM_MIN) : NORM_MIN;
}

inline void upscale_vector(float4 *const vector, const float scaling)
static inline void upscale_vector(float4 *const vector, const float scaling)
{
const int valid = (scaling > NORM_MIN) && !isnan(scaling);
*vector *= (valid) ? (scaling + NORM_MIN) : NORM_MIN;
}

inline float4 chroma_adapt_bradford(const float4 RGB,
constant const float *const RGB_to_XYZ,
constant const float *const MIX, const float4 illuminant, const float p,
const int full)
static inline float4 chroma_adapt_bradford(const float4 RGB,
constant const float *const RGB_to_XYZ,
constant const float *const MIX,
const float4 illuminant, const float p,
const int full)
{
// Convert from RGB to XYZ
const float4 XYZ = matrix_product_float4(RGB, RGB_to_XYZ);
Expand All @@ -234,10 +235,11 @@ inline float4 chroma_adapt_bradford(const float4 RGB,
return convert_bradford_LMS_to_XYZ(LMS_mixed);
};

inline float4 chroma_adapt_CAT16(const float4 RGB,
constant const float *const RGB_to_XYZ,
constant const float *const MIX, const float4 illuminant, const float p,
const int full)
static inline float4 chroma_adapt_CAT16(const float4 RGB,
constant const float *const RGB_to_XYZ,
constant const float *const MIX,
const float4 illuminant, const float p,
const int full)
{
// Convert from RGB to XYZ
const float4 XYZ = matrix_product_float4(RGB, RGB_to_XYZ);
Expand All @@ -257,9 +259,9 @@ inline float4 chroma_adapt_CAT16(const float4 RGB,
return convert_CAT16_LMS_to_XYZ(LMS_mixed);
}

inline float4 chroma_adapt_XYZ(const float4 RGB,
constant const float *const RGB_to_XYZ,
constant const float *const MIX, const float4 illuminant)
static inline float4 chroma_adapt_XYZ(const float4 RGB,
constant const float *const RGB_to_XYZ,
constant const float *const MIX, const float4 illuminant)
{
// Convert from RGB to XYZ
float4 XYZ_mixed = matrix_product_float4(RGB, RGB_to_XYZ);
Expand All @@ -274,7 +276,7 @@ inline float4 chroma_adapt_XYZ(const float4 RGB,
return matrix_product_float4(XYZ_mixed, MIX);
}

inline float4 chroma_adapt_RGB(const float4 RGB,
static inline float4 chroma_adapt_RGB(const float4 RGB,
constant const float *const RGB_to_XYZ,
constant const float *const MIX)
{
Expand Down
31 changes: 18 additions & 13 deletions data/kernels/color_conversion.h
Expand Up @@ -43,8 +43,9 @@ typedef struct dt_colorspaces_iccprofile_info_cl_t
float grey;
} dt_colorspaces_iccprofile_info_cl_t;

inline float lerp_lookup_unbounded(const float x, read_only image2d_t lut,
constant const float *const unbounded_coeffs, const int n_lut, const int lutsize)
static inline float lerp_lookup_unbounded(const float x, read_only image2d_t lut,
constant const float *const unbounded_coeffs,
const int n_lut, const int lutsize)
{
// in case the tone curve is marked as linear, return the fast
// path to linear unbounded (does not clip x at 1)
Expand All @@ -66,14 +67,14 @@ inline float lerp_lookup_unbounded(const float x, read_only image2d_t lut,
else return x;
}

inline float lookup(read_only image2d_t lut, const float x)
static inline float lookup(read_only image2d_t lut, const float x)
{
const int xi = clamp((int)(x * 0x10000ul), 0, 0xffff);
const int2 p = (int2)((xi & 0xff), (xi >> 8));
return read_imagef(lut, sampleri, p).x;
}

inline float lookup_unbounded(read_only image2d_t lut, const float x, constant const float *const a)
static inline float lookup_unbounded(read_only image2d_t lut, const float x, constant const float *const a)
{
// in case the tone curve is marked as linear, return the fast
// path to linear unbounded (does not clip x at 1)
Expand All @@ -90,8 +91,9 @@ inline float lookup_unbounded(read_only image2d_t lut, const float x, constant c
else return x;
}

inline float4 apply_trc_in(const float4 rgb_in, constant const dt_colorspaces_iccprofile_info_cl_t *const profile_info,
read_only image2d_t lut)
static inline float4 apply_trc_in(const float4 rgb_in,
constant const dt_colorspaces_iccprofile_info_cl_t *const profile_info,
read_only image2d_t lut)
{
const float R = lerp_lookup_unbounded(rgb_in.x, lut, profile_info->unbounded_coeffs_in[0], 0, profile_info->lutsize);
const float G = lerp_lookup_unbounded(rgb_in.y, lut, profile_info->unbounded_coeffs_in[1], 1, profile_info->lutsize);
Expand All @@ -100,8 +102,9 @@ inline float4 apply_trc_in(const float4 rgb_in, constant const dt_colorspaces_ic
return (float4)(R, G, B, a);
}

inline float4 apply_trc_out(const float4 rgb_in, constant const dt_colorspaces_iccprofile_info_cl_t *const profile_info,
read_only image2d_t lut)
static inline float4 apply_trc_out(const float4 rgb_in,
constant const dt_colorspaces_iccprofile_info_cl_t *const profile_info,
read_only image2d_t lut)
{
const float R = lerp_lookup_unbounded(rgb_in.x, lut, profile_info->unbounded_coeffs_out[0], 3, profile_info->lutsize);
const float G = lerp_lookup_unbounded(rgb_in.y, lut, profile_info->unbounded_coeffs_out[1], 4, profile_info->lutsize);
Expand All @@ -110,8 +113,9 @@ inline float4 apply_trc_out(const float4 rgb_in, constant const dt_colorspaces_i
return (float4)(R, G, B, a);
}

inline float get_rgb_matrix_luminance(const float4 rgb, constant const dt_colorspaces_iccprofile_info_cl_t *const profile_info,
constant const float *const matrix, read_only image2d_t lut)
static inline float get_rgb_matrix_luminance(const float4 rgb,
constant const dt_colorspaces_iccprofile_info_cl_t *const profile_info,
constant const float *const matrix, read_only image2d_t lut)
{
float luminance = 0.f;

Expand All @@ -128,8 +132,9 @@ inline float get_rgb_matrix_luminance(const float4 rgb, constant const dt_colors
return luminance;
}

inline float4 rgb_matrix_to_xyz(const float4 rgb, constant const dt_colorspaces_iccprofile_info_cl_t *const profile_info,
constant const float *const matrix, read_only image2d_t lut)
static inline float4 rgb_matrix_to_xyz(const float4 rgb,
constant const dt_colorspaces_iccprofile_info_cl_t *const profile_info,
constant const float *const matrix, read_only image2d_t lut)
{
float4 out;
if(profile_info->nonlinearlut)
Expand All @@ -144,7 +149,7 @@ inline float4 rgb_matrix_to_xyz(const float4 rgb, constant const dt_colorspaces_
return out;
}

inline float dt_camera_rgb_luminance(const float4 rgb)
static inline float dt_camera_rgb_luminance(const float4 rgb)
{
const float4 coeffs = { 0.2225045f, 0.7168786f, 0.0606169f, 0.0f };
return dot(rgb, coeffs);
Expand Down

0 comments on commit f0d8710

Please sign in to comment.