72 for(
int k = 0;
k < 2;
k++)
p[
k] = aabb[2 * ((
i >>
k) & 1) +
k];
77 aabb[0] = fminf(aabb[0],
p[0]);
78 aabb[1] = fminf(aabb[1],
p[1]);
79 aabb[2] = fmaxf(aabb[2],
p[0]);
80 aabb[3] = fmaxf(aabb[3],
p[1]);
86 return C_(
"modulename",
"rotate pixels");
113 _(
"internal module to setup technical specificities of raw sensor.\n\n"
114 "you should not touch values here !"),
115 NULL, NULL, NULL, NULL);
130 float pi[2] = {
x[0] -
d->rx * scale,
x[1] -
d->ry * scale };
140 float rt[] = {
d->m[0], -
d->m[1], -
d->m[2],
d->m[3] };
143 o[0] +=
d->rx * scale;
144 o[1] +=
d->ry * scale;
160 const float scale = roi_in->
scale;
161 const float T = (float)
d->ry * scale;
163 const float y = sqrtf(2.0f * T * T),
164 x = sqrtf(2.0f * ((
float)roi_in->
width - T) * ((
float)roi_in->
width - T));
167 const float IW = (float)interpolation->
width * scale;
169 roi_out->
width = y - IW;
177 float *
const restrict points,
size_t points_count)
181 for(
size_t i = 0;
i < points_count * 2;
i += 2)
186 pi[1] = points[
i + 1];
191 points[
i + 1] = po[1];
198 float *
const restrict points,
size_t points_count)
202 for(
size_t i = 0;
i < points_count * 2;
i += 2)
207 pi[1] = points[
i + 1];
212 points[
i + 1] = po[1];
219 const float *
const in,
float *
const out,
const dt_iop_roi_t *
const roi_in,
225 fprintf(stderr,
"TODO: implement %s() in %s\n", __FUNCTION__, __FILE__);
244 const float scale = roi_in->
scale;
250 for(
int c = 0; c < 4; c++)
264 const float IW = (float)interpolation->
width * scale;
269 roi_in->
x = fmaxf(0.0f, aabb_in[0] - IW);
270 roi_in->
y = fmaxf(0.0f, aabb_in[1] - IW);
271 roi_in->
width = fminf(orig_w - roi_in->
x, aabb_in[2] - roi_in->
x + IW);
272 roi_in->
height = fminf(orig_h - roi_in->
y, aabb_in[3] - roi_in->
y + IW);
275 roi_in->
x = CLAMP(roi_in->
x, 0, (
int)floorf(orig_w));
276 roi_in->
y = CLAMP(roi_in->
y, 0, (
int)floorf(orig_h));
277 roi_in->
width = CLAMP(roi_in->
width, 1, (
int)ceilf(orig_w) - roi_in->
x);
278 roi_in->
height = CLAMP(roi_in->
height, 1, (
int)ceilf(orig_h) - roi_in->
y);
285 const void *
const ivoid,
void *
const ovoid)
291 const int ch_width =
ch * roi_in->
width;
293 const float scale = roi_in->
scale;
299 for(
int j = 0; j < roi_out->
height; j++)
306 pi[0] = roi_out->
x +
i;
307 pi[1] = roi_out->
y + j;
315 roi_in->
height, ch_width);
328 const float angle =
p->angle *
M_PI / 180.0f;
330 const float rt[] = { cosf(angle), sinf(angle), -sinf(angle), cosf(angle) };
331 for(
int k = 0;
k < 4;
k++)
d->m[
k] = rt[
k];
344 if((
d->rx == 0u) && (
d->ry == 0u)) piece->
enabled = 0;
358 for(
size_t i = 0;
i < points_count * 2;
i += 2)
360 const float pi[2] = { points[
i], points[
i + 1] };
364 points[
i + 1] = po[1];
374 for(
size_t i = 0;
i < points_count * 2;
i += 2)
376 const float pi[2] = { points[
i], points[
i + 1] };
380 points[
i + 1] = po[1];
401 if(data->
rx == 0u && data->
ry == 0u)
443 ? _(
"automatic pixel rotation")
444 : _(
"automatic pixel rotation\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.
float dt_boundingbox_t[4]
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 k
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...
static void mul_mat_vec_2(const float *m, const float *p, float *o)
#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_DECLARE_SIMD__(...)
#define __OMP_PARALLEL_FOR__(...)
#define __OMP_PARALLEL_FOR_SIMD__(...)
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)
int distort_backtransform(dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, float *const restrict points, size_t points_count)
static void _rotatepixels_geometry_map_size(const void *data, const dt_iop_roi_t *const in, dt_iop_roi_t *out)
static void _rotatepixels_map_size(const dt_iop_rotatepixels_data_t *const d, const dt_iop_roi_t *const roi_in, dt_iop_roi_t *roi_out)
Input rect -> output rect: the inner rectangle of the 45-degree rotation.
int distort_transform(dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, float *const restrict points, size_t points_count)
static void _rotatepixels_resolve(const dt_iop_rotatepixels_params_t *const p, dt_iop_rotatepixels_data_t *d)
Params -> committed data. THE constructor, shared with geometry_record().
void gui_update(dt_iop_module_t *self)
Refresh GUI controls from current params and configuration.
static void get_corner(const float *aabb, const int i, float *p)
__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 _rotatepixels_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)
gboolean geometry_record(dt_iop_module_t *self, const void *params, dt_geometry_record_t *record)
void gui_init(dt_iop_module_t *self)
void commit_params(dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
static void transform(const dt_iop_rotatepixels_data_t *const d, const float scale, const float *const x, float *o)
void reload_defaults(dt_iop_module_t *self)
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)
static const dt_geometry_vtable_t _rotatepixels_geometry_vtable
static void adjust_aabb(const float *p, float *aabb)
void init_pipe(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
static int _rotatepixels_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 backtransform(const dt_iop_rotatepixels_data_t *const d, const float scale, const float *const x, float *o)
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.
uint32_t fuji_rotation_pos
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__