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
 

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
 

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, dt_dev_pixelpipe_iop_t *piece)
 
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 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 (const dt_aligned_pixel_t pixel)
 
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 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 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 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 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 gint 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, 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 void pipe_RGB_to_Ych (const dt_aligned_pixel_t in, const dt_colormatrix_t matrix, dt_aligned_pixel_t out)
 
static void Ych_to_pipe_RGB (const dt_aligned_pixel_t in, const dt_colormatrix_t matrix, dt_aligned_pixel_t out)
 
static void filmic_desaturate_v4 (const dt_aligned_pixel_t Ych_original, dt_aligned_pixel_t Ych_final, const float saturation)
 
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 void gamut_check_RGB (const dt_colormatrix_t matrix_in, const dt_colormatrix_t matrix_out, const float display_black, const float display_white, const dt_aligned_pixel_t Ych_in, dt_aligned_pixel_t RGB_out)
 
static void gamut_mapping (dt_aligned_pixel_t Ych_final, dt_aligned_pixel_t Ych_original, dt_aligned_pixel_t pix_out, 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, const float display_black, const float display_white, const float saturation, const int use_output_profile)
 
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 norm_tone_mapping_v4 (const dt_aligned_pixel_t pix_in, dt_aligned_pixel_t pix_out, const dt_iop_filmicrgb_methods_type_t type, 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 float norm_min, const float norm_max, const float display_black, const float display_white)
 
static void RGB_tone_mapping_v4 (const dt_aligned_pixel_t pix_in, dt_aligned_pixel_t pix_out, const dt_iop_filmicrgb_data_t *const data, const dt_iop_filmic_rgb_spline_t spline, const float display_black, const float display_white)
 
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, struct dt_dev_pixelpipe_iop_t *piece, const dt_iop_roi_t *roi_in, const dt_iop_roi_t *roi_out, struct dt_develop_tiling_t *tiling)
 
void process (dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, const void *const restrict ivoid, void *const restrict ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out)
 
static void apply_auto_grey (dt_iop_module_t *self)
 
static void apply_auto_black (dt_iop_module_t *self)
 
static void apply_auto_white_point_source (dt_iop_module_t *self)
 
static void apply_autotune (dt_iop_module_t *self)
 
void color_picker_apply (dt_iop_module_t *self, GtkWidget *picker, 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)
 
void gui_update (dt_iop_module_t *self)
 
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 the rest is loop reorganization and vectorization optimization

◆ dt_iop_filmicrgb_params_t

◆ dt_iop_filmicrgb_reconstruction_type_t

◆ dt_iop_filmicrgb_spline_version_type_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 the rest is loop reorganization and vectorization optimization

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

◆ aliases()

const char * aliases ( )

◆ apply_auto_black()

◆ apply_auto_grey()

◆ apply_auto_white_point_source()

◆ apply_autotune()

◆ area_button_press()

static gboolean area_button_press ( GtkWidget *  widget,
GdkEventButton *  event,
gpointer  user_data 
)
static

◆ 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

References for_each_channel, get_pixel_norm(), height, NORM_MIN, and width.

Referenced by process().

◆ convert_to_spline_v3()

◆ default_colorspace()

int default_colorspace ( dt_iop_module_t self,
dt_dev_pixelpipe_t pipe,
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 for_each_channel, height, 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()

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 
)
inlinestatic

◆ 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

◆ 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_desaturate_v4()

static void filmic_desaturate_v4 ( const dt_aligned_pixel_t  Ych_original,
dt_aligned_pixel_t  Ych_final,
const float  saturation 
)
inlinestatic

Referenced by gamut_mapping().

◆ filmic_gui_draw_icon()

◆ 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_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()

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 
)
inlinestatic

◆ flags()

◆ gamut_check_RGB()

static void gamut_check_RGB ( const dt_colormatrix_t  matrix_in,
const dt_colormatrix_t  matrix_out,
const float  display_black,
const float  display_white,
const dt_aligned_pixel_t  Ych_in,
dt_aligned_pixel_t  RGB_out 
)
inlinestatic

◆ gamut_mapping()

static void gamut_mapping ( dt_aligned_pixel_t  Ych_final,
dt_aligned_pixel_t  Ych_original,
dt_aligned_pixel_t  pix_out,
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,
const float  display_black,
const float  display_white,
const float  saturation,
const int  use_output_profile 
)
inlinestatic

◆ get_pixel_norm()

◆ 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()

◆ 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 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

◆ 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 
)

References dt_iop_filmicrgb_params_t::auto_hardness, dt_iop_filmicrgb_params_t::balance, dt_iop_filmicrgb_params_t::black_point_source, dt_iop_filmicrgb_params_t::black_point_target, dt_iop_filmicrgb_params_t::compensate_icc_black, dt_iop_filmicrgb_params_t::contrast, convert_to_spline_v3(), dt_iop_filmicrgb_params_t::custom_grey, dt_iop_module_t::default_params, DT_FILMIC_COLORSCIENCE_V1, DT_FILMIC_CURVE_POLY_3, DT_FILMIC_CURVE_POLY_4, DT_FILMIC_SPLINE_VERSION_V1, DT_FILMIC_SPLINE_VERSION_V2, DT_FILMIC_SPLINE_VERSION_V3, FALSE, dt_iop_filmicrgb_params_t::grey_point_source, dt_iop_filmicrgb_params_t::grey_point_target, dt_iop_filmicrgb_params_t::high_quality_reconstruction, dt_iop_filmicrgb_params_t::highlights, dt_iop_filmicrgb_params_t::latitude, dt_iop_filmicrgb_params_t::noise_distribution, dt_iop_filmicrgb_params_t::noise_level, dt_iop_filmicrgb_params_t::output_power, dt_iop_filmicrgb_params_t::preserve_color, dt_iop_filmicrgb_params_t::reconstruct_bloom_vs_details, dt_iop_filmicrgb_params_t::reconstruct_feather, dt_iop_filmicrgb_params_t::reconstruct_grey_vs_color, dt_iop_filmicrgb_params_t::reconstruct_structure_vs_texture, dt_iop_filmicrgb_params_t::reconstruct_threshold, dt_iop_filmicrgb_params_t::saturation, dt_iop_filmicrgb_params_t::security_factor, dt_iop_filmicrgb_params_t::shadows, dt_iop_filmicrgb_params_t::spline_version, TRUE, dt_iop_filmicrgb_params_t::version, dt_iop_filmicrgb_params_t::white_point_source, and dt_iop_filmicrgb_params_t::white_point_target.

◆ 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 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 ( )

◆ norm_tone_mapping_v4()

◆ pipe_RGB_to_Ych()

static void pipe_RGB_to_Ych ( const dt_aligned_pixel_t  in,
const dt_colormatrix_t  matrix,
dt_aligned_pixel_t  out 
)
inlinestatic

◆ pixel_rgb_norm_power()

static float pixel_rgb_norm_power ( const dt_aligned_pixel_t  pixel)
inlinestatic

Referenced by get_pixel_norm().

◆ process()

void process ( dt_iop_module_t self,
dt_dev_pixelpipe_iop_t piece,
const void *const restrict  ivoid,
void *const restrict  ovoid,
const dt_iop_roi_t *const  roi_in,
const dt_iop_roi_t *const  roi_out 
)

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 dt_dev_pixelpipe_iop_t::colors, compute_ratios(), dt_dev_pixelpipe_iop_t::data, dt_iop_module_t::dev, display_mask(), dt_alloc_align_float(), dt_alloc_sse_ps(), dt_control_log(), 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_free_align, dt_iop_alpha_copy(), dt_ioppr_get_pipe_output_profile_info(), dt_ioppr_get_pipe_work_profile_info(), filmic_chroma_v1(), filmic_chroma_v2_v3(), filmic_chroma_v4(), filmic_split_v1(), filmic_split_v2_v3(), filmic_split_v4(), filmic_v5(), dt_develop_t::gui_attached, dt_iop_module_t::gui_data, dt_iop_roi_t::height, dt_iop_filmicrgb_data_t::high_quality_reconstruction, inpaint_noise(), mask_clipped_pixels(), dt_iop_filmicrgb_data_t::noise_distribution, dt_iop_filmicrgb_data_t::noise_level, dt_iop_filmicrgb_data_t::normalize, dt_iop_filmicrgb_data_t::output_power, dt_dev_pixelpipe_iop_t::pipe, 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_iop_roi_t::scale, TRUE, dt_iop_filmicrgb_data_t::version, and dt_iop_roi_t::width.

◆ reconstruct_highlights()

◆ reload_defaults()

◆ restore_ratios()

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

References clamp_simd(), for_each_channel, height, and width.

Referenced by process().

◆ RGB_tone_mapping_v4()

◆ show_mask_callback()

◆ tiling_callback()

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

References get_scales().

◆ wavelets_detail_level()

static 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 height, and width.

Referenced by reconstruct_highlights().

◆ wavelets_reconstruct_ratios()

static 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 fmaxabsf(), height, and width.

Referenced by reconstruct_highlights().

◆ wavelets_reconstruct_RGB()

static 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 fmaxabsf(), height, and width.

Referenced by reconstruct_highlights().

◆ Ych_to_pipe_RGB()

static void Ych_to_pipe_RGB ( const dt_aligned_pixel_t  in,
const dt_colormatrix_t  matrix,
dt_aligned_pixel_t  out 
)
inlinestatic

References dot_product(), Ych_to_Yrg(), and Yrg_to_LMS().

Referenced by gamut_check_RGB().