Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
passthrough.c
Go to the documentation of this file.
1
2
4static void passthrough_monochrome(float *out, const float *const in, dt_iop_roi_t *const roi_out,
5 const dt_iop_roi_t *const roi_in)
6{
7 // we never want to access the input out of bounds though:
8 assert(roi_in->width >= roi_out->width);
9 assert(roi_in->height >= roi_out->height);
10
11#ifdef _OPENMP
12#pragma omp parallel for default(none) \
13 dt_omp_firstprivate(in, roi_out, roi_in) \
14 shared(out) \
15 schedule(static) collapse(2)
16#endif
17 for(int j = 0; j < roi_out->height; j++)
18 {
19 for(int i = 0; i < roi_out->width; i++)
20 {
21 for(int c = 0; c < 3; c++)
22 {
23 out[(size_t)4 * ((size_t)j * roi_out->width + i) + c]
24 = in[(size_t)((size_t)j + roi_out->y) * roi_in->width + i + roi_out->x];
25 }
26 }
27 }
28}
29
30static void passthrough_color(float *out, const float *const in, dt_iop_roi_t *const roi_out, const dt_iop_roi_t *const roi_in,
31 const uint32_t filters, const uint8_t (*const xtrans)[6])
32{
33 assert(roi_in->width >= roi_out->width);
34 assert(roi_in->height >= roi_out->height);
35
36
37 if(filters != 9u)
38 {
39 #ifdef _OPENMP
40 #pragma omp parallel for default(none) \
41 dt_omp_firstprivate(in, roi_out, roi_in, filters) \
42 shared(out) \
43 schedule(static) \
44 collapse(2)
45 #endif
46
47 for(int row = 0; row < (roi_out->height); row++)
48 {
49 for(int col = 0; col < (roi_out->width); col++)
50 {
51 const float val = in[col + roi_out->x + ((row + roi_out->y) * roi_in->width)];
52 const uint32_t offset = (size_t)4 * ((size_t)row * roi_out->width + col);
53 const uint32_t ch = FC(row + roi_out->y, col + roi_out->x, filters);
54
55 out[offset] = out[offset + 1] = out[offset + 2] = 0.0f;
56 out[offset + ch] = val;
57 }
58 }
59 }
60 else
61 {
62 #ifdef _OPENMP
63 #pragma omp parallel for default(none) \
64 dt_omp_firstprivate(in, roi_out, roi_in, xtrans) \
65 shared(out) \
66 schedule(static) \
67 collapse(2)
68 #endif
69
70 for(int row = 0; row < (roi_out->height); row++)
71 {
72 for(int col = 0; col < (roi_out->width); col++)
73 {
74 const float val = in[col + roi_out->x + ((row + roi_out->y) * roi_in->width)];
75 const uint32_t offset = (size_t)4 * ((size_t)row * roi_out->width + col);
76 const uint32_t ch = FCxtrans(row, col, roi_in, xtrans);
77
78 out[offset] = out[offset + 1] = out[offset + 2] = 0.0f;
79 out[offset + ch] = val;
80 }
81 }
82 }
83}
84
85// clang-format off
86// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
87// vim: shiftwidth=2 expandtab tabstop=2 cindent
88// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
89// clang-format on
static int FCxtrans(const int row, const int col, global const unsigned char(*const xtrans)[6])
Definition data/kernels/common.h:50
static int FC(const int row, const int col, const unsigned int filters)
Definition data/kernels/common.h:43
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:30
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:4
Definition imageop.h:32
int x
Definition imageop.h:33
int width
Definition imageop.h:33
int height
Definition imageop.h:33
int y
Definition imageop.h:33