Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
initialscale.c
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2015 johannes hanika.
4 Copyright (C) 2015-2016 Roman Lebedev.
5 Copyright (C) 2015 Ulrich Pegelow.
6 Copyright (C) 2016, 2019 Tobias Ellinghaus.
7 Copyright (C) 2017 Heiko Bauke.
8 Copyright (C) 2018, 2020-2021, 2023-2026 Aurélien PIERRE.
9 Copyright (C) 2018 Edgardo Hoszowski.
10 Copyright (C) 2020 Aldric Renaudin.
11 Copyright (C) 2020-2021 Pascal Obry.
12 Copyright (C) 2021 Hanno Schwalm.
13 Copyright (C) 2022 Martin Bařinka.
14 Copyright (C) 2022 Philipp Lutz.
15
16 darktable is free software: you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation, either version 3 of the License, or
19 (at your option) any later version.
20
21 darktable is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
25
26 You should have received a copy of the GNU General Public License
27 along with darktable. If not, see <http://www.gnu.org/licenses/>.
28*/
29#ifdef HAVE_CONFIG_H
30#include "common/darktable.h"
31#include "config.h"
32#endif
33#include "bauhaus/bauhaus.h"
35#include "common/opencl.h"
36#include "develop/imageop.h"
38#include "develop/tiling.h"
39#include "iop/iop_api.h"
40#include "gui/gtk.h"
41
43
48
50
51const char *name()
52{
53 return C_("modulename", "Initial resampling");
54}
55
60
62{
64}
65
70
71
72// see ../../doc/resizing-scaling.md for details
74 const dt_iop_roi_t *const roi_out,
75 dt_iop_roi_t *roi_in)
76{
77 *roi_in = *roi_out;
78
79 roi_in->x = 0;
80 roi_in->y = 0;
81 roi_in->width = piece->buf_in.width;
82 roi_in->height = piece->buf_in.height;
83 roi_in->scale = 1.0f;
84}
85
86void distort_mask(struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece,
87 const float *const in, float *const out, const dt_iop_roi_t *const roi_in,
88 const dt_iop_roi_t *const roi_out)
89{
90 (void)pipe;
92 dt_interpolation_resample_roi_1c(itor, out, roi_out, in, roi_in);
93}
94
95#ifdef HAVE_OPENCL
96int process_cl(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out)
97{
98 const dt_iop_roi_t *const roi_in = &piece->roi_in;
99 const dt_iop_roi_t *const roi_out = &piece->roi_out;
100 if(roi_out->scale >= 1.00001f)
101 {
103 "[opencl_initialscale] initialscale with upscaling not yet supported by opencl code\n");
104 return FALSE;
105 }
106
107 const int devid = pipe->devid;
108 cl_int err = -999;
109
110 err = dt_iop_clip_and_zoom_roi_cl(devid, dev_out, dev_in, roi_out, roi_in);
111 if(err != CL_SUCCESS) goto error;
112
113 return TRUE;
114
115error:
116 dt_print(DT_DEBUG_OPENCL, "[opencl_initialscale] couldn't enqueue kernel! %d\n", err);
117 return FALSE;
118}
119#endif
120
122 const void *const ivoid, void *const ovoid)
123{
124 const dt_iop_roi_t *const roi_in = &piece->roi_in;
125 const dt_iop_roi_t *const roi_out = &piece->roi_out;
126 dt_iop_clip_and_zoom_roi(ovoid, ivoid, roi_out, roi_in, roi_out->width, roi_in->width);
127 return 0;
128}
129
134
140
142{
143 dt_free_align(piece->data);
144 piece->data = NULL;
145}
146
148{
149 self->params = calloc(1, sizeof(dt_iop_initialscale_params_t));
150 self->default_params = calloc(1, sizeof(dt_iop_initialscale_params_t));
151 self->default_enabled = 1;
152 self->hide_enable_button = 1;
154 self->gui_data = NULL;
155}
156
158{
159 dt_free(self->params);
160 dt_free(self->default_params);
161}
162
165
167
169{
170 IOP_GUI_ALLOC(initialscale);
171 self->widget = gtk_label_new(NULL);
172 gtk_label_set_markup(GTK_LABEL(self->widget),_("This module is used to downscale images at export time. "
173 "Moving it along the pipeline will have diffent effects on exported images. "
174 "<a href='https://ansel.photos/en/doc/modules/processing-modules/initialscale/'>Learn more</a>"));
175 gtk_widget_set_halign(self->widget, GTK_ALIGN_START);
176 gtk_label_set_xalign (GTK_LABEL(self->widget), 0.0f);
177 gtk_label_set_line_wrap(GTK_LABEL(self->widget), TRUE);
178}
179
180// clang-format off
181// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
182// vim: shiftwidth=2 expandtab tabstop=2 cindent
183// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
184// clang-format on
static void error(char *msg)
Definition ashift_lsd.c:202
#define TRUE
Definition ashift_lsd.c:162
#define FALSE
Definition ashift_lsd.c:158
@ IOP_CS_RGB
const dt_colormatrix_t dt_aligned_pixel_t out
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
void dt_print(dt_debug_thread_t thread, const char *msg,...)
Definition darktable.c:1542
#define dt_free_align(ptr)
Definition darktable.h:481
static void * dt_calloc_align(size_t size)
Definition darktable.h:488
@ DT_DEBUG_OPENCL
Definition darktable.h:722
#define dt_free(ptr)
Definition darktable.h:456
#define DT_MODULE_INTROSPECTION(MODVER, PARAMSTYPE)
Definition darktable.h:151
void dt_iop_params_t
Definition dev_history.h:41
@ IOP_FLAGS_ALLOW_TILING
Definition imageop.h:169
@ IOP_FLAGS_ONE_INSTANCE
Definition imageop.h:172
@ IOP_FLAGS_TILING_FULL_ROI
Definition imageop.h:171
@ IOP_FLAGS_NO_HISTORY_STACK
Definition imageop.h:174
@ IOP_GROUP_TECHNICAL
Definition imageop.h:143
#define IOP_GUI_ALLOC(module)
Definition imageop.h:599
void dt_iop_clip_and_zoom_roi(float *out, const float *const in, const dt_iop_roi_t *const roi_out, const dt_iop_roi_t *const roi_in, const int32_t out_stride, const int32_t in_stride)
int dt_iop_clip_and_zoom_roi_cl(int devid, cl_mem dev_out, cl_mem dev_in, const dt_iop_roi_t *const roi_out, const dt_iop_roi_t *const roi_in)
void *const ovoid
void distort_mask(struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece, const float *const in, float *const out, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out)
int process(dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid)
dt_iop_initialscale_gui_data_t dummy
int default_group()
void modify_roi_in(dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece, const dt_iop_roi_t *const roi_out, dt_iop_roi_t *roi_in)
const char * name()
void gui_init(dt_iop_module_t *self)
dt_iop_initialscale_params_t dt_iop_initialscale_data_t
void cleanup_pipe(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
int default_colorspace(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
int flags()
void init(dt_iop_module_t *self)
void commit_params(dt_iop_module_t *self, dt_iop_params_t *params, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
void init_pipe(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
int process_cl(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out)
void cleanup(dt_iop_module_t *self)
const struct dt_interpolation * dt_interpolation_new(enum dt_interpolation_type type)
void dt_interpolation_resample_roi_1c(const struct dt_interpolation *itor, float *out, const dt_iop_roi_t *const roi_out, const float *const in, const dt_iop_roi_t *const roi_in)
@ DT_INTERPOLATION_USERPREF_WARP
struct dt_iop_module_t *void * data
int32_t hide_enable_button
Definition imageop.h:262
dt_iop_params_t * default_params
Definition imageop.h:307
GtkWidget * widget
Definition imageop.h:337
dt_iop_gui_data_t * gui_data
Definition imageop.h:311
gboolean default_enabled
Definition imageop.h:303
int32_t params_size
Definition imageop.h:309
dt_iop_params_t * params
Definition imageop.h:307
Region of interest passed through the pixelpipe.
Definition imageop.h:72
double scale
Definition imageop.h:74