Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
colorspaces.c File Reference
#include "common/colorspaces.h"
#include "common/colormatrices.c"
#include "common/darktable.h"
#include "common/debug.h"
#include "common/image_cache.h"
#include "common/file_location.h"
#include "common/math.h"
#include "common/matrices.h"
#include "common/srgb_tone_curve_values.h"
#include "common/utility.h"
#include "control/conf.h"
#include "control/control.h"
#include "develop/imageop.h"
#include <strings.h>
#include "common/imageio_jpeg.h"
#include "common/imageio_png.h"
#include "common/imageio_tiff.h"
+ Include dependency graph for colorspaces.c:

Macros

#define generate_mat3inv_body(c_type, A, B)
 
#define A(y, x)   src[(y - 1) * 3 + (x - 1)]
 
#define B(y, x)   dst[(y - 1) * 3 + (x - 1)]
 

Functions

static dt_colorspaces_color_profile_t_create_profile (dt_colorspaces_color_profile_type_t type, cmsHPROFILE profile, const char *name, int in_pos, int out_pos, int display_pos, int category_pos, int work_pos)
 
int mat3inv_float (float *const dst, const float *const src)
 
int mat3inv (float *const dst, const float *const src)
 
int mat3inv_double (double *const dst, const double *const src)
 
static const dt_colorspaces_color_profile_t_get_profile (dt_colorspaces_t *self, dt_colorspaces_color_profile_type_t type, const char *filename, dt_colorspaces_profile_direction_t direction)
 
static int dt_colorspaces_get_matrix_from_profile (cmsHPROFILE prof, dt_colormatrix_t matrix, float *lutr, float *lutg, float *lutb, const int lutsize, const int input)
 
int dt_colorspaces_get_matrix_from_input_profile (cmsHPROFILE prof, dt_colormatrix_t matrix, float *lutr, float *lutg, float *lutb, const int lutsize)
 
int dt_colorspaces_get_matrix_from_output_profile (cmsHPROFILE prof, dt_colormatrix_t matrix, float *lutr, float *lutg, float *lutb, const int lutsize)
 
static cmsHPROFILE dt_colorspaces_create_lab_profile ()
 
static void _compute_prequantized_primaries (const cmsCIExyY *whitepoint, const cmsCIExyYTRIPLE *primaries, cmsCIEXYZTRIPLE *primaries_prequantized)
 
static cmsHPROFILE _create_lcms_profile (const char *desc, const char *dmdd, const cmsCIExyY *whitepoint, const cmsCIExyYTRIPLE *primaries, cmsToneCurve *trc, gboolean v2)
 
static double _PQ_fct (double x)
 
static double _HLG_fct (double x)
 
static cmsToneCurve * _colorspaces_create_transfer (int32_t size, double(*fct)(double))
 
static cmsHPROFILE _colorspaces_create_srgb_profile (gboolean v2)
 
static cmsHPROFILE dt_colorspaces_create_srgb_profile ()
 
static cmsHPROFILE dt_colorspaces_create_srgb_profile_v4 ()
 
static cmsHPROFILE dt_colorspaces_create_brg_profile ()
 
static cmsHPROFILE dt_colorspaces_create_gamma_rec709_rgb_profile (void)
 
static cmsHPROFILE dt_colorspaces_create_itur_bt1886_rgb_profile (void)
 
static cmsHPROFILE dt_colorspaces_create_adobergb_profile (void)
 
cmsHPROFILE dt_colorspaces_create_alternate_profile (const char *makermodel)
 
cmsHPROFILE dt_colorspaces_create_vendor_profile (const char *makermodel)
 
cmsHPROFILE dt_colorspaces_create_darktable_profile (const char *makermodel)
 
static cmsHPROFILE dt_colorspaces_create_xyz_profile (void)
 
static cmsHPROFILE dt_colorspaces_create_linear_rec709_rgb_profile (void)
 
static cmsHPROFILE dt_colorspaces_create_linear_rec2020_rgb_profile (void)
 
static cmsHPROFILE dt_colorspaces_create_pq_rec2020_rgb_profile (void)
 
static cmsHPROFILE dt_colorspaces_create_hlg_rec2020_rgb_profile (void)
 
static cmsHPROFILE dt_colorspaces_create_pq_p3_rgb_profile (void)
 
static cmsHPROFILE dt_colorspaces_create_hlg_p3_rgb_profile (void)
 
static cmsHPROFILE dt_colorspaces_create_display_p3_rgb_profile (void)
 
static cmsHPROFILE dt_colorspaces_create_linear_prophoto_rgb_profile (void)
 
static cmsHPROFILE dt_colorspaces_create_linear_infrared_profile (void)
 
const dt_colorspaces_color_profile_tdt_colorspaces_get_work_profile (const int32_t imgid)
 
dt_colorspaces_color_profile_type_t dt_image_find_best_color_profile (int32_t imgid, cmsHPROFILE *output, gboolean *new_profile)
 Best effort to find a suitable (input) color profile for a given image, using embedded ICC or EXIF whenever possible. This will also init the profile in the image cache.
 
const cmsHPROFILE dt_colorspaces_get_embedded_profile (const int32_t imgid, dt_colorspaces_color_profile_type_t *type, gboolean *new_profile)
 
const dt_colorspaces_color_profile_t_build_embedded_profile (const int32_t imgid, dt_colorspaces_color_profile_type_t *type)
 
const dt_colorspaces_color_profile_tdt_colorspaces_get_output_profile (const int32_t imgid, dt_colorspaces_color_profile_type_t *over_type, const char *over_filename)
 
static cmsHPROFILE dt_colorspaces_create_xyzmatrix_profile (const float mat[3][3])
 
cmsHPROFILE dt_colorspaces_create_xyzimatrix_profile (float mat[3][3])
 
static cmsHPROFILE _ensure_rgb_profile (cmsHPROFILE profile)
 
cmsHPROFILE dt_colorspaces_get_rgb_profile_from_mem (uint8_t *data, uint32_t size)
 
void dt_colorspaces_cleanup_profile (cmsHPROFILE p)
 
void dt_colorspaces_get_profile_name (cmsHPROFILE p, const char *language, const char *country, char *name, size_t len)
 
void rgb2hsl (const dt_aligned_pixel_t rgb, float *h, float *s, float *l)
 
static float hue2rgb (float m1, float m2, float hue)
 
void hsl2rgb (dt_aligned_pixel_t rgb, float h, float s, float l)
 
static void _update_display_transforms (dt_colorspaces_t *self)
 
void dt_colorspaces_update_display_transforms ()
 
static void _update_display_profile (guchar *tmp_data, gsize size, char *name, size_t name_size)
 
static void cms_error_handler (cmsContext ContextID, cmsUInt32Number ErrorCode, const char *text)
 
static gint _sort_profiles (gconstpointer a, gconstpointer b)
 
static GList * load_profile_from_dir (const char *subdir)
 
dt_colorspaces_tdt_colorspaces_init ()
 
void dt_colorspaces_cleanup (dt_colorspaces_t *self)
 
const char * dt_colorspaces_get_name (dt_colorspaces_color_profile_type_t type, const char *filename)
 
void dt_colorspaces_set_display_profile (const dt_colorspaces_color_profile_type_t profile_type)
 
static gboolean _colorspaces_is_base_name (const char *profile)
 
static const char * _colorspaces_get_base_name (const char *profile)
 
gboolean dt_colorspaces_is_profile_equal (const char *fullname, const char *filename)
 
dt_colorspaces_color_profile_type_t dt_colorspaces_cicp_to_type (const dt_colorspaces_cicp_t *cicp, const char *filename)
 
const dt_colorspaces_color_profile_tdt_colorspaces_get_profile (dt_colorspaces_color_profile_type_t type, const char *filename, dt_colorspaces_profile_direction_t direction)
 
static void dt_colorspaces_pseudoinverse (double(*in)[3], double(*out)[3], int size)
 
int dt_colorspaces_conversion_matrices_xyz (const float adobe_XYZ_to_CAM[4][3], float in_XYZ_to_CAM[9], double XYZ_to_CAM[4][3], double CAM_to_XYZ[3][4])
 
int dt_colorspaces_conversion_matrices_rgb (const float adobe_XYZ_to_CAM[4][3], double out_RGB_to_CAM[4][3], double out_CAM_to_RGB[3][4], const float *embedded_matrix, double mul[4])
 
void dt_colorspaces_cygm_apply_coeffs_to_rgb (float *out, const float *in, int num, double RGB_to_CAM[4][3], double CAM_to_RGB[3][4], dt_aligned_pixel_t coeffs)
 
void dt_colorspaces_cygm_to_rgb (float *out, int num, double CAM_to_RGB[3][4])
 
void dt_colorspaces_rgb_to_cygm (float *out, int num, double RGB_to_CAM[4][3])
 

Variables

static const cmsCIEXYZ d65 = {0.95045471, 1.00000000, 1.08905029}
 
static const cmsCIExyY D65xyY = {0.312700492, 0.329000939, 1.0}
 
static const cmsCIExyY D50xyY = {0.3457, 0.3585, 1.0}
 
static const cmsCIExyYTRIPLE sRGB_Primaries
 
static const cmsCIExyYTRIPLE Rec2020_Primaries
 
static const cmsCIExyYTRIPLE Rec709_Primaries
 
static const cmsCIExyYTRIPLE Adobe_Primaries
 
static const cmsCIExyYTRIPLE P3_Primaries
 
static const cmsCIExyYTRIPLE ProPhoto_Primaries
 
cmsCIEXYZTRIPLE Rec709_Primaries_Prequantized
 

Macro Definition Documentation

◆ A

#define A (   y,
 
)    src[(y - 1) * 3 + (x - 1)]

◆ B

#define B (   y,
 
)    dst[(y - 1) * 3 + (x - 1)]

◆ generate_mat3inv_body

#define generate_mat3inv_body (   c_type,
  A,
  B 
)
Value:
int mat3inv_##c_type(c_type *const dst, const c_type *const src) \
{ \
\
const c_type det = A(1, 1) * (A(3, 3) * A(2, 2) - A(3, 2) * A(2, 3)) \
- A(2, 1) * (A(3, 3) * A(1, 2) - A(3, 2) * A(1, 3)) \
+ A(3, 1) * (A(2, 3) * A(1, 2) - A(2, 2) * A(1, 3)); \
\
const c_type epsilon = 1e-7f; \
if(fabs(det) < epsilon) return 1; \
\
const c_type invDet = 1.0 / det; \
\
B(1, 1) = invDet * (A(3, 3) * A(2, 2) - A(3, 2) * A(2, 3)); \
B(1, 2) = -invDet * (A(3, 3) * A(1, 2) - A(3, 2) * A(1, 3)); \
B(1, 3) = invDet * (A(2, 3) * A(1, 2) - A(2, 2) * A(1, 3)); \
\
B(2, 1) = -invDet * (A(3, 3) * A(2, 1) - A(3, 1) * A(2, 3)); \
B(2, 2) = invDet * (A(3, 3) * A(1, 1) - A(3, 1) * A(1, 3)); \
B(2, 3) = -invDet * (A(2, 3) * A(1, 1) - A(2, 1) * A(1, 3)); \
\
B(3, 1) = invDet * (A(3, 2) * A(2, 1) - A(3, 1) * A(2, 2)); \
B(3, 2) = -invDet * (A(3, 2) * A(1, 1) - A(3, 1) * A(1, 2)); \
B(3, 3) = invDet * (A(2, 2) * A(1, 1) - A(2, 1) * A(1, 2)); \
return 0; \
}
#define A(y, x)
Definition colorspaces.c:148

Function Documentation

◆ _build_embedded_profile()

◆ _colorspaces_create_srgb_profile()

static cmsHPROFILE _colorspaces_create_srgb_profile ( gboolean  v2)
static

◆ _colorspaces_create_transfer()

static cmsToneCurve * _colorspaces_create_transfer ( int32_t  size,
double(*)(double fct 
)
static

◆ _colorspaces_get_base_name()

static const char * _colorspaces_get_base_name ( const char *  profile)
static

References f().

Referenced by dt_colorspaces_is_profile_equal().

◆ _colorspaces_is_base_name()

static gboolean _colorspaces_is_base_name ( const char *  profile)
static

References f(), FALSE, and TRUE.

Referenced by dt_colorspaces_is_profile_equal().

◆ _compute_prequantized_primaries()

static void _compute_prequantized_primaries ( const cmsCIExyY *  whitepoint,
const cmsCIExyYTRIPLE *  primaries,
cmsCIEXYZTRIPLE *  primaries_prequantized 
)
static

References B, double(), and R.

Referenced by dt_colorspaces_init().

◆ _create_lcms_profile()

◆ _create_profile()

◆ _ensure_rgb_profile()

static cmsHPROFILE _ensure_rgb_profile ( cmsHPROFILE  profile)
static
Todo:
: we still use prequantized primaries here, we will probably want to rework this

References Rec709_Primaries_Prequantized.

Referenced by dt_colorspaces_get_rgb_profile_from_mem(), and load_profile_from_dir().

◆ _get_profile()

◆ _HLG_fct()

static double _HLG_fct ( double  x)
static

◆ _PQ_fct()

static double _PQ_fct ( double  x)
static

◆ _sort_profiles()

static gint _sort_profiles ( gconstpointer  a,
gconstpointer  b 
)
static

◆ _update_display_profile()

◆ _update_display_transforms()

◆ cms_error_handler()

static void cms_error_handler ( cmsContext  ContextID,
cmsUInt32Number  ErrorCode,
const char *  text 
)
static

Referenced by dt_colorspaces_init().

◆ dt_colorspaces_cicp_to_type()

◆ dt_colorspaces_cleanup()

◆ dt_colorspaces_cleanup_profile()

void dt_colorspaces_cleanup_profile ( cmsHPROFILE  p)

free the resources of a profile created with the functions above.

Referenced by _update_display_profile(), cleanup_pipe(), commit_params(), and dt_colorspaces_cleanup().

◆ dt_colorspaces_conversion_matrices_rgb()

int dt_colorspaces_conversion_matrices_rgb ( const float  adobe_XYZ_to_CAM[4][3],
double  RGB_to_CAM[4][3],
double  CAM_to_RGB[3][4],
const float *  embedded_matrix,
double  mul[4] 
)

Calculate CAM->RGB, RGB->CAM matrices and default WB multipliers

References dt_colorspaces_pseudoinverse(), FALSE, and TRUE.

Referenced by calculate_bogus_daylight_wb(), commit_params(), get_white_balance_coeff(), legacy_params(), and reload_defaults().

◆ dt_colorspaces_conversion_matrices_xyz()

int dt_colorspaces_conversion_matrices_xyz ( const float  adobe_XYZ_to_CAM[4][3],
float  in_XYZ_to_CAM[9],
double  XYZ_to_CAM[4][3],
double  CAM_to_XYZ[3][4] 
)

Calculate CAM->XYZ, XYZ->CAM matrices

References dt_colorspaces_pseudoinverse(), FALSE, and TRUE.

Referenced by prepare_matrices().

◆ dt_colorspaces_create_adobergb_profile()

static cmsHPROFILE dt_colorspaces_create_adobergb_profile ( void  )
static

◆ dt_colorspaces_create_alternate_profile()

cmsHPROFILE dt_colorspaces_create_alternate_profile ( const char *  makermodel)

create a ICC virtual profile from the shipped alternate matrices in darktable.

References dt_alternate_colormatrices, dt_alternate_colormatrix_cnt, name, and preset.

Referenced by commit_params().

◆ dt_colorspaces_create_brg_profile()

static cmsHPROFILE dt_colorspaces_create_brg_profile ( )
static

◆ dt_colorspaces_create_darktable_profile()

cmsHPROFILE dt_colorspaces_create_darktable_profile ( const char *  makermodel)

create a ICC virtual profile from the shipped presets in darktable.

References dt_profiled_colormatrices, dt_profiled_colormatrix_cnt, name, and preset.

Referenced by commit_params().

◆ dt_colorspaces_create_display_p3_rgb_profile()

static cmsHPROFILE dt_colorspaces_create_display_p3_rgb_profile ( void  )
static

◆ dt_colorspaces_create_gamma_rec709_rgb_profile()

static cmsHPROFILE dt_colorspaces_create_gamma_rec709_rgb_profile ( void  )
static

◆ dt_colorspaces_create_hlg_p3_rgb_profile()

static cmsHPROFILE dt_colorspaces_create_hlg_p3_rgb_profile ( void  )
static

◆ dt_colorspaces_create_hlg_rec2020_rgb_profile()

static cmsHPROFILE dt_colorspaces_create_hlg_rec2020_rgb_profile ( void  )
static

◆ dt_colorspaces_create_itur_bt1886_rgb_profile()

static cmsHPROFILE dt_colorspaces_create_itur_bt1886_rgb_profile ( void  )
static

◆ dt_colorspaces_create_lab_profile()

static cmsHPROFILE dt_colorspaces_create_lab_profile ( )
static

Referenced by dt_colorspaces_init().

◆ dt_colorspaces_create_linear_infrared_profile()

static cmsHPROFILE dt_colorspaces_create_linear_infrared_profile ( void  )
static

◆ dt_colorspaces_create_linear_prophoto_rgb_profile()

static cmsHPROFILE dt_colorspaces_create_linear_prophoto_rgb_profile ( void  )
static

◆ dt_colorspaces_create_linear_rec2020_rgb_profile()

static cmsHPROFILE dt_colorspaces_create_linear_rec2020_rgb_profile ( void  )
static

◆ dt_colorspaces_create_linear_rec709_rgb_profile()

static cmsHPROFILE dt_colorspaces_create_linear_rec709_rgb_profile ( void  )
static

◆ dt_colorspaces_create_pq_p3_rgb_profile()

static cmsHPROFILE dt_colorspaces_create_pq_p3_rgb_profile ( void  )
static

◆ dt_colorspaces_create_pq_rec2020_rgb_profile()

static cmsHPROFILE dt_colorspaces_create_pq_rec2020_rgb_profile ( void  )
static

◆ dt_colorspaces_create_srgb_profile()

static cmsHPROFILE dt_colorspaces_create_srgb_profile ( )
static

◆ dt_colorspaces_create_srgb_profile_v4()

static cmsHPROFILE dt_colorspaces_create_srgb_profile_v4 ( )
static

◆ dt_colorspaces_create_vendor_profile()

cmsHPROFILE dt_colorspaces_create_vendor_profile ( const char *  makermodel)

create a ICC virtual profile from the shipped vendor matrices in darktable.

References dt_vendor_colormatrices, dt_vendor_colormatrix_cnt, name, and preset.

Referenced by commit_params().

◆ dt_colorspaces_create_xyz_profile()

static cmsHPROFILE dt_colorspaces_create_xyz_profile ( void  )
static

Referenced by dt_colorspaces_init().

◆ dt_colorspaces_create_xyzimatrix_profile()

cmsHPROFILE dt_colorspaces_create_xyzimatrix_profile ( float  cam_xyz[3][3])

create a profile from a xyz->camera matrix.

References dt_colorspaces_create_xyzmatrix_profile(), and mat3inv().

Referenced by commit_params(), and dt_image_find_best_color_profile().

◆ dt_colorspaces_create_xyzmatrix_profile()

static cmsHPROFILE dt_colorspaces_create_xyzmatrix_profile ( const float  mat[3][3])
static

References d65.

Referenced by dt_colorspaces_create_xyzimatrix_profile().

◆ dt_colorspaces_cygm_apply_coeffs_to_rgb()

void dt_colorspaces_cygm_apply_coeffs_to_rgb ( float *  out,
const float *  in,
int  num,
double  RGB_to_CAM[4][3],
double  CAM_to_RGB[3][4],
dt_aligned_pixel_t  coeffs 
)

Applies CYGM WB coeffs to an image that's already been converted to RGB by dt_colorspaces_cygm_to_rgb

Todo:
: CRITICAL: why is this function NOT used anywhere ???

◆ dt_colorspaces_cygm_to_rgb()

void dt_colorspaces_cygm_to_rgb ( float *  out,
int  num,
double  CAM_to_RGB[3][4] 
)

convert CYGM buffer to RGB

Referenced by gui_update_from_coeffs(), and process().

◆ dt_colorspaces_get_embedded_profile()

const cmsHPROFILE dt_colorspaces_get_embedded_profile ( const int32_t  imgid,
dt_colorspaces_color_profile_type_t type,
gboolean *  new_profile 
)

return the embedded profile of a particular image

References dt_image_find_best_color_profile(), and type.

Referenced by _build_embedded_profile(), and commit_params().

◆ dt_colorspaces_get_matrix_from_input_profile()

int dt_colorspaces_get_matrix_from_input_profile ( cmsHPROFILE  prof,
dt_colormatrix_t  matrix,
float *  lutr,
float *  lutg,
float *  lutb,
const int  lutsize 
)

extracts tonecurves and color matrix prof to XYZ from a given input profile, returns 0 on success (curves and matrix are inverted for input)

References dt_colorspaces_get_matrix_from_profile().

Referenced by commit_params(), dt_colorspaces_init(), and dt_ioppr_generate_profile_info().

◆ dt_colorspaces_get_matrix_from_output_profile()

int dt_colorspaces_get_matrix_from_output_profile ( cmsHPROFILE  prof,
dt_colormatrix_t  matrix,
float *  lutr,
float *  lutg,
float *  lutb,
const int  lutsize 
)

extracts tonecurves and color matrix prof to XYZ from a given output profile, returns 0 on success.

References dt_colorspaces_get_matrix_from_profile().

Referenced by commit_params(), dt_colorspaces_init(), and dt_ioppr_generate_profile_info().

◆ dt_colorspaces_get_matrix_from_profile()

static int dt_colorspaces_get_matrix_from_profile ( cmsHPROFILE  prof,
dt_colormatrix_t  matrix,
float *  lutr,
float *  lutg,
float *  lutb,
const int  lutsize,
const int  input 
)
static

◆ dt_colorspaces_get_name()

◆ dt_colorspaces_get_output_profile()

◆ dt_colorspaces_get_profile()

◆ dt_colorspaces_get_profile_name()

void dt_colorspaces_get_profile_name ( cmsHPROFILE  p,
const char *  language,
const char *  country,
char *  name,
size_t  len 
)

wrapper to get the name from a color profile. this tries to handle character encodings.

References error(), name, and size.

Referenced by _build_embedded_profile(), _update_display_profile(), load_profile_from_dir(), and write_image().

◆ dt_colorspaces_get_rgb_profile_from_mem()

cmsHPROFILE dt_colorspaces_get_rgb_profile_from_mem ( uint8_t *  data,
uint32_t  size 
)

return an rgb lcms2 profile from data. if data points to a grayscale profile a new rgb profile is created that has the same TRC, black and white point and rec709 primaries.

References _ensure_rgb_profile(), and size.

Referenced by commit_params(), and dt_image_find_best_color_profile().

◆ dt_colorspaces_get_work_profile()

const dt_colorspaces_color_profile_t * dt_colorspaces_get_work_profile ( const int32_t  imgid)

return the work profile as set in colorin

Todo:
: does this work when using JPEG thumbs and the image was never opened?

References darktable, darktable_t::db, DT_COLORSPACE_LIN_REC2020, dt_colorspaces_get_profile(), dt_database_get(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, DT_PROFILE_DIRECTION_WORK, darktable_t::iop, and type.

◆ dt_colorspaces_init()

dt_colorspaces_t * dt_colorspaces_init ( )

populate the global color profile lists

Todo:
: what about display?
Todo:
: do want to filter out non-RGB profiles for cases besides histogram profile? colorin is OK with RGB or XYZ, print is OK with anything which LCMS likes, otherwise things are more choosey

References _compute_prequantized_primaries(), _create_profile(), _update_display_transforms(), dt_colorspaces_color_profile_t::category_pos, cms_error_handler(), color_space, D65xyY, dt_colorspaces_t::display_filename, dt_colorspaces_t::display_intent, dt_colorspaces_color_profile_t::display_pos, dt_colorspaces_t::display_type, DT_COLORSPACE_ADOBERGB, DT_COLORSPACE_BRG, DT_COLORSPACE_DISPLAY, DT_COLORSPACE_DISPLAY_P3, DT_COLORSPACE_EXPORT, DT_COLORSPACE_FILE, DT_COLORSPACE_HLG_P3, DT_COLORSPACE_HLG_REC2020, DT_COLORSPACE_INFRARED, DT_COLORSPACE_ITUR_BT1886, DT_COLORSPACE_LAB, DT_COLORSPACE_LAST, DT_COLORSPACE_LIN_REC2020, DT_COLORSPACE_LIN_REC709, DT_COLORSPACE_PQ_P3, DT_COLORSPACE_PQ_REC2020, DT_COLORSPACE_PROPHOTO_RGB, DT_COLORSPACE_REC709, DT_COLORSPACE_SOFTPROOF, DT_COLORSPACE_SRGB, DT_COLORSPACE_WORK, DT_COLORSPACE_XYZ, dt_colorspaces_create_adobergb_profile(), dt_colorspaces_create_brg_profile(), dt_colorspaces_create_display_p3_rgb_profile(), dt_colorspaces_create_gamma_rec709_rgb_profile(), dt_colorspaces_create_hlg_p3_rgb_profile(), dt_colorspaces_create_hlg_rec2020_rgb_profile(), dt_colorspaces_create_itur_bt1886_rgb_profile(), dt_colorspaces_create_lab_profile(), dt_colorspaces_create_linear_infrared_profile(), dt_colorspaces_create_linear_prophoto_rgb_profile(), dt_colorspaces_create_linear_rec2020_rgb_profile(), dt_colorspaces_create_linear_rec709_rgb_profile(), dt_colorspaces_create_pq_p3_rgb_profile(), dt_colorspaces_create_pq_rec2020_rgb_profile(), dt_colorspaces_create_srgb_profile(), dt_colorspaces_create_srgb_profile_v4(), dt_colorspaces_create_xyz_profile(), dt_colorspaces_get_matrix_from_input_profile(), dt_colorspaces_get_matrix_from_output_profile(), dt_conf_get_bool(), dt_conf_get_int(), dt_conf_get_string_const(), DT_DEBUG_DEV, dt_print(), DT_PROFILE_GAMUTCHECK, DT_PROFILE_NORMAL, dt_colorspaces_color_profile_t::in_pos, load_profile_from_dir(), dt_colorspaces_t::mode, dt_colorspaces_color_profile_t::name, dt_colorspaces_color_profile_t::out_pos, dt_colorspaces_color_profile_t::profile, dt_colorspaces_t::profiles, Rec709_Primaries, Rec709_Primaries_Prequantized, dt_colorspaces_t::softproof_filename, dt_colorspaces_t::softproof_intent, dt_colorspaces_t::softproof_type, dt_colorspaces_color_profile_t::work_pos, and dt_colorspaces_t::xprofile_lock.

Referenced by dt_init().

◆ dt_colorspaces_is_profile_equal()

gboolean dt_colorspaces_is_profile_equal ( const char *  fullname,
const char *  filename 
)

check whether filename is the same profil as fullname, this is taking into account that fullname is always the fullpathname to the profile and filename may be a full pathname or just a base name

References _colorspaces_get_base_name(), and _colorspaces_is_base_name().

Referenced by _get_profile(), _resolve_work_profile(), and gui_update().

◆ dt_colorspaces_pseudoinverse()

static void dt_colorspaces_pseudoinverse ( double(*)  in[3],
double(*)  out[3],
int  size 
)
static

◆ dt_colorspaces_rgb_to_cygm()

void dt_colorspaces_rgb_to_cygm ( float *  out,
int  num,
double  RGB_to_CAM[4][3] 
)

convert RGB buffer to CYGM

Referenced by colorpicker_callback(), and legacy_params().

◆ dt_colorspaces_set_display_profile()

◆ dt_colorspaces_update_display_transforms()

void dt_colorspaces_update_display_transforms ( )

update the display transforms of srgb and adobergb to the display profile. make sure that darktable.color_profiles->xprofile_lock is held when calling this!

References _update_display_transforms(), darktable_t::color_profiles, and darktable.

Referenced by _update_display_profile(), intent_callback(), and profile_callback().

◆ dt_image_find_best_color_profile()

dt_colorspaces_color_profile_type_t dt_image_find_best_color_profile ( int32_t  imgid,
cmsHPROFILE *  output,
gboolean *  new_profile 
)

Best effort to find a suitable (input) color profile for a given image, using embedded ICC or EXIF whenever possible. This will also init the profile in the image cache.

Parameters
imgidID of the picture
outputIf not NULL, writes the generated color profile into this pointer.
new_profileWill be set to true if a new profile was generated (aka embedded profile) and will need to be freed. If false and output profile is returned, the profile returned already exists on the public list of profiles and should not be freed.
Returns
dt_colorspaces_color_profile_type_t type of profile detected. This type is tested internally and guaranteed to work.

References dt_image_t::adobe_XYZ_to_CAM, dt_image_t::colorspace, dt_image_t::d65_color_matrix, darktable, DT_COLORSPACE_ADOBERGB, DT_COLORSPACE_EMBEDDED_ICC, DT_COLORSPACE_EMBEDDED_MATRIX, DT_COLORSPACE_LIN_REC2020, DT_COLORSPACE_LIN_REC709, DT_COLORSPACE_NONE, DT_COLORSPACE_SRGB, DT_COLORSPACE_STANDARD_MATRIX, dt_colorspaces_cicp_to_type(), dt_colorspaces_create_xyzimatrix_profile(), dt_colorspaces_get_profile(), dt_colorspaces_get_rgb_profile_from_mem(), DT_IMAGE_4BAYER, dt_image_cache_get(), DT_IMAGE_CACHE_RELAXED, dt_image_cache_write_release(), DT_IMAGE_COLORSPACE_ADOBE_RGB, DT_IMAGE_COLORSPACE_SRGB, dt_image_full_path(), dt_image_is_matrix_correction_supported(), dt_image_is_monochrome(), dt_imageio_avif_read_profile(), dt_imageio_heif_read_profile(), dt_imageio_j2k_read_profile(), dt_imageio_jpeg_read_header(), dt_imageio_jpeg_read_profile(), dt_imageio_png_read_profile(), dt_imageio_tiff_read_profile(), DT_PROFILE_DIRECTION_IN, FALSE, dt_image_t::flags, darktable_t::image_cache, PATH_MAX, dt_colorspaces_color_profile_t::profile, dt_image_t::profile, dt_image_t::profile_size, and TRUE.

Referenced by dt_colorspaces_get_embedded_profile(), and reload_defaults().

◆ hsl2rgb()

◆ hue2rgb()

static float hue2rgb ( float  m1,
float  m2,
float  hue 
)
inlinestatic

Referenced by hsl2rgb().

◆ load_profile_from_dir()

◆ mat3inv()

int mat3inv ( float *const  dst,
const float *const  src 
)

◆ mat3inv_double()

int mat3inv_double ( double *const  dst,
const double *const  src 
)

◆ mat3inv_float()

int mat3inv_float ( float *const  dst,
const float *const  src 
)

inverts the given 3x3 matrix

Referenced by mat3inv().

◆ rgb2hsl()

void rgb2hsl ( const dt_aligned_pixel_t  rgb,
float *  h,
float *  s,
float *  l 
)

common functions to change between colorspaces, used in iop modules

Referenced by color_picker_apply(), colorpick_callback(), process(), process_hsl_v1(), process_hsl_v2(), and set_HSL_sliders().

Variable Documentation

◆ Adobe_Primaries

const cmsCIExyYTRIPLE Adobe_Primaries
static
Initial value:
= {
{0.6400, 0.3300, 1.0},
{0.2100, 0.7100, 1.0},
{0.1500, 0.0600, 1.0}
}

Referenced by dt_colorspaces_create_adobergb_profile().

◆ D50xyY

const cmsCIExyY D50xyY = {0.3457, 0.3585, 1.0}
static

◆ d65

const cmsCIEXYZ d65 = {0.95045471, 1.00000000, 1.08905029}
static

◆ D65xyY

◆ P3_Primaries

const cmsCIExyYTRIPLE P3_Primaries
static
Initial value:
= {
{0.680, 0.320, 1.0},
{0.265, 0.690, 1.0},
{0.150, 0.060, 1.0}
}

Referenced by dt_colorspaces_create_display_p3_rgb_profile(), dt_colorspaces_create_hlg_p3_rgb_profile(), and dt_colorspaces_create_pq_p3_rgb_profile().

◆ ProPhoto_Primaries

const cmsCIExyYTRIPLE ProPhoto_Primaries
static
Initial value:
= {
{ 0.734699, 0.265301, 1.0000 },
{ 0.159597, 0.840403, 1.0000 },
{ 0.036598, 0.000105, 1.0000 },
}

Referenced by dt_colorspaces_create_linear_prophoto_rgb_profile().

◆ Rec2020_Primaries

const cmsCIExyYTRIPLE Rec2020_Primaries
static
Initial value:
= {
{0.7080, 0.2920, 1.0},
{0.1700, 0.7970, 1.0},
{0.1310, 0.0460, 1.0}
}

Referenced by dt_colorspaces_create_hlg_rec2020_rgb_profile(), dt_colorspaces_create_linear_rec2020_rgb_profile(), and dt_colorspaces_create_pq_rec2020_rgb_profile().

◆ Rec709_Primaries

const cmsCIExyYTRIPLE Rec709_Primaries
static
Initial value:
= {
{0.6400, 0.3300, 1.0},
{0.3000, 0.6000, 1.0},
{0.1500, 0.0600, 1.0}
}

Referenced by dt_colorspaces_create_gamma_rec709_rgb_profile(), dt_colorspaces_create_itur_bt1886_rgb_profile(), dt_colorspaces_create_linear_rec709_rgb_profile(), and dt_colorspaces_init().

◆ Rec709_Primaries_Prequantized

cmsCIEXYZTRIPLE Rec709_Primaries_Prequantized

◆ sRGB_Primaries

const cmsCIExyYTRIPLE sRGB_Primaries
static
Initial value:
= {
{0.6400, 0.3300, 1.0},
{0.3000, 0.6000, 1.0},
{0.1500, 0.0600, 1.0}
}

Referenced by _colorspaces_create_srgb_profile(), dt_colorspaces_create_brg_profile(), and dt_colorspaces_create_linear_infrared_profile().