Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
clip.c
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// Simple highlight-clip and the raw-clip visualization mode. (implementation; see clip.h for the public API.)
54
55#include "system/openmp.h"
58#include "iop/highlights/clip.h"
59#include <string.h>
60
62void process_clip(const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid,
63 const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const float clip)
64{
65 const float *const in = (const float *const)ivoid;
66 float *const out = (float *const)ovoid;
67
68 if(piece->dsc_in.filters)
69 { // raw mosaic
71 for(size_t k = 0; k < (size_t)roi_out->width * roi_out->height; k++)
72 {
73 out[k] = MIN(clip, in[k]);
74 }
75 }
76 else
77 {
78 const int ch = piece->dsc_in.channels;
80 for(size_t k = 0; k < (size_t)ch * roi_out->width * roi_out->height; k++)
81 {
82 out[k] = MIN(clip, in[k]);
83 }
84 }
85}
86
88void process_visualize(const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid,
89 const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const uint32_t filters,
91{
92 const float *const in = (const float *const)ivoid;
93 float *const out = (float *const)ovoid;
94 const size_t width = roi_out->width;
95 const size_t height = roi_out->height;
96 const float clips[4] = { 0.995f * data->clip * piece->dsc_in.processed_maximum[0],
97 0.995f * data->clip * piece->dsc_in.processed_maximum[1],
98 0.995f * data->clip * piece->dsc_in.processed_maximum[2], data->clip };
99 __OMP_FOR_SIMD__(aligned(in, out : 64))
100 for(size_t row = 0; row < height; row++)
101 {
102 for(size_t col = 0, i = row * width; col < width; col++, i++)
103 {
104 const int c = FC(row, col, filters);
105 const float ival = in[i];
106 out[i] = (ival < clips[c]) ? 0.2f * ival : 1.0f;
107 }
108 }
109}
__DT_CLONE_TARGETS__ void process_visualize(const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const uint32_t filters, dt_iop_highlights_data_t *data)
Definition clip.c:88
__DT_CLONE_TARGETS__ void process_clip(const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const float clip)
Definition clip.c:62
const dt_colormatrix_t dt_aligned_pixel_t out
static const int row
static int FC(const int row, const int col, const unsigned int filters)
void *const ovoid
float *const restrict const size_t k
float *const restrict const size_t const size_t ch
uint32_t width
Definition mipmap_cache.c:0
uint32_t height
Definition mipmap_cache.c:1
#define __OMP_FOR_SIMD__(...)
Definition openmp.h:97
#define __OMP_PARALLEL_FOR_SIMD__(...)
Definition openmp.h:96
dt_iop_buffer_dsc_t dsc_in
uint32_t filters
Definition format.h:89
unsigned int channels
Definition format.h:83
dt_aligned_pixel_t processed_maximum
Definition format.h:114
Region of interest passed through the pixelpipe.
Definition format.h:49
int width
Definition format.h:50
int height
Definition format.h:50
#define __DT_CLONE_TARGETS__
#define MIN(a, b)
Definition thinplate.c:32