Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
heal.c File Reference
#include "system/macros.h"
#include "system/openmp.h"
#include "system/mem_alloc.h"
#include "system/simd.h"
#include "caches/pixelpipe_cache_alloc.h"
#include "develop/imageop.h"
#include "math/openmp_maths.h"
#include "heal.h"
+ Include dependency graph for heal.c:

Go to the source code of this file.

Data Structures

struct  _aligned_pixel
 

Macros

#define DT_HEAL_SQRT_OFFSET   1e-3f
 

Typedefs

typedef struct _aligned_pixel _aligned_pixel
 

Functions

static float _heal_encode (const float value, const size_t c, const dt_heal_domain_t domain)
 
static float _heal_decode (const float src, const float correction, const size_t c, const dt_heal_domain_t domain)
 
static void _heal_sub (const float *const top_buffer, const float *const bottom_buffer, float *const restrict red_buffer, float *const restrict black_buffer, const size_t width, const size_t height, const dt_heal_domain_t domain)
 
static void _heal_add (const float *const restrict red_buffer, const float *const black_buffer, const float *const restrict second_buffer, float *const restrict result_buffer, const size_t width, const size_t height, const dt_heal_domain_t domain)
 
static float _heal_laplace_iteration (float *const restrict active_pixels, const float *const restrict neighbor_pixels, const size_t height, const size_t width, const unsigned *const restrict runs, const size_t num_runs, const size_t start_parity, const float w)
 
static size_t _collect_color_runs (const float *const restrict mask, const size_t start_index, size_t start, const size_t width, unsigned *const restrict runs, size_t count, size_t *nmask)
 
static void collect_runs (const int start, const float *const restrict mask, const size_t width, const size_t height, const size_t subwidth, unsigned *const restrict runs, size_t *count, size_t *nmask)
 
static void _heal_laplace_loop (float *const restrict red_pixels, float *const restrict black_pixels, const size_t width, const size_t height, const float *const restrict mask, const int max_iter)
 
void dt_heal (const float *const src_buffer, float *dest_buffer, const float *const mask_buffer, const int width, const int height, const int ch, const dt_heal_solver_t solver)
 
void dt_heal_init_cl_global (void)
 
void dt_heal_free_cl_global (void)
 
heal_params_cl_t * dt_heal_init_cl (const int devid)
 
void dt_heal_free_cl (heal_params_cl_t *p)
 
cl_int dt_heal_cl (heal_params_cl_t *p, cl_mem dev_src, cl_mem dev_dest, const float *const mask_buffer, const int width, const int height, const dt_heal_solver_t solver)
 

Variables

static dt_heal_cl_global_t * _heal_cl_global = NULL
 

Macro Definition Documentation

◆ DT_HEAL_SQRT_OFFSET

#define DT_HEAL_SQRT_OFFSET   1e-3f

Definition at line 63 of file heal.c.

Typedef Documentation

◆ _aligned_pixel

Function Documentation

◆ _collect_color_runs()

static size_t _collect_color_runs ( const float *const restrict  mask,
const size_t  start_index,
size_t  start,
const size_t  width,
unsigned *const restrict  runs,
size_t  count,
size_t *  nmask 
)
static

Definition at line 268 of file heal.c.

References FALSE, TRUE, and width.

Referenced by collect_runs().

◆ _heal_add()

static void _heal_add ( const float *const restrict  red_buffer,
const float *const  black_buffer,
const float *const restrict  second_buffer,
float *const restrict  result_buffer,
const size_t  width,
const size_t  height,
const dt_heal_domain_t  domain 
)
static

Definition at line 131 of file heal.c.

References __OMP_PARALLEL_FOR__, _heal_decode(), for_each_channel, height, row, and width.

Referenced by dt_heal().

◆ _heal_decode()

static float _heal_decode ( const float  src,
const float  correction,
const size_t  c,
const dt_heal_domain_t  domain 
)
inlinestatic

Definition at line 73 of file heal.c.

References _heal_encode(), DT_HEAL_DOMAIN_SQRT, and DT_HEAL_SQRT_OFFSET.

Referenced by _heal_add().

◆ _heal_encode()

static float _heal_encode ( const float  value,
const size_t  c,
const dt_heal_domain_t  domain 
)
inlinestatic

Definition at line 65 of file heal.c.

References DT_HEAL_DOMAIN_SQRT, DT_HEAL_SQRT_OFFSET, and value.

Referenced by _heal_decode(), and _heal_sub().

◆ _heal_laplace_iteration()

static float _heal_laplace_iteration ( float *const restrict  active_pixels,
const float *const restrict  neighbor_pixels,
const size_t  height,
const size_t  width,
const unsigned *const restrict  runs,
const size_t  num_runs,
const size_t  start_parity,
const float  w 
)
static

Definition at line 180 of file heal.c.

References __OMP_PARALLEL_FOR__, copy_pixel(), for_each_channel, height, i, row, _aligned_pixel::v, and width.

Referenced by _heal_laplace_loop().

◆ _heal_laplace_loop()

static void _heal_laplace_loop ( float *const restrict  red_pixels,
float *const restrict  black_pixels,
const size_t  width,
const size_t  height,
const float *const restrict  mask,
const int  max_iter 
)
static

◆ _heal_sub()

static void _heal_sub ( const float *const  top_buffer,
const float *const  bottom_buffer,
float *const restrict  red_buffer,
float *const restrict  black_buffer,
const size_t  width,
const size_t  height,
const dt_heal_domain_t  domain 
)
static

Definition at line 86 of file heal.c.

References __OMP_PARALLEL_FOR__, _heal_encode(), for_each_channel, height, row, and width.

Referenced by dt_heal().

◆ collect_runs()

static void collect_runs ( const int  start,
const float *const restrict  mask,
const size_t  width,
const size_t  height,
const size_t  subwidth,
unsigned *const restrict  runs,
size_t *  count,
size_t *  nmask 
)
static

Definition at line 326 of file heal.c.

References _collect_color_runs(), height, row, and width.

Referenced by _heal_laplace_loop().

◆ dt_heal()

void dt_heal ( const float *const  src_buffer,
float *  dest_buffer,
const float *const  mask_buffer,
const int  width,
const int  height,
const int  ch,
const dt_heal_solver_t  solver 
)

Heal dest_buffer using src_buffer as a reference and mask_buffer to define the area to be healed. The 3 buffers must have the same size, but mask_buffer is 1 channel and is tested for != 0.f.

Definition at line 410 of file heal.c.

References _heal_add(), _heal_laplace_loop(), _heal_sub(), ch, cleanup(), dt_heal_solver_t::domain, dt_pixelpipe_cache_alloc_align_float_cache, dt_pixelpipe_cache_free_align, height, IS_NULL_PTR, dt_heal_solver_t::max_iter, and width.

Referenced by _retouch_heal(), and dt_heal_cl().

◆ dt_heal_cl()

cl_int dt_heal_cl ( heal_params_cl_t *  p,
cl_mem  dev_src,
cl_mem  dev_dest,
const float *const  mask_buffer,
const int  width,
const int  height,
const dt_heal_solver_t  solver 
)

◆ dt_heal_free_cl()

void dt_heal_free_cl ( heal_params_cl_t *  p)

Definition at line 477 of file heal.c.

References dt_free, IS_NULL_PTR, and p.

Referenced by _retouch_heal_cl().

◆ dt_heal_free_cl_global()

void dt_heal_free_cl_global ( void  )

Definition at line 456 of file heal.c.

References _heal_cl_global, dt_free, g, and IS_NULL_PTR.

Referenced by dt_opencl_cleanup().

◆ dt_heal_init_cl()

heal_params_cl_t * dt_heal_init_cl ( const int  devid)

Definition at line 465 of file heal.c.

References _heal_cl_global, heal_params_cl_t::global, IS_NULL_PTR, and p.

Referenced by _retouch_heal_cl().

◆ dt_heal_init_cl_global()

void dt_heal_init_cl_global ( void  )

Definition at line 449 of file heal.c.

References _heal_cl_global, and g.

Referenced by dt_opencl_init().

Variable Documentation

◆ _heal_cl_global

dt_heal_cl_global_t* _heal_cl_global = NULL
static

Definition at line 447 of file heal.c.

Referenced by dt_heal_free_cl_global(), dt_heal_init_cl(), and dt_heal_init_cl_global().