Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
gather.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2010 Bruce Guenter.
4 Copyright (C) 2010-2011 Henrik Andersson.
5 Copyright (C) 2010-2014, 2016 johannes hanika.
6 Copyright (C) 2010 Stuart Henderson.
7 Copyright (C) 2011 Antony Dovgal.
8 Copyright (C) 2011 Robert Bieber.
9 Copyright (C) 2011-2014, 2016, 2019 Tobias Ellinghaus.
10 Copyright (C) 2011-2012, 2014, 2016-2017 Ulrich Pegelow.
11 Copyright (C) 2012, 2015 Edouard Gomez.
12 Copyright (C) 2012 Jérémy Rosen.
13 Copyright (C) 2012 Richard Wonka.
14 Copyright (C) 2013, 2020 Aldric Renaudin.
15 Copyright (C) 2014, 2016 Dan Torop.
16 Copyright (C) 2014-2016 Roman Lebedev.
17 Copyright (C) 2015-2016 Pedro Côrte-Real.
18 Copyright (C) 2017 Heiko Bauke.
19 Copyright (C) 2017 luzpaz.
20 Copyright (C) 2018, 2020-2026 Aurélien PIERRE.
21 Copyright (C) 2018 Edgardo Hoszowski.
22 Copyright (C) 2018 Maurizio Paglia.
23 Copyright (C) 2018-2020, 2022 Pascal Obry.
24 Copyright (C) 2018 rawfiner.
25 Copyright (C) 2019 Andreas Schneider.
26 Copyright (C) 2019 Diederik ter Rahe.
27 Copyright (C) 2019-2020, 2022 Hanno Schwalm.
28 Copyright (C) 2020 Chris Elston.
29 Copyright (C) 2020, 2022 Diederik Ter Rahe.
30 Copyright (C) 2020-2021 Ralf Brown.
31 Copyright (C) 2021 Hubert Kowalski.
32 Copyright (C) 2022 Martin Bařinka.
33 Copyright (C) 2022 Philipp Lutz.
34 Copyright (C) 2022 Victor Forsiuk.
35 Copyright (C) 2023 Alynx Zhou.
36 Copyright (C) 2023 Guillaume Stutin.
37 Copyright (C) 2023 Luca Zulberti.
38
39 darktable is free software: you can redistribute it and/or modify
40 it under the terms of the GNU General Public License as published by
41 the Free Software Foundation, either version 3 of the License, or
42 (at your option) any later version.
43
44 darktable is distributed in the hope that it will be useful,
45 but WITHOUT ANY WARRANTY; without even the implied warranty of
46 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47 GNU General Public License for more details.
48
49 You should have received a copy of the GNU General Public License
50 along with darktable. If not, see <http://www.gnu.org/licenses/>.
51 */
52
53#ifndef DT_IOP_HIGHLIGHTS_GATHER_H
54#define DT_IOP_HIGHLIGHTS_GATHER_H
55
56// Shared CFA gather/remosaic helpers (bilinear interpolation + clip masks, laplacian
57// normalization channel, remosaic to CFA). Public API of the gather TU; see gather.c.
58
59#include <stdint.h>
60
61// CFA reconstruction strategy. It selects ONLY how the disposable demosaic (the gather) and the
62// remosaic (the scatter) run; everything between them -- the knee, the segmentation and the
63// per-region reconstruction -- is CFA-agnostic and shared. PASSTHROUGH is the non-raw case: the
64// input is already demosaiced RGB (a rendered image or a linear-DNG/sRAW 4-channel buffer), so the
65// gather is a plane copy and the remosaic writes the reconstructed pixels straight back.
66typedef enum dt_hl_cfa_t
67{
68 HL_CFA_BAYER = 0, // Bayer mosaic: filters != 0 and != 9u
69 HL_CFA_XTRANS, // X-Trans mosaic: filters == 9u
70 HL_CFA_PASSTHROUGH, // already-RGB input (non-raw / sRAW): filters == 0
72
73// Map the (roi-shifted) CFA descriptor word to the gather/remosaic strategy above.
74static inline dt_hl_cfa_t _hl_cfa_strategy(const uint32_t filters)
75{
76 if(filters == 0u) return HL_CFA_PASSTHROUGH;
77 if(filters == 9u) return HL_CFA_XTRANS;
78 return HL_CFA_BAYER;
79}
80
81void _interpolate_and_mask(const float *const restrict input, float *const restrict interpolated,
82 float *const restrict clipping_mask, const dt_aligned_pixel_t clips_in,
83 const dt_aligned_pixel_t det_scale, const dt_aligned_pixel_t white_balance,
84 const uint32_t filters, const size_t width, const size_t height);
85
93void _compute_laplacian_normalization(const float *const restrict input, const dt_iop_roi_t *const roi_in,
94 const uint32_t filters, const uint8_t (*const xtrans)[6],
95 dt_aligned_pixel_t normalization);
96
103void _build_xtrans_bilinear_lookup(int32_t lookup[6][6][32], const dt_iop_roi_t *const roi_in,
104 const uint8_t (*const xtrans)[6]);
105
112void _interpolate_and_mask_xtrans(const float *const restrict input, float *const restrict interpolated,
113 float *const restrict clipping_mask, const dt_aligned_pixel_t clips,
114 const dt_aligned_pixel_t white_balance, const dt_iop_roi_t *const roi_in,
115 const int32_t lookup[6][6][32], const uint8_t (*const xtrans)[6],
116 const size_t width, const size_t height);
117
125void _interpolate_and_mask_passthrough(const float *const restrict input, float *const restrict interpolated,
126 float *const restrict clipping_mask, const dt_aligned_pixel_t clips,
127 const dt_aligned_pixel_t white_balance, const size_t width,
128 const size_t height);
129
130void _remosaic_and_replace(const float *const restrict input, const float *const restrict input_raw,
131 const float *const restrict interpolated, const float *const restrict clipping_mask,
132 float *const restrict output, const dt_aligned_pixel_t white_balance,
133 const dt_aligned_pixel_t clips, const int clip_is_floor, const uint32_t filters,
134 const size_t width, const size_t height);
135
144void _remosaic_and_replace_passthrough(const float *const restrict input, const float *const restrict input_raw,
145 const float *const restrict interpolated,
146 const float *const restrict clipping_mask, float *const restrict output,
147 const dt_aligned_pixel_t white_balance, const dt_aligned_pixel_t clips,
148 const int clip_is_floor, const size_t width, const size_t height);
149
151void _remosaic_and_replace_xtrans(const float *const restrict input, const float *const restrict input_raw,
152 const float *const restrict interpolated,
153 const float *const restrict clipping_mask, float *const restrict output,
154 const dt_aligned_pixel_t white_balance, const dt_aligned_pixel_t clips,
155 const int clip_is_floor, const dt_iop_roi_t *const roi_in,
156 const uint8_t (*const xtrans)[6], const size_t width, const size_t height);
157#endif // DT_IOP_HIGHLIGHTS_GATHER_H
static float lookup(read_only image2d_t lut, const float x)
static dt_hl_cfa_t _hl_cfa_strategy(const uint32_t filters)
Definition gather.h:74
void _build_xtrans_bilinear_lookup(int32_t lookup[6][6][32], const dt_iop_roi_t *const roi_in, const uint8_t(*const xtrans)[6])
Definition gather.c:277
void _interpolate_and_mask_xtrans(const float *const restrict input, float *const restrict interpolated, float *const restrict clipping_mask, const dt_aligned_pixel_t clips, const dt_aligned_pixel_t white_balance, const dt_iop_roi_t *const roi_in, const int32_t lookup[6][6][32], const uint8_t(*const xtrans)[6], const size_t width, const size_t height)
Definition gather.c:317
void _compute_laplacian_normalization(const float *const restrict input, const dt_iop_roi_t *const roi_in, const uint32_t filters, const uint8_t(*const xtrans)[6], dt_aligned_pixel_t normalization)
Definition gather.c:223
void _remosaic_and_replace_passthrough(const float *const restrict input, const float *const restrict input_raw, const float *const restrict interpolated, const float *const restrict clipping_mask, float *const restrict output, const dt_aligned_pixel_t white_balance, const dt_aligned_pixel_t clips, const int clip_is_floor, const size_t width, const size_t height)
Definition gather.c:514
void _interpolate_and_mask_passthrough(const float *const restrict input, float *const restrict interpolated, float *const restrict clipping_mask, const dt_aligned_pixel_t clips, const dt_aligned_pixel_t white_balance, const size_t width, const size_t height)
Definition gather.c:424
void _remosaic_and_replace(const float *const restrict input, const float *const restrict input_raw, const float *const restrict interpolated, const float *const restrict clipping_mask, float *const restrict output, const dt_aligned_pixel_t white_balance, const dt_aligned_pixel_t clips, const int clip_is_floor, const uint32_t filters, const size_t width, const size_t height)
Definition gather.c:457
void _remosaic_and_replace_xtrans(const float *const restrict input, const float *const restrict input_raw, const float *const restrict interpolated, const float *const restrict clipping_mask, float *const restrict output, const dt_aligned_pixel_t white_balance, const dt_aligned_pixel_t clips, const int clip_is_floor, const dt_iop_roi_t *const roi_in, const uint8_t(*const xtrans)[6], const size_t width, const size_t height)
Definition gather.c:488
void _interpolate_and_mask(const float *const restrict input, float *const restrict interpolated, float *const restrict clipping_mask, const dt_aligned_pixel_t clips_in, const dt_aligned_pixel_t det_scale, const dt_aligned_pixel_t white_balance, const uint32_t filters, const size_t width, const size_t height)
Definition gather.c:67
dt_hl_cfa_t
Definition gather.h:67
@ HL_CFA_PASSTHROUGH
Definition gather.h:70
@ HL_CFA_BAYER
Definition gather.h:68
@ HL_CFA_XTRANS
Definition gather.h:69
uint32_t width
Definition mipmap_cache.c:0
uint32_t height
Definition mipmap_cache.c:1
DT_ALIGNED_PIXEL float dt_aligned_pixel_t[4]
Definition simd.h:53
Region of interest passed through the pixelpipe.
Definition format.h:49