Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
conversion.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2025 Aurélien PIERRE.
4
5 darktable is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 darktable is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with darktable. If not, see <http://www.gnu.org/licenses/>.
17*/
18
54#ifndef DT_COLORPROFILES_CONVERSION_H
55#define DT_COLORPROFILES_CONVERSION_H
56
57#include <glib.h>
58#include <stddef.h>
59#include <stdint.h>
60
62#include "math/matrices.h"
63
67#define DT_CONVERSION_LUT_SAMPLES 0x10000
68
70
77
107
133
164 const dt_colorspaces_endpoint_t *const to,
165 const dt_colorspaces_endpoint_t *const clip,
166 const dt_colorspaces_endpoint_t *const proof,
167 const dt_iop_color_intent_t intent,
169
178
191typedef void (*dt_colorspaces_conversion_hook_t)(const float *const in, float *const out);
192
210 const float *const in, float *const out,
211 const size_t width, const size_t height);
212
221 const float *const in, float *const out,
222 const size_t width, const size_t height,
224
225/* --- What a device kernel needs -------------------------------------------
226 *
227 * A GPU kernel cannot call back into this module, so the numbers a conversion reduced to have
228 * to be readable to upload them. These accessors are for that and nothing else: they are the
229 * seam where the module hands a caller's own kernel its arguments, not a way to re-implement
230 * apply on the host. A caller that finds itself running a matrix multiply from
231 * dt_colorspaces_conversion_matrix() on the CPU has taken the wrong entry point.
232 */
233
255
264
271
285
302
312
324 const int channel);
325
331 const int channel);
332
340const float *dt_colorspaces_conversion_source_coeffs(const dt_colorspaces_conversion_t *const conversion);
341
345const float *dt_colorspaces_conversion_target_coeffs(const dt_colorspaces_conversion_t *const conversion);
346
347#endif // DT_COLORPROFILES_CONVERSION_H
348
349// clang-format off
350// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
351// vim: shiftwidth=2 expandtab tabstop=2 cindent
352// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
353// clang-format on
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
const dt_colormatrix_t dt_aligned_pixel_t out
const dt_colormatrix_t matrix
const float * dt_colorspaces_conversion_source_coeffs(const dt_colorspaces_conversion_t *const conversion)
The 3x3 power-law fits extrapolating the source curves past white, as one flat array of 9 floats in c...
Definition conversion.c:818
void dt_colorspaces_apply_conversion_hooked(const dt_colorspaces_conversion_t *const conversion, const float *const in, float *const out, const size_t width, const size_t height, const dt_colorspaces_conversion_hook_t hook)
dt_colorspaces_apply_conversion() with a per-pixel hook. See dt_colorspaces_conversion_hook_t for why...
Definition conversion.c:744
gboolean dt_colorspaces_conversion_has_clipping(const dt_colorspaces_conversion_t *const conversion)
Whether the conversion has a gamut-clipping stage, i.e. whether a clip endpoint was given AND survive...
Definition conversion.c:775
gboolean dt_colorspaces_conversion_matrix(const dt_colorspaces_conversion_t *const conversion, dt_colormatrix_t matrix)
The composed source-to-target matrix, row-major.
Definition conversion.c:780
const float * dt_colorspaces_conversion_target_curve(const dt_colorspaces_conversion_t *const conversion, const int channel)
One channel of the target encoding curves. Same contract as dt_colorspaces_conversion_source_curve().
Definition conversion.c:811
gboolean dt_colorspaces_conversion_is_matrix(const dt_colorspaces_conversion_t *const conversion)
Whether the conversion reduced to matrices and curves, and can therefore be run by a device kernel at...
Definition conversion.c:770
const float * dt_colorspaces_conversion_target_coeffs(const dt_colorspaces_conversion_t *const conversion)
The same fits for the target curves. Same contract.
Definition conversion.c:824
uint64_t dt_colorspaces_conversion_identity(const dt_colorspaces_conversion_t *const conversion)
What this conversion IS, as a number: equal for two conversions that render the same pixels,...
Definition conversion.c:503
gboolean dt_colorspaces_conversion_source_matrix(const dt_colorspaces_conversion_t *const conversion, dt_colormatrix_t matrix)
The SOURCE profile's own RGB -> XYZ (D50) matrix, before composition.
Definition conversion.c:788
const float * dt_colorspaces_conversion_source_curve(const dt_colorspaces_conversion_t *const conversion, const int channel)
One channel of the source decoding curves, DT_CONVERSION_LUT_SAMPLES entries.
Definition conversion.c:804
void dt_colorspaces_free_conversion(dt_colorspaces_conversion_t **conversion)
Release a conversion and NULL the caller's pointer.
Definition conversion.c:508
gboolean dt_colorspaces_conversion_clip_matrix(const dt_colorspaces_conversion_t *const conversion, dt_colormatrix_t matrix)
The clip-to-target matrix, the second leg of a clipping conversion.
Definition conversion.c:796
dt_colorspaces_conversion_t * dt_colorspaces_prepare_conversion(const dt_colorspaces_endpoint_t *const from, const dt_colorspaces_endpoint_t *const to, const dt_colorspaces_endpoint_t *const clip, const dt_colorspaces_endpoint_t *const proof, const dt_iop_color_intent_t intent, const dt_colorspaces_conversion_flags_t flags)
Build a conversion from from to to. The expensive call; do it once.
Definition conversion.c:216
dt_colorspaces_conversion_flags_t
What the caller wants, and what the caller can consume.
Definition conversion.h:118
@ DT_CONVERSION_NONE
Definition conversion.h:119
@ DT_CONVERSION_FORCE_LCMS2
Never take the matrix path, even when both profiles reduce to matrices. Backs the plugins/lighttable/...
Definition conversion.h:122
@ DT_CONVERSION_SOURCE_CURVES
The caller can apply the SOURCE profile's decoding curves before the matrix. Without this,...
Definition conversion.h:125
@ DT_CONVERSION_GAMUTCHECK
Mark out-of-gamut pixels rather than merely proofing them. Requires a soft-proof endpoint,...
Definition conversion.h:131
@ DT_CONVERSION_TARGET_CURVES
The caller can apply the TARGET profile's encoding curves after the matrix. Without this,...
Definition conversion.h:128
void dt_colorspaces_apply_conversion(const dt_colorspaces_conversion_t *const conversion, const float *const in, float *const out, const size_t width, const size_t height)
Convert a 4-channel float image through a prepared conversion.
Definition conversion.c:762
void(* dt_colorspaces_conversion_hook_t)(const float *const in, float *const out)
A per-pixel hook run between the source curves and the colour conversion proper.
Definition conversion.h:191
float DT_ALIGNED_ARRAY dt_colormatrix_t[4][4]
Definition matrices.h:34
uint32_t width
Definition mipmap_cache.c:0
uint32_t height
Definition mipmap_cache.c:1
dt_mipmap_buffer_dsc_flags flags
Definition mipmap_cache.c:4
The colour-profile vocabulary, and nothing else.
dt_iop_color_intent_t
ICC rendering intent, as stored in iop params and in conf.
dt_colorspaces_color_profile_type_t
dt_colorspaces_profile_role_t
Which use a profile is eligible for – the mandatory filter on every lookup and enumeration.
unsigned __int64 uint64_t
Definition strptime.c:75
One registered profile: its identity, its LCMS handle, and where it sits in each combo box.
One end of a conversion: a profile, named either by identity or by handing over one this module alrea...
Definition conversion.h:93
dt_colorspaces_profile_role_t role
Which role the identity is looked up under. Load-bearing, never a formality: DT_COLORSPACE_SRGB is re...
Definition conversion.h:102
const struct dt_colorspaces_color_profile_t * resolved
An already-resolved, image-owned profile, or NULL to resolve type / filename from the registered list...
Definition conversion.h:105
dt_colorspaces_color_profile_type_t type
Profile identity. Ignored when resolved is set, except for tracing.
Definition conversion.h:95
const char * filename
ICC file name, or "" / NULL for a built-in. Ignored when resolved is set.
Definition conversion.h:97