Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
flip.c File Reference
#include "widgets/widget_settings.h"
#include "database/database.h"
#include "database/history_repository.h"
#include <assert.h>
#include "system/openmp.h"
#include "system/mem_alloc.h"
#include "common/logging.h"
#include "common/module_versioning.h"
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <inttypes.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "imageio/imageio_core.h"
#include "common/opencl.h"
#include "develop/develop.h"
#include "develop/geometry/geometry.h"
#include "develop/imageop.h"
#include "develop/imageop_gui.h"
#include "gui/presets.h"
#include "iop/iop_api.h"
Include dependency graph for flip.c:

Go to the source code of this file.

Data Structures

struct  dt_iop_flip_params_t
struct  dt_iop_flip_global_data_t
struct  dt_iop_flip_geometry_t

Typedefs

typedef struct dt_iop_flip_params_t dt_iop_flip_params_t
typedef struct dt_iop_flip_params_t dt_iop_flip_data_t
typedef struct dt_iop_flip_global_data_t dt_iop_flip_global_data_t
typedef struct dt_iop_flip_geometry_t dt_iop_flip_geometry_t

Functions

static void get_corner (const int32_t *aabb, const int i, int32_t *p)
static void adjust_aabb (const int32_t *p, int32_t *aabb)
const char * name ()
const char * aliases ()
int default_group ()
int operation_tags ()
int flags ()
int default_colorspace (dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
const char ** description (struct dt_iop_module_t *self)
static dt_image_orientation_t merge_two_orientations (dt_image_orientation_t raw_orientation, dt_image_orientation_t user_orientation)
int legacy_params (dt_iop_module_t *self, const void *const old_params, const int old_version, void *new_params, const int new_version)
static void backtransform (const int32_t *x, int32_t *o, const dt_image_orientation_t orientation, int32_t iw, int32_t ih)
static dt_image_orientation_t _flip_resolve (dt_iop_module_t *self, const dt_iop_flip_params_t *const p)
 The orientation this module will actually apply.
static void _flip_map_size (const dt_image_orientation_t orientation, const dt_iop_roi_t *const roi_in, dt_iop_roi_t *roi_out)
 Input rect -> output rect: a swap, or nothing.
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)
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)
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)
void modify_roi_out (struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece, dt_iop_roi_t *roi_out, const dt_iop_roi_t *roi_in)
void modify_roi_in (struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece, const dt_iop_roi_t *roi_out, dt_iop_roi_t *roi_in)
int process (struct 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 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 init_global (dt_iop_module_so_t *self)
void cleanup_global (dt_iop_module_so_t *self)
void commit_params (struct dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
static void _flip_geometry_map_size (const void *data, const dt_iop_roi_t *const in, dt_iop_roi_t *out)
static int _flip_geometry_transform (const void *data, const dt_geometry_record_t *const record, dt_geometry_chain_t *chain, float *points, size_t points_count)
static int _flip_geometry_backtransform (const void *data, const dt_geometry_record_t *const record, dt_geometry_chain_t *chain, float *points, size_t points_count)
gboolean geometry_record (dt_iop_module_t *self, const void *params, dt_geometry_record_t *record)
void init_pipe (struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
void cleanup_pipe (struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
void init_presets (dt_iop_module_so_t *self)
void reload_defaults (dt_iop_module_t *self)
static void do_rotate (dt_iop_module_t *self, uint32_t cw)
static void rotate_cw (GtkWidget *widget, dt_iop_module_t *self)
static void rotate_ccw (GtkWidget *widget, dt_iop_module_t *self)
static void _flip_h (GtkWidget *widget, dt_iop_module_t *self)
static void _flip_v (GtkWidget *widget, dt_iop_module_t *self)
void gui_init (struct dt_iop_module_t *self)
void gui_cleanup (struct dt_iop_module_t *self)

Variables

static const dt_geometry_vtable_t _flip_geometry_vtable

Typedef Documentation

◆ dt_iop_flip_data_t

Definition at line 79 of file flip.c.

◆ dt_iop_flip_geometry_t

typedef struct dt_iop_flip_geometry_t dt_iop_flip_geometry_t

◆ dt_iop_flip_global_data_t

typedef struct dt_iop_flip_global_data_t dt_iop_flip_global_data_t

◆ dt_iop_flip_params_t

typedef struct dt_iop_flip_params_t dt_iop_flip_params_t

Function Documentation

◆ _flip_geometry_backtransform()

int _flip_geometry_backtransform ( const void * data,
const dt_geometry_record_t *const record,
dt_geometry_chain_t * chain,
float * points,
size_t points_count )
static

Definition at line 493 of file flip.c.

References data, dt_geometry_record_t, i, ORIENTATION_FLIP_X, ORIENTATION_FLIP_Y, ORIENTATION_SWAP_XY, and x.

◆ _flip_geometry_map_size()

void _flip_geometry_map_size ( const void * data,
const dt_iop_roi_t *const in,
dt_iop_roi_t * out )
static

Definition at line 466 of file flip.c.

References _flip_map_size(), data, in, and out.

◆ _flip_geometry_transform()

int _flip_geometry_transform ( const void * data,
const dt_geometry_record_t *const record,
dt_geometry_chain_t * chain,
float * points,
size_t points_count )
static

Definition at line 471 of file flip.c.

References data, dt_geometry_record_t, i, ORIENTATION_FLIP_X, ORIENTATION_FLIP_Y, ORIENTATION_SWAP_XY, and x.

◆ _flip_h()

◆ _flip_map_size()

void _flip_map_size ( const dt_image_orientation_t orientation,
const dt_iop_roi_t *const roi_in,
dt_iop_roi_t * roi_out )
static

Input rect -> output rect: a swap, or nothing.

Definition at line 250 of file flip.c.

References dt_iop_roi_t::height, ORIENTATION_SWAP_XY, and dt_iop_roi_t::width.

Referenced by _flip_geometry_map_size(), and modify_roi_out().

◆ _flip_resolve()

dt_image_orientation_t _flip_resolve ( dt_iop_module_t * self,
const dt_iop_flip_params_t *const p )
static

The orientation this module will actually apply.

ORIENTATION_NULL means "whatever the file says", which is resolved from the image's EXIF here rather than stored in params – so the resolution has to happen identically wherever the orientation is consumed, or a record would describe a rotation the pipe is not doing.

Definition at line 243 of file flip.c.

References dt_iop_module_t::dev, dt_image_orientation(), dt_develop_t::image_storage, ORIENTATION_NULL, and p.

Referenced by commit_params(), and geometry_record().

◆ _flip_v()

◆ adjust_aabb()

void adjust_aabb ( const int32_t * p,
int32_t * aabb )
static

Definition at line 92 of file flip.c.

References MAX, MIN, and p.

Referenced by modify_roi_in().

◆ aliases()

const char * aliases ( )

Definition at line 105 of file flip.c.

◆ backtransform()

void backtransform ( const int32_t * x,
int32_t * o,
const dt_image_orientation_t orientation,
int32_t iw,
int32_t ih )
static

Definition at line 203 of file flip.c.

References o, ORIENTATION_FLIP_X, ORIENTATION_FLIP_Y, ORIENTATION_SWAP_XY, and x.

Referenced by modify_roi_in().

◆ cleanup_global()

◆ cleanup_pipe()

void cleanup_pipe ( struct dt_iop_module_t * self,
dt_dev_pixelpipe_t * pipe,
dt_dev_pixelpipe_iop_t * piece )

Definition at line 548 of file flip.c.

References dt_free_align, piece, and pipe.

◆ commit_params()

void commit_params ( struct dt_iop_module_t * self,
dt_iop_params_t * p1,
dt_dev_pixelpipe_t * pipe,
dt_dev_pixelpipe_iop_t * piece )

Definition at line 448 of file flip.c.

References _flip_resolve(), d, ORIENTATION_NONE, p, piece, and pipe.

◆ default_colorspace()

int default_colorspace ( dt_iop_module_t * self,
dt_dev_pixelpipe_t * pipe,
const dt_dev_pixelpipe_iop_t * piece )

Definition at line 125 of file flip.c.

References IOP_CS_RGB, piece, and pipe.

◆ default_group()

int default_group ( )

Definition at line 110 of file flip.c.

References IOP_GROUP_TECHNICAL.

◆ description()

const char ** description ( struct dt_iop_module_t * self)

Definition at line 130 of file flip.c.

References dt_iop_set_description().

◆ distort_backtransform()

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 )

Definition at line 290 of file flip.c.

References __OMP_PARALLEL_FOR__, d, i, ORIENTATION_FLIP_X, ORIENTATION_FLIP_Y, ORIENTATION_SWAP_XY, piece, pipe, and x.

◆ distort_mask()

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 )

Definition at line 322 of file flip.c.

References bpp, d, dt_imageio_flip_buffers(), dt_iop_roi_t::height, in, out, piece, pipe, void(), and dt_iop_roi_t::width.

◆ distort_transform()

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 )

Definition at line 263 of file flip.c.

References __OMP_PARALLEL_FOR__, d, i, ORIENTATION_FLIP_X, ORIENTATION_FLIP_Y, ORIENTATION_SWAP_XY, piece, pipe, and x.

◆ do_rotate()

◆ flags()

int flags ( )

◆ geometry_record()

gboolean geometry_record ( dt_iop_module_t * self,
const void * params,
dt_geometry_record_t * record )

◆ get_corner()

void get_corner ( const int32_t * aabb,
const int i,
int32_t * p )
static

Definition at line 87 of file flip.c.

References i, k, and p.

Referenced by modify_roi_in().

◆ gui_cleanup()

void gui_cleanup ( struct dt_iop_module_t * self)

Definition at line 701 of file flip.c.

References dt_iop_module_t::gui, and dt_iop_module_gui_t::gui_data.

◆ gui_init()

◆ init_global()

◆ init_pipe()

void init_pipe ( struct dt_iop_module_t * self,
dt_dev_pixelpipe_t * pipe,
dt_dev_pixelpipe_iop_t * piece )

Definition at line 542 of file flip.c.

References dt_calloc_align(), piece, and pipe.

◆ init_presets()

◆ legacy_params()

int legacy_params ( dt_iop_module_t * self,
const void *const old_params,
const int old_version,
void * new_params,
const int new_version )

◆ merge_two_orientations()

dt_image_orientation_t merge_two_orientations ( dt_image_orientation_t raw_orientation,
dt_image_orientation_t user_orientation )
static

Merges raw camera orientation with user-specified orientation

Parameters
raw_orientationCamera/EXIF orientation (bits: Y=1, X=2, XY=4)
user_orientationUser rotation/flip request (same bit format)
Returns
Combined orientation for final image transformation

When user requests XY swap, we must swap the X/Y flip bits in raw orientation before applying the XOR combination. This ensures proper coordinate transformation.

Definition at line 145 of file flip.c.

References ORIENTATION_FLIP_X, ORIENTATION_FLIP_Y, and ORIENTATION_SWAP_XY.

Referenced by legacy_params(), and reload_defaults().

◆ modify_roi_in()

void modify_roi_in ( struct dt_iop_module_t * self,
const struct dt_dev_pixelpipe_t * pipe,
struct dt_dev_pixelpipe_iop_t * piece,
const dt_iop_roi_t * roi_out,
dt_iop_roi_t * roi_in )

◆ modify_roi_out()

void modify_roi_out ( struct dt_iop_module_t * self,
const struct dt_dev_pixelpipe_t * pipe,
struct dt_dev_pixelpipe_iop_t * piece,
dt_iop_roi_t * roi_out,
const dt_iop_roi_t * roi_in )

Definition at line 338 of file flip.c.

References _flip_map_size(), d, piece, and pipe.

◆ name()

const char * name ( )

Definition at line 100 of file flip.c.

◆ operation_tags()

int operation_tags ( )

Definition at line 115 of file flip.c.

References IOP_TAG_DISTORT.

◆ process()

int process ( struct 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 )

Definition at line 388 of file flip.c.

References bpp, d, dt_imageio_flip_buffers(), dt_iop_roi_t::height, ovoid, piece, pipe, and dt_iop_roi_t::width.

◆ process_cl()

◆ reload_defaults()

◆ rotate_ccw()

void rotate_ccw ( GtkWidget * widget,
dt_iop_module_t * self )
static

Definition at line 643 of file flip.c.

References do_rotate().

Referenced by gui_init().

◆ rotate_cw()

void rotate_cw ( GtkWidget * widget,
dt_iop_module_t * self )
static

Definition at line 639 of file flip.c.

References do_rotate().

Referenced by gui_init().

Variable Documentation

◆ _flip_geometry_vtable

const dt_geometry_vtable_t _flip_geometry_vtable
static
Initial value:
= {
.backtransform = _flip_geometry_backtransform,
}
static int _flip_geometry_backtransform(const void *data, const dt_geometry_record_t *const record, dt_geometry_chain_t *chain, float *points, size_t points_count)
Definition flip.c:493
static void _flip_geometry_map_size(const void *data, const dt_iop_roi_t *const in, dt_iop_roi_t *out)
Definition flip.c:466
static int _flip_geometry_transform(const void *data, const dt_geometry_record_t *const record, dt_geometry_chain_t *chain, float *points, size_t points_count)
Definition flip.c:471

Definition at line 515 of file flip.c.

Referenced by geometry_record().