Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
filmicrgb.c File Reference
#include "bauhaus/bauhaus.h"
#include "common/colorspaces_inline_conversions.h"
#include "common/chromatic_adaptation.h"
#include "common/darktable.h"
#include "common/bspline.h"
#include "common/dwt.h"
#include "common/image.h"
#include "common/iop_profile.h"
#include "common/opencl.h"
#include "control/control.h"
#include "develop/develop.h"
#include "develop/imageop_gui.h"
#include "develop/imageop_math.h"
#include "develop/noise_generator.h"
#include "develop/openmp_maths.h"
#include "develop/tiling.h"
#include "dtgtk/button.h"
#include "dtgtk/drawingarea.h"
#include "dtgtk/expander.h"
#include "dtgtk/paint.h"
#include "gui/color_picker_proxy.h"
#include "gui/gtk.h"
#include "gui/presets.h"
#include "iop/gaussian_elimination.h"
#include "iop/iop_api.h"
#include "develop/imageop.h"
#include "gui/draw.h"
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
+ Include dependency graph for filmicrgb.c:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dt_iop_filmic_rgb_spline_t
 
struct  dt_iop_filmicrgb_params_t
 
struct  dt_iop_filmicrgb_gui_button_data_t
 
struct  dt_iop_filmicrgb_gui_data_t
 
struct  dt_iop_filmicrgb_data_t
 
struct  dt_iop_filmicrgb_global_data_t
 
struct  dt_iop_filmicrgb_v3_geometry_t
 
struct  dt_iop_filmicrgb_v3_nodes_t
 
struct  dt_iop_filmicrgb_simd_matrices_t
 

Macros

#define INVERSE_SQRT_3   0.5773502691896258f
 
#define SAFETY_MARGIN   0.01f
 
#define DT_GUI_CURVE_EDITOR_INSET   DT_PIXEL_APPLY_DPI(1)
 
#define MAX_NUM_SCALES   10
 
#define CIE_Y_1931_to_CIE_Y_2006(x)   (1.05785528f * (x))
 
#define ORDER_4   5
 
#define ORDER_3   4
 
#define LOGBASE   20.f
 

Typedefs

typedef enum dt_iop_filmicrgb_methods_type_t dt_iop_filmicrgb_methods_type_t
 
typedef enum dt_iop_filmicrgb_curve_type_t dt_iop_filmicrgb_curve_type_t
 
typedef enum dt_iop_filmicrgb_colorscience_type_t dt_iop_filmicrgb_colorscience_type_t
 
typedef enum dt_iop_filmicrgb_spline_version_type_t dt_iop_filmicrgb_spline_version_type_t
 
typedef enum dt_iop_filmicrgb_reconstruction_type_t dt_iop_filmicrgb_reconstruction_type_t
 
typedef struct dt_iop_filmic_rgb_spline_t dt_iop_filmic_rgb_spline_t
 
typedef enum dt_iop_filmic_rgb_gui_mode_t dt_iop_filmic_rgb_gui_mode_t
 
typedef enum dt_iop_filmic_noise_distribution_t dt_iop_filmic_noise_distribution_t
 
typedef struct dt_iop_filmicrgb_params_t dt_iop_filmicrgb_params_t
 
typedef enum dt_iop_filmicrgb_gui_button_t dt_iop_filmicrgb_gui_button_t
 
typedef struct dt_iop_filmicrgb_gui_button_data_t dt_iop_filmicrgb_gui_button_data_t
 
typedef struct dt_iop_filmicrgb_gui_data_t dt_iop_filmicrgb_gui_data_t
 
typedef struct dt_iop_filmicrgb_data_t dt_iop_filmicrgb_data_t
 
typedef struct dt_iop_filmicrgb_global_data_t dt_iop_filmicrgb_global_data_t
 
typedef struct dt_iop_filmicrgb_v3_geometry_t dt_iop_filmicrgb_v3_geometry_t
 
typedef struct dt_iop_filmicrgb_v3_nodes_t dt_iop_filmicrgb_v3_nodes_t
 
typedef struct dt_iop_filmicrgb_simd_matrices_t dt_iop_filmicrgb_simd_matrices_t
 

Enumerations

enum  dt_iop_filmicrgb_methods_type_t {
  DT_FILMIC_METHOD_NONE = 0 ,
  DT_FILMIC_METHOD_MAX_RGB = 1 ,
  DT_FILMIC_METHOD_LUMINANCE = 2 ,
  DT_FILMIC_METHOD_POWER_NORM = 3 ,
  DT_FILMIC_METHOD_EUCLIDEAN_NORM_V2 = 5 ,
  DT_FILMIC_METHOD_EUCLIDEAN_NORM_V1 = 4
}
 
enum  dt_iop_filmicrgb_curve_type_t {
  DT_FILMIC_CURVE_POLY_4 = 0 ,
  DT_FILMIC_CURVE_POLY_3 = 1 ,
  DT_FILMIC_CURVE_RATIONAL = 2
}
 
enum  dt_iop_filmicrgb_colorscience_type_t {
  DT_FILMIC_COLORSCIENCE_V1 = 0 ,
  DT_FILMIC_COLORSCIENCE_V2 = 1 ,
  DT_FILMIC_COLORSCIENCE_V3 = 2 ,
  DT_FILMIC_COLORSCIENCE_V4 = 3 ,
  DT_FILMIC_COLORSCIENCE_V5 = 4
}
 
enum  dt_iop_filmicrgb_spline_version_type_t {
  DT_FILMIC_SPLINE_VERSION_V1 = 0 ,
  DT_FILMIC_SPLINE_VERSION_V2 = 1 ,
  DT_FILMIC_SPLINE_VERSION_V3 = 2
}
 
enum  dt_iop_filmicrgb_reconstruction_type_t {
  DT_FILMIC_RECONSTRUCT_RGB = 0 ,
  DT_FILMIC_RECONSTRUCT_RATIOS = 1
}
 
enum  dt_iop_filmic_rgb_gui_mode_t {
  DT_FILMIC_GUI_LOOK = 0 ,
  DT_FILMIC_GUI_BASECURVE = 1 ,
  DT_FILMIC_GUI_BASECURVE_LOG = 2 ,
  DT_FILMIC_GUI_RANGES = 3 ,
  DT_FILMIC_GUI_LAST
}
 
enum  dt_iop_filmic_noise_distribution_t {
  DT_FILMIC_NOISE_UNIFORM = DT_NOISE_UNIFORM ,
  DT_FILMIC_NOISE_GAUSSIAN = DT_NOISE_GAUSSIAN ,
  DT_FILMIC_NOISE_POISSONIAN = DT_NOISE_POISSONIAN
}
 
enum  dt_iop_filmicrgb_gui_button_t {
  DT_FILMIC_GUI_BUTTON_TYPE = 0 ,
  DT_FILMIC_GUI_BUTTON_LABELS = 1 ,
  DT_FILMIC_GUI_BUTTON_LAST
}
 

Functions

const char * name ()
 
const char * aliases ()
 
const char ** description (struct dt_iop_module_t *self)
 
int default_group ()
 
int flags ()
 
int default_colorspace (dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
 
void input_format (dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece, dt_iop_buffer_dsc_t *dsc)
 
static gboolean dt_iop_filmic_rgb_compute_spline (const dt_iop_filmicrgb_params_t *const p, struct dt_iop_filmic_rgb_spline_t *const spline)
 
static gboolean filmic_v3_compute_geometry (const dt_iop_filmicrgb_params_t *const p, dt_iop_filmicrgb_v3_geometry_t *const geometry)
 
static gboolean filmic_v3_compute_nodes_from_legacy (const dt_iop_filmicrgb_params_t *const p, dt_iop_filmicrgb_v3_geometry_t *const geometry, dt_iop_filmicrgb_v3_nodes_t *const nodes)
 
static void filmic_v3_legacy_to_direct (const dt_iop_filmicrgb_params_t *const p, float *const toe, float *const shoulder)
 
static void filmic_v3_direct_to_legacy (const dt_iop_filmicrgb_params_t *const p, const float toe, const float shoulder, float *const latitude, float *const balance)
 
static void convert_to_spline_v3 (dt_iop_filmicrgb_params_t *n)
 
int legacy_params (dt_iop_module_t *self, const void *const old_params, const int old_version, void *new_params, const int new_version)
 
static float pixel_rgb_norm_power_simd (const dt_aligned_pixel_simd_t pixel)
 
static float pixel_rgb_norm_power (const dt_aligned_pixel_t pixel)
 
static float get_pixel_norm_simd (const dt_aligned_pixel_simd_t pixel, const dt_iop_filmicrgb_methods_type_t variant, const dt_iop_order_iccprofile_info_t *const work_profile)
 
static float get_pixel_norm (const dt_aligned_pixel_t pixel, const dt_iop_filmicrgb_methods_type_t variant, const dt_iop_order_iccprofile_info_t *const work_profile)
 
static float log_tonemapping (const float x, const float grey, const float black, const float dynamic_range)
 
static float exp_tonemapping_v2 (const float x, const float grey, const float black, const float dynamic_range)
 
static float filmic_spline (const float x, const dt_aligned_pixel_t M1, const dt_aligned_pixel_t M2, const dt_aligned_pixel_t M3, const dt_aligned_pixel_t M4, const dt_aligned_pixel_t M5, const float latitude_min, const float latitude_max, const dt_iop_filmicrgb_curve_type_t type[2])
 
static float filmic_desaturate_v1 (const float x, const float sigma_toe, const float sigma_shoulder, const float saturation)
 
static float filmic_desaturate_v2 (const float x, const float sigma_toe, const float sigma_shoulder, const float saturation)
 
static float linear_saturation (const float x, const float luminance, const float saturation)
 
static __DT_CLONE_TARGETS__ gint mask_clipped_pixels (const float *const restrict in, float *const restrict mask, const float normalize, const float feathering, const size_t width, const size_t height, const size_t ch)
 
static void inpaint_noise (const float *const in, const float *const mask, float *const inpainted, const float noise_level, const float threshold, const dt_noise_distribution_t noise_distribution, const size_t width, const size_t height)
 
static __DT_CLONE_TARGETS__ void wavelets_reconstruct_RGB (const float *const restrict HF, const float *const restrict LF, const float *const restrict texture, const float *const restrict mask, float *const restrict reconstructed, const size_t width, const size_t height, const size_t ch, const float gamma, const float gamma_comp, const float beta, const float beta_comp, const float delta, const size_t s, const size_t scales)
 
static __DT_CLONE_TARGETS__ void wavelets_reconstruct_ratios (const float *const restrict HF, const float *const restrict LF, const float *const restrict texture, const float *const restrict mask, float *const restrict reconstructed, const size_t width, const size_t height, const size_t ch, const float gamma, const float gamma_comp, const float beta, const float beta_comp, const float delta, const size_t s, const size_t scales)
 
static void init_reconstruct (const float *const restrict in, const float *const restrict mask, float *const restrict reconstructed, const size_t width, const size_t height)
 
static __DT_CLONE_TARGETS__ void wavelets_detail_level (const float *const restrict detail, const float *const restrict LF, float *const restrict HF, float *const restrict texture, const size_t width, const size_t height, const size_t ch)
 
static int get_scales (const dt_iop_roi_t *roi_in, const dt_dev_pixelpipe_iop_t *const piece)
 
static int reconstruct_highlights (const float *const restrict in, const float *const restrict mask, float *const restrict reconstructed, const dt_iop_filmicrgb_reconstruction_type_t variant, const size_t ch, const dt_iop_filmicrgb_data_t *const data, const dt_dev_pixelpipe_iop_t *piece, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out)
 
static void filmic_split_v1 (const float *const restrict in, float *const restrict out, const dt_iop_order_iccprofile_info_t *const work_profile, const dt_iop_filmicrgb_data_t *const data, const dt_iop_filmic_rgb_spline_t spline, const size_t width, const size_t height)
 
static void filmic_split_v2_v3 (const float *const restrict in, float *const restrict out, const dt_iop_order_iccprofile_info_t *const work_profile, const dt_iop_filmicrgb_data_t *const data, const dt_iop_filmic_rgb_spline_t spline, const size_t width, const size_t height)
 
static void filmic_chroma_v1 (const float *const restrict in, float *const restrict out, const dt_iop_order_iccprofile_info_t *const work_profile, const dt_iop_filmicrgb_data_t *const data, const dt_iop_filmic_rgb_spline_t spline, const int variant, const size_t width, const size_t height)
 
static void filmic_chroma_v2_v3 (const float *const restrict in, float *const restrict out, const dt_iop_order_iccprofile_info_t *const work_profile, const dt_iop_filmicrgb_data_t *const data, const dt_iop_filmic_rgb_spline_t spline, const int variant, const size_t width, const size_t height, const size_t ch, const dt_iop_filmicrgb_colorscience_type_t colorscience_version)
 
static __attribute__ ((always_inline))
 
static float clip_chroma_white_raw (const float coeffs[3], const float target_white, const float Y, const float cos_h, const float sin_h)
 
static float clip_chroma_white (const float coeffs[3], const float target_white, const float Y, const float cos_h, const float sin_h)
 
static float clip_chroma_black (const float coeffs[3], const float cos_h, const float sin_h)
 
static float clip_chroma (const dt_colormatrix_t matrix_out, const float target_white, const float Y, const float cos_h, const float sin_h, const float chroma)
 
static int filmic_v4_prepare_matrices (dt_colormatrix_t input_matrix, dt_colormatrix_t output_matrix, dt_colormatrix_t export_input_matrix, dt_colormatrix_t export_output_matrix, const dt_iop_order_iccprofile_info_t *const work_profile, const dt_iop_order_iccprofile_info_t *const export_profile)
 
static void filmic_prepare_simd_matrices (const dt_colormatrix_t input_matrix, const dt_colormatrix_t output_matrix, const dt_colormatrix_t export_input_matrix, const dt_colormatrix_t export_output_matrix, dt_iop_filmicrgb_simd_matrices_t *const simd_matrices)
 
static void filmic_chroma_v4 (const float *const restrict in, float *const restrict out, const dt_iop_order_iccprofile_info_t *const work_profile, const dt_iop_order_iccprofile_info_t *const export_profile, const dt_iop_filmicrgb_data_t *const data, const dt_iop_filmic_rgb_spline_t spline, const int variant, const size_t width, const size_t height, const size_t ch, const dt_iop_filmicrgb_colorscience_type_t colorscience_version, const float display_black, const float display_white)
 
static void filmic_split_v4 (const float *const restrict in, float *const restrict out, const dt_iop_order_iccprofile_info_t *const work_profile, const dt_iop_order_iccprofile_info_t *const export_profile, const dt_iop_filmicrgb_data_t *const data, const dt_iop_filmic_rgb_spline_t spline, const int variant, const size_t width, const size_t height, const size_t ch, const dt_iop_filmicrgb_colorscience_type_t colorscience_version, const float display_black, const float display_white)
 
static void filmic_v5 (const float *const restrict in, float *const restrict out, const dt_iop_order_iccprofile_info_t *const work_profile, const dt_iop_order_iccprofile_info_t *const export_profile, const dt_iop_filmicrgb_data_t *const data, const dt_iop_filmic_rgb_spline_t spline, const size_t width, const size_t height, const size_t ch, const float display_black, const float display_white)
 
static void display_mask (const float *const restrict mask, float *const restrict out, const size_t width, const size_t height)
 
static void compute_ratios (const float *const restrict in, float *const restrict norms, float *const restrict ratios, const dt_iop_order_iccprofile_info_t *const work_profile, const int variant, const size_t width, const size_t height)
 
static void restore_ratios (float *const restrict ratios, const float *const restrict norms, const size_t width, const size_t height)
 
void tiling_callback (struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, struct dt_develop_tiling_t *tiling)
 
int process (dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const restrict ivoid, void *const restrict ovoid)
 
static void apply_auto_grey (dt_iop_module_t *self, const dt_iop_order_iccprofile_info_t *const work_profile)
 
static void apply_auto_black (dt_iop_module_t *self, const dt_iop_order_iccprofile_info_t *const work_profile)
 
static void apply_auto_white_point_source (dt_iop_module_t *self, const dt_iop_order_iccprofile_info_t *const work_profile)
 
static void apply_autotune (dt_iop_module_t *self, const dt_iop_order_iccprofile_info_t *const work_profile)
 
void color_picker_apply (dt_iop_module_t *self, GtkWidget *picker, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
static void show_mask_callback (GtkToggleButton *button, GdkEventButton *event, gpointer user_data)
 
void commit_params (dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
void gui_focus (struct dt_iop_module_t *self, gboolean in)
 
void init_pipe (dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
void cleanup_pipe (dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
static void filmic_gui_sync_toe_shoulder (dt_iop_module_t *self)
 
static void toe_shoulder_callback (GtkWidget *slider, gpointer user_data)
 
void gui_update (dt_iop_module_t *self)
 Refresh GUI controls from current params and configuration.
 
void reload_defaults (dt_iop_module_t *module)
 
void init_global (dt_iop_module_so_t *module)
 
void cleanup_global (dt_iop_module_so_t *module)
 
void gui_reset (dt_iop_module_t *self)
 
static void dt_cairo_draw_arrow (cairo_t *cr, double origin_x, double origin_y, double destination_x, double destination_y, gboolean show_head)
 
void filmic_gui_draw_icon (cairo_t *cr, struct dt_iop_filmicrgb_gui_button_data_t *button, struct dt_iop_filmicrgb_gui_data_t *g)
 
static gboolean dt_iop_tonecurve_draw (GtkWidget *widget, cairo_t *crf, gpointer user_data)
 
static gboolean area_button_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 
static gboolean area_enter_notify (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
 
static gboolean area_leave_notify (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
 
static gboolean area_motion_notify (GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
 
static gboolean area_scroll_callback (GtkWidget *widget, GdkEventScroll *event, gpointer user_data)
 
void gui_init (dt_iop_module_t *self)
 
void gui_changed (dt_iop_module_t *self, GtkWidget *w, void *previous)
 

Macro Definition Documentation

◆ CIE_Y_1931_to_CIE_Y_2006

#define CIE_Y_1931_to_CIE_Y_2006 (   x)    (1.05785528f * (x))

◆ DT_GUI_CURVE_EDITOR_INSET

#define DT_GUI_CURVE_EDITOR_INSET   DT_PIXEL_APPLY_DPI(1)

◆ INVERSE_SQRT_3

#define INVERSE_SQRT_3   0.5773502691896258f

◆ LOGBASE

#define LOGBASE   20.f

◆ MAX_NUM_SCALES

#define MAX_NUM_SCALES   10

◆ ORDER_3

#define ORDER_3   4

◆ ORDER_4

#define ORDER_4   5

◆ SAFETY_MARGIN

#define SAFETY_MARGIN   0.01f

Typedef Documentation

◆ dt_iop_filmic_noise_distribution_t

◆ dt_iop_filmic_rgb_gui_mode_t

◆ dt_iop_filmic_rgb_spline_t

◆ dt_iop_filmicrgb_colorscience_type_t

◆ dt_iop_filmicrgb_curve_type_t

◆ dt_iop_filmicrgb_data_t

◆ dt_iop_filmicrgb_global_data_t

◆ dt_iop_filmicrgb_gui_button_data_t

◆ dt_iop_filmicrgb_gui_button_t

◆ dt_iop_filmicrgb_gui_data_t

◆ dt_iop_filmicrgb_methods_type_t

DOCUMENTATION

This code ports :

  1. Troy Sobotka's filmic curves for Blender (and other softs) https://github.com/sobotka/OpenAgX/blob/master/lib/agx_colour.py
  2. ACES camera logarithmic encoding https://github.com/ampas/aces-dev/blob/master/transforms/ctl/utilities/ACESutil.Lin_to_Log2_param.ctl

The ACES log implementation is taken from the profile_gamma.c IOP where it works in camera RGB space. Here, it works on an arbitrary RGB space. ProPhotoRGB has been chosen for its wide gamut coverage and for conveniency because it's already in darktable's libs. Any other RGB working space could work. This chouice could (should) also be exposed to the user.

The filmic curves are tonecurves intended to simulate the luminance transfer function of film with "S" curves. These could be reproduced in the tonecurve.c IOP, however what we offer here is a parametric interface useful to remap accurately and promptly the middle grey to any arbitrary value chosen accordingly to the destination space.

The combined use of both define a modern way to deal with large dynamic range photographs by remapping the values with a comprehensive interface avoiding many of the back and forth adjustments darktable is prone to enforce. Note : we use finite-math-only and fast-math because divisions by zero are manually avoided in the code fp-contract=fast enables hardware-accelerated Fused Multiply-Add

◆ dt_iop_filmicrgb_params_t

◆ dt_iop_filmicrgb_reconstruction_type_t

◆ dt_iop_filmicrgb_simd_matrices_t

◆ dt_iop_filmicrgb_spline_version_type_t

◆ dt_iop_filmicrgb_v3_geometry_t

◆ dt_iop_filmicrgb_v3_nodes_t

Enumeration Type Documentation

◆ dt_iop_filmic_noise_distribution_t

Enumerator
DT_FILMIC_NOISE_UNIFORM 
DT_FILMIC_NOISE_GAUSSIAN 
DT_FILMIC_NOISE_POISSONIAN 

◆ dt_iop_filmic_rgb_gui_mode_t

Enumerator
DT_FILMIC_GUI_LOOK 
DT_FILMIC_GUI_BASECURVE 
DT_FILMIC_GUI_BASECURVE_LOG 
DT_FILMIC_GUI_RANGES 
DT_FILMIC_GUI_LAST 

◆ dt_iop_filmicrgb_colorscience_type_t

Enumerator
DT_FILMIC_COLORSCIENCE_V1 
DT_FILMIC_COLORSCIENCE_V2 
DT_FILMIC_COLORSCIENCE_V3 
DT_FILMIC_COLORSCIENCE_V4 
DT_FILMIC_COLORSCIENCE_V5 

◆ dt_iop_filmicrgb_curve_type_t

Enumerator
DT_FILMIC_CURVE_POLY_4 
DT_FILMIC_CURVE_POLY_3 
DT_FILMIC_CURVE_RATIONAL 

◆ dt_iop_filmicrgb_gui_button_t

Enumerator
DT_FILMIC_GUI_BUTTON_TYPE 
DT_FILMIC_GUI_BUTTON_LABELS 
DT_FILMIC_GUI_BUTTON_LAST 

◆ dt_iop_filmicrgb_methods_type_t

DOCUMENTATION

This code ports :

  1. Troy Sobotka's filmic curves for Blender (and other softs) https://github.com/sobotka/OpenAgX/blob/master/lib/agx_colour.py
  2. ACES camera logarithmic encoding https://github.com/ampas/aces-dev/blob/master/transforms/ctl/utilities/ACESutil.Lin_to_Log2_param.ctl

The ACES log implementation is taken from the profile_gamma.c IOP where it works in camera RGB space. Here, it works on an arbitrary RGB space. ProPhotoRGB has been chosen for its wide gamut coverage and for conveniency because it's already in darktable's libs. Any other RGB working space could work. This chouice could (should) also be exposed to the user.

The filmic curves are tonecurves intended to simulate the luminance transfer function of film with "S" curves. These could be reproduced in the tonecurve.c IOP, however what we offer here is a parametric interface useful to remap accurately and promptly the middle grey to any arbitrary value chosen accordingly to the destination space.

The combined use of both define a modern way to deal with large dynamic range photographs by remapping the values with a comprehensive interface avoiding many of the back and forth adjustments darktable is prone to enforce. Note : we use finite-math-only and fast-math because divisions by zero are manually avoided in the code fp-contract=fast enables hardware-accelerated Fused Multiply-Add

Enumerator
DT_FILMIC_METHOD_NONE 
DT_FILMIC_METHOD_MAX_RGB 
DT_FILMIC_METHOD_LUMINANCE 
DT_FILMIC_METHOD_POWER_NORM 
DT_FILMIC_METHOD_EUCLIDEAN_NORM_V2 
DT_FILMIC_METHOD_EUCLIDEAN_NORM_V1 

◆ dt_iop_filmicrgb_reconstruction_type_t

Enumerator
DT_FILMIC_RECONSTRUCT_RGB 
DT_FILMIC_RECONSTRUCT_RATIOS 

◆ dt_iop_filmicrgb_spline_version_type_t

Enumerator
DT_FILMIC_SPLINE_VERSION_V1 
DT_FILMIC_SPLINE_VERSION_V2 
DT_FILMIC_SPLINE_VERSION_V3 

Function Documentation

◆ __attribute__()

static __attribute__ ( (always_inline)  )
inlinestatic

References c, dt_fast_hypotf(), g, r, and Yrg.

◆ aliases()

const char * aliases ( )

◆ apply_auto_black()

◆ apply_auto_grey()

◆ apply_auto_white_point_source()

◆ apply_autotune()

◆ area_button_press()

◆ area_enter_notify()

static gboolean area_enter_notify ( GtkWidget widget,
GdkEventCrossing *  event,
gpointer  user_data 
)
static

◆ area_leave_notify()

static gboolean area_leave_notify ( GtkWidget widget,
GdkEventCrossing *  event,
gpointer  user_data 
)
static

◆ area_motion_notify()

static gboolean area_motion_notify ( GtkWidget widget,
GdkEventMotion *  event,
gpointer  user_data 
)
static

◆ area_scroll_callback()

static gboolean area_scroll_callback ( GtkWidget widget,
GdkEventScroll *  event,
gpointer  user_data 
)
static

◆ cleanup_global()

◆ cleanup_pipe()

void cleanup_pipe ( dt_iop_module_t self,
dt_dev_pixelpipe_t pipe,
dt_dev_pixelpipe_iop_t piece 
)

◆ clip_chroma()

static float clip_chroma ( const dt_colormatrix_t  matrix_out,
const float  target_white,
const float  Y,
const float  cos_h,
const float  sin_h,
const float  chroma 
)
inlinestatic

◆ clip_chroma_black()

static float clip_chroma_black ( const float  coeffs[3],
const float  cos_h,
const float  sin_h 
)
inlinestatic

Referenced by clip_chroma().

◆ clip_chroma_white()

static float clip_chroma_white ( const float  coeffs[3],
const float  target_white,
const float  Y,
const float  cos_h,
const float  sin_h 
)
inlinestatic

◆ clip_chroma_white_raw()

static float clip_chroma_white_raw ( const float  coeffs[3],
const float  target_white,
const float  Y,
const float  cos_h,
const float  sin_h 
)
inlinestatic

Referenced by clip_chroma_white().

◆ color_picker_apply()

◆ commit_params()

◆ compute_ratios()

static void compute_ratios ( const float *const restrict  in,
float *const restrict  norms,
float *const restrict  ratios,
const dt_iop_order_iccprofile_info_t *const  work_profile,
const int  variant,
const size_t  width,
const size_t  height 
)
inlinestatic

◆ convert_to_spline_v3()

◆ default_colorspace()

int default_colorspace ( dt_iop_module_t self,
dt_dev_pixelpipe_t pipe,
const dt_dev_pixelpipe_iop_t piece 
)

References IOP_CS_RGB.

◆ default_group()

int default_group ( )

References IOP_GROUP_TONES.

◆ description()

const char ** description ( struct dt_iop_module_t self)

◆ display_mask()

static void display_mask ( const float *const restrict  mask,
float *const restrict  out,
const size_t  width,
const size_t  height 
)
inlinestatic

References dt_omploop_sfence, dt_simd_set1(), height, out, and width.

Referenced by process().

◆ dt_cairo_draw_arrow()

static void dt_cairo_draw_arrow ( cairo_t *  cr,
double  origin_x,
double  origin_y,
double  destination_x,
double  destination_y,
gboolean  show_head 
)
inlinestatic

References DT_PIXEL_APPLY_DPI, and M_PI.

Referenced by dt_iop_tonecurve_draw().

◆ dt_iop_filmic_rgb_compute_spline()

◆ dt_iop_tonecurve_draw()

◆ exp_tonemapping_v2()

static float exp_tonemapping_v2 ( const float  x,
const float  grey,
const float  black,
const float  dynamic_range 
)
inlinestatic

References x.

Referenced by dt_iop_tonecurve_draw(), filmic_chroma_v4(), and filmic_v5().

◆ filmic_chroma_v1()

◆ filmic_chroma_v2_v3()

◆ filmic_chroma_v4()

static void filmic_chroma_v4 ( const float *const restrict  in,
float *const restrict  out,
const dt_iop_order_iccprofile_info_t *const  work_profile,
const dt_iop_order_iccprofile_info_t *const  export_profile,
const dt_iop_filmicrgb_data_t *const  data,
const dt_iop_filmic_rgb_spline_t  spline,
const int  variant,
const size_t  width,
const size_t  height,
const size_t  ch,
const dt_iop_filmicrgb_colorscience_type_t  colorscience_version,
const float  display_black,
const float  display_white 
)
inlinestatic

◆ filmic_desaturate_v1()

static float filmic_desaturate_v1 ( const float  x,
const float  sigma_toe,
const float  sigma_shoulder,
const float  saturation 
)
inlinestatic

◆ filmic_desaturate_v2()

static float filmic_desaturate_v2 ( const float  x,
const float  sigma_toe,
const float  sigma_shoulder,
const float  saturation 
)
inlinestatic

◆ filmic_gui_draw_icon()

◆ filmic_gui_sync_toe_shoulder()

◆ filmic_prepare_simd_matrices()

static void filmic_prepare_simd_matrices ( const dt_colormatrix_t  input_matrix,
const dt_colormatrix_t  output_matrix,
const dt_colormatrix_t  export_input_matrix,
const dt_colormatrix_t  export_output_matrix,
dt_iop_filmicrgb_simd_matrices_t *const  simd_matrices 
)
inlinestatic

Prepare the transposed matrix rows used by the v4/v5 SIMD pixel path.

The v4/v5 CPU code repeatedly applies the same four RGB/LMS matrices to every pixel. We transpose them once here, then cache the 3 SIMD rows so the processing loops only perform the actual vector products.

References dt_iop_filmicrgb_simd_matrices_t::export_input, dt_iop_filmicrgb_simd_matrices_t::export_output, dt_iop_filmicrgb_simd_matrices_t::input, dt_iop_filmicrgb_simd_matrices_t::output, row, and transpose_3xSSE().

Referenced by filmic_chroma_v4(), filmic_split_v4(), and filmic_v5().

◆ filmic_spline()

static float filmic_spline ( const float  x,
const dt_aligned_pixel_t  M1,
const dt_aligned_pixel_t  M2,
const dt_aligned_pixel_t  M3,
const dt_aligned_pixel_t  M4,
const dt_aligned_pixel_t  M5,
const float  latitude_min,
const float  latitude_max,
const dt_iop_filmicrgb_curve_type_t  type[2] 
)
inlinestatic

◆ filmic_split_v1()

◆ filmic_split_v2_v3()

◆ filmic_split_v4()

static void filmic_split_v4 ( const float *const restrict  in,
float *const restrict  out,
const dt_iop_order_iccprofile_info_t *const  work_profile,
const dt_iop_order_iccprofile_info_t *const  export_profile,
const dt_iop_filmicrgb_data_t *const  data,
const dt_iop_filmic_rgb_spline_t  spline,
const int  variant,
const size_t  width,
const size_t  height,
const size_t  ch,
const dt_iop_filmicrgb_colorscience_type_t  colorscience_version,
const float  display_black,
const float  display_white 
)
inlinestatic

◆ filmic_v3_compute_geometry()

static gboolean filmic_v3_compute_geometry ( const dt_iop_filmicrgb_params_t *const  p,
dt_iop_filmicrgb_v3_geometry_t *const  geometry 
)
inlinestatic

Recover the affine segment used by the v3 spline generator from the user parameters.

Toe and shoulder are defined on that affine segment, as percentages of the available room between middle grey and the points where the current slope hits display black and display white.

References dt_iop_filmicrgb_v3_geometry_t::black_display, dt_iop_filmicrgb_v3_geometry_t::contrast, dt_iop_filmicrgb_v3_geometry_t::contrast_clamped, DT_FILMIC_SPLINE_VERSION_V3, FALSE, dt_iop_filmicrgb_v3_geometry_t::grey_display, dt_iop_filmicrgb_v3_geometry_t::grey_log, dt_iop_filmicrgb_v3_geometry_t::linear_intercept, p, SAFETY_MARGIN, TRUE, dt_iop_filmicrgb_v3_geometry_t::white_display, dt_iop_filmicrgb_v3_geometry_t::xmax, and dt_iop_filmicrgb_v3_geometry_t::xmin.

Referenced by filmic_v3_compute_nodes_from_legacy(), and filmic_v3_direct_to_legacy().

◆ filmic_v3_compute_nodes_from_legacy()

static gboolean filmic_v3_compute_nodes_from_legacy ( const dt_iop_filmicrgb_params_t *const  p,
dt_iop_filmicrgb_v3_geometry_t *const  geometry,
dt_iop_filmicrgb_v3_nodes_t *const  nodes 
)
inlinestatic

Place the v3 toe and shoulder nodes from the legacy latitude/balance controls.

The linear mid-tones segment is first expanded to the admissible [xmin ; xmax] interval for the current contrast, then latitude picks a symmetric position around middle grey. Balance finally translates that pair of nodes along the slope to favor shadows or highlights.

References dt_iop_filmicrgb_v3_geometry_t::contrast, FALSE, filmic_v3_compute_geometry(), dt_iop_filmicrgb_v3_geometry_t::grey_log, dt_iop_filmicrgb_v3_geometry_t::linear_intercept, p, dt_iop_filmicrgb_v3_nodes_t::shoulder_display, dt_iop_filmicrgb_v3_nodes_t::shoulder_log, dt_iop_filmicrgb_v3_nodes_t::toe_display, dt_iop_filmicrgb_v3_nodes_t::toe_log, TRUE, dt_iop_filmicrgb_v3_geometry_t::xmax, and dt_iop_filmicrgb_v3_geometry_t::xmin.

Referenced by dt_iop_filmic_rgb_compute_spline(), and filmic_v3_legacy_to_direct().

◆ filmic_v3_direct_to_legacy()

static void filmic_v3_direct_to_legacy ( const dt_iop_filmicrgb_params_t *const  p,
const float  toe,
const float  shoulder,
float *const  latitude,
float *const  balance 
)
inlinestatic

◆ filmic_v3_legacy_to_direct()

◆ filmic_v4_prepare_matrices()

static int filmic_v4_prepare_matrices ( dt_colormatrix_t  input_matrix,
dt_colormatrix_t  output_matrix,
dt_colormatrix_t  export_input_matrix,
dt_colormatrix_t  export_output_matrix,
const dt_iop_order_iccprofile_info_t *const  work_profile,
const dt_iop_order_iccprofile_info_t *const  export_profile 
)
static

◆ filmic_v5()

◆ flags()

◆ get_pixel_norm()

static float get_pixel_norm ( const dt_aligned_pixel_t  pixel,
const dt_iop_filmicrgb_methods_type_t  variant,
const dt_iop_order_iccprofile_info_t *const  work_profile 
)
inlinestatic

◆ get_pixel_norm_simd()

◆ get_scales()

◆ gui_changed()

◆ gui_focus()

void gui_focus ( struct dt_iop_module_t self,
gboolean  in 
)

◆ gui_init()

◆ gui_reset()

void gui_reset ( dt_iop_module_t self)

◆ gui_update()

void gui_update ( dt_iop_module_t self)

Refresh GUI controls from current params and configuration.

Todo:
check why needed
Todo:
by hand

References dt_conf_get_int(), dt_iop_color_picker_reset(), FALSE, filmic_gui_sync_toe_shoulder(), g, gui_changed(), dt_iop_module_t::gui_data, p, dt_iop_module_t::params, and TRUE.

◆ init_global()

◆ init_pipe()

◆ init_reconstruct()

static void init_reconstruct ( const float *const restrict  in,
const float *const restrict  mask,
float *const restrict  reconstructed,
const size_t  width,
const size_t  height 
)
inlinestatic

References c, for_each_channel, height, and width.

Referenced by reconstruct_highlights().

◆ inpaint_noise()

static void inpaint_noise ( const float *const  in,
const float *const  mask,
float *const  inpainted,
const float  noise_level,
const float  threshold,
const dt_noise_distribution_t  noise_distribution,
const size_t  width,
const size_t  height 
)
inlinestatic

◆ input_format()

◆ legacy_params()

int legacy_params ( dt_iop_module_t self,
const void *const  old_params,
const int  old_version,
void new_params,
const int  new_version 
)

◆ linear_saturation()

static float linear_saturation ( const float  x,
const float  luminance,
const float  saturation 
)
inlinestatic

◆ log_tonemapping()

static float log_tonemapping ( const float  x,
const float  grey,
const float  black,
const float  dynamic_range 
)
inlinestatic

◆ mask_clipped_pixels()

static __DT_CLONE_TARGETS__ gint mask_clipped_pixels ( const float *const restrict  in,
float *const restrict  mask,
const float  normalize,
const float  feathering,
const size_t  width,
const size_t  height,
const size_t  ch 
)
inlinestatic

References clamp_simd(), height, normalize(), sqf(), weight(), and width.

Referenced by process().

◆ name()

const char * name ( )

◆ pixel_rgb_norm_power()

static float pixel_rgb_norm_power ( const dt_aligned_pixel_t  pixel)
inlinestatic

◆ pixel_rgb_norm_power_simd()

static float pixel_rgb_norm_power_simd ( const dt_aligned_pixel_simd_t  pixel)
inlinestatic

References c, and value.

Referenced by get_pixel_norm_simd(), and pixel_rgb_norm_power().

◆ process()

int process ( dt_iop_module_t self,
const dt_dev_pixelpipe_t pipe,
const dt_dev_pixelpipe_iop_t piece,
const void *const restrict  ivoid,
void *const restrict  ovoid 
)

The log2(x) -> -INF when x -> 0 thus very low values (noise) will get even lower, resulting in noise negative amplification, which leads to pepper noise in shadows. To avoid that, we need to clip values that are noise for sure. Using 16 bits RAW data, the black value (known by rawspeed for every manufacturer) could be used as a threshold. However, at this point of the pixelpipe, the RAW levels have already been corrected and everything can happen with black levels in the exposure module. So we define the threshold as the first non-null 16 bit integer

References compute_ratios(), dt_dev_pixelpipe_iop_t::data, dt_iop_module_t::dev, display_mask(), DT_DEV_PIXELPIPE_DISPLAY_MASK, DT_DEV_PIXELPIPE_FULL, DT_FILMIC_COLORSCIENCE_V1, DT_FILMIC_COLORSCIENCE_V2, DT_FILMIC_COLORSCIENCE_V3, DT_FILMIC_COLORSCIENCE_V4, DT_FILMIC_COLORSCIENCE_V5, DT_FILMIC_METHOD_EUCLIDEAN_NORM_V1, DT_FILMIC_METHOD_NONE, DT_FILMIC_RECONSTRUCT_RATIOS, DT_FILMIC_RECONSTRUCT_RGB, dt_iop_alpha_copy(), dt_ioppr_get_pipe_output_profile_info(), dt_ioppr_get_pipe_work_profile_info(), dt_pixelpipe_cache_alloc_align_float, dt_pixelpipe_cache_free_align, filmic_chroma_v1(), filmic_chroma_v2_v3(), filmic_chroma_v4(), filmic_split_v1(), filmic_split_v2_v3(), filmic_split_v4(), filmic_v5(), g, dt_develop_t::gui_attached, dt_iop_module_t::gui_data, dt_iop_roi_t::height, dt_iop_filmicrgb_data_t::high_quality_reconstruction, i, inpaint_noise(), mask_clipped_pixels(), dt_dev_pixelpipe_t::mask_display, dt_iop_filmicrgb_data_t::noise_distribution, dt_iop_filmicrgb_data_t::noise_level, dt_iop_filmicrgb_data_t::normalize, out, dt_iop_filmicrgb_data_t::output_power, dt_iop_filmicrgb_data_t::preserve_color, dt_iop_filmicrgb_data_t::reconstruct_feather, reconstruct_highlights(), dt_iop_filmicrgb_data_t::reconstruct_threshold, restore_ratios(), dt_dev_pixelpipe_iop_t::roi_in, dt_dev_pixelpipe_iop_t::roi_out, dt_iop_roi_t::scale, dt_dev_pixelpipe_t::type, dt_iop_filmicrgb_data_t::version, and dt_iop_roi_t::width.

◆ reconstruct_highlights()

◆ reload_defaults()

void reload_defaults ( dt_iop_module_t module)

◆ restore_ratios()

static void restore_ratios ( float *const restrict  ratios,
const float *const restrict  norms,
const size_t  width,
const size_t  height 
)
inlinestatic

◆ show_mask_callback()

◆ tiling_callback()

void tiling_callback ( struct dt_iop_module_t self,
const struct dt_dev_pixelpipe_t pipe,
const struct dt_dev_pixelpipe_iop_t piece,
struct dt_develop_tiling_t tiling 
)
Todo:
: check if that's sufficiently large

References get_scales(), and dt_dev_pixelpipe_iop_t::roi_in.

◆ toe_shoulder_callback()

◆ wavelets_detail_level()

static __DT_CLONE_TARGETS__ void wavelets_detail_level ( const float *const restrict  detail,
const float *const restrict  LF,
float *const restrict  HF,
float *const restrict  texture,
const size_t  width,
const size_t  height,
const size_t  ch 
)
inlinestatic

References c, height, and width.

Referenced by reconstruct_highlights().

◆ wavelets_reconstruct_ratios()

static __DT_CLONE_TARGETS__ void wavelets_reconstruct_ratios ( const float *const restrict  HF,
const float *const restrict  LF,
const float *const restrict  texture,
const float *const restrict  mask,
float *const restrict  reconstructed,
const size_t  width,
const size_t  height,
const size_t  ch,
const float  gamma,
const float  gamma_comp,
const float  beta,
const float  beta_comp,
const float  delta,
const size_t  s,
const size_t  scales 
)
inlinestatic

References c, delta, fmaxabsf(), height, and width.

Referenced by reconstruct_highlights().

◆ wavelets_reconstruct_RGB()

static __DT_CLONE_TARGETS__ void wavelets_reconstruct_RGB ( const float *const restrict  HF,
const float *const restrict  LF,
const float *const restrict  texture,
const float *const restrict  mask,
float *const restrict  reconstructed,
const size_t  width,
const size_t  height,
const size_t  ch,
const float  gamma,
const float  gamma_comp,
const float  beta,
const float  beta_comp,
const float  delta,
const size_t  s,
const size_t  scales 
)
inlinestatic

References c, delta, fmaxabsf(), height, and width.

Referenced by reconstruct_highlights().