73 return C_(
"modulename",
"scale pixels");
100 _(
"internal module to setup technical specificities of raw sensor.\n\n"
101 "you should not touch values here !"),
102 NULL, NULL, NULL, NULL);
109 if(
d->pixel_aspect_ratio < 1.0f)
111 p[1] /=
d->pixel_aspect_ratio;
115 p[0] *=
d->pixel_aspect_ratio;
138 if(pixel_aspect_ratio < 1.0f)
141 *y_scale = pixel_aspect_ratio;
145 *x_scale = 1.0f / pixel_aspect_ratio;
160 float *points,
size_t points_count)
165 for(
size_t i = 0;
i < points_count * 2;
i += 2)
167 points[
i] /=
d->x_scale;
168 points[
i+1] /=
d->y_scale;
175 float *points,
size_t points_count)
180 for(
size_t i = 0;
i < points_count * 2;
i += 2)
182 points[
i] *=
d->x_scale;
183 points[
i+1] *=
d->y_scale;
190 const float *
const in,
float *
const out,
const dt_iop_roi_t *
const roi_in,
196 fprintf(stderr,
"TODO: implement %s() in %s\n", __FUNCTION__, __FILE__);
205 float xy[2] = { roi_out->
x, roi_out->
y };
211 roi_out->
x = (int)floorf(xy[0]);
212 roi_out->
y = (int)floorf(xy[1]);
213 roi_out->
width = (int)ceilf(wh[0]);
214 roi_out->
height = (int)ceilf(wh[1]);
217 if(roi_out->
x < 0) roi_out->
x = 0;
218 if(roi_out->
y < 0) roi_out->
y = 0;
233 roi_in->
width = hw[1];
236 if (reduction_ratio > 1.0f)
238 roi_in->
height /= reduction_ratio;
239 roi_in->
width /= reduction_ratio;
243 d->x_scale = (roi_in->
width * 1.0f) / (roi_out->
width * 1.0f);
244 d->y_scale = (roi_in->
height * 1.0f) / (roi_out->
height * 1.0f);
247 roi_in->
x = roi_out->
x *
d->x_scale;
248 roi_in->
y = roi_out->
y *
d->y_scale;
253 const void *
const ivoid,
void *
const ovoid)
259 const int ch_width =
ch * roi_in->
width;
265 for(
int j = 0; j < roi_out->
height; j++)
267 float *
out = ((
float *)
ovoid) + (size_t)4 * j * roi_out->
width;
270 float x =
i*
d->x_scale;
271 float y = j*
d->y_scale;
274 roi_in->
height, ch_width);
286 d->pixel_aspect_ratio =
p->pixel_aspect_ratio;
290 if(isnan(
p->pixel_aspect_ratio) ||
p->pixel_aspect_ratio <= 0.0f ||
p->pixel_aspect_ratio == 1.0f)
309 out->
x = (int)floorf(in->
x /
g->x_scale);
310 out->y = (int)floorf(in->
y /
g->y_scale);
311 out->width = (int)ceilf(in->
width /
g->x_scale);
312 out->height = (int)ceilf(in->
height /
g->y_scale);
315 if(
out->x < 0)
out->x = 0;
316 if(
out->y < 0)
out->y = 0;
317 if(
out->width < 1)
out->width = 1;
318 if(
out->height < 1)
out->height = 1;
325 for(
size_t i = 0;
i < points_count * 2;
i += 2)
328 points[
i + 1] /=
g->y_scale;
338 for(
size_t i = 0;
i < points_count * 2;
i += 2)
341 points[
i + 1] *=
g->y_scale;
358 if(isnan(
p->pixel_aspect_ratio) ||
p->pixel_aspect_ratio <= 0.0f ||
p->pixel_aspect_ratio == 1.0f)
393 d->pixel_aspect_ratio > 0.0f &&
394 d->pixel_aspect_ratio != 1.0f);
404 ? _(
"automatic pixel scaling")
405 : _(
"automatic pixel scaling\nonly works for the sensors that need it."));
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
const dt_colormatrix_t dt_aligned_pixel_t out
Where things are on the image, answered without a pipeline.
const char ** dt_iop_set_description(dt_iop_module_t *module, const char *main_text, const char *purpose, const char *input, const char *process, const char *output)
@ IOP_FLAGS_TILING_FULL_ROI
#define IOP_GUI_ALLOC(module)
const struct dt_interpolation * dt_interpolation_new(enum dt_interpolation_type type)
__DT_CLONE_TARGETS__ void dt_interpolation_compute_pixel4c(const struct dt_interpolation *itor, const float *in, float *out, const float x, const float y, const int width, const int height, const int linestride)
@ DT_INTERPOLATION_USERPREF
GtkWidget * dt_ui_label_new(const gchar *str)
float *const restrict const size_t const size_t ch
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#define dt_free_align(ptr)
Release memory from dt_alloc_align() and set ptr to NULL.
static void * dt_calloc_align(size_t size)
dt_alloc_align() followed by a zero fill.
static void dt_free_gpointer(gpointer ptr)
g_free() one pointer, with the signature GDestroyNotify wants.
#define DT_MODULE_INTROSPECTION(MODVER, PARAMSTYPE)
DT_MODULE() for a module whose params struct is introspected.
#define __OMP_PARALLEL_FOR__(...)
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)
const char ** description(struct dt_iop_module_t *self)
void modify_roi_out(dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece, dt_iop_roi_t *roi_out, const dt_iop_roi_t *const roi_in)
static void _scalepixels_scales(const float pixel_aspect_ratio, float *x_scale, float *y_scale)
The axis scales this module applies, from its one parameter. THE constructor.
void gui_update(dt_iop_module_t *self)
Refresh GUI controls from current params and configuration.
__DT_CLONE_TARGETS__ 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)
static int _scalepixels_geometry_backtransform(const void *data, const dt_geometry_record_t *const record, dt_geometry_chain_t *chain, float *points, size_t points_count)
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)
static const dt_geometry_vtable_t _scalepixels_geometry_vtable
gboolean geometry_record(dt_iop_module_t *self, const void *params, dt_geometry_record_t *record)
void gui_init(dt_iop_module_t *self)
int distort_backtransform(dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, float *points, size_t points_count)
void reload_defaults(dt_iop_module_t *self)
static void _scalepixels_geometry_map_size(const void *data, const dt_iop_roi_t *const in, dt_iop_roi_t *out)
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)
void commit_params(dt_iop_module_t *self, dt_iop_params_t *params, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
static void transform(const dt_dev_pixelpipe_iop_t *const piece, float *p)
void init_pipe(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
int distort_transform(dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, float *points, size_t points_count)
static int _scalepixels_geometry_transform(const void *data, const dt_geometry_record_t *const record, dt_geometry_chain_t *chain, float *points, size_t points_count)
static void precalculate_scale(dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
dt_iop_buffer_dsc_t dsc_in
struct dt_iop_module_t *void * data
One module instance's contribution, as data.
const dt_geometry_vtable_t * vtable
void(* free_data)(void *data)
A module's geometry, evaluated. Pure functions of the record's own data.
void(* map_size)(const void *data, const dt_iop_roi_t *const in, dt_iop_roi_t *out)
Full-resolution input rect -> output rect. Mirrors modify_roi_out() at scale 1.
int32_t hide_enable_button
dt_iop_params_t * default_params
struct dt_iop_module_gui_t * gui
struct dt_develop_t * dev
Region of interest passed through the pixelpipe.
#define __DT_CLONE_TARGETS__