Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
rawprepare.c File Reference
#include "widgets/bauhaus.h"
#include "system/macros.h"
#include "system/openmp.h"
#include "system/target_clones.h"
#include "system/mem_alloc.h"
#include "common/logging.h"
#include "common/module_versioning.h"
#include "database/database.h"
#include "imageio/imageio_rawspeed.h"
#include "common/opencl.h"
#include "common/imagebuf.h"
#include "common/image.h"
#include "develop/geometry/geometry.h"
#include "develop/imageop.h"
#include "develop/imageop_gui.h"
#include "caches/image_cache.h"
#include "gui/presets.h"
#include "iop/iop_api.h"
#include "common/dng_opcode.h"
#include <gtk/gtk.h>
#include <stdint.h>
#include <stdlib.h>
#include "widgets/label.h"
#include "control/signal.h"
+ Include dependency graph for rawprepare.c:

Go to the source code of this file.

Data Structures

struct  dt_iop_rawprepare_params_t
 
struct  dt_iop_rawprepare_gui_data_t
 
struct  dt_iop_rawprepare_data_t
 
struct  dt_iop_rawprepare_global_data_t
 
struct  dt_iop_rawprepare_geometry_t
 

Typedefs

typedef enum dt_iop_rawprepare_flat_field_t dt_iop_rawprepare_flat_field_t
 
typedef struct dt_iop_rawprepare_params_t dt_iop_rawprepare_params_t
 
typedef struct dt_iop_rawprepare_gui_data_t dt_iop_rawprepare_gui_data_t
 
typedef struct dt_iop_rawprepare_data_t dt_iop_rawprepare_data_t
 
typedef struct dt_iop_rawprepare_global_data_t dt_iop_rawprepare_global_data_t
 
typedef struct dt_iop_rawprepare_geometry_t dt_iop_rawprepare_geometry_t
 

Enumerations

enum  dt_iop_rawprepare_flat_field_t {
  FLAT_FIELD_OFF = 0 ,
  FLAT_FIELD_EMBEDDED = 1
}
 

Functions

const char * name ()
 
int operation_tags ()
 
int flags ()
 
int default_group ()
 
int default_colorspace (dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
 
int legacy_params (dt_iop_module_t *self, const void *const old_params, const int old_version, void *new_params, const int new_version)
 
const char ** description (struct dt_iop_module_t *self)
 
void init_presets (dt_iop_module_so_t *self)
 
static __attribute__ ((always_inline))
 
static void _update_output_cfa_descriptor (const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const dt_iop_roi_t *const roi_in, dt_iop_buffer_dsc_t *dsc)
 
static void _rawprepare_offset (const int32_t crop_x, const int32_t crop_y, const double scale, double *dx, double *dy)
 The translation the trim applies, at scale.
 
static void _rawprepare_map_size (const dt_iop_rawprepare_geometry_t *const g, const dt_iop_roi_t *const roi_in, dt_iop_roi_t *roi_out)
 Input rect -> output rect, shrunk by the total margin at the input's own scale.
 
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 (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)
 
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)
 
void output_format (dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece, dt_iop_buffer_dsc_t *dsc)
 
void input_format (dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece, dt_iop_buffer_dsc_t *dsc)
 
void autoset (struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const void *input)
 RawSpeed tends to under-evaluate the white point of RAW images, which leads to RGB values > 1 after normalization. We sanitize it here. It does the same for black point, which leads to negative RGB values, but detecting the min RGB here is not more robust to figure out black level per channel than RawSpeed reading black pixels (does it though ?).
 
__DT_CLONE_TARGETS__ 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 (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)
 
static int image_is_normalized (const dt_image_t *const image)
 
static gboolean image_set_rawcrops (const int32_t imgid, int dx, int dy)
 
static gboolean _validate_gain_maps (const dt_image_t *const image, dt_dng_gain_map_t **gainmaps_out)
 
gboolean check_gain_maps (const int32_t imgid)
 
static void _free_owned_gainmaps (dt_iop_rawprepare_data_t *d)
 
static gboolean _own_gainmaps (const int32_t imgid, dt_iop_rawprepare_data_t *d)
 
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)
 
static void _rawprepare_geometry_map_size (const void *data, const dt_iop_roi_t *const in, dt_iop_roi_t *out)
 
static int _rawprepare_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 _rawprepare_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 cleanup_pipe (dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
static gboolean enable (const dt_image_t *image)
 
gboolean force_enable (struct dt_iop_module_t *self, const gboolean current_state)
 
void reload_defaults (dt_iop_module_t *self)
 
void init_global (dt_iop_module_so_t *self)
 
void cleanup_global (dt_iop_module_so_t *self)
 
void gui_update (dt_iop_module_t *self)
 Refresh GUI controls from current params and configuration.
 
void gui_changed (dt_iop_module_t *self, GtkWidget *w, void *previous)
 
void gui_init (dt_iop_module_t *self)
 

Variables

static const dt_geometry_vtable_t _rawprepare_geometry_vtable
 
const gchar * black_label []
 

Typedef Documentation

◆ dt_iop_rawprepare_data_t

◆ dt_iop_rawprepare_flat_field_t

◆ dt_iop_rawprepare_geometry_t

◆ dt_iop_rawprepare_global_data_t

◆ dt_iop_rawprepare_gui_data_t

◆ dt_iop_rawprepare_params_t

Enumeration Type Documentation

◆ dt_iop_rawprepare_flat_field_t

Enumerator
FLAT_FIELD_OFF 
FLAT_FIELD_EMBEDDED 

Definition at line 69 of file rawprepare.c.

Function Documentation

◆ __attribute__()

static __attribute__ ( (always_inline)  )
inlinestatic

Definition at line 206 of file rawprepare.c.

References dt_iop_roi_t::scale, and value.

◆ _free_owned_gainmaps()

static void _free_owned_gainmaps ( dt_iop_rawprepare_data_t d)
static

Definition at line 865 of file rawprepare.c.

References d, and i.

Referenced by _own_gainmaps(), cleanup_pipe(), and commit_params().

◆ _own_gainmaps()

static gboolean _own_gainmaps ( const int32_t  imgid,
dt_iop_rawprepare_data_t d 
)
static

◆ _rawprepare_geometry_backtransform()

static int _rawprepare_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 1011 of file rawprepare.c.

References _rawprepare_offset(), g, i, dt_geometry_record_t::in, dt_iop_roi_t::scale, and x.

◆ _rawprepare_geometry_map_size()

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

Definition at line 990 of file rawprepare.c.

References _rawprepare_map_size(), and out.

◆ _rawprepare_geometry_transform()

static int _rawprepare_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 995 of file rawprepare.c.

References _rawprepare_offset(), g, i, dt_geometry_record_t::in, dt_iop_roi_t::scale, and x.

◆ _rawprepare_map_size()

static void _rawprepare_map_size ( const dt_iop_rawprepare_geometry_t *const  g,
const dt_iop_roi_t *const  roi_in,
dt_iop_roi_t roi_out 
)
static

Input rect -> output rect, shrunk by the total margin at the input's own scale.

Definition at line 293 of file rawprepare.c.

References g, dt_iop_roi_t::height, dt_iop_roi_t::scale, dt_iop_roi_t::width, x, dt_iop_roi_t::x, and dt_iop_roi_t::y.

Referenced by _rawprepare_geometry_map_size(), and modify_roi_out().

◆ _rawprepare_offset()

static void _rawprepare_offset ( const int32_t  crop_x,
const int32_t  crop_y,
const double  scale,
double dx,
double dy 
)
static

The translation the trim applies, at scale.

Definition at line 285 of file rawprepare.c.

References double().

Referenced by _rawprepare_geometry_backtransform(), _rawprepare_geometry_transform(), distort_backtransform(), and distort_transform().

◆ _update_output_cfa_descriptor()

static void _update_output_cfa_descriptor ( const dt_dev_pixelpipe_t pipe,
const dt_dev_pixelpipe_iop_t piece,
const dt_iop_roi_t *const  roi_in,
dt_iop_buffer_dsc_t dsc 
)
static

XTrans doc: XTrans sensors work by color filter tiles of 6x6 pixels, which are expected to start at the top-left corner of the image. When cropping images, depending on the number of trimmed pixels, we generally cut in the middle of the 6x6 pattern. So this corrects the phase shift to account for the current trimming, aka we reorder the filter coefficients for the current phase shift.

Definition at line 212 of file rawprepare.c.

References d, dt_dev_pixelpipe_iop_t::data, dt_dev_pixelpipe_t::dev, dt_image_t::dsc, DT_DEBUG_DEMOSAIC, DT_DEV_PIXELPIPE_EXPORT, DT_DEV_PIXELPIPE_FULL, DT_DEV_PIXELPIPE_PREVIEW, DT_DEV_PIXELPIPE_THUMBNAIL, dt_print(), dt_rawspeed_crop_dcraw_filters(), dt_iop_buffer_dsc_t::filters, i, dt_develop_t::image_storage, IS_NULL_PTR, dt_iop_roi_t::scale, dt_dev_pixelpipe_t::type, dt_iop_roi_t::x, dt_iop_buffer_dsc_t::xtrans, and dt_iop_roi_t::y.

Referenced by modify_roi_in(), modify_roi_out(), and output_format().

◆ _validate_gain_maps()

static gboolean _validate_gain_maps ( const dt_image_t *const  image,
dt_dng_gain_map_t **  gainmaps_out 
)
static

◆ autoset()

void autoset ( struct dt_iop_module_t self,
const struct dt_dev_pixelpipe_t pipe,
const struct dt_dev_pixelpipe_iop_t piece,
const void input 
)

RawSpeed tends to under-evaluate the white point of RAW images, which leads to RGB values > 1 after normalization. We sanitize it here. It does the same for black point, which leads to negative RGB values, but detecting the min RGB here is not more robust to figure out black level per channel than RawSpeed reading black pixels (does it though ?).

Parameters
self
pipe
piece
input

Definition at line 432 of file rawprepare.c.

References __OMP_PARALLEL_FOR__, dt_iop_buffer_dsc_t::channels, dt_iop_buffer_dsc_t::datatype, dt_dev_pixelpipe_t::dev, dt_dev_pixelpipe_iop_t::dsc_in, dt_iop_buffer_dsc_t::filters, dt_iop_roi_t::height, i, dt_develop_t::image_storage, max, MAX, p, dt_iop_module_t::params, dt_image_t::raw_white_point, dt_dev_pixelpipe_iop_t::roi_in, dt_dev_pixelpipe_iop_t::roi_out, TYPE_UINT16, dt_iop_roi_t::width, dt_iop_roi_t::x, and dt_iop_roi_t::y.

◆ check_gain_maps()

gboolean check_gain_maps ( const int32_t  imgid)

◆ cleanup_global()

◆ cleanup_pipe()

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

Definition at line 1053 of file rawprepare.c.

References _free_owned_gainmaps(), d, dt_dev_pixelpipe_iop_t::data, and dt_free_align.

◆ commit_params()

◆ default_colorspace()

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

◆ default_group()

int default_group ( )

Definition at line 139 of file rawprepare.c.

References IOP_GROUP_TECHNICAL.

◆ description()

const char ** description ( struct dt_iop_module_t self)

Definition at line 177 of file rawprepare.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 
)

◆ 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 352 of file rawprepare.c.

References dt_iop_copy_image_roi(), out, TRUE, and void().

◆ 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 
)

◆ enable()

static gboolean enable ( const dt_image_t image)
static

Definition at line 1062 of file rawprepare.c.

References dt_image_needs_rawprepare(), and image_is_normalized().

Referenced by force_enable(), and reload_defaults().

◆ flags()

◆ force_enable()

gboolean force_enable ( struct dt_iop_module_t self,
const gboolean  current_state 
)

◆ geometry_record()

◆ gui_changed()

◆ gui_init()

◆ gui_update()

◆ image_is_normalized()

static int image_is_normalized ( const dt_image_t *const  image)
static

◆ image_set_rawcrops()

static gboolean image_set_rawcrops ( const int32_t  imgid,
int  dx,
int  dy 
)
static

◆ init_global()

◆ init_pipe()

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

◆ init_presets()

◆ input_format()

void input_format ( dt_iop_module_t self,
dt_dev_pixelpipe_t pipe,
dt_dev_pixelpipe_iop_t piece,
dt_iop_buffer_dsc_t dsc 
)

◆ 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 
)

Definition at line 151 of file rawprepare.c.

References FLAT_FIELD_OFF, height, n, width, and x.

◆ modify_roi_in()

◆ modify_roi_out()

◆ name()

const char * name ( )

Definition at line 123 of file rawprepare.c.

◆ operation_tags()

int operation_tags ( )

Definition at line 128 of file rawprepare.c.

References IOP_TAG_DISTORT.

◆ output_format()

◆ process()

◆ process_cl()

◆ reload_defaults()

Variable Documentation

◆ _rawprepare_geometry_vtable

const dt_geometry_vtable_t _rawprepare_geometry_vtable
static
Initial value:
= {
}
static int _rawprepare_geometry_transform(const void *data, const dt_geometry_record_t *const record, dt_geometry_chain_t *chain, float *points, size_t points_count)
Definition rawprepare.c:995
static void _rawprepare_geometry_map_size(const void *data, const dt_iop_roi_t *const in, dt_iop_roi_t *out)
Definition rawprepare.c:990
static int _rawprepare_geometry_backtransform(const void *data, const dt_geometry_record_t *const record, dt_geometry_chain_t *chain, float *points, size_t points_count)

Definition at line 1027 of file rawprepare.c.

Referenced by geometry_record().

◆ black_label

const gchar* black_label[]
Initial value:
= { N_("black level 0"),
N_("black level 1"),
N_("black level 2"),
N_("black level 3") }

Definition at line 1176 of file rawprepare.c.

Referenced by gui_init().