Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
passthrough.c
Go to the documentation of this file.
1/*
2 This file is part of the Ansel project.
3 Copyright (C) 2023 Aurélien PIERRE.
4
5 Ansel 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 Ansel 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 Ansel. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19
22static void passthrough_monochrome(float *out, const float *const in, dt_iop_roi_t *const roi_out,
23 const dt_iop_roi_t *const roi_in)
24{
25 // we never want to access the input out of bounds though:
26 assert(roi_in->width >= roi_out->width);
27 assert(roi_in->height >= roi_out->height);
28 __OMP_PARALLEL_FOR__(collapse(2))
29 for(int j = 0; j < roi_out->height; j++)
30 {
31 for(int i = 0; i < roi_out->width; i++)
32 {
33 for(int c = 0; c < 3; c++)
34 {
35 out[(size_t)4 * ((size_t)j * roi_out->width + i) + c]
36 = in[(size_t)((size_t)j + roi_out->y) * roi_in->width + i + roi_out->x];
37 }
38 }
39 }
40
41}
42
44static void passthrough_color(float *out, const float *const in, dt_iop_roi_t *const roi_out, const dt_iop_roi_t *const roi_in,
45 const uint32_t filters, const uint8_t (*const xtrans)[6])
46{
47 assert(roi_in->width >= roi_out->width);
48 assert(roi_in->height >= roi_out->height);
49
50
51 if(filters != 9u)
52 {
53
54 __OMP_PARALLEL_FOR__( collapse(2))
55 for(int row = 0; row < (roi_out->height); row++)
56 {
57 for(int col = 0; col < (roi_out->width); col++)
58 {
59 const float val = in[col + roi_out->x + ((row + roi_out->y) * roi_in->width)];
60 const uint32_t offset = (size_t)4 * ((size_t)row * roi_out->width + col);
61 const uint32_t ch = FC(row + roi_out->y, col + roi_out->x, filters);
62
63 out[offset] = out[offset + 1] = out[offset + 2] = 0.0f;
64 out[offset + ch] = val;
65 }
66 }
67
68 }
69 else
70 {
71
72 __OMP_PARALLEL_FOR__( collapse(2))
73 for(int row = 0; row < (roi_out->height); row++)
74 {
75 for(int col = 0; col < (roi_out->width); col++)
76 {
77 const float val = in[col + roi_out->x + ((row + roi_out->y) * roi_in->width)];
78 const uint32_t offset = (size_t)4 * ((size_t)row * roi_out->width + col);
79 const uint32_t ch = FCxtrans(row, col, roi_in, xtrans);
80
81 out[offset] = out[offset + 1] = out[offset + 2] = 0.0f;
82 out[offset + ch] = val;
83 }
84 }
85
86 }
87}
88
89// clang-format off
90// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
91// vim: shiftwidth=2 expandtab tabstop=2 cindent
92// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
93// clang-format on
const float i
Definition colorspaces_inline_conversions.h:440
const dt_colormatrix_t dt_aligned_pixel_t out
Definition colorspaces_inline_conversions.h:42
static const int row
Definition colorspaces_inline_conversions.h:35
#define __DT_CLONE_TARGETS__
Definition darktable.h:367
#define __OMP_PARALLEL_FOR__(...)
Definition darktable.h:258
static int FCxtrans(const int row, const int col, global const unsigned char(*const xtrans)[6])
Definition data/kernels/common.h:54
static int FC(const int row, const int col, const unsigned int filters)
Definition data/kernels/common.h:47
float *const restrict const size_t const size_t ch
Definition luminance_mask.h:78
static __DT_CLONE_TARGETS__ void passthrough_monochrome(float *out, const float *const in, dt_iop_roi_t *const roi_out, const dt_iop_roi_t *const roi_in)
Definition passthrough.c:22
static __DT_CLONE_TARGETS__ void passthrough_color(float *out, const float *const in, dt_iop_roi_t *const roi_out, const dt_iop_roi_t *const roi_in, const uint32_t filters, const uint8_t(*const xtrans)[6])
Definition passthrough.c:44
Region of interest passed through the pixelpipe.
Definition imageop.h:72
int x
Definition imageop.h:73
int width
Definition imageop.h:73
int height
Definition imageop.h:73
int y
Definition imageop.h:73