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
21static void passthrough_monochrome(float *out, const float *const in, dt_iop_roi_t *const roi_out,
22 const dt_iop_roi_t *const roi_in)
23{
24 // we never want to access the input out of bounds though:
25 assert(roi_in->width >= roi_out->width);
26 assert(roi_in->height >= roi_out->height);
27
28#ifdef _OPENMP
29#pragma omp parallel for default(none) \
30 dt_omp_firstprivate(in, roi_out, roi_in) \
31 shared(out) \
32 schedule(static) collapse(2)
33#endif
34 for(int j = 0; j < roi_out->height; j++)
35 {
36 for(int i = 0; i < roi_out->width; i++)
37 {
38 for(int c = 0; c < 3; c++)
39 {
40 out[(size_t)4 * ((size_t)j * roi_out->width + i) + c]
41 = in[(size_t)((size_t)j + roi_out->y) * roi_in->width + i + roi_out->x];
42 }
43 }
44 }
45}
46
47static void passthrough_color(float *out, const float *const in, dt_iop_roi_t *const roi_out, const dt_iop_roi_t *const roi_in,
48 const uint32_t filters, const uint8_t (*const xtrans)[6])
49{
50 assert(roi_in->width >= roi_out->width);
51 assert(roi_in->height >= roi_out->height);
52
53
54 if(filters != 9u)
55 {
56 #ifdef _OPENMP
57 #pragma omp parallel for default(none) \
58 dt_omp_firstprivate(in, roi_out, roi_in, filters) \
59 shared(out) \
60 schedule(static) \
61 collapse(2)
62 #endif
63
64 for(int row = 0; row < (roi_out->height); row++)
65 {
66 for(int col = 0; col < (roi_out->width); col++)
67 {
68 const float val = in[col + roi_out->x + ((row + roi_out->y) * roi_in->width)];
69 const uint32_t offset = (size_t)4 * ((size_t)row * roi_out->width + col);
70 const uint32_t ch = FC(row + roi_out->y, col + roi_out->x, filters);
71
72 out[offset] = out[offset + 1] = out[offset + 2] = 0.0f;
73 out[offset + ch] = val;
74 }
75 }
76 }
77 else
78 {
79 #ifdef _OPENMP
80 #pragma omp parallel for default(none) \
81 dt_omp_firstprivate(in, roi_out, roi_in, xtrans) \
82 shared(out) \
83 schedule(static) \
84 collapse(2)
85 #endif
86
87 for(int row = 0; row < (roi_out->height); row++)
88 {
89 for(int col = 0; col < (roi_out->width); col++)
90 {
91 const float val = in[col + roi_out->x + ((row + roi_out->y) * roi_in->width)];
92 const uint32_t offset = (size_t)4 * ((size_t)row * roi_out->width + col);
93 const uint32_t ch = FCxtrans(row, col, roi_in, xtrans);
94
95 out[offset] = out[offset + 1] = out[offset + 2] = 0.0f;
96 out[offset + ch] = val;
97 }
98 }
99 }
100}
101
102// clang-format off
103// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
104// vim: shiftwidth=2 expandtab tabstop=2 cindent
105// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
106// clang-format on
const float i
Definition colorspaces_inline_conversions.h:669
const float c
Definition colorspaces_inline_conversions.h:1365
static const dt_colormatrix_t dt_aligned_pixel_t out
Definition colorspaces_inline_conversions.h:184
static const int row
Definition colorspaces_inline_conversions.h:175
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
static 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:47
static 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:21
Definition imageop.h:67
int x
Definition imageop.h:68
int width
Definition imageop.h:68
int height
Definition imageop.h:68
int y
Definition imageop.h:68