![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#include "common/colorspaces.h"
#include "common/darktable.h"
#include "common/iop_profile.h"
#include "common/debug.h"
#include "common/matrices.h"
#include "develop/imageop.h"
#include "develop/imageop_math.h"
#include "develop/pixelpipe.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Macros | |
#define | DT_IOPPR_LUT_SAMPLES 0x10000 |
Functions | |
static void | _mark_as_nonmatrix_profile (dt_iop_order_iccprofile_info_t *const profile_info) |
static void | _clear_lut_curves (dt_iop_order_iccprofile_info_t *const profile_info) |
static void | _transform_from_to_rgb_lab_lcms2 (const float *const image_in, float *const image_out, const int width, const int height, const dt_colorspaces_color_profile_type_t type, const char *filename, const int intent, const int direction) |
static void | _transform_rgb_to_rgb_lcms2 (const float *const image_in, float *const image_out, const int width, const int height, const dt_colorspaces_color_profile_type_t type_from, const char *filename_from, const dt_colorspaces_color_profile_type_t type_to, const char *filename_to, const int intent) |
static void | _transform_lcms2 (struct dt_iop_module_t *self, const float *const image_in, float *const image_out, const int width, const int height, const int cst_from, const int cst_to, int *converted_cst, const dt_iop_order_iccprofile_info_t *const profile_info) |
static void | _transform_lcms2_rgb (const float *const image_in, float *const image_out, const int width, const int height, const dt_iop_order_iccprofile_info_t *const profile_info_from, const dt_iop_order_iccprofile_info_t *const profile_info_to) |
static int | _init_unbounded_coeffs (float *const lutr, float *const lutg, float *const lutb, float *const unbounded_coeffsr, float *const unbounded_coeffsg, float *const unbounded_coeffsb, const int lutsize) |
static void | _apply_tonecurves (const float *const image_in, float *const image_out, const int width, const int height, const float *const restrict lutr, const float *const restrict lutg, const float *const restrict lutb, const float *const restrict unbounded_coeffsr, const float *const restrict unbounded_coeffsg, const float *const restrict unbounded_coeffsb, const int lutsize) |
static void | _transform_rgb_to_lab_matrix (const float *const restrict image_in, float *const restrict image_out, const int width, const int height, const dt_iop_order_iccprofile_info_t *const profile_info) |
static void | _transform_lab_to_rgb_matrix (const float *const image_in, float *const image_out, const int width, const int height, const dt_iop_order_iccprofile_info_t *const profile_info) |
static void | _transform_matrix_rgb (const float *const restrict image_in, float *const restrict image_out, const int width, const int height, const dt_iop_order_iccprofile_info_t *const profile_info_from, const dt_iop_order_iccprofile_info_t *const profile_info_to) |
static void | _transform_matrix (struct dt_iop_module_t *self, const float *const restrict image_in, float *const restrict image_out, const int width, const int height, const dt_iop_colorspace_type_t cst_from, const dt_iop_colorspace_type_t cst_to, dt_iop_colorspace_type_t *converted_cst, const dt_iop_order_iccprofile_info_t *const profile_info) |
void | dt_ioppr_init_profile_info (dt_iop_order_iccprofile_info_t *profile_info, const int lutsize) |
void | dt_ioppr_cleanup_profile_info (dt_iop_order_iccprofile_info_t *profile_info) |
static int | dt_ioppr_generate_profile_info (dt_iop_order_iccprofile_info_t *profile_info, const int type, const char *filename, const int intent) |
dt_iop_order_iccprofile_info_t * | dt_ioppr_get_profile_info_from_list (struct dt_develop_t *dev, const dt_colorspaces_color_profile_type_t profile_type, const char *profile_filename) |
dt_iop_order_iccprofile_info_t * | dt_ioppr_add_profile_info_to_list (struct dt_develop_t *dev, const dt_colorspaces_color_profile_type_t profile_type, const char *profile_filename, const int intent) |
dt_iop_order_iccprofile_info_t * | dt_ioppr_get_iop_work_profile_info (struct dt_iop_module_t *module, GList *iop_list) |
dt_iop_order_iccprofile_info_t * | dt_ioppr_set_pipe_work_profile_info (struct dt_develop_t *dev, struct dt_dev_pixelpipe_t *pipe, const dt_colorspaces_color_profile_type_t type, const char *filename, const int intent) |
dt_iop_order_iccprofile_info_t * | dt_ioppr_set_pipe_input_profile_info (struct dt_develop_t *dev, struct dt_dev_pixelpipe_t *pipe, const dt_colorspaces_color_profile_type_t type, const char *filename, const int intent, const dt_colormatrix_t matrix_in) |
dt_iop_order_iccprofile_info_t * | dt_ioppr_set_pipe_output_profile_info (struct dt_develop_t *dev, struct dt_dev_pixelpipe_t *pipe, const dt_colorspaces_color_profile_type_t type, const char *filename, const int intent) |
dt_iop_order_iccprofile_info_t * | dt_ioppr_get_pipe_work_profile_info (struct dt_dev_pixelpipe_t *pipe) |
dt_iop_order_iccprofile_info_t * | dt_ioppr_get_pipe_input_profile_info (struct dt_dev_pixelpipe_t *pipe) |
dt_iop_order_iccprofile_info_t * | dt_ioppr_get_pipe_output_profile_info (struct dt_dev_pixelpipe_t *pipe) |
dt_iop_order_iccprofile_info_t * | dt_ioppr_get_pipe_current_profile_info (dt_iop_module_t *module, struct dt_dev_pixelpipe_t *pipe) |
void | dt_ioppr_get_work_profile_type (struct dt_develop_t *dev, dt_colorspaces_color_profile_type_t *profile_type, const char **profile_filename) |
void | dt_ioppr_get_export_profile_type (struct dt_develop_t *dev, dt_colorspaces_color_profile_type_t *profile_type, const char **profile_filename) |
__DT_CLONE_TARGETS__ void | dt_ioppr_transform_image_colorspace (struct dt_iop_module_t *self, const float *const image_in, float *const image_out, const int width, const int height, const int cst_from, const int cst_to, int *converted_cst, const dt_iop_order_iccprofile_info_t *const profile_info) |
__DT_CLONE_TARGETS__ void | dt_ioppr_transform_image_colorspace_rgb (const float *const restrict image_in, float *const restrict image_out, const int width, const int height, const dt_iop_order_iccprofile_info_t *const profile_info_from, const dt_iop_order_iccprofile_info_t *const profile_info_to, const char *message) |
#define DT_IOPPR_LUT_SAMPLES 0x10000 |
|
inlinestatic |
References eval_exp(), extrapolate_lut(), height, and width.
Referenced by _transform_lab_to_rgb_matrix(), and _transform_rgb_to_lab_matrix().
|
static |
References dt_iop_order_iccprofile_info_t::lut_in, and dt_iop_order_iccprofile_info_t::lut_out.
Referenced by dt_ioppr_generate_profile_info().
|
inlinestatic |
References dt_iop_estimate_exp(), and extrapolate_lut().
Referenced by dt_ioppr_generate_profile_info().
|
static |
Note : we do not use finite-math-only and fast-math because divisions by zero are not manually avoided in the code fp-contract=fast enables hardware-accelerated Fused Multiply-Add the rest is loop reorganization and vectorization optimization
References dt_iop_order_iccprofile_info_t::matrix_in, dt_iop_order_iccprofile_info_t::matrix_in_transposed, dt_iop_order_iccprofile_info_t::matrix_out, and dt_iop_order_iccprofile_info_t::matrix_out_transposed.
Referenced by dt_ioppr_generate_profile_info(), and dt_ioppr_init_profile_info().
|
static |
References darktable_t::color_profiles, darktable, DT_COLORSPACE_DISPLAY, DT_COLORSPACE_LAB, DT_COLORSPACE_LIN_REC2020, DT_COLORSPACE_NONE, dt_colorspaces_get_profile(), DT_PROFILE_DIRECTION_ANY, DT_PROFILE_DIRECTION_WORK, height, output_format(), dt_colorspaces_color_profile_t::profile, type, width, and dt_colorspaces_t::xprofile_lock.
Referenced by _transform_lcms2().
|
inlinestatic |
References _apply_tonecurves(), dt_apply_transposed_color_matrix(), dt_Lab_to_XYZ(), height, dt_iop_order_iccprofile_info_t::lut_out, dt_iop_order_iccprofile_info_t::lutsize, dt_iop_order_iccprofile_info_t::matrix_out_transposed, dt_iop_order_iccprofile_info_t::nonlinearlut, and width.
Referenced by _transform_matrix().
|
static |
References _transform_from_to_rgb_lab_lcms2(), DT_DEBUG_DEV, dt_print(), dt_iop_order_iccprofile_info_t::filename, height, dt_iop_order_iccprofile_info_t::intent, IOP_CS_LAB, IOP_CS_RGB, dt_iop_module_t::multi_name, dt_iop_module_t::op, dt_iop_order_iccprofile_info_t::type, and width.
Referenced by dt_ioppr_transform_image_colorspace().
|
inlinestatic |
|
inlinestatic |
References _transform_lab_to_rgb_matrix(), _transform_rgb_to_lab_matrix(), height, IOP_CS_LAB, IOP_CS_RGB, and width.
Referenced by dt_ioppr_transform_image_colorspace().
|
inlinestatic |
References DT_ALIGNED_PIXEL, dt_apply_transposed_color_matrix(), dt_colormatrix_mul(), eval_exp(), extrapolate_lut(), for_each_channel, height, dt_iop_order_iccprofile_info_t::lut_in, dt_iop_order_iccprofile_info_t::lut_out, dt_iop_order_iccprofile_info_t::lutsize, dt_iop_order_iccprofile_info_t::matrix_in, dt_iop_order_iccprofile_info_t::matrix_out, dt_iop_order_iccprofile_info_t::nonlinearlut, transpose_3xSSE(), and width.
Referenced by dt_ioppr_transform_image_colorspace_rgb().
|
inlinestatic |
References _apply_tonecurves(), dt_apply_transposed_color_matrix(), dt_XYZ_to_Lab(), height, dt_iop_order_iccprofile_info_t::lut_in, dt_iop_order_iccprofile_info_t::lutsize, dt_iop_order_iccprofile_info_t::matrix_in_transposed, dt_iop_order_iccprofile_info_t::nonlinearlut, and width.
Referenced by _transform_matrix().
|
static |
dt_iop_order_iccprofile_info_t * dt_ioppr_add_profile_info_to_list | ( | struct dt_develop_t * | dev, |
const dt_colorspaces_color_profile_type_t | profile_type, | ||
const char * | profile_filename, | ||
const int | intent | ||
) |
adds the profile info from (profile_type, profile_filename) to the dev profiles info list if not already exists returns the generated profile or the existing one
References dt_develop_t::allprofile_info, dt_alloc_align, dt_free_align, dt_ioppr_generate_profile_info(), dt_ioppr_get_profile_info_from_list(), and dt_ioppr_init_profile_info().
Referenced by dt_ioppr_get_iop_work_profile_info(), dt_ioppr_set_pipe_input_profile_info(), dt_ioppr_set_pipe_output_profile_info(), dt_ioppr_set_pipe_work_profile_info(), process(), process(), and workicc_changed().
void dt_ioppr_cleanup_profile_info | ( | dt_iop_order_iccprofile_info_t * | profile_info | ) |
must be called when done with profile_info
References dt_free_align, dt_iop_order_iccprofile_info_t::lut_in, and dt_iop_order_iccprofile_info_t::lut_out.
Referenced by dt_dev_cleanup().
|
static |
generate the info for the profile (type, filename) if matrix can be retrieved from lcms2 it can be called multiple time between init and cleanup return 0 if OK, non zero otherwise
References _clear_lut_curves(), _init_unbounded_coeffs(), _mark_as_nonmatrix_profile(), darktable_t::color_profiles, darktable, DT_COLORSPACE_DISPLAY, dt_colorspaces_get_matrix_from_input_profile(), dt_colorspaces_get_matrix_from_output_profile(), dt_colorspaces_get_profile(), dt_ioppr_get_rgb_matrix_luminance(), DT_PROFILE_DIRECTION_ANY, dt_iop_order_iccprofile_info_t::filename, dt_iop_order_iccprofile_info_t::grey, dt_iop_order_iccprofile_info_t::intent, dt_iop_order_iccprofile_info_t::lut_in, dt_iop_order_iccprofile_info_t::lut_out, dt_iop_order_iccprofile_info_t::lutsize, dt_iop_order_iccprofile_info_t::matrix_in, dt_iop_order_iccprofile_info_t::matrix_in_transposed, dt_iop_order_iccprofile_info_t::matrix_out, dt_iop_order_iccprofile_info_t::matrix_out_transposed, dt_iop_order_iccprofile_info_t::nonlinearlut, dt_colorspaces_color_profile_t::profile, transpose_3xSSE(), dt_iop_order_iccprofile_info_t::type, type, and dt_colorspaces_t::xprofile_lock.
Referenced by dt_ioppr_add_profile_info_to_list().
void dt_ioppr_get_export_profile_type | ( | struct dt_develop_t * | dev, |
dt_colorspaces_color_profile_type_t * | profile_type, | ||
const char ** | profile_filename | ||
) |
returns the current setting of the export profile on colorout iop
References darktable, DT_COLORSPACE_NONE, darktable_t::iop, dt_develop_t::iop, dt_iop_module_so_t::op, and dt_iop_module_t::params.
dt_iop_order_iccprofile_info_t * dt_ioppr_get_iop_work_profile_info | ( | struct dt_iop_module_t * | module, |
GList * | iop_list | ||
) |
returns a reference to the work profile info as set on colorin iop only if module is between colorin and colorout, otherwise returns NULL work profile must not be cleanup()
References DT_COLORSPACE_NONE, DT_INTENT_PERCEPTUAL, dt_ioppr_add_profile_info_to_list(), dt_ioppr_get_work_profile_type(), FALSE, dt_iop_module_t::op, TRUE, and type.
Referenced by _area_draw_callback(), _draw_color_picker(), _signal_profile_user_changed(), _update_gradient_slider_pickers(), apply_auto_black(), apply_auto_grey(), apply_auto_white_point_source(), apply_autotune(), blend_color_picker_apply(), dt_develop_blendif_init_masking_profile(), gui_changed(), process(), process(), process_fusion(), and process_lut().
dt_iop_order_iccprofile_info_t * dt_ioppr_get_pipe_current_profile_info | ( | struct dt_iop_module_t * | module, |
struct dt_dev_pixelpipe_t * | pipe | ||
) |
Get the relevant RGB -> XYZ profile at the position of current module
References dt_iop_module_t::dev, dt_ioppr_get_iop_order(), dt_ioppr_get_pipe_input_profile_info(), dt_ioppr_get_pipe_output_profile_info(), dt_ioppr_get_pipe_work_profile_info(), and dt_develop_t::iop_order_list.
Referenced by _update_gradient_slider_pickers(), blend_color_picker_apply(), color_picker_apply(), commit_params(), dt_develop_blendif_init_masking_profile(), pipe_RGB_to_Ych(), pixelpipe_picker(), process(), and process().
dt_iop_order_iccprofile_info_t * dt_ioppr_get_pipe_input_profile_info | ( | struct dt_dev_pixelpipe_t * | pipe | ) |
References dt_dev_pixelpipe_t::input_profile_info.
Referenced by _auto_set_exposure(), commit_params(), dt_ioppr_get_pipe_current_profile_info(), and process().
dt_iop_order_iccprofile_info_t * dt_ioppr_get_pipe_output_profile_info | ( | struct dt_dev_pixelpipe_t * | pipe | ) |
References dt_dev_pixelpipe_t::output_profile_info.
Referenced by _area_draw_callback(), _draw_color_picker(), _update_RGB_colors(), dt_ioppr_get_pipe_current_profile_info(), gui_post_expose(), and process().
dt_iop_order_iccprofile_info_t * dt_ioppr_get_pipe_work_profile_info | ( | struct dt_dev_pixelpipe_t * | pipe | ) |
returns the active work/input/output profile on the pipe
References dt_dev_pixelpipe_t::work_profile_info.
Referenced by _auto_set_illuminant(), _generate_curve_lut(), _retouch_blur(), _sample_color_picker(), collect_histogram_on_CPU(), color_picker_apply(), dt_develop_blendif_lab_blend(), dt_ioppr_get_pipe_current_profile_info(), histogram_collect(), pixelpipe_process_on_CPU(), process(), process(), process(), rt_adjust_levels(), and rt_process_stats().
dt_iop_order_iccprofile_info_t * dt_ioppr_get_profile_info_from_list | ( | struct dt_develop_t * | dev, |
dt_colorspaces_color_profile_type_t | profile_type, | ||
const char * | profile_filename | ||
) |
returns the profile info from dev profiles info list that matches (profile_type, profile_filename) NULL if not found
References dt_develop_t::allprofile_info, dt_iop_order_iccprofile_info_t::filename, and dt_iop_order_iccprofile_info_t::type.
Referenced by dt_ioppr_add_profile_info_to_list().
void dt_ioppr_get_work_profile_type | ( | struct dt_develop_t * | dev, |
dt_colorspaces_color_profile_type_t * | profile_type, | ||
const char ** | profile_filename | ||
) |
returns the current setting of the work profile on colorin iop
References darktable, DT_COLORSPACE_NONE, darktable_t::iop, dt_develop_t::iop, dt_iop_module_so_t::op, and dt_iop_module_t::params.
Referenced by dt_ioppr_get_iop_work_profile_info().
void dt_ioppr_init_profile_info | ( | dt_iop_order_iccprofile_info_t * | profile_info, |
const int | lutsize | ||
) |
must be called before using profile_info, default lutsize = 0
References _mark_as_nonmatrix_profile(), dt_alloc_align_float(), DT_COLORSPACE_NONE, DT_INTENT_PERCEPTUAL, DT_IOPPR_LUT_SAMPLES, dt_iop_order_iccprofile_info_t::filename, dt_iop_order_iccprofile_info_t::grey, dt_iop_order_iccprofile_info_t::intent, dt_iop_order_iccprofile_info_t::lut_in, dt_iop_order_iccprofile_info_t::lut_out, dt_iop_order_iccprofile_info_t::lutsize, dt_iop_order_iccprofile_info_t::nonlinearlut, and dt_iop_order_iccprofile_info_t::type.
Referenced by dt_ioppr_add_profile_info_to_list().
dt_iop_order_iccprofile_info_t * dt_ioppr_set_pipe_input_profile_info | ( | struct dt_develop_t * | dev, |
struct dt_dev_pixelpipe_t * | pipe, | ||
const dt_colorspaces_color_profile_type_t | type, | ||
const char * | filename, | ||
const int | intent, | ||
const dt_colormatrix_t | matrix_in | ||
) |
References DT_COLORSPACE_ALTERNATE_MATRIX, DT_COLORSPACE_EMBEDDED_ICC, DT_COLORSPACE_LIN_REC2020, dt_ioppr_add_profile_info_to_list(), dt_dev_pixelpipe_t::input_profile_info, mat3SSEinv(), dt_iop_order_iccprofile_info_t::matrix_in, dt_iop_order_iccprofile_info_t::matrix_in_transposed, dt_iop_order_iccprofile_info_t::matrix_out, dt_iop_order_iccprofile_info_t::matrix_out_transposed, transpose_3xSSE(), dt_iop_order_iccprofile_info_t::type, and type.
Referenced by commit_params().
dt_iop_order_iccprofile_info_t * dt_ioppr_set_pipe_output_profile_info | ( | struct dt_develop_t * | dev, |
struct dt_dev_pixelpipe_t * | pipe, | ||
const dt_colorspaces_color_profile_type_t | type, | ||
const char * | filename, | ||
const int | intent | ||
) |
dt_iop_order_iccprofile_info_t * dt_ioppr_set_pipe_work_profile_info | ( | struct dt_develop_t * | dev, |
struct dt_dev_pixelpipe_t * | pipe, | ||
const dt_colorspaces_color_profile_type_t | type, | ||
const char * | filename, | ||
const int | intent | ||
) |
set the work profile (type, filename) on the pipe, should be called on process*() if matrix cannot be generated it default to linear rec 2020 returns the actual profile that has been set
References DT_COLORSPACE_LIN_REC2020, dt_ioppr_add_profile_info_to_list(), dt_iop_order_iccprofile_info_t::matrix_in, dt_iop_order_iccprofile_info_t::matrix_out, type, and dt_dev_pixelpipe_t::work_profile_info.
Referenced by commit_params().
__DT_CLONE_TARGETS__ void dt_ioppr_transform_image_colorspace | ( | struct dt_iop_module_t * | self, |
const float *const | image_in, | ||
float *const | image_out, | ||
const int | width, | ||
const int | height, | ||
const int | cst_from, | ||
const int | cst_to, | ||
int * | converted_cst, | ||
const dt_iop_order_iccprofile_info_t *const | profile_info | ||
) |
transforms image from cst_from to cst_to colorspace using profile_info
References _transform_lcms2(), _transform_matrix(), dt_times_t::clock, darktable, DT_COLORSPACE_NONE, DT_DEBUG_PERF, dt_get_times(), height, IOP_CS_RGB, dt_iop_order_iccprofile_info_t::matrix_in, dt_iop_order_iccprofile_info_t::matrix_out, dt_iop_module_t::multi_name, dt_iop_module_t::op, dt_iop_order_iccprofile_info_t::type, darktable_t::unmuted, dt_times_t::user, and width.
Referenced by _draw_color_picker(), _retouch_blur(), _sample_color_picker(), collect_histogram_on_CPU(), and pixelpipe_process_on_CPU().
__DT_CLONE_TARGETS__ void dt_ioppr_transform_image_colorspace_rgb | ( | const float *const restrict | image_in, |
float *const restrict | image_out, | ||
const int | width, | ||
const int | height, | ||
const dt_iop_order_iccprofile_info_t *const | profile_info_from, | ||
const dt_iop_order_iccprofile_info_t *const | profile_info_to, | ||
const char * | message | ||
) |
References _transform_lcms2_rgb(), _transform_matrix_rgb(), dt_times_t::clock, darktable, DT_COLORSPACE_NONE, DT_DEBUG_PERF, dt_get_times(), dt_iop_order_iccprofile_info_t::filename, height, dt_iop_order_iccprofile_info_t::matrix_in, dt_iop_order_iccprofile_info_t::matrix_out, dt_iop_order_iccprofile_info_t::type, darktable_t::unmuted, dt_times_t::user, and width.
Referenced by _area_draw_callback(), _draw_color_picker(), and process().