85 return _(
"censorize");
92 _(
"linear or non-linear, RGB, scene-referred"),
93 _(
"frequential, RGB"),
94 _(
"special, RGB, scene-referred"));
117 for(
size_t j = 0; j <
width; j++)
126 const size_t index = (
i *
width + j) * 4;
127 float *
const restrict pix_out = __builtin_assume_aligned(output + index, 16);
128 const float norm = pix_out[1];
131 const float epsilon = gaussian_noise(norm,
noise * norm,
i % 2 || j % 2,
state) / norm;
134 for(
size_t c = 0; c < 3; c++) pix_out[c] = fmaxf(pix_out[c] * epsilon, 0.f);
147 const float *
const restrict in =
DT_IS_ALIGNED((
const float *
const restrict)ivoid);
158 const float sigma_1 = data->
radius_1 / module_scale;
159 const float sigma_2 = data->
radius_2 / module_scale;
160 const size_t pixel_radius = data->
pixelate / module_scale;
163 const float scale = fmaxf(module_scale, 1.f);
167 for(
int k = 0;
k < 4;
k++)
169 RGBmax[
k] = INFINITY;
173 const float *restrict input = in;
174 float *restrict output =
out;
194 if(pixel_radius != 0)
196 const size_t pixels_x =
width / (2 * pixel_radius);
197 const size_t pixels_y =
height / (2 * pixel_radius);
199 for(
size_t j = 0; j < pixels_y + 1; j++)
200 for(
size_t i = 0;
i < pixels_x + 1;
i++)
203 const point_t tl = { CLAMP(2 * pixel_radius *
i, 0,
width - 1),
204 CLAMP(2 * pixel_radius * j, 0,
height - 1) };
206 const point_t cc = { CLAMP(tl.
x + pixel_radius, 0,
width - 1),
207 CLAMP(tl.
y + pixel_radius, 0,
height - 1) };
209 const point_t br = { CLAMP(cc.
x + pixel_radius, 0,
width - 1),
210 CLAMP(cc.
y + pixel_radius, 0,
height - 1) };
213 const point_t box[5] = { tl, { br.
x, tl.
y }, cc, { tl.
x, br.
y }, br };
217 for(
size_t k = 0;
k < 5;
k++)
219 const float *
const restrict pix_in = __builtin_assume_aligned(input + (
width * box[
k].y + box[
k].
x) * 4, 16);
221 RGB[c] += pix_in[c] / 5.f;
225 for(
size_t jj = tl.
y; jj < br.
y; jj++)
226 for(
size_t ii = tl.
x; ii < br.
x; ii++)
228 float *
const restrict pix_out = __builtin_assume_aligned(output + (jj *
width + ii) * 4, 16);
281 const int devid = pipe->devid;
283 const int width = roi_in->width;
284 const int height = roi_in->height;
285 const int channels = piece->dsc_in.channels;
287 const float radius_1 = fmax(0.1f,
d->radius_1);
288 const float sigma = radius_1 * roi_in->scale;
289 const float saturation =
d->saturation;
290 const int order =
d->order;
291 const int unbound =
d->unbound;
293 cl_mem dev_cm = NULL;
294 cl_mem dev_ccoeffs = NULL;
295 cl_mem dev_lm = NULL;
296 cl_mem dev_lcoeffs = NULL;
297 cl_mem dev_tmp = NULL;
302 float RGBmax[] = { 100.0f, 128.0f, 128.0f, 1.0f };
303 float RGBmin[] = { 0.0f, -128.0f, -128.0f, 0.0f };
307 for(
int k = 0;
k < 4;
k++) RGBmax[
k] = INFINITY;
308 for(
int k = 0;
k < 4;
k++) RGBmin[
k] = -INFINITY;
316 if(err != CL_SUCCESS)
goto error;
324 const float detail = -1.0f;
329 if(err != CL_SUCCESS)
goto error;
331 if(err != CL_SUCCESS)
goto error;
333 if(err != CL_SUCCESS)
goto error;
353 size_t origin[] = { 0, 0, 0 };
356 if(err != CL_SUCCESS)
goto error;
371 if(err != CL_SUCCESS)
goto error;
410 const int program = 6;
438 gtk_widget_set_tooltip_text(
g->radius_1, _(
"radius of gaussian blur before pixellation"));
439 gtk_widget_set_tooltip_text(
g->radius_2, _(
"radius of gaussian blur after pixellation"));
440 gtk_widget_set_tooltip_text(
g->pixelate, _(
"radius of the intermediate pixellation"));
441 gtk_widget_set_tooltip_text(
g->noise, _(
"amount of noise to add at the end"));
void cleanup_global(dt_iop_module_so_t *module)
void init_global(dt_iop_module_so_t *module)
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)
static void error(char *msg)
void dt_bilateral_free_cl(dt_bilateral_cl_t *b)
cl_int dt_bilateral_slice_cl(dt_bilateral_cl_t *b, cl_mem in, cl_mem out, const float detail)
dt_bilateral_cl_t * dt_bilateral_init_cl(const int devid, const int width, const int height, const float sigma_s, const float sigma_r)
cl_int dt_bilateral_blur_cl(dt_bilateral_cl_t *b)
cl_int dt_bilateral_splat_cl(dt_bilateral_cl_t *b, cl_mem in)
const char ** description(struct dt_iop_module_t *self)
__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)
static __DT_CLONE_TARGETS__ void make_noise(float *const output, const float noise, const size_t width, const size_t height)
void gui_init(struct dt_iop_module_t *self)
int default_colorspace(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
dt_iop_censorize_params_t dt_iop_censorize_data_t
const dt_colormatrix_t dt_aligned_pixel_t out
static dt_aligned_pixel_t RGB
void dt_print(dt_debug_thread_t thread, const char *msg,...)
#define DT_MODULE_INTROSPECTION(MODVER, PARAMSTYPE)
#define dt_pixelpipe_cache_free_align(mem)
#define dt_pixelpipe_cache_alloc_align_float(pixels, pipe)
#define __DT_CLONE_TARGETS__
#define for_four_channels(_var,...)
#define __OMP_PARALLEL_FOR__(...)
#define __OMP_PARALLEL_FOR_SIMD__(...)
#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 unsigned int splitmix32(const unsigned long seed)
static float xoshiro128plus(uint state[4])
@ DT_DEV_PIXELPIPE_DISPLAY_MASK
void dt_gaussian_free(dt_gaussian_t *g)
void dt_gaussian_free_cl(dt_gaussian_cl_t *g)
cl_int dt_gaussian_blur_cl(dt_gaussian_cl_t *g, cl_mem dev_in, cl_mem dev_out)
void dt_gaussian_blur_4c(dt_gaussian_t *g, const float *const in, float *const out)
dt_gaussian_cl_t * dt_gaussian_init_cl(const int devid, const int width, const int height, const int channels, const float *max, const float *min, const float sigma, const int order)
dt_gaussian_t * dt_gaussian_init(const int width, const int height, const int channels, const float *max, const float *min, const float sigma, const int order)
static __DT_CLONE_TARGETS__ void dt_simd_memcpy(const float *const __restrict__ in, float *const __restrict__ out, const size_t num_elem)
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)
float dt_dev_get_module_scale(const dt_dev_pixelpipe_t *const pipe, const dt_iop_roi_t *const roi_in)
@ IOP_FLAGS_INCLUDE_IN_STYLES
@ IOP_FLAGS_SUPPORTS_BLENDING
#define IOP_GUI_ALLOC(module)
GtkWidget * dt_bauhaus_slider_from_params(dt_iop_module_t *self, const char *param)
float *const restrict const size_t k
float *const restrict const size_t const size_t ch
float dt_aligned_pixel_t[4]
int dt_opencl_enqueue_kernel_2d(const int dev, const int kernel, const size_t *sizes)
void * dt_opencl_alloc_device(const int devid, const int width, const int height, const int bpp)
int dt_opencl_create_kernel(const int prog, const char *name)
void * dt_opencl_copy_host_to_device_constant(const int devid, const size_t size, void *host)
int dt_opencl_enqueue_copy_image(const int devid, cl_mem src, cl_mem dst, size_t *orig_src, size_t *orig_dst, size_t *region)
void dt_opencl_free_kernel(const int kernel)
int dt_opencl_set_kernel_arg(const int dev, const int kernel, const int num, const size_t size, const void *arg)
void * dt_opencl_copy_host_to_device(const int devid, void *host, const int width, const int height, const int bpp)
void dt_opencl_release_mem_object(cl_mem mem)
struct _GtkWidget GtkWidget
const float uint32_t state[4]
struct dt_iop_module_t *void * data
dt_iop_global_data_t * data
Region of interest passed through the pixelpipe.
void tiling_callback(struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, struct dt_develop_tiling_t *tiling)