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 "common/darktable.h"
57#include "iop/highlights/clip.h"
58#include <string.h>
59
61void process_clip(const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid,
62 const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const float clip)
63{
64 const float *const in = (const float *const)ivoid;
65 float *const out = (float *const)ovoid;
66
67 if(piece->dsc_in.filters)
68 { // raw mosaic
70 for(size_t k = 0; k < (size_t)roi_out->width * roi_out->height; k++)
71 {
72 out[k] = MIN(clip, in[k]);
73 }
74 }
75 else
76 {
77 const int ch = piece->dsc_in.channels;
79 for(size_t k = 0; k < (size_t)ch * roi_out->width * roi_out->height; k++)
80 {
81 out[k] = MIN(clip, in[k]);
82 }
83 }
84}
85
87void process_visualize(const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid,
88 const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const uint32_t filters,
90{
91 const float *const in = (const float *const)ivoid;
92 float *const out = (float *const)ovoid;
93 const size_t width = roi_out->width;
94 const size_t height = roi_out->height;
95 const float clips[4] = { 0.995f * data->clip * piece->dsc_in.processed_maximum[0],
96 0.995f * data->clip * piece->dsc_in.processed_maximum[1],
97 0.995f * data->clip * piece->dsc_in.processed_maximum[2], data->clip };
98 __OMP_FOR_SIMD__(aligned(in, out : 64))
99 for(size_t row = 0; row < height; row++)
100 {
101 for(size_t col = 0, i = row * width; col < width; col++, i++)
102 {
103 const int c = FC(row, col, filters);
104 const float ival = in[i];
105 out[i] = (ival < clips[c]) ? 0.2f * ival : 1.0f;
106 }
107 }
108}
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
__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:87
__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:61
const dt_colormatrix_t dt_aligned_pixel_t out
static const int row
#define __DT_CLONE_TARGETS__
Definition darktable.h:379
#define __OMP_FOR_SIMD__(...)
Definition darktable.h:272
#define __OMP_PARALLEL_FOR_SIMD__(...)
Definition darktable.h:271
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
dt_iop_buffer_dsc_t dsc_in
uint32_t filters
Definition format.h:60
unsigned int channels
Definition format.h:54
dt_aligned_pixel_t processed_maximum
Definition format.h:85
Region of interest passed through the pixelpipe.
Definition imageop.h:72
#define MIN(a, b)
Definition thinplate.c:32