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 "system/mem_alloc.h"
32#include "common/logging.h"
33#include "config.h"
34#endif
35#include "develop/imageop_gui.h"
36#include "pixel/interpolation.h"
37#include "develop/imageop.h"
39#include "iop/iop_api.h"
40
42
47
49
50const char *name()
51{
52 return C_("modulename", "Initial resampling");
53}
54
59
61{
63}
64
69
70
71// see ../../doc/resizing-scaling.md for details
73 const dt_iop_roi_t *const roi_out,
74 dt_iop_roi_t *roi_in)
75{
76 *roi_in = *roi_out;
77
78 roi_in->x = 0;
79 roi_in->y = 0;
80 roi_in->width = piece->buf_in.width;
81 roi_in->height = piece->buf_in.height;
82 roi_in->scale = 1.0f;
83}
84
85void distort_mask(struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece,
86 const float *const in, float *const out, const dt_iop_roi_t *const roi_in,
87 const dt_iop_roi_t *const roi_out)
88{
89 (void)pipe;
91 dt_interpolation_resample_roi_1c(itor, out, roi_out, in, roi_in);
92}
93
94#ifdef HAVE_OPENCL
95int 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)
96{
97 const dt_iop_roi_t *const roi_in = &piece->roi_in;
98 const dt_iop_roi_t *const roi_out = &piece->roi_out;
99 if(roi_out->scale >= 1.00001f)
100 {
102 "[opencl_initialscale] initialscale with upscaling not yet supported by opencl code\n");
103 return FALSE;
104 }
105
106 const int devid = pipe->devid;
107 cl_int err = -999;
108
109 err = dt_iop_clip_and_zoom_roi_cl(devid, dev_out, dev_in, roi_out, roi_in);
110 if(err != CL_SUCCESS) goto error;
111
112 return TRUE;
113
114error:
115 dt_print(DT_DEBUG_OPENCL, "[opencl_initialscale] couldn't enqueue kernel! %d\n", err);
116 return FALSE;
117}
118#endif
119
121 const void *const ivoid, void *const ovoid)
122{
123 const dt_iop_roi_t *const roi_in = &piece->roi_in;
124 const dt_iop_roi_t *const roi_out = &piece->roi_out;
125 dt_iop_clip_and_zoom_roi(ovoid, ivoid, roi_out, roi_in, roi_out->width, roi_in->width);
126 return 0;
127}
128
133
139
141{
142 dt_free_align(piece->data);
143 piece->data = NULL;
144}
145
147{
148 self->params = calloc(1, sizeof(dt_iop_initialscale_params_t));
149 self->default_params = calloc(1, sizeof(dt_iop_initialscale_params_t));
150 self->default_enabled = 1;
151 self->hide_enable_button = 1;
153}
154
156{
157 dt_free(self->params);
158 dt_free(self->default_params);
159}
160
163
164
166{
167 IOP_GUI_ALLOC(initialscale);
168 self->gui->widget = gtk_label_new(NULL);
169 gtk_label_set_markup(GTK_LABEL(self->gui->widget),_("This module is used to downscale images at export time. "
170 "Moving it along the pipeline will have diffent effects on exported images. "
171 "<a href='https://ansel.photos/en/doc/modules/processing-modules/initialscale/'>Learn more</a>"));
172 gtk_widget_set_halign(self->gui->widget, GTK_ALIGN_START);
173 gtk_label_set_xalign (GTK_LABEL(self->gui->widget), 0.0f);
174 gtk_label_set_line_wrap(GTK_LABEL(self->gui->widget), TRUE);
175}
176
177// clang-format off
178// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
179// vim: shiftwidth=2 expandtab tabstop=2 cindent
180// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
181// 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
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
@ IOP_CS_RGB
const dt_colormatrix_t dt_aligned_pixel_t out
void dt_iop_params_t
Definition dev_history.h:43
@ IOP_FLAGS_ALLOW_TILING
Definition imageop.h:188
@ IOP_FLAGS_ONE_INSTANCE
Definition imageop.h:191
@ IOP_FLAGS_TILING_FULL_ROI
Definition imageop.h:190
@ IOP_FLAGS_NO_HISTORY_STACK
Definition imageop.h:193
@ IOP_GROUP_TECHNICAL
Definition imageop.h:162
#define IOP_GUI_ALLOC(module)
Definition imageop_gui.h:93
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)
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
@ DT_DEBUG_OPENCL
Definition logging.h:57
void dt_print(dt_debug_thread_t thread, const char *msg,...) __attribute__((format(printf
Print to stdout when thread is enabled, prefixed with seconds since startup.
#define dt_free_align(ptr)
Release memory from dt_alloc_align() and set ptr to NULL.
Definition mem_alloc.h:214
static void * dt_calloc_align(size_t size)
dt_alloc_align() followed by a zero fill.
Definition mem_alloc.h:225
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
Definition mem_alloc.h:171
#define DT_MODULE_INTROSPECTION(MODVER, PARAMSTYPE)
DT_MODULE() for a module whose params struct is introspected.
struct dt_iop_module_t *void * data
GtkWidget * widget
Definition imageop_gui.h:47
int32_t hide_enable_button
Definition imageop.h:270
dt_iop_params_t * default_params
Definition imageop.h:333
struct dt_iop_module_gui_t * gui
Definition imageop.h:346
gboolean default_enabled
Definition imageop.h:318
int32_t params_size
Definition imageop.h:335
dt_iop_params_t * params
Definition imageop.h:333
Region of interest passed through the pixelpipe.
Definition format.h:49
double scale
Definition format.h:51
int width
Definition format.h:50
int height
Definition format.h:50