Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
gamma.c File Reference
#include "develop/imageop_gui.h"
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "common/colorspaces_inline_conversions.h"
#include "common/opencl.h"
#include "develop/develop.h"
#include "iop/iop_api.h"
#include "widgets/widget_settings.h"
+ Include dependency graph for gamma.c:

Go to the source code of this file.

Data Structures

struct  dt_iop_gamma_params_t
 This module converts float32 RGBA pixels to uint8 BGRA pixels, for GUI pipelines only (darkroom main preview and navigation thumbnail). It self-disables for export pipelines. More...
 
struct  dt_iop_gamma_global_data_t
 
struct  dt_iop_gamma_mask_preview_t
 Shared appearance of mask previews rendered by the display encoding module. More...
 
struct  dt_iop_gamma_data_t
 Everything the two process() paths need, settled once per commit_params(). More...
 

Typedefs

typedef struct dt_iop_gamma_params_t dt_iop_gamma_params_t
 This module converts float32 RGBA pixels to uint8 BGRA pixels, for GUI pipelines only (darkroom main preview and navigation thumbnail). It self-disables for export pipelines.
 
typedef struct dt_iop_gamma_global_data_t dt_iop_gamma_global_data_t
 
typedef enum dt_iop_gamma_kernel_mode_t dt_iop_gamma_kernel_mode_t
 
typedef enum dt_iop_gamma_false_color_t dt_iop_gamma_false_color_t
 
typedef struct dt_iop_gamma_mask_preview_t dt_iop_gamma_mask_preview_t
 Shared appearance of mask previews rendered by the display encoding module.
 
typedef struct dt_iop_gamma_data_t dt_iop_gamma_data_t
 Everything the two process() paths need, settled once per commit_params().
 

Enumerations

enum  dt_iop_gamma_kernel_mode_t {
  DT_IOP_GAMMA_KERNEL_COPY = 0 ,
  DT_IOP_GAMMA_KERNEL_MASK = 1 ,
  DT_IOP_GAMMA_KERNEL_CHANNEL_MONO = 2 ,
  DT_IOP_GAMMA_KERNEL_CHANNEL_FALSE_COLOR = 3
}
 
enum  dt_iop_gamma_false_color_t {
  DT_IOP_GAMMA_FALSE_COLOR_MONO = 0 ,
  DT_IOP_GAMMA_FALSE_COLOR_A = 1 ,
  DT_IOP_GAMMA_FALSE_COLOR_B = 2 ,
  DT_IOP_GAMMA_FALSE_COLOR_R = 3 ,
  DT_IOP_GAMMA_FALSE_COLOR_G = 4 ,
  DT_IOP_GAMMA_FALSE_COLOR_B_CH = 5 ,
  DT_IOP_GAMMA_FALSE_COLOR_C = 6 ,
  DT_IOP_GAMMA_FALSE_COLOR_LCH_H = 7 ,
  DT_IOP_GAMMA_FALSE_COLOR_HSL_H = 8 ,
  DT_IOP_GAMMA_FALSE_COLOR_JZ_HZ = 9
}
 

Functions

const char * name ()
 
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)
 
void output_format (dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece, dt_iop_buffer_dsc_t *dsc)
 
static void _write_pixel (const float *const restrict in, uint8_t *const restrict out, const dt_iop_gamma_mask_preview_t *const preview, const size_t pixel_index, const float alpha)
 Blend one linear RGB pixel with its mask checker and encode it for display.
 
 __OMP_DECLARE_SIMD__ (aligned(pixel:16) uniform(norm))
 
 __OMP_DECLARE_SIMD__ (aligned(XYZ, sRGB:16) uniform(norm))
 
static __DT_CLONE_TARGETS__ void _channel_display_monochrome (const float *const restrict in, uint8_t *const restrict out, const size_t buffsize, const float alpha, const dt_iop_gamma_mask_preview_t *const preview)
 
static __DT_CLONE_TARGETS__ void _channel_display_false_color (const float *const restrict in, uint8_t *const restrict out, const size_t buffsize, const float alpha, dt_dev_pixelpipe_display_mask_t channel, const dt_iop_gamma_mask_preview_t *const preview)
 
static __DT_CLONE_TARGETS__ void _mask_display (const float *const restrict in, uint8_t *const restrict out, const size_t buffsize, const float alpha, const dt_iop_gamma_mask_preview_t *const preview)
 
static __DT_CLONE_TARGETS__ void _copy_output (const float *const restrict in, uint8_t *const restrict out, const size_t buffsize)
 
int process (struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const i, void *const o)
 
static int _false_color_channel_to_kernel_code (const dt_dev_pixelpipe_display_mask_t mask_display)
 
int process_cl (struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out)
 
void init_global (dt_iop_module_so_t *module)
 
void cleanup_global (dt_iop_module_so_t *module)
 
void init (dt_iop_module_t *module)
 
gboolean runtime_data_hash (struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
 
void init_pipe (struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
void cleanup_pipe (struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
void commit_params (dt_iop_module_t *self, dt_iop_params_t *params, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 

Typedef Documentation

◆ dt_iop_gamma_data_t

Everything the two process() paths need, settled once per commit_params().

Display encoding is the LAST node of every darkroom frame, so whatever it reads is paid at the frame rate, on every interaction. All of this describes the mask-preview checkerboard and the false-colour channel display, and every field of it used to be read from conf inside process()/process_cl() – six of them through dt_conf_get_float(), which runs dt_calculator_solve() over the stored string on EVERY call: an expression parser, per value, per frame, for a checkerboard an ordinary frame never draws.

Reading application-level configuration is not a pipeline filter's job in the first place. commit_params() is where a node's effective contract is settled, and iop/colorbalancergb.c already settles these same keys there; this module is the other half of the same preview and had simply never been moved.

What makes that safe is runtime_data_hash() (iop/iop_api.h): it folds the first piece->data_size bytes into the cache key, so a settled value that changes re-keys this node instead of being silently served from a cacheline that no longer describes it. The struct therefore holds CONTENT only and no pointers at all – see the api doc for why a pointer in the hashed prefix is wrong in both directions (issue #1145).

preview.width is the ROI's, not a setting: it stays 0 here and is filled per call.

◆ dt_iop_gamma_false_color_t

◆ dt_iop_gamma_global_data_t

◆ dt_iop_gamma_kernel_mode_t

◆ dt_iop_gamma_mask_preview_t

Shared appearance of mask previews rendered by the display encoding module.

The checker colors remain in linear RGB until they are blended with the image so this path matches module-authored previews that continue through display encoding.

◆ dt_iop_gamma_params_t

This module converts float32 RGBA pixels to uint8 BGRA pixels, for GUI pipelines only (darkroom main preview and navigation thumbnail). It self-disables for export pipelines.

Enumeration Type Documentation

◆ dt_iop_gamma_false_color_t

Enumerator
DT_IOP_GAMMA_FALSE_COLOR_MONO 
DT_IOP_GAMMA_FALSE_COLOR_A 
DT_IOP_GAMMA_FALSE_COLOR_B 
DT_IOP_GAMMA_FALSE_COLOR_R 
DT_IOP_GAMMA_FALSE_COLOR_G 
DT_IOP_GAMMA_FALSE_COLOR_B_CH 
DT_IOP_GAMMA_FALSE_COLOR_C 
DT_IOP_GAMMA_FALSE_COLOR_LCH_H 
DT_IOP_GAMMA_FALSE_COLOR_HSL_H 
DT_IOP_GAMMA_FALSE_COLOR_JZ_HZ 

Definition at line 90 of file gamma.c.

◆ dt_iop_gamma_kernel_mode_t

Enumerator
DT_IOP_GAMMA_KERNEL_COPY 
DT_IOP_GAMMA_KERNEL_MASK 
DT_IOP_GAMMA_KERNEL_CHANNEL_MONO 
DT_IOP_GAMMA_KERNEL_CHANNEL_FALSE_COLOR 

Definition at line 82 of file gamma.c.

Function Documentation

◆ __OMP_DECLARE_SIMD__() [1/2]

__OMP_DECLARE_SIMD__ ( aligned(pixel:16) uniform(norm)  )

Definition at line 217 of file gamma.c.

References factor, for_each_channel, and x.

◆ __OMP_DECLARE_SIMD__() [2/2]

__OMP_DECLARE_SIMD__ ( aligned(XYZ, sRGB:16) uniform(norm)  )

Definition at line 226 of file gamma.c.

References dt_XYZ_to_Rec709_D50(), sRGB, and XYZ.

◆ _channel_display_false_color()

◆ _channel_display_monochrome()

static __DT_CLONE_TARGETS__ void _channel_display_monochrome ( const float *const restrict  in,
uint8_t *const restrict  out,
const size_t  buffsize,
const float  alpha,
const dt_iop_gamma_mask_preview_t *const  preview 
)
static

Definition at line 234 of file gamma.c.

References __OMP_PARALLEL_FOR_SIMD__, _write_pixel(), out, and preview.

Referenced by _channel_display_false_color(), and process().

◆ _copy_output()

static __DT_CLONE_TARGETS__ void _copy_output ( const float *const restrict  in,
uint8_t *const restrict  out,
const size_t  buffsize 
)
static

Definition at line 382 of file gamma.c.

References __OMP_PARALLEL_FOR_SIMD__, and out.

Referenced by process().

◆ _false_color_channel_to_kernel_code()

◆ _mask_display()

static __DT_CLONE_TARGETS__ void _mask_display ( const float *const restrict  in,
uint8_t *const restrict  out,
const size_t  buffsize,
const float  alpha,
const dt_iop_gamma_mask_preview_t *const  preview 
)
static

Definition at line 364 of file gamma.c.

References __OMP_PARALLEL_FOR_SIMD__, _write_pixel(), out, and preview.

Referenced by process().

◆ _write_pixel()

static void _write_pixel ( const float *const restrict  in,
uint8_t *const restrict  out,
const dt_iop_gamma_mask_preview_t *const  preview,
const size_t  pixel_index,
const float  alpha 
)
inlinestatic

Blend one linear RGB pixel with its mask checker and encode it for display.

Definition at line 191 of file gamma.c.

References out, preview, value, and x.

Referenced by _channel_display_false_color(), _channel_display_monochrome(), and _mask_display().

◆ cleanup_global()

◆ cleanup_pipe()

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

Definition at line 608 of file gamma.c.

References dt_free_align, and piece.

◆ commit_params()

◆ default_colorspace()

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

Definition at line 120 of file gamma.c.

References IOP_CS_RGB_DISPLAY.

◆ default_group()

int default_group ( )

Definition at line 110 of file gamma.c.

References IOP_GROUP_TECHNICAL.

◆ flags()

int flags ( )

◆ init()

void init ( dt_iop_module_t *  module)

Definition at line 582 of file gamma.c.

◆ init_global()

void init_global ( dt_iop_module_so_t *  module)

◆ init_pipe()

void init_pipe ( struct dt_iop_module_t *  self,
dt_dev_pixelpipe_t *  pipe,
dt_dev_pixelpipe_iop_t *  piece 
)

Definition at line 602 of file gamma.c.

References dt_calloc_align(), IS_NULL_PTR, and piece.

◆ input_format()

◆ name()

const char * name ( )

Definition at line 105 of file gamma.c.

◆ output_format()

◆ process()

◆ process_cl()

◆ runtime_data_hash()

gboolean runtime_data_hash ( struct dt_iop_module_t *  self,
dt_dev_pixelpipe_t *  pipe,
const dt_dev_pixelpipe_iop_t *  piece 
)

Definition at line 596 of file gamma.c.

References TRUE.